Changeset 7955 for extensions


Ignore:
Timestamp:
Nov 30, 2010, 5:24:38 PM (14 years ago)
Author:
Eric
Message:
  • Bug 1585 fixed : Adding plugin's version number in #_config table
  • Performing old code cleanup
  • 1st step to branch 2.16
Location:
extensions/NBC_UserAdvManager/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/NBC_UserAdvManager/trunk/admin/UAM_admin.php

    r6801 r7955  
    1616include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    1717include_once (PHPWG_ROOT_PATH.'/include/constants.php');
    18 $my_base_url = get_admin_plugin_menu_link(__FILE__);
    1918
    2019load_language('plugin.lang', UAM_PATH);
    2120load_language('help/plugin.lang', UAM_PATH);
     21
     22
     23// +-----------------------------------------------------------------------+
     24// |                   Variables initialization                            |
     25// +-----------------------------------------------------------------------+
     26$my_base_url = get_admin_plugin_menu_link(__FILE__);
    2227
    2328$page['global'] = array();
     
    2833$UAM_Password_Test_Score = 0;
    2934$UAM_Exclusionlist_Error = false;
     35
    3036
    3137// +-----------------------------------------------------------------------+
     
    6470// |            FCK Editor for email text fields              |
    6571// +----------------------------------------------------------+
    66 
    67 /* Available only for ConfirmMail return page customization */
    6872$toolbar = 'Basic';
    6973$width = '750px';
     
    104108  {
    105109
    106 /* General configuration settings */
     110    //General configuration settings
    107111                $_POST['UAM_MailInfo_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_MailInfo_Text'])));
    108112   
     
    112116
    113117
    114 /* Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them */
     118    //Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them
    115119    if (preg_match('/^[\s]+/', $_POST['UAM_MailExclusion_List']))
    116120    {
     
    154158                pwg_query($query);
    155159
    156 /* Email confirmation settings */
     160    //Email confirmation settings
    157161    $_POST['UAM_ConfirmMail_ReMail_Txt1'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_ConfirmMail_ReMail_Txt1'])));
    158162
     
    187191
    188192
    189 /* Testing password enforcement */
     193  //Testing password enforcement
    190194  if (isset($_POST['PasswordTest']) and !is_adviser() and isset($_POST['UAM_Password_Test']) and !empty($_POST['UAM_Password_Test']))
    191195  {
     
    199203  $conf_UAM = unserialize($conf['UserAdvManager']);
    200204
    201 /* Group setting for unvalidated and validated users */
     205  //Group setting for unvalidated and validated users
    202206  $groups[-1] = '---------';
    203207  $No_Valid = -1;
    204208  $Valid = -1;
    205209       
    206 /* Check groups list in database  */
     210  //Check groups list in database
    207211  $query = '
    208212SELECT id, name
     
    216220  {
    217221    $groups[$row['id']] = $row['name'];
    218 /* configuration value for unvalidated users */
     222    //configuration value for unvalidated users
    219223    if (isset($conf_UAM[2]) and $conf_UAM[2] == $row['id'])
    220224    {
    221225                $No_Valid = $row['id'];
    222226                }
    223 /* configuration value for validated users */
     227    //configuration value for validated users
    224228    if (isset($conf_UAM[3]) and $conf_UAM[3] == $row['id'])
    225229                {
     
    228232  }
    229233       
    230 /* Template initialization for unvalidated users group */
     234  //Template initialization for unvalidated users group
    231235  $template->assign(
    232236    'No_Confirm_Group',
     
    236240                        )
    237241                );
    238 /* Template initialization for validated users group */
     242  //Template initialization for validated users group
    239243  $template->assign(
    240244    'Validated_Group',
     
    245249        );
    246250       
    247 /* Status setting for unvalidated and validated users */
     251  //Status setting for unvalidated and validated users
    248252  $status_options[-1] = '------------';
    249253  $No_Valid_Status = -1;
    250254  $Valid_Status = -1;
    251255       
    252 /* Get status values */
     256  //Get status values
    253257  foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
    254258  {
     
    259263          }
    260264         
    261 /* Template initialization for unvalidated users group */
     265      //Template initialization for unvalidated users group
    262266      $template->assign(
    263267        'No_Confirm_Status',
     
    269273  }
    270274 
    271 /* Get status values */
     275  //Get status values
    272276  foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
    273277  {
     
    278282                }
    279283               
    280 /* Template initialization for unvalidated users group */
     284      //Template initialization for unvalidated users group
    281285      $template->assign(
    282286            'Confirm_Status',
     
    288292        }
    289293
    290 /* Save last opened paragraph in configuration tab */
     294  //Save last opened paragraph in configuration tab
    291295  $nb_para=(isset($_POST["nb_para"])) ? $_POST["nb_para"]:"";
    292296  $nb_para2=(isset($_POST["nb_para2"])) ? $_POST["nb_para2"]:"";
    293297
    294298  $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
    295  
     299
     300  // Template initialization for forms and data
    296301  $template->assign(
    297302    array(
     
    352357                $msg_error1 = '';
    353358               
    354 /* Username without forbidden keys */
     359    //Username without forbidden keys
    355360    if ( isset($conf_UAM[6]) and $conf_UAM[6] == 'true' )
    356361          {
     
    371376                $msg_error2 = '';
    372377               
    373 /* Email without forbidden domain */
     378    //Email without forbidden domain
    374379    if ( isset($conf_UAM[11]) and $conf_UAM[11] == 'true' )
    375380          {
     
    464469
    465470// +-----------------------------------------------------------------------+
    466 // |                           Template Init                               |
    467 // +-----------------------------------------------------------------------+
    468                 /*$base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
    469 
    470     if (isset($_GET['start']) and is_numeric($_GET['start']))
    471     {
    472       $start = $_GET['start'];
    473     }
    474     else
    475     {
    476       $start = 0;
    477     }*/
    478 
    479 // +-----------------------------------------------------------------------+
    480 // |                            navigation bar                             |
    481 // +-----------------------------------------------------------------------+
    482 
    483 /*$url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start'));
    484 
    485 $navbar = create_navigation_bar(
    486   $url,
    487   count($page['filtered_users']),
    488   $start,
    489   $conf['users_page']
    490   );
    491 
    492 $template->assign('navbar', $navbar);*/
    493 
    494 // +-----------------------------------------------------------------------+
    495471// |                               user list                               |
    496472// +-----------------------------------------------------------------------+
     
    499475    foreach ($page['filtered_users'] as $num => $local_user)
    500476    {
    501 // simulate LIMIT $start, $conf['users_page']
    502                         /*if ($num < $start)
    503       {
    504         continue;
    505       }
    506       if ($num >= $start + $conf['users_page'])
    507       {
    508         break;
    509       }*/
    510 
    511477      $visible_user_list[] = $local_user;
    512478                }
     
    557523                        );
    558524                }
    559     /* Plugin version inserted */
     525    //Plugin version inserted
    560526    $template->assign(
    561527      array(
     
    977943    }
    978944
    979 // +-----------------------------------------------------------------------+
    980 // |                           Template Init                               |
    981 // +-----------------------------------------------------------------------+
    982                 /*$base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
    983 
    984     if (isset($_GET['start']) and is_numeric($_GET['start']))
    985     {
    986       $start = $_GET['start'];
    987     }
    988     else
    989     {
    990       $start = 0;
    991     }*/
    992 
    993 /* Hide radio-button if not allow to assign adviser */
     945    //Hide radio-button if not allow to assign adviser
    994946                if ($conf['allow_adviser'])
    995947        {
    996948        $template->assign('adviser', true);
    997949        }
    998 
    999 // +-----------------------------------------------------------------------+
    1000 // |                            navigation bar                             |
    1001 // +-----------------------------------------------------------------------+
    1002 
    1003 /*$url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start'));
    1004 
    1005 $navbar = create_navigation_bar(
    1006   $url,
    1007   count($page['filtered_users']),
    1008   $start,
    1009   $conf['users_page']
    1010   );
    1011 
    1012 $template->assign('navbar', $navbar);*/
    1013950
    1014951// +-----------------------------------------------------------------------+
     
    1022959    foreach ($page['filtered_users'] as $num => $local_user)
    1023960    {
    1024 /* simulate LIMIT $start, $conf['users_page'] */
    1025                         /*if ($num < $start)
    1026       {
    1027         continue;
    1028       }
    1029       if ($num >= $start + $conf['users_page'])
    1030       {
    1031         break;
    1032       }*/
    1033 
    1034961      $visible_user_list[] = $local_user;
    1035962                }
     
    11241051    }
    11251052   
    1126     /* Plugin version inserted */
     1053    //Plugin version inserted
    11271054    $template->assign(
    11281055      array(
     
    13571284    if (isset($_POST['GhostTracker_Init']))
    13581285    {
    1359       /* Reset is only allowed for admins ! */
     1286      //Reset is only allowed for admins !
    13601287      if (is_admin() and !is_adviser())
    13611288      {
     
    14261353    }
    14271354
    1428 // +-----------------------------------------------------------------------+
    1429 // |                           Template Init                               |
    1430 // +-----------------------------------------------------------------------+
    1431                 /*$base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
    1432 
    1433     if (isset($_GET['start']) and is_numeric($_GET['start']))
    1434     {
    1435       $start = $_GET['start'];
    1436     }
    1437     else
    1438     {
    1439       $start = 0;
    1440     }*/
    1441 
    1442 /* Hide radio-button if not allow to assign adviser */
     1355    //Hide radio-button if not allow to assign adviser
    14431356                if ($conf['allow_adviser'])
    14441357    {
     
    14471360
    14481361// +-----------------------------------------------------------------------+
    1449 // |                            navigation bar                             |
    1450 // +-----------------------------------------------------------------------+
    1451 
    1452 /*$url = PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start'));
    1453 
    1454 $navbar = create_navigation_bar(
    1455   $url,
    1456   count($page['filtered_users']),
    1457   $start,
    1458   $conf['users_page']
    1459   );
    1460 
    1461 $template->assign('navbar', $navbar);*/
    1462 
    1463 // +-----------------------------------------------------------------------+
    14641362// |                               user list                               |
    14651363// +-----------------------------------------------------------------------+
     
    14681366    foreach ($page['filtered_users'] as $num => $local_user)
    14691367    {
    1470 /* simulate LIMIT $start, $conf['users_page'] */
    1471                         /*if ($num < $start)
    1472       {
    1473         continue;
    1474       }
    1475       if ($num >= $start + $conf['users_page'])
    1476       {
    1477         break;
    1478       }*/
    1479 
    14801368      $visible_user_list[] = $local_user;
    14811369                }
    14821370
    1483 /* Plugin version inserted */
     1371      //Plugin version inserted
    14841372      $template->assign(
    14851373        array(
  • extensions/NBC_UserAdvManager/trunk/changelog.txt.php

    r7277 r7955  
    202202            Bug 1936 fixed - Bad home link in ConfirmMail page when gallery URL is not set
    203203            small CSS improvement (thx to Gotcha)
     204
     205-- 2.15.9 : Bug 2010 fixed - No confirmation email when information email is not set
    204206*/
    205207?>
  • extensions/NBC_UserAdvManager/trunk/include/upgradedb.inc.php

    r6775 r7955  
    208208}
    209209
    210 /* upgrade from branch 2.15.3 to 2.15.4 */
    211 /* ************************************ */
     210/* upgrade from 2.15.3 to 2.15.4 */
     211/* ***************************** */
    212212function upgrade_2153_2154()
    213213{
     
    267267  pwg_query($query);
    268268}
     269
     270/* upgrade from 2.15.9 to 2.16.0 */
     271/* ***************************** */
     272function upgrade_2159_2160()
     273{
     274  global $conf;
     275
     276/* Upgrading options */
     277  $query = '
     278SELECT value
     279  FROM '.CONFIG_TABLE.'
     280WHERE param = "UserAdvManager"
     281;';
     282
     283  $result = pwg_query($query);
     284  $conf_UAM = pwg_db_fetch_assoc($result);
     285   
     286  $Newconf_UAM = unserialize($conf_UAM['value']);
     287 
     288  $Newconf_UAM[22] = 'false';
     289  $Newconf_UAM[23] = 'false';
     290  $Newconf_UAM[24] = 'false';
     291  $Newconf_UAM[25] = 'Sorry, your account has been deleted due to a too long time passed since your last visit.';
     292  $Newconf_UAM[26] = 'Sorry, your account has been deprecated due to a too long time passed since your last visit. Please, use the following link to revalidate your account.';
     293 
     294  $update_conf = serialize($Newconf_UAM);
     295   
     296  $query = '
     297      UPDATE '.CONFIG_TABLE.'
     298                        SET value="'.addslashes($update_conf).'"
     299                        WHERE param="UserAdvManager"
     300                        LIMIT 1
     301                ;';
     302
     303        pwg_query($query);
     304
     305  // Insert a new config entry for futur plugin's version check
     306  $query = '
     307INSERT INTO '.CONFIG_TABLE.' (param, value, comment)
     308VALUES ("UserAdvManager_Version","2.15.8","UAM version check")
     309  ;';
     310 
     311  pwg_query($query);
     312}
    269313?>
  • extensions/NBC_UserAdvManager/trunk/main.inc.php

    r7656 r7955  
    22/*
    33Plugin Name: UserAdvManager
    4 Version: 2.15.9
     4Version: 2.16.0-alpha
    55Description: Renforcer la gestion des utilisateurs - Enforce users management
    66Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=216
     
    2626
    2727
    28 /* Plugin admin */
     28// Plugin administration panel
    2929add_event_handler('get_admin_plugin_menu_links', 'UAM_admin_menu');
    30 
    31 function UAM_admin_menu($menu)
    32 {
    33 // +-----------------------------------------------------------------------+
    34 // |                      Getting plugin name                              |
    35 // +-----------------------------------------------------------------------+
    36   $plugin =  PluginInfos(UAM_PATH);
    37   $name = $plugin['name'];
    38  
    39   array_push($menu,
    40     array(
    41       'NAME' => $name,
    42       'URL'  => get_admin_plugin_menu_link(UAM_PATH.'/admin/UAM_admin.php')
    43     )
    44   );
    45 
    46   return $menu;
    47 }
    4830
    4931/* Lastvisit table feed for Ghost Tracker */
    5032add_event_handler('loc_begin_index', 'UAM_GhostTracker');
    5133
    52 function UAM_GhostTracker()
    53 {
    54   global $conf, $user;
    55 
    56   $conf_UAM = unserialize($conf['UserAdvManager']);
    57 
    58   /* Admins, Guests and Adult_Content users are not tracked for Ghost Tracker or Users Tracker */
    59   if (!is_admin() and !is_a_guest() and $user['username'] != "16" and $user['username'] != "18")
    60   {
    61     if ((isset($conf_UAM[16]) and $conf_UAM[16] == 'true') or (isset($conf_UAM[19]) and $conf_UAM[19] == 'true'))
    62     {
    63 
    64       $userid = get_userid($user['username']);
    65          
    66       /* Looking for existing entry in last visit table */
    67       $query = '
    68 SELECT *
    69   FROM '.USER_LASTVISIT_TABLE.'
    70 WHERE user_id = '.$userid.'
    71 ;';
    72        
    73       $count = pwg_db_num_rows(pwg_query($query));
    74          
    75       if ($count == 0)
    76       {
    77         /* If not, data are inserted in table */
    78         $query = '
    79 INSERT INTO '.USER_LASTVISIT_TABLE.' (user_id, lastvisit, reminder)
    80 VALUES ('.$userid.', now(), "false")
    81 ;';
    82         pwg_query($query);
    83       }
    84       else if ($count > 0)
    85       {
    86         /* If yes, data are updated in table */
    87         $query = '
    88 UPDATE '.USER_LASTVISIT_TABLE.'
    89 SET lastvisit = now(), reminder = "false"
    90 WHERE user_id = '.$userid.'
    91 LIMIT 1
    92 ;';
    93         pwg_query($query);
    94       }
    95     }
    96   }
    97 }
    98 
    99 
    100 /* User creation */
     34// User creation
    10135add_event_handler('register_user', 'UAM_Adduser');
    10236
    103 function UAM_Adduser($register_user)
    104 {
    105   global $conf;
    106 
    107   $conf_UAM = unserialize($conf['UserAdvManager']);
    108 
    109   // Exclusion of Adult_Content users
    110   if ($register_user['username'] != "16" and $register_user['username'] != "18")
    111   {
    112     if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local'))
    113     {
    114       /* This is to send an information email and set user to "waiting" group or status until admin validation */
    115       $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
    116       SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false);
    117       setgroup($register_user['id']);// Set to "waiting" group or status until admin validation
    118     }
    119     elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local'))
    120     {
    121       /* This is to set user to "waiting" group or status until admin validation */
    122       setgroup($register_user['id']);// Set to "waiting" group or status until admin validation
    123     }
    124     elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'false'))
    125     {
    126       /* This is to send an information email without validation key */
    127       $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
    128       SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false);
    129     }
    130     /* Sending registration confirmation by email */
    131     elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true' or $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true'))
    132     {
    133       if (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'true')
    134       {
    135         $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
    136         SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true);
    137       }
    138       elseif (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'false')
    139       {
    140         $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
    141         SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false);
    142       }
    143       elseif (!is_admin())
    144       {
    145         $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';
    146         SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true);
    147       }
    148     }
    149   }
    150 }
    151 
    152 
    153 /* User deletion */
     37// User deletion
    15438add_event_handler('delete_user', 'UAM_Deluser');
    155 
    156 function UAM_Deluser($user_id)
    157 {
    158   /* Cleanup for ConfirmMail table */
    159   DeleteConfirmMail($user_id);
    160   /* Cleanup for LastVisit table */
    161   DeleteLastVisit($user_id);
    162   /* Cleanup Redirection settings */
    163   DeleteRedir($user_id);
    164 }
    165 
    16639
    16740// Check users registration
    16841add_event_handler('register_user_check', 'UAM_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    16942
    170 function UAM_RegistrationCheck($err, $user)
    171 {
    172   global $errors, $conf;
    173 
    174   // Exclusion of Adult_Content users
    175   if ($user['username'] != "16" and $user['username'] != "18")
    176   {
    177 // ***********************************************************
    178 // We need to reset the standard Piwigo's register controls   
    179 // because the call of register_user_check trigger resets them
    180 // ***********************************************************
    181   // **********************************
    182   // Standard Piwigo's username control
    183   // **********************************
    184     if ($_POST['login'] == '')
    185     {
    186       return l10n('reg_err_login1');
    187     }
    188     if (preg_match('/^.* $/', $_POST['login']))
    189     {
    190       return l10n('reg_err_login2');
    191     }
    192     if (preg_match('/^ .*$/', $_POST['login']))
    193     {
    194       return l10n('reg_err_login3');
    195     }
    196     if (get_userid($_POST['login']))
    197     {
    198       return l10n('reg_err_login5');
    199     }
    200  
    201     if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list') // not the same email variable if we are on users registration page or on admin's user registration page
    202     {
    203     // Email doblons check
    204       $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
    205       $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
    206       $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
    207  
    208       if (!preg_match($regex, $_POST['email']))
    209       {
    210         return l10n('reg_err_mail_address');
    211       }
    212    
    213       $query = '
    214 SELECT count(*)
    215 FROM '.USERS_TABLE.'
    216 WHERE upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['email'].'\')
    217 ;';
    218       list($count) = pwg_db_fetch_row(pwg_query($query));
    219       if ($count != 0)
    220       {
    221         return l10n('reg_err_mail_address_dbl');
    222       }
    223     }
    224 
    225     if (script_basename() == 'register') // not the same email variable if we are on users registration page or on admin's user registration page
    226     {
    227   // Email doblons check
    228       $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
    229       $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
    230       $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
    231  
    232       if (!preg_match($regex, $_POST['mail_address']))
    233       {
    234         return l10n('reg_err_mail_address');
    235       }
    236    
    237       $query = '
    238 SELECT count(*)
    239 FROM '.USERS_TABLE.'
    240 WHERE upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['mail_address'].'\')
    241 ;';
    242       list($count) = pwg_db_fetch_row(pwg_query($query));
    243       if ($count != 0)
    244       {
    245         return l10n('reg_err_mail_address_dbl');
    246       }
    247     }
    248 // ******************************************
    249 // End of Piwigo's standard register controls
    250 // ******************************************
    251 
    252 
    253 // ******************************************
    254 // Here begins the advanced register controls
    255 // ******************************************
    256     $PasswordCheck = 0;
    257 
    258     $conf_UAM = unserialize($conf['UserAdvManager']);
    259 
    260     // Password enforcement control
    261     if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14]))
    262     {
    263       if (!empty($user['password']) and !is_admin())
    264       {
    265         $PasswordCheck = testpassword($user['password']);
    266  
    267         if ($PasswordCheck < $conf_UAM[14])
    268         {
    269           $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck);
    270           return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]);
    271         }
    272       }
    273       else if (!empty($user['password']) and is_admin() and isset($conf_UAM[15]) and $conf_UAM[15] == 'true')
    274       {
    275         $PasswordCheck = testpassword($user['password']);
    276  
    277         if ($PasswordCheck < $conf_UAM[14])
    278         {
    279           $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck);
    280           return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]);
    281         }
    282       }
    283     }
    284 
    285     // Username without forbidden keys
    286     if (isset($conf_UAM[6]) and $conf_UAM[6] == 'true' and !empty($_POST['login']) and ValidateUsername($_POST['login']) and !is_admin())
    287     {
    288       $_POST['login'] = '';
    289       return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_UAM[7]."'");
    290     }
    291 
    292     // Email without forbidden domains
    293     if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']) and !is_admin())
    294     {
    295       $_POST['mail_address'] = '';
    296       return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_UAM[12]."'");
    297     }
    298   }
    299 }
    300 
    301 
    30243if (script_basename() == 'profile')
    30344{
    30445  add_event_handler('loc_begin_profile', 'UAM_Profile_Init');
    305 
    306   function UAM_Profile_Init()
    307   {
    308     global $conf, $user, $template;
    309 
    310     $conf_UAM = unserialize($conf['UserAdvManager']);
    311    
    312     if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true'))
    313     {
    314       $user_idsOK = array();
    315       if (!check_consult($user['id'], $user_idsOK))
    316       {
    317         $user_idsOK[] = $user['id'];
    318        
    319         $query = "
    320           UPDATE ".CONFIG_TABLE."
    321           SET value = \"".implode(',', $user_idsOK)."\"
    322           WHERE param = 'UserAdvManager_Redir';";
    323          
    324         pwg_query($query);
    325       }
    326     }
    327 
    328     if (isset($_POST['validate']) and !is_admin())
    329     {
    330       /* Email without forbidden domains */
    331       if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address']))
    332       {
    333         if (ValidateEmailProvider($_POST['mail_address']))
    334         {
    335           $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'");
    336           unset($_POST['validate']);
    337         }
    338       }
    339 
    340       $typemail = 3;
    341      
    342       if (!empty($_POST['use_new_pwd']))
    343       {
    344         $typemail = 2;
    345        
    346         /* Password enforcement control */
    347         if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14]))
    348         {
    349           $PasswordCheck = testpassword($_POST['use_new_pwd']);
    350          
    351           if ($PasswordCheck < $conf_UAM[14])
    352           {
    353             $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck);
    354             $template->append('errors', l10n_args($message).$conf_UAM[14]);
    355             unset($_POST['use_new_pwd']);
    356             unset($_POST['validate']);
    357           }
    358         }
    359       }
    360      
    361       /* Sending registration confirmation by email */
    362       if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'local'))
    363       {
    364         $confirm_mail_need = false;
    365              
    366         if (!empty($_POST['mail_address']))
    367         {
    368           $query = '
    369 SELECT '.$conf['user_fields']['email'].' AS email
    370 FROM '.USERS_TABLE.'
    371 WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\'
    372 ;';
    373          
    374           list($current_email) = pwg_db_fetch_row(pwg_query($query));
    375 
    376           /* This is to send a new validation key */
    377           if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true'))
    378        
    379             $confirm_mail_need = true;
    380 
    381           /* This is to set the user to "waiting" group or status until admin validation */
    382           if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local'))
    383        
    384             setgroup($register_user['id']);// Set to "waiting" group or status until admin validation
    385             $confirm_mail_need = false;
    386         }
    387        
    388         if ((!empty($_POST['use_new_pwd']) and (isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or $confirm_mail_need))
    389         {
    390           $query = '
    391 SELECT '.$conf['user_fields']['username'].'
    392 FROM '.USERS_TABLE.'
    393 WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\'
    394 ;';
    395        
    396           list($username) = pwg_db_fetch_row(pwg_query($query));
    397 
    398           SendMail2User($typemail, $user['id'], $username, $_POST['use_new_pwd'], $_POST['mail_address'], $confirm_mail_need);
    399         }
    400       }
    401     }
    402   }
    40346}
    40447
    405 
    406 // RedirectToProfile - Thx to LucMorizur
    407 // redirects a visitor (except for admins, webmasters and generic statuses) to his
    408 // profile.php page
    409 //
    410 // no variable, no return
     48// Redirection to profile page
    41149add_event_handler('login_success', 'RedirectToProfile');
    41250
    413 function RedirectToProfile()
    414 {
    415   global $conf, $user;
    416  
    417   $conf_UAM = unserialize($conf['UserAdvManager']);
    418  
    419   $query ='
    420 SELECT user_id, status
    421 FROM '.USER_INFOS_TABLE.'
    422 WHERE user_id = '.$user['id'].'
    423 ;';
    424   $data = pwg_db_fetch_assoc(pwg_query($query));
    425  
    426   if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic")
    427   {
    428     if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true'))
    429     {
    430       $user_idsOK = array();
    431       if (!check_consult($user['id'], $user_idsOK))
    432         redirect(PHPWG_ROOT_PATH.'profile.php');
    433     }
    434   }
    435 }
     51// *** Important ! This is necessary to make email exclusion work in admin's users management panel ***
     52add_event_handler('init', 'UAM_InitPage');
    43653
    437 
    438 add_event_handler('init', 'UAM_InitPage');
    439 /* *** Important ! This is necessary to make email exclusion work in admin's users management panel *** */
    440 function UAM_InitPage()
    441 {
    442   load_language('plugin.lang', UAM_PATH);
    443   global $conf, $template, $page, $lang, $errors;
    444 
    445   $conf_UAM = unserialize($conf['UserAdvManager']);
    446 
    447 /* Admin user management */
    448   if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list')
    449   {
    450     if (isset($_POST['submit_add']))
    451     {
    452       /* Email without forbidden domains */
    453       if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email']))
    454       {
    455         $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'");
    456         unset($_POST['submit_add']);
    457       }
    458     }
    459   }
    460 }
    461 
    462 
     54// Comment without author
    46355add_event_handler('user_comment_check', 'UAM_CheckEmptyCommentAuthor', 50, 2);
    464 
    465 function UAM_CheckEmptyCommentAuthor($comment_action, $comm)
    466 {
    467   load_language('plugin.lang', UAM_PATH);
    468   global $infos, $conf, $template;
    469 
    470   $conf_UAM = unserialize($conf['UserAdvManager']);
    471 
    472 /* User creation OR update */
    473   if (isset($conf_UAM[5]) and $conf_UAM[5] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest')
    474   {
    475     $comment_action = 'reject';
    476 
    477     array_push($infos, l10n('UAM_Empty Author'));
    478   }
    479 
    480   return $comment_action;
    481 }
    48256?>
  • extensions/NBC_UserAdvManager/trunk/maintain.inc.php

    r6822 r7955  
    180180  }
    181181
     182
     183        $query = '
     184SELECT param
     185  FROM '.CONFIG_TABLE.'
     186WHERE param = "UserAdvManager_Version"
     187;';
     188  $count = pwg_db_num_rows(pwg_query($query));
     189 
     190  if ($count == 0)
     191  {
     192    upgrade_2159_2160();
     193  }
     194
    182195load_conf_from_db('param like \'UserAdvManager\\_%\'');
    183196}
Note: See TracChangeset for help on using the changeset viewer.