/**
  * Получить комменты по юзеру
  *
  * @param  int $sId ID пользователя
  * @param  string $sTargetType Тип владельца комментария
  * @param  int $iPage Номер страницы
  * @param  int $iPerPage Количество элементов на страницу
  * @return array
  */
 public function GetCommentsByUserId($sId, $sTargetType, $iPage, $iPerPage)
 {
     /**
      * Исключаем из выборки идентификаторы закрытых блогов
      */
     $aCloseBlogs = $this->oUserCurrent && $sId == $this->oUserCurrent->getId() ? array() : $this->Blog_GetInaccessibleBlogsByUser();
     $s = serialize($aCloseBlogs);
     if (false === ($data = $this->Cache_Get("comment_user_{$sId}_{$sTargetType}_{$iPage}_{$iPerPage}_{$s}"))) {
         $data = array('collection' => $this->oMapper->GetCommentsByUserId($sId, $sTargetType, $iCount, $iPage, $iPerPage, array(), $aCloseBlogs), 'count' => $iCount);
         $this->Cache_Set($data, "comment_user_{$sId}_{$sTargetType}_{$iPage}_{$iPerPage}_{$s}", array("comment_new_user_{$sId}_{$sTargetType}", "comment_update_status_{$sTargetType}"), 60 * 60 * 24 * 2);
     }
     $data['collection'] = $this->GetCommentsAdditionalData($data['collection']);
     return $data;
 }
Exemple #2
0
 /**
  * Получить комменты по юзеру
  *
  * @param  int    $iUserId        ID пользователя
  * @param  string $sTargetType    Тип владельца комментария
  * @param  int    $iPage          Номер страницы
  * @param  int    $iPerPage       Количество элементов на страницу
  *
  * @return array
  */
 public function GetCommentsByUserId($iUserId, $sTargetType, $iPage, $iPerPage)
 {
     /**
      * Исключаем из выборки идентификаторы закрытых блогов
      */
     $aCloseBlogs = $this->oUserCurrent && $iUserId == $this->oUserCurrent->getId() ? array() : E::ModuleBlog()->GetInaccessibleBlogsByUser();
     $sCacheKey = "comment_user_{$iUserId}_{$sTargetType}_{$iPage}_{$iPerPage}_" . serialize($aCloseBlogs);
     if (false === ($data = E::ModuleCache()->Get($sCacheKey))) {
         $data = array('collection' => $this->oMapper->GetCommentsByUserId($iUserId, $sTargetType, $iCount, $iPage, $iPerPage, array(), $aCloseBlogs), 'count' => $iCount);
         E::ModuleCache()->Set($data, $sCacheKey, array("comment_new_user_{$iUserId}_{$sTargetType}", "comment_update_status_{$sTargetType}"), 'P2D');
     }
     if ($data['collection']) {
         $data['collection'] = $this->GetCommentsAdditionalData($data['collection']);
     }
     return $data;
 }