1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 12:48:26 +02:00

Bugtracker #4552 - default icons to starting 'user_', plus various fixes

This commit is contained in:
e107steved
2010-01-03 12:12:34 +00:00
parent 625e006f9a
commit 71bef64fc3

View File

@@ -1,16 +1,26 @@
//USAGE: {USER_EXTENDED=<field_name>.[text|value|icon|text_value].<user_id>} /*
//EXAMPLE: {USER_EXTENDED=user_gender.value.5} will show the value of the extended field user_gender for user #5 * Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
include(e_LANGUAGEDIR.e_LANGUAGE."/lan_user_extended.php"); * $Id: user_extended.sc,v 1.11 2010-01-03 12:12:34 e107steved Exp $
$parms = explode(".", $parm); *
* Extended user field shortcode
*/
/**
*
* USAGE: {USER_EXTENDED=<field_name>.[text|value|icon|text_value].<user_id>}
* EXAMPLE: {USER_EXTENDED=user_gender.value.5} will show the value of the extended field user_gender for user #5
*/
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_user_extended.php');
$parms = explode('.', $parm);
global $currentUser, $tp, $loop_uid, $e107, $sc_style; global $currentUser, $tp, $loop_uid, $e107, $sc_style;
if(isset($loop_uid) && intval($loop_uid) == 0) { return ""; } if(isset($loop_uid) && intval($loop_uid) == 0) { return ''; }
$key = $parms[0].".".$parms[1]; $key = $parms[0].".".$parms[1];
$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"); include_once(e_HANDLER.'user_extended_class.php');
$ueStruct = e107_user_extended::user_extended_getStruct(); $ueStruct = e107_user_extended::user_extended_getStruct();
$uid = intval($parms[2]); $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)
@@ -25,16 +35,22 @@ if($uid == 0)
$udata = get_user_data($uid); $udata = get_user_data($uid);
$udata['user_class'] .= ($udata['user_class'] == "" ? "" : ","); $udata['user_class'] .= ($udata['user_class'] == '' ? '' : ',');
$udata['user_class'] .= e_UC_PUBLIC.",".e_UC_MEMBER; $udata['user_class'] .= e_UC_PUBLIC.",".e_UC_MEMBER;
if($udata['user_admin'] == 1) if($udata['user_admin'] == 1)
{ {
$udata['user_class'].= ",".e_UC_ADMIN; $udata['user_class'].= ','.e_UC_ADMIN;
} }
// Need to pick up the 'miscellaneous' category - anything which isn't in a named category. Have to control visibility on a field by field basis // Need to pick up the 'miscellaneous' category - anything which isn't in a named category. Have to control visibility on a field by field basis
if ($parms[0] != LAN_410) // And I don't think this should apply to icons
/**
* @todo - must be a better way of picking up the 'Miscellaneous' category
*/
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_user.php');
if (($parms[1] != 'icon') && ($parms[0] != LAN_USER_44))
{ {
$ret_cause = 0; $ret_cause = 0;
if (!check_class($ueStruct["user_".$parms[0]]['user_extended_struct_applicable'], $udata['user_class'])) $ret_cause = 1; if (!check_class($ueStruct["user_".$parms[0]]['user_extended_struct_applicable'], $udata['user_class'])) $ret_cause = 1;
@@ -53,10 +69,10 @@ if($parms[1] == 'text_value')
$_value = $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.value}"); $_value = $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.value}");
if($_value) if($_value)
{ {
$__pre = (isset($sc_style['USER_EXTENDED'][$key]['pre']) ? $sc_style['USER_EXTENDED'][$key]['pre'] : ""); $__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'] : ""); $__post = (isset($sc_style['USER_EXTENDED'][$key]['post']) ? $sc_style['USER_EXTENDED'][$key]['post'] : '');
$_text = $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.text}"); $_text = $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.text}");
$_mid = (isset($sc_style['USER_EXTENDED'][$key]['mid']) ? $sc_style['USER_EXTENDED'][$key]['mid'] : ""); $_mid = (isset($sc_style['USER_EXTENDED'][$key]['mid']) ? $sc_style['USER_EXTENDED'][$key]['mid'] : '');
return $__pre.$_text.$_mid.$_value.$__post; return $__pre.$_text.$_mid.$_value.$__post;
} }
return false; return false;
@@ -64,7 +80,7 @@ if($parms[1] == 'text_value')
if ($parms[1] == 'text') if ($parms[1] == 'text')
{ {
$text_val = $ueStruct["user_".$parms[0]]['user_extended_struct_text']; $text_val = $ueStruct['user_'.$parms[0]]['user_extended_struct_text'];
if($text_val) if($text_val)
{ {
return (defined($text_val) ? constant($text_val) : $text_val); return (defined($text_val) ? constant($text_val) : $text_val);
@@ -77,24 +93,28 @@ if ($parms[1] == 'text')
if ($parms[1] == 'icon') if ($parms[1] == 'icon')
{ {
if(defined(strtoupper($parms[0])."_ICON")) if(defined(strtoupper($parms[0]).'_ICON'))
{ {
return constant(strtoupper($parms[0])."_ICON"); return constant(strtoupper($parms[0]).'_ICON');
} }
elseif(file_exists(e_IMAGE."user_icons/{$parms[0]}.png")) elseif(is_readable(e_IMAGE."user_icons/user_{$parms[0]}.png"))
{ {
return "<img src='".e_IMAGE."user_icons/{$parms[0]}.png' style='width:16px; height:16px' alt='' />"; return "<img src='".e_IMAGE_ABS."user_icons/user_{$parms[0]}.png' style='width:16px; height:16px' alt='' />";
} }
return ""; 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 '';
} }
if ($parms[1] == 'value') if ($parms[1] == 'value')
{ {
$uVal = str_replace(chr(1), "", $udata['user_'.$parms[0]]); $uVal = str_replace(chr(1), '', $udata['user_'.$parms[0]]);
switch ($ueStruct["user_".$parms[0]]['user_extended_struct_type']) switch ($ueStruct["user_".$parms[0]]['user_extended_struct_type'])
{ {
case EUF_DB_FIELD : // check for db_lookup type case EUF_DB_FIELD : // check for db_lookup type
$tmp = explode(",",$ueStruct["user_".$parms[0]]['user_extended_struct_values']); $tmp = explode(',',$ueStruct['user_'.$parms[0]]['user_extended_struct_values']);
$sql_ue = new db; // Use our own DB object to avoid conflicts $sql_ue = new db; // Use our own DB object to avoid conflicts
if($sql_ue->db_Select($tmp[0],"{$tmp[1]}, {$tmp[2]}","{$tmp[1]} = '{$uVal}'")) if($sql_ue->db_Select($tmp[0],"{$tmp[1]}, {$tmp[2]}","{$tmp[1]} = '{$uVal}'"))
{ {
@@ -107,18 +127,18 @@ if ($parms[1] == 'value')
} }
break; break;
case EUF_DATE : //check for 0000-00-00 in date field case EUF_DATE : //check for 0000-00-00 in date field
if($uVal == "0000-00-00") { $uVal = ""; } if($uVal == '0000-00-00') { $uVal = ''; }
$ret_data = $uVal; $ret_data = $uVal;
break; break;
case EUF_PREDEFINED : // Predefined field - have to look up display string in relevant file case EUF_PREDEFINED : // Predefined field - have to look up display string in relevant file
$ret_data = e107_user_extended::user_extended_display_text($ueStruct["user_".$parms[0]]['user_extended_struct_values'],$uVal); $ret_data = e107_user_extended::user_extended_display_text($ueStruct['user_'.$parms[0]]['user_extended_struct_values'],$uVal);
break; break;
default : default :
$ret_data = $uVal; $ret_data = $uVal;
} }
if($ret_data != "") if($ret_data != '')
{ {
return $tp->toHTML($ret_data, TRUE, "no_make_clickable", "class:{$udata['user_class']}"); return $tp->toHTML($ret_data, TRUE, 'no_make_clickable', "class:{$udata['user_class']}");
} }
return FALSE; return FALSE;
} }