1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +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:
Cameron
2017-01-23 17:54:43 -08:00
parent 3a0c353568
commit 28de9f2be1
7 changed files with 119 additions and 61 deletions

View File

@@ -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'
{ {
@@ -377,12 +378,15 @@ class usersettings_shortcodes extends e_shortcode
} }
function sc_userextended_cat($parm = '') function sc_userextended_cat($parm = '')
{ {
global $usersettings_shortcodes, $USER_EXTENDED_CAT, $extended_showed; global $extended_showed;
if(deftrue('BOOTSTRAP')===3) if(THEME_LEGACY === true)
{
$USER_EXTENDED_CAT = $this->legacyTemplate['USER_EXTENDED_CAT'];
}
else
{ {
$USER_EXTENDED_CAT = e107::getCoreTemplate('usersettings', 'extended-category'); $USER_EXTENDED_CAT = e107::getCoreTemplate('usersettings', 'extended-category');
} }
@@ -421,6 +425,7 @@ class usersettings_shortcodes extends e_shortcode
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();
@@ -437,23 +442,35 @@ class usersettings_shortcodes extends e_shortcode
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 $usersettings_shortcodes, $extended_showed, $ue, $USEREXTENDED_FIELD, $REQUIRED_FIELD; global $extended_showed;
if(deftrue('BOOTSTRAP')===3) $ue = e107::getUserExt();
if(THEME_LEGACY === true)
{
$USEREXTENDED_FIELD = $this->legacyTemplate['USEREXTENDED_FIELD'];
$REQUIRED_FIELD = $this->legacyTemplate['REQUIRED_FIELD'];
}
else
{ {
$USEREXTENDED_FIELD = e107::getCoreTemplate('usersettings', 'extended-field'); $USEREXTENDED_FIELD = e107::getCoreTemplate('usersettings', 'extended-field');
$REQUIRED_FIELD = '';
} }
@@ -465,10 +482,10 @@ class usersettings_shortcodes extends e_shortcode
$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 = "
@@ -486,7 +503,12 @@ class usersettings_shortcodes extends e_shortcode
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'))
@@ -497,13 +519,16 @@ class usersettings_shortcodes extends e_shortcode
$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);
} }
@@ -517,6 +542,7 @@ class usersettings_shortcodes extends e_shortcode
} }
$extended_showed['field'][$parm] = 1; $extended_showed['field'][$parm] = 1;
return $ret; return $ret;
} }

View File

@@ -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');
} }

View File

@@ -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>

View File

@@ -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} />";
@@ -922,6 +935,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;

View File

@@ -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)");

View File

@@ -53,3 +53,5 @@ 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% }

View File

@@ -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;