예제 #1
0
 /**
  * Returns class instance
  *
  * @return FORUM_BOL_SectionDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
예제 #2
0
 /**
  * Returns group by specified entity id
  *
  * @param string $entity
  * @param int $entityId
  * @return FORUM_BOL_Group
  */
 public function findGroupByEntityId($entity, $entityId)
 {
     $entityId = (int) $entityId;
     if (!$entityId || !isset($entity)) {
         return null;
     }
     $section = $this->sectionDao->findByEntity($entity);
     return $this->groupDao->findByEntityId($section->getId(), $entityId);
 }
예제 #3
0
 /**
  * Returns forum topic info
  * 
  * @param int $topicId
  * @return array 
  */
 public function findTopicInfo($topicId)
 {
     $query = "\n\t\tSELECT `t`.*, `g`.`id` AS `groupId`, `g`.`name` AS `groupName`, `s`.`name` AS `sectionName`, `s`.`id` AS `sectionId` \n\t\tFROM `" . $this->getTableName() . "` AS `t`\n\t\tLEFT JOIN `" . FORUM_BOL_GroupDao::getInstance()->getTableName() . "` AS `g` \n\t\tON (`t`.`groupId` = `g`.`id`)\n\t\tLEFT JOIN `" . FORUM_BOL_SectionDao::getInstance()->getTableName() . "` AS `s`\n\t\tON (`g`.`sectionId` = `s`.`id`)\n\t\tWHERE `t`.`id` = ?\n\t\t";
     return $this->dbo->queryForRow($query, array($topicId));
 }
예제 #4
0
 public function countFoundTopicsInGroup($token, $userToken, $groupId, $isHidden = 0)
 {
     $hiddenCond = $isHidden ? ' AND `s`.`isHidden` = 1' : ' AND `s`.`isHidden` = 0';
     if (!mb_strlen($token)) {
         $query = "SELECT count(DISTINCT(`t`.`id`)) \n            FROM `" . $this->getTableName() . "` AS `p`\n            INNER JOIN `" . FORUM_BOL_TopicDao::getInstance()->getTableName() . "` AS `t` ON (`t`.`id`=`p`.`topicId`)\n            INNER JOIN `" . FORUM_BOL_GroupDao::getInstance()->getTableName() . "` AS `g` ON (`g`.`id`=`t`.`groupId`)\n            INNER JOIN `" . FORUM_BOL_SectionDao::getInstance()->getTableName() . "` AS `s` ON (`s`.`id`=`g`.`sectionId`)\n                " . $this->getUserTokenJoinString($userToken) . "\n                WHERE `g`.`id` = :groupId AND `t`.`status` = :status " . $hiddenCond;
         $params = array('groupId' => $groupId, 'status' => FORUM_BOL_ForumService::STATUS_APPROVED);
     } else {
         $multiple = $this->countTokenWords($token) > 1;
         $booleanMode = $multiple ? ' IN BOOLEAN MODE' : '';
         $token = $booleanMode ? '"' . $token . '"' : $token;
         $query = "SELECT count(DISTINCT(`t`.`id`))\n                FROM `" . $this->getTableName() . "` AS `p`\n                INNER JOIN `" . FORUM_BOL_TopicDao::getInstance()->getTableName() . "` AS `t` ON (`t`.`id`=`p`.`topicId`)\n                INNER JOIN `" . FORUM_BOL_GroupDao::getInstance()->getTableName() . "` AS `g` ON (`g`.`id`=`t`.`groupId`)\n                INNER JOIN `" . FORUM_BOL_SectionDao::getInstance()->getTableName() . "` AS `s` ON (`s`.`id`=`g`.`sectionId`)\n                " . $this->getUserTokenJoinString($userToken) . "\n                WHERE (MATCH (`t`.`title`) AGAINST(:token" . $booleanMode . ") OR MATCH (`p`.`text`) AGAINST(:token" . $booleanMode . "))\n            AND `g`.`id` = :groupId AND `t`.`status` = :status " . $hiddenCond;
         $params = array('token' => $token, 'groupId' => $groupId, 'status' => FORUM_BOL_ForumService::STATUS_APPROVED);
     }
     return (int) $this->dbo->queryForColumn($query, $params);
 }