本文整理汇总了PHP中SecurityUtil::getSecurityLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityUtil::getSecurityLevel方法的具体用法?PHP SecurityUtil::getSecurityLevel怎么用?PHP SecurityUtil::getSecurityLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecurityUtil
的用法示例。
在下文中一共展示了SecurityUtil::getSecurityLevel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modify
//.........这里部分代码省略.........
if (empty($vars['menutree_content'])) {
// no content - get list of menus to allow import
$vars['menutree_menus'] = $this->_get_current_menus($blockinfo['bid']);
} else {
// are there new langs not present in current menu?
// check if there are new languages not present in current menu
// if so - need to set reference lang to copy initial menu items data
if (count(array_diff($vars['languages'],$vars['oldlanguages'])) > 1) {
// fisrt try current default lang
if (in_array($vars['defaultanguage'],$vars['oldlanguages'])) {
$langs['ref'] = $vars['defaultanguage'];
// or user lang
} elseif (in_array($userlanguage,$vars['oldlanguages'])) {
$langs['ref'] = $userlanguage;
// or old default lang
} elseif (in_array($vars['olddefaultanguage'],$vars['languages'])) {
$langs['ref'] = $vars['olddefaultanguage'];
// it must be any language present in old and new lang list
} else {
$langs['ref'] = current(array_intersect($vars['languages'], $vars['oldlanguages']));
}
}
}
// decode tree array
$tree = new Blocks_MenutreeTree();
$tree->setOption('id', 'adm-menutree'.$blockinfo['bid']);
$tree->setOption('sortable', true);
if (isset($langs)) {
$tree->setOption('langs', $langs['list']);
}
$tree->setOption('stripbaseurl', $vars['menutree_stripbaseurl']);
$tree->setOption('maxDepth', $vars['menutree_maxdepth']);
$tree->loadArrayData($vars['menutree_content']);
$vars['menutree_content'] = $tree->getHTML();
// get all templates and stylesheets.
$vars['tpls'] = Blocks_MenutreeUtil::getTemplates();
$vars['styles'] = Blocks_MenutreeUtil::getStylesheets();
$someThemes = $this->__('Only in some themes');
$vars['somethemes'] = isset($vars['tpls'][$someThemes]) || isset($vars['styles'][$someThemes]) ? true : false;
// template to use
if (empty($vars['menutree_tpl']) || !$this->view->template_exists($vars['menutree_tpl'])) {
$vars['menutree_tpl'] = 'menutree/blocks_block_menutree_default.tpl';
}
// prepare block titles array
foreach (array_keys($vars['languages']) as $lang) {
if (!array_key_exists($lang, $vars['menutree_titles'])) {
$vars['menutree_titles'][$lang] = '';
}
}
// for permissions settings get first supported permlevels
$vars['permlevels'] = $this->_permlevels();
// check if saved permlevels are correct
$vars['menutree_titlesperms'] = !empty($vars['menutree_titlesperms']) ? $vars['menutree_titlesperms'] : 'ACCESS_EDIT';
$vars['menutree_displayperms'] = !empty($vars['menutree_displayperms']) ? $vars['menutree_displayperms'] : 'ACCESS_EDIT';
$vars['menutree_settingsperms'] = !empty($vars['menutree_settingsperms']) ? $vars['menutree_settingsperms'] : 'ACCESS_EDIT';
// check user permissions for settings sections
$useraccess = SecurityUtil::getSecurityLevel(SecurityUtil::getAuthInfo(), 'Blocks::', "$blockinfo[bkey]:$blockinfo[title]:$blockinfo[bid]");
$vars['menutree_titlesaccess'] = $useraccess >= constant($vars['menutree_titlesperms']);
$vars['menutree_displayaccess'] = $useraccess >= constant($vars['menutree_displayperms']);
$vars['menutree_settingsaccess'] = $useraccess >= constant($vars['menutree_settingsperms']);
$vars['menutree_adminaccess'] = $useraccess >= ACCESS_ADMIN;
$vars['menutree_anysettingsaccess'] = $vars['menutree_adminaccess'] || $vars['menutree_titlesaccess'] || $vars['menutree_displayaccess'] || $vars['menutree_settingsaccess'];
// check if the users wants to add a new link via the "Add current url" link in the block
$addurl = FormUtil::getPassedValue('addurl', 0, 'GET');
// or if we come from the normal "edit this block" link
$fromblock = FormUtil::getPassedValue('fromblock', null, 'GET');
$vars['redirect'] = '';
$vars['menutree_newurl'] = '';
if ($addurl == 1) {
// set a marker for redirection later on
$newurl = System::serverGetVar('HTTP_REFERER');
$vars['redirect'] = urlencode($newurl);
$newurl = str_replace(System::getBaseUrl(), '', $newurl);
if (empty($newurl)) {
$newurl = System::getHomepageUrl();
}
$vars['menutree_newurl'] = $newurl;
} elseif (isset($fromblock)) {
$vars['redirect'] = urlencode(System::serverGetVar('HTTP_REFERER'));
}
// Create output object
$this->view->setCaching(Zikula_View::CACHE_DISABLED);
// assign all block variables
$this->view->assign($vars)
->assign('blockinfo', $blockinfo);
// Return the output that has been generated by this function
return $this->view->fetch('menutree/blocks_block_menutree_modify.tpl');
}
示例2: display
/**
* display block
* @author The Zikula Development Team
*/
public function display($blockinfo)
{
// security check
if (!SecurityUtil::checkPermission('Quotes:Quoteblock:', $blockinfo['bid'] . '::', ACCESS_READ)) {
return;
}
// Get current content
$vars = BlockUtil::varsFromContent($blockinfo['content']);
// filter desplay by hour of the day: @nikp
$a_datetime = getdate();
if (isset($vars['hourfrom']) and $vars['hourfrom'] > -1 and $a_datetime["hours"] < $vars['hourfrom']) {
return "";
}
if (isset($vars['hourto']) and $vars['hourto'] > -1 and $a_datetime["hours"] > $vars['hourto']) {
return "";
}
if (isset($vars['wdayfrom']) and $vars['wdayfrom'] > -1 and $a_datetime["wday"] < $vars['wdayfrom']) {
return "";
}
if (isset($vars['wdayto']) and $vars['wdayto'] > -1 and $a_datetime["wday"] > $vars['wdayto']) {
return "";
}
if (isset($vars['mdayfrom']) and $vars['mdayfrom'] > -1 and $a_datetime["mday"] < $vars['mdayfrom']) {
return "";
}
if (isset($vars['mdayto']) and $vars['mdayto'] > -1 and $a_datetime["mday"] > $vars['mdayto']) {
return "";
}
if (isset($vars['monfrom']) and $vars['monfrom'] > -1 and $a_datetime["mon"] < $vars['monfrom']) {
return "";
}
if (isset($vars['monto']) and $vars['monto'] > -1 and $a_datetime["mon"] > $vars['monto']) {
return "";
}
if (!isset($vars['category'])) {
$vars['category'] = null;
}
if (isset($vars['ballooncolor'])) {
$ballooncolor = $vars['ballooncolor'];
} else {
$ballooncolor = "grey";
}
// Implementation cached content: @nikp
$enable_cache = true;
$write_to_cache = false;
# flag
$cache_time = 240;
# seconds
if (isset($vars['cache_time'])) {
$cache_time = $vars['cache_time'];
}
$content = "";
if ($enable_cache and $cache_time > 0) {
$cachefilestem = 'quote_' . $blockinfo['bid'];
$cachedir = System::getVar('temp');
if (StringUtil::right($cachedir, 1) != '/') {
$cachedir .= '/';
}
if (isset($vars['cache_dir']) and !empty($vars['cache_dir'])) {
$cachedir .= $vars['cache_dir'];
} else {
$cachedir .= 'any_cache';
}
$cachefile = $cachedir . '/' . $cachefilestem . '_' . SecurityUtil::getSecurityLevel(SecurityUtil::getAuthInfo(), 'Quotes::', '::');
// attempt to load from cache
if (file_exists($cachefile)) {
$file_time = filectime($cachefile);
$now = time();
$diff = $now - $file_time;
if ($diff <= $cache_time) {
$content = file_get_contents($cachefile);
}
}
if (empty($content)) {
$write_to_cache = true;
# not loaded, flag to write to cache later
}
}
if (empty($content)) {
// Create output object
$this->view->setCaching(false);
// we implement caching other way
mt_srand((double) microtime() * 1000000);
$apiargs = array();
$apiargs['status'] = 1;
// Make a category filter only if categorization is enabled
$enablecategorization = ModUtil::getVar($this->name, 'enablecategorization');
if ($enablecategorization) {
// load the categories system
if (!Loader::loadClass('CategoryRegistryUtil')) {
return LogUtil::registerError(__f('Error! Could not load [%s] class.'), 'CategoryRegistryUtil');
}
// Get the registrered categories for the module
$catregistry = CategoryRegistryUtil::getRegisteredModuleCategories($this->name, 'quotes');
$this->view->assign('catregistry', $catregistry);
$apiargs['catregistry'] = $catregistry;
//.........这里部分代码省略.........
示例3: pnSecGetLevel
/**
* calculate security level for a test item
*
* @deprecated
* @see SecurityUtil::getSecurityLevel
* @param perms $ array of permissions to test against
* @param testrealm $ realm of item under test
* @param testcomponent $ component of item under test
* @param testinstance $ instance of item under test
* @return int matching security level
*/
function pnSecGetLevel($perms, $testrealm, $testcomponent, $testinstance)
{
LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(
'pnSecGetLevel()',
'SecurityUtil::getSecurityLevel()')), E_USER_DEPRECATED);
return SecurityUtil::getSecurityLevel($perms, $testcomponent, $testinstance);
}
示例4: display
/**
* display block
* @author The Zikula Development Team
*/
public function display($blockinfo)
{
// security check
if (!SecurityUtil::checkPermission('Ephemerides:Ephemerideblock:', $blockinfo['bid'] . '::', ACCESS_READ)) {
return;
}
// Get current content
$vars = BlockUtil::varsFromContent($blockinfo['content']);
if (!isset($vars['category'])) {
$vars['category'] = null;
}
// Implementation cached content: @nikp
$enable_cache = true;
$write_to_cache = false;
# flag
$cache_time = 3600;
# seconds
if (isset($vars['cache_time'])) {
$cache_time = $vars['cache_time'];
}
$content = "";
$title = $blockinfo['title'];
if ($enable_cache and $cache_time > 0) {
$cachefilestem = 'ephem_' . $blockinfo['bid'];
$cachedir = System::getVar('temp');
if (StringUtil::right($cachedir, 1) != '/') {
$cachedir .= '/';
}
if (isset($vars['cache_dir']) and !empty($vars['cache_dir'])) {
$cachedir .= $vars['cache_dir'];
} else {
$cachedir .= 'any_cache';
}
$cachefile = $cachedir . '/' . $cachefilestem . '_' . SecurityUtil::getSecurityLevel(SecurityUtil::getAuthInfo(), 'Ephemerides::', '::');
$cachefile_title = $cachedir . '/' . $cachefilestem . '_t';
// attempt to load from cache
if (file_exists($cachefile)) {
$file_time = filectime($cachefile);
$now = time();
$diff = $now - $file_time;
if ($diff <= $cache_time) {
$content = file_get_contents($cachefile);
}
if (file_exists($cachefile_title)) {
$title = file_get_contents($cachefile_title);
}
}
if (empty($content)) {
$write_to_cache = true;
}
# not loaded, flag to write to cache later
}
if (empty($content)) {
// Create output object
$this->view->setCaching(false);
// we implement caching other way
$apiargs = array();
$apiargs['status'] = 1;
// Make a category filter only if categorization is enabled
$enablecategorization = ModUtil::getVar($this->name, 'enablecategorization');
if ($enablecategorization) {
// load the categories system
if (!Loader::loadClass('CategoryRegistryUtil')) {
return LogUtil::registerError(__f('Error! Could not load [%s] class.'), 'CategoryRegistryUtil');
}
// Get the registrered categories for the module
$catregistry = CategoryRegistryUtil::getRegisteredModuleCategories($this->name, 'ephem');
$this->view->assign('catregistry', $catregistry);
$apiargs['catregistry'] = $catregistry;
$apiargs['category'] = $vars['category'];
}
$this->view->assign('enablecategorization', $enablecategorization);
$this->view->assign($vars);
// assign the block vars
if (!isset($vars['category']) || !is_array($vars['category'])) {
$vars['category'] = array();
}
$this->view->assign('category', $vars['category']);
// get items
$items = ModUtil::apiFunc($this->name, 'user', 'gettoday', $apiargs);
if (!$items) {
return '';
# do not display empty block: @nikp
}
$this->view->assign('items', $items);
// Populate block info and pass to theme
$content = $this->view->fetch('ephemerides_block_ephemeride.tpl');
// loop to see if we have items of type=1 (events), if not - not to put title to the block (holidays only)
$have_events = false;
foreach ($items as $item) {
if ($item['type'] == 1) {
$have_events = true;
break;
}
}
if (!$have_events) {
//.........这里部分代码省略.........