コード例 #1
0
 /**
  * getDefaultView
  *
  * @param	void
  *
  * @return	Enum
  **/
 public function getDefaultView()
 {
     $handler = Legacy_Utils::getModuleHandler('forums', $this->mAsset->mDirname);
     if (isset($this->forum_id) && $this->forum_id > 0) {
         $this->mForumObj = $handler->get($this->forum_id);
     } else {
         $this->mForumObj = $handler->create();
     }
     // set moderators
     $handler->setModerateGroups($this->mForumObj, $this->forum_id);
     $handler->setModerateUsers($this->mForumObj, $this->forum_id);
     $this->mFilter =& $this->_getFilterForm();
     $this->mFilter->fetch();
     $handler =& $this->_getHandler();
     $mCriteria = $this->mFilter->getCriteria();
     $mCriteria->add(new criteria('forum_id', $this->mForumAcc['can_read'], 'IN'));
     $db = $this->mRoot->mController->mDB;
     $dirname = $this->mAsset->mDirname;
     $uid = $this->mRoot->mContext->mUser->isInRole('Site.RegisteredUser') ? $this->mRoot->mContext->mXoopsUser->get('uid') : 0;
     // forum_id
     if ($this->forum_id > 0) {
         $whr_forum = 't.forum_id=' . $this->forum_id;
         $isadminormod = $this->mod_isadmin ? true : in_array($this->forum_id, $this->mForumAcc['moderate']);
         $fields_forum = "";
         $join_forum = "";
         $initial_mode = 1;
     } else {
         $whr_forum = 't.forum_id IN (' . implode(',', $this->mForumAcc['can_read']) . ') ';
         $isadminormod = $this->mod_isadmin ? true : false;
         $fields_forum = ", f.forum_id, f.forum_title, f.forum_external_link_format ";
         $join_forum = " LEFT JOIN " . $db->prefix($dirname . "_forums") . " f ON f.forum_id=t.forum_id ";
         $initial_mode = 2;
     }
     // INVISIBLE
     $whr_invisible = $isadminormod ? '1' : '! t.topic_invisible';
     // SOLVED
     $this->solved_options = array(0 => '----', 1 => _MD_XCFORUM_OPT_SOLVEDYES, 2 => _MD_XCFORUM_OPT_SOLVEDNO);
     $solved_sqls = array(0 => '1', 1 => 't.topic_solved=1', 2 => 't.topic_solved=0');
     if (empty($this->mod_config['use_solved'])) {
         // disable "solved function"
         $query4assign['solved'] = 0;
         $whr_solved = $solved_sqls[0];
     } else {
         $q_solved = (int) $this->mRoot->mContext->mRequest->getRequest('solved');
         if (!empty($this->solved_options[$q_solved])) {
             $query4assign['solved'] = $q_solved;
             $whr_solved = $solved_sqls[$query4assign['solved']];
         } else {
             $query4assign['solved'] = 0;
             $whr_solved = $solved_sqls[0];
         }
     }
     $mCriteria->add(new criteria('topic_solved', $whr_solved));
     // TXT
     $myts =& Xcforum_Utils::getMytextSanitizer();
     $q_txt = $this->mRoot->mContext->mRequest->getRequest('txt');
     //adump($this->mRoot->mContext->mRequest->getRequest('txt'));
     //$q_txt = $_GET['txt'];
     if (!empty($q_txt)) {
         $txt = $myts->stripSlashesGPC($q_txt);
         $query4assign['txt'] = htmlspecialchars($txt, ENT_QUOTES, _CHARSET);
         $txt4sql = addslashes($txt);
         $whr_txt = "fp.subject LIKE '%{$txt4sql}%' OR fp.post_text LIKE '%{$txt4sql}%'";
         $mCriteria->add(new criteria('topic_title', $txt4sql, 'LIKE'));
     } else {
         $query4assign['txt'] = '';
         $whr_txt = '1';
     }
     $this->query4assign = $query4assign;
     $limit = $this->mod_config['topics_per_page'];
     // get counts of total topics
     $sql_base = "FROM " . $db->prefix($dirname . "_topics") . " t LEFT JOIN " . $db->prefix($dirname . "_users2topics") . " u2t ON t.topic_id=u2t.topic_id AND u2t.uid={$uid} LEFT JOIN " . $db->prefix($dirname . "_posts") . " lp ON lp.post_id=t.topic_last_post_id LEFT JOIN " . $db->prefix($dirname . "_posts") . " fp ON fp.post_id=t.topic_first_post_id\n\t\t\t" . $join_forum . "\n\t\t  WHERE ({$whr_forum}) AND ({$whr_invisible}) AND ({$whr_solved}) AND ({$whr_txt})";
     //		  WHERE t.forum_id=$this->forum_id AND ($whr_invisible) AND ($whr_solved) AND ($whr_txt)
     //		  AND ($whr_external_link_id) ORDER BY $odr_query LIMIT $pos,$num" ;
     $sql = $sql_base;
     $this->topic_hits = $handler->getCount($mCriteria, $sql);
     // get topic objects
     $sql = "SELECT t.*, lp.post_text AS lp_post_text, lp.subject AS lp_subject, lp.icon AS lp_icon,\n\t\t  lp.number_entity AS lp_number_entity, lp.special_entity AS lp_special_entity,\n\t\t  lp.guest_name AS lp_guest_name, fp.subject AS fp_subject, fp.icon AS fp_icon,\n\t\t  fp.number_entity AS fp_number_entity, fp.special_entity AS fp_special_entity,\n\t\t  fp.guest_name AS fp_guest_name, u2t.u2t_time, u2t.u2t_marked, u2t.u2t_rsv\n\t\t  " . $fields_forum . $sql_base;
     // No6 argument is for additional initializztion : 1::forum_id>0, 2::forum_id==0
     $this->mObjects =& $handler->getObjects($mCriteria, NULL, NULL, false, $sql, $initial_mode);
     return XCFORUM_FRAME_VIEW_INDEX;
 }
