mirror of
https://github.com/e107inc/e107.git
synced 2025-01-16 20:28:28 +01: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:
parent
3a0c353568
commit
28de9f2be1
@ -18,6 +18,7 @@ if (!defined('e107_INIT')) { exit; }
|
||||
class usersettings_shortcodes extends e_shortcode
|
||||
{
|
||||
private $extendedTabs = false;
|
||||
public $legacyTemplate = array();
|
||||
|
||||
function sc_username($parm) // This is the 'display name'
|
||||
{
|
||||
@ -375,22 +376,25 @@ class usersettings_shortcodes extends e_shortcode
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sc_userextended_cat($parm='')
|
||||
{
|
||||
global $usersettings_shortcodes, $USER_EXTENDED_CAT, $extended_showed;
|
||||
|
||||
if(deftrue('BOOTSTRAP')===3)
|
||||
|
||||
|
||||
function sc_userextended_cat($parm = '')
|
||||
{
|
||||
global $extended_showed;
|
||||
|
||||
if(THEME_LEGACY === true)
|
||||
{
|
||||
$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();
|
||||
$tp = e107::getParser();
|
||||
|
||||
|
||||
if(isset($extended_showed['cat'][$parm]))
|
||||
{
|
||||
return "";
|
||||
@ -401,26 +405,27 @@ class usersettings_shortcodes extends e_shortcode
|
||||
{
|
||||
$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_id = ".intval($parm)."
|
||||
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 = " . intval($parm) . "
|
||||
";
|
||||
if($sql->gen($qry))
|
||||
{
|
||||
$catInfo = $sql->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($catInfo)
|
||||
{
|
||||
$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 = ".intval($parm)."
|
||||
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 = " . intval($parm) . "
|
||||
AND user_extended_struct_type != 0
|
||||
ORDER BY user_extended_struct_order ASC
|
||||
";
|
||||
|
||||
if($sql->gen($qry))
|
||||
{
|
||||
$fieldList = $sql->db_getList();
|
||||
@ -429,94 +434,115 @@ class usersettings_shortcodes extends e_shortcode
|
||||
cachevars("extendedfield_{$field['user_extended_struct_name']}", $field);
|
||||
//TODO use $this instead of parseTemplate();
|
||||
$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)
|
||||
{
|
||||
$catName = $catInfo['user_extended_struct_text'] ? $catInfo['user_extended_struct_text'] : $catInfo['user_extended_struct_name'];
|
||||
if(defined($catName)) $catName = constant($catName);
|
||||
$ret = str_replace("{CATNAME}", $tp->toHTML($catName, FALSE, 'emotes_off,defs'), $USER_EXTENDED_CAT).$ret;
|
||||
if(defined($catName))
|
||||
{
|
||||
$catName = constant($catName);
|
||||
}
|
||||
$ret = str_replace("{CATNAME}", $tp->toHTML($catName, false, 'emotes_off,defs'), $USER_EXTENDED_CAT) . $ret;
|
||||
}
|
||||
|
||||
|
||||
$extended_showed['cat'][$parm] = 1;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sc_userextended_field($parm='')
|
||||
{
|
||||
global $usersettings_shortcodes, $extended_showed, $ue, $USEREXTENDED_FIELD, $REQUIRED_FIELD;
|
||||
|
||||
if(deftrue('BOOTSTRAP')===3)
|
||||
|
||||
|
||||
function sc_userextended_field($parm = '')
|
||||
{
|
||||
global $extended_showed;
|
||||
|
||||
$ue = e107::getUserExt();
|
||||
|
||||
|
||||
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]))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
$sql = e107::getDb();
|
||||
$tp = e107::getParser();
|
||||
|
||||
|
||||
|
||||
$ret = "";
|
||||
|
||||
|
||||
$fInfo = getcachedvars("extendeddata_{$parm}");
|
||||
|
||||
if(!$fInfo)
|
||||
{
|
||||
$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_name = '".$tp -> toDB($parm, 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_name = '" . $tp->toDB($parm, true) . "'
|
||||
";
|
||||
if($sql->gen($qry))
|
||||
{
|
||||
$fInfo = $sql->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($fInfo)
|
||||
{
|
||||
$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");
|
||||
|
||||
|
||||
if($fInfo['user_extended_struct_required'] == 1 && !deftrue('BOOTSTRAP'))
|
||||
{
|
||||
$fname = str_replace("{FIELDNAME}", $fname, $REQUIRED_FIELD);
|
||||
}
|
||||
|
||||
$parms = explode("^,^",$fInfo['user_extended_struct_parms']);
|
||||
|
||||
$fhide="";
|
||||
|
||||
$parms = explode("^,^", $fInfo['user_extended_struct_parms']);
|
||||
|
||||
$fhide = "";
|
||||
|
||||
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']))
|
||||
{
|
||||
$chk = isset($_POST['hide']['user_'.$parm]);
|
||||
$chk = isset($_POST['hide']['user_' . $parm]);
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
|
||||
$ret = $USEREXTENDED_FIELD;
|
||||
$ret = str_replace("{FIELDNAME}", $fname, $ret);
|
||||
$ret = str_replace("{FIELDVAL}", $fval, $ret);
|
||||
$ret = str_replace("{HIDEFIELD}", $fhide, $ret);
|
||||
}
|
||||
|
||||
|
||||
$extended_showed['field'][$parm] = 1;
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
if(!deftrue('BOOTSTRAP'))
|
||||
if(THEME_LEGACY === true)
|
||||
{
|
||||
$e_js->otherCSS('{e_WEB_CSS}backcompat.css');
|
||||
}
|
||||
|
@ -8,8 +8,7 @@
|
||||
<write>253</write>
|
||||
</item>
|
||||
<item name="country">
|
||||
<type>db field</type>
|
||||
<values>user_extended_country,country_iso,country_name,country_name</values>
|
||||
<type>country</type>
|
||||
<include_text></include_text>
|
||||
<applicable>253</applicable>
|
||||
<read>253</read>
|
||||
|
@ -67,6 +67,7 @@ class e107_user_extended
|
||||
define('EUF_CHECKBOX',10);
|
||||
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_COUNTRY', 13); // $frm->country()
|
||||
|
||||
$this->typeArray = array(
|
||||
'text' => 1,
|
||||
@ -80,7 +81,8 @@ class e107_user_extended
|
||||
'list' => 9,
|
||||
'checkbox' => 10,
|
||||
'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(
|
||||
@ -488,6 +490,10 @@ class e107_user_extended
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case EUF_COUNTRY :
|
||||
$db_type = 'VARCHAR(2)';
|
||||
break;
|
||||
|
||||
case EUF_INTEGER :
|
||||
$db_type = 'INT(11)';
|
||||
break;
|
||||
@ -577,6 +583,7 @@ class e107_user_extended
|
||||
|
||||
if ($this->user_extended_reserved($name))
|
||||
{
|
||||
e107::getMessage()->addDebug("Reserved Field");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -753,6 +760,12 @@ class e107_user_extended
|
||||
|
||||
switch($struct['user_extended_struct_type'])
|
||||
{
|
||||
|
||||
case EUF_COUNTRY:
|
||||
return e107::getForm()->country($fname,$curval);
|
||||
break;
|
||||
|
||||
|
||||
case EUF_TEXT : //textbox
|
||||
case EUF_INTEGER : //integer
|
||||
$ret = "<input id='{$fid}' type='text' name='{$fname}' {$title} value='{$curval}' {$include} {$required} {$placeholder} />";
|
||||
@ -921,6 +934,11 @@ class e107_user_extended
|
||||
{
|
||||
$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'));
|
||||
break;
|
||||
|
@ -20,6 +20,9 @@ define("UE_LAN_6", "Integer");
|
||||
define("UE_LAN_8", "Language");
|
||||
define("UE_LAN_9", "Predefined list");
|
||||
define("UE_LAN_10", "Checkboxes");
|
||||
//v2.1.5
|
||||
define("UE_LAN_13", "Country");
|
||||
|
||||
// Leave a gap to allow for more field types
|
||||
define("UE_LAN_21", "Name");
|
||||
define("UE_LAN_22", "Type");
|
||||
@ -44,7 +47,7 @@ define("UE_LAN_BIRTHDAY_DESC", "Birthday");
|
||||
define("UE_LAN_LANGUAGE", "Language");
|
||||
define("UE_LAN_LANGUAGE_DESC", "User Language");
|
||||
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_DESC", "User Timezone (from predefined list)");
|
||||
|
||||
|
@ -52,4 +52,6 @@ ul.breadcrumb li span.divider { padding-left:5px; }
|
||||
}
|
||||
.media-left, .media > .pull-left {
|
||||
padding-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.form-control { max-width:100% }
|
@ -89,6 +89,9 @@ class usersettings_front // Begin Usersettings rewrite.
|
||||
else
|
||||
{
|
||||
global $sc_style;
|
||||
$REQUIRED_FIELD = '';
|
||||
$USER_EXTENDED_CAT = '';
|
||||
$USEREXTENDED_FIELD = '';
|
||||
$USERSETTINGS_MESSAGE = '';
|
||||
$USERSETTINGS_MESSAGE_CAPTION = '';
|
||||
$USERSETTINGS_EDIT_CAPTION = '';
|
||||
@ -97,6 +100,13 @@ class usersettings_front // Begin Usersettings rewrite.
|
||||
include_once($coreTemplatePath); //correct way to load a core template.
|
||||
e107::scStyle($sc_style);
|
||||
$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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user