mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 22:27:34 +02:00
Removed all SQL queries from usersettings_shortcodes.
This commit is contained in:
@@ -12,25 +12,44 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if(!defined('e107_INIT'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
e107::coreLan('user');
|
e107::coreLan('user');
|
||||||
e107::coreLan('usersettings');
|
e107::coreLan('usersettings');
|
||||||
|
|
||||||
|
|
||||||
class usersettings_shortcodes extends e_shortcode
|
class usersettings_shortcodes extends e_shortcode
|
||||||
{
|
{
|
||||||
|
|
||||||
private $extendedTabs = false;
|
private $extendedTabs = false;
|
||||||
public $legacyTemplate = array();
|
public $legacyTemplate = array();
|
||||||
private $pref;
|
private $pref;
|
||||||
|
private $extendedShown = array();
|
||||||
|
|
||||||
|
private $catInfo = array(); // user's extended-field category list data;
|
||||||
|
private $fieldInfo = array(); // user's extended-field field list data;
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
$this->pref = e107::getPref();
|
$this->pref = e107::getPref();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset so that extended field data is reloaded.
|
||||||
|
public function reset()
|
||||||
|
{
|
||||||
|
$this->extendedShown = array();
|
||||||
|
$this->fieldInfo = array();
|
||||||
|
$this->catInfo = array();
|
||||||
|
$this->extendedTabs = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function sc_username($parm = null) // This is the 'display name'
|
function sc_username($parm = null) // This is the 'display name'
|
||||||
{
|
{
|
||||||
|
|
||||||
$pref = $this->pref;
|
$pref = $this->pref;
|
||||||
$dis_name_len = varset($pref['displayname_maxlength'], 15);
|
$dis_name_len = varset($pref['displayname_maxlength'], 15);
|
||||||
|
|
||||||
@@ -82,19 +101,21 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
// No write permission.
|
// No write permission.
|
||||||
$options['readonly'] = true;
|
$options['readonly'] = true;
|
||||||
|
|
||||||
return e107::getForm()->text('loginname', $this->var['user_loginname'], $log_name_length, $options);
|
return e107::getForm()->text('loginname', $this->var['user_loginname'], $log_name_length, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_customtitle($parm = null)
|
function sc_customtitle($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if($this->pref['signup_option_customtitle'])
|
if($this->pref['signup_option_customtitle'])
|
||||||
{
|
{
|
||||||
$options = array(
|
$options = array(
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'size' => 40,
|
'size' => 40,
|
||||||
'required' => ($this->pref['signup_option_customtitle'] == 2));
|
'required' => ($this->pref['signup_option_customtitle'] == 2));
|
||||||
|
|
||||||
return e107::getForm()->text('customtitle', $this->var['user_customtitle'], 100, $options);
|
return e107::getForm()->text('customtitle', $this->var['user_customtitle'], 100, $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,6 +174,7 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
if(!isset($pref['auth_method']) || $pref['auth_method'] == '' || $pref['auth_method'] == 'e107' || $pref['auth_method'] == '>e107')
|
if(!isset($pref['auth_method']) || $pref['auth_method'] == '' || $pref['auth_method'] == 'e107' || $pref['auth_method'] == '>e107')
|
||||||
{
|
{
|
||||||
$options = array('size' => 40, 'title' => LAN_USET_23, 'required' => 0, 'autocomplete' => 'off');
|
$options = array('size' => 40, 'title' => LAN_USET_23, 'required' => 0, 'autocomplete' => 'off');
|
||||||
|
|
||||||
return e107::getForm()->password('password1', '', 20, $options);
|
return e107::getForm()->password('password1', '', 20, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +182,6 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_password2($parm = null)
|
function sc_password2($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -172,6 +193,7 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
if(!isset($this->pref['auth_method']) || $this->pref['auth_method'] == '' || $this->pref['auth_method'] == 'e107' || $this->pref['auth_method'] == '>e107')
|
if(!isset($this->pref['auth_method']) || $this->pref['auth_method'] == '' || $this->pref['auth_method'] == 'e107' || $this->pref['auth_method'] == '>e107')
|
||||||
{
|
{
|
||||||
$options = array('size' => 40, 'title' => LAN_USET_23, 'required' => 0);
|
$options = array('size' => 40, 'title' => LAN_USET_23, 'required' => 0);
|
||||||
|
|
||||||
return e107::getForm()->password('password2', '', 20, $options);
|
return e107::getForm()->password('password2', '', 20, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,20 +201,21 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_password_len($parm = null)
|
function sc_password_len($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!isset($this->pref['auth_method']) || ($this->pref['auth_method'] != 'e107' && $this->pref['auth_method'] != '>e107'))
|
if(!isset($this->pref['auth_method']) || ($this->pref['auth_method'] != 'e107' && $this->pref['auth_method'] != '>e107'))
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->pref['signup_pass_len'];
|
return $this->pref['signup_pass_len'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_email($parm = null)
|
function sc_email($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$sc = $this;
|
$sc = $this;
|
||||||
|
|
||||||
$options = array(
|
$options = array(
|
||||||
@@ -200,7 +223,10 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
'title' => '',
|
'title' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (e107::getPref('disable_emailcheck') == 0) $options['required'] = true;
|
if(e107::getPref('disable_emailcheck') == 0)
|
||||||
|
{
|
||||||
|
$options['required'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(!empty($sc->var['user_email']) && !empty($sc->var['user_xup'])) // social login active.
|
if(!empty($sc->var['user_email']) && !empty($sc->var['user_xup'])) // social login active.
|
||||||
{
|
{
|
||||||
@@ -211,20 +237,21 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_hideemail($parm = null)
|
function sc_hideemail($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if($parm == 'radio')
|
if($parm == 'radio')
|
||||||
{
|
{
|
||||||
$options['enabled'] = array('title' => LAN_USER_84);
|
$options['enabled'] = array('title' => LAN_USER_84);
|
||||||
|
|
||||||
return "<div class='radio'>" . e107::getForm()->radio_switch("hideemail", $this->var['user_hideemail'], LAN_YES, LAN_NO, $options) . "</div>";
|
return "<div class='radio'>" . e107::getForm()->radio_switch("hideemail", $this->var['user_hideemail'], LAN_YES, LAN_NO, $options) . "</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_userclasses($parm = null)
|
function sc_userclasses($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
global $e_userclass;
|
global $e_userclass;
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
@@ -233,15 +260,24 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (!is_object($e_userclass)) $e_userclass = new user_class;
|
if(!is_object($e_userclass))
|
||||||
$ucList = $e_userclass->get_editable_classes(USERCLASS_LIST, TRUE); // List of classes which this user can edit (as array)
|
{
|
||||||
|
$e_userclass = new user_class;
|
||||||
|
}
|
||||||
|
$ucList = $e_userclass->get_editable_classes(USERCLASS_LIST, true); // List of classes which this user can edit (as array)
|
||||||
$ret = '';
|
$ret = '';
|
||||||
if(!count($ucList)) return;
|
if(!count($ucList))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$is_checked = array();
|
$is_checked = array();
|
||||||
foreach($ucList as $cid)
|
foreach($ucList as $cid)
|
||||||
{
|
{
|
||||||
if (check_class($cid, $this->var['user_class'])) $is_checked[$cid] = $cid;
|
if(check_class($cid, $this->var['user_class']))
|
||||||
|
{
|
||||||
|
$is_checked[$cid] = $cid;
|
||||||
|
}
|
||||||
// if(isset($_POST['class']))
|
// if(isset($_POST['class']))
|
||||||
// {
|
// {
|
||||||
// $is_checked[$cid] = in_array($cid, $_POST['class']);
|
// $is_checked[$cid] = in_array($cid, $_POST['class']);
|
||||||
@@ -252,15 +288,16 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
// $ret = "<table style='width:95%;margin-left:0px'><tr><td class='defaulttext'>";
|
// $ret = "<table style='width:95%;margin-left:0px'><tr><td class='defaulttext'>";
|
||||||
$ret .= $e_userclass->vetted_tree('class', array($e_userclass, 'checkbox_desc'), $inclass, 'editable, no-excludes');
|
$ret .= $e_userclass->vetted_tree('class', array($e_userclass, 'checkbox_desc'), $inclass, 'editable, no-excludes');
|
||||||
|
|
||||||
// $ret .= "</td></tr></table>\n";
|
// $ret .= "</td></tr></table>\n";
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_signature($parm = null)
|
function sc_signature($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!check_class(varset($this->pref['signature_access'], 0)))
|
if(!check_class(varset($this->pref['signature_access'], 0)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -278,6 +315,7 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
*/
|
*/
|
||||||
function sc_signature_help($parm = null)
|
function sc_signature_help($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
return;
|
return;
|
||||||
/*
|
/*
|
||||||
$pref = e107::getPref();
|
$pref = e107::getPref();
|
||||||
@@ -290,16 +328,16 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_avatar_upload($parm = null) // deprecated and combined into avatarpicker() (see sc_avatar_remote)
|
function sc_avatar_upload($parm = null) // deprecated and combined into avatarpicker() (see sc_avatar_remote)
|
||||||
{
|
{
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_avatar_remote($parm = null)
|
function sc_avatar_remote($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!empty($this->var['user_xup'])) // social login active.
|
if(!empty($this->var['user_xup'])) // social login active.
|
||||||
{
|
{
|
||||||
// return $this->var['user_image'];
|
// return $this->var['user_image'];
|
||||||
@@ -310,16 +348,16 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_avatar_choose($parm = null) // deprecated
|
function sc_avatar_choose($parm = null) // deprecated
|
||||||
{
|
{
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_photo_upload($parm = null)
|
function sc_photo_upload($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$diz = LAN_USET_27 . ". " . LAN_USET_28 . ".";
|
$diz = LAN_USET_27 . ". " . LAN_USET_28 . ".";
|
||||||
$text = '';
|
$text = '';
|
||||||
|
|
||||||
@@ -344,50 +382,33 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function sc_userextended_all($parm = '')
|
function sc_userextended_all($parm = '')
|
||||||
{
|
{
|
||||||
$sql = e107::getDb();
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
|
|
||||||
if(empty($this->var['userclass_list']) && ADMIN)
|
$this->reset();
|
||||||
|
|
||||||
|
if(empty($this->catInfo))
|
||||||
{
|
{
|
||||||
return '$this->var[\'userclass_list\'] is empty';
|
$this->loadUECatData();
|
||||||
}
|
}
|
||||||
|
|
||||||
$qry = "
|
$catList = $this->catInfo;
|
||||||
SELECT * FROM #user_extended_struct
|
|
||||||
WHERE user_extended_struct_applicable IN (".$tp -> toDB($this->var['userclass_list'], true).")
|
|
||||||
AND user_extended_struct_write IN (".USERCLASS_LIST.")
|
|
||||||
AND user_extended_struct_type = 0
|
|
||||||
ORDER BY user_extended_struct_order ASC";
|
|
||||||
|
|
||||||
$ret="";
|
|
||||||
|
|
||||||
if($sql->gen($qry))
|
|
||||||
{
|
|
||||||
$catList = $sql->db_getList();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e107::getMessage()->addDebug("No extended fields found");
|
|
||||||
$catList = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$catList[] = array("user_extended_struct_id" => 0, "user_extended_struct_name" => LAN_USET_7);
|
|
||||||
|
|
||||||
$tabs = array();
|
$tabs = array();
|
||||||
|
|
||||||
if($parm == 'tabs' && deftrue('BOOTSTRAP'))
|
if($parm === 'tabs' && deftrue('BOOTSTRAP'))
|
||||||
{
|
{
|
||||||
$this->extendedTabs = true;
|
$this->extendedTabs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ret = '';
|
||||||
|
|
||||||
foreach($catList as $cat)
|
foreach($catList as $cat)
|
||||||
{
|
{
|
||||||
e107::setRegistry("core/shortcodes/usersettings/userextended/cat_".$cat['user_extended_struct_id'], $cat);
|
$this->catInfo[$cat['user_extended_struct_id']] = $cat;
|
||||||
$text = $this->sc_userextended_cat($cat['user_extended_struct_id']);
|
$text = $this->sc_userextended_cat($cat['user_extended_struct_id']);
|
||||||
$ret .= $text;
|
$ret .= $text;
|
||||||
$catName = vartrue($cat['user_extended_struct_text'], $cat['user_extended_struct_name']);
|
$catName = vartrue($cat['user_extended_struct_text'], $cat['user_extended_struct_name']);
|
||||||
@@ -402,17 +423,20 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
return e107::getForm()->tabs($tabs);
|
return e107::getForm()->tabs($tabs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function sc_userextended_cat($parm = 0)
|
public function sc_userextended_cat($parm = 0)
|
||||||
{
|
{
|
||||||
global $extended_showed;
|
|
||||||
|
|
||||||
$parm = (int) $parm;
|
$parm = (int) $parm;
|
||||||
|
|
||||||
|
if(empty($this->catInfo))
|
||||||
|
{
|
||||||
|
$this->loadUECatData('write');
|
||||||
|
}
|
||||||
|
|
||||||
if(THEME_LEGACY === true)
|
if(THEME_LEGACY === true)
|
||||||
{
|
{
|
||||||
$USER_EXTENDED_CAT = $this->legacyTemplate['USER_EXTENDED_CAT'];
|
$USER_EXTENDED_CAT = $this->legacyTemplate['USER_EXTENDED_CAT'];
|
||||||
@@ -422,98 +446,140 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
$USER_EXTENDED_CAT = e107::getCoreTemplate('usersettings', 'extended-category');
|
$USER_EXTENDED_CAT = e107::getCoreTemplate('usersettings', 'extended-category');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(empty($USER_EXTENDED_CAT))
|
||||||
|
{
|
||||||
|
trigger_error('User settings template key "extended-category" was empty', E_USER_NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql = e107::getDb();
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
if(isset($extended_showed['cat'][$parm]))
|
if(!empty($this->extendedShown['cat'][$parm]))
|
||||||
{
|
{
|
||||||
|
trigger_error('Category already shown. Use ->reset()', E_USER_NOTICE);
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = "";
|
$catInfo = varset($this->catInfo[$parm]);
|
||||||
$catInfo = e107::getRegistry("core/shortcodes/usersettings/userextended/cat_{$parm}");
|
|
||||||
if(!$catInfo)
|
if(empty($catInfo))
|
||||||
{
|
{
|
||||||
$qry = "
|
return null;
|
||||||
SELECT * FROM #user_extended_struct
|
|
||||||
WHERE user_extended_struct_applicable IN (" . $tp->toDB($this->var['userclass_list'], true) . ")
|
|
||||||
AND user_extended_struct_write IN (" . USERCLASS_LIST . ")
|
|
||||||
AND user_extended_struct_id = " . (int) $parm . "
|
|
||||||
";
|
|
||||||
if($sql->gen($qry))
|
|
||||||
{
|
|
||||||
$catInfo = $sql->fetch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ret = '';
|
||||||
|
|
||||||
|
if($fieldList = $this->loadUEFieldData('write', $parm))
|
||||||
|
{
|
||||||
|
foreach($fieldList as $field => $row)
|
||||||
|
{
|
||||||
|
$ret .= $this->sc_userextended_field($field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trigger_error(__METHOD__ . ' -- $fieldList is empty. Line: ' . __LINE__, E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($catInfo)
|
if(!empty($ret) && ($this->extendedTabs === false))
|
||||||
{
|
|
||||||
$qry = "
|
|
||||||
SELECT * FROM #user_extended_struct
|
|
||||||
WHERE user_extended_struct_applicable IN (" . $tp->toDB($this->var['userclass_list'], true) . ")
|
|
||||||
AND user_extended_struct_write IN (" . USERCLASS_LIST . ")
|
|
||||||
AND user_extended_struct_parent = " . (int) $parm . "
|
|
||||||
AND user_extended_struct_type != 0
|
|
||||||
ORDER BY user_extended_struct_order ASC
|
|
||||||
";
|
|
||||||
|
|
||||||
if($sql->gen($qry))
|
|
||||||
{
|
|
||||||
$fieldList = $sql->db_getList();
|
|
||||||
foreach($fieldList as $field)
|
|
||||||
{
|
|
||||||
e107::setRegistry("core/shortcodes/usersettings/userextended/{$field['user_extended_struct_name']}", $field);
|
|
||||||
$ret .= $this->sc_userextended_field($field['user_extended_struct_name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($ret && $this->extendedTabs == false)
|
|
||||||
{
|
{
|
||||||
$catName = !empty($catInfo['user_extended_struct_text']) ? $catInfo['user_extended_struct_text'] : $catInfo['user_extended_struct_name'];
|
$catName = !empty($catInfo['user_extended_struct_text']) ? $catInfo['user_extended_struct_text'] : $catInfo['user_extended_struct_name'];
|
||||||
if(defined($catName))
|
$ret = str_replace("{CATNAME}", $tp->toHTML($catName, false, 'TITLE'), $USER_EXTENDED_CAT) . $ret;
|
||||||
{
|
|
||||||
$catName = constant($catName);
|
|
||||||
}
|
|
||||||
$ret = str_replace("{CATNAME}", $tp->toHTML($catName, false, 'emotes_off,defs'), $USER_EXTENDED_CAT) . $ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$extended_showed['cat'][$parm] = 1;
|
if(empty($ret))
|
||||||
|
{
|
||||||
|
trigger_error(__METHOD__ . ' returned nothing. Line: ' . __LINE__, E_USER_NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->extendedShown['cat'][$parm] = true;
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserExtendedFieldData($name)
|
|
||||||
{
|
|
||||||
$tp = e107::getParser();
|
|
||||||
$sql = e107::getDb();
|
|
||||||
|
|
||||||
$fInfo = array();
|
/**
|
||||||
|
* Return a list of User-Extended categories based on the logged in user permissions.
|
||||||
$qry = "
|
* For Internal Use Only
|
||||||
SELECT * FROM #user_extended_struct
|
* @param string $perm read|write|applicable
|
||||||
WHERE user_extended_struct_applicable IN (" . $tp->toDB($this->var['userclass_list'], true) . ")
|
*/
|
||||||
AND user_extended_struct_write IN (" . USERCLASS_LIST . ")
|
public function loadUECatData($perm = 'read')
|
||||||
AND user_extended_struct_name = '" . $tp->toDB($name, true) . "'
|
|
||||||
";
|
|
||||||
if($sql->gen($qry))
|
|
||||||
{
|
{
|
||||||
$fInfo = $sql->fetch();
|
|
||||||
|
$ue = e107::getUserExt();
|
||||||
|
$data = (array) $ue->getCategories();
|
||||||
|
$uclass = !empty($this->var['userclass_list']) ? $this->var['userclass_list'] : USERCLASS_LIST;
|
||||||
|
|
||||||
|
$this->catInfo = [];
|
||||||
|
foreach($data as $id => $row)
|
||||||
|
{
|
||||||
|
$userclass = (int) $row['user_extended_struct_' . $perm];
|
||||||
|
if(check_class($userclass, $uclass))
|
||||||
|
{
|
||||||
|
$this->catInfo[$id] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fInfo;
|
}
|
||||||
|
|
||||||
|
$this->catInfo[0] = array("user_extended_struct_id" => 0, "user_extended_struct_name" => LAN_USET_7);
|
||||||
|
|
||||||
|
return $this->catInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Fields by category ID and perms v2.3.1 for the current user. ie. respecting userclass permissionss.
|
||||||
|
* For Internal Use Only
|
||||||
|
* @param string $perm
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function loadUEFieldData($perm = 'read', $cat = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$uclass = !empty($this->var['userclass_list']) ? $this->var['userclass_list'] : USERCLASS_LIST;
|
||||||
|
|
||||||
|
$ue = e107::getUserExt();
|
||||||
|
$data = (array) $ue->getFields($cat);
|
||||||
|
|
||||||
|
if(empty($data))
|
||||||
|
{
|
||||||
|
trigger_error('$data was empty', E_USER_NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->fieldInfo = [];
|
||||||
|
foreach($data as $k => $row)
|
||||||
|
{
|
||||||
|
$fieldname = 'user_' . $row['user_extended_struct_name'];
|
||||||
|
|
||||||
|
if($ue->hasPermission($fieldname, $perm, $uclass) && $ue->hasPermission($fieldname, 'applicable', $uclass))
|
||||||
|
{
|
||||||
|
$key = $row['user_extended_struct_name'];
|
||||||
|
$this->fieldInfo[$key] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->fieldInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $parm extended field name without the 'user_' prefix.
|
||||||
|
* @return string|string[]
|
||||||
|
*/
|
||||||
function sc_userextended_field($parm = null)
|
function sc_userextended_field($parm = null)
|
||||||
{
|
{
|
||||||
global $extended_showed;
|
|
||||||
if(empty($parm))
|
if(empty($parm) || !empty($this->extendedShown['field'][$parm]))
|
||||||
{
|
{
|
||||||
$parm = '';
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty($this->fieldInfo))
|
||||||
|
{
|
||||||
|
$this->loadUEFieldData('write');
|
||||||
}
|
}
|
||||||
|
|
||||||
$ue = e107::getUserExt();
|
$ue = e107::getUserExt();
|
||||||
@@ -531,25 +597,18 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(isset($extended_showed['field'][$parm]))
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = e107::getDb();
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
$ret = "";
|
$ret = "";
|
||||||
|
|
||||||
$fInfo = e107::getRegistry("extendeddata_{$parm}");
|
$fInfo = varset($this->fieldInfo[$parm]);
|
||||||
|
|
||||||
if(!$fInfo)
|
if(empty($fInfo))
|
||||||
{
|
{
|
||||||
$fInfo = $this->getUserExtendedFieldData($parm);
|
trigger_error('$fInfo was empty', E_USER_NOTICE);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($fInfo)
|
|
||||||
{
|
|
||||||
$fname = $fInfo['user_extended_struct_text'];
|
$fname = $fInfo['user_extended_struct_text'];
|
||||||
|
|
||||||
if(defined($fname))
|
if(defined($fname))
|
||||||
@@ -586,16 +645,14 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
$rVal = !empty($fInfo['user_extended_struct_required']);
|
$rVal = !empty($fInfo['user_extended_struct_required']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$ret = $USEREXTENDED_FIELD;
|
$ret = $USEREXTENDED_FIELD;
|
||||||
$ret = str_replace("{FIELDNAME}", $fname, $ret);
|
$ret = str_replace("{FIELDNAME}", $fname, $ret);
|
||||||
$ret = str_replace("{FIELDVAL}", $fval, $ret);
|
$ret = str_replace("{FIELDVAL}", $fval, $ret);
|
||||||
$ret = str_replace("{HIDEFIELD}", $fhide, $ret);
|
$ret = str_replace("{HIDEFIELD}", $fhide, $ret);
|
||||||
$ret = str_replace("{REQUIRED}", $this->required($rVal), $ret);
|
$ret = str_replace("{REQUIRED}", $this->required($rVal), $ret);
|
||||||
}
|
|
||||||
|
|
||||||
$extended_showed['field'][$parm] = 1;
|
|
||||||
|
$this->extendedShown['field'][$parm] = true;
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@@ -610,6 +667,7 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
private function required($val = null)
|
private function required($val = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(empty($val))
|
if(empty($val))
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
@@ -621,6 +679,7 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
function sc_required($parm = null)
|
function sc_required($parm = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(empty($parm) || !isset($this->pref['signup_option_' . $parm]))
|
if(empty($parm) || !isset($this->pref['signup_option_' . $parm]))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@@ -127,7 +127,7 @@ class e107_user_extended
|
|||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb('ue');
|
||||||
|
|
||||||
// Read in all the field and category fields
|
// Read in all the field and category fields
|
||||||
// At present we load all fields into common array - may want to split system and non-system
|
// At present we load all fields into common array - may want to split system and non-system
|
||||||
@@ -195,13 +195,23 @@ class e107_user_extended
|
|||||||
/**
|
/**
|
||||||
* Check read/write access on extended user-fields
|
* Check read/write access on extended user-fields
|
||||||
* @param string $field eg. user_something
|
* @param string $field eg. user_something
|
||||||
* @param string $type read|write
|
* @param string $type read|write|applicable
|
||||||
* @return boolean true if
|
* @return boolean true if
|
||||||
*/
|
*/
|
||||||
public function hasPermission($field, $type='read')
|
public function hasPermission($field, $type='read', $classList=null)
|
||||||
{
|
{
|
||||||
$class = ($type == 'read') ? $this->fieldAttributes[$field]['read'] : $this->fieldAttributes[$field]['write'];
|
if($classList === null)
|
||||||
return check_class($class);
|
{
|
||||||
|
$classList = USERCLASS_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($this->fieldAttributes[$field][$type]))
|
||||||
|
{
|
||||||
|
trigger_error('$this->fieldAttributes['.$field.']['.$type.'] was not set', E_USER_NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = $this->fieldAttributes[$field][$type];
|
||||||
|
return check_class($class, $classList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -552,10 +562,9 @@ class e107_user_extended
|
|||||||
/**
|
/**
|
||||||
* alias of user_extended_get_categories();
|
* alias of user_extended_get_categories();
|
||||||
*
|
*
|
||||||
* @param bool $byID
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getCategories($byID = TRUE)
|
function getCategories()
|
||||||
{
|
{
|
||||||
return $this->catDefinitions;
|
return $this->catDefinitions;
|
||||||
}
|
}
|
||||||
@@ -591,13 +600,14 @@ class e107_user_extended
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BC Alias of getFields();
|
* Returns an array of fields for the selected category.
|
||||||
|
* The keys are the field name, minus the 'user_'.
|
||||||
* @param string $cat
|
* @param string $cat
|
||||||
* @return mixed
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getFields($cat = "")
|
public function getFields($cat = null)
|
||||||
{
|
{
|
||||||
return $this->user_extended_get_fieldList($cat);
|
return $this->user_extended_get_fieldList($cat, 'user_extended_struct_name');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -885,7 +895,7 @@ class e107_user_extended
|
|||||||
|
|
||||||
function user_extended_field_exist($name)
|
function user_extended_field_exist($name)
|
||||||
{
|
{
|
||||||
$sql = e107::getDb('sql2');
|
$sql = e107::getDb('ue');
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
return $sql->count('user_extended_struct','(*)', "WHERE user_extended_struct_name = '".$tp -> toDB($name, true)."'");
|
return $sql->count('user_extended_struct','(*)', "WHERE user_extended_struct_name = '".$tp -> toDB($name, true)."'");
|
||||||
}
|
}
|
||||||
@@ -985,7 +995,6 @@ class e107_user_extended
|
|||||||
if(!$this->user_extended_field_exist($name))
|
if(!$this->user_extended_field_exist($name))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$nid = $sql->insert('user_extended_struct', $extStructInsert);
|
$nid = $sql->insert('user_extended_struct', $extStructInsert);
|
||||||
$this->init(); // rebuild the list.
|
$this->init(); // rebuild the list.
|
||||||
|
|
||||||
@@ -1580,7 +1589,7 @@ class e107_user_extended
|
|||||||
*/
|
*/
|
||||||
function user_extended_setvalue($uid, $field_name, $newvalue, $fieldType = 'todb')
|
function user_extended_setvalue($uid, $field_name, $newvalue, $fieldType = 'todb')
|
||||||
{
|
{
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb('ue');
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
$uid = (int)$uid;
|
$uid = (int)$uid;
|
||||||
|
@@ -26,15 +26,13 @@
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->ue = $this->make('e107_user_extended');
|
$this->ue = e107::getUserExt(); // $this->make('e107_user_extended');
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
$this->assertTrue(false, "Couldn't load e107_user_extended object");
|
$this->assertTrue(false, "Couldn't load e107_user_extended object");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ue->__construct();
|
|
||||||
|
|
||||||
|
|
||||||
$this->structTypes = array(
|
$this->structTypes = array(
|
||||||
'text' => EUF_TEXT,
|
'text' => EUF_TEXT,
|
||||||
@@ -120,9 +118,13 @@
|
|||||||
|
|
||||||
// clear the table.
|
// clear the table.
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
if($sql->select('user_extended_struct', 'user_extended_struct_id', "user_extended_struct_text = '_system_'"))
|
$fieldCount = (int) $sql->count('user_extended_struct');
|
||||||
|
|
||||||
|
if($fieldCount > 17)
|
||||||
{
|
{
|
||||||
|
codecept_debug("Truncating user_extended_struct");
|
||||||
$sql->truncate('user_extended_struct');
|
$sql->truncate('user_extended_struct');
|
||||||
|
$this->ue->init(); // reload the extended fields from db.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -140,6 +142,9 @@
|
|||||||
'default' => (isset($this->structDefault[$k])) ? $this->structDefault[$k] : null,
|
'default' => (isset($this->structDefault[$k])) ? $this->structDefault[$k] : null,
|
||||||
'parent' => (isset($this->structParent[$k])) ? $this->structParent[$k] : 0,
|
'parent' => (isset($this->structParent[$k])) ? $this->structParent[$k] : 0,
|
||||||
'required' => (isset($this->structRequired[$k])) ? $this->structRequired[$k] : 0,
|
'required' => (isset($this->structRequired[$k])) ? $this->structRequired[$k] : 0,
|
||||||
|
'read' => e_UC_MEMBER,
|
||||||
|
'write' => e_UC_ADMIN,
|
||||||
|
'applicable' => e_UC_MAINADMIN,
|
||||||
);
|
);
|
||||||
|
|
||||||
// simulate data from e_user.php 'settings' method.
|
// simulate data from e_user.php 'settings' method.
|
||||||
@@ -220,6 +225,44 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUserextendedCatShortcode()
|
||||||
|
{
|
||||||
|
$sc = e107::getScBatch('usersettings');
|
||||||
|
$sc->reset();
|
||||||
|
|
||||||
|
$perms = array(e_UC_PUBLIC, e_UC_MEMBER, e_UC_ADMIN, e_UC_MAINADMIN);
|
||||||
|
$sc->setVars(array('userclass_list' => implode(',',$perms)));
|
||||||
|
$cat = (int) e107::getDb()->retrieve('user_extended_struct', 'user_extended_struct_id', "user_extended_struct_name = 'mycategory' LIMIT 1");
|
||||||
|
|
||||||
|
|
||||||
|
$result = $sc->sc_userextended_cat($cat);
|
||||||
|
$this->assertStringContainsString('<h3>Category Name</h3>', $result);
|
||||||
|
$this->assertStringContainsString("<label class='col-sm-3 control-label'>Radio <span class='required'>", $result);
|
||||||
|
$this->assertStringContainsString("<textarea id='ue-user-textarea'", $result);
|
||||||
|
$this->assertStringContainsString("<select id='ue-user-list'", $result);
|
||||||
|
|
||||||
|
$result = $sc->sc_userextended_cat(0);
|
||||||
|
$this->assertStringContainsString('<h3>Miscellaneous</h3>', $result);
|
||||||
|
$this->assertStringContainsString("<label class='col-sm-3 control-label'>Dropdown", $result);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUserExtendedFieldShortcode()
|
||||||
|
{
|
||||||
|
$sc = e107::getScBatch('usersettings');
|
||||||
|
$sc->reset();
|
||||||
|
|
||||||
|
$perms = array(e_UC_PUBLIC, e_UC_MEMBER, e_UC_ADMIN, e_UC_MAINADMIN);
|
||||||
|
$sc->setVars(array('userclass_list' => implode(',',$perms)));
|
||||||
|
|
||||||
|
$result = $sc->sc_userextended_field('radio');
|
||||||
|
$this->assertStringContainsString("Radio <span class='required'", $result);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the {USER_EXTENDED} shortcode.
|
* Test the {USER_EXTENDED} shortcode.
|
||||||
*/
|
*/
|
||||||
@@ -338,6 +381,8 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
$sc = e107::getScBatch('usersettings');
|
$sc = e107::getScBatch('usersettings');
|
||||||
|
$sc->wrapper('not-a-real-wrapper');
|
||||||
|
$sc->reset();
|
||||||
|
|
||||||
$sc->setVars(array('userclass_list' => '253,251,0,254,250'));
|
$sc->setVars(array('userclass_list' => '253,251,0,254,250'));
|
||||||
|
|
||||||
@@ -349,6 +394,65 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testloadUECatData()
|
||||||
|
{
|
||||||
|
/** @var usersettings_shortcodes $sc */
|
||||||
|
$sc = e107::getScBatch('usersettings');
|
||||||
|
|
||||||
|
$data = $sc->loadUECatData('write');
|
||||||
|
$this->assertCount(3, $data); // 3 categories including "Misc"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testloadUEFieldData()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* All fields have been created with the following.
|
||||||
|
* 'read' => e_UC_MEMBER,
|
||||||
|
'write' => e_UC_ADMIN,
|
||||||
|
'applicable' => e_UC_MAINADMIN,
|
||||||
|
*
|
||||||
|
* $this->structParent = array(
|
||||||
|
'list' => 16,
|
||||||
|
'radio' => 16,
|
||||||
|
'textarea' => 16,
|
||||||
|
'country' => 17,
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
$sc = e107::getScBatch('usersettings');
|
||||||
|
$GLOBALS['_E107']['phpunit'] = true; // disable universal CLI access in check_class()
|
||||||
|
|
||||||
|
$perms = array(e_UC_PUBLIC, e_UC_MEMBER, e_UC_ADMIN, e_UC_MAINADMIN);
|
||||||
|
$sc->setVars(array('userclass_list' => implode(',',$perms)));
|
||||||
|
|
||||||
|
// Load Fields from parent = 0
|
||||||
|
$data = $sc->loadUEFieldData('write', 0);
|
||||||
|
$this->assertArrayHasKey('text', $data);
|
||||||
|
$this->assertArrayHasKey('homepage', $data);
|
||||||
|
$this->assertArrayNotHasKey('radio', $data);
|
||||||
|
|
||||||
|
// Load Fields from parent = 16
|
||||||
|
$data = $sc->loadUEFieldData('write', 16);
|
||||||
|
$this->assertArrayHasKey('radio', $data);
|
||||||
|
$this->assertArrayHasKey('list', $data);
|
||||||
|
$this->assertArrayHasKey('textarea', $data);
|
||||||
|
|
||||||
|
// Load Fields from parent = 17
|
||||||
|
$data = $sc->loadUEFieldData('write', 17);
|
||||||
|
$this->assertArrayHasKey('country', $data);
|
||||||
|
|
||||||
|
|
||||||
|
$perms = array(e_UC_GUEST); // ie USERCLASS_LIST
|
||||||
|
$sc->setVars(array('userclass_list' => implode(',',$perms)));
|
||||||
|
$data = $sc->loadUEFieldData('write', 16);
|
||||||
|
$this->assertCount(0, $data); // should be empty
|
||||||
|
|
||||||
|
$GLOBALS['_E107']['phpunit'] = false; // fix check_class()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function testSignupExtendedUserFieldsShortcode()
|
public function testSignupExtendedUserFieldsShortcode()
|
||||||
{
|
{
|
||||||
$this->fixRegistry('before');
|
$this->fixRegistry('before');
|
||||||
@@ -407,6 +511,7 @@
|
|||||||
|
|
||||||
private function fixRegistry($mode)
|
private function fixRegistry($mode)
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
$regID = 'core/e107/singleton/e107_user_extended';
|
$regID = 'core/e107/singleton/e107_user_extended';
|
||||||
|
|
||||||
static $originalRegistry;
|
static $originalRegistry;
|
||||||
@@ -424,7 +529,7 @@
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public function testGetUserExtendedFieldData()
|
public function testGetUserExtendedFieldData()
|
||||||
{
|
{
|
||||||
$sc = e107::getScBatch('usersettings');
|
$sc = e107::getScBatch('usersettings');
|
||||||
@@ -439,11 +544,11 @@
|
|||||||
'user_extended_struct_parms' => '',
|
'user_extended_struct_parms' => '',
|
||||||
'user_extended_struct_values' => 'M => UE_LAN_MALE,F => UE_LAN_FEMALE',
|
'user_extended_struct_values' => 'M => UE_LAN_MALE,F => UE_LAN_FEMALE',
|
||||||
'user_extended_struct_default' => 'F',
|
'user_extended_struct_default' => 'F',
|
||||||
'user_extended_struct_read' => '0',
|
'user_extended_struct_read' => '253',
|
||||||
'user_extended_struct_write' => '0',
|
'user_extended_struct_write' => '254',
|
||||||
'user_extended_struct_required' => '1',
|
'user_extended_struct_required' => '1',
|
||||||
'user_extended_struct_signup' => '0',
|
'user_extended_struct_signup' => '0',
|
||||||
'user_extended_struct_applicable' => '0',
|
'user_extended_struct_applicable' => '250',
|
||||||
'user_extended_struct_order' => '2',
|
'user_extended_struct_order' => '2',
|
||||||
'user_extended_struct_parent' => '16',
|
'user_extended_struct_parent' => '16',
|
||||||
);
|
);
|
||||||
@@ -452,7 +557,7 @@
|
|||||||
$this->assertEquals($result, $expected);
|
$this->assertEquals($result, $expected);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public function testGetStructure()
|
public function testGetStructure()
|
||||||
{
|
{
|
||||||
@@ -525,12 +630,47 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public function testHasPermission()
|
public function testHasPermission()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* All fields have been createad with the following.
|
||||||
|
* 'read' => e_UC_MEMBER,
|
||||||
|
'write' => e_UC_ADMIN,
|
||||||
|
'applicable' => e_UC_MAINADMIN,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$GLOBALS['_E107']['phpunit'] = true; // fix check_class()
|
||||||
|
// $_E107['phpunit'] = true;
|
||||||
|
$ret = [];
|
||||||
|
foreach($this->structTypes as $field => $name)
|
||||||
|
{
|
||||||
|
$fid = 'user_'.$field;
|
||||||
|
|
||||||
|
// test public access against read = member.
|
||||||
|
$result = $this->ue->hasPermission($fid,'read', e_UC_PUBLIC);
|
||||||
|
$this->assertFalse($result);
|
||||||
|
|
||||||
|
// test member against write = admin.
|
||||||
|
$result = $this->ue->hasPermission($fid,'write', e_UC_MEMBER);
|
||||||
|
$this->assertFalse($result);
|
||||||
|
|
||||||
|
// test member against write = admin.
|
||||||
|
$result = $this->ue->hasPermission($fid,'applicable', e_UC_ADMIN);
|
||||||
|
$this->assertFalse($result);
|
||||||
|
|
||||||
|
// test member against write = admin.
|
||||||
|
$result = $this->ue->hasPermission($fid,'applicable', e_UC_MAINADMIN);
|
||||||
|
$this->assertTrue($result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$GLOBALS['_E107']['phpunit'] = false;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetFieldTypes()
|
public function testGetFieldTypes()
|
||||||
{
|
{
|
||||||
$result = $this->ue->getFieldTypes();
|
$result = $this->ue->getFieldTypes();
|
||||||
@@ -864,11 +1004,11 @@
|
|||||||
'user_extended_struct_parms' => '',
|
'user_extended_struct_parms' => '',
|
||||||
'user_extended_struct_values' => 'M => UE_LAN_MALE,F => UE_LAN_FEMALE',
|
'user_extended_struct_values' => 'M => UE_LAN_MALE,F => UE_LAN_FEMALE',
|
||||||
'user_extended_struct_default' => 'F',
|
'user_extended_struct_default' => 'F',
|
||||||
'user_extended_struct_read' => '0',
|
'user_extended_struct_read' => '253',
|
||||||
'user_extended_struct_write' => '0',
|
'user_extended_struct_write' => '254',
|
||||||
'user_extended_struct_required' => '1',
|
'user_extended_struct_required' => '1',
|
||||||
'user_extended_struct_signup' => '0',
|
'user_extended_struct_signup' => '0',
|
||||||
'user_extended_struct_applicable' => '0',
|
'user_extended_struct_applicable' => '250',
|
||||||
'user_extended_struct_order' => '2',
|
'user_extended_struct_order' => '2',
|
||||||
'user_extended_struct_parent' => '16',
|
'user_extended_struct_parent' => '16',
|
||||||
),
|
),
|
||||||
@@ -881,11 +1021,11 @@
|
|||||||
'user_extended_struct_parms' => '',
|
'user_extended_struct_parms' => '',
|
||||||
'user_extended_struct_values' => '',
|
'user_extended_struct_values' => '',
|
||||||
'user_extended_struct_default' => '',
|
'user_extended_struct_default' => '',
|
||||||
'user_extended_struct_read' => '0',
|
'user_extended_struct_read' => '253',
|
||||||
'user_extended_struct_write' => '0',
|
'user_extended_struct_write' => '254',
|
||||||
'user_extended_struct_required' => '0',
|
'user_extended_struct_required' => '0',
|
||||||
'user_extended_struct_signup' => '0',
|
'user_extended_struct_signup' => '0',
|
||||||
'user_extended_struct_applicable' => '0',
|
'user_extended_struct_applicable' => '250',
|
||||||
'user_extended_struct_order' => '5',
|
'user_extended_struct_order' => '5',
|
||||||
'user_extended_struct_parent' => '16',
|
'user_extended_struct_parent' => '16',
|
||||||
),
|
),
|
||||||
@@ -898,11 +1038,11 @@
|
|||||||
'user_extended_struct_parms' => '',
|
'user_extended_struct_parms' => '',
|
||||||
'user_extended_struct_values' => 'timezones',
|
'user_extended_struct_values' => 'timezones',
|
||||||
'user_extended_struct_default' => '',
|
'user_extended_struct_default' => '',
|
||||||
'user_extended_struct_read' => '0',
|
'user_extended_struct_read' => '253',
|
||||||
'user_extended_struct_write' => '0',
|
'user_extended_struct_write' => '254',
|
||||||
'user_extended_struct_required' => '1',
|
'user_extended_struct_required' => '1',
|
||||||
'user_extended_struct_signup' => '0',
|
'user_extended_struct_signup' => '0',
|
||||||
'user_extended_struct_applicable' => '0',
|
'user_extended_struct_applicable' => '250',
|
||||||
'user_extended_struct_order' => '9',
|
'user_extended_struct_order' => '9',
|
||||||
'user_extended_struct_parent' => '16',
|
'user_extended_struct_parent' => '16',
|
||||||
),
|
),
|
||||||
@@ -961,16 +1101,23 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public function testGetFields()
|
public function testGetFields()
|
||||||
{
|
{
|
||||||
|
$data = $this->ue->getFields();
|
||||||
|
$this->assertArrayHasKey('text', $data);
|
||||||
|
// var_dump($data);
|
||||||
|
// $this->assertCount(15, $data);
|
||||||
|
|
||||||
|
$data = $this->ue->getFields(16);
|
||||||
|
$this->assertArrayHasKey('radio', $data);
|
||||||
|
// $this->assertCount(3, $data);
|
||||||
|
|
||||||
|
$data = $this->ue->getFields(17);
|
||||||
|
$this->assertArrayHasKey('country', $data);
|
||||||
|
// $this->assertCount(1, $data);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public function testGet()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUser_extended_field_exist()
|
public function testUser_extended_field_exist()
|
||||||
{
|
{
|
||||||
@@ -1029,11 +1176,11 @@
|
|||||||
'user_extended_struct_parms' => '',
|
'user_extended_struct_parms' => '',
|
||||||
'user_extended_struct_values' => 'M => UE_LAN_MALE,F => UE_LAN_FEMALE',
|
'user_extended_struct_values' => 'M => UE_LAN_MALE,F => UE_LAN_FEMALE',
|
||||||
'user_extended_struct_default' => 'F',
|
'user_extended_struct_default' => 'F',
|
||||||
'user_extended_struct_read' => '0',
|
'user_extended_struct_read' => '253',
|
||||||
'user_extended_struct_write' => '0',
|
'user_extended_struct_write' => '254',
|
||||||
'user_extended_struct_required' => '1',
|
'user_extended_struct_required' => '1',
|
||||||
'user_extended_struct_signup' => '0',
|
'user_extended_struct_signup' => '0',
|
||||||
'user_extended_struct_applicable' => '0',
|
'user_extended_struct_applicable' => '250',
|
||||||
'user_extended_struct_order' => '2',
|
'user_extended_struct_order' => '2',
|
||||||
'user_extended_struct_parent' => 16,
|
'user_extended_struct_parent' => 16,
|
||||||
),
|
),
|
||||||
@@ -1046,11 +1193,11 @@
|
|||||||
'user_extended_struct_parms' => '',
|
'user_extended_struct_parms' => '',
|
||||||
'user_extended_struct_values' => '',
|
'user_extended_struct_values' => '',
|
||||||
'user_extended_struct_default' => '',
|
'user_extended_struct_default' => '',
|
||||||
'user_extended_struct_read' => '0',
|
'user_extended_struct_read' => '253',
|
||||||
'user_extended_struct_write' => '0',
|
'user_extended_struct_write' => '254',
|
||||||
'user_extended_struct_required' => '0',
|
'user_extended_struct_required' => '0',
|
||||||
'user_extended_struct_signup' => '0',
|
'user_extended_struct_signup' => '0',
|
||||||
'user_extended_struct_applicable' => '0',
|
'user_extended_struct_applicable' => '250',
|
||||||
'user_extended_struct_order' => '5',
|
'user_extended_struct_order' => '5',
|
||||||
'user_extended_struct_parent' => 16,
|
'user_extended_struct_parent' => 16,
|
||||||
),
|
),
|
||||||
@@ -1063,11 +1210,11 @@
|
|||||||
'user_extended_struct_parms' => '',
|
'user_extended_struct_parms' => '',
|
||||||
'user_extended_struct_values' => 'timezones',
|
'user_extended_struct_values' => 'timezones',
|
||||||
'user_extended_struct_default' => '',
|
'user_extended_struct_default' => '',
|
||||||
'user_extended_struct_read' => '0',
|
'user_extended_struct_read' => '253',
|
||||||
'user_extended_struct_write' => '0',
|
'user_extended_struct_write' => '254',
|
||||||
'user_extended_struct_required' => '1',
|
'user_extended_struct_required' => '1',
|
||||||
'user_extended_struct_signup' => '0',
|
'user_extended_struct_signup' => '0',
|
||||||
'user_extended_struct_applicable' => '0',
|
'user_extended_struct_applicable' => '250',
|
||||||
'user_extended_struct_order' => '9',
|
'user_extended_struct_order' => '9',
|
||||||
'user_extended_struct_parent' => 16,
|
'user_extended_struct_parent' => 16,
|
||||||
),
|
),
|
||||||
|
@@ -1093,7 +1093,7 @@ class usersettings_front // Begin Usersettings rewrite.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// e107::scStyle($sc_style);
|
// e107::scStyle($sc_style);
|
||||||
e107::getScBatch('usersettings')->setVars($curVal);
|
e107::getScBatch('usersettings')->setVars($curVal)->reset();
|
||||||
|
|
||||||
$USERSETTINGS_EDIT = $this->getTemplate('edit');
|
$USERSETTINGS_EDIT = $this->getTemplate('edit');
|
||||||
$USERSETTINGS_EDIT_CAPTION = $this->getTemplate('edit_caption');
|
$USERSETTINGS_EDIT_CAPTION = $this->getTemplate('edit_caption');
|
||||||
|
Reference in New Issue
Block a user