コード例 #2
0
 /**
  * fetch
  * 
  * @param   void
  * 
  * @return  void
  **/
 public function fetch()
 {
     parent::fetch();
     $root =& XCube_Root::getSingleton();
     if (($value = $root->mContext->mRequest->getRequest('topic_id')) !== null) {
         $this->mNavi->addExtra('topic_id', $value);
         $this->_mCriteria->add(new Criteria('topic_id', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('forum_id')) !== null) {
         $this->mNavi->addExtra('forum_id', $value);
         $this->_mCriteria->add(new Criteria('forum_id', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_external_link_id')) !== null) {
         $this->mNavi->addExtra('topic_external_link_id', $value);
         $this->_mCriteria->add(new Criteria('topic_external_link_id', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_title')) !== null) {
         $this->mNavi->addExtra('topic_title', $value);
         $this->_mCriteria->add(new Criteria('topic_title', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_first_uid')) !== null) {
         $this->mNavi->addExtra('topic_first_uid', $value);
         $this->_mCriteria->add(new Criteria('topic_first_uid', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_first_post_id')) !== null) {
         $this->mNavi->addExtra('topic_first_post_id', $value);
         $this->_mCriteria->add(new Criteria('topic_first_post_id', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_first_post_time')) !== null) {
         $this->mNavi->addExtra('topic_first_post_time', $value);
         $this->_mCriteria->add(new Criteria('topic_first_post_time', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_last_uid')) !== null) {
         $this->mNavi->addExtra('topic_last_uid', $value);
         $this->_mCriteria->add(new Criteria('topic_last_uid', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_last_post_id')) !== null) {
         $this->mNavi->addExtra('topic_last_post_id', $value);
         $this->_mCriteria->add(new Criteria('topic_last_post_id', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_last_post_time')) !== null) {
         $this->mNavi->addExtra('topic_last_post_time', $value);
         $this->_mCriteria->add(new Criteria('topic_last_post_time', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_views')) !== null) {
         $this->mNavi->addExtra('topic_views', $value);
         $this->_mCriteria->add(new Criteria('topic_views', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_posts_count')) !== null) {
         $this->mNavi->addExtra('topic_posts_count', $value);
         $this->_mCriteria->add(new Criteria('topic_posts_count', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_locked')) !== null) {
         $this->mNavi->addExtra('topic_locked', $value);
         $this->_mCriteria->add(new Criteria('topic_locked', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_sticky')) !== null) {
         $this->mNavi->addExtra('topic_sticky', $value);
         $this->_mCriteria->add(new Criteria('topic_sticky', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_solved')) !== null) {
         $this->mNavi->addExtra('topic_solved', $value);
         $this->_mCriteria->add(new Criteria('topic_solved', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_invisible')) !== null) {
         $this->mNavi->addExtra('topic_invisible', $value);
         $this->_mCriteria->add(new Criteria('topic_invisible', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_votes_sum')) !== null) {
         $this->mNavi->addExtra('topic_votes_sum', $value);
         $this->_mCriteria->add(new Criteria('topic_votes_sum', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('topic_votes_count')) !== null) {
         $this->mNavi->addExtra('topic_votes_count', $value);
         $this->_mCriteria->add(new Criteria('topic_votes_count', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('status')) !== null) {
         $this->mNavi->addExtra('status', $value);
         $this->_mCriteria->add(new Criteria('status', $value));
     }
     if (($value = $root->mContext->mRequest->getRequest('posttime')) !== null) {
         $this->mNavi->addExtra('posttime', $value);
         $this->_mCriteria->add(new Criteria('posttime', $value));
     }
     // TXT
     $myts =& Xcforum_Utils::getMytextSanitizer();
     $q_txt = $root->mContext->mRequest->getRequest('txt');
     if (!empty($q_txt)) {
         $txt = $myts->stripSlashesGPC($q_txt);
         //$query4assign['txt'] = htmlspecialchars( $txt , ENT_QUOTES , _CHARSET ) ;
         $txt4sql = addslashes($txt);
         //$whr_txt = "fp.subject LIKE '%$txt4sql%' OR fp.post_text LIKE '%$txt4sql%'" ;
         $this->_mCriteria->add(new criteria('topic_title', $txt4sql, 'LIKE'));
     } else {
         //$query4assign['txt'] = '' ;
         //$whr_txt = '1' ;
     }
     $this->_mCriteria->addSort($this->getSort(), $this->getOrder());
 }