mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 03:40:37 +02:00
User-extended cleanup
This commit is contained in:
@@ -483,7 +483,7 @@ class signup_shortcodes extends e_shortcode
|
|||||||
// 'unallocated' entries are `user_extended_struct_parent` = 0
|
// 'unallocated' entries are `user_extended_struct_parent` = 0
|
||||||
|
|
||||||
// Get a list of defined categories
|
// Get a list of defined categories
|
||||||
$catList = $ue->getCategories(FALSE);
|
$catList = $ue->getCategories();
|
||||||
// Add in category zero - the 'no category' category
|
// Add in category zero - the 'no category' category
|
||||||
array_unshift($catList,array('user_extended_struct_parent' => 0, 'user_extended_struct_id' => '0'));
|
array_unshift($catList,array('user_extended_struct_parent' => 0, 'user_extended_struct_id' => '0'));
|
||||||
|
|
||||||
|
@@ -764,13 +764,11 @@ class user_shortcodes extends e_shortcode
|
|||||||
";
|
";
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(e_HANDLER."user_extended_class.php");
|
$ue = e107::getUserExt();
|
||||||
|
|
||||||
$ue = new e107_user_extended;
|
|
||||||
$ueCatList = $ue->user_extended_get_categories();
|
$ueCatList = $ue->user_extended_get_categories();
|
||||||
$ueFieldList = $ue->user_extended_get_fields();
|
$ueFieldList = $ue->user_extended_get_fields();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$ueCatList[0][0] = array('user_extended_struct_name' => LAN_USER_44, 'user_extended_struct_text' => '');
|
$ueCatList[0][0] = array('user_extended_struct_name' => LAN_USER_44, 'user_extended_struct_text' => '');
|
||||||
|
|
||||||
|
@@ -14,31 +14,30 @@
|
|||||||
function user_extended_shortcode($parm)
|
function user_extended_shortcode($parm)
|
||||||
{
|
{
|
||||||
|
|
||||||
$currentUser = e107::user();
|
// $currentUser = e107::user();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
$ue = e107::getUserExt();
|
||||||
|
|
||||||
global $loop_uid, $e107, $sc_style;
|
global $loop_uid, $e107, $sc_style;
|
||||||
|
|
||||||
// include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_user_extended.php');
|
$tmp = explode('.', $parm);
|
||||||
|
$fieldname = $tmp[0];
|
||||||
$parms = explode('.', $parm);
|
$type = $tmp[1];
|
||||||
|
$user = varset($tmp[2], 0);
|
||||||
|
|
||||||
if(isset($loop_uid) && intval($loop_uid) == 0)
|
if(isset($loop_uid) && intval($loop_uid) == 0)
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = $parms[0].".".$parms[1];
|
$key = $fieldname.".".$type;
|
||||||
|
|
||||||
$sc_style['USER_EXTENDED']['pre'] = (isset($sc_style['USER_EXTENDED'][$key]['pre']) ? $sc_style['USER_EXTENDED'][$key]['pre'] : '');
|
$sc_style['USER_EXTENDED']['pre'] = (isset($sc_style['USER_EXTENDED'][$key]['pre']) ? $sc_style['USER_EXTENDED'][$key]['pre'] : '');
|
||||||
$sc_style['USER_EXTENDED']['post'] = (isset($sc_style['USER_EXTENDED'][$key]['post']) ? $sc_style['USER_EXTENDED'][$key]['post'] : '');
|
$sc_style['USER_EXTENDED']['post'] = (isset($sc_style['USER_EXTENDED'][$key]['post']) ? $sc_style['USER_EXTENDED'][$key]['post'] : '');
|
||||||
|
|
||||||
//include_once(e_HANDLER.'user_extended_class.php');
|
$uid = (int) $user;
|
||||||
$ueStruct = e107::getUserExt()->user_extended_getStruct();
|
|
||||||
// $ueStruct = e107_user_extended::user_extended_getStruct();
|
|
||||||
|
|
||||||
$uid = intval(varset($parms[2],0));
|
if($uid === 0)
|
||||||
if($uid == 0)
|
|
||||||
{
|
{
|
||||||
if(isset($loop_uid) && intval($loop_uid) > 0)
|
if(isset($loop_uid) && intval($loop_uid) > 0)
|
||||||
{
|
{
|
||||||
@@ -57,7 +56,7 @@
|
|||||||
|
|
||||||
if(!empty($udata['user_admin']))
|
if(!empty($udata['user_admin']))
|
||||||
{
|
{
|
||||||
$udata['user_class'].= ','.e_UC_ADMIN;
|
$udata['user_class'] .= ','.e_UC_ADMIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -66,167 +65,108 @@
|
|||||||
/**
|
/**
|
||||||
* @todo - must be a better way of picking up the 'Miscellaneous' category
|
* @todo - must be a better way of picking up the 'Miscellaneous' category
|
||||||
*/
|
*/
|
||||||
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_user.php');
|
|
||||||
|
|
||||||
|
// e107::coreLan('user');
|
||||||
|
|
||||||
if (($parms[1] != 'icon') && ($parms[0] != LAN_USER_44))
|
if(($type !== 'icon') && ($ue->getCategoryAttribute($fieldname, 'read') === false))
|
||||||
{
|
{
|
||||||
$fkeyApplic = varset($ueStruct["user_".$parms[0]]['user_extended_struct_applicable']);
|
$fkeyApplic = $ue->getFieldAttribute("user_" . $fieldname, 'applicable');
|
||||||
$fkeyRead = varset($ueStruct["user_".$parms[0]]['user_extended_struct_read']);
|
$fkeyRead = $ue->getFieldAttribute("user_" . $fieldname, 'read');
|
||||||
$fkeyStruct = varset($ueStruct["user_".$parms[0]]['user_extended_struct_parms']);
|
$fkeyStruct = $ue->getFieldAttribute("user_" . $fieldname, 'parms');
|
||||||
|
|
||||||
$ret_cause = 0;
|
$ret_cause = 0;
|
||||||
if (!check_class($fkeyApplic, $udata['user_class'])) $ret_cause = 1;
|
|
||||||
if (!check_class($fkeyRead, $udata['user_class'])) $ret_cause = 2;
|
if(!check_class($fkeyApplic, $udata['user_class']))
|
||||||
if (($ueStruct["user_".$parms[0]]['user_extended_struct_read'] == e_UC_READONLY && (!ADMIN && $udata['user_id'] != USERID))) $ret_cause = 3;
|
|
||||||
if ((!ADMIN && substr($fkeyStruct, -1) == 1
|
|
||||||
&& strpos($udata['user_hidden_fields'], "^user_".$parms[0]."^") !== FALSE && $uid != USERID)) $ret_cause = 4;
|
|
||||||
if ($ret_cause != 0)
|
|
||||||
{
|
{
|
||||||
return FALSE;
|
$ret_cause = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if($parms[1] == 'text_value')
|
if(!check_class($fkeyRead, $udata['user_class']))
|
||||||
{
|
|
||||||
// $_value = $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.value}");
|
|
||||||
$_value = user_extended_shortcode($parms[0].".value");
|
|
||||||
//print_a($parms);
|
|
||||||
|
|
||||||
if($_value)
|
|
||||||
{
|
{
|
||||||
$__pre = (isset($sc_style['USER_EXTENDED'][$key]['pre']) ? $sc_style['USER_EXTENDED'][$key]['pre'] : '');
|
$ret_cause = 2;
|
||||||
$__post = (isset($sc_style['USER_EXTENDED'][$key]['post']) ? $sc_style['USER_EXTENDED'][$key]['post'] : '');
|
|
||||||
|
|
||||||
// $_text = $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.text}");
|
|
||||||
|
|
||||||
$_text = user_extended_shortcode($parms[0].".text");
|
|
||||||
|
|
||||||
|
|
||||||
$_mid = (isset($sc_style['USER_EXTENDED'][$key]['mid']) ? $sc_style['USER_EXTENDED'][$key]['mid'] : ': ');
|
|
||||||
return $__pre.$_text.$_mid.$_value.$__post;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($parms[1] == 'text')
|
if(($fkeyRead == e_UC_READONLY && (!ADMIN && $udata['user_id'] != USERID)))
|
||||||
{
|
{
|
||||||
if(!isset($parms[0]) || !isset($ueStruct['user_'.$parms[0]]) || !isset($ueStruct['user_'.$parms[0]]['user_extended_struct_text']))
|
$ret_cause = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((!ADMIN && substr($fkeyStruct, -1) == 1 && strpos($udata['user_hidden_fields'], "^user_" . $fieldname . "^") !== false && $uid != USERID))
|
||||||
|
{
|
||||||
|
$ret_cause = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($ret_cause))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$text_val = $ueStruct['user_'.$parms[0]]['user_extended_struct_text'];
|
|
||||||
|
|
||||||
if($text_val)
|
|
||||||
{
|
|
||||||
return (defined($text_val) ? constant($text_val) : $text_val);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($parms[1] == 'icon')
|
|
||||||
|
|
||||||
|
$ret = false;
|
||||||
|
|
||||||
|
switch($type)
|
||||||
{
|
{
|
||||||
if(defined(strtoupper($parms[0]).'_ICON'))
|
case "text_value":
|
||||||
{
|
$_value = user_extended_shortcode($fieldname.".value.".$user);
|
||||||
return constant(strtoupper($parms[0]).'_ICON');
|
|
||||||
}
|
|
||||||
elseif(is_readable(e_IMAGE."user_icons/user_{$parms[0]}.png"))
|
|
||||||
{
|
|
||||||
return "<img src='".e_IMAGE_ABS."user_icons/user_{$parms[0]}.png' style='width:16px; height:16px' alt='' />";
|
|
||||||
}
|
|
||||||
elseif(is_readable(e_IMAGE."user_icons/{$parms[0]}.png"))
|
|
||||||
{
|
|
||||||
return "<img src='".e_IMAGE_ABS."user_icons/{$parms[0]}.png' style='width:16px; height:16px' alt='' />";
|
|
||||||
}
|
|
||||||
//return '';
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($parms[1] === 'value')
|
if($_value)
|
||||||
{
|
{
|
||||||
$uVal = isset($parms[0]) && isset($udata['user_'.$parms[0]]) ? str_replace(chr(1), '', $udata['user_'.$parms[0]]) : '';
|
$__pre = (isset($sc_style['USER_EXTENDED'][$key]['pre']) ? $sc_style['USER_EXTENDED'][$key]['pre'] : '');
|
||||||
|
$__post = (isset($sc_style['USER_EXTENDED'][$key]['post']) ? $sc_style['USER_EXTENDED'][$key]['post'] : '');
|
||||||
if(!isset($parms[0]) || !isset($ueStruct["user_".$parms[0]]) || !isset($ueStruct["user_".$parms[0]]['user_extended_struct_type']))
|
$_text = $ue->getFieldLabel($fieldname); // user_extended_shortcode($fieldname.".text");
|
||||||
{
|
$_mid = (isset($sc_style['USER_EXTENDED'][$key]['mid']) ? $sc_style['USER_EXTENDED'][$key]['mid'] : ': ');
|
||||||
return null;
|
$ret = $__pre.$_text.$_mid.$_value.$__post;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($ueStruct["user_".$parms[0]]['user_extended_struct_type'])
|
|
||||||
{
|
|
||||||
|
|
||||||
case EUF_CHECKBOX:
|
|
||||||
|
|
||||||
$uVal = e107::unserialize($uVal);
|
|
||||||
|
|
||||||
if(!empty($uVal))
|
|
||||||
{
|
|
||||||
return implode(', ',$uVal);
|
|
||||||
|
|
||||||
/*
|
|
||||||
$text = '<ul>';
|
|
||||||
foreach($uVal as $v)
|
|
||||||
{
|
|
||||||
$text .= "<li>".$v."</li>";
|
|
||||||
|
|
||||||
}
|
|
||||||
$text .= "</ul>";
|
|
||||||
$ret_data = $text;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EUF_COUNTRY:
|
|
||||||
if(!empty($uVal))
|
case "text":
|
||||||
|
if(isset($fieldname))
|
||||||
|
{
|
||||||
|
$ret = $ue->getFieldLabel($fieldname);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case "icon":
|
||||||
|
if(defined(strtoupper($fieldname).'_ICON'))
|
||||||
|
{
|
||||||
|
$ret = constant(strtoupper($fieldname).'_ICON');
|
||||||
|
}
|
||||||
|
elseif(is_readable(e_IMAGE."user_icons/user_{$fieldname}.png"))
|
||||||
|
{
|
||||||
|
$ret = "<img src='".e_IMAGE_ABS."user_icons/user_{$fieldname}.png' style='width:16px; height:16px' alt='' />";
|
||||||
|
}
|
||||||
|
elseif(is_readable(e_IMAGE."user_icons/{$fieldname}.png"))
|
||||||
|
{
|
||||||
|
$ret = "<img src='".e_IMAGE_ABS."user_icons/{$fieldname}.png' style='width:16px; height:16px' alt='' />";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case "value":
|
||||||
|
$uVal = isset($fieldname) && isset($udata['user_'.$fieldname]) ? str_replace(chr(1), '', $udata['user_'.$fieldname]) : '';
|
||||||
|
|
||||||
|
if(!empty($uVal))
|
||||||
|
{
|
||||||
|
|
||||||
|
$ret = $ue->renderValue($uVal, "user_".$fieldname);
|
||||||
|
|
||||||
|
if(!empty($ret))
|
||||||
{
|
{
|
||||||
return e107::getForm()->getCountry($uVal);
|
$ret = $tp->toHTML($ret, TRUE, 'no_make_clickable', "class:{$udata['user_class']}");
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
break;
|
break;
|
||||||
case EUF_DB_FIELD : // check for db_lookup type
|
|
||||||
$tmp = explode(',',$ueStruct['user_'.$parms[0]]['user_extended_struct_values']);
|
|
||||||
|
|
||||||
if(empty($tmp[1]) || empty($tmp[2]))
|
// code to be executed if n is different from all labels;
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$sql_ue = new db; // Use our own DB object to avoid conflicts
|
|
||||||
if($sql_ue->select($tmp[0],"{$tmp[1]}, {$tmp[2]}","{$tmp[1]} = '{$uVal}'"))
|
|
||||||
{
|
|
||||||
$row = $sql_ue->fetch();
|
|
||||||
$ret_data = $row[$tmp[2]];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ret_data = FALSE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EUF_DATE : //check for 0000-00-00 in date field
|
|
||||||
if($uVal == '0000-00-00') { $uVal = ''; }
|
|
||||||
$ret_data = $uVal;
|
|
||||||
break;
|
|
||||||
case EUF_PREDEFINED : // Predefined field - have to look up display string in relevant file
|
|
||||||
$ret_data = e107::getUserExt()->user_extended_display_text($ueStruct['user_'.$parms[0]]['user_extended_struct_values'],$uVal);
|
|
||||||
break;
|
|
||||||
case EUF_RICHTEXTAREA :
|
|
||||||
$ret_data = e107::getParser()->toHTML($uVal);
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
$ret_data = $uVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!empty($ret_data))
|
|
||||||
{
|
|
||||||
return $tp->toHTML($ret_data, TRUE, 'no_make_clickable', "class:{$udata['user_class']}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
// return TRUE;
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
|
||||||
}
|
}
|
@@ -44,6 +44,7 @@ class e107_user_extended
|
|||||||
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 $fieldAttributes = array(); // Field Permissionss with field name as key.
|
private $fieldAttributes = array(); // Field Permissionss with field name as key.
|
||||||
|
private $catAttributes = array();
|
||||||
private $lastError;
|
private $lastError;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -139,20 +140,34 @@ class e107_user_extended
|
|||||||
{
|
{
|
||||||
while($row = $sql->fetch())
|
while($row = $sql->fetch())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if ($row['user_extended_struct_type'] == 0)
|
if ($row['user_extended_struct_type'] == 0)
|
||||||
{ // Its a category
|
{ // Its a category
|
||||||
|
$id = $row['user_extended_struct_name'];
|
||||||
$this->catDefinitions[$row['user_extended_struct_id']] = $row;
|
$this->catDefinitions[$row['user_extended_struct_id']] = $row;
|
||||||
|
$this->catAttributes[$id] = array(
|
||||||
|
'read' => (int) $row['user_extended_struct_read'],
|
||||||
|
'write' => (int) $row['user_extended_struct_write'],
|
||||||
|
'applicable' => (int) $row['user_extended_struct_applicable'],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Its a field definition
|
{ // Its a field definition
|
||||||
$this->fieldDefinitions[$row['user_extended_struct_id']] = $row;
|
|
||||||
$id = 'user_' . $row['user_extended_struct_name'];
|
$id = 'user_' . $row['user_extended_struct_name'];
|
||||||
|
$this->fieldDefinitions[$row['user_extended_struct_id']] = $row;
|
||||||
|
|
||||||
|
|
||||||
$this->fieldAttributes[$id] = array(
|
$this->fieldAttributes[$id] = array(
|
||||||
'read' => $row['user_extended_struct_read'],
|
'read' => (int) $row['user_extended_struct_read'],
|
||||||
'write' => $row['user_extended_struct_write'],
|
'write' => (int) $row['user_extended_struct_write'],
|
||||||
'type' => $row['user_extended_struct_type']
|
'type' => $row['user_extended_struct_type'],
|
||||||
|
'values' => $row['user_extended_struct_values'],
|
||||||
|
'parms' => $row['user_extended_struct_parms'],
|
||||||
|
'applicable' => (int) $row['user_extended_struct_applicable'],
|
||||||
|
'required' => (int) $row['user_extended_struct_required'],
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->nameIndex['user_' . $row['user_extended_struct_name']] = $row['user_extended_struct_id']; // Create name to ID index
|
$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_')
|
if($row['user_extended_struct_text'] == '_system_')
|
||||||
@@ -514,16 +529,18 @@ class e107_user_extended
|
|||||||
*/
|
*/
|
||||||
function getCategories($byID = TRUE)
|
function getCategories($byID = TRUE)
|
||||||
{
|
{
|
||||||
return $this->user_extended_get_categories($byID);
|
return $this->catDefinitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BC Alias of getCategories()
|
* Return a list of the user-extended categories.
|
||||||
|
* @deprecated Use getCategories() instead.
|
||||||
* @param bool $byID
|
* @param bool $byID
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function user_extended_get_categories($byID = TRUE)
|
function user_extended_get_categories($byID = TRUE)
|
||||||
{
|
{
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
$sql = e107::getDb('ue');
|
$sql = e107::getDb('ue');
|
||||||
|
|
||||||
@@ -679,7 +696,7 @@ class e107_user_extended
|
|||||||
public function getFieldType($field)
|
public function getFieldType($field)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!empty($this->fieldAttributes[$field]['type']))
|
if(isset($this->fieldAttributes[$field]['type']))
|
||||||
{
|
{
|
||||||
return (int) $this->fieldAttributes[$field]['type'];
|
return (int) $this->fieldAttributes[$field]['type'];
|
||||||
}
|
}
|
||||||
@@ -687,6 +704,53 @@ class e107_user_extended
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the field attributes of a given field-name.
|
||||||
|
* @param string $field
|
||||||
|
* @param string read|write|type|values|parms|applicable
|
||||||
|
* @return bool|int|string
|
||||||
|
*/
|
||||||
|
public function getFieldAttribute($field, $att)
|
||||||
|
{
|
||||||
|
if(isset($this->fieldAttributes[$field][$att]))
|
||||||
|
{
|
||||||
|
return e107::getParser()->toHtml($this->fieldAttributes[$field][$att],false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the category attributes of a given category-name.
|
||||||
|
* @param string $field
|
||||||
|
* @param string read|write|applicable
|
||||||
|
* @return bool|int
|
||||||
|
*/
|
||||||
|
public function getCategoryAttribute($field, $att)
|
||||||
|
{
|
||||||
|
if(isset($this->catAttributes[$field][$att]))
|
||||||
|
{
|
||||||
|
return (int) $this->catAttributes[$field][$att];
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the field structure values of a given field-name.
|
||||||
|
* @param $field
|
||||||
|
* @return bool|string
|
||||||
|
*/
|
||||||
|
public function getFieldValues($field)
|
||||||
|
{
|
||||||
|
if(!empty($this->fieldAttributes[$field]['values']))
|
||||||
|
{
|
||||||
|
return e107::getParser()->toHTML($this->fieldAttributes[$field]['values'], false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of all field types.
|
* Return a list of all field types.
|
||||||
@@ -1346,6 +1410,28 @@ class e107_user_extended
|
|||||||
return $this->extended_xml;
|
return $this->extended_xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $field
|
||||||
|
* @return false|mixed|null
|
||||||
|
*/
|
||||||
|
public function getFieldLabel($field)
|
||||||
|
{
|
||||||
|
if(strpos($field, 'user_') !== 0)
|
||||||
|
{
|
||||||
|
$field = 'user_' . $field;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($this->nameIndex[$field]) || !isset($this->fieldDefinitions[$this->nameIndex[$field]]['user_extended_struct_text']))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = $this->fieldDefinitions[$this->nameIndex[$field]]['user_extended_struct_text'];
|
||||||
|
|
||||||
|
return defset($text, $text);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement Method for user_extended_getvalue(); Returns extended field data in the original posted format.
|
* Replacement Method for user_extended_getvalue(); Returns extended field data in the original posted format.
|
||||||
* @param int $uid
|
* @param int $uid
|
||||||
@@ -1384,7 +1470,6 @@ class e107_user_extended
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
$ret = $uinfo[$field_name];
|
$ret = $uinfo[$field_name];
|
||||||
// code to be executed if n is different from all labels;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
@@ -1537,65 +1622,126 @@ class e107_user_extended
|
|||||||
/**
|
/**
|
||||||
* Render Extended User Field Data in a read-only fashion.
|
* Render Extended User Field Data in a read-only fashion.
|
||||||
* @param $value
|
* @param $value
|
||||||
* @param $type
|
* @param int|string $type field type number or field name.
|
||||||
* @return array|string
|
* @return array|string
|
||||||
*/
|
*/
|
||||||
public function renderValue($value, $type=null)
|
public function renderValue($value, $type=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(!empty($type) && !is_numeric($type))
|
||||||
|
{
|
||||||
|
$fieldname = $type;
|
||||||
|
$type = $this->getFieldType($type);
|
||||||
|
}
|
||||||
|
|
||||||
//TODO FIXME Add more types.
|
$ret = null;
|
||||||
|
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
|
case EUF_RADIO:
|
||||||
|
|
||||||
|
if(isset($fieldname))
|
||||||
|
{
|
||||||
|
$tmp = $this->getFieldAttribute($fieldname, 'values');
|
||||||
|
$choices = explode(',', $tmp);
|
||||||
|
|
||||||
|
foreach($choices as $choice)
|
||||||
|
{
|
||||||
|
$choice = trim($choice);
|
||||||
|
$choice = e107::getParser()->toHTML($choice);
|
||||||
|
|
||||||
|
if(strpos($choice,"|")!==FALSE)
|
||||||
|
{
|
||||||
|
list($val,$label) = explode("|",$choice);
|
||||||
|
}
|
||||||
|
elseif(strpos($choice," => ")!==FALSE) // new in v2.x
|
||||||
|
{
|
||||||
|
list($val,$label) = explode(" => ",$choice);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$val = $choice;
|
||||||
|
$label = $choice;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($val == $value)
|
||||||
|
{
|
||||||
|
$ret = defset($label, $label);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case EUF_COUNTRY:
|
case EUF_COUNTRY:
|
||||||
if(!empty($value))
|
if(!empty($value))
|
||||||
{
|
{
|
||||||
return e107::getForm()->getCountry($value);
|
$ret = e107::getForm()->getCountry($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case EUF_CHECKBOX:
|
|
||||||
$value = e107::unserialize($value);
|
|
||||||
|
|
||||||
if(!empty($value))
|
|
||||||
{
|
|
||||||
|
|
||||||
sort($value);
|
|
||||||
return implode('<br />',$value);
|
|
||||||
|
|
||||||
/*
|
|
||||||
$text = '<ul>';
|
|
||||||
foreach($uVal as $v)
|
|
||||||
{
|
|
||||||
$text .= "<li>".$v."</li>";
|
|
||||||
|
|
||||||
}
|
|
||||||
$text .= "</ul>";
|
|
||||||
$ret_data = $text;*/
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EUF_DATE : //check for 0000-00-00 in date field
|
case EUF_CHECKBOX:
|
||||||
if($value == '0000-00-00') { $value = ''; }
|
$value = e107::unserialize($value);
|
||||||
return $value;
|
|
||||||
break;
|
if(!empty($value))
|
||||||
|
{
|
||||||
|
sort($value);
|
||||||
|
$ret = implode(', ', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EUF_DATE : //check for 0000-00-00 in date field
|
||||||
|
if($value == '0000-00-00')
|
||||||
|
{
|
||||||
|
$value = '';
|
||||||
|
}
|
||||||
|
$ret = $value;
|
||||||
|
break;
|
||||||
|
|
||||||
case EUF_RICHTEXTAREA:
|
case EUF_RICHTEXTAREA:
|
||||||
return e107::getParser()->toHTML($value, true);
|
$ret = e107::getParser()->toHTML($value, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EUF_DB_FIELD : // check for db_lookup type
|
||||||
|
if(!isset($fieldname))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$structValues = $this->getFieldValues($fieldname);
|
||||||
|
$tmp = explode(',', $structValues);
|
||||||
|
|
||||||
|
if(empty($tmp[1]) || empty($tmp[2]))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_ue = e107::getDb('euf_db'); // Use our own DB object to avoid conflicts
|
||||||
|
if($sql_ue->select($tmp[0], "{$tmp[1]}, {$tmp[2]}", "{$tmp[1]} = '{$value}'"))
|
||||||
|
{
|
||||||
|
|
||||||
|
$row = $sql_ue->fetch();
|
||||||
|
$ret = varset($row[$tmp[2]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EUF_PREDEFINED : // Predefined field - have to look up display string in relevant file
|
||||||
|
if(isset($fieldname))
|
||||||
|
{
|
||||||
|
$structValues = $this->getFieldValues($fieldname);
|
||||||
|
$ret = $this->user_extended_display_text($structValues, $value);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $value;
|
$ret = $value;
|
||||||
// code to be executed if n is different from all labels;
|
// code to be executed if n is different from all labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,8 @@
|
|||||||
class e107_user_extendedTest extends \Codeception\Test\Unit
|
class e107_user_extendedTest extends \Codeception\Test\Unit
|
||||||
{
|
{
|
||||||
|
|
||||||
private $typeArray;
|
private $structTypes;
|
||||||
|
private $structLabels;
|
||||||
|
|
||||||
/** @var e107_user_extended */
|
/** @var e107_user_extended */
|
||||||
protected $ue;
|
protected $ue;
|
||||||
@@ -31,7 +32,7 @@
|
|||||||
|
|
||||||
$this->ue->__construct();
|
$this->ue->__construct();
|
||||||
|
|
||||||
$this->typeArray = array(
|
$this->structTypes = array(
|
||||||
'text' => EUF_TEXT,
|
'text' => EUF_TEXT,
|
||||||
'homepage' => EUF_TEXT,
|
'homepage' => EUF_TEXT,
|
||||||
'radio' => EUF_RADIO,
|
'radio' => EUF_RADIO,
|
||||||
@@ -49,6 +50,24 @@
|
|||||||
'richtextarea' => EUF_RICHTEXTAREA,
|
'richtextarea' => EUF_RICHTEXTAREA,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->structLabels = array (
|
||||||
|
'text' => 'Text',
|
||||||
|
'homepage' => 'UE_LAN_HOMEPAGE', // test constant use as well.
|
||||||
|
'radio' => 'Radio',
|
||||||
|
'dropdown' => 'Dropdown',
|
||||||
|
'dbfield' => 'Dbfield',
|
||||||
|
'textarea' => 'Textarea',
|
||||||
|
'integer' => 'Integer',
|
||||||
|
'date' => 'Date',
|
||||||
|
'language' => 'Language',
|
||||||
|
'list' => 'List',
|
||||||
|
'checkbox' => 'Checkbox',
|
||||||
|
'predefined' => 'Predefined',
|
||||||
|
'country' => 'Country',
|
||||||
|
'richtextarea' => 'Richtextarea',
|
||||||
|
'addon' => 'Addon'
|
||||||
|
);
|
||||||
|
|
||||||
$this->structValues = array(
|
$this->structValues = array(
|
||||||
'dropdown' => 'drop1,drop2,drop3',
|
'dropdown' => 'drop1,drop2,drop3',
|
||||||
'dbfield' => 'core_media_cat,media_cat_id,media_cat_title,media_cat_order',
|
'dbfield' => 'core_media_cat,media_cat_id,media_cat_title,media_cat_order',
|
||||||
@@ -68,13 +87,13 @@
|
|||||||
|
|
||||||
|
|
||||||
// Add a field of each type.
|
// Add a field of each type.
|
||||||
foreach($this->typeArray as $k=>$v)
|
foreach($this->structTypes as $k=> $v)
|
||||||
{
|
{
|
||||||
$value = (isset($this->structValues[$k])) ? $this->structValues[$k] : null;
|
$value = (isset($this->structValues[$k])) ? $this->structValues[$k] : null;
|
||||||
|
|
||||||
$insert = array(
|
$insert = array(
|
||||||
'name' => $k,
|
'name' => $k,
|
||||||
'text' => ucfirst($k),
|
'text' => $this->structLabels[$k],
|
||||||
'type' => $v,
|
'type' => $v,
|
||||||
'parms' => null,
|
'parms' => null,
|
||||||
'values' => (isset($this->structValues[$k])) ? $this->structValues[$k] : null,
|
'values' => (isset($this->structValues[$k])) ? $this->structValues[$k] : null,
|
||||||
@@ -85,6 +104,30 @@
|
|||||||
// $this->ue->user_extended_add($k, ucfirst($k), $v , null, $value);
|
// $this->ue->user_extended_add($k, ucfirst($k), $v , null, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert a User-Extended Category
|
||||||
|
$insertCategory = array(
|
||||||
|
'name' => 'mycategory',
|
||||||
|
'text' => 'Category Name',
|
||||||
|
'type' => 0,
|
||||||
|
'read' => e_UC_PUBLIC,
|
||||||
|
'write' => e_UC_ADMIN,
|
||||||
|
'applicable' => e_UC_MEMBER
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->ue->user_extended_add($insertCategory);
|
||||||
|
|
||||||
|
// Insert a User-Extended Category
|
||||||
|
$insertCategory2 = array(
|
||||||
|
'name' => 'mycategory2 ',
|
||||||
|
'text' => 'Category Name 2',
|
||||||
|
'type' => 0,
|
||||||
|
'read' => e_UC_ADMIN,
|
||||||
|
'write' => e_UC_ADMIN,
|
||||||
|
'applicable' => e_UC_MEMBER
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->ue->user_extended_add($insertCategory2);
|
||||||
|
|
||||||
// As $_POSTED.
|
// As $_POSTED.
|
||||||
$this->userValues = array(
|
$this->userValues = array(
|
||||||
'text' => 'Some Text',
|
'text' => 'Some Text',
|
||||||
@@ -143,7 +186,7 @@
|
|||||||
$legacyExpectedValues = array (
|
$legacyExpectedValues = array (
|
||||||
'text' => 'Some Text',
|
'text' => 'Some Text',
|
||||||
'homepage' => 'https://e107.org',
|
'homepage' => 'https://e107.org',
|
||||||
'radio' => 'M',
|
'radio' => 'Male',
|
||||||
'dropdown' => 'drop3',
|
'dropdown' => 'drop3',
|
||||||
'dbfield' => 'News',
|
'dbfield' => 'News',
|
||||||
'textarea' => 'Text area value',
|
'textarea' => 'Text area value',
|
||||||
@@ -168,36 +211,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$legacyExpectedLabels = array (
|
|
||||||
'text' => 'Text',
|
|
||||||
'homepage' => 'Homepage',
|
|
||||||
'radio' => 'Radio',
|
|
||||||
'dropdown' => 'Dropdown',
|
|
||||||
'dbfield' => 'Dbfield',
|
|
||||||
'textarea' => 'Textarea',
|
|
||||||
'integer' => 'Integer',
|
|
||||||
'date' => 'Date',
|
|
||||||
'language' => 'Language',
|
|
||||||
'list' => 'List',
|
|
||||||
'checkbox' => 'Checkbox',
|
|
||||||
'predefined' => 'Predefined',
|
|
||||||
'country' => 'Country',
|
|
||||||
'richtextarea' => 'Richtextarea',
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach($this->userValues as $field => $value)
|
foreach($this->userValues as $field => $value)
|
||||||
{
|
{
|
||||||
$parm = $field.'.text.1';
|
$parm = $field.'.text.1';
|
||||||
$result = $tp->parseTemplate('{USER_EXTENDED='.$parm.'}', true); // retrieve value for $field of user_id: 1.
|
$result = $tp->parseTemplate('{USER_EXTENDED='.$parm.'}', true); // retrieve value for $field of user_id: 1.
|
||||||
$this->assertEquals($legacyExpectedLabels[$field], $result);
|
$expected = defset($this->structLabels[$field],$this->structLabels[$field]);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$legacyExpectedLabelValues = array (
|
$legacyExpectedLabelValues = array (
|
||||||
'text' => 'Text: Some Text',
|
'text' => 'Text: Some Text',
|
||||||
'homepage' => 'Homepage: https://e107.org',
|
'homepage' => 'Homepage: https://e107.org',
|
||||||
'radio' => 'Radio: M',
|
'radio' => 'Radio: Male',
|
||||||
'dropdown' => 'Dropdown: drop3',
|
'dropdown' => 'Dropdown: drop3',
|
||||||
'dbfield' => 'Dbfield: News',
|
'dbfield' => 'Dbfield: News',
|
||||||
'textarea' => 'Textarea: Text area value',
|
'textarea' => 'Textarea: Text area value',
|
||||||
@@ -254,7 +280,7 @@
|
|||||||
|
|
||||||
$result = $this->ue->getStructure();
|
$result = $this->ue->getStructure();
|
||||||
|
|
||||||
foreach($this->typeArray as $k=>$v)
|
foreach($this->structTypes as $k=> $v)
|
||||||
{
|
{
|
||||||
$key = 'user_'.$k;
|
$key = 'user_'.$k;
|
||||||
$this->assertArrayHasKey($key,$result);
|
$this->assertArrayHasKey($key,$result);
|
||||||
@@ -278,6 +304,36 @@
|
|||||||
|
|
||||||
$this->assertEquals(EUF_RADIO,$result);
|
$this->assertEquals(EUF_RADIO,$result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetFieldValues()
|
||||||
|
{
|
||||||
|
foreach($this->structValues as $key=>$value)
|
||||||
|
{
|
||||||
|
$result = $this->ue->getFieldValues('user_'.$key);
|
||||||
|
$this->assertEquals($value, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetFieldLabel()
|
||||||
|
{
|
||||||
|
foreach($this->structLabels as $field => $label)
|
||||||
|
{
|
||||||
|
$result = $this->ue->getFieldLabel('user_'.$field);
|
||||||
|
$this->assertSame(defset($label, $label), $result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testGetFieldAttibute()
|
||||||
|
{
|
||||||
|
foreach($this->structValues as $field=>$val)
|
||||||
|
{
|
||||||
|
$result = $this->ue->getFieldAttribute('user_'.$field,'values');
|
||||||
|
$this->assertSame($val, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public function testUser_extended_getvalue()
|
public function testUser_extended_getvalue()
|
||||||
{
|
{
|
||||||
@@ -357,6 +413,78 @@
|
|||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetCategoryAttribute()
|
||||||
|
{
|
||||||
|
$result = $this->ue->getCategoryAttribute('mycategory', 'read');
|
||||||
|
$this->assertSame(e_UC_PUBLIC, $result);
|
||||||
|
|
||||||
|
$result = $this->ue->getCategoryAttribute('mycategory', 'write');
|
||||||
|
$this->assertSame(e_UC_ADMIN, $result);
|
||||||
|
|
||||||
|
$result = $this->ue->getCategoryAttribute('user_text', 'read');
|
||||||
|
$this->assertSame(false, $result);
|
||||||
|
|
||||||
|
$result = $this->ue->getCategoryAttribute('not-a-category', 'read');
|
||||||
|
$this->assertSame(false, $result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetCategories()
|
||||||
|
{
|
||||||
|
$expected = array (
|
||||||
|
0 =>
|
||||||
|
array (
|
||||||
|
// 'user_extended_struct_id' => '16',
|
||||||
|
'user_extended_struct_name' => 'mycategory',
|
||||||
|
'user_extended_struct_text' => 'Category Name',
|
||||||
|
'user_extended_struct_type' => '0',
|
||||||
|
'user_extended_struct_parms' => '',
|
||||||
|
'user_extended_struct_values' => '',
|
||||||
|
'user_extended_struct_default' => '',
|
||||||
|
'user_extended_struct_read' => '0',
|
||||||
|
'user_extended_struct_write' => '254',
|
||||||
|
'user_extended_struct_required' => '0',
|
||||||
|
'user_extended_struct_signup' => '0',
|
||||||
|
'user_extended_struct_applicable' => '253',
|
||||||
|
'user_extended_struct_order' => '0',
|
||||||
|
'user_extended_struct_parent' => '0',
|
||||||
|
),
|
||||||
|
1 =>
|
||||||
|
array (
|
||||||
|
// 'user_extended_struct_id' => '17',
|
||||||
|
'user_extended_struct_name' => 'mycategory2',
|
||||||
|
'user_extended_struct_text' => 'Category Name 2',
|
||||||
|
'user_extended_struct_type' => '0',
|
||||||
|
'user_extended_struct_parms' => '',
|
||||||
|
'user_extended_struct_values' => '',
|
||||||
|
'user_extended_struct_default' => '',
|
||||||
|
'user_extended_struct_read' => '254',
|
||||||
|
'user_extended_struct_write' => '254',
|
||||||
|
'user_extended_struct_required' => '0',
|
||||||
|
'user_extended_struct_signup' => '0',
|
||||||
|
'user_extended_struct_applicable' => '253',
|
||||||
|
'user_extended_struct_order' => '0',
|
||||||
|
'user_extended_struct_parent' => '0',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$result = $this->ue->getCategories(false);
|
||||||
|
|
||||||
|
$this->assertNotEmpty($result);
|
||||||
|
|
||||||
|
$id = 0;
|
||||||
|
foreach($result as $row)
|
||||||
|
{
|
||||||
|
unset($row['user_extended_struct_id']);
|
||||||
|
$this->assertSame($expected[$id], $row);
|
||||||
|
$id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public function testUser_extended_edit()
|
public function testUser_extended_edit()
|
||||||
{
|
{
|
||||||
@@ -397,12 +525,92 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public function testUser_extended_get_categories()
|
public function testUser_extended_get_categories()
|
||||||
{
|
{
|
||||||
|
$expected = array (
|
||||||
|
'mycategory' =>
|
||||||
|
array (
|
||||||
|
'user_extended_struct_name' => 'mycategory',
|
||||||
|
'user_extended_struct_text' => 'Category Name',
|
||||||
|
'user_extended_struct_type' => '0',
|
||||||
|
'user_extended_struct_parms' => '',
|
||||||
|
'user_extended_struct_values' => '',
|
||||||
|
'user_extended_struct_default' => '',
|
||||||
|
'user_extended_struct_read' => '0',
|
||||||
|
'user_extended_struct_write' => '254',
|
||||||
|
'user_extended_struct_required' => '0',
|
||||||
|
'user_extended_struct_signup' => '0',
|
||||||
|
'user_extended_struct_applicable' => '253',
|
||||||
|
'user_extended_struct_order' => '0',
|
||||||
|
'user_extended_struct_parent' => '0',
|
||||||
|
),
|
||||||
|
'mycategory2' =>
|
||||||
|
array (
|
||||||
|
'user_extended_struct_name' => 'mycategory2',
|
||||||
|
'user_extended_struct_text' => 'Category Name 2',
|
||||||
|
'user_extended_struct_type' => '0',
|
||||||
|
'user_extended_struct_parms' => '',
|
||||||
|
'user_extended_struct_values' => '',
|
||||||
|
'user_extended_struct_default' => '',
|
||||||
|
'user_extended_struct_read' => '254',
|
||||||
|
'user_extended_struct_write' => '254',
|
||||||
|
'user_extended_struct_required' => '0',
|
||||||
|
'user_extended_struct_signup' => '0',
|
||||||
|
'user_extended_struct_applicable' => '253',
|
||||||
|
'user_extended_struct_order' => '0',
|
||||||
|
'user_extended_struct_parent' => '0',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Test 1.
|
||||||
|
$result = $this->compileCategoryResult($this->ue->user_extended_get_categories());
|
||||||
|
$this->assertNotEmpty($result);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
// Test 2
|
||||||
|
$result = $this->compileCategoryResult($this->ue->user_extended_get_categories(false), false);
|
||||||
|
$this->assertNotEmpty($result);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove ID since it could change during testing.
|
||||||
|
* @param array $result
|
||||||
|
*/
|
||||||
|
private function compileCategoryResult($result, $other=true)
|
||||||
|
{
|
||||||
|
if(empty($result))
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$myresult = [];
|
||||||
|
|
||||||
|
if($other === false)
|
||||||
|
{
|
||||||
|
$result = array($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($result as $row)
|
||||||
|
{
|
||||||
|
foreach($row as $arr)
|
||||||
|
{
|
||||||
|
unset($arr['user_extended_struct_id']);
|
||||||
|
$id = (string) $arr['user_extended_struct_name'];
|
||||||
|
foreach($arr as $field=>$val)
|
||||||
|
{
|
||||||
|
$myresult[$id][$field] = $val;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $myresult;
|
||||||
|
}
|
||||||
|
/*
|
||||||
public function testAddDefaultFields()
|
public function testAddDefaultFields()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user