Added group_rank option in admin group manager and user_title option in admin user manager
authorDan
Sat, 12 Jul 2008 04:49:30 -0400
changeset 631 f4f4146d8b6c
parent 630 3a8ed301be66
child 632 567e4b2c763f
Added group_rank option in admin group manager and user_title option in admin user manager
language/english/admin.json
plugins/admin/GroupManager.php
plugins/admin/UserManager.php
--- a/language/english/admin.json	Sat Jul 12 04:10:04 2008 -0400
+++ b/language/english/admin.json	Sat Jul 12 04:49:30 2008 -0400
@@ -805,6 +805,9 @@
       
       field_signature: 'Signature:',
       
+      field_usertitle: 'User title:',
+      field_usertitle_hint: 'Displayed below the avatar or username, and above the rank.',
+      
       heading_imcontact: 'Instant messenger contact information',
       
       field_aim: 'AIM handle:',
@@ -856,13 +859,14 @@
       btn_edit_stage1: 'Edit group',
       heading_create_new: 'Create a new group',
       field_group_name: 'Group name:',
+      field_group_rank: 'Assigned rank:',
       btn_create_stage1: 'Continue',
       
       // Edit form
-      heading_edit_name: 'Edit group name',
+      heading_edit_name: 'Edit group basics',
       btn_cant_delete: 'Can\'t delete system group',
       btn_delete_group: 'Delete this group',
-      btn_save_name: 'Save name',
+      btn_save_name: 'Save changes',
       heading_edit_members: 'Edit group members',
       msg_no_members: 'This group has no members.',
       lbl_member_mod: 'Mod',
@@ -888,7 +892,7 @@
       // More editor bits, validation messages
       err_nodelete_system_group: 'The group "%g_name%" could not be deleted because it is a system group required for site functionality.',
       msg_delete_success: 'The group "%g_name%" has been deleted. Return to the <a %a_flags%>group manager</a>.',
-      msg_name_update_success: 'The group name has been updated.',
+      msg_name_update_success: 'The group name and rank have been updated.',
       msg_user_added: 'The user "%username%" has been added to this usergroup.',
       err_username_not_exist: '<b>The user "%username%" could not be added.</b><br />This username does not exist.',
     },
