Exemplo n.º 1
0
    /**
     * Получаем массив id топиков удовлетворяющих фильтру
     * @param	array		параметры фильтра array(
     * 				'eq' => array('fieldName' => val) //Значение поля равно
     * 				'more' => array('fieldName' => val) //Значение поля больше чем
     * 				'less' => array('fieldName' => val) //Значение поля меньше чем
     *				'in' => array('fieldName' => array(val)) //Значение поля принадлежит множеству
     * 												)
     * @param	array(поле=>направление для сортировки)
     * @param	array('iPage', 'iElementsPerPage') параметры для браузера страниц
     * @return	array		массив id
     */
    public function GetTopicsByFilter($aFilter, $aOrder, &$iCount = 0, $aPaging = null)
    {
        if (isset($aFilter['eq'])) {
            $aFilterEq['eq'] = $aFilter['eq'];
            $sWhere = PluginLib_ModuleMapper::BuildFilter($aFilterEq, 't');
        }
        if (isset($aFilter['in'])) {
            $aFilterIn['in'] = $aFilter['in'];
            $sWhere .= PluginLib_ModuleMapper::BuildFilter($aFilterIn, 'b');
        }
        $sOrder = PluginLib_ModuleMapper::BuildOrder($aOrder, 't');
        if ($aPaging !== null) {
            $sLimit = PluginLib_ModuleMapper::BuildLimit($aPaging);
        } else {
            $sLimit = '';
        }
        $sql = 'SELECT 
						t.topic_id
					FROM 
						' . Config::Get('db.table.topic') . ' as t, 
						' . Config::Get('db.table.blog') . ' as b
					WHERE t.blog_id=b.blog_id
						' . $sWhere . ' 
						' . $sOrder . '
						' . $sLimit;
        $aTopics = array();
        if ($aRows = $this->oDb->selectPage($iCount, $sql)) {
            foreach ($aRows as $aTopic) {
                $aTopics[] = $aTopic['topic_id'];
            }
        }
        return $aTopics;
    }
Exemplo n.º 2
0
    /**
     * Получаем число блогов удовлетворяющих фильтру
     * 
     * @param	array		параметры фильтра array(
     * 											'more' => array('fieldName' => 'value'),
     * 											'less' => ...,
     * 											'in' => ...
     * 										)
     * @return	int
     */
    public function GetCountBlogsByFilter($aFilter)
    {
        $sWhere = PluginLib_ModuleMapper::BuildFilter($aFilter, 'b');
        $sql = 'SELECT 
						COUNT(b.blog_id) as blogs_count
					FROM 
						' . Config::Get('db.table.blog') . ' as b
					WHERE 1 = 1
						' . $sWhere;
        if ($aRow = $this->oDb->selectRow($sql)) {
            return $aRow['blogs_count'];
        }
        return false;
    }
Exemplo n.º 3
0
    /**
     * Получаем массив id топиков удовлетворяющих фильтру
     * 
     * @param	array		параметры фильтра array(
     * 											'more' => array('fieldName' => 'value'),
     * 											'less' => ...,
     * 											'in' => ...
     * 										)
     * @param	bool		доступен ли плагин для проверки на доступ к топикам
     * @return	array		массив id
     */
    public function GetTopicsForBlogosphereByFilter($aFilter)
    {
        $sWhere = PluginLib_ModuleMapper::BuildFilter($aFilter, 't');
        //фильтрация по уровню доступа к топикам
        if (PluginLib_ModulePlugin::IsPluginAvailable('accesstotopic') && !$aFilter['oUser']->isAdministrator()) {
            $sWhere .= ' AND ' . PluginAccesstotopic_ModuleAccess::GetAccessWhereStatment($aFilter['oUser']->getId());
        }
        $sql = 'SELECT 
						t.topic_id
					FROM 
						' . Config::Get('db.table.topic') . ' as t
					WHERE 
						1 = 1
						' . $sWhere;
        $aTopics = array();
        if ($aRows = $this->oDb->select($sql)) {
            foreach ($aRows as $aTopic) {
                $aTopics[] = $aTopic['topic_id'];
            }
        }
        return $aTopics;
    }
Exemplo n.º 4
0
    /**
     * Получаем массив id топиков удовлетворяющих фильтру
     * 
     * @param	array		параметры фильтра 'aUserFilter' array(
     * 												'more' => array('fieldName' => 'value'),
     * 												'less' => ...,
     * 												'in' => ...
     * 												...
     * 											),
     * 											'aTopicFilter' => (...)
     * @param	array		(поле=>направление для сортировки)
     * @param	array		параметры для браузера страниц ('iPage', 'iElementsPerPage')
     * @return	array		массив id
     */
    public function GetTopicsByFilters($aFilters, $aOrder, $aPaging)
    {
        if (isset($aFilters['aUserFilter'])) {
            $sUserWhere = PluginLib_ModuleMapper::BuildFilter($aFilters['aUserFilter'], 'u');
        } else {
            $sUserWhere = '';
        }
        if (isset($aFilters['aTopicFilter'])) {
            $sTopicWhere = PluginLib_ModuleMapper::BuildFilter($aFilters['aTopicFilter'], 't');
        } else {
            $sTopicWhere = '';
        }
        $oUserCurrent = PluginLib_ModuleUser::GetUserCurrent();
        if (!$oUserCurrent->isAdministrator() && PluginLib_ModulePlugin::IsPluginAvailable('accesstotopic')) {
            $sTopicWhere .= ' AND ' . PluginAccesstotopic_ModuleAccess::GetAccessWhereStatment($oUserCurrent->getId());
        }
        $sOrder = PluginLib_ModuleMapper::BuildOrder($aOrder, 't');
        $sLimit = PluginLib_ModuleMapper::BuildLimit($aPaging);
        $sql = 'SELECT 
						t.topic_id
					FROM 
						' . Config::Get('db.table.user') . ' as u,
						' . Config::Get('db.table.topic') . ' as t
					WHERE t.user_id = u.user_id
						' . $sUserWhere . '
						' . $sTopicWhere . '
						' . $sOrder . '
						' . $sLimit;
        $aTopics = array();
        if ($aRows = $this->oDb->select($sql)) {
            foreach ($aRows as $aTopic) {
                $aTopics[] = $aTopic['topic_id'];
            }
        }
        return $aTopics;
    }