plugins/admin/UserManager.php
changeset 630 3a8ed301be66
parent 629 8733c22969e7
child 631 f4f4146d8b6c
equal deleted inserted replaced
629:8733c22969e7 630:3a8ed301be66
   101       $signature = RenderMan::preprocess_text($_POST['signature'], true, true);
   101       $signature = RenderMan::preprocess_text($_POST['signature'], true, true);
   102       
   102       
   103       $user_level = intval($_POST['user_level']);
   103       $user_level = intval($_POST['user_level']);
   104       if ( $user_level < USER_LEVEL_MEMBER || $user_level > USER_LEVEL_ADMIN )
   104       if ( $user_level < USER_LEVEL_MEMBER || $user_level > USER_LEVEL_ADMIN )
   105         $errors[] = 'Invalid user level';
   105         $errors[] = 'Invalid user level';
       
   106       
       
   107       $user_rank = $_POST['user_rank'];
       
   108       if ( $user_rank !== 'NULL' )
       
   109       {
       
   110         $user_rank = intval($user_rank);
       
   111         if ( !$user_rank )
       
   112           $errors[] = 'Invalid user rank';
       
   113       }
   106       
   114       
   107       $imaddr_aim = htmlspecialchars($_POST['imaddr_aim']);
   115       $imaddr_aim = htmlspecialchars($_POST['imaddr_aim']);
   108       $imaddr_msn = htmlspecialchars($_POST['imaddr_msn']);
   116       $imaddr_msn = htmlspecialchars($_POST['imaddr_msn']);
   109       $imaddr_yahoo = htmlspecialchars($_POST['imaddr_yahoo']);
   117       $imaddr_yahoo = htmlspecialchars($_POST['imaddr_yahoo']);
   110       $imaddr_xmpp = htmlspecialchars($_POST['imaddr_xmpp']);
   118       $imaddr_xmpp = htmlspecialchars($_POST['imaddr_xmpp']);
   158           $to_update_users['email'] = $email;
   166           $to_update_users['email'] = $email;
   159           $to_update_users['real_name'] = $real_name;
   167           $to_update_users['real_name'] = $real_name;
   160         }
   168         }
   161         $to_update_users['signature'] = $signature;
   169         $to_update_users['signature'] = $signature;
   162         $to_update_users['user_level'] = $user_level;
   170         $to_update_users['user_level'] = $user_level;
       
   171         $to_update_users['user_rank'] = $user_rank;
   163         
   172         
   164         if ( isset($_POST['account_active']) )
   173         if ( isset($_POST['account_active']) )
   165         {
   174         {
   166           $to_update_users['account_active'] = "1";
   175           $to_update_users['account_active'] = "1";
   167         }
   176         }
   428       $form->username = $username;
   437       $form->username = $username;
   429       $form->email = $email;
   438       $form->email = $email;
   430       $form->real_name = $real_name;
   439       $form->real_name = $real_name;
   431       $form->signature = $signature;
   440       $form->signature = $signature;
   432       $form->user_level = $user_level;
   441       $form->user_level = $user_level;
       
   442       $form->user_rank = $user_rank;
   433       $form->im = array(
   443       $form->im = array(
   434           'aim' => $imaddr_aim,
   444           'aim' => $imaddr_aim,
   435           'yahoo' => $imaddr_yahoo,
   445           'yahoo' => $imaddr_yahoo,
   436           'msn' => $imaddr_msn,
   446           'msn' => $imaddr_msn,
   437           'xmpp' => $imaddr_xmpp
   447           'xmpp' => $imaddr_xmpp
   469     else
   479     else
   470     {
   480     {
   471       echo 'No username provided';
   481       echo 'No username provided';
   472       return false;
   482       return false;
   473     }
   483     }
   474     $q = $db->sql_query('SELECT u.user_id AS authoritative_uid, u.username, u.email, u.real_name, u.signature, u.account_active, u.user_level, u.user_has_avatar, u.avatar_type, u.user_registration_ip, x.* FROM '.table_prefix.'users AS u
   484     $q = $db->sql_query('SELECT u.user_id AS authoritative_uid, u.username, u.email, u.real_name, u.signature, u.account_active, u.user_level, u.user_rank, u.user_has_avatar, u.avatar_type, u.user_registration_ip, x.* FROM '.table_prefix.'users AS u
   475                            LEFT JOIN '.table_prefix.'users_extra AS x
   485                            LEFT JOIN '.table_prefix.'users_extra AS x
   476                              ON ( u.user_id = x.user_id OR x.user_id IS NULL )
   486                              ON ( u.user_id = x.user_id OR x.user_id IS NULL )
   477                            WHERE ( ' . ENANO_SQLFUNC_LOWERCASE . '(u.username) = \'' . $db->escape(strtolower($username)) . '\' OR u.username = \'' . $db->escape($username) . '\' ) AND u.user_id != 1;');
   487                            WHERE ( ' . ENANO_SQLFUNC_LOWERCASE . '(u.username) = \'' . $db->escape(strtolower($username)) . '\' OR u.username = \'' . $db->escape($username) . '\' ) AND u.user_id != 1;');
   478     if ( !$q )
   488     if ( !$q )
   479       $db->_die();
   489       $db->_die();
   491       $form->username  = $row['username'];
   501       $form->username  = $row['username'];
   492       $form->email     = $row['email'];
   502       $form->email     = $row['email'];
   493       $form->real_name = $row['real_name'];
   503       $form->real_name = $row['real_name'];
   494       $form->signature = $row['signature'];
   504       $form->signature = $row['signature'];
   495       $form->user_level= $row['user_level'];
   505       $form->user_level= $row['user_level'];
       
   506       $form->user_rank = $row['user_rank'];
   496       $form->account_active = ( $row['account_active'] == 1 );
   507       $form->account_active = ( $row['account_active'] == 1 );
   497       $form->email_public   = ( $row['email_public'] == 1 );
   508       $form->email_public   = ( $row['email_public'] == 1 );
   498       $form->has_avatar     = ( $row['user_has_avatar'] == 1 );
   509       $form->has_avatar     = ( $row['user_has_avatar'] == 1 );
   499       $form->avi_type       = $row['avatar_type'];
   510       $form->avi_type       = $row['avatar_type'];
   500       $form->im = array(
   511       $form->im = array(
   755    * User level
   766    * User level
   756    * @var int
   767    * @var int
   757    */
   768    */
   758   
   769   
   759   var $user_level = USER_LEVEL_MEMBER;
   770   var $user_level = USER_LEVEL_MEMBER;
       
   771   
       
   772   /**
       
   773    * User-specific user rank
       
   774    * @var int
       
   775    */
       
   776   
       
   777   var $user_rank = NULL;
   760   
   778   
   761   /**
   779   /**
   762    * Account activated
   780    * Account activated
   763    * @var bool
   781    * @var bool
   764    */
   782    */
  1135                       <option value="{USER_LEVEL_ADMIN}"<!-- BEGIN ul_admin --> selected="selected"<!-- END ul_admin -->>{lang:userfuncs_ml_level_admin}</option>
  1153                       <option value="{USER_LEVEL_ADMIN}"<!-- BEGIN ul_admin --> selected="selected"<!-- END ul_admin -->>{lang:userfuncs_ml_level_admin}</option>
  1136                     </select>
  1154                     </select>
  1137                   </td>
  1155                   </td>
  1138                 </tr>
  1156                 </tr>
  1139                 
  1157                 
       
  1158                 <tr>
       
  1159                   <td class="row2">
       
  1160                     {lang:acpum_field_userrank}<br />
       
  1161                     <small>{lang:acpum_field_userrank_hint}</small>
       
  1162                   </td>
       
  1163                   <td class="row1">
       
  1164                     <select name="user_rank">
       
  1165                       {RANK_LIST}
       
  1166                     </select>
       
  1167                   </td>
       
  1168                 </tr>
       
  1169                 
  1140                 <!-- BEGIN have_reg_ip -->
  1170                 <!-- BEGIN have_reg_ip -->
  1141                 <tr>
  1171                 <tr>
  1142                   <td class="row2">
  1172                   <td class="row2">
  1143                     {lang:acpum_field_reg_ip}
  1173                     {lang:acpum_field_reg_ip}
  1144                   </td>
  1174                   </td>
  1246         $db->_die();
  1276         $db->_die();
  1247     }
  1277     }
  1248     else
  1278     else
  1249     {
  1279     {
  1250       $dh_key_pub = '';
  1280       $dh_key_pub = '';
       
  1281     }
       
  1282     
       
  1283     // build rank list
       
  1284     $q = $db->sql_query('SELECT rank_id, rank_title FROM ' . table_prefix . 'ranks');
       
  1285     if ( !$q )
       
  1286       $db->_die();
       
  1287     $rank_list = '<option value="NULL"' . ( $this->user_rank === NULL ? ' selected="selected"' : '' ) . '>--</option>' . "\n";
       
  1288     while ( $row = $db->fetchrow() )
       
  1289     {
       
  1290       $rank_list .= '<option value="' . $row['rank_id'] . '"' . ( $row['rank_id'] == $this->user_rank ? ' selected="selected"' : '' ) . '>' . htmlspecialchars($lang->get($row['rank_title'])) . '</option>' . "\n";
  1251     }
  1291     }
  1252     
  1292     
  1253     $parser->assign_vars(array(
  1293     $parser->assign_vars(array(
  1254         'UUID' => $this->uuid,
  1294         'UUID' => $this->uuid,
  1255         'USERNAME' => $this->username,
  1295         'USERNAME' => $this->username,
  1273         'LOCATION' => $location,
  1313         'LOCATION' => $location,
  1274         'JOB' => $job,
  1314         'JOB' => $job,
  1275         'HOBBIES' => $hobbies,
  1315         'HOBBIES' => $hobbies,
  1276         'FORM_ACTION' => $form_action,
  1316         'FORM_ACTION' => $form_action,
  1277         'REG_IP_ADDR' => $this->reg_ip_addr,
  1317         'REG_IP_ADDR' => $this->reg_ip_addr,
       
  1318         'RANK_LIST' => $rank_list,
  1278         'GRAVATAR_URL' => make_gravatar_url($this->email, 16)
  1319         'GRAVATAR_URL' => make_gravatar_url($this->email, 16)
  1279       ));
  1320       ));
  1280     
  1321     
  1281     if ( $this->has_avatar )
  1322     if ( $this->has_avatar )
  1282     {
  1323     {