From: Eloi G. <ada...@us...> - 2006-02-24 06:50:51
|
Update of /cvsroot/phpwsbb/phpwsbb/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11607/class Modified Files: Manager.php Message.php Thread.php Log Message: Reduced the number of queries required to show a thread. On my test system this reduced the number of queries produced by a view of a 12-message topic by an unregistered user from 70 to 18. The same page request by a moderator reduced the querycount from 108 to 31. Index: Thread.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Thread.php,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** Thread.php 23 Feb 2006 06:16:37 -0000 1.81 --- Thread.php 24 Feb 2006 06:50:46 -0000 1.82 *************** *** 304,312 **** $content = ''; $bg = NULL; ! foreach($this->messages as $mid) { ! $message = new PHPWSBB_Message($mid, $this->isModerator); ! PHPWS_WizardBag::toggle($bg, ' class="bg_light"'); ! $content .= $message->_view($bg); ! } $tags['AUTHOR'] = $_SESSION['translate']->it('Author'); --- 304,318 ---- $content = ''; $bg = NULL; ! ! /* Retrieve all messages for this thread */ ! $sql = 'SELECT * FROM mod_phpwsbb_messages WHERE id IN ('.implode(',', $this->messages).') ORDER BY created'; ! if($result = $GLOBALS['core']->query($sql, 1)) { ! while($row=$result->fetchrow(DB_FETCHMODE_ASSOC)) { ! $message = new PHPWSBB_Message(null, $this->isModerator, $row); ! PHPWS_WizardBag::toggle($bg, ' class="bg_light"'); ! $content .= $message->_view($bg, $this->_replies); ! } ! } ! unset($result); $tags['AUTHOR'] = $_SESSION['translate']->it('Author'); Index: Message.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Message.php,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** Message.php 27 Jan 2006 04:18:16 -0000 1.85 --- Message.php 24 Feb 2006 06:50:46 -0000 1.86 *************** *** 93,97 **** * @param int $MESSAGE_ID optional */ ! function PHPWSBB_Message($MESSAGE_ID = NULL, $isModerator=FALSE) { /* These variable are excluded when calling commit() */ $exclude = array('isModerator'); --- 93,97 ---- * @param int $MESSAGE_ID optional */ ! function PHPWSBB_Message($MESSAGE_ID = NULL, $isModerator=FALSE, $message_data=null) { /* These variable are excluded when calling commit() */ $exclude = array('isModerator'); *************** *** 106,109 **** --- 106,113 ---- $this->init(); } + /* otherwise, populate this object if data exists */ + if (isset($message_data)) { + $this->init($message_data); + } $this->isModerator = $isModerator; *************** *** 114,118 **** * Builds display page for message */ ! function _view($bg) { $tags = array(); --- 118,127 ---- * Builds display page for message */ ! function _view($bg, $thread_messagecount=null) { ! // If thread_messagecount wasn't given, retrieve it now ! if($thread_messagecount == null) { ! $thread = new PHPWSBB_Thread($this->_tid); ! $thread_messagecount = $thread->_replies; ! } $tags = array(); *************** *** 142,153 **** } else { if ($_SESSION['OBJ_user']->username && $_SESSION['OBJ_user']->username!=$this->getOwner()) { ! if ($GLOBALS['core']->moduleExists('notes')) { ! $notesinfo = PHPWS_Boost::getVersionInfo('notes'); ! if (version_compare($notesinfo['version'], '1.6.0') >= 0) ! $tags['NOTE'] = '<a href="index.php?module=notes&NOTE_op=new_note&NOTE_toUser=' . $this->getOwner() . '"><img src="./images/phpwsbb/new_note.png" border="0" height="16" width="16" alt="' . $_SESSION['translate']->it('Send note to poster') . '" title="' . $_SESSION['translate']->it('Send note to poster') . '" /> ' . $_SESSION['translate']->it('Note to [var1]',$this->getOwner()) . '</a>'; } } ! if ($GLOBALS['core']->moduleExists('phpwscontacts')) { require_once(PHPWS_SOURCE_DIR.'mod/phpwscontacts/class/Contact.php'); // Find contact owned by this username --- 151,160 ---- } else { if ($_SESSION['OBJ_user']->username && $_SESSION['OBJ_user']->username!=$this->getOwner()) { ! if (in_array('notes', $_SESSION['PHPWSBB_Manager']->installed_modules)) { ! $tags['NOTE'] = '<a href="index.php?module=notes&NOTE_op=new_note&NOTE_toUser=' . $this->getOwner() . '"><img src="./images/phpwsbb/new_note.png" border="0" height="16" width="16" alt="' . $_SESSION['translate']->it('Send note to poster') . '" title="' . $_SESSION['translate']->it('Send note to poster') . '" /> ' . $_SESSION['translate']->it('Note to [var1]',$this->getOwner()) . '</a>'; } } ! if (in_array('phpwscontacts', $_SESSION['PHPWSBB_Manager']->installed_modules)) { require_once(PHPWS_SOURCE_DIR.'mod/phpwscontacts/class/Contact.php'); // Find contact owned by this username *************** *** 182,187 **** } ! $thread = new PHPWSBB_Thread($this->_tid); ! if (($_SESSION['OBJ_user']->allow_access('phpwsbb', 'fork_messages') && $this->isModerator) && ($thread->_replies > 0)) $tags['FORK'] = '<a href="./index.php?module=phpwsbb&PHPWSBB_MAN_OP=fork&PHPWS_MAN_ITEMS[]=' . $this->getId() . '"><img src="./images/phpwsbb/fork.png" border="0" height="16" width="16" alt="' . $_SESSION['translate']->it('Fork') . '" title="' . $_SESSION['translate']->it('Fork') . '" /> ' . $_SESSION['translate']->it('Fork') . '</a>'; --- 189,193 ---- } ! if (($_SESSION['OBJ_user']->allow_access('phpwsbb', 'fork_messages') && $this->isModerator) && ($thread_messagecount > 0)) $tags['FORK'] = '<a href="./index.php?module=phpwsbb&PHPWSBB_MAN_OP=fork&PHPWS_MAN_ITEMS[]=' . $this->getId() . '"><img src="./images/phpwsbb/fork.png" border="0" height="16" width="16" alt="' . $_SESSION['translate']->it('Fork') . '" title="' . $_SESSION['translate']->it('Fork') . '" /> ' . $_SESSION['translate']->it('Fork') . '</a>'; Index: Manager.php =================================================================== RCS file: /cvsroot/phpwsbb/phpwsbb/class/Manager.php,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** Manager.php 23 Feb 2006 06:16:36 -0000 1.66 --- Manager.php 24 Feb 2006 06:50:46 -0000 1.67 *************** *** 232,239 **** * Internal flag to determine when the user logs in as a member * ! * @var PHPWSBB_Message * @access public */ var $logged_in = NULL; function PHPWSBB_Manager() { --- 232,247 ---- * Internal flag to determine when the user logs in as a member * ! * @var boolean * @access public */ var $logged_in = NULL; + + /** + * List of all modules currently installed. For interoperability. + * + * @var array + * @access public + */ + var $installed_modules = NULL; function PHPWSBB_Manager() { *************** *** 270,273 **** --- 278,282 ---- else $this->logged_in = false; + $this->installed_modules = $GLOBALS['core']->listModules(1); }// END FUNC PHPWSBB_Manager *************** *** 563,567 **** $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); --- 572,576 ---- $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); |