Ejemplo n.º 1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return BOL_CommentDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Ejemplo n.º 2
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;
     }
 }
Ejemplo n.º 3
0
 public function findBatchCommentsData(array $items)
 {
     if (empty($items)) {
         return array();
     }
     if (OW::getUser()->isAuthenticated()) {
         $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
     }
     $resultArray = array('_static' => array());
     $creditsParams = array();
     foreach ($items as $item) {
         if (!isset($resultArray[$item['entityType']])) {
             $resultArray[$item['entityType']] = array();
         }
         $resultArray[$item['entityType']][$item['entityId']] = array('commentsCount' => 0, 'countOnPage' => $item['countOnPage'], 'commentsList' => array());
         $creditsParams[$item['pluginKey']] = array('add_comment');
     }
     if (OW::getUser()->isAuthenticated()) {
         $userInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
     }
     // get comments count
     $result = $this->commentDao->findBatchCommentsCount($items);
     $entitiesForList = array();
     foreach ($result as $item) {
         $resultArray[$item['entityType']][$item['entityId']]['commentsCount'] = (int) $item['count'];
         $entitiesForList[] = array('entityType' => $item['entityType'], 'entityId' => $item['entityId'], 'countOnPage' => $resultArray[$item['entityType']][$item['entityId']]['countOnPage']);
     }
     // get comments list
     $result = $this->commentDao->findBatchCommentsList($entitiesForList);
     $batchUserIdList = array();
     foreach ($result as $item) {
         $resultArray[$item->entityType][$item->entityId]['commentsList'][] = $item;
         $batchUserIdList[] = $item->getUserId();
     }
     $resultArray['_static']['avatars'] = BOL_AvatarService::getInstance()->getDataForUserAvatars(array_unique($batchUserIdList));
     if (OW::getUser()->isAuthenticated()) {
         $resultArray['_static']['currentUserInfo'] = $currentUserInfo[OW::getUser()->getId()];
     }
     $eventParams = array('actionList' => $creditsParams);
     $resultArray['_static']['credits'] = OW::getEventManager()->call('usercredits.batch_check_balance_for_action_list', $eventParams);
     return $resultArray;
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 5
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);
 }