本文整理汇总了PHP中cmsCore::checkContentAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::checkContentAccess方法的具体用法?PHP cmsCore::checkContentAccess怎么用?PHP cmsCore::checkContentAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::checkContentAccess方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mod_menu
function mod_menu($mod, $cfg)
{
$inCore = cmsCore::getInstance();
$inUser = cmsUser::getInstance();
$menuid = $inCore->menuId();
$full_menu = $inCore->getMenuStruct();
$current_uri = '/' . $inCore->getUri();
if (!isset($cfg['menu'])) {
$menu = 'mainmenu';
} else {
$menu = $cfg['menu'];
}
if (!isset($cfg['show_home'])) {
$cfg['show_home'] = 1;
}
if (!isset($cfg['is_sub_menu'])) {
$cfg['is_sub_menu'] = 0;
}
// текущий пункт меню
$currentmenu = isset($full_menu[$menuid]) ? $full_menu[$menuid] : array();
// результирующий массив меню
$items = array();
// id корня меню если обычный вывод меню, $menuid если режим подменю
if ($cfg['is_sub_menu']) {
// в подменю не должно быть ссылки на главную
$cfg['show_home'] = 0;
// на главной или нет активного пункта меню
if ($menuid == 1 || !$currentmenu) {
return false;
}
foreach ($full_menu as $item) {
if ($item['NSLeft'] > $currentmenu['NSLeft'] && $item['NSRight'] < $currentmenu['NSRight'] && in_array($menu, $item['menu']) && ($item['is_lax'] || cmsCore::checkContentAccess($item['access_list'], false)) && $item['published']) {
$item['link'] = cmsUser::stringReplaceUserProperties($item['link']);
$item['title'] = cmsUser::stringReplaceUserProperties($item['title'], true);
$items[] = $item;
// массивы для сортировки
$nsl[] = $item['NSLeft'];
$ord[] = $item['ordering'];
}
}
} else {
foreach ($full_menu as $item) {
if (in_array($menu, $item['menu']) && ($item['is_lax'] || cmsCore::checkContentAccess($item['access_list'], false)) && $item['published']) {
$item['link'] = cmsUser::stringReplaceUserProperties($item['link']);
$item['title'] = cmsUser::stringReplaceUserProperties($item['title'], true);
$items[] = $item;
// массивы для сортировки
$nsl[] = $item['NSLeft'];
$ord[] = $item['ordering'];
}
}
}
if (!$items) {
return false;
}
// сортируем массив
array_multisort($nsl, SORT_ASC, $ord, SORT_ASC, $items);
cmsPage::initTemplate('modules', $cfg['tpl'])->assign('menuid', $menuid)->assign('currentmenu', $currentmenu)->assign('current_uri', $current_uri)->assign('menu', $menu)->assign('items', $items)->assign('last_level', 0)->assign('user_id', $inUser->id)->assign('is_admin', $inUser->is_admin)->assign('cfg', $cfg)->display($cfg['tpl']);
return true;
}
示例2: mod_menu
function mod_menu($module_id, $cfg)
{
$inCore = cmsCore::getInstance();
$inUser = cmsUser::getInstance();
$menuid = $inCore->menuId();
$full_menu = $inCore->getMenuStruct();
if (!isset($cfg['menu'])) {
$menu = 'mainmenu';
} else {
$menu = $cfg['menu'];
}
if (!isset($cfg['show_home'])) {
$cfg['show_home'] = 1;
}
if (!isset($cfg['is_sub_menu'])) {
$cfg['is_sub_menu'] = 0;
}
// текущий пункт меню
$currentmenu = $full_menu[$menuid];
// результирующий массив меню
$items = array();
// id корня меню если обычный вывод меню, $menuid если режим подменю
if ($cfg['is_sub_menu']) {
// в подменю не должно быть ссылки на главную
$cfg['show_home'] = 0;
// на главной подменю не можт быть
if ($menuid == 1) {
return false;
}
foreach ($full_menu as $item) {
if ($item['NSLeft'] > $currentmenu['NSLeft'] && $item['NSRight'] < $currentmenu['NSRight'] && $item['menu'] == $menu && cmsCore::checkContentAccess($item['access_list']) && $item['published']) {
$items[] = $item;
// массивы для сортировки
$nsl[] = $item['NSLeft'];
$ord[] = $item['ordering'];
}
}
} else {
foreach ($full_menu as $item) {
if ($item['menu'] == $menu && cmsCore::checkContentAccess($item['access_list']) && $item['published']) {
$items[] = $item;
// массивы для сортировки
$nsl[] = $item['NSLeft'];
$ord[] = $item['ordering'];
}
}
}
if (!$items) {
return false;
}
// сортируем массив
array_multisort($nsl, SORT_ASC, $ord, SORT_ASC, $items);
$template = $cfg['tpl'] ? $cfg['tpl'] : 'mod_menu.tpl';
cmsPage::initTemplate('modules', $template)->assign('menuid', $menuid)->assign('currentmenu', $currentmenu)->assign('menu', $menu)->assign('items', $items)->assign('last_level', 0)->assign('user_id', $inUser->id)->assign('is_admin', $inUser->is_admin)->assign('cfg', $cfg)->display($template);
return true;
}
示例3: sphinx_add_result_forum
function sphinx_add_result_forum($items) {
$inCore = cmsCore::getInstance();
global $_LANG;
cmsCore::loadLanguage('components/forum');
$config = $inCore->loadComponentConfig('forum');
$search_model = cms_model_search::initModel();
foreach ($items as $id => $item) {
if (!cmsCore::checkContentAccess($item['attrs']['access_list'])) { continue; }
$pages = ceil($item['attrs']['post_count'] / $config['pp_thread']);
$result_array = array(
'link' => '/forum/thread'. $id .'-'. $pages .'.html',
'place' => $item['attrs']['forum'],
'placelink' => '/forum/'. $item['attrs']['forum_id'],
'description' => $search_model->getProposalWithSearchWord($item['attrs']['description']),
'title' => $item['attrs']['title'],
'pubdate' => date('Y-m-d H:i:s', $item['attrs']['pubdate'])
);
$search_model->addResult($result_array);
}
// Ищем в тексте постов
$cl = new SphinxClient();
$cl->SetServer('127.0.0.1', 9312);
$cl->SetMatchMode(SPH_MATCH_EXTENDED2);
$cl->SetLimits(0, 100);
$result = $cl->Query($search_model->against, $search_model->config['Sphinx_Search']['prefix'] .'_forum_posts');
if ($result !== false) {
foreach ($result['matches'] as $id => $item) {
$pages = ceil($item['attrs']['post_count'] / $config['pp_thread']);
$post_page = ($pages > 1) ? postPage::getPage($item['attrs']['thread_id'], $id, $config['pp_thread']) : 1;
$result_array = array(
'link' => '/forum/thread'. $item['attrs']['thread_id'] .'-'. $post_page .'.html#'. $id,
'place' => $_LANG['FORUM_POST'],
'placelink' => '/forum/thread'. $item['attrs']['thread_id'] .'-'. $post_page .'.html#'. $id,
'description' => $search_model->getProposalWithSearchWord($item['attrs']['content_html']),
'title' => $item['attrs']['thread'],
'imageurl' => $item['attrs']['fileurl'],
'pubdate' => date('Y-m-d H:i:s', $item['attrs']['pubdate'])
);
$search_model->addResult($result_array);
}
}
return;
}
示例4: search_forum
function search_forum($query, $look)
{
$inCore = cmsCore::getInstance();
$inDB = cmsDatabase::getInstance();
$searchModel = cms_model_search::initModel();
global $_LANG;
cmsCore::loadLanguage('components/forum');
$config = $inCore->loadComponentConfig('forum');
// Ищем в названиях тем
$sql = "SELECT t.*, f.title as forum, f.id as forum_id, f.access_list\r\n FROM cms_forum_threads t\r\n INNER JOIN cms_forums f ON f.id = t.forum_id\r\n WHERE MATCH(t.title) AGAINST ('{$query}' IN BOOLEAN MODE) AND t.is_hidden=0 LIMIT 50";
$result = $inDB->query($sql);
if ($inDB->num_rows($result)) {
while ($item = $inDB->fetch_assoc($result)) {
if (!cmsCore::checkContentAccess($item['access_list'])) {
continue;
}
$result_array = array();
$pages = ceil($item['post_count'] / $config['pp_thread']);
$result_array['link'] = "/forum/thread{$item['id']}-{$pages}.html";
$result_array['place'] = $item['forum'];
$result_array['placelink'] = "/forum/" . $item['forum_id'];
$result_array['title'] = $item['title'];
$result_array['pubdate'] = $item['pubdate'];
$result_array['description'] = $searchModel->getProposalWithSearchWord($item['description']);
$result_array['session_id'] = session_id();
$searchModel->addResult($result_array);
}
}
// Ищем в тексте постов
$sql = "SELECT p.*, t.title as thread, t.id as thread_id, t.post_count, img.fileurl\r\n FROM cms_forum_posts p\r\n INNER JOIN cms_forum_threads t ON t.id = p.thread_id AND t.is_hidden=0\r\n LEFT JOIN cms_upload_images img ON img.target_id = p.id AND img.target = 'post' AND img.component = 'forum'\r\n WHERE MATCH(p.content) AGAINST ('{$query}' IN BOOLEAN MODE) LIMIT 50";
$result = $inDB->query($sql);
if ($inDB->num_rows($result)) {
while ($item = $inDB->fetch_assoc($result)) {
$result_array = array();
$pages = ceil($item['post_count'] / $config['pp_thread']);
$post_page = $pages > 1 ? postPage::getPage($item['thread_id'], $item['id'], $config['pp_thread']) : 1;
$result_array['link'] = "/forum/thread{$item['thread_id']}-{$post_page}.html#{$item['id']}";
$result_array['place'] = $_LANG['FORUM_POST'];
$result_array['placelink'] = $result_array['link'];
$result_array['description'] = $searchModel->getProposalWithSearchWord($item['content_html']);
$result_array['title'] = $item['thread'];
$result_array['pubdate'] = $item['pubdate'];
$result_array['imageurl'] = $item['fileurl'];
$result_array['session_id'] = session_id();
$searchModel->addResult($result_array);
}
}
return;
}
示例5: printModule
/**
* Печатает модуль по id или по названию
* @param mixed $id
* @return html
*/
public function printModule($id)
{
if (is_numeric($id)) {
$where = "id = '{$id}'";
} else {
$where = "MATCH(content) AGAINST ('{$id}' IN BOOLEAN MODE)";
}
$mod = cmsDatabase::getInstance()->get_fields('cms_modules', $where, '*');
if (!$mod) {
return false;
}
if (!cmsCore::checkContentAccess($mod['access_list'])) {
return false;
}
// формируем html модуля
$m = $this->renderModule($mod);
if (!$m) {
return false;
}
echo $m;
return true;
}
示例6: getForums
public function getForums($is_admin = false)
{
$pub_sql = $is_admin ? '' : ' AND f.published = 1';
$sql = "SELECT f.*, cat.title as cat_title, cat.seolink as cat_seolink, cat.id as cat_id\r\n FROM cms_forums f\r\n LEFT JOIN cms_forum_cats cat ON cat.id = f.category_id\r\n WHERE f.parent_id > 0 AND cat.published = 1 {$pub_sql}\r\n {$this->inDB->where}\r\n ORDER BY cat.ordering, f.NSLeft \n";
if ($this->inDB->limit) {
$sql .= "LIMIT {$this->inDB->limit}";
}
$result = $this->inDB->query($sql);
$this->inDB->resetConditions();
if (!$this->inDB->num_rows($result)) {
return array();
}
$forums = array();
while ($forum = $this->inDB->fetch_assoc($result)) {
// проверяем доступ к форуму
if (!cmsCore::checkContentAccess($forum['access_list'])) {
continue;
}
// получаем массив последнего сообщения
$forum['last_msg_array'] = cmsCore::yamlToArray($forum['last_msg']);
if ($forum['last_msg_array']) {
$forum['last_msg_array']['fpubdate'] = cmsCore::dateFormat($forum['last_msg_array']['pubdate']);
}
// Путь до иконки форума
$forum['icon_url'] = '/upload/forum/cat_icons/' . ($forum['icon'] ? $forum['icon'] : 'forum.gif');
$forums[] = $forum;
}
if ($forums) {
$forums = translations::process(cmsConfig::getConfig('lang'), 'forum_forums', $forums);
$forums = translations::process(cmsConfig::getConfig('lang'), 'forum_forum_cats', $forums, 'cat_id', array('title' => 'cat_title'));
foreach ($forums as $f) {
// Уровень первого элемента
$first_level = isset($first_level) ? $first_level : $f['NSLevel'];
// Формируем корневой уровень
if ($f['NSLevel'] == $first_level) {
$nested_forums[] = $f;
} else {
// формируем подфорумы
$k = array_keys($nested_forums);
$nested_forums[end($k)]['sub_forums'][] = $f;
}
}
}
return cmsCore::callEvent('GET_FORUMS', $nested_forums);
}
示例7: forum
function forum()
{
$inCore = cmsCore::getInstance();
$inPage = cmsPage::getInstance();
$inDB = cmsDatabase::getInstance();
$inUser = cmsUser::getInstance();
$model = new cms_model_forum();
define('IS_BILLING', $inCore->isComponentInstalled('billing'));
if (IS_BILLING) {
cmsCore::loadClass('billing');
}
global $_LANG;
$pagetitle = $inCore->getComponentTitle();
$inPage->addPathway($pagetitle, '/forum');
$inPage->setTitle($pagetitle);
$inPage->setDescription($model->config['meta_desc'] ? $model->config['meta_desc'] : $pagetitle);
$inPage->setKeywords($model->config['meta_keys'] ? $model->config['meta_keys'] : $pagetitle);
$id = cmsCore::request('id', 'int', 0);
$do = $inCore->do;
$page = cmsCore::request('page', 'int', 1);
$inPage->addHeadJS('components/forum/js/common.js');
$inPage->addHeadJsLang(array('CONFIRM_DELETE_POLL', 'CONFIRM_DEL_POST', 'CONFIRM_DEL_THREAD', 'MOVE_THREAD', 'MOVE_POST', 'RENAME_THREAD', 'CONFIRM_DELETE_FILE', 'SELECT_NEW_FILE_UPLOAD', 'SELECT_TEXT_QUOTE', 'CONFIRM_DELETE_ALL_USER_POSTS'));
//============================================================================//
//=============================== Список Форумов ============================//
//============================================================================//
if ($do == 'view') {
$inPage->addHead('<link rel="alternate" type="application/rss+xml" title="' . $_LANG['FORUMS'] . '" href="' . HOST . '/rss/forum/all/feed.rss">');
$forums = $model->getForums();
cmsPage::initTemplate('components', 'com_forum_list')->assign('pagetitle', $pagetitle)->assign('forums', $forums)->assign('forum', array())->assign('user_id', $inUser->id)->assign('cfg', $model->config)->display('com_forum_list.tpl');
}
//============================================================================//
//================ Список тем форума + список подфорумов ====================//
//============================================================================//
if ($do == 'forum') {
$forum = $model->getForum($id);
if (!$forum) {
cmsCore::error404();
}
$forum = translations::process(cmsConfig::getConfig('lang'), 'forum_forums', $forum);
$moderators = $model->getForumModerators($forum['moder_list']);
// опции просмотра
$order_by = cmsCore::getSearchVar('order_by', 'pubdate');
$order_to = cmsCore::getSearchVar('order_to', 'desc');
if (!in_array($order_by, array('pubdate', 'title', 'post_count', 'hits'))) {
$order_by = 'pubdate';
}
if (!in_array($order_to, array('asc', 'desc'))) {
$order_to = 'desc';
}
$daysprune = (int) cmsCore::getSearchVar('daysprune');
if (!cmsCore::checkContentAccess($forum['access_list'])) {
cmsPage::includeTemplateFile('special/accessdenied.php');
return;
}
$inPage->addHead('<link rel="alternate" type="application/rss+xml" title="' . htmlspecialchars($forum['title']) . '" href="' . HOST . '/rss/forum/' . $forum['id'] . '/feed.rss">');
$inPage->setTitle($forum['pagetitle'] ? $forum['pagetitle'] : $forum['title']);
$inPage->setDescription($forum['meta_desc'] ? $forum['meta_desc'] : crop($forum['description'] ? $forum['description'] : $forum['title']));
$inPage->setKeywords($forum['meta_keys'] ? $forum['meta_keys'] : $forum['title']);
// Получаем дерево форумов
$path_list = $inDB->getNsCategoryPath('cms_forums', $forum['NSLeft'], $forum['NSRight'], 'id, title, access_list, moder_list');
// Строим глубиномер
if ($path_list) {
$path_list = translations::process(cmsConfig::getConfig('lang'), 'forum_forums', $path_list);
foreach ($path_list as $pcat) {
if (!cmsCore::checkContentAccess($pcat['access_list'])) {
cmsPage::includeTemplateFile('special/accessdenied.php');
return;
}
$inPage->addPathway($pcat['title'], '/forum/' . $pcat['id']);
}
}
// Получим подфорумы
$model->whereNestedForum($forum['NSLeft'], $forum['NSRight']);
$sub_forums = $model->getForums();
cmsPage::initTemplate('components', 'com_forum_list')->assign('pagetitle', $forum['title'])->assign('forums', $sub_forums)->assign('forum', $forum)->assign('cfg', $model->config)->assign('user_id', $inUser->id)->display('com_forum_list.tpl');
// Получим темы
if ($daysprune) {
$model->whereDayIntervalIs($daysprune);
}
$model->whereForumIs($forum['id']);
$inDB->orderBy('t.pinned', 'DESC, t.' . $order_by . ' ' . $order_to);
$inDB->limitPage($page, $model->config['pp_forum']);
$threads = $model->getThreads();
if (!$threads && $page > 1) {
cmsCore::error404();
}
cmsPage::initTemplate('components', 'com_forum_view')->assign('threads', $threads)->assign('show_panel', true)->assign('order_by', $order_by)->assign('order_to', $order_to)->assign('daysprune', $daysprune)->assign('moderators', $moderators)->assign('pagination', cmsPage::getPagebar($forum['thread_count'], $page, $model->config['pp_forum'], '/forum/' . $forum['id'] . '-%page%'))->display('com_forum_view.tpl');
}
//============================================================================//
//======================== Просмотр темы форума =============================//
//============================================================================//
if ($do == 'thread') {
$thread = $model->getThread($id);
if (!$thread) {
cmsCore::error404();
}
// Строим глубиномер
$path_list = $inDB->getNsCategoryPath('cms_forums', $thread['NSLeft'], $thread['NSRight'], 'id, title, access_list, moder_list');
if ($path_list) {
$path_list = translations::process(cmsConfig::getConfig('lang'), 'forum_forums', $path_list);
//.........这里部分代码省略.........
示例8: search_forum
function search_forum($query, $look) {
$inCore = cmsCore::getInstance();
global $_LANG;
cmsCore::loadLanguage('components/forum');
$config = $inCore->loadComponentConfig('forum');
// Ищем в названиях тем
$sql = "SELECT t.*, f.title as forum, f.id as forum_id, f.access_list
FROM cms_forum_threads t
INNER JOIN cms_forums f ON f.id = t.forum_id
WHERE MATCH(t.title) AGAINST ('". $query ."' IN BOOLEAN MODE) AND t.is_hidden=0 LIMIT 50";
$result = cmsCore::c('db')->query($sql);
if (cmsCore::c('db')->num_rows($result)) {
while($item = cmsCore::c('db')->fetch_assoc($result)) {
if (!cmsCore::checkContentAccess($item['access_list'])) { continue; }
$pages = ceil($item['post_count'] / $config['pp_thread']);
$result_array = array(
'link' => '/forum/thread'. $item['id'] .'-'. $pages .'.html',
'place' => $item['forum'],
'placelink' => '/forum/'. $item['forum_id'],
'description' => cmsCore::m('search')->getProposalWithSearchWord($item['description']),
'title' => $item['title'],
'pubdate' => $item['pubdate']
);
cmsCore::m('search')->addResult($result_array);
}
}
// Ищем в тексте постов
$sql = "SELECT p.*, t.title as thread, t.id as thread_id, t.post_count, img.fileurl
FROM cms_forum_posts p
INNER JOIN cms_forum_threads t ON t.id = p.thread_id AND t.is_hidden=0
LEFT JOIN cms_upload_images img ON img.target_id = p.id AND img.target = 'post' AND img.component = 'forum'
WHERE MATCH(p.content) AGAINST ('". $query ."' IN BOOLEAN MODE) LIMIT 50";
$result = cmsCore::c('db')->query($sql);
if (cmsCore::c('db')->num_rows($result)) {
while($item = cmsCore::c('db')->fetch_assoc($result)){
$pages = ceil($item['post_count'] / $config['pp_thread']);
$post_page = ($pages > 1) ? postPage::getPage($item['thread_id'], $item['id'], $config['pp_thread']) : 1;
$result_array = array(
'link' => '/forum/thread'. $item['thread_id'] .'-'. $post_page .'.html#'. $item['id'],
'place' => $_LANG['FORUM_POST'],
'placelink' => $result_array['link'],
'description' => cmsCore::m('search')->getProposalWithSearchWord($item['content_html']),
'title' => $item['thread'],
'imageurl' => $item['fileurl'],
'pubdate' => $item['pubdate']
);
cmsCore::m('search')->addResult($result_array);
}
}
return;
}
示例9: getFormFields
/**
* Возвращает поля формы
* @param int $form_id ID формы
* @return array
*/
public static function getFormFields($form_id)
{
if (isset(self::$cached_form_fields[$form_id])) {
return self::$cached_form_fields[$form_id];
}
$form_fields = array();
$inDB = cmsDatabase::getInstance();
$sql = "SELECT * FROM cms_form_fields WHERE form_id = '{$form_id}' ORDER BY ordering ASC";
$res = $inDB->query($sql);
if ($inDB->num_rows($res)) {
while ($form_field = $inDB->fetch_assoc($res)) {
$form_field['config'] = cmsCore::yamlToArray($form_field['config']);
$form_field['show_for_group'] = cmsCore::yamlToArray($form_field['show_for_group']);
if (!cmsCore::checkContentAccess($form_field['show_for_group'])) {
continue;
}
$form_fields[] = $form_field;
}
}
return cmsCore::callEvent('GET_FORM_FIELDS', $form_fields);
}