From: Don S. <ri...@us...> - 2004-09-13 18:17:32
|
Update of /cvsroot/phpwsbb/phpwsbb/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16688/class Modified Files: Forum.php Manager.php Message.php Thread.php Log Message: PHPWS_TBL_PREFIX is deprecated Index: Thread.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Thread.php,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** Thread.php 10 Sep 2004 02:01:33 -0000 1.52 --- Thread.php 13 Sep 2004 18:17:21 -0000 1.53 *************** *** 127,131 **** $this->setId($THREAD_ID); $this->init(); ! $sql = "SELECT id FROM " . PHPWS_TBL_PREFIX . "mod_phpwsbb_messages WHERE tid=" . $this->getId(); if (!$_SESSION["OBJ_user"]->allow_access("phpwsbb", "hide_threads")) $sql .= " AND hidden=0"; --- 127,131 ---- $this->setId($THREAD_ID); $this->init(); ! $sql = "SELECT id FROM " . $GLOBALS["core"]->tbl_prefix . "mod_phpwsbb_messages WHERE tid=" . $this->getId(); if (!$_SESSION["OBJ_user"]->allow_access("phpwsbb", "hide_threads")) $sql .= " AND hidden=0"; *************** *** 266,270 **** function updateThread($new = FALSE) { if (!empty($this->_id)) { ! $sql = "SELECT id FROM " . PHPWS_TBL_PREFIX . "mod_phpwsbb_messages WHERE tid=" . $this->getId() . " ORDER BY created;"; $this->messages = $GLOBALS["core"]->getCol($sql); $this->_replies = count($this->messages) - 1; --- 266,270 ---- function updateThread($new = FALSE) { if (!empty($this->_id)) { ! $sql = "SELECT id FROM " . $GLOBALS["core"]->tbl_prefix . "mod_phpwsbb_messages WHERE tid=" . $this->getId() . " ORDER BY created;"; $this->messages = $GLOBALS["core"]->getCol($sql); $this->_replies = count($this->messages) - 1; *************** *** 310,316 **** // Send email to monitors for new messages ! $user = $_SESSION['PHPWSBB_Manager']->_load_user_settings($_SESSION['OBJ_user']->user_id); if ($_SESSION["PHPWSBB_Manager"]->_allow_user_monitors && $new && !$user['suspendmonitors']) { ! $sql = "SELECT email FROM " . PHPWS_TBL_PREFIX . "mod_phpwsbb_monitors a," . $GLOBALS["core"]->tbl_prefix . "mod_users b WHERE a.thread_id=" . $this->getId() . " AND b.user_id=a.user_id and a.user_id != '" . $_SESSION["OBJ_user"]->user_id . "'"; $emails = $GLOBALS["core"]->getCol($sql); --- 310,321 ---- // Send email to monitors for new messages ! if (!isset($_SESSION["PHPWSBB_Manager"])) ! echo "<h3>phpwsbb manager not set!</h3>"; ! if (!isset($_SESSION["OBJ_user"])) ! echo "<h3>session user not set!</h3>"; ! ! $user = $_SESSION["PHPWSBB_Manager"]->_load_user_settings($_SESSION["OBJ_user"]->user_id); if ($_SESSION["PHPWSBB_Manager"]->_allow_user_monitors && $new && !$user['suspendmonitors']) { ! $sql = "SELECT email FROM " . $GLOBALS["core"]->tbl_prefix . "mod_phpwsbb_monitors a," . $GLOBALS["core"]->tbl_prefix . "mod_users b WHERE a.thread_id=" . $this->getId() . " AND b.user_id=a.user_id and a.user_id != '" . $_SESSION["OBJ_user"]->user_id . "'"; $emails = $GLOBALS["core"]->getCol($sql); Index: Message.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Message.php,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** Message.php 10 Sep 2004 02:01:33 -0000 1.59 --- Message.php 13 Sep 2004 18:17:21 -0000 1.60 *************** *** 145,149 **** require_once(PHPWS_SOURCE_DIR.'mod/phpwscontacts/class/Contact.php'); // Find contact owned by this username ! $sql = "select id from " . PHPWS_TBL_PREFIX . "mod_phpwscontacts_contacts where owner='" . $this->getOwner() . "' and mine=1"; $results = $GLOBALS["core"]->getCol($sql); if ($results) { --- 145,149 ---- require_once(PHPWS_SOURCE_DIR.'mod/phpwscontacts/class/Contact.php'); // Find contact owned by this username ! $sql = "select id from " . $GLOBALS["core"]->tbl_prefix . "mod_phpwscontacts_contacts where owner='" . $this->getOwner() . "' and mine=1"; $results = $GLOBALS["core"]->getCol($sql); if ($results) { Index: Forum.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Forum.php,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Forum.php 10 Sep 2004 02:01:33 -0000 1.24 --- Forum.php 13 Sep 2004 18:17:20 -0000 1.25 *************** *** 297,306 **** if(!empty($this->_id)) { /* Develop total replies and extended thread information */ ! $sql = 'SELECT COUNT(id),SUM(replies) FROM ' . PHPWS_TBL_PREFIX . 'mod_phpwsbb_threads WHERE fid=' . $this->getId() . ' ORDER BY lastpost DESC'; ! $t = $GLOBALS['core']->getRow($sql); $this->_threads = $t['COUNT(id)']; $this->_posts = $t['SUM(replies)']; ! $sql = "SELECT id FROM " . PHPWS_TBL_PREFIX . "mod_phpwsbb_threads WHERE fid=" . $this->getId() . " ORDER BY lastpost DESC"; $t = $GLOBALS["core"]->getOne($sql); $thread = new PHPWSBB_Thread($t); --- 297,306 ---- if(!empty($this->_id)) { /* Develop total replies and extended thread information */ ! $sql = 'SELECT COUNT(id),SUM(replies) FROM ' . $GLOBALS["core"]->tbl_prefix . 'mod_phpwsbb_threads WHERE fid=' . $this->getId() . ' ORDER BY lastpost DESC'; ! $t = $GLOBALS["core"]->getRow($sql); $this->_threads = $t['COUNT(id)']; $this->_posts = $t['SUM(replies)']; ! $sql = "SELECT id FROM " . $GLOBALS["core"]->tbl_prefix . "mod_phpwsbb_threads WHERE fid=" . $this->getId() . " ORDER BY lastpost DESC"; $t = $GLOBALS["core"]->getOne($sql); $thread = new PHPWSBB_Thread($t); *************** *** 332,336 **** $_SESSION["OBJ_fatcat"]->purge($this->getId(), "phpwsbb"); ! $sql = "SELECT id FROM " . PHPWS_TBL_PREFIX . "mod_phpwsbb_threads WHERE fid=" . $this->getId() . " ORDER BY created;"; $results = $GLOBALS["core"]->getCol($sql); foreach($results as $tid) { --- 332,336 ---- $_SESSION["OBJ_fatcat"]->purge($this->getId(), "phpwsbb"); ! $sql = "SELECT id FROM " . $GLOBALS["core"]->tbl_prefix . "mod_phpwsbb_threads WHERE fid=" . $this->getId() . " ORDER BY created;"; $results = $GLOBALS["core"]->getCol($sql); foreach($results as $tid) { Index: Manager.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Manager.php,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Manager.php 10 Sep 2004 02:01:33 -0000 1.39 --- Manager.php 13 Sep 2004 18:17:20 -0000 1.40 *************** *** 478,482 **** $GLOBALS["CNT_phpwsbb"]["content"] = $_SESSION["translate"]->it("Anonymous viewing of this bulletin board has been disabled. You must log-in to view this bulletin board."); } else { ! $sql = "SELECT tid, label FROM " . PHPWS_TBL_PREFIX . "mod_phpwsbb_messages $where"; $result = $GLOBALS["core"]->query($sql); --- 478,482 ---- $GLOBALS["CNT_phpwsbb"]["content"] = $_SESSION["translate"]->it("Anonymous viewing of this bulletin board has been disabled. You must log-in to view this bulletin board."); } else { ! $sql = "SELECT tid, label FROM " . $GLOBALS["core"]->tbl_prefix . "mod_phpwsbb_messages $where"; $result = $GLOBALS["core"]->query($sql); *************** *** 563,567 **** $GLOBALS["CNT_phpwsbb"]["content"] .= $this->_menu(); ! $sql = "SELECT id FROM " . PHPWS_TBL_PREFIX . "mod_phpwsbb_threads ORDER BY updated ASC"; $result = $GLOBALS["core"]->getCol($sql); if($result) { --- 563,567 ---- $GLOBALS["CNT_phpwsbb"]["content"] .= $this->_menu(); ! $sql = "SELECT id FROM " . $GLOBALS["core"]->tbl_prefix . "mod_phpwsbb_threads ORDER BY updated ASC"; $result = $GLOBALS["core"]->getCol($sql); if($result) { *************** *** 750,754 **** } ! if($GLOBALS['core']->sqlUpdate($data, 'mod_phpwsbb_user_info', 'user_id', $_SESSION['OBJ_user']->user_id)) { // This had to be moved to the user settings table. // Use of setUserVar creates too many SELECTs to retrieve the values --- 750,754 ---- } ! if($GLOBALS["core"]->sqlUpdate($data, 'mod_phpwsbb_user_info', 'user_id', $_SESSION['OBJ_user']->user_id)) { // This had to be moved to the user settings table. // Use of setUserVar creates too many SELECTs to retrieve the values *************** *** 1000,1008 **** else $data['rank_special'] = 0; ! $GLOBALS['core']->sqlUpdate($data, 'mod_phpwsbb_user_ranks', 'rank_id', $rank_id); } else { // Erase rank if title is empty ! $GLOBALS['core']->sqlDelete('mod_phpwsbb_user_ranks', 'rank_id', $rank_id); } } --- 1000,1008 ---- else $data['rank_special'] = 0; ! $GLOBALS["core"]->sqlUpdate($data, 'mod_phpwsbb_user_ranks', 'rank_id', $rank_id); } else { // Erase rank if title is empty ! $GLOBALS["core"]->sqlDelete('mod_phpwsbb_user_ranks', 'rank_id', $rank_id); } } *************** *** 1020,1024 **** else $data['rank_special'] = 0; ! $GLOBALS['core']->sqlInsert($data, 'mod_phpwsbb_user_ranks', 'rank_id'); } // Now, reload the rank data into this class --- 1020,1024 ---- else $data['rank_special'] = 0; ! $GLOBALS["core"]->sqlInsert($data, 'mod_phpwsbb_user_ranks', 'rank_id'); } // Now, reload the rank data into this class *************** *** 1275,1279 **** case "recalc_users": /* Resets all post count to 0 so they'll be recalculated on user_load */ ! $GLOBALS['core']->query('UPDATE mod_phpwsbb_user_info SET posts=0', true); $GLOBALS["CNT_phpwsbb"]["title"] = $_SESSION["translate"]->it('Bulletin Board Forums'); $GLOBALS["CNT_phpwsbb"]["content"] = $_SESSION["translate"]->it('All user post counts have been reset.'); --- 1275,1279 ---- case "recalc_users": /* Resets all post count to 0 so they'll be recalculated on user_load */ ! $GLOBALS["core"]->query('UPDATE mod_phpwsbb_user_info SET posts=0', true); $GLOBALS["CNT_phpwsbb"]["title"] = $_SESSION["translate"]->it('Bulletin Board Forums'); $GLOBALS["CNT_phpwsbb"]["content"] = $_SESSION["translate"]->it('All user post counts have been reset.'); *************** *** 1293,1301 **** function _load_user_ranks () { ! $results = $GLOBALS['core']->sqlSelect('mod_phpwsbb_user_ranks',NULL,NULL,'rank_min'); ! if($results) ! $this->_user_ranks = $results; ! else ! $this->_user_ranks = NULL; } --- 1293,1301 ---- function _load_user_ranks () { ! $results = $GLOBALS["core"]->sqlSelect('mod_phpwsbb_user_ranks',NULL,NULL,'rank_min'); ! if($results) ! $this->_user_ranks = $results; ! else ! $this->_user_ranks = NULL; } *************** *** 1310,1379 **** function _load_user_settings ($id) { ! // If this is not a member, mark them as a guest ! if(!$id) ! return array(); ! ! // If user data was passed in, use it ! elseif(is_array($id) && !empty($id['user_id'])) { ! $result = $id; ! } ! // Using 1 sql statement instead of loading user classes which would use more memory ! // and generate an additional query per user. ! elseif (!$result = $GLOBALS['core']->getRow('SELECT * FROM ' ! . PHPWS_TBL_PREFIX . 'mod_phpwsbb_user_info AS i LEFT JOIN ' . PHPWS_TBL_PREFIX ! . 'mod_users AS u ON ( u.user_id = i.user_id ) WHERE i.user_id ='.$id)) ! { ! // If no record was found, create one ! $result = array(); ! // Develop correct user post counts ! $posts = $GLOBALS['core']->getRow('SELECT COUNT(owner_id) FROM mod_phpwsbb_messages WHERE owner_id='.$id, 1); ! $result['posts'] = $posts['COUNT(owner_id)']; ! // If the user has uservars set for this module... ! $monitordefault = $_SESSION['OBJ_user']->getUserVar('monitordefault', NULL, 'phpwsbb'); ! if ($monitordefault!==NULL) { ! // transfer the values to the table ! $result['monitordefault'] = $monitordefault; ! $result['suspendmonitors'] = $_SESSION['OBJ_user']->getUserVar('suspendmonitors', NULL, 'phpwsbb'); ! } ! $GLOBALS['core']->sqlInsert($result,'mod_phpwsbb_user_info'); ! $result['location']=$result['avatar']=$result['signature']=$result['monitordefault']=$result['suspendmonitors']=null; ! } ! // If user's post count is set to 0, recalculate it. ! if($result['posts']==0) { ! // Develop correct user post counts ! $result['posts'] = $data['posts'] = $GLOBALS['core']->getOne('SELECT COUNT(owner_id) FROM mod_phpwsbb_messages WHERE owner_id='.$id, 1); ! $GLOBALS['core']->sqlUpdate($data, 'mod_phpwsbb_user_info', 'user_id', $id); ! } ! $result['POSTS'] = $_SESSION['translate']->it('Posts').': '.$result['posts']; ! $result['MONITORDEFAULT'] = $result['monitordefault']; ! $result['SUSPENDMONITORS'] = $result['suspendmonitors']; ! if (!empty($result['location'])) ! $result['FROM'] = $_SESSION['translate']->it('From').': '.PHPWS_Text::parseOutput($result['location']); ! $result['AVATAR'] = null; ! if (!empty($result['avatar_file']) && $this->_use_avatars) ! { ! // Gallery Avatar ! if (!empty($result['avatar_dir'])) ! $result['AVATAR'] = '<img src="images/phpwsbb/'.$result['avatar_dir'].$result['avatar_file'].'" alt="" title="" border="0" />'; ! // Offsite Avatar ! elseif ($this->_use_offsite_avatars && empty($result['avatar_dir'])) ! $result['AVATAR'] = '<img src="http://'.$result['avatar_file'].'" alt="" title="" border="0" />'; ! } ! if (!empty($result['signature']) && $this->_use_signatures) ! $result['SIGNATURE'] = PHPWS_Text::parseOutput($result['signature']); ! // Determine user's rank ! if($result['posts']&& $this->_user_ranks) { ! $isSpecialuser = $result['deity'] || stristr($result['varValue'], 'lock_threads'); ! foreach ($this->_user_ranks as $rank) ! if(($rank['rank_min']<=$result['posts']) ! && (($rank['rank_special'] && $isSpecialuser) ! || (!$rank['rank_special'] && !$isSpecialuser))) { ! $result['RANK'] = $rank['rank_title']; } } - return $result; - } } --- 1310,1375 ---- function _load_user_settings ($id) { ! // If this is not a member, mark them as a guest ! if(!$id) { ! return array(); ! } elseif(is_array($id) && !empty($id['user_id'])) { ! // If user data was passed in, use it ! $result = $id; ! } elseif (!$result = $GLOBALS["core"]->getRow('SELECT * FROM ' ! . $GLOBALS["core"]->tbl_prefix . 'mod_phpwsbb_user_info AS i LEFT JOIN ' . $GLOBALS["core"]->tbl_prefix ! . 'mod_users AS u ON ( u.user_id = i.user_id ) WHERE i.user_id ='.$id)) { ! // Using 1 sql statement instead of loading user classes which would use more memory ! // and generate an additional query per user. ! // If no record was found, create one ! $result = array(); ! // Develop correct user post counts ! $posts = $GLOBALS["core"]->getRow('SELECT COUNT(owner_id) FROM mod_phpwsbb_messages WHERE owner_id='.$id, 1); ! $result['posts'] = $posts['COUNT(owner_id)']; ! // If the user has uservars set for this module... ! $monitordefault = $_SESSION['OBJ_user']->getUserVar('monitordefault', NULL, 'phpwsbb'); ! if ($monitordefault!==NULL) { ! // transfer the values to the table ! $result['monitordefault'] = $monitordefault; ! $result['suspendmonitors'] = $_SESSION['OBJ_user']->getUserVar('suspendmonitors', NULL, 'phpwsbb'); ! } ! $GLOBALS["core"]->sqlInsert($result,'mod_phpwsbb_user_info'); ! $result['location']=$result['avatar']=$result['signature']=$result['monitordefault']=$result['suspendmonitors']=null; ! } ! // If user's post count is set to 0, recalculate it. ! if($result['posts']==0) { ! // Develop correct user post counts ! $result['posts'] = $data['posts'] = $GLOBALS["core"]->getOne('SELECT COUNT(owner_id) FROM mod_phpwsbb_messages WHERE owner_id='.$id, 1); ! $GLOBALS["core"]->sqlUpdate($data, 'mod_phpwsbb_user_info', 'user_id', $id); ! } ! $result['POSTS'] = $_SESSION['translate']->it('Posts').': '.$result['posts']; ! $result['MONITORDEFAULT'] = $result['monitordefault']; ! $result['SUSPENDMONITORS'] = $result['suspendmonitors']; ! if (!empty($result['location'])) ! $result['FROM'] = $_SESSION['translate']->it('From').': '.PHPWS_Text::parseOutput($result['location']); ! $result['AVATAR'] = null; ! if (!empty($result['avatar_file']) && $this->_use_avatars) { ! // Gallery Avatar ! if (!empty($result['avatar_dir'])) ! $result['AVATAR'] = '<img src="images/phpwsbb/'.$result['avatar_dir'].$result['avatar_file'].'" alt="" title="" border="0" />'; ! // Offsite Avatar ! elseif ($this->_use_offsite_avatars && empty($result['avatar_dir'])) ! $result['AVATAR'] = '<img src="http://'.$result['avatar_file'].'" alt="" title="" border="0" />'; ! } ! if (!empty($result['signature']) && $this->_use_signatures) ! $result['SIGNATURE'] = PHPWS_Text::parseOutput($result['signature']); ! // Determine user's rank ! if($result['posts']&& $this->_user_ranks) { ! $isSpecialuser = $result['deity'] || stristr($result['varValue'], 'lock_threads'); ! foreach ($this->_user_ranks as $rank) ! if(($rank['rank_min']<=$result['posts']) ! && (($rank['rank_special'] && $isSpecialuser) ! || (!$rank['rank_special'] && !$isSpecialuser))) { ! $result['RANK'] = $rank['rank_title']; ! } } + return $result; } } |