1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 22:27:34 +02:00

admin->users and admin->userclass minor interface and code cleanup.

This commit is contained in:
CaMer0n
2009-10-21 07:31:07 +00:00
parent 2e71f54abb
commit 24ed49a86a
2 changed files with 175 additions and 259 deletions

View File

@@ -9,9 +9,9 @@
* Administration Area - User classes
*
* $Source: /cvs_backup/e107_0.8/e107_admin/userclass2.php,v $
* $Revision: 1.28 $
* $Date: 2009-08-28 16:11:00 $
* $Author: marj_nl_fr $
* $Revision: 1.29 $
* $Date: 2009-10-21 07:31:05 $
* $Author: e107coders $
*
*/
@@ -743,176 +743,6 @@ $ns->tablerender(UCSLAN_21, $text);
$ns->tablerender('User classes - test features', $text);
break; // End of temporary test options
//-----------------------------------
// Edit class membership
//-----------------------------------
case 'membs' :
if ($params == 'clear')
{
$class_id = intval(varset($uc_qs[2]));
check_allowed($class_id);
if ($sql->db_Select('user', 'user_id, user_class', "user_class = '{$class_id}' OR user_class REGEXP('^{$class_id},') OR user_class REGEXP(',{$class_id},') OR user_class REGEXP(',{$class_id}$')"))
{
while ($row = $sql->db_Fetch())
{
$uidList[$row['user_id']] = $row['user_class'];
}
$e_userclass->class_remove($class_id, $uidList);
$message = UCSLAN_1;
userclass2_adminlog("06","ID:{$class_id} (".$e_userclass->uc_get_classname($class_id).")");
}
}
elseif($params)
{ // Process the updated membership list
$tmp2 = explode('-', $params,2);
$class_id = intval($tmp2[0]);
check_allowed($class_id);
$message = UCSLAN_2;
if ($sql->db_Select('user', 'user_id, user_class', "user_class = '{$class_id}' OR user_class REGEXP('^{$class_id},') OR user_class REGEXP(',{$class_id},') OR user_class REGEXP(',{$class_id}$')"))
{
while ($row = $sql->db_Fetch())
{
$uidList[$row['user_id']] = $row['user_class'];
}
$e_userclass->class_remove($class_id, $uidList);
}
unset($uidList);
if ($sql->db_Select('user', 'user_id, user_class', "user_id IN({$tmp2[1]})"))
{
while ($row = $sql->db_Fetch())
{
$uidList[$row['user_id']] = $row['user_class'];
}
$e_userclass->class_add($class_id, $uidList);
}
userclass2_adminlog("04","ID:{$class_id} (".$e_userclass->uc_get_classname($class_id).")");
}
if ($message)
{
$ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
}
// If we're editing a class, get the info on the class
if(isset($_POST['class_members_edit']))
{
$uc_edit_class = varset($_POST['class_to_edit'],0);
check_allowed($uc_edit_class);
$sql->db_Select('userclass_classes', '*', "userclass_id=".$uc_edit_class);
$row = $sql->db_Fetch();
extract($row);
}
$class_total = $sql->db_Select("userclass_classes", "*", "ORDER BY userclass_name", "nowhere");
$text = "<div style='text-align:center'>
<form method='post' action='".e_SELF."?membs' id='classForm'>
<table class='fborder' style='".ADMIN_WIDTH."'>
<tr>
<td class='fcaption' style='text-align:center' colspan='2'>";
if ($class_total == "0")
{
$text .= UCSLAN_7;
}
else
{
$text .= "<span class='defaulttext'>".UCSLAN_8.":</span>
<select name='class_to_edit' class='tbox'>";
while ($row = $sql->db_Fetch())
{
if (check_class($row['userclass_editclass']) || getperms("0"))
{
$s = $uc_edit_class == $row['userclass_id'] ? " selected='selected'" : '';
$text .= "<option value='{$row['userclass_id']}'{$s}>{$row['userclass_name']}</option>";
}
}
$text .= "</select>
<input class='button' type='submit' name='class_members_edit' value='".LAN_EDIT."' />";
}
$text .= "</td></tr><tr><td>&nbsp;</td></tr></table>";
if(isset($_POST['class_members_edit']))
{
$sql->db_Select("user", "user_id, user_name, user_class, user_login", "user_ban != 1 ORDER BY user_name ");
$c = 0;
$d = 0;
while ($row = $sql->db_Fetch())
{
extract($row);
if (check_class($userclass_id, $user_class))
{
$in_userid[$c] = $user_id;
$in_username[$c] = $user_name;
$in_userlogin[$c] = $user_login ? "(".$user_login.")" : "";
$c++;
}
else
{
$out_userid[$d] = $user_id;
$out_username[$d] = $user_name;
$out_userlogin[$d] = $user_login ? "(".$user_login.")" : "";
$d++;
}
}
$text .= "<table class='fborder' style='".ADMIN_WIDTH."'>
<tr>
<td class='fcaption' style='text-align:center;width:30%'>".UCSLAN_16." ".$userclass_name."</td></tr>
<tr>
<td style='width:70%; text-align:center'>
<table style='width:90%'>
<tr>
<td style='width:45%; vertical-align:top'>
".UCSLAN_22."<br />
<select class='tbox' id='assignclass1' name='assignclass1' size='10' style='width:220px' onchange='addIt()'>";
// <select class='tbox' id='assignclass1' name='assignclass1' size='10' style='width:220px' multiple='multiple'>";
for ($a = 0; $a <= ($d-1); $a++)
{
$text .= "<option value='".$out_userid[$a]."'>".htmlentities($out_username[$a])." ".htmlentities($out_userlogin[$a])."</option>\n";
}
$text .= "</select>
</td>\n
<td style='width:45%; vertical-align:top'>
".UCSLAN_23."<br />
<select class='tbox' id='assignclass2' name='assignclass2' size='10' style='width:220px' onchange='delIt()'>";
// <select class='tbox' id='assignclass2' name='assignclass2' size='10' style='width:220px' multiple='multiple'>";
for($a = 0; $a <= ($c-1); $a++)
{
$text .= "<option value='".$in_userid[$a]."'>".htmlentities($in_username[$a])." ".htmlentities($in_userlogin[$a])."</option>\n";
}
$text .= "</select><br />\n<br />";
if (count($in_userid))
{ // No option to clear class if it starts empty
$text .= "<input class='button' type='button' value='".UCSLAN_18."' onclick='clearMe({$userclass_id});' />";
}
$text .= "<input type='hidden' name='class_id' value='{$userclass_id}' />
</td></tr></table>
</td></tr>
<tr><td colspan='2' style='text-align:center' class='forumheader'>
<input class='button' type='button' value='".UCSLAN_19." ".$userclass_name." ".UCSLAN_20."' onclick='saveMe({$userclass_id});' />
</td>
</tr>
</table>";
}
$text .= "</form>
</div>";
$ns->tablerender(UCSLAN_28, $text);
break; // End of 'membs' (class membership) option
//-----------------------------------
// Special fooling around
@@ -982,8 +812,11 @@ function userclass2_adminmenu()
$var['config']['text'] = UCSLAN_25;
$var['config']['link'] = 'userclass2.php?config';
//DEPRECATED - use admin->users instead.
/*
$var['membs']['text'] = UCSLAN_26;
$var['membs']['link'] ='userclass2.php?membs';
*/
$var['initial']['text'] = UCSLAN_38;
$var['initial']['link'] ='userclass2.php?initial';
@@ -1027,9 +860,9 @@ class uclass_manager
'userclass_id' => array('title'=> ID, 'width'=>'5%', 'thclass' => 'left'),
'userclass_name' => array('title'=> UCSLAN_12, 'width'=>'auto', 'thclass' => 'left'),
'userclass_description' => array('title'=> UCSLAN_13, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'),
'userclass_editclass' => array('title'=> UCSLAN_24, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'), // Display name
'userclass_parent' => array('title'=> UCSLAN_35, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'), // User name
'userclass_visibility' => array('title'=> UCSLAN_34, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'), // Photo
'userclass_editclass' => array('title'=> UCSLAN_24, 'type' => 'userclass', 'width' => 'auto', 'thclass' => 'left'), // Display name
'userclass_parent' => array('title'=> UCSLAN_35, 'type' => 'userclass', 'width' => 'auto', 'thclass' => 'left'), // User name
'userclass_visibility' => array('title'=> UCSLAN_34, 'type' => 'userclass', 'width' => 'auto', 'thclass' => 'left'), // Photo
'userclass_type' => array('title'=> UCSLAN_79, 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting)
'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last')
);
@@ -1057,10 +890,7 @@ class uclass_manager
"<tbody>";
$classes = $sql->db_getList('ALL', FALSE, FALSE);
$types = array(
UC_TYPE_STD => UCSLAN_80,
UC_TYPE_GROUP => UCSLAN_81
);
foreach($classes as $row)
{
@@ -1070,17 +900,31 @@ class uclass_manager
$icon = is_readable($iconpath) ? "<img src='".$iconpath."' alt='' />" : "&nbsp;";
}
// $disp = key($row);
//
$text .= "
<tr>";
$text .= (in_array("userclass_icon",$this->fieldpref)) ? "<td class='center'>".$icon."</td>" : "";
$text .= (in_array("userclass_id",$this->fieldpref)) ? "<td>".$row['userclass_id']."</td>" : "";
$text .= (in_array("userclass_name",$this->fieldpref)) ? "<td>".($row['userclass_name'])."</td>" : "";
$text .= (in_array("userclass_description",$this->fieldpref)) ? "<td>".($row['userclass_description'])."</td>" : "";
$text .= (in_array("userclass_editclass",$this->fieldpref)) ? "<td>".r_userclass_name($row['userclass_editclass'])."</td>" : "";
$text .= (in_array("userclass_parent",$this->fieldpref)) ? "<td>".(r_userclass_name($row['userclass_parent']))."</td>" : "";
$text .= (in_array("userclass_visibility",$this->fieldpref)) ? "<td>".(r_userclass_name($row['userclass_visibility']))."</td>" : "";
$text .= (in_array("userclass_type",$this->fieldpref)) ? "<td>".($types[$row['userclass_type']])."</td>" : "";
foreach($this->fieldpref as $key)
{
$class = vartrue($this->fields[$key]['thclass']) ? "class='".$this->fields[$key]['thclass']."'" : "";
$text .= "<td ".$class.">";
$text .= $this->renderValue($key, $row);
$text .= "</td>";
}
/*
$text .= (in_array("userclass_icon",$this->fieldpref)) ? "<td ".$class.">".$icon."</td>" : "";
$text .= (in_array("userclass_id",$this->fieldpref)) ? "<td ".$class.">".$row['userclass_id']."</td>" : "";
$text .= (in_array("userclass_name",$this->fieldpref)) ? "<td ".$class.">".($row['userclass_name'])."</td>" : "";
$text .= (in_array("userclass_description",$this->fieldpref)) ? "<td ".$class.">".($row['userclass_description'])."</td>" : "";
$text .= (in_array("userclass_editclass",$this->fieldpref)) ? "<td ".$class.">".r_userclass_name($row['userclass_editclass'])."</td>" : "";
$text .= (in_array("userclass_parent",$this->fieldpref)) ? "<td ".$class.">".(r_userclass_name($row['userclass_parent']))."</td>" : "";
$text .= (in_array("userclass_visibility",$this->fieldpref)) ? "<td ".$class.">".(r_userclass_name($row['userclass_visibility']))."</td>" : "";
$text .= (in_array("userclass_type",$this->fieldpref)) ? "<td ".$class.">".($types[$row['userclass_type']])."</td>" : "";
*/
$text .= "<td class='center'>
@@ -1098,6 +942,27 @@ class uclass_manager
}
function renderValue($key,$row)
{
$types = array(
UC_TYPE_STD => UCSLAN_80,
UC_TYPE_GROUP => UCSLAN_81
);
if($this->fields[$key]['type']=='userclass')
{
return r_userclass_name($row[$key]);
}
if($key == "userclass_type")
{
return $types[$row['userclass_type']];
}
return $row[$key];
}
}
require_once("footer.php");

