/**
  * Список полей типа контента
  *
  * @param  array $aFilter    Фильтр
  *
  * @return ModuleTopic_EntityField[]
  */
 public function getContentFields($aFilter)
 {
     $sql = "SELECT\n            cf.field_id AS ARRAY_KEY, cf.*\n        FROM\n            ?_content_field AS cf\n        WHERE\n            1=1\n            { AND cf.content_id = ?d }\n            { AND cf.field_unique_name = ? }\n        ORDER BY cf.field_sort DESC\n        ";
     $aResult = array();
     $aRows = $this->oDb->select($sql, isset($aFilter['content_id']) ? $aFilter['content_id'] : DBSIMPLE_SKIP, empty($aFilter['field_unique_name']) ? DBSIMPLE_SKIP : $aFilter['field_unique_name']);
     if ($aRows) {
         $aResult = E::GetEntityRows('Topic_Field', $aRows);
     }
     return $aResult;
 }
Beispiel #2
0
 /**
  * Получить список голосований по списку айдишников
  *
  * @param array  $aTargetId   - Список ID владельцев
  * @param string $sTargetType - Тип владельца
  * @param int    $iUserId     - ID пользователя
  *
  * @return array
  */
 public function GetVoteByArray($aTargetId, $sTargetType, $iUserId)
 {
     if (!is_array($aTargetId) || count($aTargetId) == 0) {
         return array();
     }
     $sql = "SELECT\n\t\t\t\t\t*\n\t\t\t\tFROM \n\t\t\t\t\t?_vote\n\t\t\t\tWHERE\n\t\t\t\t\ttarget_id IN(?a)\n\t\t\t\t\tAND\n\t\t\t\t\ttarget_type = ?\n\t\t\t\t\tAND\n\t\t\t\t\tuser_voter_id = ?d ";
     $aVotes = array();
     if ($aRows = $this->oDb->select($sql, $aTargetId, $sTargetType, $iUserId)) {
         $aVotes = E::GetEntityRows('Vote', $aRows);
     }
     return $aVotes;
 }
 /**
  * Возвращает список тегов по фильтру
  *
  * @param array $aFilter      Фильтр
  * @param array $aOrder       Сортировка
  * @param int   $iCount       Возвращает количество элементов
  * @param int   $iCurrPage    Номер страницы
  * @param int   $iPerPage     Количество элементов на страницу
  *
  * @return array
  */
 public function GetTags($aFilter, $aOrder, &$iCount, $iCurrPage, $iPerPage)
 {
     $aOrderAllow = array('target_id', 'user_id', 'is_user');
     $sOrder = '';
     foreach ($aOrder as $key => $value) {
         if (!in_array($key, $aOrderAllow)) {
             unset($aOrder[$key]);
         } elseif (in_array($value, array('asc', 'desc'))) {
             $sOrder .= " {$key} {$value},";
         }
     }
     $sOrder = trim($sOrder, ',');
     if ($sOrder == '') {
         $sOrder = ' target_id DESC ';
     }
     $sql = "SELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\t?_favourite_tag\n\t\t\t\tWHERE\n\t\t\t\t\t1 = 1\n\t\t\t\t\t{ AND user_id = ?d }\n\t\t\t\t\t{ AND target_type = ? }\n\t\t\t\t\t{ AND target_id = ?d }\n\t\t\t\t\t{ AND is_user = ?d }\n\t\t\t\t\t{ AND text = ? }\n\t\t\t\tORDER by {$sOrder}\n\t\t\t\tLIMIT ?d, ?d ;\n\t\t\t\t\t";
     $aResult = array();
     $aRows = $this->oDb->selectPage($iCount, $sql, isset($aFilter['user_id']) ? $aFilter['user_id'] : DBSIMPLE_SKIP, isset($aFilter['target_type']) ? $aFilter['target_type'] : DBSIMPLE_SKIP, isset($aFilter['target_id']) ? $aFilter['target_id'] : DBSIMPLE_SKIP, isset($aFilter['is_user']) ? $aFilter['is_user'] : DBSIMPLE_SKIP, isset($aFilter['text']) ? $aFilter['text'] : DBSIMPLE_SKIP, ($iCurrPage - 1) * $iPerPage, $iPerPage);
     if ($aRows) {
         $aResult = E::GetEntityRows('ModuleFavourite_EntityTag', $aRows);
     }
     return $aResult;
 }