--- a/plugins/admin/GroupManager.php	Sat Jul 12 04:10:04 2008 -0400
+++ b/plugins/admin/GroupManager.php	Sat Jul 12 04:49:30 2008 -0400
@@ -130,7 +130,7 @@
   if(isset($_POST['do_edit']) || isset($_POST['edit_do']))
   {
     // Fetch the group name
-    $q = $db->sql_query('SELECT group_name,system_group FROM '.table_prefix.'groups WHERE group_id='.intval($_POST['group_edit_id']).';');
+    $q = $db->sql_query('SELECT group_name,system_group,group_rank FROM '.table_prefix.'groups WHERE group_id='.intval($_POST['group_edit_id']).';');
     if(!$q)
     {
       echo $db->get_error();
@@ -176,7 +176,19 @@
           echo '<p>' . $lang->get('acpug_err_group_name_invalid') . '</p>';
           return;
         }
-        $q = $db->sql_query('UPDATE '.table_prefix.'groups SET group_name=\''.$db->escape($_POST['group_name']).'\'
+        // determine rank
+        $group_rank =& $_POST['group_rank'];
+        if ( $_POST['group_rank'] !== 'NULL' )
+        {
+          $group_rank = intval($group_rank);
+          if ( empty($group_rank) )
+          {
+            echo '<p>Hacked rank ID</p>';
+            return;
+          }
+        }
+        $row['group_rank'] = $group_rank;
+        $q = $db->sql_query('UPDATE '.table_prefix.'groups SET group_name=\''.$db->escape($_POST['group_name']).'\',group_rank = ' . $group_rank . '
             WHERE group_id='.intval($_POST['group_edit_id']).';');
         if(!$q)
         {
@@ -201,11 +213,11 @@
       }
       if($db->numrows() > 0)
       {
-        while($row = $db->fetchrow($q))
+        while($delrow = $db->fetchrow($q))
         {
-          if(isset($_POST['edit_do']['del_' . $row['member_id']]))
+          if(isset($_POST['edit_do']['del_' . $delrow['member_id']]))
           {
-            $e = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE member_id='.$row['member_id']);
+            $e = $db->sql_query('DELETE FROM '.table_prefix.'group_members WHERE member_id='.$delrow['member_id']);
             if(!$e)
             {
               echo $db->get_error();
@@ -250,6 +262,17 @@
     $sg_disabled = ( $row['system_group'] == 1 ) ?
              ' value="' . $lang->get('acpug_btn_cant_delete') . '" disabled="disabled" style="color: #FF9773" ' :
              ' value="' . $lang->get('acpug_btn_delete_group') . '" style="color: #FF3713" ';
+    
+    // build rank list
+    $q = $db->sql_query('SELECT rank_id, rank_title FROM ' . table_prefix . 'ranks');
+    if ( !$q )
+      $db->_die();
+    $rank_list = '<option value="NULL"' . ( $row['group_rank'] === NULL ? ' selected="selected"' : '' ) . '>--</option>' . "\n";
+    while ( $rank_row = $db->fetchrow() )
+    {
+      $rank_list .= '<option value="' . $rank_row['rank_id'] . '"' . ( $rank_row['rank_id'] == $row['group_rank'] ? ' selected="selected"' : '' ) . '>' . htmlspecialchars($lang->get($rank_row['rank_title'])) . '</option>' . "\n";
+    }
+             
     echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">';
     echo '<div class="tblholder">
           <table border="0" style="width:100%;" cellspacing="1" cellpadding="4">
@@ -260,6 +283,11 @@
             </td>
           </tr>
           <tr>
+            <td class="row1">
+              ' . $lang->get('acpug_field_group_rank') . ' <select name="group_rank" />' . $rank_list . '</select>
+            </td>
+          </tr>
+          <tr>
             <th class="subhead">
               <input type="submit" name="edit_do[save_name]" value="' . $lang->get('acpug_btn_save_name') . '" />
               <input type="submit" name="edit_do[del_group]" '.$sg_disabled.' />
--- a/plugins/admin/UserManager.php	Sat Jul 12 04:10:04 2008 -0400
+++ b/plugins/admin/UserManager.php	Sat Jul 12 04:49:30 2008 -0400
@@ -121,6 +121,7 @@
       $occupation = htmlspecialchars($_POST['occupation']);
       $hobbies = htmlspecialchars($_POST['hobbies']);
       $email_public = ( isset($_POST['email_public']) ) ? '1' : '0';
+      $user_title = htmlspecialchars($_POST['user_title']);
       
       if ( !preg_match('/@([a-z0-9-]+)(\.([a-z0-9-\.]+))?/', $imaddr_msn) && !empty($imaddr_msn) )
       {
@@ -169,6 +170,7 @@
         $to_update_users['signature'] = $signature;
         $to_update_users['user_level'] = $user_level;
         $to_update_users['user_rank'] = $user_rank;
+        $to_update_users['user_title'] = $user_title;
         
         if ( isset($_POST['account_active']) )
         {
@@ -440,6 +442,7 @@
       $form->signature = $signature;
       $form->user_level = $user_level;
       $form->user_rank = $user_rank;
+      $form->user_title = $user_title;
       $form->im = array(
           'aim' => $imaddr_aim,
           'yahoo' => $imaddr_yahoo,
@@ -481,7 +484,7 @@
       echo 'No username provided';
       return false;
     }
-    $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
+    $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_title, u.user_has_avatar, u.avatar_type, u.user_registration_ip, x.* FROM '.table_prefix.'users AS u
                            LEFT JOIN '.table_prefix.'users_extra AS x
                              ON ( u.user_id = x.user_id OR x.user_id IS NULL )
                            WHERE ( ' . ENANO_SQLFUNC_LOWERCASE . '(u.username) = \'' . $db->escape(strtolower($username)) . '\' OR u.username = \'' . $db->escape($username) . '\' ) AND u.user_id != 1;');
@@ -504,6 +507,7 @@
       $form->signature = $row['signature'];
       $form->user_level= $row['user_level'];
       $form->user_rank = $row['user_rank'];
+      $form->user_title= $row['user_title'];
       $form->account_active = ( $row['account_active'] == 1 );
       $form->email_public   = ( $row['email_public'] == 1 );
       $form->has_avatar     = ( $row['user_has_avatar'] == 1 );
@@ -777,6 +781,13 @@
   var $user_rank = NULL;
   
   /**
+   * User's custom title
+   * @var int
+   */
+  
+  var $user_title = '';
+  
+  /**
    * Account activated
    * @var bool
    */
@@ -1000,6 +1011,20 @@
                   </td>
                 </tr>
                 
+                <tr>
+                  <td class="row2" style="width: 25%;">
+                    {lang:acpum_field_usertitle}<br />
+                    <small>
+                      {lang:acpum_field_usertitle_hint}
+                    </small>
+                  </td>
+                  <td class="row1" style="width: 75%;">
+                    <input type="text" name="user_title" value="{USER_TITLE}" />
+                  </td>
+                </tr>
+                
+                
+                
               <!-- / Basic options -->
               
               <!-- Extended options (anything in enano_users_extra) -->
@@ -1301,6 +1326,7 @@
         'DH_PUBLIC' => $dh_key_pub,
         'REAL_NAME' => $this->real_name,
         'SIGNATURE_FIELD' => $template->tinymce_textarea('signature', $this->signature, 10, 50),
+        'USER_TITLE' => $this->user_title,
         'USER_LEVEL_MEMBER' => USER_LEVEL_CHPREF,
         'USER_LEVEL_MOD' => USER_LEVEL_MOD,
         'USER_LEVEL_ADMIN' => USER_LEVEL_ADMIN,