protected function savePost() { if (!$this->check()) { return false; } // Update rest of the information $this->setOption('allowed', null); // Fill user related information if ($this->getOption('anonymous')) { // Anonymous post: Just in case remove userid, email and IP address - name is already anonymous $this->set('ip', ''); $this->set('userid', 0); $this->set('email', ''); } else { // Regular post: Fill missing fields if (!$this->get('ip')) { $this->set('ip', $_SERVER["REMOTE_ADDR"]); } if (!$this->get('userid')) { $this->set('userid', $this->_my->id); } if (!$this->get('name')) { $this->set('name', $this->_myuser->getName()); } if (!$this->get('email')) { $this->set('email', $this->_my->email); } } // Fill thread/post related information $this->set('parent', $this->parent->id); $this->set('thread', $this->parent->thread); $this->set('catid', $this->parent->catid); if (!$this->get('time')) { $this->set('time', CKunenaTimeformat::internalTime()); } // On reviewed forum, require approval if user is not a moderator $this->set('hold', CKunenaTools::isModerator($this->_my, $this->parent->catid) ? 0 : (int) $this->parent->review); // Activity integration $activity = KunenaFactory::getActivityIntegration(); if ($this->parent->hold == 0) { if ($this->parent->thread == 0) { $activity->onBeforePost($this); } else { $activity->onBeforeReply($this); } } if (!empty($this->errors)) { return false; } if ($this->isAlreadyPosted()) { return $this->setError('-post-', JText::_('COM_KUNENA_POST_DUPLICATE_IGNORED')); } $meskeys = array(); $mesvalues = array(); $txtkeys = array('mesid'); $txtvalues = array(0); foreach ($this->message as $field => $value) { if ($field != 'message') { $meskeys[] = $this->_db->nameQuote($field); $mesvalues[] = $this->_db->quote($value); } else { $txtkeys[] = $this->_db->nameQuote($field); $txtvalues[] = $this->_db->quote($value); } } if (empty($mesvalues) || count($txtvalues) < 2) { return $this->setError('-post-', JText::_('COM_KUNENA_POST_ERROR_SAVE')); } $meskeys = implode(', ', $meskeys); $mesvalues = implode(', ', $mesvalues); $query = "INSERT INTO #__kunena_messages ({$meskeys}) VALUES({$mesvalues})"; $this->_db->setQuery($query); $this->_db->query(); $dberror = $this->checkDatabaseError(); if ($dberror) { return $this->setError('-post-', JText::_('COM_KUNENA_POST_ERROR_SAVE')); } $id = (int) $this->_db->insertId(); $txtvalues[0] = $this->_db->quote($id); $txtkeys = implode(', ', $txtkeys); $txtvalues = implode(', ', $txtvalues); $query = "INSERT INTO #__kunena_messages_text ({$txtkeys}) VALUES({$txtvalues})"; $this->_db->setQuery($query); $this->_db->query(); $dberror = $this->checkDatabaseError(); if ($dberror) { // Delete partial message on error $query = "DELETE FROM #__kunena_messages WHERE mesid={$this->_db->quote($id)}"; $this->_db->setQuery($query); $this->_db->query(); return $this->setError('-post-', JText::_('COM_KUNENA_POST_ERROR_SAVE')); } $this->set('id', $id); if ($this->parent->thread == 0) { // For new thread, we now know to where the message belongs $this->set('thread', $id); $query = "UPDATE #__kunena_messages SET thread={$this->_db->quote($id)} WHERE id={$this->_db->quote($id)}"; $this->_db->setQuery($query); $this->_db->query(); $dberror = $this->checkDatabaseError(); if ($dberror) { return $this->setError('-post-', JText::_('COM_KUNENA_POST_ERROR_SAVE')); } } //update the user posts count $userid = (int) $this->get('userid'); if ($userid) { $userprofile = KunenaFactory::getUser($userid); if (!$userprofile->exists()) { $userprofile->save(); } $query = "UPDATE #__kunena_users SET posts=posts+1 WHERE userid={$this->_db->quote($userid)}"; $this->_db->setQuery($query); $this->_db->query(); } // now increase the #s in categories only case approved if (!$this->get('hold')) { CKunenaTools::modifyCategoryStats($id, $this->get('parent'), $this->get('time'), $this->get('catid')); } // Add attachments if there are any // TODO: find better way if ($this->getOption('attachments')) { require_once KUNENA_PATH_LIB . '/kunena.attachments.class.php'; $attachments = CKunenaAttachments::getInstance(); $message = $this->get('message'); $fileinfos = $attachments->multiupload($id, $message); foreach ($fileinfos as $fileinfo) { if (!$fileinfo['status']) { $this->_app->enqueueMessage(JText::sprintf('COM_KUNENA_UPLOAD_FAILED', $fileinfo['name']) . ': ' . $fileinfo['error'], 'error'); } } $this->_db->setQuery("UPDATE #__kunena_messages_text SET message={$this->_db->quote($message)} WHERE mesid={$this->_db->Quote($id)}"); $this->_db->query(); } // Mark topic read for me CKunenaTools::markTopicRead($this->get('thread'), $this->_my->id); // Mark topic unread for others // First take care of old sessions to make our job easier and faster $lasttime = $this->get('time') - max(intval(JFactory::getConfig()->getValue('config.lifetime')) * 60, intval(KunenaFactory::getConfig()->fbsessiontimeout)) - 60; $query = "UPDATE #__kunena_sessions SET readtopics='0' WHERE currvisit<{$this->_db->quote($lasttime)}"; $this->_db->setQuery($query); $this->_db->query(); $dberror = $this->checkDatabaseError(); if ($dberror) { return $this->setError('-post-', JText::_('COM_KUNENA_POST_ERROR_SESSIONS')); } // Then look at users who have read the thread $thread = $this->get('thread'); $query = "SELECT userid, readtopics FROM #__kunena_sessions WHERE readtopics LIKE '%{$thread}%' AND userid!={$this->_db->quote($userid)}"; $this->_db->setQuery($query); $sessions = $this->_db->loadObjectList(); $dberror = $this->checkDatabaseError(); if ($dberror) { return $this->setError('-post-', JText::_('COM_KUNENA_POST_ERROR_SESSIONS')); } // And clear current thread $errcount = 0; foreach ($sessions as $session) { $readtopics = $session->readtopics; $rt = explode(",", $readtopics); $key = array_search($thread, $rt); if ($key !== false) { unset($rt[$key]); $readtopics = implode(",", $rt); $query = "UPDATE #__kunena_sessions SET readtopics={$this->_db->quote($readtopics)} WHERE userid={$this->_db->quote($session->userid)}"; $this->_db->setQuery($query); $this->_db->query(); $dberror = $this->checkDatabaseError(); if ($dberror) { $errcount++; } } } if ($errcount) { return $this->setError('-post-', JText::_('COM_KUNENA_POST_ERROR_SESSIONS')); } // Get the event dispatcher $dispatcher = JDispatcher::getInstance(); // Load the JXFinder plug-in group JPluginHelper::importPlugin('finder'); // Fire after post save event $dispatcher->trigger('onAfterSaveKunenaPost', array($id)); // Activity integration $activity = KunenaFactory::getActivityIntegration(); if ($this->parent->thread == 0) { $activity->onAfterPost($this); } else { $activity->onAfterReply($this); } return $id; }
function getView() { // Is user allowed to read category from the URL? if ($this->catid && !$this->session->canRead($this->catid)) { return; } $this->allow = 1; $where[] = "a.hold IN ({$this->hold})"; $where = implode(' AND ', $where); $query = "SELECT a.*, b.*, p.id AS poll_id, modified.name AS modified_name, modified.username AS modified_username\n\t\t\tFROM #__kunena_messages AS a\n\t\t\tLEFT JOIN #__kunena_messages_text AS b ON a.id=b.mesid\n\t\t\tLEFT JOIN #__users AS modified ON a.modified_by = modified.id\n\t\t\tLEFT JOIN #__kunena_polls AS p ON a.id=p.threadid\n\t\t\tWHERE a.id={$this->db->Quote($this->id)} AND {$where}"; $this->db->setQuery($query); $this->first_message = $this->db->loadObject(); // Invalid message id (deleted, on hold?) if (KunenaError::checkDatabaseError() || !$this->first_message) { return; } // Is user allowed to see the forum specified in the message? if (!$this->session->canRead($this->first_message->catid)) { $this->allow = 0; return; } $this->thread = $this->first_message->thread; // Test if this is a valid URL. If not, redirect browser to the right location if ($this->first_message->moved || $this->thread != $this->id || $this->catid != $this->first_message->catid) { $this->catid = $this->first_message->catid; if ($this->first_message->moved) { $newurl = array(); parse_str($this->first_message->message, $newloc); $this->id = $newloc['id']; $query = "SELECT catid, thread FROM #__kunena_messages AS a WHERE a.id='{$this->id}'"; $this->db->setQuery($query); $newpos = $this->db->loadObject(); if (!$newpos) { $this->allow = 0; return; } if (KunenaError::checkDatabaseError()) { return; } $this->thread = $newpos->thread; $this->catid = $newpos->catid; } // This query to calculate the page this reply is sitting on within this thread $query = "SELECT COUNT(*) FROM #__kunena_messages AS a WHERE a.thread={$this->db->Quote($this->thread)} AND {$where} AND a.id<={$this->db->Quote($this->id)}"; $this->db->setQuery($query); $replyCount = $this->db->loadResult(); if (KunenaError::checkDatabaseError()) { return; } $replyPage = $replyCount > $this->config->messages_per_page ? ceil($replyCount / $this->config->messages_per_page) : 1; $this->redirect = CKunenaLink::GetThreadPageURL('view', $this->catid, $this->thread, $replyPage, $this->config->messages_per_page, $this->first_message->id, false); } //Get the category name for breadcrumb $this->db->setQuery("SELECT * FROM #__kunena_categories WHERE id={$this->db->Quote($this->catid)}"); $this->catinfo = $this->db->loadObject(); if (KunenaError::checkDatabaseError()) { return; } //Get Parent's cat.name for breadcrumb $this->db->setQuery("SELECT id, name FROM #__kunena_categories WHERE id={$this->db->Quote($this->catinfo->parent)}"); $objCatParentInfo = $this->db->loadObject(); if (KunenaError::checkDatabaseError()) { return; } // START $this->emoticons = smile::getEmoticons(0); $this->prevCheck = $this->session->lasttime; $this->read_topics = explode(',', $this->session->readtopics); $showedEdit = 0; $this->kunena_forum_locked = $this->catinfo->locked; //check if topic is locked $this->topicLocked = $this->first_message->locked; if (!$this->topicLocked) { //topic not locked; check if forum is locked $this->topicLocked = $this->catinfo->locked; } $this->topicSticky = $this->first_message->ordering; CKunenaTools::markTopicRead($this->thread, $this->my->id); //update the hits counter for this topic & exclude the owner if ($this->my->id == 0 || $this->first_message->userid != $this->my->id) { $this->db->setQuery("UPDATE #__kunena_messages SET hits=hits+1 WHERE id={$this->db->Quote($this->thread)} AND parent='0'"); $this->db->query(); KunenaError::checkDatabaseError(); } $query = "SELECT COUNT(*) FROM #__kunena_messages AS a WHERE a.thread={$this->db->Quote($this->thread)} AND {$where}"; $this->db->setQuery($query); $this->total_messages = $this->db->loadResult(); KunenaError::checkDatabaseError(); // If page does not exist, redirect to the last page if ($this->total_messages <= $this->limitstart) { $page = ceil($this->total_messages / $this->limit); $this->redirect = CKunenaLink::GetThreadPageURL('view', $this->catid, $this->id, $page, $this->limit, '', false); } $maxpages = 7 - 2; // odd number here (show - 2) $totalpages = ceil($this->total_messages / $this->limit); $page = floor($this->limitstart / $this->limit) + 1; $firstpage = 1; if ($this->ordering == 'desc') { $firstpage = $totalpages; } // Get replies of current thread $query = "SELECT a.*, b.*, modified.name AS modified_name, modified.username AS modified_username\n\t\t\t\t\tFROM #__kunena_messages AS a\n\t\t\t\t\tLEFT JOIN #__kunena_messages_text AS b ON a.id=b.mesid\n\t\t\t\t\tLEFT JOIN #__users AS modified ON a.modified_by = modified.id\n\t\t\t\t\tWHERE a.thread={$this->db->Quote($this->thread)} AND {$where}\n\t\t\t\t\tORDER BY id {$this->ordering}"; $this->db->setQuery($query, $this->limitstart, $this->limit); $this->messages = (array) $this->db->loadObjectList('id'); KunenaError::checkDatabaseError(); // First collect the message ids of the first message and all replies $messageids = array(); $this->threaded = array(); $userlist = array(); foreach ($this->messages as $message) { $messageids[] = $message->id; // Threaded ordering if (isset($this->messages[$message->parent])) { $this->threaded[$message->parent][] = $message->id; } else { $this->threaded[0][] = $message->id; } $userlist[intval($message->userid)] = intval($message->userid); $userlist[intval($message->modified_by)] = intval($message->modified_by); } if (!isset($this->messages[$this->mesid])) { $this->mesid = reset($messageids); } if ($this->layout != 'view') { if (!isset($this->messages[$this->id])) { $this->messages = $this->getThreadedOrdering(0, array('edge')); } else { $this->messages = $this->getThreadedOrdering(); } } // create a list of ids we can use for our sql $idstr = @join(",", $messageids); // Load attachments require_once KUNENA_PATH_LIB . '/kunena.attachments.class.php'; $attachments = CKunenaAttachments::getInstance(); if (is_a($attachments, 'CKunenaAttachments')) { $message_attachments = $attachments->get($idstr); // Now that we have all relevant messages in messages, asign any matching attachments foreach ($this->messages as $message) { // Mark as new if ($this->my->id && $this->prevCheck < $message->time && !in_array($message->thread, $this->read_topics)) { $message->new = true; } else { $message->new = false; } // Assign attachments if (isset($message_attachments[$message->id])) { $message->attachments = $message_attachments[$message->id]; } } // Done with attachments } $this->pagination = $this->getPagination($this->catid, $this->thread, $page, $totalpages, $maxpages); //meta description and keywords $metaKeys = kunena_htmlspecialchars("{$this->first_message->subject}, {$objCatParentInfo->name}, {$this->config->board_title}, " . JText::_('COM_KUNENA_GEN_FORUM') . ', ' . $this->app->getCfg('sitename')); // Create Meta Description form the content of the first message // better for search results display but NOT for search ranking! $metaDesc = KunenaParser::stripBBCode($this->first_message->message); $metaDesc = strip_tags($metaDesc); // Now remove all tags $metaDesc = preg_replace('/\\s+/', ' ', $metaDesc); // remove newlines $metaDesc = preg_replace('/^[^\\w0-9]+/', '', $metaDesc); // remove characters at the beginning that are not letters or numbers $metaDesc = trim($metaDesc); // Remove trailing spaces and beginning // remove multiple spaces while (strpos($metaDesc, ' ') !== false) { $metaDesc = str_replace(' ', ' ', $metaDesc); } // limit to 185 characters - google will cut off at ~150 if (strlen($metaDesc) > 185) { $metaDesc = rtrim(JString::substr($metaDesc, 0, 182)) . '...'; } $metaDesc = htmlspecialchars($metaDesc); $document =& JFactory::getDocument(); $document->setMetadata('keywords', $metaKeys); $document->setDescription($metaDesc); $this->layout_buttons = array(); if ($this->config->enable_threaded_layouts) { if ($this->layout != 'view') { $this->layout_buttons[] = CKunenaLink::GetThreadLayoutLink('flat', $this->catid, $this->thread, $this->mesid, CKunenaTools::showButton('layout-flat', JText::_('COM_KUNENA_BUTTON_LAYOUT_FLAT')), $this->limitstart, $this->limit, JText::_('COM_KUNENA_BUTTON_LAYOUT_FLAT_LONG'), 'nofollow', 'kicon-button kbuttonuser btn-left'); } if ($this->layout != 'threaded') { $this->layout_buttons[] = CKunenaLink::GetThreadLayoutLink('threaded', $this->catid, $this->thread, $this->mesid, CKunenaTools::showButton('layout-threaded', JText::_('COM_KUNENA_BUTTON_LAYOUT_THREADED')), $this->limitstart, $this->limit, JText::_('COM_KUNENA_BUTTON_LAYOUT_THREADED_LONG'), 'nofollow', 'kicon-button kbuttonuser btn-left'); } if ($this->layout != 'indented') { $this->layout_buttons[] = CKunenaLink::GetThreadLayoutLink('indented', $this->catid, $this->thread, $this->mesid, CKunenaTools::showButton('layout-indented', JText::_('COM_KUNENA_BUTTON_LAYOUT_INDENTED')), $this->limitstart, $this->limit, JText::_('COM_KUNENA_BUTTON_LAYOUT_INDENTED_LONG'), 'nofollow', 'kicon-button kbuttonuser btn-left'); } } //Perform subscriptions check only once $this->cansubscribe = 0; if ($this->config->allowsubscriptions && $this->config->topic_subscriptions != 'disabled' && $this->my->id) { $this->db->setQuery("SELECT thread, future1 FROM #__kunena_subscriptions WHERE userid={$this->db->Quote($this->my->id)} AND thread={$this->db->Quote($this->thread)}"); $fb_subscribed = $this->db->loadObject(); KunenaError::checkDatabaseError(); if (!$fb_subscribed) { $this->cansubscribe = 1; } elseif ($fb_subscribed->future1 == 1) { $query_thread = "UPDATE #__kunena_subscriptions\n\t\t\t\t\tSET future1=0 WHERE thread={$this->db->Quote($this->thread)} AND userid={$this->db->Quote($this->my->id)}"; $this->db->setQuery($query_thread); $this->db->query(); } } //Perform favorites check only once $fb_canfavorite = 0; $this->db->setQuery("SELECT MAX(userid={$this->db->Quote($this->my->id)}) AS favorited, COUNT(*) AS totalfavorited FROM #__kunena_favorites WHERE thread={$this->db->Quote($this->thread)}"); list($this->favorited, $this->totalfavorited) = $this->db->loadRow(); KunenaError::checkDatabaseError(); if ($this->config->allowfavorites && $this->my->id) { if (!$this->favorited) { $fb_canfavorite = 1; } } //get the Moderator list for display $this->db->setQuery("SELECT m.*, u.* FROM #__kunena_moderation AS m INNER JOIN #__users AS u ON u.id=m.userid WHERE m.catid={$this->db->Quote($this->catid)} AND u.block=0"); $this->modslist = $this->db->loadObjectList(); KunenaError::checkDatabaseError(); $this->catModerators = array(); foreach ($this->modslist as $mod) { $this->catModerators[] = $mod->userid; $userlist[intval($mod->userid)] = intval($mod->userid); } // Prefetch all users/avatars to avoid user by user queries during template iterations KunenaUser::loadUsers($userlist); //data ready display now if (CKunenaTools::isModerator($this->my->id, $this->catid) || $this->topicLocked == 0) { //this user is allowed to reply to this topic $this->thread_reply = CKunenaLink::GetTopicPostReplyLink('reply', $this->catid, $this->thread, CKunenaTools::showButton('reply', JText::_('COM_KUNENA_BUTTON_REPLY_TOPIC')), 'nofollow', 'kicon-button kbuttoncomm btn-left', JText::_('COM_KUNENA_BUTTON_REPLY_TOPIC_LONG')); } // Thread Subscription if ($this->cansubscribe == 1) { // this user is allowed to subscribe - check performed further up to eliminate duplicate checks // for top and bottom navigation $this->thread_subscribe = CKunenaLink::GetTopicPostLink('subscribe', $this->catid, $this->id, CKunenaTools::showButton('subscribe', JText::_('COM_KUNENA_BUTTON_SUBSCRIBE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_SUBSCRIBE_TOPIC_LONG')); } if ($this->my->id != 0 && $this->config->allowsubscriptions && $this->config->topic_subscriptions != 'disabled' && $this->cansubscribe == 0) { // this user is allowed to unsubscribe $this->thread_subscribe = CKunenaLink::GetTopicPostLink('unsubscribe', $this->catid, $this->id, CKunenaTools::showButton('subscribe', JText::_('COM_KUNENA_BUTTON_UNSUBSCRIBE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_UNSUBSCRIBE_TOPIC_LONG')); } //START: FAVORITES if ($fb_canfavorite == 1) { // this user is allowed to add a favorite - check performed further up to eliminate duplicate checks // for top and bottom navigation $this->thread_favorite = CKunenaLink::GetTopicPostLink('favorite', $this->catid, $this->id, CKunenaTools::showButton('favorite', JText::_('COM_KUNENA_BUTTON_FAVORITE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_FAVORITE_TOPIC_LONG')); } if ($this->my->id != 0 && $this->config->allowfavorites && $fb_canfavorite == 0) { // this user is allowed to unfavorite $this->thread_favorite = CKunenaLink::GetTopicPostLink('unfavorite', $this->catid, $this->id, CKunenaTools::showButton('favorite', JText::_('COM_KUNENA_BUTTON_UNFAVORITE_TOPIC')), 'nofollow', 'kicon-button kbuttonuser btn-left', JText::_('COM_KUNENA_BUTTON_UNFAVORITE_TOPIC_LONG')); } // FINISH: FAVORITES if (CKunenaTools::isModerator($this->my->id, $this->catid) || !$this->kunena_forum_locked) { //this user is allowed to post a new topic $this->thread_new = CKunenaLink::GetPostNewTopicLink($this->catid, CKunenaTools::showButton('newtopic', JText::_('COM_KUNENA_BUTTON_NEW_TOPIC')), 'nofollow', 'kicon-button kbuttoncomm btn-left', JText::_('COM_KUNENA_BUTTON_NEW_TOPIC_LONG')); } if (CKunenaTools::isModerator($this->my->id, $this->catid)) { // offer the moderator always the move link to relocate a topic to another forum // and the (un)sticky bit links // and the (un)lock links if ($this->topicSticky == 0) { $this->thread_sticky = CKunenaLink::GetTopicPostLink('sticky', $this->catid, $this->id, CKunenaTools::showButton('sticky', JText::_('COM_KUNENA_BUTTON_STICKY_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_STICKY_TOPIC_LONG')); } else { $this->thread_sticky = CKunenaLink::GetTopicPostLink('unsticky', $this->catid, $this->id, CKunenaTools::showButton('sticky', JText::_('COM_KUNENA_BUTTON_UNSTICKY_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_UNSTICKY_TOPIC_LONG')); } if ($this->topicLocked == 0) { $this->thread_lock = CKunenaLink::GetTopicPostLink('lock', $this->catid, $this->id, CKunenaTools::showButton('lock', JText::_('COM_KUNENA_BUTTON_LOCK_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_LOCK_TOPIC_LONG')); } else { $this->thread_lock = CKunenaLink::GetTopicPostLink('unlock', $this->catid, $this->id, CKunenaTools::showButton('lock', JText::_('COM_KUNENA_BUTTON_UNLOCK_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_UNLOCK_TOPIC_LONG')); } $this->thread_delete = CKunenaLink::GetTopicPostLink('deletethread', $this->catid, $this->id, CKunenaTools::showButton('delete', JText::_('COM_KUNENA_BUTTON_DELETE_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_DELETE_TOPIC_LONG')); $this->thread_moderate = CKunenaLink::GetTopicPostReplyLink('moderatethread', $this->catid, $this->id, CKunenaTools::showButton('moderate', JText::_('COM_KUNENA_BUTTON_MODERATE_TOPIC')), 'nofollow', 'kicon-button kbuttonmod btn-left', JText::_('COM_KUNENA_BUTTON_MODERATE')); } $this->headerdesc = nl2br(smile::smileReplace($this->catinfo->headerdesc, 0, $this->config->disemoticons, $this->emoticons)); $tabclass = array("row1", "row2"); $this->mmm = 0; $this->replydir = $this->ordering == 'DESC' ? -1 : 1; if ($this->replydir < 0) { $this->replynum = $this->total_messages - $this->limitstart + 1; } else { $this->replynum = $this->limitstart; } $this->myname = $this->config->username ? $this->my->username : $this->my->name; $this->allow_anonymous = !empty($this->catinfo->allow_anonymous) && $this->my->id; $this->anonymous = $this->allow_anonymous && !empty($this->catinfo->post_anonymous); }