Beispiel #4
0
 /**
  * Возвращает информацию о категориях изображений пользователя
  * с разбивкой по типу контента
  *
  * @param int $iUserId
  *
  * @return array
  */
 public function GetTopicsImageCategory($iUserId)
 {
     $aFilter = array('user_id' => $iUserId, 'mresource_type' => ModuleMresource::TYPE_IMAGE | ModuleMresource::TYPE_PHOTO | ModuleMresource::TYPE_PHOTO_PRIMARY, 'target_type' => array('photoset', 'topic'));
     if (E::IsUser() && E::User() !== $iUserId) {
         // Если текущий юзер не совпадает с запрашиваемым, то получаем список доступных блогов
         $aFilter['blogs_id'] = E::ModuleBlog()->GetAccessibleBlogsByUser(E::User());
         // И топики должны быть опубликованы
         $aFilter['topic_publish'] = 1;
     }
     if (!E::IsUser()) {
         // Если юзер не авторизован, то считаем все доступные для индексации топики
         $aFilter['topic_index_ignore'] = 0;
     }
     $aData = $this->oMapper->GetCountImagesByTopicType($aFilter);
     if ($aData) {
         foreach ($aData as $xIndex => $aRow) {
             $sLabelKey = 'target_type_' . $aRow['id'];
             if (($sLabel = E::ModuleLang()->Get($sLabelKey)) == mb_strtoupper($sLabelKey)) {
                 /** @var ModuleTopic_EntityContentType $oContentType */
                 $oContentType = E::ModuleTopic()->GetContentTypeByUrl($aRow['id']);
                 if ($oContentType) {
                     $sLabel = $oContentType->getContentTitleDecl();
                 }
             }
             $aData[$xIndex]['label'] = E::ModuleLang()->Get($sLabel);
         }
         $aResult = E::GetEntityRows('Mresource_MresourceCategory', $aData);
     } else {
         $aResult = array();
     }
     return $aResult;
 }
 /**
  * Returns media resources' relation entities by target
  *
  * @param string|array  $xTargetType
  * @param int|array $xTargetId
  * @param int|array $xUserId
  *
  * @return ModuleMresource_EntityMresourceRel[]
  */
 public function GetMresourcesRelByTargetAndUser($xTargetType, $xTargetId, $xUserId)
 {
     if (is_array($xTargetType)) {
         $aCriteria = array('filter' => array('target_types' => $xTargetType));
     } else {
         $aCriteria = array('filter' => array('target_type' => $xTargetType));
     }
     if (!is_null($xTargetId)) {
         $aCriteria['filter']['target_id'] = $xTargetId;
     }
     if (!is_null($xUserId)) {
         $aCriteria['filter']['user_id'] = $xUserId;
     }
     $aData = $this->_getMresourcesRelByCriteria($aCriteria);
     $aResult = array();
     if ($aData['data']) {
         $aResult = E::GetEntityRows('Mresource_MresourceRel', $aData['data']);
     }
     return $aResult;
 }
Beispiel #6
0
 /**
  * Возвращает список полей по списку id топиков
  *
  * @param array $aTargetId    Список ID топиков
  *
  * @return ModuleTopic_EntityContentValues[]
  *
  * @TODO рефакторинг + solid
  */
 public function GetTopicValuesByArrayId($aTargetId)
 {
     if (!is_array($aTargetId) || count($aTargetId) == 0) {
         return array();
     }
     $sql = "SELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\t?_content_values\n\t\t\t\tWHERE\n\t\t\t\t\ttarget_id IN(?a)\n\t\t\t\t\tAND\n\t\t\t\t\ttarget_type = 'topic'\n\t\t\t\t";
     $aFields = array();
     if ($aRows = $this->oDb->select($sql, $aTargetId)) {
         $aFields = E::GetEntityRows('Topic_ContentValues', $aRows);
     }
     return $aFields;
 }
Beispiel #7
0
    /**
     * Чтение событий
     *
     * @param array      $aEventTypes    Список типов событий
     * @param array|null $aUsersList     Список пользователей, чьи события читать
     * @param int        $iCount         Количество
     * @param int        $iFromId        ID события с которого начинать выборку
     *
     * @return array
     */
    public function Read($aEventTypes, $aUsersList, $iCount, $iFromId)
    {
        $sql = 'SELECT * FROM ?_stream_event
				WHERE
					event_type IN (?a) 
					{ AND user_id IN (?a) }
					AND publish = 1
					{ AND id < ?d }	
				ORDER BY id DESC
				{ LIMIT 0,?d }';
        $aResult = array();
        $aRows = $this->oDb->select($sql, $aEventTypes, (!is_null($aUsersList) and count($aUsersList)) ? $aUsersList : DBSIMPLE_SKIP, !is_null($iFromId) ? $iFromId : DBSIMPLE_SKIP, !is_null($iCount) ? $iCount : DBSIMPLE_SKIP);
        if ($aRows) {
            $aResult = E::GetEntityRows('Stream_Event', $aRows);
        }
        return $aResult;
    }
