Example #1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return BOL_CommentEntityDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Example #2
0
 /**
  * Constructor.
  */
 private function __construct()
 {
     $this->commentDao = BOL_CommentDao::getInstance();
     $this->commentEntityDao = BOL_CommentEntityDao::getInstance();
     $this->configs[self::CONFIG_COMMENTS_ON_PAGE] = 10;
     $this->configs[self::CONFIG_MB_COMMENTS_ON_PAGE] = 3;
     $this->configs[self::CONFIG_MB_COMMENTS_COUNT_TO_LOAD] = 10;
     //$this->configs[self::CONFIG_ALLOWED_TAGS] = array('a', 'b', 'i', 'span', 'u', 'strong', 'br');
     //$this->configs[self::CONFIG_ALLOWED_ATTRS] = array('style', 'href');
 }
Example #3
0
 public function isDuplicateComment($groupId, $data)
 {
     $commentDao = BOL_CommentDao::getInstance();
     $entityDao = BOL_CommentEntityDao::getInstance();
     $query = "SELECT COUNT(*) FROM " . $commentDao->getTableName() . " a," . $entityDao->getTableName() . " b\n                  WHERE a.message = '" . addslashes($data) . "'\n                    AND b.entityId = " . $groupId . "\n                    AND b.id = a.commentEntityId                   \n                    AND b.entityType = 'groups_wal'\n                    AND b.pluginKey = 'groups'";
     $count = $this->dbo->queryForColumn($query);
     if ($count > 0) {
         return true;
     } else {
         return false;
     }
 }
Example #4
0
 public function findUserPostCommentList($userId, $first, $count)
 {
     if ($first < 0) {
         $first = 0;
     }
     if ($count < 0) {
         $count = 1;
     }
     $query = "\n\t\tSELECT `c`.*, `ce`.`entityId`\n\t\tFROM `{$this->getTableName()}` as `p`\n\t\tINNER JOIN `" . BOL_CommentEntityDao::getInstance()->getTableName() . "` as `ce`\n\t\t\tON( `p`.`id` = `ce`.`entityId` and `entityType` = 'blog-post' )\n\t\tINNER JOIN `" . BOL_CommentDao::getInstance()->getTableName() . "` as `c`\n\t\t\tON( `ce`.`id` = `c`.`commentEntityId` )\n\n\t\tWHERE `p`.`authorId` = ? AND `p`.`isDraft` = 0\n\t\tORDER BY `c`.`createStamp` DESC\n\t\tLIMIT ?, ?\n\t\t";
     return $this->dbo->queryForList($query, array($userId, $first, $count));
 }
Example #5
0
 public function findBatchCommentsList($entities)
 {
     if (empty($entities)) {
         return array();
     }
     $queryParts = array();
     $queryParams = array();
     $genId = 1;
     foreach ($entities as $entity) {
         $queryParts[] = " SELECT * FROM ( SELECT `c`.*, `ce`.`entityType`, `ce`.`entityId` FROM `" . $this->getTableName() . "` AS `c`\n\t\t\tLEFT JOIN `" . BOL_CommentEntityDao::getInstance()->getTableName() . "` AS `ce` ON ( `c`.`" . self::COMMENT_ENTITY_ID . "` = `ce`.`id` )\n\t\t\tWHERE `ce`.`" . BOL_CommentEntityDao::ENTITY_TYPE . "` = ? AND `ce`.`" . BOL_CommentEntityDao::ENTITY_ID . "` = ?\n\t\t\tORDER BY `" . self::CREATE_STAMP . "` DESC\n\t\t\tLIMIT 0, ? ) AS `al" . $genId++ . "` " . PHP_EOL;
         $queryParams[] = $entity['entityType'];
         $queryParams[] = $entity['entityId'];
         $queryParams[] = (int) $entity['countOnPage'];
     }
     $query = implode(" UNION ALL ", $queryParts);
     return $this->dbo->queryForObjectList($query, $this->getDtoClassName(), $queryParams);
 }
Example #6
0
 public function countPopularGoals()
 {
     $sql = "SELECT COUNT(*) FROM `" . $this->getTableName() . "` AS `g`\n            LEFT JOIN `" . BOL_CommentEntityDao::getInstance()->getTableName() . "` AS `ce` ON ( `g`.`id` = `ce`.`entityId` AND `entityType` = 'ocsfundraising_project' )\n            LEFT JOIN `" . BOL_CommentDao::getInstance()->getTableName() . "` AS `c` ON (`ce`.`id` = `c`.`commentEntityId`)\n            ";
     return $this->dbo->queryForColumn($sql);
 }