View File

@@ -10,8 +10,8 @@
* Administration Area - Users
*
* $Source: /cvs_backup/e107_0.8/e107_admin/users.php,v $
* $Revision: 1.58 $
* $Date: 2009-09-22 19:43:34 $
* $Revision: 1.59 $
* $Date: 2009-10-21 07:31:07 $
* $Author: e107coders $
*
*/
@@ -565,18 +565,19 @@ class users
'user_image' => array('title' => LAN_USER_07,'type' => 'text','width' => 'auto'), // Avatar
'user_email' => array('title' => LAN_USER_08,'type' => 'text','width' => 'auto'),
'user_signature' => array('title' => LAN_USER_09,'type' => 'text','width' => 'auto'),
'user_hideemail' => array('title' => LAN_USER_10,'type' => 'int','width' => 'auto'),
'user_hideemail' => array('title' => LAN_USER_10,'type' => 'boolean','width' => 'auto'),
'user_xup' => array('title' => LAN_USER_11,'type' => 'text','width' => 'auto'),
'user_class' => array('title' => LAN_USER_12,'type' => 'class'),
'user_join' => array('title' => LAN_USER_14,'width' => 'auto'),
'user_lastvisit' => array('title' => LAN_USER_15,'width' => 'auto'),
'user_currentvisit' => array('title' => LAN_USER_16,'width' => 'auto'),
'user_join' => array('title' => LAN_USER_14,'type' => 'date', 'width' => 'auto'),
'user_lastvisit' => array('title' => LAN_USER_15,'type' => 'date', 'width' => 'auto'),
'user_currentvisit' => array('title' => LAN_USER_16,'type' => 'date', 'width' => 'auto'),
'user_comments' => array('title' => LAN_USER_17,'width' => 'auto'),
'user_lastpost' => array('title' => 'Last Post','type' => 'date', 'width' => 'auto'),
'user_ip' => array('title' => LAN_USER_18,'width' => 'auto'),
'user_ban' => array('title' => LAN_USER_19,'width' => 'auto'),
'user_ban' => array('title' => LAN_USER_19,'type' => 'boolean', 'width' => 'auto'),
'user_prefs' => array('title' => LAN_USER_20,'width' => 'auto'),
'user_visits' => array('title' => LAN_USER_21,'width' => 'auto'),
'user_admin' => array('title' => LAN_USER_22,'width' => 'auto'),
'user_visits' => array('title' => LAN_USER_21,'width' => 'auto','thclass'=>'right'),
'user_admin' => array('title' => LAN_USER_22,'type' => 'boolean', 'width' => 'auto', 'thclass'=>'center'),
'user_perms' => array('title' => LAN_USER_23,'width' => 'auto'),
'user_pwchange' => array('title' => LAN_USER_24,'width' => 'auto'),
);
@@ -1029,6 +1030,13 @@ class users
}
}
// $user_total = db_Count($table, $fields = '(*)',
if($_SESSION['searchclass']==e_UC_ADMIN)
{
$this->fieldpref[] = 'user_perms';
}
$qry_insert = 'SELECT u.*, ue.* FROM `#user` AS u LEFT JOIN `#user_extended` AS ue ON ue.user_extended_id = u.user_id ';
return ($query) ? $qry_insert." WHERE ".$query.$qry_order : $qry_insert.$qry_order;
@@ -1036,89 +1044,64 @@ class users
function show_existing_users($action,$sub_action,$id,$from,$amount)
{
global $sql,$frm,$ns,$tp,$mySQLdefaultdb,$pref,$unverified,$userMethods;
global $mySQLdefaultdb,$pref,$unverified,$userMethods;
$sql = e107::getDb();
$frm = e107::getForm();
$ns = e107::getRender();
$tp = e107::getParser();
$e107 = e107 :: getInstance();
$qry = $this->get_search_query();
$this->fieldpref = array_unique($this->fieldpref);
$text = "<div>".$this->show_search_filter();
if ($user_total = $sql->db_Select_gen($qry))
{
$text .= "<form method='post' action='".e_SELF."?".e_QUERY."'>
$text .= "
<form method='post' action='".e_SELF."?".e_QUERY."'>
<fieldset id='core-users-list'>
<legend class='e-hideme'>".NWSLAN_4."</legend>
<table cellpadding='0' cellspacing='0' class='adminlist'>".$frm->colGroup($this->fields,$this->fieldpref).$frm->thead($this->fields,$this->fieldpref,"main.[FIELD].[ASC].[FROM]")."<tbody>";
<table cellpadding='0' cellspacing='0' class='adminlist'>".
$frm->colGroup($this->fields,$this->fieldpref).
$frm->thead($this->fields,$this->fieldpref,"main.[FIELD].[ASC].[FROM]").
"<tbody>\n";
while ($row = $sql->db_Fetch())
{
extract($row);
$text .= "<tr>
$text .= "
<tr>
<td class='center' >".$frm->checkbox('user_selected[]',$row['user_id'])."</td>
<td class='center' style='width:5%; text-align:center' >{$row['user_id']}</td>";
<td class='center' >".$frm->checkbox('user_selected[]',$user_id)."</td>
<td class='center' style='width:5%; text-align:center' >{$user_id}</td>";
// Display Chosen options
$datefields = array("user_lastpost","user_lastvisit","user_join","user_currentvisit");
$boleanfields = array("user_admin","user_hideemail","user_ban");
foreach ($this->fieldpref as $disp)
{
$text .= "<td style='white-space:nowrap'>";
if ($disp == 'user_class')
{
if ($user_class)
{
$tmp = explode(",",$user_class);
while (list($key,$class_id) = each($tmp))
{
$text .= $e107->user_class->uc_get_classname($class_id)."<br />\n";
$class = vartrue($this->fields[$disp]['thclass']) ? "class='".$this->fields[$disp]['thclass']."'" : "";
$text .= "<td ".$class." style='white-space:nowrap'>".$this->renderValue($disp,$row)."</td>\n";
}
}
else
{
$text .= "&nbsp;";
}
}
elseif ($disp == 'user_ip')
{
$text .= $e107->ipDecode($user_ip);
}
elseif (in_array($disp,$boleanfields))
{
$text .= ($row[$disp] == 1) ? ADMIN_TRUE_ICON : '';
}
elseif (in_array($disp,$datefields))
{
$text .= ($row[$disp]) ? strftime($pref['shortdate'],$row[$disp]).'&nbsp;' : '&nbsp';
}
elseif ($disp == 'user_name')
{
$text .= "<a href='".$e107->url->getUrl('core:user','main','func=profile&id='.$row['user_id'])."'>{$row['user_name']}</a>";
}
elseif ($disp == "user_status")
{
$text .= $this->showUserStatus($row);
}
else
{
$text .= $row[$disp].'&nbsp;';
}
$text .= "</td>";
}
// -------------------------------------------------------------
$qry = (e_QUERY) ? "?".e_QUERY : "";
$text .= "
<td style='width:30%' class='center'>".$this->showUserOptions($row)."</td></tr>";
<td style='width:30%' class='center'>".$this->showUserOptions($row)."</td></tr>\n";
}
$text .= "</tbody>
</table>
<div class='buttons-bar center'>".$this->show_batch_options();
$users = (e_QUERY != "unverified") ? $sql->db_Count("user") : $unverified;
if ($users > $amount && !$_POST['searchquery'])
{
$parms = "{$users},{$amount},{$from},".e_SELF."?".(e_QUERY ? "$action.$sub_action.$id." : "main.user_id.desc.")."[FROM]";
$text .= $tp->parseTemplate("{NEXTPREV={$parms}}");
}
if ($action == "unverified")
{
$qry = (e_QUERY) ? "?".e_QUERY : "";
$text .= "
<form method='post' action='".e_SELF.$qry."'>";
if ($pref['mail_bounce_pop3'] != '')
@@ -1133,14 +1116,82 @@ class users
$text .= "</fieldset></form>
</div>";
$emessage = & eMessage :: getInstance();
// ======================
$total_cap = (isset ($_POST['searchquery'])) ? $user_total : $users;
$caption = USRLAN_77."&nbsp;&nbsp; (total: $total_cap)";
$ns->tablerender($caption,$emessage->render().$text);
}
function renderValue($key,$row)
{
$frm = e107::getForm();
$e107 = e107 :: getInstance();
$type = $this->fields[$key]['type'];
$pref = e107::getConfig()->getPref();
switch($key) // switch based on field.
{
case 'user_class':
if ($row['user_class'])
{
$tmp = explode(",",$row['user_class']);
while (list($key,$class_id) = each($tmp))
{
$text .= $frm->uc_label($class_id)."<br />\n";
}
return $text;
}
else
{
return "&nbsp;";
}
break;
case 'user_ip':
return $e107->ipDecode($row['user_ip']);
break;
case 'user_status':
return $this->showUserStatus($row);
break;
case 'user_name':
return "<a href='".$e107->url->getUrl('core:user','main','func=profile&id='.$row['user_id'])."'>{$row['user_name']}</a>";
break;
case 'user_perms': //TODO display link to popup window with editable perms.
return $row[$key].'&nbsp;';
break;
}
switch($type) // switch based on type.
{
case 'date':
return ($row[$key]) ? strftime($pref['shortdate'],$row[$key]).'&nbsp;' : '&nbsp';
break;
case 'boolean':
return ($row[$key] == 1) ? ADMIN_TRUE_ICON : '';
break;
case 'user_status':
return $this->showUserStatus($row);
break;
}
return $row[$key].'&nbsp;';
}
function show_batch_options()
{
$e107 = e107::getInstance();