diff --git a/e107_admin/users.php b/e107_admin/users.php
index 756272424..d9eee766b 100644
--- a/e107_admin/users.php
+++ b/e107_admin/users.php
@@ -86,7 +86,7 @@ require_once (e_HANDLER.'userclass_class.php');
include_once (e_HANDLER.'user_extended_class.php');
require_once (e_HANDLER.'validator_class.php');
$user = new users;
-require_once ('auth.php');
+//require_once ('auth.php');
@@ -207,11 +207,13 @@ if (isset ($_POST['update_options']))
{
save_prefs();
// Only save if changes
- $user->show_message(USRLAN_1);
+ $mes->addSuccess(USRLAN_1);
+ //$user->show_message(USRLAN_1);
}
else
{
- $user->show_message(USRLAN_193);
+ $mes->addError(USRLAN_193);
+ // $user->show_message(USRLAN_193);
}
}
// ------- Prune Users. --------------
@@ -245,8 +247,16 @@ if (isset ($_POST['prune']))
// ------- Quick Add User --------------
-if (isset ($_POST['adduser']))
+function addUser()
{
+
+ $e107cache = e107::getCache();
+ $userMethods = e107::getUserSession();
+ $mes = e107::getMessage();
+ $sql = e107::getDb();
+ $e_event = e107::getEvent();
+ global $admin_log;
+
if (!$_POST['ac'] == md5(ADMINPWCHANGE))
{
exit;
@@ -296,9 +306,10 @@ if (isset ($_POST['adduser']))
}
if (count($allData['errors']))
{
- require_once (e_HANDLER."message_handler.php");
+ // require_once (e_HANDLER."message_handler.php");
$temp = validatorClass :: makeErrorList($allData,'USER_ERR_','%n - %x - %t: %v','
',$userMethods->userVettingInfo);
- message_handler('P_ALERT',$temp);
+ // message_handler('P_ALERT',$temp);
+ $mes->addError($temp);
$error = true;
}
// Always save some of the entered data - then we can redisplay on error
@@ -393,12 +404,17 @@ if (isset ($_POST['adduser']))
unset ($user_data);
// Don't recycle the data once the user's been accepted without error
}
+ $mes->addSuccess($message);
+ }
+ else
+ {
+
}
- if (isset ($message))
- {
- $user->show_message($message);
- }
+
+ // $mes = e107::getMessage();
+
+
}
// ------- Bounce --> Unverified --------------
@@ -415,6 +431,7 @@ if (isset ($_POST['useraction']) && $_POST['useraction'] == "reqverify")
$sub_action = "user_id";
}
}
+/*
if (isset ($_POST['useraction']) && $_POST['useraction'] == "ban")
{
$user->user_ban($_POST['userid']);
@@ -451,7 +468,7 @@ if (isset ($_POST['useraction']) && $_POST['useraction'] == 'userclass')
// exit;
$user->show_userclass($_POST['userid']);
}
-
+*/
// ---- Login as another user --------------------
if (isset ($_POST['useraction']) && $_POST['useraction'] == 'loginas')
{
@@ -513,6 +530,7 @@ if (isset ($_POST['useraction']) && $_POST['useraction'] == 'test')
$prm = e107::getUserPerms();
// ------- Make Admin --------------
+/*
if ((varset($_POST['useraction'])== "admin" || varset($_POST['useraction'])== "adminperms") && getperms('3'))
{
$sql->db_Select("user","user_id, user_name, user_perms","user_id='".$_POST['userid']."'");
@@ -540,7 +558,7 @@ if ((varset($_POST['useraction'])== "admin" || varset($_POST['useraction'])== "a
require_once ("footer.php");
exit;
}
-
+*/
if (varset($_POST['update_admin'])) // Update admin Perms.
{
$prm->updatePerms($_POST['a_id'],$_POST['perms']);
@@ -598,6 +616,582 @@ echo "from= ".$from."
";
echo "amount= ".$amount."
";
*/
// $unverified = $sql->db_Count("user","(*)","WHERE user_ban = 2");
+
+
+
+// ----------------------------- START NEW --------------------------
+
+class users_admin extends e_admin_dispatcher
+{
+
+ protected $modes = array(
+ 'main' => array(
+ 'controller' => 'users_admin_ui',
+ 'path' => null,
+ 'ui' => 'users_admin_form_ui',
+ 'uipath' => null
+ )
+ );
+
+
+ protected $adminMenu = array(
+ 'main/list' => array('caption'=> 'Manage', 'perm' => '0'),
+ 'main/add' => array('caption'=> LAN_USER_QUICKADD, 'perm' => '4|U0|U1'),
+ 'main/prefs' => array('caption'=> LAN_OPTIONS, 'perm' => '4|U2'),
+ 'main/ranks' => array('caption'=> LAN_USER_RANKS, 'perm' => '4|U3')
+ );
+
+ /*
+
+ $var ['prune']['text'] = LAN_USER_PRUNE;
+ $var ['prune']['link'] = e_ADMIN.'users.php?action=prune';// Will be moved to "Schedule tasks"
+ $var ['prune']['perm'] = '4';
+
+*/
+ protected $adminMenuAliases = array(
+ 'main/edit' => 'main/list'
+ );
+
+ protected $menuTitle = 'users';
+}
+
+
+class users_admin_ui extends e_admin_ui
+{
+
+ protected $pluginTitle = LAN_USER;
+ protected $pluginName = 'core';
+ protected $table = "user";
+
+ // protected $listQry = "SELECT SQL_CALC_FOUND_ROWS * FROM #users"; // without any Order or Limit.
+ protected $listQry = "SELECT u.*,ue.* from #user AS u left join #user_extended AS ue ON u.user_id = ue.user_extended_id "; // without any Order or Limit.
+
+ //protected $editQry = "SELECT * FROM #users WHERE comment_id = {ID}";
+
+ protected $pid = "user_id";
+ protected $perPage = 10;
+ protected $batchDelete = true;
+ protected $listOrder = 'user_id DESC';
+
+
+ //TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields
+ protected $fields = array(
+ 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
+
+ 'user_id' => array('title' => 'Id', 'type' =>'integer', 'width' => '5%','forced' => true),
+ // 'user_status' => array('title' => LAN_STATUS, 'type' => 'method', 'alias'=>'user_status', 'width' => 'auto','forced' => true, 'nosort'=>TRUE),
+ 'user_ban' => array('title' => LAN_STATUS, 'type' => 'method', 'width' => 'auto', 'filter'=>true, 'batch'=>true,'thclass'=>'center', 'class'=>'center'),
+
+ 'user_name' => array('title' => LAN_USER_01, 'type' => 'text', 'width' => 'auto','thclass' => 'left first'), // Display name
+ 'user_loginname' => array('title' => LAN_USER_02, 'type' => 'text', 'width' => 'auto'), // User name
+ 'user_login' => array('title' => LAN_USER_03, 'type' => 'text', 'width' => 'auto'), // Real name (no real vetting)
+ 'user_customtitle' => array('title' => LAN_USER_04, 'type' => 'text', 'width' => 'auto'), // No real vetting
+ 'user_password' => array('title' => LAN_USER_05, 'type' => 'text', 'width' => 'auto'),
+ 'user_sess' => array('title' => 'session', 'type' => 'text', 'width' => 'auto'), // Photo
+ 'user_image' => array('title' => LAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar
+ 'user_email' => array('title' => LAN_USER_08, 'type' => 'text', 'width' => 'auto'),
+ 'user_hideemail' => array('title' => LAN_USER_10, 'type' => 'boolean', 'width' => 'auto', 'thclass'=>'center', 'class'=>'center', 'filter'=>true, 'batch'=>true, 'readParms'=>'trueonly=1'),
+ 'user_xup' => array('title' => 'Xup', 'type' => 'text', 'width' => 'auto'),
+ 'user_class' => array('title' => LAN_USER_12, 'type' => 'userclass' , 'filter'=>true, 'batch'=>true),
+ 'user_join' => array('title' => LAN_USER_14, 'type' => 'datestamp', 'width' => 'auto'),
+ 'user_lastvisit' => array('title' => LAN_USER_15, 'type' => 'datestamp', 'width' => 'auto'),
+ 'user_currentvisit' => array('title' => LAN_USER_16, 'type' => 'datestamp', 'width' => 'auto'),
+ 'user_comments' => array('title' => LAN_USER_17, 'type' => 'integer', 'width' => 'auto','thclass'=>'right','class'=>'right'),
+ 'user_lastpost' => array('title' => 'Last Post', 'type' => 'datestamp', 'width' => 'auto'),
+ 'user_ip' => array('title' => LAN_USER_18, 'type' => 'ip', 'width' => 'auto'),
+ // 'user_prefs' => array('title' => LAN_USER_20, 'type' => 'text', 'width' => 'auto'),
+ 'user_visits' => array('title' => LAN_USER_21, 'type' => 'integer', 'width' => 'auto','thclass'=>'right','class'=>'right'),
+ 'user_admin' => array('title' => LAN_USER_22, 'type' => 'boolean', 'width' => 'auto', 'thclass'=>'center', 'class'=>'center', 'filter'=>true, 'batch'=>true, 'readParms'=>'trueonly=1'),
+ 'user_perms' => array('title' => LAN_USER_23, 'type' => 'method', 'width' => 'auto'),
+ 'user_pwchange' => array('title' => LAN_USER_24, 'type'=>'datestamp' , 'width' => 'auto'),
+
+ );
+
+ protected $fieldpref = array('user_ban','user_name','user_loginname','user_login','user_email','user_class','user_ban','user_admin');
+
+ protected $prefs = array(
+ // 'anon_post' => array('title'=>PRFLAN_32, 'type'=>'boolean'),
+ );
+
+
+
+ function init()
+ {
+
+ $sql = e107::getDb();
+ $tp = e107::getParser();
+ if($sql->db_Select('user_extended_struct', 'user_extended_struct_name,user_extended_struct_text', "user_extended_struct_type > 0 AND user_extended_struct_text != '_system_' ORDER BY user_extended_struct_parent ASC"))
+ {
+ while ($row = $sql->db_Fetch())
+ {
+ $field = "user_".$row['user_extended_struct_name'];
+ $title = ucfirst(str_replace("user_","",$field));
+ $label = $tp->toHtml($row['user_extended_struct_text'],false,'defs');
+ $this->fields[$field] = array('title' => $label,'width' => 'auto','type'=>'text');
+ }
+ }
+
+
+ $this->fields['user_signature'] = array('title' => LAN_USER_09, 'type' => 'bbarea', 'width' => 'auto');
+
+
+ $this->fields['options'] = array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center');
+
+
+ if(!getperms('4|U0')) // Quick Add User Access Only.
+ {
+ unset($this->fields['checkboxes']);
+ unset($this->fields['options']);
+ }
+
+ if ((varset($_POST['useraction'])== "admin" || varset($_POST['useraction'])== "adminperms") && getperms('3'))
+ {
+ $this->adminPerms();
+ }
+
+ if(isset ($_POST['adduser']))
+ {
+ addUser();
+ }
+
+ }
+
+ function ranksPage()
+ {
+ //echo "hello";
+ showRanks();
+
+ }
+
+ function adminPerms() // ------- Make Admin -------------- // - maybe no longer needed - on 'edit' page now.
+ {
+
+ $sql = e107::getDb();
+
+ global $admin_log,$user;
+
+ $sql->db_Select("user","user_id, user_name, user_perms","user_id='".$_POST['userid']."'");
+ $row = $sql->db_Fetch();
+
+ if(varset($_POST['useraction'])== "admin")
+ {
+ $sql->db_Update("user","user_admin='1' WHERE user_id='".$_POST['userid']."' ");
+ }
+
+ $admin_log->log_event('USET_08',str_replace(array('--UID--','--NAME--'),array($row['user_id'],$row['user_name']),USRLAN_164),E_LOG_INFORMATIVE);
+ // $user->show_message($row['user_name']." ".USRLAN_3." ".USRLAN_4."");
+ $action = "main";
+ if (!$sub_action)
+ {
+ $sub_action = "user_id";
+ }
+ if (!$id)
+ {
+ $id = "DESC";
+ }
+
+ $prm = e107::getUserPerms();
+ $prm->edit_administrator($row);
+
+ }
+
+
+
+ function addPage()
+ {
+
+ global $rs,$pref,$e_userclass;
+
+ $prm = e107::getUserPerms();
+ $list = $prm->getPermList();
+ $frm = e107::getForm();
+ $ns = e107::getRender();
+ $mes = e107::getMessage();
+
+ if (!is_object($e_userclass)) $e_userclass = new user_class;
+
+
+ $text = "
".USRLAN_61." | ++ ".$rs->form_text('username',40,varset($user_data['user_name'],""),varset($pref['displayname_maxlength'],15))." + | +
".USRLAN_128." | ++ ".$rs->form_text('loginname',40,varset($user_data['user_loginname'],""),varset($pref['loginname_maxlength'],30))." + ".$frm->checkbox_label(USRLAN_170,'generateloginname', 1,varset($pref['predefinedLoginName'],false))." + | +
".USRLAN_129." | ++ ".$rs->form_text("realname",40,varset($user_data['user_login'],""),30)." + | +
".USRLAN_62." | +".$frm->password('password','',20,array('size'=>40,'class'=>'tbox e-password-admin'))." | +
".USRLAN_64." | ++ ".$rs->form_text("email",60,varset($user_data['user_email'],""),100)." + | +
Require Confirmation | +".$frm->checkbox_label(USRLAN_181,'sendconfemail', 1)." | +
+ ".USRLAN_120." + |
+ ".USRLAN_120."
+
+ {$temp}
+ |
+
".USRLAN_35." | +
+ Set Permissions
+ \n";
+
+ $text .= $prm->renderPermTable('grouped');
+
+ $text .= " |
+