public function getAccessLevelName() { $sLevelName = array_search($this->getAccessLevel(), PluginAccesstotopic_ModuleAccess::GetPersonalTopicAccessLevels()); if ($sLevelName !== false) { return $sLevelName; } $sLevelName = array_search($this->getAccessLevel(), PluginAccesstotopic_ModuleAccess::GetCollectiveTopicAccessLevels()); return $sLevelName !== false ? $sLevelName : ''; }
public function AddAccessLevelToTopic($data) { if (getRequest('access_level', null) !== null) { $sAccessLevelName = strtoupper(substr(getRequest('access_level'), 0, 20)); if ($data['oBlog']->getType() == 'personal') { $aAccessLevel = PluginAccesstotopic_ModuleAccess::GetPersonalTopicAccessLevels(); $iAccessLevelNum = $aAccessLevel[$sAccessLevelName] ? $aAccessLevel[$sAccessLevelName] : $aAccessLevel['FOR_ALL']; } else { $aAccessLevel = PluginAccesstotopic_ModuleAccess::GetCollectiveTopicAccessLevels(); $iAccessLevelNum = $aAccessLevel[$sAccessLevelName] ? $aAccessLevel[$sAccessLevelName] : $aAccessLevel['FOR_ALL']; } } $data['oTopic']->setAccessLevel($iAccessLevelNum); }
public function getTopicIDsForMyStuff($oUser, $aFilter = array()) { $sql = 'SELECT user_to FROM ' . Config::Get('db.table.friend') . ' WHERE user_from = ?d AND (status_from = 1 OR status_from = 2) UNION SELECT user_from FROM ' . Config::Get('db.table.friend') . ' WHERE user_to = ?d AND (status_to = 1 OR status_to = 2)'; //first, get a list of all my friends $friends = $this->oDb->selectCol($sql, $oUser->getId(), $oUser->getId()); dump('My friends are: ' . print_r($friends, true)); //now get a list of topics my friends commented $oUserCurrent = PluginLib_ModuleUser::GetUserCurrent(); $sAccessWhere = !$oUserCurrent->isAdministrator() && PluginLib_ModulePlugin::IsPluginAvailable('accesstotopic') ? ' AND ' . PluginAccesstotopic_ModuleAccess::GetAccessWhereStatment($oUserCurrent->getId()) : ' '; $sDateWhere = ''; if (isset($aFilter['more']['topic_add_date']) && isset($aFilter['less']['topic_add_date'])) { $sDateWhere = ' AND tc.created >= "' . mysql_real_escape_string($aFilter['more']['topic_add_date']) . '" AND ' . 'tc.created <= "' . mysql_real_escape_string($aFilter['less']['topic_add_date']) . '"'; } $sql = 'SELECT tc.topic_id FROM ' . Config::Get('plugin.mystuff.table.topic_commented') . ' as tc, ' . Config::Get('db.table.topic') . ' as t WHERE tc.user_id IN (?a) AND tc.topic_id = t.topic_id ' . $sDateWhere . ' ' . $sAccessWhere . ' '; if ($topics = $this->oDb->selectCol($sql, $friends)) { $topics = array_unique($topics); dump('My Stuff Topics are: ' . print_r($topics, true)); return $topics; } //fallback return array(); }
/** * Получаем массив 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; }
/** * Получаем массив 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; }
public function GetAllTopics($aFilter) { $oUserCurrent = PluginLib_ModuleUser::GetUserCurrent(); $sAccessWhere = $oUserCurrent->isAdministrator() ? '' : ' AND ' . PluginAccesstotopic_ModuleAccess::GetAccessWhereStatment($oUserCurrent->getId()); $sWhere = $this->buildFilter($aFilter); $sql = 'SELECT t.topic_id FROM ' . Config::Get('db.table.topic') . ' as t, ' . Config::Get('db.table.blog') . ' as b WHERE 1=1 ' . $sWhere . ' ' . $sAccessWhere . ' AND t.blog_id=b.blog_id ORDER by t.topic_id desc'; $aTopics = array(); if ($aRows = $this->oDb->select($sql)) { foreach ($aRows as $aTopic) { $aTopics[] = $aTopic['topic_id']; } } return $aTopics; }
/** * Выводим HTML * */ public function AddSelectToChangeAccessLevel() { $this->Viewer_Assign('personalAccessLevels', PluginAccesstotopic_ModuleAccess::GetPersonalTopicAccessLevels()); $this->Viewer_Assign('collectiveAccessLevels', PluginAccesstotopic_ModuleAccess::GetCollectiveTopicAccessLevels()); return $this->Viewer_Fetch(Plugin::GetTemplatePath(__CLASS__) . 'SelectToChangeAccessLevel.tpl'); }