/** * Returns class instance * * @return FORUM_BOL_GroupDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
/** * 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); }
/** * 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)); }
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); }
/** * Returns section groups list * * @param int $isHidden * @return array */ public function getCustomSectionGroupList($isHidden = 0) { $groupDao = FORUM_BOL_GroupDao::getInstance(); $query = "\n \tSELECT `g`.*, `s`.`id` AS `sectionId`, `s`.`name` AS `sectionName`, `s`.`order` AS `sectionOrder` \t\n \tFROM `" . $this->getTableName() . "` AS `s`\n \tLEFT JOIN `" . $groupDao->getTableName() . "` AS `g` ON ( `s`.`id` = `g`.`sectionId` )\n WHERE `s`.`isHidden` = " . $isHidden . "\n ORDER BY `s`.`order`, `g`.`order`\n \t"; return $this->dbo->queryForList($query); }