Beispiel #8
0
 /**
  * Возвращает массив пользователей, участвующих в разговоре
  *
  * @param  int $iTalkId    ID разговора
  *
  * @return array
  */
 public function GetTalkUsers($iTalkId)
 {
     $sql = "\n\t\t\tSELECT \n\t\t\t\tt.* \n\t\t\tFROM \n\t\t\t\t?_talk_user as t\n\t\t\tWHERE\n\t\t\t\ttalk_id = ? \n\t\t\t";
     $aResult = array();
     if ($aRows = $this->oDb->select($sql, $iTalkId)) {
         $aResult = E::GetEntityRows('Talk_TalkUser', $aRows);
     }
     return $aResult;
 }
 /**
  * Возвращает список треков по фильтру
  *
  * @param array $aFilter      Фильтр
  * @param array $aOrder       Сортировка
  * @param int   $iCount       Возвращает общее количество элементов
  * @param int   $iCurrPage    Номер страницы
  * @param int   $iPerPage     Количество элементов на страницу
  *
  * @return array
  */
 public function GetTracks($aFilter, $aOrder, &$iCount, $iCurrPage, $iPerPage)
 {
     $aOrderAllow = array('id', 'date_add', 'status');
     $sOrder = '';
     foreach ($aOrder as $key => $value) {
         if (!in_array($key, $aOrderAllow)) {
             unset($aOrder[$key]);
         } elseif (in_array($value, array('asc', 'desc'))) {
             $sOrder .= " {$key} {$value},";
         }
     }
     $sOrder = trim($sOrder, ',');
     if ($sOrder == '') {
         $sOrder = ' id desc ';
     }
     if (isset($aFilter['exclude_mail']) and !is_array($aFilter['exclude_mail'])) {
         $aFilter['exclude_mail'] = array($aFilter['exclude_mail']);
     }
     $sql = "SELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\t?_track trc\n\t\t\t\tWHERE\n\t\t\t\t\t1 = 1\n\t\t\t\t\t{ AND trc.target_type = ? }\n\t\t\t\t\t{ AND trc.target_id = ?d }\n\t\t\t\t\t{ AND trc.user_id = ?d }\n\t\t\t\t\t{ AND trc.user_id not IN (?a) }\n\t\t\t\t\t{ AND trc.`key` = ? }\n\t\t\t\t\t{ AND trc.status = ?d }\n\t\t\t\t\t{ AND exists   (  SELECT ?d\n\t\t\t\t\t                  FROM   ?_topic_read as tr,\n\t\t\t\t\t                         ?_topic as t\n\t\t\t\t\t                  WHERE   t.topic_id = trc.target_id\n\t\t\t\t\t                  AND t.topic_id = tr.topic_id\n\t\t\t\t\t                  AND (t.topic_count_comment > tr.comment_count_last)\n\t\t\t\t\t                  AND  tr.user_id = trc.user_id\n\t\t\t\t\t                  ) }\n\t\t\t\tORDER by {$sOrder}\n\t\t\t\tLIMIT ?d, ?d ;\n\t\t\t\t\t";
     $aResult = array();
     $aRows = $this->oDb->selectPage($iCount, $sql, isset($aFilter['target_type']) ? $aFilter['target_type'] : DBSIMPLE_SKIP, isset($aFilter['target_id']) ? $aFilter['target_id'] : DBSIMPLE_SKIP, isset($aFilter['user_id']) ? $aFilter['user_id'] : DBSIMPLE_SKIP, (isset($aFilter['exclude_user']) and count($aFilter['exclude_user'])) ? $aFilter['exclude_user'] : DBSIMPLE_SKIP, isset($aFilter['key']) ? $aFilter['key'] : DBSIMPLE_SKIP, isset($aFilter['status']) ? $aFilter['status'] : DBSIMPLE_SKIP, (isset($aFilter['only_new']) and $aFilter['only_new']) ? 1 : DBSIMPLE_SKIP, ($iCurrPage - 1) * $iPerPage, $iPerPage);
     if ($aRows) {
         $aResult = E::GetEntityRows('ModuleSubscribe_EntityTrack', $aRows);
     }
     return $aResult;
 }
