From 1142738397df4aec759571be140292dc3b2d14cb Mon Sep 17 00:00:00 2001 From: Tijn Kuyper Date: Tue, 3 Dec 2019 14:36:13 +0100 Subject: [PATCH] user_shortcodes code clean-up (no functional changes) Formatting, indentation, empty lines --- .../shortcodes/batch/user_shortcodes.php | 203 ++++++++---------- 1 file changed, 85 insertions(+), 118 deletions(-) diff --git a/e107_core/shortcodes/batch/user_shortcodes.php b/e107_core/shortcodes/batch/user_shortcodes.php index 06c11289c..bb6faea89 100644 --- a/e107_core/shortcodes/batch/user_shortcodes.php +++ b/e107_core/shortcodes/batch/user_shortcodes.php @@ -32,9 +32,10 @@ class user_shortcodes extends e_shortcode } - - function sc_total_chatposts($parm) { + function sc_total_chatposts($parm = null) + { $sql = e107::getDb(); + if(!$chatposts = e107::getRegistry('total_chatposts')) { $chatposts = 0; // In case plugin not installed @@ -44,38 +45,40 @@ class user_shortcodes extends e_shortcode } e107::setRegistry('total_chatposts', $chatposts); } + return $chatposts; } + - - - function sc_total_commentposts($parm) + function sc_total_commentposts($parm = null) { $sql = e107::getDb(); + if(!$commentposts = e107::getRegistry('total_commentposts')) { $commentposts = $sql->count("comments"); e107::setRegistry('total_commentposts', $commentposts); } + return $commentposts; } - - function sc_total_forumposts($parm) + function sc_total_forumposts($parm = null) { $sql = e107::getDb(); + if(!$forumposts = e107::getRegistry('total_forumposts')) { $forumposts = $sql->count("forum_thread"); e107::setRegistry('total_forumposts', $forumposts); } + return $forumposts; } + - - - function sc_user_commentposts($parm) + function sc_user_commentposts($parm = null) { if($this->commentsDisabled) { @@ -85,8 +88,7 @@ class user_shortcodes extends e_shortcode } - - function sc_user_forumposts($parm) + function sc_user_forumposts($parm = null) { //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. @@ -94,18 +96,19 @@ class user_shortcodes extends e_shortcode } - - function sc_user_chatposts($parm) + function sc_user_chatposts($parm = null) { 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']); } - function sc_user_chatper($parm) + + function sc_user_chatper($parm = null) { $sql = e107::getDb(); @@ -122,7 +125,6 @@ class user_shortcodes extends e_shortcode } - function sc_user_commentper($parm='') { if($this->commentsDisabled) @@ -141,7 +143,6 @@ class user_shortcodes extends e_shortcode } - function sc_user_forumper($parm='') { $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; } - - function sc_user_level($parm) + function sc_user_level($parm = null) { $pref = e107::getPref(); @@ -177,20 +177,17 @@ class user_shortcodes extends e_shortcode } - function sc_user_lastvisit($parm='') { return $this->var['user_currentvisit'] ? e107::getDate()->convert_date($this->var['user_currentvisit'], "long") : "".LAN_USER_33.""; } - function sc_user_lastvisit_lapse($parm='') { return $this->var['user_currentvisit'] ? "( ".e107::getDate()->computeLapse($this->var['user_currentvisit'])." ".LAN_USER_34." )" : ''; } - function sc_user_visits($parm='') { @@ -198,20 +195,17 @@ class user_shortcodes extends e_shortcode } - function sc_user_join($parm='') { return e107::getDate()->convert_date($this->var['user_join'], "forum"); } - function sc_user_daysregged($parm='') { return e107::getDate()->computeLapse($this->var['user_join']); } - function sc_user_realname_icon($parm='') { @@ -226,7 +220,6 @@ class user_shortcodes extends e_shortcode return " "; } - function sc_user_realname($parm='') @@ -234,7 +227,6 @@ class user_shortcodes extends e_shortcode return $this->var['user_login'] ? $this->var['user_login'] : "".LAN_USER_33.""; } - function sc_user_email_icon($parm='') { @@ -251,7 +243,6 @@ class user_shortcodes extends e_shortcode } - function sc_user_email_link($parm='') { $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}"); } - -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'] ) ) + function sc_user_email($parm='') { - return "".LAN_USER_35.""; - } - else - { - if($this->var['user_email']!=$aCurUserData['user_email']){ - return $tp->emailObfuscate($this->var['user_email']); - //list($user,$dom) = explode('@', $this->var['user_email']); - //return "@"; - }else{ - return $this->var['user_email']; + $tp = e107::getParser(); + + $aCurUserData = e107::user(USERID); + + if( ($this->var['user_hideemail'] && !ADMIN ) && ( $this->var['user_email']!=$aCurUserData['user_email'] ) ) + { + return "".LAN_USER_35.""; + } + else + { + if($this->var['user_email']!=$aCurUserData['user_email']) + { + return $tp->emailObfuscate($this->var['user_email']); + //list($user,$dom) = explode('@', $this->var['user_email']); + //return "@"; + } + else + { + return $this->var['user_email']; + } } } -} - /** * USER_ICON Shortcode @@ -457,7 +448,6 @@ function sc_user_email($parm='') } - function sc_user_forum_link($parm) { $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) { $pref = e107::getPref(); @@ -477,49 +466,50 @@ function sc_user_email($parm='') } - function sc_user_rating($parm='') { $pref = e107::getPref(); $frm = e107::getForm(); if(!vartrue($pref['profile_rate'])){ return; } - if(!USER){ return LAN_USER_87; } - else{ - switch ($parm) + if(!USER) + { + return LAN_USER_87; + } + else { - case 'like': - return $frm->like('user',$this->var['user_id']); - break; - - case 'legacy': - $rater = e107::getRate(); - $ret = ""; - if($rating = $rater->getrating('user', $this->var['user_id'])) - { - $num = $rating[1]; - for($i=1; $i<= $num; $i++) + switch ($parm) + { + case 'like': + return $frm->like('user',$this->var['user_id']); + break; + case 'legacy': + $rater = e107::getRate(); + $ret = ""; + if($rating = $rater->getrating('user', $this->var['user_id'])) { - $ret .= ""; + $num = $rating[1]; + for($i=1; $i<= $num; $i++) + { + $ret .= ""; + } } - } - if(!$rater->checkrated('user', $this->var['user_id'])) - { - $ret .= "    ".$rater->rateselect('', 'user', $this->var['user_id']); - } - $ret .= ""; - return $ret; - break; - - default: - return $frm->rate('user',$this->var['user_id']); - break; - } - - return ""; - }} + if(!$rater->checkrated('user', $this->var['user_id'])) + { + $ret .= "    ".$rater->rateselect('', 'user', $this->var['user_id']); + } + $ret .= ""; + return $ret; + break; + default: + return $frm->rate('user',$this->var['user_id']); + break; + } + return ""; + } + } function sc_user_update_link($parm) @@ -541,12 +531,11 @@ function sc_user_email($parm='') } return "".$label.""; - } + function sc_user_settings_url($parm=null) { - if (USERID == $this->var['user_id']) { 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']; } - } - /** * @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']; - if($parms[1] == 'prev') { @@ -626,7 +612,7 @@ function sc_user_email($parm='') { return e107::getParser()->toAvatar($this->var, $parm); -/* + /* 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) { 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_' ) * @param string $parm * @return string - */ + */ function sc_user_euf($parm=null) { - if(!empty($parm['field'])) { @@ -696,11 +680,9 @@ function sc_user_email($parm='') } return false; - } - function sc_user_extended_all($parm) { $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 "; - - - + require_once(e_HANDLER."user_extended_class.php"); $ue = new e107_user_extended; @@ -737,9 +717,6 @@ function sc_user_email($parm='') $ret = ""; foreach($ueCatList as $catnum => $cat) { - - - $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 @@ -785,7 +762,6 @@ function sc_user_email($parm='') } - function sc_profile_comments($parm) { 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::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. { - return ; + return; } @@ -815,19 +789,19 @@ function sc_user_email($parm='') } - function sc_user_form_records($parm='') { global $records; + $opts = array(5,10,20,30,50); return e107::getForm()->select('records', $opts, $records,'useValues=1'); - } - + function sc_user_form_order($parm) { global $order; + if ($order == "ASC") { $ret = "

@@ -863,7 +838,6 @@ function sc_user_email($parm='') } - function sc_user_form_submit($parm) { return ""; @@ -900,18 +874,14 @@ function sc_user_email($parm='') } return $text; - } - - /** * @Deprecated Use {USER_ADDONS} instead. */ function sc_user_embed_userprofile($parm='') { - return $this->sc_user_addons($parm); //if no parm, it means we render ALL embedded contents //so we're preloading all registerd e_userprofile files @@ -989,12 +959,9 @@ function sc_user_email($parm='') } - function sc_user_customtitle($parm) { return $this->var['user_customtitle']; } - - -} +} \ No newline at end of file