mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Fixes #2270: Usersettings : Custom User Fields on Legacy themes.
Fixes #2165: Country field added (doesn't required database) Fixes #1297: Extended fields failing
This commit is contained in:
@@ -18,6 +18,7 @@ if (!defined('e107_INIT')) { exit; }
|
|||||||
class usersettings_shortcodes extends e_shortcode
|
class usersettings_shortcodes extends e_shortcode
|
||||||
{
|
{
|
||||||
private $extendedTabs = false;
|
private $extendedTabs = false;
|
||||||
|
public $legacyTemplate = array();
|
||||||
|
|
||||||
function sc_username($parm) // This is the 'display name'
|
function sc_username($parm) // This is the 'display name'
|
||||||
{
|
{
|
||||||
@@ -375,22 +376,25 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sc_userextended_cat($parm = '')
|
||||||
function sc_userextended_cat($parm='')
|
{
|
||||||
{
|
global $extended_showed;
|
||||||
global $usersettings_shortcodes, $USER_EXTENDED_CAT, $extended_showed;
|
|
||||||
|
if(THEME_LEGACY === true)
|
||||||
if(deftrue('BOOTSTRAP')===3)
|
|
||||||
{
|
{
|
||||||
$USER_EXTENDED_CAT = e107::getCoreTemplate('usersettings','extended-category');
|
$USER_EXTENDED_CAT = $this->legacyTemplate['USER_EXTENDED_CAT'];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$USER_EXTENDED_CAT = e107::getCoreTemplate('usersettings', 'extended-category');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
if(isset($extended_showed['cat'][$parm]))
|
if(isset($extended_showed['cat'][$parm]))
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
@@ -401,26 +405,27 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
{
|
{
|
||||||
$qry = "
|
$qry = "
|
||||||
SELECT * FROM #user_extended_struct
|
SELECT * FROM #user_extended_struct
|
||||||
WHERE user_extended_struct_applicable IN (".$tp -> toDB($this->var['userclass_list'], true).")
|
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_write IN (" . USERCLASS_LIST . ")
|
||||||
AND user_extended_struct_id = ".intval($parm)."
|
AND user_extended_struct_id = " . intval($parm) . "
|
||||||
";
|
";
|
||||||
if($sql->gen($qry))
|
if($sql->gen($qry))
|
||||||
{
|
{
|
||||||
$catInfo = $sql->fetch();
|
$catInfo = $sql->fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($catInfo)
|
if($catInfo)
|
||||||
{
|
{
|
||||||
$qry = "
|
$qry = "
|
||||||
SELECT * FROM #user_extended_struct
|
SELECT * FROM #user_extended_struct
|
||||||
WHERE user_extended_struct_applicable IN (".$tp -> toDB($this->var['userclass_list'], true).")
|
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_write IN (" . USERCLASS_LIST . ")
|
||||||
AND user_extended_struct_parent = ".intval($parm)."
|
AND user_extended_struct_parent = " . intval($parm) . "
|
||||||
AND user_extended_struct_type != 0
|
AND user_extended_struct_type != 0
|
||||||
ORDER BY user_extended_struct_order ASC
|
ORDER BY user_extended_struct_order ASC
|
||||||
";
|
";
|
||||||
|
|
||||||
if($sql->gen($qry))
|
if($sql->gen($qry))
|
||||||
{
|
{
|
||||||
$fieldList = $sql->db_getList();
|
$fieldList = $sql->db_getList();
|
||||||
@@ -429,94 +434,115 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
cachevars("extendedfield_{$field['user_extended_struct_name']}", $field);
|
cachevars("extendedfield_{$field['user_extended_struct_name']}", $field);
|
||||||
//TODO use $this instead of parseTemplate();
|
//TODO use $this instead of parseTemplate();
|
||||||
$ret .= $this->sc_userextended_field($field['user_extended_struct_name']);
|
$ret .= $this->sc_userextended_field($field['user_extended_struct_name']);
|
||||||
// $ret .= $tp->parseTemplate("{USEREXTENDED_FIELD={$field['user_extended_struct_name']}}", TRUE, $usersettings_shortcodes);
|
// $ret .= $tp->parseTemplate("{USEREXTENDED_FIELD={$field['user_extended_struct_name']}}", TRUE, $usersettings_shortcodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ret && $this->extendedTabs == false)
|
if($ret && $this->extendedTabs == false)
|
||||||
{
|
{
|
||||||
$catName = $catInfo['user_extended_struct_text'] ? $catInfo['user_extended_struct_text'] : $catInfo['user_extended_struct_name'];
|
$catName = $catInfo['user_extended_struct_text'] ? $catInfo['user_extended_struct_text'] : $catInfo['user_extended_struct_name'];
|
||||||
if(defined($catName)) $catName = constant($catName);
|
if(defined($catName))
|
||||||
$ret = str_replace("{CATNAME}", $tp->toHTML($catName, FALSE, 'emotes_off,defs'), $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;
|
$extended_showed['cat'][$parm] = 1;
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sc_userextended_field($parm = '')
|
||||||
function sc_userextended_field($parm='')
|
{
|
||||||
{
|
global $extended_showed;
|
||||||
global $usersettings_shortcodes, $extended_showed, $ue, $USEREXTENDED_FIELD, $REQUIRED_FIELD;
|
|
||||||
|
$ue = e107::getUserExt();
|
||||||
if(deftrue('BOOTSTRAP')===3)
|
|
||||||
|
|
||||||
|
if(THEME_LEGACY === true)
|
||||||
{
|
{
|
||||||
$USEREXTENDED_FIELD = e107::getCoreTemplate('usersettings','extended-field');
|
$USEREXTENDED_FIELD = $this->legacyTemplate['USEREXTENDED_FIELD'];
|
||||||
|
$REQUIRED_FIELD = $this->legacyTemplate['REQUIRED_FIELD'];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$USEREXTENDED_FIELD = e107::getCoreTemplate('usersettings', 'extended-field');
|
||||||
|
$REQUIRED_FIELD = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(isset($extended_showed['field'][$parm]))
|
if(isset($extended_showed['field'][$parm]))
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
|
||||||
$ret = "";
|
$ret = "";
|
||||||
|
|
||||||
$fInfo = getcachedvars("extendeddata_{$parm}");
|
$fInfo = getcachedvars("extendeddata_{$parm}");
|
||||||
|
|
||||||
if(!$fInfo)
|
if(!$fInfo)
|
||||||
{
|
{
|
||||||
$qry = "
|
$qry = "
|
||||||
SELECT * FROM #user_extended_struct
|
SELECT * FROM #user_extended_struct
|
||||||
WHERE user_extended_struct_applicable IN (".$tp -> toDB($this->var['userclass_list'], true).")
|
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_write IN (" . USERCLASS_LIST . ")
|
||||||
AND user_extended_struct_name = '".$tp -> toDB($parm, true)."'
|
AND user_extended_struct_name = '" . $tp->toDB($parm, true) . "'
|
||||||
";
|
";
|
||||||
if($sql->gen($qry))
|
if($sql->gen($qry))
|
||||||
{
|
{
|
||||||
$fInfo = $sql->fetch();
|
$fInfo = $sql->fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($fInfo)
|
if($fInfo)
|
||||||
{
|
{
|
||||||
$fname = $fInfo['user_extended_struct_text'];
|
$fname = $fInfo['user_extended_struct_text'];
|
||||||
if(defined($fname)) $fname = constant($fname);
|
|
||||||
|
if(defined($fname))
|
||||||
|
{
|
||||||
|
$fname = constant($fname);
|
||||||
|
}
|
||||||
|
|
||||||
$fname = $tp->toHTML($fname, "", "emotes_off, defs");
|
$fname = $tp->toHTML($fname, "", "emotes_off, defs");
|
||||||
|
|
||||||
if($fInfo['user_extended_struct_required'] == 1 && !deftrue('BOOTSTRAP'))
|
if($fInfo['user_extended_struct_required'] == 1 && !deftrue('BOOTSTRAP'))
|
||||||
{
|
{
|
||||||
$fname = str_replace("{FIELDNAME}", $fname, $REQUIRED_FIELD);
|
$fname = str_replace("{FIELDNAME}", $fname, $REQUIRED_FIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
$parms = explode("^,^",$fInfo['user_extended_struct_parms']);
|
$parms = explode("^,^", $fInfo['user_extended_struct_parms']);
|
||||||
|
|
||||||
$fhide="";
|
$fhide = "";
|
||||||
|
|
||||||
if(varset($parms[3]))
|
if(varset($parms[3]))
|
||||||
{
|
{
|
||||||
$chk = (strpos($this->var['user_hidden_fields'], "^user_".$parm."^") === FALSE) ? FALSE : TRUE;
|
$chk = (strpos($this->var['user_hidden_fields'], "^user_" . $parm . "^") === false) ? false : true;
|
||||||
|
|
||||||
if(isset($_POST['updatesettings']))
|
if(isset($_POST['updatesettings']))
|
||||||
{
|
{
|
||||||
$chk = isset($_POST['hide']['user_'.$parm]);
|
$chk = isset($_POST['hide']['user_' . $parm]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fhide = $ue->user_extended_hide($fInfo, $chk);
|
$fhide = $ue->user_extended_hide($fInfo, $chk);
|
||||||
}
|
}
|
||||||
|
|
||||||
$uVal = str_replace(chr(1), "", $this->var['user_'.$parm]);
|
$uVal = str_replace(chr(1), "", $this->var['user_' . $parm]);
|
||||||
$fval = $ue->user_extended_edit($fInfo, $uVal);
|
$fval = $ue->user_extended_edit($fInfo, $uVal);
|
||||||
|
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
$extended_showed['field'][$parm] = 1;
|
$extended_showed['field'][$parm] = 1;
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -187,7 +187,7 @@ if (/*!defined("PREVIEWTHEME") && */! (isset($no_core_css) && $no_core_css !==tr
|
|||||||
$e_js->otherCSS('{e_WEB_CSS}e107.css');
|
$e_js->otherCSS('{e_WEB_CSS}e107.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!deftrue('BOOTSTRAP'))
|
if(THEME_LEGACY === true)
|
||||||
{
|
{
|
||||||
$e_js->otherCSS('{e_WEB_CSS}backcompat.css');
|
$e_js->otherCSS('{e_WEB_CSS}backcompat.css');
|
||||||
}
|
}
|
||||||
|
@@ -8,8 +8,7 @@
|
|||||||
<write>253</write>
|
<write>253</write>
|
||||||
</item>
|
</item>
|
||||||
<item name="country">
|
<item name="country">
|
||||||
<type>db field</type>
|
<type>country</type>
|
||||||
<values>user_extended_country,country_iso,country_name,country_name</values>
|
|
||||||
<include_text></include_text>
|
<include_text></include_text>
|
||||||
<applicable>253</applicable>
|
<applicable>253</applicable>
|
||||||
<read>253</read>
|
<read>253</read>
|
||||||
|
@@ -67,6 +67,7 @@ class e107_user_extended
|
|||||||
define('EUF_CHECKBOX',10);
|
define('EUF_CHECKBOX',10);
|
||||||
define('EUF_PREFIELD',11); // should be EUF_PREDEFINED, useful when creating fields from e.g. plugin XML
|
define('EUF_PREFIELD',11); // should be EUF_PREDEFINED, useful when creating fields from e.g. plugin XML
|
||||||
define('EUF_ADDON', 12); // defined within e_user.php addon
|
define('EUF_ADDON', 12); // defined within e_user.php addon
|
||||||
|
define('EUF_COUNTRY', 13); // $frm->country()
|
||||||
|
|
||||||
$this->typeArray = array(
|
$this->typeArray = array(
|
||||||
'text' => 1,
|
'text' => 1,
|
||||||
@@ -80,7 +81,8 @@ class e107_user_extended
|
|||||||
'list' => 9,
|
'list' => 9,
|
||||||
'checkbox' => 10,
|
'checkbox' => 10,
|
||||||
'predefined' => 11, // DON'T USE IT IN PREDEFINED FIELD XML!!! Used in plugin installation routine.
|
'predefined' => 11, // DON'T USE IT IN PREDEFINED FIELD XML!!! Used in plugin installation routine.
|
||||||
'addon' => 12
|
'addon' => 12,
|
||||||
|
'country' => 13,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->user_extended_types = array(
|
$this->user_extended_types = array(
|
||||||
@@ -488,6 +490,10 @@ class e107_user_extended
|
|||||||
|
|
||||||
switch ($type)
|
switch ($type)
|
||||||
{
|
{
|
||||||
|
case EUF_COUNTRY :
|
||||||
|
$db_type = 'VARCHAR(2)';
|
||||||
|
break;
|
||||||
|
|
||||||
case EUF_INTEGER :
|
case EUF_INTEGER :
|
||||||
$db_type = 'INT(11)';
|
$db_type = 'INT(11)';
|
||||||
break;
|
break;
|
||||||
@@ -577,6 +583,7 @@ class e107_user_extended
|
|||||||
|
|
||||||
if ($this->user_extended_reserved($name))
|
if ($this->user_extended_reserved($name))
|
||||||
{
|
{
|
||||||
|
e107::getMessage()->addDebug("Reserved Field");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,6 +760,12 @@ class e107_user_extended
|
|||||||
|
|
||||||
switch($struct['user_extended_struct_type'])
|
switch($struct['user_extended_struct_type'])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
case EUF_COUNTRY:
|
||||||
|
return e107::getForm()->country($fname,$curval);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case EUF_TEXT : //textbox
|
case EUF_TEXT : //textbox
|
||||||
case EUF_INTEGER : //integer
|
case EUF_INTEGER : //integer
|
||||||
$ret = "<input id='{$fid}' type='text' name='{$fname}' {$title} value='{$curval}' {$include} {$required} {$placeholder} />";
|
$ret = "<input id='{$fid}' type='text' name='{$fname}' {$title} value='{$curval}' {$include} {$required} {$placeholder} />";
|
||||||
@@ -921,6 +934,11 @@ class e107_user_extended
|
|||||||
{
|
{
|
||||||
$curval = '';
|
$curval = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(THEME_LEGACY === true)
|
||||||
|
{
|
||||||
|
return e107::getForm()->text($fname,$curval,10,array('placeholder'=>'yyyy-mm-dd'));
|
||||||
|
}
|
||||||
|
|
||||||
return e107::getForm()->datepicker($fname,$curval,array('format'=>'yyyy-mm-dd','return'=>'string'));
|
return e107::getForm()->datepicker($fname,$curval,array('format'=>'yyyy-mm-dd','return'=>'string'));
|
||||||
break;
|
break;
|
||||||
|
@@ -20,6 +20,9 @@ define("UE_LAN_6", "Integer");
|
|||||||
define("UE_LAN_8", "Language");
|
define("UE_LAN_8", "Language");
|
||||||
define("UE_LAN_9", "Predefined list");
|
define("UE_LAN_9", "Predefined list");
|
||||||
define("UE_LAN_10", "Checkboxes");
|
define("UE_LAN_10", "Checkboxes");
|
||||||
|
//v2.1.5
|
||||||
|
define("UE_LAN_13", "Country");
|
||||||
|
|
||||||
// Leave a gap to allow for more field types
|
// Leave a gap to allow for more field types
|
||||||
define("UE_LAN_21", "Name");
|
define("UE_LAN_21", "Name");
|
||||||
define("UE_LAN_22", "Type");
|
define("UE_LAN_22", "Type");
|
||||||
@@ -44,7 +47,7 @@ define("UE_LAN_BIRTHDAY_DESC", "Birthday");
|
|||||||
define("UE_LAN_LANGUAGE", "Language");
|
define("UE_LAN_LANGUAGE", "Language");
|
||||||
define("UE_LAN_LANGUAGE_DESC", "User Language");
|
define("UE_LAN_LANGUAGE_DESC", "User Language");
|
||||||
define("UE_LAN_COUNTRY", "Country");
|
define("UE_LAN_COUNTRY", "Country");
|
||||||
define("UE_LAN_COUNTRY_DESC", "User Country (includes db table)");
|
define("UE_LAN_COUNTRY_DESC", "User Country");
|
||||||
define("UE_LAN_TIMEZONE", "Timezone");
|
define("UE_LAN_TIMEZONE", "Timezone");
|
||||||
define("UE_LAN_TIMEZONE_DESC", "User Timezone (from predefined list)");
|
define("UE_LAN_TIMEZONE_DESC", "User Timezone (from predefined list)");
|
||||||
|
|
||||||
|
@@ -52,4 +52,6 @@ ul.breadcrumb li span.divider { padding-left:5px; }
|
|||||||
}
|
}
|
||||||
.media-left, .media > .pull-left {
|
.media-left, .media > .pull-left {
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-control { max-width:100% }
|
@@ -89,6 +89,9 @@ class usersettings_front // Begin Usersettings rewrite.
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
global $sc_style;
|
global $sc_style;
|
||||||
|
$REQUIRED_FIELD = '';
|
||||||
|
$USER_EXTENDED_CAT = '';
|
||||||
|
$USEREXTENDED_FIELD = '';
|
||||||
$USERSETTINGS_MESSAGE = '';
|
$USERSETTINGS_MESSAGE = '';
|
||||||
$USERSETTINGS_MESSAGE_CAPTION = '';
|
$USERSETTINGS_MESSAGE_CAPTION = '';
|
||||||
$USERSETTINGS_EDIT_CAPTION = '';
|
$USERSETTINGS_EDIT_CAPTION = '';
|
||||||
@@ -97,6 +100,13 @@ class usersettings_front // Begin Usersettings rewrite.
|
|||||||
include_once($coreTemplatePath); //correct way to load a core template.
|
include_once($coreTemplatePath); //correct way to load a core template.
|
||||||
e107::scStyle($sc_style);
|
e107::scStyle($sc_style);
|
||||||
$usersettings_shortcodes = e107::getScBatch('usersettings');
|
$usersettings_shortcodes = e107::getScBatch('usersettings');
|
||||||
|
|
||||||
|
$usersettings_shortcodes->legacyTemplate = array(
|
||||||
|
'USER_EXTENDED_CAT' => $USER_EXTENDED_CAT,
|
||||||
|
'USEREXTENDED_FIELD' => $USEREXTENDED_FIELD,
|
||||||
|
'REQUIRED_FIELD' => $REQUIRED_FIELD
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sc = $usersettings_shortcodes;
|
$this->sc = $usersettings_shortcodes;
|
||||||
|
Reference in New Issue
Block a user