Beispiel #10
0
 /**
  * Получение записей по ID, без дополнительных данных
  *
  * @param array $aMessagesId    Список ID сообщений
  *
  * @return array
  */
 public function GetWallsByArrayId($aMessagesId)
 {
     if (!is_array($aMessagesId) || count($aMessagesId) == 0) {
         return array();
     }
     $nLimit = sizeof($aMessagesId);
     $sql = "\n            SELECT\n                w.id AS ARRAY_KEY,\n                w.*\n            FROM ?_wall AS w\n            WHERE\n                w.id IN(?a)\n            LIMIT {$nLimit}";
     $aResult = array();
     if ($aRows = $this->oDb->select($sql, $aMessagesId)) {
         $aResult = E::GetEntityRows('Wall', $aRows, $aMessagesId);
     }
     return $aResult;
 }
Beispiel #11
0
 /**
  * Возвращает список стран по фильтру
  *
  * @param array $aFilter      Фильтр
  * @param array $aOrder       Сортировка
  * @param int   $iCount       Возвращает количество элементов
  * @param int   $iCurrPage    Номер страницы
  * @param int   $iPerPage     Количество элементов на страницу
  *
  * @return array
  */
 public function GetCities($aFilter, $aOrder, &$iCount, $iCurrPage, $iPerPage)
 {
     $aOrderAllow = array('id', 'name_ru', 'name_en', 'sort', 'country_id', 'region_id');
     $sOrder = '';
     foreach ($aOrder as $key => $value) {
         if (!in_array($key, $aOrderAllow)) {
             unset($aOrder[$key]);
         } elseif (in_array($value, array('asc', 'desc'))) {
             $sOrder .= " {$key} {$value},";
         }
     }
     $sOrder = trim($sOrder, ',');
     if ($sOrder == '') {
         $sOrder = ' id desc ';
     }
     if (isset($aFilter['country_id']) && !is_array($aFilter['country_id'])) {
         $aFilter['country_id'] = array($aFilter['country_id']);
     }
     if (isset($aFilter['region_id']) && !is_array($aFilter['region_id'])) {
         $aFilter['region_id'] = array($aFilter['region_id']);
     }
     $sql = "SELECT\n\t\t\t\t\tgc.id AS ARRAY_KEY, gc.*\n\t\t\t\tFROM\n\t\t\t\t\t?_geo_city as gc\n\t\t\t\tWHERE\n\t\t\t\t\t1 = 1\n\t\t\t\t\t{ AND id = ?d }\n\t\t\t\t\t{ AND id IN (?a) }\n\t\t\t\t\t{ AND name_ru = ? }\n\t\t\t\t\t{ AND name_ru LIKE ? }\n\t\t\t\t\t{ AND name_en = ? }\n\t\t\t\t\t{ AND name_en LIKE ? }\n\t\t\t\t\t{ AND country_id IN ( ?a ) }\n\t\t\t\t\t{ AND region_id IN ( ?a ) }\n\t\t\t\tORDER BY {$sOrder}\n\t\t\t\tLIMIT ?d, ?d ;\n\t\t\t\t\t";
     $aResult = array();
     $aRows = $this->oDb->selectPage($iCount, $sql, isset($aFilter['id']) && !is_array($aFilter['id']) ? $aFilter['id'] : DBSIMPLE_SKIP, isset($aFilter['id']) && is_array($aFilter['id']) ? $aFilter['id'] : DBSIMPLE_SKIP, isset($aFilter['name_ru']) ? $aFilter['name_ru'] : DBSIMPLE_SKIP, isset($aFilter['name_ru_like']) ? $aFilter['name_ru_like'] : DBSIMPLE_SKIP, isset($aFilter['name_en']) ? $aFilter['name_en'] : DBSIMPLE_SKIP, isset($aFilter['name_en_like']) ? $aFilter['name_en_like'] : DBSIMPLE_SKIP, isset($aFilter['country_id']) && count($aFilter['country_id']) ? $aFilter['country_id'] : DBSIMPLE_SKIP, isset($aFilter['region_id']) && count($aFilter['region_id']) ? $aFilter['region_id'] : DBSIMPLE_SKIP, ($iCurrPage - 1) * $iPerPage, $iPerPage);
     if ($aRows) {
         $aResult = E::GetEntityRows('ModuleGeo_EntityCity', $aRows);
     }
     return $aResult;
 }
