From: Eloi G. <ada...@us...> - 2004-09-15 18:53:07
|
Update of /cvsroot/phpwsbb/phpwsbb/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9824/class Modified Files: Manager.php Log Message: Minor code formatting changes Index: Manager.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Manager.php,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** Manager.php 14 Sep 2004 04:10:42 -0000 1.43 --- Manager.php 15 Sep 2004 18:52:58 -0000 1.44 *************** *** 1312,1383 **** // 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 memoryand 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; ! } } --- 1312,1378 ---- // 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; ! } 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)) { ! // 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; ! } } |