Changeset 22204


Ignore:
Timestamp:
Apr 14, 2013, 4:11:39 PM (7 years ago)
Author:
Eric
Message:

Version 2.5.9:
Bug fixed : Adding accounts from FluxBB to Piwigo was not working
Rewrite plugin admin panel URL

Location:
extensions/Register_FluxBB
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/Register_FluxBB/admin/admin.php

    r22092 r22204  
    142142if ( isset($_POST['Synchro']))
    143143{
    144   $page_Register_FluxBB_admin = get_admin_plugin_menu_link(__FILE__);
    145  
    146144  $msg_error_PWG_Dup = '';
    147145  $msg_error_FluxBB_Dup = '';
     
    199197      $msg_error_FluxBB_Dup .= ' <a href="';
    200198
    201       $msg_error_FluxBB_Dup .= add_url_params($page_Register_FluxBB_admin, array(
     199      $msg_error_FluxBB_Dup .= add_url_params(REGFLUXBB_ADMIN, array(
    202200        'action' => 'del_user',
    203201        'id' => $subrow['id'],
     
    428426      $msg_error_FluxBB2PWG .= '<br>'.l10n('Error_FluxBB2PWG').stripslashes($row['username']).' ('.$row['email'].')';
    429427      $msg_error_FluxBB2PWG .= ' <a href="';
    430       $msg_error_FluxBB2PWG .= add_url_params($page_Register_FluxBB_admin, array(
     428      $msg_error_FluxBB2PWG .= add_url_params(REGFLUXBB_ADMIN, array(
    431429          'action' => 'del_user',
    432430          'id' => $row['id'],
     
    481479{
    482480  global $page, $conf, $errors;
    483 
    484   $page_Register_FluxBB_admin = get_admin_plugin_menu_link(__FILE__);
    485481
    486482  $conf_Register_FluxBB = unserialize($conf['Register_FluxBB']);
     
    509505    $msg_error_PWG_Dup .= '<br>'.l10n('Error_PWG_Dup').$row['nbr_dup'].' x '.stripslashes($row['username']);
    510506
     507  // Display OK message or build errors
    511508  if ($msg_error_PWG_Dup == '')
    512509    array_push($page['infos'], l10n('Audit_PWG_Dup').'<br>'.l10n('Audit_OK'));
    513510  else
    514511    $msg_error_PWG_Dup = l10n('Audit_PWG_Dup').$msg_error_PWG_Dup.'<br>'.l10n('Advise_PWG_Dup');
    515  
     512
    516513
    517514// Check duplicate accounts in FluxBB users table
     
    539536    {
    540537      $msg_error_FluxBB_Dup .= '<br>id:'.$subrow['id'].'='.stripslashes($subrow['username']).' ('.$subrow['email'].')';
    541  
     538
     539      // Action : Delete duplicate user from FluxBB
    542540      $msg_error_FluxBB_Dup .= ' <a href="';
    543      
    544       $msg_error_FluxBB_Dup .= add_url_params($page_Register_FluxBB_admin, array(
     541      $msg_error_FluxBB_Dup .= add_url_params(REGFLUXBB_ADMIN, array(
    545542        'action' => 'del_user',
    546543        'id' => $subrow['id'],
    547544      ));
    548        
    549545      $msg_error_FluxBB_Dup .= '" title="'.l10n('Del_User').stripslashes($subrow['username']).'"';
    550        
    551546      $msg_error_FluxBB_Dup .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
    552        
    553547      $msg_error_FluxBB_Dup .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').$subrow['username'].'" /></a>';
    554548    }
    555549  }
    556550
     551  // Display OK message or build errors
    557552  if ($msg_error_FluxBB_Dup == '')
    558553    array_push($page['infos'], l10n('Audit_FluxBB_Dup').'<br>'.l10n('Audit_OK'));
     
    587582    $msg_error_Link_Break .= '<br>'.l10n('Error_Link_Break').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')';
    588583
     584    // Action : Create new link
    589585    $msg_error_Link_Break .= ' <a href="';
    590 
    591     $msg_error_Link_Break .= add_url_params($page_Register_FluxBB_admin, array(
     586    $msg_error_Link_Break .= add_url_params(REGFLUXBB_ADMIN, array(
    592587      'action'   => 'new_link',
    593588      'pwg_id' => $row['pwg_id'],
    594589      'bb_id' => $row['bb_id'],
    595590    ));
    596 
    597591    $msg_error_Link_Break .= '" title="'.l10n('New_Link').stripslashes($row['pwg_user']).'"';
    598 
    599592    $msg_error_Link_Break .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
    600 
    601593    $msg_error_Link_Break .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_break.png" alt="'.l10n('New_Link').stripslashes($row['pwg_user']).'" /></a>';
    602594  }
    603595
     596  // Display OK message or build errors
    604597  if ($msg_error_Link_Break == '')
    605598    array_push($page['infos'], l10n('Audit_Link_Break').'<br>'.l10n('Audit_OK'));
     
    625618    $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Del').stripslashes($row['pwg_user']).' ('.$row['pwg_mail'].')'.' -- '.stripslashes($row['bb_user']).' ('.$row['bb_mail'].')';
    626619
     620    // Action : Delete obsolete links
    627621    $msg_error_Link_Bad .= ' <a href="';
    628  
    629     $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array(
     622    $msg_error_Link_Bad .= add_url_params(REGFLUXBB_ADMIN, array(
    630623      'action'   => 'link_del',
    631624      'pwg_id' => $row['pwg_id'],
    632625      'bb_id'  => $row['bb_id'],
    633626    ));
    634 
    635627    $msg_error_Link_Bad .= '" title="'.l10n('Link_Del').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'"';
    636 
    637628    $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
    638 
    639629    $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_delete.png" alt="'.l10n('Link_Del').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'" /></a>';
    640630
     631    // Action : Synch users data
    641632    $msg_error_Link_Bad .= ' -- <a href="';
    642 
    643     $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array(
     633    $msg_error_Link_Bad .= add_url_params(REGFLUXBB_ADMIN, array(
    644634      'action' => 'sync_user',
    645635      'username' => stripslashes($row['pwg_user']),
    646636    ));
    647 
    648637    $msg_error_Link_Bad .= '" title="'.l10n('Sync_User').stripslashes($row['pwg_user']).' --> '.stripslashes($row['bb_user']).'"';
    649 
    650638    $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
    651 
    652639    $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/arrow_switch.png" alt="'.l10n('Sync_User').stripslashes($row['pwg_user']).' --> '.stripslashes($row['bb_user']).'" /></a>';
    653640  }
     
    675662    $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Dead').$Compteur['nbr_dead'];
    676663
     664    // Action : Repair dead links
    677665    $msg_error_Link_Bad .= ' <a href="';
    678 
    679     $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array(
     666    $msg_error_Link_Bad .= add_url_params(REGFLUXBB_ADMIN, array(
    680667      'action'   => 'link_dead',
    681668    ));
    682 
    683669    $msg_error_Link_Bad .= '" title="'.l10n('Link_Dead').$Compteur['nbr_dead'].'"';
    684 
    685670    $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
    686 
    687671    $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_delete.png" alt="'.l10n('Link_Dead').$Compteur['nbr_dead'].'" /></a>';
    688672  }
     
    707691    $msg_error_Link_Bad .= '<br>'.l10n('Error_Link_Dup').$row['nbr_dup'].' = '.stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).')';
    708692
     693    // Action : Repair links
    709694    $msg_error_Link_Bad .= ' <a href="';
    710 
    711     $msg_error_Link_Bad .= add_url_params($page_Register_FluxBB_admin, array(
     695    $msg_error_Link_Bad .= add_url_params(REGFLUXBB_ADMIN, array(
    712696      'action'   => 'new_link',
    713697      'pwg_id' => $row['pwg_id'],
    714698      'bb_id' => $row['bb_id'],
    715699    ));
    716 
    717700    $msg_error_Link_Bad .= '" title="'.l10n('Link_Dup').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'"';
    718 
    719701    $msg_error_Link_Bad .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
    720 
    721702    $msg_error_Link_Bad .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/link_error.png" alt="'.l10n('Link_Dup').stripslashes($row['pwg_user']).' -- '.stripslashes($row['bb_user']).'" /></a>';
    722703  }
    723704
     705  // Display OK message or build errors
    724706  if ($msg_error_Link_Bad == '')
    725707    array_push($page['infos'], l10n('Audit_Link_Bad').'<br>'.l10n('Audit_OK'));
     
    746728    if (($row['pwg_eml'] != $row['bb_eml']) or Reg_FluxBB_PwdSynch($row['pwg_id']))
    747729    {
    748       if ($row['pwg_eml'] != $row['bb_eml'] and Reg_FluxBB_PwdSynch($row['pwg_id']))
     730      if ($row['pwg_eml'] != $row['bb_eml'] and Reg_FluxBB_PwdSynch($row['pwg_id'])) // If passwords are synch
    749731      {
    750732        $msg_error_Synchro .= '<br>'.l10n('Error_Synchro').stripslashes($row['username']);
    751733
     734        // Action : Synch users data from Piwigo to FluxBB
    752735        $msg_error_Synchro .= ' <a href="';
    753 
    754         $msg_error_Synchro .= add_url_params($page_Register_FluxBB_admin, array(
     736        $msg_error_Synchro .= add_url_params(REGFLUXBB_ADMIN, array(
    755737          'action' => 'sync_user',
    756738          'username' => stripslashes($row['username']),
    757739        ));
    758 
    759740        $msg_error_Synchro .= '" title="'.l10n('Sync_User').stripslashes($row['username']).'"';
    760 
    761741        $msg_error_Synchro .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
    762 
    763742        $msg_error_Synchro .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_refresh.png" alt="'.l10n('Sync_User').stripslashes($row['username']).'" /></a>';
    764743
     
    767746        $msg_error_Synchro .= '<br>'.l10n('Error_Synchro_Pswd');
    768747      }
    769       elseif ($row['pwg_eml'] != $row['bb_eml'] and !Reg_FluxBB_PwdSynch($row['pwg_id']))
     748      elseif ($row['pwg_eml'] != $row['bb_eml'] and !Reg_FluxBB_PwdSynch($row['pwg_id'])) // If passwords are NOT synch
    770749      {
    771750        $msg_error_Synchro .= '<br>'.l10n('Error_Synchro').stripslashes($row['username']);
    772751
     752        // Action : Synch users data from Piwigo to FluxBB
    773753        $msg_error_Synchro .= ' <a href="';
    774 
    775         $msg_error_Synchro .= add_url_params($page_Register_FluxBB_admin, array(
     754        $msg_error_Synchro .= add_url_params(REGFLUXBB_ADMIN, array(
    776755          'action' => 'sync_user',
    777756          'username' => stripslashes($row['username']),
    778757        ));
    779 
    780758        $msg_error_Synchro .= '" title="'.l10n('Sync_User').stripslashes($row['username']).'"';
    781 
    782759        $msg_error_Synchro .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
    783 
    784760        $msg_error_Synchro .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_refresh.png" alt="'.l10n('Sync_User').stripslashes($row['username']).'" /></a>';
    785761
     
    789765      {
    790766        $msg_error_Synchro .= '<br>'.l10n('Error_Synchro').stripslashes($row['username']);
    791 
    792767        $msg_error_Synchro .= '<br>'.l10n('Error_Synchro_Pswd');
    793768      }
     
    797772  }
    798773
     774  // Display OK message or build errors
    799775  if ($msg_error_Synchro <> '')
    800776    $msg_error_Synchro = l10n('Audit_Synchro').$msg_error_Synchro;
     
    807783
    808784
     785// Check Piwigo accounts not in FluxBB
     786// -----------------------------------
    809787  $query = '
    810788SELECT username, mail_address FROM '.USERS_TABLE.'
     
    826804    $msg_error_PWG2FluxBB .= '<br>'.l10n('Error_PWG2FluxBB').stripslashes($row['username']).' ('.$row['mail_address'].')';
    827805
     806    // Action : Add user to FluxBB
    828807    $msg_error_PWG2FluxBB .= ' <a href="';
    829 
    830     $msg_error_PWG2FluxBB .= add_url_params($page_Register_FluxBB_admin, array(
     808    $msg_error_PWG2FluxBB .= add_url_params(REGFLUXBB_ADMIN, array(
    831809      'action' => 'add_user',
    832810      'username' => stripslashes($row['username']),
    833811    ));
    834 
    835812    $msg_error_PWG2FluxBB .= '" title="'.l10n('Add_User').stripslashes($row['username']).'" ';
    836 
    837813    $msg_error_PWG2FluxBB .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
    838 
    839814    $msg_error_PWG2FluxBB .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_add.png" alt="'.l10n('Add_User').stripslashes($row['username']).'" /></a>';
    840815  }
    841816
     817  // Display OK message or build errors
    842818  if ($msg_error_PWG2FluxBB == '')
    843819    array_push($page['infos'], l10n('Audit_PWG2FluxBB').'<br>'.l10n('Audit_OK'));
     
    846822
    847823
     824// Check FluxBB accounts not in Piwigo
     825// -----------------------------------
    848826  $query = '
    849827SELECT id, username, email FROM '.FluxBB_USERS_TABLE.'
     
    864842    $msg_error_FluxBB2PWG .= '<br>'.l10n('Error_FluxBB2PWG').stripslashes($row['username']).' ('.$row['email'].')';
    865843
     844    // Action : Delete user from FluxBB
    866845    $msg_error_FluxBB2PWG .= ' <a href="';
    867 
    868     $msg_error_FluxBB2PWG .= add_url_params($page_Register_FluxBB_admin, array(
     846    $msg_error_FluxBB2PWG .= add_url_params(REGFLUXBB_ADMIN, array(
    869847      'action' => 'del_user',
    870848      'id' => $row['id'],
    871849    ));
    872 
    873850    $msg_error_FluxBB2PWG .= '" title="'.l10n('Del_User').stripslashes($row['username']).'"';
    874 
    875851    $msg_error_FluxBB2PWG .= $conf_Register_FluxBB['FLUXBB_CONFIRM']=='false' ?  ' onclick="return confirm(\''.l10n('Are you sure?').'\');" ' : ' ';
    876 
    877852    $msg_error_FluxBB2PWG .= '><img src="'.REGFLUXBB_PATH.'/admin/template/icon/user_delete.png" alt="'.l10n('Del_User').stripslashes($row['username']).'" /></a>';
    878853
     854    // Action : Add user from FluxBB to Piwigo
    879855    $msg_error_FluxBB2PWG .= ' <a href="';
    880 
    881     $msg_error_FluxBB2PWG .= add_url_params($page_Register_FluxBB_admin, array(
     856    $msg_error_FluxBB2PWG .= add_url_params(REGFLUXBB_ADMIN, array(
    882857      'action' => 'add2pwg',
    883858      'id' => $row['id'],
     
    893868  }
    894869
     870  // Display OK message or build errors
    895871  if ($msg_error_FluxBB2PWG == '')
    896872    array_push($page['infos'], l10n('Audit_FluxBB2PWG').'<br>'.l10n('Audit_OK'));
     
    933909// |                       Audit actions process                           |
    934910// +-----------------------------------------------------------------------+
     911
     912// Action : Delete dead link
     913// -------------------------
    935914if (isset($_GET['action']) and ($_GET['action']=='link_dead'))
    936915{
     
    951930  Audit_PWG_FluxBB();
    952931}
     932// Action : Delete duplicate link
     933// ------------------------------
    953934else if (isset($_GET['action']) and ($_GET['action']=='link_del') and isset($_GET['pwg_id']) and isset($_GET['bb_id']))
    954935{
     
    963944  Audit_PWG_FluxBB();
    964945}
     946// Action : Rebuild link
     947// ---------------------
    965948else if (isset($_GET['action']) and ($_GET['action']=='new_link') and isset($_GET['pwg_id']) and isset($_GET['bb_id']))
    966949{
     
    969952  Audit_PWG_FluxBB();
    970953}
     954// Action : Synch users data
     955// -------------------------
    971956else if (isset($_GET['action']) and ($_GET['action']=='sync_user') and isset($_GET['username']))
    972957{
     
    988973  Audit_PWG_FluxBB();
    989974}
     975// Action : Add user to FluxBB
     976// ---------------------------
    990977else if (isset($_GET['action']) and ($_GET['action']=='add_user') and isset($_GET['username']))
    991978{
     
    1005992   Audit_PWG_FluxBB();
    1006993}
     994// Action : Delete user
     995// --------------------
    1007996else if (isset($_GET['action']) and ($_GET['action']=='del_user') and isset($_GET['id']))
    1008997{
     
    10111000  Audit_PWG_FluxBB();
    10121001}
     1002// Action : Add user to Piwigo
     1003// ---------------------------
    10131004else if (isset($_GET['action']) and ($_GET['action']=='add2pwg') and isset($_GET['id']) and isset($_GET['username']) and isset($_GET['email']))
    10141005{
    1015   $error = Synch_Piwigo_Adduser($_GET['id'], $_GET['username'], $_GET['email']);
    1016  
    1017   if (!$error)
    1018     Audit_PWG_FluxBB();
     1006  $emails_to_create = array();
     1007  $emails_rejected = array();
     1008  $emails_already_exist = array();
     1009  $emails_created = array();
     1010  $emails_on_error = array();
     1011 
     1012  $email = trim($_GET['email']);
     1013  $username = $_GET['username'];
     1014  $fluxbb_id = $_GET['id'];
     1015
     1016  // this test requires PHP 5.2+
     1017  if (filter_var($email, FILTER_VALIDATE_EMAIL) !== false)
     1018  {
     1019    $emails_to_check[] = $email;
     1020
     1021    if (!get_userid_by_email($email))
     1022    {
     1023      $emails_to_create[] = $email;
     1024    }
     1025    else
     1026    {
     1027      $emails_existing[] = $email;
     1028    }
     1029  }
     1030  elseif (!empty($email))
     1031  {
     1032    $emails_rejected[] = $email;
     1033  }
     1034
     1035  // find a password
     1036  $password = generate_key(8);
     1037
     1038  $Piwigo_Adduser_Errors = Synch_Piwigo_Adduser($fluxbb_id, $username, $password, $email);
     1039
     1040  if (!empty($Piwigo_Adduser_Errors))
     1041  {
     1042    $emails_on_error[] = $email;
     1043  }
    10191044  else
    1020     $template->append('errors', l10n('RegFluxBB_Email_or_Username_already_exist'));
     1045  {
     1046    $emails_created[] = $email;
     1047  }
     1048
     1049  $emails_for_form = array();
     1050
     1051  if (!empty($emails_created))
     1052  {
     1053    array_push(
     1054      $page['infos'],
     1055      sprintf(
     1056        l10n('%d users registered'),
     1057        count($emails_created)
     1058        )
     1059      );
     1060  }
     1061
     1062  if (!empty($emails_on_error))
     1063  {
     1064    array_push(
     1065      $page['errors'],
     1066      sprintf(
     1067        l10n('%d registrations on error: %s'),
     1068        count($emails_on_error),
     1069        implode(', ', $emails_on_error)
     1070        )
     1071      );
     1072
     1073    $emails_for_form = array_merge($emails_for_form, $emails_on_error);
     1074  }
     1075
     1076  if (!empty($emails_rejected))
     1077  {
     1078    array_push(
     1079      $page['errors'],
     1080      sprintf(
     1081        l10n('%d email addresses rejected: %s'),
     1082        count($emails_rejected),
     1083        implode(', ', $emails_rejected)
     1084        )
     1085      );
     1086
     1087    $emails_for_form = array_merge($emails_for_form, $emails_rejected);
     1088  }
     1089
     1090  if (!empty($emails_existing))
     1091  {
     1092    array_push(
     1093      $page['warnings'],
     1094      sprintf(
     1095        l10n('%d email addresses already exist: %s'),
     1096        count($emails_existing),
     1097        implode(', ', $emails_existing)
     1098        )
     1099      );
     1100  }
    10211101}
    10221102
  • extensions/Register_FluxBB/changelog.txt.php

    r22092 r22204  
    1301302.5.8 - Add accounts synchronization from FluxBB to Piwigo
    131131      - Bug fixed : Missing function in audit
     132
     1332.5.9 - Bug fixed : Adding accounts from FluxBB to Piwigo was not working
     134        // TODO: Compatibility with user_mass_register
    132135*/
    133136?>
  • extensions/Register_FluxBB/include/functions.inc.php

    r22092 r22204  
    33include_once (PHPWG_ROOT_PATH.'/include/constants.php');
    44include_once (REGFLUXBB_PATH.'include/constants.php');
    5 
    6 
    7 function Register_FluxBB_admin_menu($menu)
    8 {
    9   array_push($menu, array(
    10     'NAME' => 'Register FluxBB',
    11     'URL' => get_root_url().'admin.php?page=plugin-'.basename(REGFLUXBB_PATH)
    12     )
    13   );
    14   return $menu;
    15 }
    165
    176
     
    6554
    6655/**
    67  * Checks special users exclusion befaore add new registered user in FluxBB user table
     56 * Checks special users exclusion before add new registered user in FluxBB user table
    6857 */
    6958function Register_FluxBB_Adduser($register_user)
    7059{
    7160  global $errors, $conf;
    72        
    73   // Exclusion of Adult_Content users
    74   if ($register_user['username'] != "16" and $register_user['username'] != "18")
     61
     62  // Exclusion of Adult_Content users - //Todo: Compatibility with user_mass_register plugin
     63  if ($register_user['username'] != "16" and $register_user['username'] != "18" /*and strpos(@$_GET['page'],'user_mass_register') === false*/)
    7564  {
    7665    FluxBB_Adduser($register_user['id'], $register_user['username'], sha1($_POST['password']), $register_user['email']);
    7766  }
     67  /*elseif ($register_user['username'] != "16" and $register_user['username'] != "18" and strpos(@$_GET['page'],'user_mass_register') !== false)
     68  {
     69    //include_once(PHPWG_ROOT_PATH.'plugins/user_mass_register/admin.php');
     70    //FluxBB_Adduser($register_user['id'],$login, $password, $email);
     71  }*/
    7872}
    7973
     
    643637 * To solve password synch problem, passwords are reset to NULL to force users to get a new password on their profile page
    644638 *
    645  * @return : $error
    646  */
    647 function Synch_Piwigo_Adduser($fluxbb_id, $username, $email)
     639 * Based on user_mass_register plugin (thx to plg!)
     640 *
     641 * @return : $errors
     642 */
     643function Synch_Piwigo_Adduser($fluxbb_id, $username, $password, $email)
    648644{
    649645  global $conf;
    650646  load_language('plugin.lang', REGFLUXBB_PATH);
    651647
    652   if (!get_userid_by_email($email) and !get_userid($username))
    653   {
    654     // find a password
    655     $password = generate_key(8);
    656 
    657     $error = register_user($username, $password, $email, false);
    658 
    659     if (empty($error))
     648    $errors = register_user($username, $password, $email, false);
     649
     650    if (empty($errors))
    660651    {
    661652      include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    662653
    663654      $keyargs_content = array(
    664         get_l10n_args('Hello %s,', $login),
     655        get_l10n_args('Hello %s,', $username),
    665656        get_l10n_args('To synchronize your forum access with the gallery you have been registered at %s!', $conf['gallery_title']),
    666657        get_l10n_args('', ''),
    667658        get_l10n_args('Here are your connection settings', ''),
    668         get_l10n_args('Username: %s', $login),
     659        get_l10n_args('Username: %s', $username),
    669660        get_l10n_args('Password: %s', $password),
    670         get_l10n_args('Email: %s', $mail_address),
     661        get_l10n_args('Email: %s', $email),
    671662        get_l10n_args('', ''),
    672663        get_l10n_args('Please change your password at your first connexion on the gallery', ''),
     
    676667
    677668      pwg_mail(
    678         $mail_address,
     669        $email,
    679670        array(
    680671          'subject' => '['.$conf['gallery_title'].'] '.l10n('Registration'),
     
    687678
    688679      FluxBB_Linkuser($pwg_id, $fluxbb_id, "NOK");
    689      
    690       $error = false;
    691680    }
    692   }
    693   else $error = true;
    694 
    695   return $error;
     681
     682  return $errors;
    696683}
    697684
  • extensions/Register_FluxBB/main.inc.php

    r22091 r22204  
    1111if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1212
    13 if (!defined('REGFLUXBB_PATH')) define('REGFLUXBB_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
     13// +-----------------------------------------------------------------------+
     14// | Define plugin constants                                               |
     15// +-----------------------------------------------------------------------+
     16
     17defined('REGFLUXBB_ID') or define('REGFLUXBB_ID', basename(dirname(__FILE__)));
     18define('REGFLUXBB_PATH' ,   PHPWG_PLUGINS_PATH . REGFLUXBB_ID . '/');
     19define('REGFLUXBB_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . REGFLUXBB_ID);
    1420
    1521include_once (REGFLUXBB_PATH.'include/constants.php');
     
    1824load_language('plugin.lang', REGFLUXBB_PATH);
    1925
    20 /* plugin administration */
     26// admin plugins menu link
    2127add_event_handler('get_admin_plugin_menu_links', 'Register_FluxBB_admin_menu');
    2228
     29/**
     30 * admin plugins menu link
     31 */
     32function Register_FluxBB_admin_menu($menu)
     33{
     34  array_push(
     35    $menu,
     36    array(
     37      'NAME' => 'Register FluxBB',
     38      'URL' => REGFLUXBB_ADMIN,
     39      )
     40    );
    2341
    24 /* user creation*/
    25 add_event_handler('register_user', 'Register_FluxBB_Adduser');
     42  return $menu;
     43}
     44
     45
     46/* user creation */
     47if (strpos(@$_GET['page'],'Register_FluxBB') === false) // Exclude user creation from plugin panel to make FluxBB2Piwigo synch available
     48{
     49  add_event_handler('register_user', 'Register_FluxBB_Adduser', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     50}
    2651
    2752
    2853// Check users registration
    29 add_event_handler('register_user_check', 'Register_FluxBB_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     54if (strpos(@$_GET['page'],'Register_FluxBB') === false) // Exclude user creation from plugin panel to make FluxBB2Piwigo synch available
     55{
     56  add_event_handler('register_user_check', 'Register_FluxBB_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     57}
    3058
    3159
Note: See TracChangeset for help on using the changeset viewer.