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

user_shortcodes code clean-up (no functional changes)

Formatting, indentation, empty lines
This commit is contained in:
Tijn Kuyper
2019-12-03 14:36:13 +01:00
parent 972fa1a29c
commit 1142738397

View File

@@ -32,9 +32,10 @@ class user_shortcodes extends e_shortcode
} }
function sc_total_chatposts($parm = null)
function sc_total_chatposts($parm) { {
$sql = e107::getDb(); $sql = e107::getDb();
if(!$chatposts = e107::getRegistry('total_chatposts')) if(!$chatposts = e107::getRegistry('total_chatposts'))
{ {
$chatposts = 0; // In case plugin not installed $chatposts = 0; // In case plugin not installed
@@ -44,38 +45,40 @@ class user_shortcodes extends e_shortcode
} }
e107::setRegistry('total_chatposts', $chatposts); e107::setRegistry('total_chatposts', $chatposts);
} }
return $chatposts; return $chatposts;
} }
function sc_total_commentposts($parm = null)
function sc_total_commentposts($parm)
{ {
$sql = e107::getDb(); $sql = e107::getDb();
if(!$commentposts = e107::getRegistry('total_commentposts')) if(!$commentposts = e107::getRegistry('total_commentposts'))
{ {
$commentposts = $sql->count("comments"); $commentposts = $sql->count("comments");
e107::setRegistry('total_commentposts', $commentposts); e107::setRegistry('total_commentposts', $commentposts);
} }
return $commentposts; return $commentposts;
} }
function sc_total_forumposts($parm = null)
function sc_total_forumposts($parm)
{ {
$sql = e107::getDb(); $sql = e107::getDb();
if(!$forumposts = e107::getRegistry('total_forumposts')) if(!$forumposts = e107::getRegistry('total_forumposts'))
{ {
$forumposts = $sql->count("forum_thread"); $forumposts = $sql->count("forum_thread");
e107::setRegistry('total_forumposts', $forumposts); e107::setRegistry('total_forumposts', $forumposts);
} }
return $forumposts; return $forumposts;
} }
function sc_user_commentposts($parm = null)
function sc_user_commentposts($parm)
{ {
if($this->commentsDisabled) if($this->commentsDisabled)
{ {
@@ -85,8 +88,7 @@ class user_shortcodes extends e_shortcode
} }
function sc_user_forumposts($parm = null)
function sc_user_forumposts($parm)
{ {
//return $this->var['user_forums']; //FIXME column not present in v2. Possible fix on next line. //return $this->var['user_forums']; //FIXME column not present in v2. Possible fix on next line.
//return e107::getDb()->count("forum_thread","(*)","where thread_user=".$this->var['user_id']); // Does not account for pruned posts? #716. Possible fix on next line. //return e107::getDb()->count("forum_thread","(*)","where thread_user=".$this->var['user_id']); // Does not account for pruned posts? #716. Possible fix on next line.
@@ -94,18 +96,19 @@ class user_shortcodes extends e_shortcode
} }
function sc_user_chatposts($parm = null)
function sc_user_chatposts($parm)
{ {
return $this->var['user_chats']; return $this->var['user_chats'];
} }
function sc_user_downloads($parm)
function sc_user_downloads($parm = null)
{ {
return e107::getDb()->count("download_requests","(*)","where download_request_userid=".$this->var['user_id']); return e107::getDb()->count("download_requests","(*)","where download_request_userid=".$this->var['user_id']);
} }
function sc_user_chatper($parm)
function sc_user_chatper($parm = null)
{ {
$sql = e107::getDb(); $sql = e107::getDb();
@@ -122,7 +125,6 @@ class user_shortcodes extends e_shortcode
} }
function sc_user_commentper($parm='') function sc_user_commentper($parm='')
{ {
if($this->commentsDisabled) if($this->commentsDisabled)
@@ -141,7 +143,6 @@ class user_shortcodes extends e_shortcode
} }
function sc_user_forumper($parm='') function sc_user_forumper($parm='')
{ {
$sql = e107::getDb(); $sql = e107::getDb();
@@ -155,10 +156,9 @@ class user_shortcodes extends e_shortcode
} }
return ($total_forumposts > 0) ? round(($user_forumposts/$total_forumposts) * 100, 2) : 0; return ($total_forumposts > 0) ? round(($user_forumposts/$total_forumposts) * 100, 2) : 0;
} }
function sc_user_level($parm) function sc_user_level($parm = null)
{ {
$pref = e107::getPref(); $pref = e107::getPref();
@@ -177,20 +177,17 @@ class user_shortcodes extends e_shortcode
} }
function sc_user_lastvisit($parm='') function sc_user_lastvisit($parm='')
{ {
return $this->var['user_currentvisit'] ? e107::getDate()->convert_date($this->var['user_currentvisit'], "long") : "<i>".LAN_USER_33."</i>"; return $this->var['user_currentvisit'] ? e107::getDate()->convert_date($this->var['user_currentvisit'], "long") : "<i>".LAN_USER_33."</i>";
} }
function sc_user_lastvisit_lapse($parm='') function sc_user_lastvisit_lapse($parm='')
{ {
return $this->var['user_currentvisit'] ? "( ".e107::getDate()->computeLapse($this->var['user_currentvisit'])." ".LAN_USER_34." )" : ''; return $this->var['user_currentvisit'] ? "( ".e107::getDate()->computeLapse($this->var['user_currentvisit'])." ".LAN_USER_34." )" : '';
} }
function sc_user_visits($parm='') function sc_user_visits($parm='')
{ {
@@ -198,20 +195,17 @@ class user_shortcodes extends e_shortcode
} }
function sc_user_join($parm='') function sc_user_join($parm='')
{ {
return e107::getDate()->convert_date($this->var['user_join'], "forum"); return e107::getDate()->convert_date($this->var['user_join'], "forum");
} }
function sc_user_daysregged($parm='') function sc_user_daysregged($parm='')
{ {
return e107::getDate()->computeLapse($this->var['user_join']); return e107::getDate()->computeLapse($this->var['user_join']);
} }
function sc_user_realname_icon($parm='') function sc_user_realname_icon($parm='')
{ {
@@ -226,7 +220,6 @@ class user_shortcodes extends e_shortcode
return "<img src='".e_IMAGE_ABS."user_icons/user_realname_".IMODE.".png' alt='' style='vertical-align:middle;' /> "; return "<img src='".e_IMAGE_ABS."user_icons/user_realname_".IMODE.".png' alt='' style='vertical-align:middle;' /> ";
} }
function sc_user_realname($parm='') function sc_user_realname($parm='')
@@ -234,7 +227,6 @@ class user_shortcodes extends e_shortcode
return $this->var['user_login'] ? $this->var['user_login'] : "<i>".LAN_USER_33."</i>"; return $this->var['user_login'] ? $this->var['user_login'] : "<i>".LAN_USER_33."</i>";
} }
function sc_user_email_icon($parm='') function sc_user_email_icon($parm='')
{ {
@@ -251,7 +243,6 @@ class user_shortcodes extends e_shortcode
} }
function sc_user_email_link($parm='') function sc_user_email_link($parm='')
{ {
$tp = e107::getParser(); $tp = e107::getParser();
@@ -260,32 +251,32 @@ class user_shortcodes extends e_shortcode
/* Not Hidden or Admin */ $tp->parseTemplate("{email={$this->var['user_email']}-link}"); /* Not Hidden or Admin */ $tp->parseTemplate("{email={$this->var['user_email']}-link}");
} }
function sc_user_email($parm='') function sc_user_email($parm='')
{
$tp = e107::getParser();
$aCurUserData = e107::user(USERID);
if( ($this->var['user_hideemail'] && !ADMIN ) && ( $this->var['user_email']!=$aCurUserData['user_email'] ) )
{ {
return "<i>".LAN_USER_35."</i>"; $tp = e107::getParser();
}
else $aCurUserData = e107::user(USERID);
{
if($this->var['user_email']!=$aCurUserData['user_email']){ if( ($this->var['user_hideemail'] && !ADMIN ) && ( $this->var['user_email']!=$aCurUserData['user_email'] ) )
return $tp->emailObfuscate($this->var['user_email']); {
//list($user,$dom) = explode('@', $this->var['user_email']); return "<i>".LAN_USER_35."</i>";
//return "<span class='e-email' data-user='".$user."' data-dom='".$dom."'>&#64;</span>"; }
}else{ else
return $this->var['user_email']; {
if($this->var['user_email']!=$aCurUserData['user_email'])
{
return $tp->emailObfuscate($this->var['user_email']);
//list($user,$dom) = explode('@', $this->var['user_email']);
//return "<span class='e-email' data-user='".$user."' data-dom='".$dom."'>&#64;</span>";
}
else
{
return $this->var['user_email'];
}
} }
} }
}
/** /**
* USER_ICON Shortcode * USER_ICON Shortcode
@@ -457,7 +448,6 @@ function sc_user_email($parm='')
} }
function sc_user_forum_link($parm) function sc_user_forum_link($parm)
{ {
$user_forumposts = e107::getDb()->count("forum_thread","(*)","where thread_user=".$this->var['user_id']); $user_forumposts = e107::getDb()->count("forum_thread","(*)","where thread_user=".$this->var['user_id']);
@@ -465,7 +455,6 @@ function sc_user_email($parm='')
} }
function sc_user_sendpm($parm) function sc_user_sendpm($parm)
{ {
$pref = e107::getPref(); $pref = e107::getPref();
@@ -477,49 +466,50 @@ function sc_user_email($parm='')
} }
function sc_user_rating($parm='') function sc_user_rating($parm='')
{ {
$pref = e107::getPref(); $pref = e107::getPref();
$frm = e107::getForm(); $frm = e107::getForm();
if(!vartrue($pref['profile_rate'])){ return; } if(!vartrue($pref['profile_rate'])){ return; }
if(!USER){ return LAN_USER_87; }
else{
switch ($parm) if(!USER)
{
return LAN_USER_87;
}
else
{ {
case 'like': switch ($parm)
return $frm->like('user',$this->var['user_id']); {
break; case 'like':
return $frm->like('user',$this->var['user_id']);
case 'legacy': break;
$rater = e107::getRate(); case 'legacy':
$ret = "<span>"; $rater = e107::getRate();
if($rating = $rater->getrating('user', $this->var['user_id'])) $ret = "<span>";
{ if($rating = $rater->getrating('user', $this->var['user_id']))
$num = $rating[1];
for($i=1; $i<= $num; $i++)
{ {
$ret .= "<img src='".e_IMAGE_ABS."rate/star.png' alt='' />"; $num = $rating[1];
for($i=1; $i<= $num; $i++)
{
$ret .= "<img src='".e_IMAGE_ABS."rate/star.png' alt='' />";
}
} }
} if(!$rater->checkrated('user', $this->var['user_id']))
if(!$rater->checkrated('user', $this->var['user_id'])) {
{ $ret .= " &nbsp; &nbsp;".$rater->rateselect('', 'user', $this->var['user_id']);
$ret .= " &nbsp; &nbsp;".$rater->rateselect('', 'user', $this->var['user_id']); }
} $ret .= "</span>";
$ret .= "</span>"; return $ret;
return $ret; break;
break; default:
return $frm->rate('user',$this->var['user_id']);
default: break;
return $frm->rate('user',$this->var['user_id']); }
break;
}
return "";
}}
return "";
}
}
function sc_user_update_link($parm) function sc_user_update_link($parm)
@@ -541,12 +531,11 @@ function sc_user_email($parm='')
} }
return "<a class='btn btn-default' href='".$this->sc_user_settings_url()."'>".$label."</a>"; return "<a class='btn btn-default' href='".$this->sc_user_settings_url()."'>".$label."</a>";
} }
function sc_user_settings_url($parm=null) function sc_user_settings_url($parm=null)
{ {
if (USERID == $this->var['user_id']) if (USERID == $this->var['user_id'])
{ {
return e107::getUrl()->create('user/myprofile/edit'); return e107::getUrl()->create('user/myprofile/edit');
@@ -555,11 +544,9 @@ function sc_user_email($parm='')
{ {
return e_ADMIN_ABS."users.php?mode=main&action=edit&id=".$this->var['user_id']; return e_ADMIN_ABS."users.php?mode=main&action=edit&id=".$this->var['user_id'];
} }
} }
/** /**
* @example {USER_JUMP_LINK=prev|class=btn-secondary} * @example {USER_JUMP_LINK=prev|class=btn-secondary}
*/ */
@@ -594,7 +581,6 @@ function sc_user_email($parm='')
} }
$class = empty($parms[2]['class']) ? 'e-tip' : $parms[2]['class']; $class = empty($parms[2]['class']) ? 'e-tip' : $parms[2]['class'];
if($parms[1] == 'prev') if($parms[1] == 'prev')
{ {
@@ -626,7 +612,7 @@ function sc_user_email($parm='')
{ {
return e107::getParser()->toAvatar($this->var, $parm); return e107::getParser()->toAvatar($this->var, $parm);
/* /*
return $tp->parseTemplate("{USER_AVATAR=".$this->var['user_sess']."}",true); return $tp->parseTemplate("{USER_AVATAR=".$this->var['user_sess']."}",true);
@@ -653,7 +639,6 @@ function sc_user_email($parm='')
} }
function sc_user_picture_delete($parm) function sc_user_picture_delete($parm)
{ {
if (USERID == $this->var['user_id'] || (ADMIN && getperms("4"))) if (USERID == $this->var['user_id'] || (ADMIN && getperms("4")))
@@ -671,10 +656,9 @@ function sc_user_email($parm='')
* Usage {USER_EUF: field=xxxx} (excluding the 'user_' ) * Usage {USER_EUF: field=xxxx} (excluding the 'user_' )
* @param string $parm * @param string $parm
* @return string * @return string
*/ */
function sc_user_euf($parm=null) function sc_user_euf($parm=null)
{ {
if(!empty($parm['field'])) if(!empty($parm['field']))
{ {
@@ -696,11 +680,9 @@ function sc_user_email($parm='')
} }
return false; return false;
} }
function sc_user_extended_all($parm) function sc_user_extended_all($parm)
{ {
$sql = e107::getDb(); $sql = e107::getDb();
@@ -719,9 +701,7 @@ function sc_user_email($parm='')
ORDER BY c.user_extended_struct_order ASC, f.user_extended_struct_order ASC ORDER BY c.user_extended_struct_order ASC, f.user_extended_struct_order ASC
"; ";
require_once(e_HANDLER."user_extended_class.php"); require_once(e_HANDLER."user_extended_class.php");
$ue = new e107_user_extended; $ue = new e107_user_extended;
@@ -737,9 +717,6 @@ function sc_user_email($parm='')
$ret = ""; $ret = "";
foreach($ueCatList as $catnum => $cat) foreach($ueCatList as $catnum => $cat)
{ {
$key = $cat[0]['user_extended_struct_text'] ? $cat[0]['user_extended_struct_text'] : $cat[0]['user_extended_struct_name']; $key = $cat[0]['user_extended_struct_text'] ? $cat[0]['user_extended_struct_text'] : $cat[0]['user_extended_struct_name'];
$cat_name = $tp->parseTemplate("{USER_EXTENDED={$key}.text.{$this->var['user_id']}}", TRUE); //XXX FIXME Fails $cat_name = $tp->parseTemplate("{USER_EXTENDED={$key}.text.{$this->var['user_id']}}", TRUE); //XXX FIXME Fails
@@ -785,7 +762,6 @@ function sc_user_email($parm='')
} }
function sc_profile_comments($parm) function sc_profile_comments($parm)
{ {
if(!e107::getPref('profile_comments')) if(!e107::getPref('profile_comments'))
@@ -795,15 +771,13 @@ function sc_user_email($parm='')
return e107::getComment()->compose_comment('profile', 'comment', $this->var['user_id'], null, $this->var['user_name'], false,'html'); return e107::getComment()->compose_comment('profile', 'comment', $this->var['user_id'], null, $this->var['user_name'], false,'html');
// return e107::getRender()->tablerender($ret['caption'],$ret['comment_form']. $ret['comment'], 'profile_comments', TRUE); // return e107::getRender()->tablerender($ret['caption'],$ret['comment_form']. $ret['comment'], 'profile_comments', TRUE);
} }
function sc_profile_comment_form($parm='') // deprecated. function sc_profile_comment_form($parm='') // deprecated.
{ {
return ; return;
} }
@@ -815,19 +789,19 @@ function sc_user_email($parm='')
} }
function sc_user_form_records($parm='') function sc_user_form_records($parm='')
{ {
global $records; global $records;
$opts = array(5,10,20,30,50); $opts = array(5,10,20,30,50);
return e107::getForm()->select('records', $opts, $records,'useValues=1'); return e107::getForm()->select('records', $opts, $records,'useValues=1');
} }
function sc_user_form_order($parm) function sc_user_form_order($parm)
{ {
global $order; global $order;
if ($order == "ASC") if ($order == "ASC")
{ {
$ret = "<select name='order' class='form-control tbox'> $ret = "<select name='order' class='form-control tbox'>
@@ -849,6 +823,7 @@ function sc_user_email($parm='')
function sc_user_form_start($parm) function sc_user_form_start($parm)
{ {
global $from; global $from;
return " return "
<form method='post' action='".e_SELF."'> <form method='post' action='".e_SELF."'>
<p><input type='hidden' name='from' value='$from' /></p> <p><input type='hidden' name='from' value='$from' /></p>
@@ -863,7 +838,6 @@ function sc_user_email($parm='')
} }
function sc_user_form_submit($parm) function sc_user_form_submit($parm)
{ {
return "<input class='btn btn-default btn-secondary button' type='submit' name='submit' value='".LAN_GO."' />"; return "<input class='btn btn-default btn-secondary button' type='submit' name='submit' value='".LAN_GO."' />";
@@ -900,18 +874,14 @@ function sc_user_email($parm='')
} }
return $text; return $text;
} }
/** /**
* @Deprecated Use {USER_ADDONS} instead. * @Deprecated Use {USER_ADDONS} instead.
*/ */
function sc_user_embed_userprofile($parm='') function sc_user_embed_userprofile($parm='')
{ {
return $this->sc_user_addons($parm); return $this->sc_user_addons($parm);
//if no parm, it means we render ALL embedded contents //if no parm, it means we render ALL embedded contents
//so we're preloading all registerd e_userprofile files //so we're preloading all registerd e_userprofile files
@@ -989,12 +959,9 @@ function sc_user_email($parm='')
} }
function sc_user_customtitle($parm) function sc_user_customtitle($parm)
{ {
return $this->var['user_customtitle']; return $this->var['user_customtitle'];
} }
} }