diff --git a/e107_core/shortcodes/batch/comment_shortcodes.php b/e107_core/shortcodes/batch/comment_shortcodes.php index 311ba870a..6b9516d8a 100644 --- a/e107_core/shortcodes/batch/comment_shortcodes.php +++ b/e107_core/shortcodes/batch/comment_shortcodes.php @@ -101,13 +101,21 @@ class comment_shortcodes extends e_shortcode function sc_comment_avatar($parm) { - $height = e107::getPref("im_height"); - $width = e107::getPref("im_width"); + $tp = e107::getParser(); // - return $tp->parseTemplate("{USER_AVATAR=".$this->var['user_image']."}"); - exit; + $text = $tp->parseTemplate("{USER_AVATAR=".$this->var['user_image']."}"); + $text .= "
+
"; + $text .= "

".$this->sc_username()."

"; + // $text .= e107::getDate()-> // convert($this->var['user_lastvisit'],'short'); + $text .= $this->sc_joined()."
".$this->sc_comments()."
".$this->sc_rating().$this->sc_location; + + $text .= " +
+
"; + return $text; } diff --git a/e107_core/shortcodes/batch/user_shortcodes.php b/e107_core/shortcodes/batch/user_shortcodes.php index 45636bb04..64d0b3778 100644 --- a/e107_core/shortcodes/batch/user_shortcodes.php +++ b/e107_core/shortcodes/batch/user_shortcodes.php @@ -13,647 +13,721 @@ * */ if (!defined('e107_INIT')) { exit; } -include_once(e_HANDLER.'shortcode_handler.php'); -$user_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__); -/* -SC_BEGIN TOTAL_CHATPOSTS -global $sql; -if(!$chatposts = getcachedvars('total_chatposts')) + +class user_shortcodes extends e_shortcode { - $chatposts = 0; // In case plugin not installed - if (isset($pref['plug_installed']['chatbox_menu'])) - { - $chatposts = $sql->db_Count("chatbox"); - } - cachevars('total_chatposts', $chatposts); -} -return $chatposts; -SC_END - -SC_BEGIN TOTAL_COMMENTPOSTS -global $sql; -if(!$commentposts = getcachedvars('total_commentposts')) -{ - $commentposts = $sql->db_Count("comments"); - cachevars('total_commentposts', $commentposts); -} -return $commentposts; -SC_END - -SC_BEGIN TOTAL_FORUMPOSTS -global $sql; -if(!$forumposts = getcachedvars('total_forumposts')) -{ - $forumposts = $sql->db_Count("forum_t"); - cachevars('total_forumposts', $forumposts); -} -return $forumposts; -SC_END - -SC_BEGIN USER_COMMENTPOSTS -global $user; -return $user['user_comments']; -SC_END - -SC_BEGIN USER_FORUMPOSTS -global $user; -return $user['user_forums']; -SC_END - -SC_BEGIN USER_CHATPOSTS -global $user; -return $user['user_chats']; -SC_END - -SC_BEGIN USER_DOWNLOADS -global $sql,$user; -$downloads = $sql->db_Count("download_requests","(*)","where download_request_userid=".$user['user_id']); -return $downloads; -SC_END - -SC_BEGIN USER_CHATPER -global $sql, $user; -if(!$chatposts = getcachedvars('total_chatposts')) -{ - $chatposts = 0; // In case plugin not installed - if (isset($pref['plug_installed']['chatbox_menu'])) - { - $chatposts = $sql->db_Count("chatbox"); - } - cachevars('total_chatposts', $chatposts); -} -return ($chatposts!=0) ? round(($user['user_chats']/$chatposts) * 100, 2): 0; -SC_END - -SC_BEGIN USER_COMMENTPER -global $sql, $user; -if(!$commentposts = getcachedvars('total_commentposts')) -{ - $commentposts = $sql->db_Count("comments"); - cachevars('total_commentposts', $commentposts); -} -return ($commentposts!=0) ? round(($user['user_comments']/$commentposts) * 100, 2): 0; -SC_END - -SC_BEGIN USER_FORUMPER -global $sql, $user; -if(!$forumposts = getcachedvars('total_forumposts')) -{ - $forumposts = (isset($pref['plug_installed']['forum'])) ? $sql->db_Count("forum_t"): 0; - cachevars('total_forumposts', $forumposts); -} -return ($forumposts!==0) ? round(($user['user_forums']/$forumposts) * 100, 2): 0; -SC_END - -SC_BEGIN USER_LEVEL -global $user, $pref; -//FIXME - new level handler, currently commented to avoid parse errors -//require_once(e_HANDLER."level_handler.php"); -//$ldata = get_level($user['user_id'], $user['user_forums'], $user['user_comments'], $user['user_chats'], $user['user_visits'], $user['user_join'], $user['user_admin'], $user['user_perms'], $pref); -$ldata = array(); -if (strstr($ldata[0], "IMAGE_rank_main_admin_image")) -{ - return LAN_USER_31; -} -elseif(strstr($ldata[0], "IMAGE")) -{ - return LAN_USER_32; -} -else -{ - return $USER_LEVEL = $ldata[1]; -} -SC_END - -SC_BEGIN USER_LASTVISIT -global $user; -$gen = new convert; -return $user['user_currentvisit'] ? $gen->convert_date($user['user_currentvisit'], "long") : "".LAN_USER_33.""; -SC_END - -SC_BEGIN USER_LASTVISIT_LAPSE -global $user; -$gen = new convert; -return $user['user_currentvisit'] ? "( ".$gen -> computeLapse($user['user_currentvisit'])." ".LAN_USER_34." )" : ''; -SC_END - -SC_BEGIN USER_VISITS -global $user; -return $user['user_visits']; -SC_END - -SC_BEGIN USER_JOIN -global $user; -$gen = new convert; -return $gen->convert_date($user['user_join'], "forum"); -SC_END - -SC_BEGIN USER_DAYSREGGED -global $user; -$gen = new convert; -return $gen -> computeLapse($user['user_join'])." ".LAN_USER_34; -SC_END - -SC_BEGIN USER_REALNAME_ICON - -if(defined("USER_REALNAME_ICON")) -{ - return USER_REALNAME_ICON; -} -if(file_exists(THEME."images/user_realname.png")) -{ - return " "; -} -return " "; -SC_END - -SC_BEGIN USER_REALNAME -global $user; -return $user['user_login'] ? $user['user_login'] : "".LAN_USER_33.""; -SC_END - -SC_BEGIN USER_EMAIL_ICON - -if(defined("USER_EMAIL_ICON")) -{ - return USER_EMAIL_ICON; -} -if(file_exists(THEME."images/email.png")) -{ - return " "; -} -return " "; -SC_END - -SC_BEGIN USER_EMAIL_LINK -global $user, $tp; -return ($user['user_hideemail'] && !ADMIN) ? "".LAN_USER_35."" : $tp->parseTemplate("{email={$user['user_email']}-link}"); -SC_END - -SC_BEGIN USER_EMAIL -global $user,$tp; -return ($user['user_hideemail'] && !ADMIN) ? "".LAN_USER_35."" : $tp->toHTML($user['user_email'],"no_replace"); -SC_END - -SC_BEGIN USER_ICON -if(defined("USER_ICON")) -{ - return USER_ICON; -} -if(file_exists(THEME."images/user.png")) -{ - return " "; -} -return " "; -SC_END - -SC_BEGIN USER_ICON_LINK -global $user; -$uparams = array('id' => $user['user_id'], 'name' => $user['user_name']); -$url = e107::getUrl(); -if(defined("USER_ICON")) -{ - $icon = USER_ICON; -} -else if(file_exists(THEME."images/user.png")) -{ - $icon = " "; -} -else -{ - $icon = " "; -} -return "{$icon}"; -SC_END - -SC_BEGIN USER_ID -global $user; -return $user['user_id']; -SC_END - -SC_BEGIN USER_NAME -global $user; -return $user['user_name']; -SC_END - -SC_BEGIN USER_NAME_LINK -global $user; -$uparams = array('id' => $user['user_id'], 'name' => $user['user_name']); -$url = e107::getUrl(); -return "".$user['user_name'].""; -SC_END - -SC_BEGIN USER_LOGINNAME -global $user; -if(ADMIN && getperms("4")) { - return $user['user_loginname']; -} -SC_END - -SC_BEGIN USER_BIRTHDAY_ICON - -if(defined("USER_BIRTHDAY_ICON")) -{ - return USER_BIRTHDAY_ICON; -} -if(file_exists(THEME."images/user_birthday.png")) -{ - return " "; -} -return " "; -SC_END - -SC_BEGIN USER_BIRTHDAY -global $user; -if ($user['user_birthday'] != "" && $user['user_birthday'] != "0000-00-00" && preg_match("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/", $user['user_birthday'], $regs)) -{ - return "$regs[3].$regs[2].$regs[1]"; -} -else -{ - return "".LAN_USER_33.""; -} -SC_END - -SC_BEGIN USER_SIGNATURE -global $tp, $user; -return $user['user_signature'] ? $tp->toHTML($user['user_signature'], TRUE) : ""; -SC_END - -SC_BEGIN USER_COMMENTS_LINK -global $user; -return $user['user_comments'] ? "".LAN_USER_36."" : ""; -SC_END - -SC_BEGIN USER_FORUM_LINK -global $user; -return $user['user_forums'] ? "".LAN_USER_37."" : ""; -SC_END - -SC_BEGIN USER_SENDPM -global $pref, $tp, $user; -if(isset($pref['plug_installed']['pm']) && ($user['user_id'] > 0)) -{ - return $tp->parseTemplate("{SENDPM={$user['user_id']}}"); -} -SC_END - -SC_BEGIN USER_RATING -global $pref, $user; -if($pref['profile_rate'] && USER) -{ - include_once(e_HANDLER."rate_class.php"); - $rater = new rater; - $ret = ""; - if($rating = $rater->getrating('user', $user['user_id'])) - { - $num = $rating[1]; - for($i=1; $i<= $num; $i++) + + function sc_total_chatposts($parm) { + global $sql; + if(!$chatposts = getcachedvars('total_chatposts')) { - $ret .= ""; + $chatposts = 0; // In case plugin not installed + if (isset($pref['plug_installed']['chatbox_menu'])) + { + $chatposts = $sql->db_Count("chatbox"); + } + cachevars('total_chatposts', $chatposts); + } + return $chatposts; + } + + + + function sc_total_commentposts($parm) + { + global $sql; + if(!$commentposts = getcachedvars('total_commentposts')) + { + $commentposts = $sql->db_Count("comments"); + cachevars('total_commentposts', $commentposts); + } + return $commentposts; + } + + + + function sc_total_forumposts($parm) + { + global $sql; + if(!$forumposts = getcachedvars('total_forumposts')) + { + $forumposts = $sql->db_Count("forum_t"); + cachevars('total_forumposts', $forumposts); + } + return $forumposts; + } + + + + function sc_user_commentposts($parm) + { + return $this->var['user_comments']; + } + + + + function sc_user_forumposts($parm) + { + return $this->var['user_forums']; + } + + + + function sc_user_chatposts($parm) + { + return $this->var['user_chats']; + } + + function sc_user_downloads($parm) + { + return e107::getDb()->db_Count("download_requests","(*)","where download_request_userid=".$this->var['user_id']); + } + + function sc_user_chatper($parm) + { + $sql = e107::getDb(); + if(!$chatposts = getcachedvars('total_chatposts')) + { + $chatposts = 0; // In case plugin not installed + if (isset($pref['plug_installed']['chatbox_menu'])) + { + $chatposts = $sql->db_Count("chatbox"); + } + cachevars('total_chatposts', $chatposts); + } + return ($chatposts!=0) ? round(($this->var['user_chats']/$chatposts) * 100, 2): 0; + } + + + + function sc_user_commentper($parm) + { + $sql = e107::getDb(); + if(!$commentposts = getcachedvars('total_commentposts')) + { + $commentposts = $sql->db_Count("comments"); + cachevars('total_commentposts', $commentposts); + } + return ($commentposts!=0) ? round(($this->var['user_comments']/$commentposts) * 100, 2): 0; + } + + + + function sc_user_forumper($parm) + { + $sql = e107::getDb(); + if(!$forumposts = getcachedvars('total_forumposts')) + { + $forumposts = (isset($pref['plug_installed']['forum'])) ? $sql->db_Count("forum_t"): 0; + cachevars('total_forumposts', $forumposts); + } + return ($forumposts!==0) ? round(($this->var['user_forums']/$forumposts) * 100, 2): 0; + } + + + + function sc_user_level($parm) + { + $pref = e107::getPref(); + //FIXME - new level handler, currently commented to avoid parse errors + //require_once(e_HANDLER."level_handler.php"); + //$ldata = get_level($this->var['user_id'], $this->var['user_forums'], $this->var['user_comments'], $this->var['user_chats'], $this->var['user_visits'], $this->var['user_join'], $this->var['user_admin'], $this->var['user_perms'], $pref); + $ldata = array(); + if (strstr($ldata[0], "IMAGE_rank_main_admin_image")) + { + return LAN_USER_31; + } + elseif(strstr($ldata[0], "IMAGE")) + { + return LAN_USER_32; + } + else + { + return $USER_LEVEL = $ldata[1]; } } - if(!$rater->checkrated('user', $user['user_id'])) + + + + function sc_user_lastvisit($parm) { - $ret .= "    ".$rater->rateselect('', 'user', $user['user_id']); + $gen = new convert; + return $this->var['user_currentvisit'] ? $gen->convert_date($this->var['user_currentvisit'], "long") : "".LAN_USER_33.""; + } + + + + function sc_user_lastvisit_lapse($parm) + { + $gen = new convert; + return $this->var['user_currentvisit'] ? "( ".$gen -> computeLapse($this->var['user_currentvisit'])." ".LAN_USER_34." )" : ''; } - $ret .= ""; - return $ret; -} -return ""; -SC_END - -SC_BEGIN USER_UPDATE_LINK -global $user; -$url = e107::getUrl(); -if (USERID == $user['user_id']) -{ - //return "".LAN_USER_38.""; - return "".LAN_USER_38.""; // TODO: repair dirty fix for usersettings -} -else if(ADMIN && getperms("4") && !$user['user_admin']) -{ - return " $user['user_id'], 'name' => $user['user_name']))."'>".LAN_USER_39.""; -} -SC_END - -SC_BEGIN USER_JUMP_LINK -global $sql, $user, $full_perms; -if (!$full_perms) return; -$url = e107::getUrl(); -if(!$userjump = getcachedvars('userjump')) -{ -// $sql->db_Select("user", "user_id, user_name", "`user_id` > ".intval($user['user_id'])." AND `user_ban`=0 ORDER BY user_id ASC LIMIT 1 "); - $sql->db_Select_gen("SELECT user_id, user_name FROM `#user` FORCE INDEX (PRIMARY) WHERE `user_id` > ".intval($user['user_id'])." AND `user_ban`=0 ORDER BY user_id ASC LIMIT 1 "); - if ($row = $sql->db_Fetch()) - { - $userjump['next']['id'] = $row['user_id']; - $userjump['next']['name'] = $row['user_name']; - } -// $sql->db_Select("user", "user_id, user_name", "`user_id` < ".intval($user['user_id'])." AND `user_ban`=0 ORDER BY user_id DESC LIMIT 1 "); - $sql->db_Select_gen("SELECT user_id, user_name FROM `#user` FORCE INDEX (PRIMARY) WHERE `user_id` < ".intval($user['user_id'])." AND `user_ban`=0 ORDER BY user_id DESC LIMIT 1 "); - if ($row = $sql->db_Fetch()) - { - $userjump['prev']['id'] = $row['user_id']; - $userjump['prev']['name'] = $row['user_name']; - } - cachevars('userjump', $userjump); -} -if($parm == 'prev') -{ - return isset($userjump['prev']['id']) ? "<< ".LAN_USER_40." [ ".$userjump['prev']['name']." ]" : " "; -} -else -{ - return isset($userjump['next']['id']) ? "[ ".$userjump['next']['name']." ] ".LAN_USER_41." >>" : " "; -} -SC_END - -SC_BEGIN USER_PICTURE -global $user; -if ($user['user_sess'] && file_exists(e_UPLOAD."avatars/".$user['user_sess'])) -{ - return ""; -} -else -{ - return LAN_USER_42; -} -SC_END - -SC_BEGIN USER_AVATAR -global $user, $tp; -if ($user['user_image']) -{ - return $tp->parseTemplate("{USER_AVATAR=".$user['user_image']."}", true); -} -else -{ - return LAN_USER_42; -} -SC_END -SC_BEGIN USER_PICTURE_NAME -global $user; -if (ADMIN && getperms("4")) -{ - return $user['user_sess']; -} -SC_END - -SC_BEGIN USER_PICTURE_DELETE -if (USERID == $user['user_id'] || (ADMIN && getperms("4"))) -{ - return " -
- -
- "; -} -SC_END - -SC_BEGIN USER_EXTENDED_ALL - -global $user, $tp, $sql; -global $EXTENDED_CATEGORY_START, $EXTENDED_CATEGORY_END, $EXTENDED_CATEGORY_TABLE; -$qry = "SELECT f.*, c.user_extended_struct_name AS category_name, c.user_extended_struct_id AS category_id FROM #user_extended_struct as f - LEFT JOIN #user_extended_struct as c ON f.user_extended_struct_parent = c.user_extended_struct_id - ORDER BY c.user_extended_struct_order ASC, f.user_extended_struct_order ASC -"; + + function sc_user_visits($parm) + { + return $this->var['user_visits']; + } + + function sc_user_join($parm) + { + $gen = new convert; + return $gen->convert_date($this->var['user_join'], "forum"); + } + + + + function sc_user_daysregged($parm) + { + $gen = new convert; + return $gen -> computeLapse($this->var['user_join'])." ".LAN_USER_34; + } -require_once(e_HANDLER."user_extended_class.php"); + + + function sc_user_realname_icon($parm) + { + if(defined("USER_REALNAME_ICON")) + { + return USER_REALNAME_ICON; + } + if(file_exists(THEME."images/user_realname.png")) + { + return " "; + } + return " "; + } -$ue = new e107_user_extended; -$ueCatList = $ue->user_extended_get_categories(); -$ueFieldList = $ue->user_extended_get_fields(); -$ueCatList[0][0] = array('user_extended_struct_name' => LAN_USER_44, 'user_extended_struct_text' => ''); -$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.{$user['user_id']}}", TRUE); - if($cat_name != FALSE && count($ueFieldList[$catnum])) + + + function sc_user_realname($parm) + { + return $this->var['user_login'] ? $this->var['user_login'] : "".LAN_USER_33.""; + } + + + + function sc_user_email_icon($parm) + { + if(defined("USER_EMAIL_ICON")) + { + return USER_EMAIL_ICON; + } + if(file_exists(THEME."images/email.png")) + { + return " "; + } + return " "; + } + + + + function sc_user_email_link($parm) + { + global $user, $tp; + return ($this->var['user_hideemail'] && !ADMIN) ? "".LAN_USER_35."" : $tp->parseTemplate("{email={$this->var['user_email']}-link}"); + } + + + + function sc_user_email($parm) + { + $tp = e107::getParser(); + return ($this->var['user_hideemail'] && !ADMIN) ? "".LAN_USER_35."" : $tp->toHTML($this->var['user_email'],"no_replace"); + } + + + + function sc_user_icon($parm) + { + if(defined("USER_ICON")) + { + return USER_ICON; + } + if(file_exists(THEME."images/user.png")) + { + return " "; + } + return " "; + } + + + + function sc_user_icon_link($parm) { - $ret .= str_replace("{EXTENDED_NAME}", $key, $EXTENDED_CATEGORY_START); - foreach($ueFieldList[$catnum] as $f) + $uparams = array('id' => $this->var['user_id'], 'name' => $this->var['user_name']); + $url = e107::getUrl(); + if(defined("USER_ICON")) { - $key = $f['user_extended_struct_name']; - if($ue_name = $tp->parseTemplate("{USER_EXTENDED={$key}.text.{$user['user_id']}}", TRUE)) + $icon = USER_ICON; + } + else if(file_exists(THEME."images/user.png")) + { + $icon = " "; + } + else + { + $icon = " "; + } + return "{$icon}"; + } + + + + function sc_user_id($parm) + { + return $this->var['user_id']; + } + + + + function sc_user_name($parm) + { + return $this->var['user_name']; + } + + + + function sc_user_name_link($parm) + { + $uparams = array('id' => $this->var['user_id'], 'name' => $this->var['user_name']); + $url = e107::getUrl(); + return "".$this->var['user_name'].""; + } + + + + function sc_user_loginname($parm) + { + if(ADMIN && getperms("4")) { + return $this->var['user_loginname']; + } + } + + + + function sc_user_birthday_icon($parm) + { + if(defined("USER_BIRTHDAY_ICON")) + { + return USER_BIRTHDAY_ICON; + } + if(file_exists(THEME."images/user_birthday.png")) + { + return " "; + } + return " "; + } + + + + function sc_user_birthday($parm) + { + if ($this->var['user_birthday'] != "" && $this->var['user_birthday'] != "0000-00-00" && preg_match("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/", $this->var['user_birthday'], $regs)) + { + return "$regs[3].$regs[2].$regs[1]"; + } + else + { + return "".LAN_USER_33.""; + } + } + + + + function sc_user_signature($parm) + { + $tp = e107::getParser(); + return $this->var['user_signature'] ? $tp->toHTML($this->var['user_signature'], TRUE) : ""; + } + + + + function sc_user_comments_link($parm) + { + return $this->var['user_comments'] ? "".LAN_USER_36."" : ""; + } + + + + function sc_user_forum_link($parm) + { + global $user; + return $this->var['user_forums'] ? "".LAN_USER_37."" : ""; + } + + + + function sc_user_sendpm($parm) + { + global $pref, $tp, $user; + if(isset($pref['plug_installed']['pm']) && ($this->var['user_id'] > 0)) + { + return $tp->parseTemplate("{SENDPM={$this->var['user_id']}}"); + } + } + + + + function sc_user_rating($parm) + { + $pref = e107::getPref(); + if($pref['profile_rate'] && USER) + { + include_once(e_HANDLER."rate_class.php"); + $rater = new rater; + $ret = ""; + if($rating = $rater->getrating('user', $this->var['user_id'])) { - $extended_record = str_replace("EXTENDED_ICON","USER_EXTENDED={$key}.icon", $EXTENDED_CATEGORY_TABLE); - $extended_record = str_replace("{EXTENDED_NAME}", $tp->toHTML($ue_name,"","defs"), $extended_record); - $extended_record = str_replace("EXTENDED_VALUE","USER_EXTENDED={$key}.value.{$user['user_id']}", $extended_record); - if(HIDE_EMPTY_FIELDS === TRUE) + $num = $rating[1]; + for($i=1; $i<= $num; $i++) { - $this_value = $tp->parseTemplate("{USER_EXTENDED={$key}.value.{$user['user_id']}}", TRUE); - if($this_value != "") + $ret .= ""; + } + } + if(!$rater->checkrated('user', $this->var['user_id'])) + { + $ret .= "    ".$rater->rateselect('', 'user', $this->var['user_id']); + } + $ret .= ""; + return $ret; + } + return ""; + } + + + + function sc_user_update_link($parm) + { + $url = e107::getUrl(); + if (USERID == $this->var['user_id']) + { + //return "".LAN_USER_38.""; + return "".LAN_USER_38.""; // TODO: repair dirty fix for usersettings + } + else if(ADMIN && getperms("4") && !$this->var['user_admin']) + { + return " $this->var['user_id'], 'name' => $this->var['user_name']))."'>".LAN_USER_39.""; + } + } + + + + function sc_user_jump_link($parm) + { + global $full_perms; + $sql = e107::getDb(); + if (!$full_perms) return; + $url = e107::getUrl(); + if(!$userjump = getcachedvars('userjump')) + { + // $sql->db_Select("user", "user_id, user_name", "`user_id` > ".intval($this->var['user_id'])." AND `user_ban`=0 ORDER BY user_id ASC LIMIT 1 "); + $sql->db_Select_gen("SELECT user_id, user_name FROM `#user` FORCE INDEX (PRIMARY) WHERE `user_id` > ".intval($this->var['user_id'])." AND `user_ban`=0 ORDER BY user_id ASC LIMIT 1 "); + if ($row = $sql->db_Fetch()) + { + $userjump['next']['id'] = $row['user_id']; + $userjump['next']['name'] = $row['user_name']; + } + // $sql->db_Select("user", "user_id, user_name", "`user_id` < ".intval($this->var['user_id'])." AND `user_ban`=0 ORDER BY user_id DESC LIMIT 1 "); + $sql->db_Select_gen("SELECT user_id, user_name FROM `#user` FORCE INDEX (PRIMARY) WHERE `user_id` < ".intval($this->var['user_id'])." AND `user_ban`=0 ORDER BY user_id DESC LIMIT 1 "); + if ($row = $sql->db_Fetch()) + { + $userjump['prev']['id'] = $row['user_id']; + $userjump['prev']['name'] = $row['user_name']; + } + cachevars('userjump', $userjump); + } + if($parm == 'prev') + { + return isset($userjump['prev']['id']) ? "<< ".LAN_USER_40." [ ".$userjump['prev']['name']." ]" : " "; + } + else + { + return isset($userjump['next']['id']) ? "[ ".$userjump['next']['name']." ] ".LAN_USER_41." >>" : " "; + } + } + + + + function sc_user_picture($parm) + { + if ($this->var['user_sess'] && file_exists(e_MEDIA."avatars/".$this->var['user_sess'])) + { + //return $tp->parseTemplate("{USER_AVATAR=".$this->var['user_image']."}", true); + return ""; + } + else + { + return LAN_USER_42; + } + } + + /* sc_USER_AVATAR - see single/user_avatar.php */ + + + function sc_user_picture_name($parm) + { + if (ADMIN && getperms("4")) + { + return $this->var['user_sess']; + } + } + + + + function sc_user_picture_delete($parm) + { + if (USERID == $this->var['user_id'] || (ADMIN && getperms("4"))) + { + return " +
+ +
+ "; + } + } + + + + function sc_user_extended_all($parm) + { + $sql = e107::getDb(); + $tp = e107::getParser(); + + global $EXTENDED_CATEGORY_START, $EXTENDED_CATEGORY_END, $EXTENDED_CATEGORY_TABLE; + $qry = "SELECT f.*, c.user_extended_struct_name AS category_name, c.user_extended_struct_id AS category_id FROM #user_extended_struct as f + LEFT JOIN #user_extended_struct as c ON f.user_extended_struct_parent = c.user_extended_struct_id + 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; + $ueCatList = $ue->user_extended_get_categories(); + $ueFieldList = $ue->user_extended_get_fields(); + $ueCatList[0][0] = array('user_extended_struct_name' => LAN_USER_44, 'user_extended_struct_text' => ''); + $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); + if($cat_name != FALSE && count($ueFieldList[$catnum])) + { + + $ret .= str_replace("{EXTENDED_NAME}", $key, $EXTENDED_CATEGORY_START); + foreach($ueFieldList[$catnum] as $f) + { + $key = $f['user_extended_struct_name']; + if($ue_name = $tp->parseTemplate("{USER_EXTENDED={$key}.text.{$this->var['user_id']}}", TRUE)) { - $ret .= $tp->parseTemplate($extended_record, TRUE); + $extended_record = str_replace("EXTENDED_ICON","USER_EXTENDED={$key}.icon", $EXTENDED_CATEGORY_TABLE); + $extended_record = str_replace("{EXTENDED_NAME}", $tp->toHTML($ue_name,"","defs"), $extended_record); + $extended_record = str_replace("EXTENDED_VALUE","USER_EXTENDED={$key}.value.{$this->var['user_id']}", $extended_record); + if(HIDE_EMPTY_FIELDS === TRUE) + { + $this_value = $tp->parseTemplate("{USER_EXTENDED={$key}.value.{$this->var['user_id']}}", TRUE); + if($this_value != "") + { + $ret .= $tp->parseTemplate($extended_record, TRUE); + } + } + else + { + $ret .= $tp->parseTemplate($extended_record, TRUE); + } } } - else - { - $ret .= $tp->parseTemplate($extended_record, TRUE); + } + $ret .= $EXTENDED_CATEGORY_END; + } + return $ret; + } + + + + function sc_profile_comments($parm) + { + if(e107::getPref('profile_comments')) + { + $ret = e107::getComment()->compose_comment('profile', 'comment', $this->var['user_id'], null, $this->var['user_name'], FALSE,true); + + return e107::getRender()->tablerender($ret['caption'],$ret['comment_form']. $ret['comment'], 'profile_comments', TRUE); + } + return ""; + } + + + + function sc_profile_comment_form($parm) // deprecated. + { + return ; + + } + + + + function sc_total_users($parm) + { + global $users_total; + return $users_total; + } + + + + function sc_user_form_records($parm) + { + global $records, $user_frm; + $ret = $user_frm->form_select_open("records"); + for($i=10; $i<=30; $i+=10) + { + $sel = ($i == $records ? true: false); + $ret .= $user_frm->form_option($i, $sel, $i); + } + $ret .= $user_frm->form_select_close(); + return $ret; + } + + + function sc_user_form_order($parm) + { + global $order; + if ($order == "ASC") + { + $ret = ""; + } + else + { + $ret = ""; + } + return $ret; + } + + + function sc_user_form_start($parm) + { + global $from; + return " +
+

+ "; + } + + + + function sc_user_form_end($parm) + { + return "
"; + } + + + + function sc_user_form_submit($parm) + { + return ""; + } + + + + function sc_user_embed_userprofile($parm) + { + global $pref, $USER_EMBED_USERPROFILE_TEMPLATE, $embed_already_rendered; + + //if no parm, it means we render ALL embedded contents + //so we're preloading all registerd e_userprofile files + $key = varset($pref['e_userprofile_list']); + + //if we don't have any embedded contents, return + if(!is_array($key) || empty($key)){ return; } + + //array holding specific hooks to render + $render=array(); + + if($parm){ + + //if the first char of parm is an ! mark, it means it should not render the following parms + if(strpos($parm,'!')===0){ + $tmp = explode(",", substr($parm,1) ); + foreach($tmp as $not){ + $not=trim($not); + if(isset($key[$not])){ + //so we're unsetting them from the $key array + unset($key[$not]); + } + } + + //else it means we render only the following parms + }else{ + $tmp = explode(",", $parm ); + foreach($tmp as $yes){ + $yes=trim($yes); + if(isset($key[$yes])){ + //so add the ones we need to render to the $render array + $render[$yes] = $key[$yes]; + } + } + //finally assign the render array as the key array, overwriting it + $key = $render; + } + } + + foreach($key as $hook){ + //include the e_user file and initiate the class + if(is_readable(e_PLUGIN.$hook."/e_userprofile.php")){ + //if the current hook is not yet rendered + if(!in_array($hook, $embed_already_rendered)){ + require_once(e_PLUGIN.$hook."/e_userprofile.php"); + $name = "e_userprofile_{$hook}"; + if(function_exists($name)){ + $arr[] = $name(); + //we need to store which hooks are already rendered + $embed_already_rendered[] = $hook; + } } } } - } - $ret .= $EXTENDED_CATEGORY_END; -} -return $ret; -SC_END - -SC_BEGIN PROFILE_COMMENTS -global $user, $pref, $sql, $ns; -if($pref['profile_comments']) -{ - $ret = e107::getSingleton('comment')->compose_comment('profile', 'comment', $user['user_id'], null, $user['user_name'], FALSE,true); - - return $ns->tablerender($ret['caption'],$ret['comment_form']. $ret['comment'], 'profile_comments', TRUE); - - include_once(e_HANDLER."comment_class.php"); - $cobj = new comment; - $qry = " - SELECT c.*, u.*, ue.* FROM #comments AS c - LEFT JOIN #user AS u ON c.comment_author_id = u.user_id - LEFT JOIN #user_extended AS ue ON c.comment_author_id = ue.user_extended_id - WHERE c.comment_item_id=".intval($user['user_id'])." - AND c.comment_type='profile' - AND c.comment_pid='0' - ORDER BY c.comment_datestamp - "; - - if($comment_total = $sql->db_Select_gen($qry)) - { - while($row = $sql->db_Fetch()) - { - $ret .= $cobj->render_comment($row); + + $ret = ''; + foreach($arr as $data){ + if(is_array($data['caption'])){ + foreach($data['caption'] as $k=>$v){ + if(isset($data['caption'][$k]) && isset($data['text'][$k])){ + $search = array('{USER_EMBED_USERPROFILE_CAPTION}', '{USER_EMBED_USERPROFILE_TEXT}'); + $replace = array($data['caption'][$k], $data['text'][$k]); + $ret .= str_replace($search, $replace, $USER_EMBED_USERPROFILE_TEMPLATE); + } + } + }else{ + if(isset($data['caption']) && isset($data['text'])){ + $search = array('{USER_EMBED_USERPROFILE_CAPTION}', '{USER_EMBED_USERPROFILE_TEXT}'); + $replace = array($data['caption'], $data['text']); + $ret .= str_replace($search, $replace, $USER_EMBED_USERPROFILE_TEMPLATE); + } + } } + return $ret; } - return $ns->tablerender(COMLAN_5, $ret, 'profile_comments', TRUE); -} -return ""; -SC_END - -SC_BEGIN PROFILE_COMMENT_FORM -return ; - -global $pref, $user; -if($pref['profile_comments']) -{ - include_once(e_HANDLER."comment_class.php"); - $cobj = new comment; - $ret = ""; - if(ADMIN === TRUE) - { - $ret .= "".COMLAN_314."

"; - } - $ret .= $cobj->form_comment("comment", "profile", $user['user_id'], $user['user_name'], "", TRUE); - return $ret; -} -SC_END - -SC_BEGIN TOTAL_USERS -global $users_total; -return $users_total; -SC_END - -SC_BEGIN USER_FORM_RECORDS -global $records, $user_frm; -$ret = $user_frm->form_select_open("records"); -for($i=10; $i<=30; $i+=10) -{ - $sel = ($i == $records ? true: false); - $ret .= $user_frm->form_option($i, $sel, $i); -} -$ret .= $user_frm->form_select_close(); -return $ret; -SC_END - - -SC_BEGIN USER_FORM_ORDER -global $order; -if ($order == "ASC") -{ - $ret = ""; -} -else -{ - $ret = ""; -} -return $ret; -SC_END - - -SC_BEGIN USER_FORM_START -global $from; -return " -
-

-"; -SC_END - -SC_BEGIN USER_FORM_END -return "
"; -SC_END - -SC_BEGIN USER_FORM_SUBMIT -return ""; -SC_END - -SC_BEGIN USER_EMBED_USERPROFILE -global $pref, $USER_EMBED_USERPROFILE_TEMPLATE, $embed_already_rendered; - -//if no parm, it means we render ALL embedded contents -//so we're preloading all registerd e_userprofile files -$key = varset($pref['e_userprofile_list']); - -//if we don't have any embedded contents, return -if(!is_array($key) || empty($key)){ return; } - -//array holding specific hooks to render -$render=array(); - -if($parm){ - //if the first char of parm is an ! mark, it means it should not render the following parms - if(strpos($parm,'!')===0){ - $tmp = explode(",", substr($parm,1) ); - foreach($tmp as $not){ - $not=trim($not); - if(isset($key[$not])){ - //so we're unsetting them from the $key array - unset($key[$not]); - } - } - //else it means we render only the following parms - }else{ - $tmp = explode(",", $parm ); - foreach($tmp as $yes){ - $yes=trim($yes); - if(isset($key[$yes])){ - //so add the ones we need to render to the $render array - $render[$yes] = $key[$yes]; - } - } - //finally assign the render array as the key array, overwriting it - $key = $render; + + function sc_user_customtitle($parm) + { + return $this->var['user_customtitle']; } + + + } - -foreach($key as $hook){ - //include the e_user file and initiate the class - if(is_readable(e_PLUGIN.$hook."/e_userprofile.php")){ - //if the current hook is not yet rendered - if(!in_array($hook, $embed_already_rendered)){ - require_once(e_PLUGIN.$hook."/e_userprofile.php"); - $name = "e_userprofile_{$hook}"; - if(function_exists($name)){ - $arr[] = $name(); - //we need to store which hooks are already rendered - $embed_already_rendered[] = $hook; - } - } - } -} - -$ret = ''; -foreach($arr as $data){ - if(is_array($data['caption'])){ - foreach($data['caption'] as $k=>$v){ - if(isset($data['caption'][$k]) && isset($data['text'][$k])){ - $search = array('{USER_EMBED_USERPROFILE_CAPTION}', '{USER_EMBED_USERPROFILE_TEXT}'); - $replace = array($data['caption'][$k], $data['text'][$k]); - $ret .= str_replace($search, $replace, $USER_EMBED_USERPROFILE_TEMPLATE); - } - } - }else{ - if(isset($data['caption']) && isset($data['text'])){ - $search = array('{USER_EMBED_USERPROFILE_CAPTION}', '{USER_EMBED_USERPROFILE_TEXT}'); - $replace = array($data['caption'], $data['text']); - $ret .= str_replace($search, $replace, $USER_EMBED_USERPROFILE_TEMPLATE); - } - } -} -return $ret; -SC_END - -SC_BEGIN USER_CUSTOMTITLE -global $user; -return $user['user_customtitle']; -SC_END - -*/ ?> \ No newline at end of file diff --git a/e107_core/shortcodes/single/user_avatar.php b/e107_core/shortcodes/single/user_avatar.php index f2b13cfb0..873844857 100644 --- a/e107_core/shortcodes/single/user_avatar.php +++ b/e107_core/shortcodes/single/user_avatar.php @@ -44,7 +44,7 @@ function user_avatar_shortcode($parm='') { $img = (strpos($image,"://")!==false) ? $image : $tp->thumbUrl(e_MEDIA."avatars/".$image,"aw=".$width."&ah=".$height); $text = " -
User info here
"; + "; } else { diff --git a/e107_themes/templates/usersettings_template.php b/e107_themes/templates/usersettings_template.php index 756834568..efd99bfdd 100755 --- a/e107_themes/templates/usersettings_template.php +++ b/e107_themes/templates/usersettings_template.php @@ -75,7 +75,11 @@ $sc_style['LOGINNAME']['post'] = "\n"; $sc_style['SIGNATURE']['pre'] = "".LAN_USER_71.req($pref['signup_option_signature'])." "; -$sc_style['SIGNATURE_HELP']['pre'] = ""; +//$sc_style['SIGNATURE']['pre'] = " + // "; + +// $sc_style['SIGNATURE_HELP']['pre'] = ""; \ +$sc_style['SIGNATURE_HELP']['post'] = ""; $USER_EXTENDED_CAT = "{CATNAME}"; diff --git a/e107_web/css/e107.css b/e107_web/css/e107.css index fcd12f748..321961ee8 100644 --- a/e107_web/css/e107.css +++ b/e107_web/css/e107.css @@ -133,6 +133,8 @@ div.bbcode { margin: 15px 0px; clear: both; } /* layout control via bbcodes */ /* default comments layout */ + + .comment-box { padding-bottom:10px; margin-bottom:10px; border-top:1px solid #C0C0C0; } .comment-box-left { float:left; text-align:center; width:10%; min-width:100px } @@ -145,7 +147,7 @@ div.comment-avatar { margin-top:5px; padding:10px 10px 0px 10px; } img.user-avatar { max-width:128px; -webkit-box-shadow:#CCCCCC 0px 0px 10px; -moz-box-shadow:#CCCCCC 0px 0px 10px; box-shadow:#CCCCCC 0px 0px 10px; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; } -.comment-box-right { width:85%; min-height: 70px; float:left; } +.comment-box-right { width:auto; min-height: 70px; float:left; } .comment-box-arrow { width:11px; height:26px; float:left; position:relative; top:5px; left:-18px; } @@ -155,7 +157,9 @@ img.user-avatar { max-width:128px; -webkit-box-shadow:#CCCCCC 0px 0px 1 .comment-replyxxx { position:relative; bottom:0px; right:-10px; padding:2px 5px; font-size:0.85em; background-color:#EBFAFF; border:1px solid #C6F1FF; border-bottom:0px none; border-right:0px none; -webkit-border-top-left-radius: 5px; -moz-border-radius-topleft: 5px; border-top-left-radius: 5px; } -.comment-input { width:100% } +.comment-input { width:100%; } + +.comment-box-right textarea { border:1px solid red; width: 90%; resize: none; margin:0px auto;} .comment-status { float:right; font-style: italic } @@ -179,7 +183,9 @@ div.e-comment-edit-save { margin-top:8px; padding: 5px } .e-rate-up img { opacity: 0.4 } .e-rate-down img { opacity: 0.4 } - +#comments-container .comment-box:nth-child(even) { + background: red; +} .divider { border-bottom: 1px solid silver; font-size: 18px; margin-bottom: 30px; position: relative; text-align: center; } .divider span { background: #fff; padding: 0 15px; position: relative; top: 10px; } diff --git a/user.php b/user.php index 311767446..01d8798e5 100644 --- a/user.php +++ b/user.php @@ -21,7 +21,7 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE); global $user; $user['user_id'] = USERID; -require_once(e_CORE."shortcodes/batch/user_shortcodes.php"); +// require_once(e_CORE."shortcodes/batch/user_shortcodes.php"); require_once(e_HANDLER."form_handler.php"); if (isset($_POST['delp'])) @@ -45,6 +45,16 @@ if (isset($_POST['delp'])) $qs = explode(".", e_QUERY); $self_page =($qs[0] == 'id' && intval($qs[1]) == USERID); +include_once(e107::coreTemplatePath('user')); //correct way to load a core template. + +$user_shortcodes = e107::getScBatch('user'); + + + + + + +/* if (file_exists(THEME."user_template.php")) { require_once(THEME."user_template.php"); @@ -53,6 +63,8 @@ else { require_once(e_BASE.$THEMES_DIRECTORY."templates/user_template.php"); } + */ + $user_frm = new form; require_once(HEADERF); if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%"); } @@ -164,6 +176,7 @@ else foreach ($userList as $row) { $loop_uid = $row['user_id']; + $text .= renderuser($row, "short"); } $text .= $tp->parseTemplate($USER_SHORT_TEMPLATE_END, TRUE, $user_shortcodes); @@ -192,6 +205,8 @@ function renderuser($uid, $mode = "verbose") return FALSE; } } + + e107::getScBatch('user')->setVars($user); if($mode == 'verbose') { @@ -204,4 +219,4 @@ function renderuser($uid, $mode = "verbose") } require_once(FOOTERF); -?> +?> \ No newline at end of file diff --git a/usersettings.php b/usersettings.php index b5f460c53..c9a9a1cbd 100644 --- a/usersettings.php +++ b/usersettings.php @@ -57,10 +57,11 @@ $userMethods = e107::getUserSession(); require_once (e_HANDLER.'ren_help.php'); include_once (e107::coreTemplatePath('usersettings')); //correct way to load a core template. -include_once (e_CORE.'shortcodes/batch/usersettings_shortcodes.php'); +// include_once (e_CORE.'shortcodes/batch/usersettings_shortcodes.php'); $usersettings_shortcodes = e107::getScBatch('usersettings'); + e107::js('inline'," function addtext_us(sc) {