Ignore:
Timestamp:
Dec 2, 2010, 10:36:33 PM (14 years ago)
Author:
Eric
Message:

Merge from trunk to branch 2.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Register_FluxBB/branches/2.3/main.inc.php

    r7002 r7983  
    22/*
    33Plugin Name: Register FluxBB
    4 Version: 2.3.4
     4Version: 2.3.5
    55Description: Link user registration from Piwigo to FluxBB forum (registration, password changing, deletion) - Original Nicco's NBC_LinkUser2PunBB plugin upgraded to Piwigo / Liez l'inscription des utilisateurs de Piwigo avec votre forum FluxBB - Portage du plugin NBC_LinkUser2PunBB de Nicco vers Piwigo
    66Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=252
     
    6666
    67672.3.4     - 22/09/10  - Compatibility with Plugin Adult_Content
     68
     692.3.5     - 02/12/10  - Bug 2047 fixed : Check case sensitivity for logins in FluxBB's user table
     70                      - Code refactory and optimization
    6871--------------------------------------------------------------------------------
    6972*/
     
    8588add_event_handler('get_admin_plugin_menu_links', 'Register_FluxBB_admin_menu');
    8689
    87 function Register_FluxBB_admin_menu($menu)
    88 {
    89   array_push($menu, array(
    90     'NAME' => 'Register FluxBB',
    91     'URL'  => get_admin_plugin_menu_link(REGFLUXBB_PATH.'admin/admin.php')));
    92   return $menu;
    93 }
    94 
    9590
    9691/* user creation*/
    9792add_event_handler('register_user', 'Register_FluxBB_Adduser');
    9893
    99 function Register_FluxBB_Adduser($register_user)
    100 {
    101   global $conf;
    102        
    103   // Exclusion of Adult_Content users
    104   if ($register_user['username'] != "16" and $register_user['username'] != "18")
    105   {
    106     include_once (REGFLUXBB_PATH.'include/functions.inc.php');
    10794
    108     // Warning : FluxBB uses Sha1 hash instead of md5 for Piwigo!
    109     FluxBB_Adduser($register_user['id'], $register_user['username'], sha1($_POST['password']), $register_user['email']);
    110   }
    111 }
     95// Check users registration
     96add_event_handler('register_user_check', 'Register_FluxBB_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    11297
    11398
    11499/* user deletion */
    115100add_event_handler('delete_user', 'Register_FluxBB_Deluser');
    116 
    117 function Register_FluxBB_Deluser($user_id)
    118 {
    119   include_once (REGFLUXBB_PATH.'include/functions.inc.php');
    120 
    121   FluxBB_Deluser( FluxBB_Searchuser($user_id), true );
    122 }
    123101
    124102
     
    127105{
    128106  add_event_handler('loc_begin_profile', 'Register_FluxBB_InitPage', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    129 
    130   function Register_FluxBB_InitPage()
    131   {
    132     global $conf, $user;
    133     include_once (REGFLUXBB_PATH.'include/functions.inc.php');
    134    
    135     if (isset($_POST['validate']) and !is_admin())
    136     {
    137     if (!empty($_POST['use_new_pwd']))
    138       {
    139       $query = '
    140 SELECT '.$conf['user_fields']['username'].' AS username
    141 FROM '.USERS_TABLE.'
    142 WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\'
    143 ;';
    144 
    145       list($username) = pwg_db_fetch_row(pwg_query($query));
    146 
    147       FluxBB_Updateuser($user['id'], stripslashes($username), sha1($_POST['use_new_pwd']), $_POST['mail_address']);
    148       }
    149     }
    150   }
    151107}
    152108
     
    155111add_event_handler('login_success', 'UAM_Bridge', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    156112
    157 function UAM_Bridge()
    158 {
    159   global $conf, $user;
    160  
    161   $conf_Register_FluxBB = isset($conf['Register_FluxBB']) ? explode(";" , $conf['Register_FluxBB']) : array();
    162  
    163   // Check if UAM is installed and if bridge is set - Exception for admins and webmasters
    164   $query ='
    165 SELECT user_id, status
    166 FROM '.USER_INFOS_TABLE.'
    167 WHERE user_id = '.$user['id'].'
    168 ;';
    169   $data = pwg_db_fetch_assoc(pwg_query($query));
    170  
    171   if ($data['status'] <> "admin" and $data['status'] <> "webmaster")
    172   {
    173     if (function_exists('FindAvailableConfirmMailID') and isset($conf_Register_FluxBB[6]) and $conf_Register_FluxBB[6] == 'true')
    174     {
    175       $conf_UAM = unserialize($conf['UserAdvManager']);
    176    
    177       // Getting unvalidated users group else Piwigo's default group
    178       if (isset($conf_UAM[2]) and $conf_UAM[2] != '-1')
    179       {
    180         $Waitingroup = $conf_UAM[2];
    181       }
    182       else
    183       {
    184         $query = '
    185 SELECT id
    186 FROM '.GROUPS_TABLE.'
    187 WHERE is_default = "true"
    188 LIMIT 1
    189 ;';
    190         $data = pwg_db_fetch_assoc(pwg_query($query));
    191         $Waitingroup = $data['id'];
    192       }
    193    
    194       // check if logged in user is in a Piwigo's validated or unvalidated users group
    195       $query = '
    196 SELECT *
    197 FROM '.USER_GROUP_TABLE.'
    198 WHERE user_id = '.$user['id'].'
    199 AND group_id = '.$Waitingroup.'
    200 ;';
    201       $count = pwg_db_num_rows(pwg_query($query));
    202 
    203       // Check if logged in user is in a FluxBB's unvalidated group
    204       $query = "
    205 SELECT group_id
    206 FROM ".FluxBB_USERS_TABLE."
    207 WHERE id = ".FluxBB_Searchuser($user['id'])."
    208 ;";
    209 
    210       $data = pwg_db_fetch_assoc(pwg_query($query));
    211 
    212       // Logged in user switch to the default FluxBB's group if he'is validated
    213       if ($count == 0 and $data['group_id'] = $conf_Register_FluxBB[7])
    214       {
    215         $query = "
    216 SELECT conf_value
    217 FROM ".FluxBB_CONFIG_TABLE."
    218 WHERE conf_name = 'o_default_user_group'
    219 ;";
    220 
    221         $o_default_user_group = pwg_db_fetch_assoc(pwg_query($query));
    222      
    223         $query = "
    224 UPDATE ".FluxBB_USERS_TABLE."
    225 SET group_id = ".$o_default_user_group['conf_value']."
    226 WHERE id = ".FluxBB_Searchuser($user['id'])."
    227 ;";
    228         pwg_query($query);
    229       }
    230     }
    231   }
    232 }
    233113?>
Note: See TracChangeset for help on using the changeset viewer.