From e34cd645418178b9d6a127c048a5d95d8e4cbde8 Mon Sep 17 00:00:00 2001 From: secretr Date: Tue, 26 Apr 2011 11:27:36 +0000 Subject: [PATCH] More work on ranking, minor forum bugfixes and improvements --- e107_handlers/e_ranks_class.php | 23 ++++++++++++++++------- e107_plugins/forum/forum_class.php | 17 +++++++++++------ e107_plugins/forum/forum_viewtopic.php | 9 +++++++-- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/e107_handlers/e_ranks_class.php b/e107_handlers/e_ranks_class.php index 4910be9f0..bc104a2c8 100644 --- a/e107_handlers/e_ranks_class.php +++ b/e107_handlers/e_ranks_class.php @@ -202,24 +202,32 @@ class e_ranks } $ret = array(); - $userData = e107::getSystemUser($userId)->getData(); //get_user_data($userId); + if(is_array($userId)) + { + $userData = $userId; + $userId = $userData['user_id']; + } + else + { + $userData = e107::getSystemUser($userId)->getData(); //get_user_data($userId); + } if($userData['user_admin']) { if($userData['user_perms'] == '0') { //Main Site Admin - $data['special'] = "".$this->_getName($this->ranks[
"; + $data['special'] = "".$this->_getName($this->ranks["; } else { //Site Admin - $data['special'] = "".$this->_getName($this->ranks[
"; + $data['special'] = "".$this->_getName($this->ranks["; } } elseif($moderator) { - $data['special'] = "".$this->_getName($this->ranks[
"; + $data['special'] = "".$this->_getName($this->ranks["; } $userData['user_daysregged'] = max(1, round((time() - $userData['user_join']) / 86400)); @@ -241,7 +249,7 @@ class e_ranks { if($level >= $this->ranks['data'][$i]['thresh'] && $level < $this->ranks['data'][($i+1)]['thresh']) { - $rank = $i; + $rank = $i + 1; break; } } @@ -249,14 +257,15 @@ class e_ranks if($rank !== false) { $data['name'] = $this->_getName($this->ranks['data'][$rank]); - $img_title = ($this->ranks['data'][$rank]['name'] ? "alt='{$data['name']}' title='{$data['name']}'" : ''); - $data['pic'] = "
"; + $img_title = ($this->ranks['data'][$rank]['name'] ? " alt='{$data['name']}' title='{$data['name']}'" : ' alt = ""'); + $data['pic'] = ""; } $this->userRanks[$userId] = $data; return $data; } + // TODO - custom ranking by array key - e.g. user_comments only private function _calcLevel(&$userData) { $forumCount = varset($userData['user_plugin_forum_posts'], 0) * 5; diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index 52ad76be5..a9924a42f 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -58,7 +58,7 @@ class e107forum */ } - function loadPermList() + private function loadPermList() { $e107 = e107::getInstance(); if($tmp = $e107->ecache->retrieve_sys('forum_perms')) @@ -67,13 +67,19 @@ class e107forum } else { - $this->getForumPermList(); + $this->_getForumPermList(); $tmp = $e107->arrayStorage->WriteArray($this->permList, false); $e107->ecache->set_sys('forum_perms', $tmp); } unset($tmp); } + public function getForumPermList($what = null) + { + if(null !== $what) return (isset($this->permList[$what]) ? $this->permList[$what] : null); + return $this->permList; + } + private function setDefaults() { $this->prefs->set('show_topics', '1'); @@ -89,7 +95,7 @@ class e107forum $this->prefs->set('highlightsticky', '1'); } - function getForumPermList() + private function _getForumPermList() { $e107 = e107::getInstance(); @@ -1003,14 +1009,13 @@ class e107forum function threadIncView($id) { - $e107 = e107::getInstance(); $id = (int)$id; - return $e107->sql->db_Update('forum_thread', 'thread_views=thread_views+1 WHERE thread_id='.$id); + return e107::getDb()->db_Update('forum_thread', 'thread_views=thread_views+1 WHERE thread_id='.$id); } function _forum_lp_update($lp_type, $lp_user, $lp_info, $lp_forum_id, $lp_forum_sub) { - global $sql; + $sql = e107::getDb(); $sql->db_Update('forum', "{$lp_type}={$lp_type}+1, forum_lastpost_user='{$lp_user}', forum_lastpost_info = '{$lp_info}' WHERE forum_id='".intval($lp_forum_id)."' "); if($lp_forum_sub) { diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index e25b8a2dd..d5b881462 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -86,7 +86,7 @@ $pm_installed = plugInstalled('pm'); //Only increment thread views if not being viewed by thread starter if (USER && (USERID != $thread->threadInfo['thread_user'] || $thread->threadInfo['thread_total_replies'] > 0) || !$thread->noInc) { - $forum->threadIncview($threadId); + $forum->threadIncview($thread->threadInfo['thread_id']); } define('e_PAGETITLE', $tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off').' / '.$e107->tp->toHTML($thread->threadInfo['forum_name'], true, 'no_hook, emotes_off').' / '.LAN_01); @@ -474,7 +474,12 @@ function rpg($user_join, $user_forums) class e107ForumThread { - var $message, $threadId, $forumId, $perPage, $noInc, $pages; + public $message; + public $threadId; + public $forumId; + public $perPage; + public $noInc; + public $pages; function init() {