1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-08 07:36:32 +02:00

Issue #2165 {EUF: field=country}

This commit is contained in:
Cameron
2017-01-24 11:28:00 -08:00
parent 2640e536ff
commit 3552090bea
2 changed files with 26 additions and 10 deletions

View File

@@ -679,14 +679,14 @@ class user_shortcodes extends e_shortcode
if(!$ext->hasPermission($fld,'read')) if(!$ext->hasPermission($fld,'read'))
{ {
// e107::getDebug()->log("Wrong permissions for user_euf: ".$fld);
return false; return false;
} }
$val = $this->var[$fld]; $val = $this->var[$fld];
$type = $ext->getFieldType($fld);
// e107::getDebug()->log(print_a($ext,true)); return $ext->renderValue($val,$type);
return $ext->renderValue($val); //TODO auto-detect type, from within the user-extended class.
} }

View File

@@ -50,7 +50,7 @@ class e107_user_extended
private $nameIndex = array(); // Array for field name lookup - initialised by constructor private $nameIndex = array(); // Array for field name lookup - initialised by constructor
public $systemCount = 0; // Count of system fields - always zero ATM public $systemCount = 0; // Count of system fields - always zero ATM
public $userCount = 0; // Count of non-system fields public $userCount = 0; // Count of non-system fields
private $fieldPermissions = array(); // Field Permissionss with field name as key. private $fieldAttributes = array(); // Field Permissionss with field name as key.
public function __construct() public function __construct()
{ {
@@ -130,10 +130,16 @@ class e107_user_extended
else else
{ // Its a field definition { // Its a field definition
$this->fieldDefinitions[$row['user_extended_struct_id']] = $row; $this->fieldDefinitions[$row['user_extended_struct_id']] = $row;
$id = 'user_'.$row['user_extended_struct_name']; $id = 'user_' . $row['user_extended_struct_name'];
$this->fieldPermissions[$id] = array('read'=>$row['user_extended_struct_read'], 'write'=>$row['user_extended_struct_write']);
$this->nameIndex['user_'.$row['user_extended_struct_name']] = $row['user_extended_struct_id']; // Create name to ID index $this->fieldAttributes[$id] = array(
if ($row['user_extended_struct_text'] == '_system_') 'read' => $row['user_extended_struct_read'],
'write' => $row['user_extended_struct_write'],
'type' => $row['user_extended_struct_type']
);
$this->nameIndex['user_' . $row['user_extended_struct_name']] = $row['user_extended_struct_id']; // Create name to ID index
if($row['user_extended_struct_text'] == '_system_')
{ {
$this->systemCount++; $this->systemCount++;
} }
@@ -154,7 +160,7 @@ class e107_user_extended
*/ */
public function hasPermission($field, $type='read') public function hasPermission($field, $type='read')
{ {
$class = ($type == 'read') ? $this->fieldPermissions[$field]['read'] : $this->fieldPermissions[$field]['write']; $class = ($type == 'read') ? $this->fieldAttributes[$field]['read'] : $this->fieldAttributes[$field]['write'];
return check_class($class); return check_class($class);
} }
@@ -486,7 +492,16 @@ class e107_user_extended
} }
public function getFieldType($field)
{
if(!empty($this->fieldAttributes[$field]['type']))
{
return (int) $this->fieldAttributes[$field]['type'];
}
return false;
}
// Return the field creation text for a definition // Return the field creation text for a definition
@@ -1189,9 +1204,10 @@ class e107_user_extended
* @param $type * @param $type
* @return array|string * @return array|string
*/ */
function renderValue($value, $type='') public function renderValue($value, $type=null)
{ {
//TODO FIXME Add more types. //TODO FIXME Add more types.
switch($type) switch($type)