Beispiel #12
0
 /**
  * List of active pages
  *
  * @param integer $iCount
  * @param integer $iCurrPage
  * @param integer $iPerPage
  *
  * @return array
  */
 public function getListOfActivePages(&$iCount, $iCurrPage, $iPerPage)
 {
     $sql = 'SELECT
                 `page`.*
             FROM
                 ?_page AS `page`
             WHERE
                 `page`.`page_active` = 1
             ORDER BY
                 page_sort DESC, `page`.`page_id` ASC
             LIMIT
                 ?d, ?d
             ';
     $aResult = array();
     if ($aRows = $this->oDb->selectPage($iCount, $sql, ($iCurrPage - 1) * $iPerPage, $iPerPage)) {
         $aResult = E::GetEntityRows('Page', $aRows);
     }
     return $aResult;
 }
Beispiel #13
0
 /**
  * Получает массив заданий на публикацию из базы с указанным количественным ограничением (выборка FIFO)
  *
  * @param  int    $iLimit    Количество
  *
  * @return array
  */
 public function GetTasks($iLimit)
 {
     $sql = "SELECT *\n\t\t\t\tFROM ?_notify_task\n\t\t\t\tORDER BY date_created ASC\n\t\t\t\tLIMIT ?d";
     $aResult = array();
     if ($aRows = $this->oDb->select($sql, $iLimit)) {
         $aResult = E::GetEntityRows('Notify_Task', $aRows);
     }
     return $aResult;
 }
Beispiel #14
0
 /**
  * Список комментов по ID
  *
  * @param array $aCommentsId    Список ID комментариев
  *
  * @return ModuleComment_EntityComment[]
  */
 public function GetCommentsByArrayId($aCommentsId)
 {
     if (!$aCommentsId) {
         return array();
     }
     if (!is_array($aCommentsId)) {
         $aCommentsId = array(intval($aCommentsId));
     }
     $iLimit = sizeof($aCommentsId);
     $sql = "\n            SELECT\n                c.comment_id AS ARRAY_KEYS,\n                c.*\n            FROM\n                ?_comment AS c\n            WHERE\n                c.comment_id IN(?a)\n            LIMIT {$iLimit}\n            ";
     $aComments = array();
     if ($aRows = $this->oDb->select($sql, $aCommentsId)) {
         $aComments = E::GetEntityRows('Comment', $aRows, $aCommentsId);
     }
     return $aComments;
 }
Beispiel #15
0
 /**
  * Возвращает массив тегов
  *
  * @param bool $bTextOnly
  * @return array
  */
 public function getTagsArray($bTextOnly = true)
 {
     if ($sTags = $this->getTags()) {
         if ($bTextOnly) {
             return explode(',', $sTags);
         }
         $aTexts = explode(',', $sTags);
         $aData = array();
         foreach ($aTexts as $nI => $sText) {
             $aData[] = array('topic_tag_id' => -$nI, 'topic_id' => $this->getId(), 'user_id' => $this->getUserId(), 'blog_id' => $this->getBlogId(), 'topic_tag_text' => $sText);
         }
         return E::GetEntityRows('Topic_TopicTag', $aData);
     }
     return array();
 }
Beispiel #16
0
 /**
  * Возвращает список заметок пользователя по ID целевых юзеров
  *
  * @param array $aArrayId    Список ID целевых пользователей
  * @param int   $nUserId     ID пользователя, кто оставлял заметки
  *
  * @return array
  */
 public function GetUserNotesByArrayUserId($aArrayId, $nUserId)
 {
     if (!is_array($aArrayId) || count($aArrayId) == 0) {
         return array();
     }
     $sql = "SELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\t?_user_note\n\t\t\t\tWHERE target_user_id IN (?a) AND user_id = ?d\n\t\t\t\t";
     $aRows = $this->oDb->select($sql, $aArrayId, $nUserId);
     $aResult = array();
     if ($aRows) {
         $aResult = E::GetEntityRows('ModuleUser_EntityNote', $aRows);
     }
     return $aResult;
 }
Beispiel #17
0
 /**
  * Статистка блогов
  *
  * @param $aExcludeTypes
  *
  * @return array
  */
 public function GetBlogsData($aExcludeTypes)
 {
     if (isset($aExcludeTypes) && !is_array($aExcludeTypes)) {
         $aExcludeTypes = array($aExcludeTypes);
     }
     $sql = "\n            SELECT\n                b.*,\n                SUM(t.topic_rating) as sum_rating\n            FROM\n                ?_blog as b,\n                ?_topic as t\n            WHERE\n                b.blog_id=t.blog_id\n                AND\n                t.topic_publish=1\n                AND\n                blog_type not IN (?a) \n            GROUP BY b.blog_id\n            ";
     $aBlogs = array();
     if ($aRows = $this->oDb->select($sql, $aExcludeTypes)) {
         $aBlogs = E::GetEntityRows('Blog', $aRows);
     }
     return $aBlogs;
 }