当前位置: 首页>>代码示例>>PHP>>正文


PHP CKunenaTools::markTopicRead方法代码示例

本文整理汇总了PHP中CKunenaTools::markTopicRead方法的典型用法代码示例。如果您正苦于以下问题:PHP CKunenaTools::markTopicRead方法的具体用法?PHP CKunenaTools::markTopicRead怎么用?PHP CKunenaTools::markTopicRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CKunenaTools的用法示例。


在下文中一共展示了CKunenaTools::markTopicRead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: savePost


//.........这里部分代码省略.........
     }
     $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;
 }
开发者ID:redigy,项目名称:Kunena-1.6,代码行数:101,代码来源:kunena.posting.class.php

示例2: getView

 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;
//.........这里部分代码省略.........
开发者ID:vuchannguyen,项目名称:hoctap,代码行数:101,代码来源:view.php


注:本文中的CKunenaTools::markTopicRead方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。