本文整理汇总了PHP中SessionUtil::getVar方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionUtil::getVar方法的具体用法?PHP SessionUtil::getVar怎么用?PHP SessionUtil::getVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionUtil
的用法示例。
在下文中一共展示了SessionUtil::getVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FlashChatBridge_user_showChat
function FlashChatBridge_user_showChat()
{
// perform permission check
if (!SecurityUtil::checkPermission('FlashChatBridge::', '::', ACCESS_READ)) {
return LogUtil::registerPermissionError();
}
$popup = FormUtil::getPassedValue('popup', false);
// Security check
$render =& pnRender::getInstance('FlashChatBridge', false);
$UserVars = pnUserGetVars(SessionUtil::getVar('uid'));
$client_type = FormUtil::getPassedValue('client_type', 'standard');
$settings = pnModGetVar('FlashChatBridge');
$settings['init_user'] = $UserVars['uname'];
$settings['init_password'] = $UserVars['pass'];
if ($settings['autosize'] == 1) {
$settings['width'] = "100%";
$settings['height'] = "100%";
}
if ($popup) {
$settings['width'] = "100%";
$settings['height'] = "100%";
$render->assign('settings', $settings);
$chat = $render->fetch("flashchatbridge_user_chat_{$client_type}.htm");
$render->assign('chat', $chat);
echo $render->fetch('flashchatbridge_user_popup.htm');
exit;
} else {
$render->assign('settings', $settings);
return $render->fetch("flashchatbridge_user_chat_{$client_type}.htm");
}
}
示例2: contentMainEditExpandAll
public static function contentMainEditExpandAll($belowPageId = null)
{
$expandedPageIds = SessionUtil::getVar('contentExpandedPageIds', array());
foreach (Content_Util::contentMainEditGetPagesList($belowPageId) as $page) {
$expandedPageIds[$page['id']] = 1;
}
SessionUtil::setVar('contentExpandedPageIds', $expandedPageIds);
}
示例3: FlashChatBridge_Bannerchatblock_display
/**
* display block
*
* @param array $blockinfo a blockinfo structure
* @return output the rendered bock
*/
function FlashChatBridge_Bannerchatblock_display($blockinfo)
{
if (!SecurityUtil::checkPermission('FlashChatBridge:Bannerchatblock:', "::", ACCESS_READ)) {
return false;
}
if (!pnModAvailable('FlashChatBridge') || !pnUserLoggedIn()) {
return false;
}
$render = pnRender::getInstance('FlashChatBridge', false);
$UserVars = pnUserGetVars(SessionUtil::getVar('uid'));
$settings = pnModGetVar('FlashChatBridge');
$settings['init_user'] = $UserVars['uname'];
$settings['init_password'] = $UserVars['pass'];
$settings['width'] = "100%";
$settings['height'] = "150";
$render->assign('settings', $settings);
$blockinfo['content'] = $render->fetch('flashchatbridge_user_chat_banner.htm');
return pnBlockThemeBlock($blockinfo);
}
示例4: smarty_function_contenteditthis
/**
* Content
*
* @copyright (C) 2007-2010, Content Development Team
* @link http://github.com/zikula-modules/Content
* @license See license.txt
*/
function smarty_function_contenteditthis($params, $view)
{
$dom = ZLanguage::getModuleDomain('Content');
$data = $params['data'];
$type = $params['type'];
$access = $params['access'];
if (!$access['pageEditAllowed']) {
return '';
}
$editmode = SessionUtil::getVar('ContentEditMode');
$vars = $view->get_template_vars();
if ($vars['preview']) {
return '';
}
$html = '';
if ($type == 'page') {
// Unused ...
$html = '<div class="content-editthis">';
$url = DataUtil::formatForDisplay(ModUtil::url('Content', 'admin', 'editPage', array('pid' => $data['id'], 'back' => 1)));
$translateurl = DataUtil::formatForDisplay(ModUtil::url('Content', 'admin', 'translatePage', array('pid' => $data['id'], 'back' => 1)));
$html .= "<a href=\"{$url}\">" . __("Edit this page", $dom) . "</a>";
if ($vars['multilingual'] == 1) {
$html .= "| <a href=\"{$translateurl}\">" . __("Translate this page", $dom) . "</a>";
}
$html .= '</div>';
} elseif ($type == 'content' && $editmode) {
$html = '<div class="content-editthis">';
$url = DataUtil::formatForDisplay(ModUtil::url('Content', 'admin', 'editContent', array('cid' => $data['id'], 'back' => 1)));
$translateurl = DataUtil::formatForDisplay(ModUtil::url('Content', 'admin', 'translateContent', array('cid' => $data['id'], 'back' => 1)));
$edittext = __f('Edit this: %1$s [ID%2$s]', array($data['title'], $data['id']), $dom);
$html .= "<a href=\"{$url}\" title=\"" . __("Click to edit this content item", $dom) . "\">" . $edittext . "</a> ";
if ($vars['multilingual'] == 1) {
$html .= "<a href=\"{$translateurl}\">" . __("Translate", $dom) . "</a>";
}
$html .= '</div>';
}
if (isset($params['assign'])) {
$smarty->assign($params['assign'], $html);
} else {
return $html;
}
}
示例5: start
/**
* {@inheritdoc}
*/
public function start()
{
// create IP finger print
$current_ipaddr = '';
$_REMOTE_ADDR = System::serverGetVar('REMOTE_ADDR');
$_HTTP_X_FORWARDED_FOR = System::serverGetVar('HTTP_X_FORWARDED_FOR');
// create the ip fingerprint
$current_ipaddr = md5($_REMOTE_ADDR . $_HTTP_X_FORWARDED_FOR);
// start session check expiry and ip fingerprint if required
if (parent::start()) {
// check if session has expired or not
$now = time();
$inactive = $now - (int) (System::getVar('secinactivemins') * 60);
$daysold = $now - (int) (System::getVar('secmeddays') * 86400);
$lastused = $this->getMetadataBag()->getLastUsed();
$rememberme = SessionUtil::getVar('rememberme');
$uid = $this->getBag('attributes')->get('uid');
switch (System::getVar('seclevel')) {
case 'Low':
// Low security - users stay logged in permanently
// no special check necessary
break;
case 'Medium':
// Medium security - delete session info if session cookie has
// expired or user decided not to remember themself and inactivity timeout
// OR max number of days have elapsed without logging back in
if (!$rememberme && $lastused < $inactive || $lastused < $daysold || $uid == '0' && $lastused < $inactive) {
$this->expire();
}
break;
case 'High':
default:
// High security - delete session info if user is inactive
//if ($rememberme && ($lastused < $inactive)) { // see #427
if ($lastused < $inactive) {
$this->expire();
}
break;
}
}
return true;
}
示例6: bbsmiles
/**
* bbsmiles
* returns a html snippet with buttons for inserting bbsmiles into a text
*
* @param $args['textfieldid'] id of the textfield for inserting smilies
*/
public function bbsmiles($args)
{
if (!isset($args['textfieldid']) || empty($args['textfieldid'])) {
return LogUtil::registerArgsError();
}
// if we have more than one textarea we need to distinguish them, so we simply use
// a counter stored in a session var until we find a better solution
$counter = SessionUtil::getVar('bbsmile_counter', 0);
$counter++;
SessionUtil::setVar('bbsmile_counter', $counter);
$this->view->assign('counter', $counter);
$this->view->assign('textfieldid', $args['textfieldid']);
PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('BBSmile'));
$templatefile = DataUtil::formatForOS(ModUtil::getName()) . '.tpl';
if ($this->view->template_exists($templatefile)) {
return $this->view->fetch($templatefile);
}
$this->view->add_core_data();
return $this->view->fetch('bbsmile_user_bbsmiles.tpl');
}
示例7: smarty_block_checkgroup
/**
* Zikula_View block to implement group checks in a template.
*
* Available attributes:
* - gid (numeric) The ID number of the group to be tested.
*
* Example:
* <pre>
* {checkgroup gid='1'}
* do some stuff now we have permission
* {/checkgroup}
* </pre>.
*
* @param array $params All attributes passed to this function from the template.
* @param string $content The content between the block tags.
* @param Zikula_View $view Reference to the {@link Zikula_View} object.
*
* @return string|boolean|void The content of the matching case.
* If the user is a member of the group specified by the gid,
* then the content contained in the block, otherwise null,
* false on error.
*/
function smarty_block_checkgroup($params, $content, Zikula_View $view)
{
// check if there is something between the tags
if (is_null($content)) {
return;
}
// check our input
if (!isset($params['gid'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('smarty_block_checkgroup', 'component')));
return false;
}
$uid = SessionUtil::getVar('uid');
if (empty($uid)) {
return;
}
if (!ModUtil::apiFunc('Groups', 'user', 'isgroupmember', array('uid' => $uid, 'gid' => $params['gid']))) {
return;
}
return $content;
}
示例8: initialize
public function initialize(Zikula_Form_View $view)
{
if (!SecurityUtil::checkPermission('Content:page:', '::', ACCESS_EDIT)) {
throw new Zikula_Exception_Forbidden(LogUtil::getErrorMsgPermission());
}
// Include categories only when 2nd category enabled in settings
$pages = ModUtil::apiFunc('Content', 'Page', 'getPages', array('editing' => true, 'filter' => array('checkActive' => false, 'expandedPageIds' => SessionUtil::getVar('contentExpandedPageIds', array())), 'enableEscape' => true, 'translate' => false, 'includeLanguages' => true, 'includeCategories' => $this->getVar('categoryUsage') < 3, 'orderBy' => 'setLeft'));
if ($pages === false) {
return $this->view->registerError(null);
}
// Get categories names if enabled
if ($this->getVar('$categoryUsage') < 4) {
$lang = ZLanguage::getLanguageCode();
$categories = array();
foreach ($pages as $page) {
$cat = CategoryUtil::getCategoryByID($page['categoryId']);
$categories[$page['id']] = array();
$categories[$page['id']][] = isset($cat['display_name'][$lang]) ? $cat['display_name'][$lang] : $cat['name'];
if (isset($page['categories']) && is_array($page['categories'])) {
foreach ($page['categories'] as $pageCat) {
$cat = CategoryUtil::getCategoryByID($pageCat['categoryId']);
$categories[$page['id']][] = isset($cat['display_name'][$lang]) ? $cat['display_name'][$lang] : $cat['name'];
}
}
}
$this->view->assign('categories', $categories);
}
PageUtil::setVar('title', $this->__('Page list and content structure'));
$csssrc = ThemeUtil::getModuleStylesheet('admin', 'admin.css');
PageUtil::addVar('stylesheet', $csssrc);
$this->view->assign('pages', $pages);
$this->view->assign('multilingual', ModUtil::getVar(ModUtil::CONFIG_MODULE, 'multilingual'));
$this->view->assign('enableVersioning', $this->getVar('enableVersioning'));
$this->view->assign('language', ZLanguage::getLanguageCode());
Content_Util::contentAddAccess($this->view, null);
return true;
}
示例9: __construct
/**
* Constructor.
*/
public function __construct()
{
$this->langSession = SessionUtil::getVar('language', null);
$this->langSystemDefault = System::getVar('language_i18n', 'en');
$this->languageCode = $this->langSystemDefault;
$this->langFixSession = preg_replace('#[^a-z-].#', '', FormUtil::getPassedValue('setsessionlanguage', null, 'POST'));
$this->multiLingualCapable = System::getVar('multilingual');
$this->langUrlRule = System::getVar('languageurl', 0);
$this->langDetect = System::getVar('language_detect', 0);
$this->setDBCharset();
$this->setEncoding();
}
示例10: isGuestUser
/**
* Determine if the current session is that of an anonymous user.
*
* @return boolean
*/
public static function isGuestUser()
{
return !SessionUtil::getVar('uid', 0);
}
示例11: compile
/**
* Compiles the given string of code, and returns
* the result in a string.
* If "do_not_echo" is true, the returned code will not be directly
* executable, but can be used as part of a variable assignment
* for use in assign_code_from_handle().
*/
function compile($code, $do_not_echo = false, $retvar = '')
{
// Begin PNphpBB2 Module
global $board_config, $gen_simple_header;
if (!defined('PNPHPBB_TEMPLATE') && empty($gen_simple_header) && SessionUtil::getVar('fullpage') == 0) {
$search = array("'<\\!doctype\\s+.*?>'si", "'<title[^>]*?>.*?</title>'si", "'<head>'i", "'</head>'i", "'<html>'i", "'<html\\s+.*?>'i", "'</html>'i", "'body\\s*{(\\s*[a-zA-Z0-9\\-_]*:\\s*{[a-zA-Z0-9\\-_]*};*)*\\s*}'i", "'/\\*.*?\\*/'i", "'<body\\s+.*?>'si", "'</body\\s+.*?>'si", "'<font.*?>'i", "'</font>'i");
$replace = array("", "", "", "", "", "", "", "", "", "", "", "", "");
$code = preg_replace($search, $replace, $code);
}
if (!defined(PNPHPBB_TEMPLATE)) {
$code = str_replace("../templates/", "./modules/ZphpBB2/vendor/phpBB2/templates/", $code);
$code = str_replace("\"templates/", "\"./modules/ZphpBB2/vendor/phpBB2/templates/", $code);
$code = str_replace("url(templates", "url(./modules/ZphpBB2/vendor/phpBB2/templates", $code);
$search = array("'font(?!-).*?\\s*{(\\s*[a-zA-Z0-9\\-_]*\\s*:\\s*{[a-zA-Z0-9\\-_]*};*)*\\s*}'i", "'a:(link|active|visited|hover|).*?{(\\s*[a-zA-Z0-9\\-_]*\\s*:\\s*.*?;)*\\s*}'i", "'<input\\s+type\\s*=\\s*\"?text\"?\\s+name\\s*=\\s*\"?username\"?'i", "'<input\\s+type\\s*=\\s*\"?password\"?\\s+name\\s*=\\s*\"?password\"?'i", "'<input\\s+type\\s*=\\s*\"?checkbox\"?\\s+name\\s*=\\s*\"?autologin\"?'i", "'\\.copyright'i", "'<span\\s+class\\s*=\\s*\"?copyright\"?'i");
$replace = array("", "", '<input type="text" name="uname"', '<input type="password" name="pass"', '<input type="checkbox" name="rememberme"', "", '<div class="gensmall" align="center"');
$code = preg_replace($search, $replace, $code);
if (preg_match("/L_CONFIGURATION_TITLE/i", $code)) {
$code = preg_replace("'<tr[^>]*>[^<]*(<(?!tr)[^<]*)*(L_SERVER_NAME|L_SERVER_PORT|L_SCRIPT_PATH|L_SITE_NAME|L_SITE_DESCRIPTION|L_ACCT_ACTIVATION|L_VISUAL_CONFIRM|L_ALLOW_AUTOLOGIN|L_AUTOLOGIN_TIME|L_DATE_FORMAT|L_SYSTEM_TIMEZONE|L_ENABLE_GZIP|L_COOKIE_SECURE|L_ALLOW_NAME_CHANGE|L_COPPA_SETTINGS|L_COPPA_FAX|L_COPPA_MAIL|L_DEFAULT_LANGUAGE|L_TIMEZONE).*?</tr>'si", "", $code);
}
if (preg_match("/L_REGISTRATION_INFO/i", $code)) {
// $code = preg_replace ("'<table[^>]*>[^<]*(<(?!table)[^<]*)*(L_REGISTRATION_INFO).*?</table>'si", "", $code);
$code = preg_replace("'<tr[^>]*>[^<]*(<(?!tr)[^<]*)*(L_REGISTRATION_INFO|L_ITEMS_REQUIRED|L_USERNAME|L_EMAIL_ADDRESS|L_NEW_PASSWORD|L_CONFIRM_PASSWORD|L_ICQ_NUMBER|L_AIM|L_MESSENGER|L_YAHOO|L_WEBSITE|L_LOCATION|L_OCCUPATION|L_INTERESTS|L_BOARD_LANGUAGE|L_DATE_FORMAT|L_TIMEZONE).*?</tr>'si", "", $code);
}
}
// End PNphpBB2 Module
// replace \ with \\ and then ' with \'.
$code = str_replace('\\', '\\\\', $code);
$code = str_replace('\'', '\\\'', $code);
// change template varrefs into PHP varrefs
// This one will handle varrefs WITH namespaces
$varrefs = array();
preg_match_all('#\\{(([a-z0-9\\-_]+?\\.)+?)([a-z0-9\\-_]+?)\\}#is', $code, $varrefs);
$varcount = sizeof($varrefs[1]);
for ($i = 0; $i < $varcount; $i++) {
$namespace = $varrefs[1][$i];
$varname = $varrefs[3][$i];
$new = $this->generate_block_varref($namespace, $varname);
$code = str_replace($varrefs[0][$i], $new, $code);
}
// This will handle the remaining root-level varrefs
$code = preg_replace('#\\{([a-z0-9\\-_]*?)\\}#is', '\' . ( ( isset($this->_tpldata[\'.\'][0][\'\\1\']) ) ? $this->_tpldata[\'.\'][0][\'\\1\'] : \'\' ) . \'', $code);
// Break it up into lines.
$code_lines = explode("\n", $code);
$block_nesting_level = 0;
$block_names = array();
$block_names[0] = ".";
// Second: prepend echo ', append ' . "\n"; to each line.
$line_count = sizeof($code_lines);
for ($i = 0; $i < $line_count; $i++) {
$code_lines[$i] = chop($code_lines[$i]);
if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m)) {
$n[0] = $m[0];
$n[1] = $m[1];
// Added: dougk_ff7-Keeps templates from bombing if begin is on the same line as end.. I think. :)
if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $n)) {
$block_nesting_level++;
$block_names[$block_nesting_level] = $m[1];
if ($block_nesting_level < 2) {
// Block is not nested.
$code_lines[$i] = '$_' . $n[1] . '_count = ( isset($this->_tpldata[\'' . $n[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $n[1] . '.\']) : 0;';
$code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)';
$code_lines[$i] .= "\n" . '{';
} else {
// This block is nested.
// Generate a namespace string for this block.
$namespace = implode('.', $block_names);
// strip leading period from root level..
$namespace = substr($namespace, 2);
// Get a reference to the data array for this block that depends on the
// current indices of all parent blocks.
$varref = $this->generate_block_data_ref($namespace, false);
// Create the for loop code to iterate over this block.
$code_lines[$i] = '$_' . $n[1] . '_count = ( isset(' . $varref . ') ) ? sizeof(' . $varref . ') : 0;';
$code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)';
$code_lines[$i] .= "\n" . '{';
}
// We have the end of a block.
unset($block_names[$block_nesting_level]);
$block_nesting_level--;
$code_lines[$i] .= '} // END ' . $n[1];
$m[0] = $n[0];
$m[1] = $n[1];
} else {
// We have the start of a block.
$block_nesting_level++;
$block_names[$block_nesting_level] = $m[1];
if ($block_nesting_level < 2) {
// Block is not nested.
$code_lines[$i] = '$_' . $m[1] . '_count = ( isset($this->_tpldata[\'' . $m[1] . '.\']) ) ? sizeof($this->_tpldata[\'' . $m[1] . '.\']) : 0;';
$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
$code_lines[$i] .= "\n" . '{';
} else {
// This block is nested.
//.........这里部分代码省略.........
示例12: _processIdsResult
/**
* Process results from IDS scan.
*
* @param IDS_Init $init PHPIDS init object reference.
* @param IDS_Report $result The result object from PHPIDS.
*
* @return void
*/
private function _processIdsResult(IDS_Init $init, IDS_Report $result)
{
// $result contains any suspicious fields enriched with additional info
// Note: it is moreover possible to dump this information by simply doing
//"echo $result", calling the IDS_Report::$this->__toString() method implicitely.
$requestImpact = $result->getImpact();
if ($requestImpact < 1) {
// nothing to do
return;
}
// update total session impact to track an attackers activity for some time
$sessionImpact = SessionUtil::getVar('idsImpact', 0) + $requestImpact;
SessionUtil::setVar('idsImpact', $sessionImpact);
// let's see which impact mode we are using
$idsImpactMode = System::getVar('idsimpactmode', 1);
$idsImpactFactor = 1;
if ($idsImpactMode == 1) {
$idsImpactFactor = 1;
} elseif ($idsImpactMode == 2) {
$idsImpactFactor = 10;
} elseif ($idsImpactMode == 3) {
$idsImpactFactor = 5;
}
// determine our impact threshold values
$impactThresholdOne = System::getVar('idsimpactthresholdone', 1) * $idsImpactFactor;
$impactThresholdTwo = System::getVar('idsimpactthresholdtwo', 10) * $idsImpactFactor;
$impactThresholdThree = System::getVar('idsimpactthresholdthree', 25) * $idsImpactFactor;
$impactThresholdFour = System::getVar('idsimpactthresholdfour', 75) * $idsImpactFactor;
$usedImpact = ($idsImpactMode == 1) ? $requestImpact : $sessionImpact;
// react according to given impact
if ($usedImpact > $impactThresholdOne) {
// db logging
// determine IP address of current user
$_REMOTE_ADDR = System::serverGetVar('REMOTE_ADDR');
$_HTTP_X_FORWARDED_FOR = System::serverGetVar('HTTP_X_FORWARDED_FOR');
$ipAddress = ($_HTTP_X_FORWARDED_FOR) ? $_HTTP_X_FORWARDED_FOR : $_REMOTE_ADDR;
$currentPage = System::getCurrentUri();
$currentUid = UserUtil::getVar('uid');
$intrusionItems = array();
foreach ($result as $event) {
$eventName = $event->getName();
$malVar = explode(".", $eventName, 2);
$filters = array();
foreach ($event as $filter) {
array_push($filters, array(
'id' => $filter->getId(),
'description' => $filter->getDescription(),
'impact' => $filter->getImpact(),
'tags' => $filter->getTags(),
'rule' => $filter->getRule()));
}
$tagVal = $malVar[1];
$newIntrusionItem = array(
'name' => array($eventName),
'tag' => $tagVal,
'value' => $event->getValue(),
'page' => $currentPage,
'uid' => $currentUid,
'ip' => $ipAddress,
'impact' => $result->getImpact(),
'filters' => serialize($filters),
'date' => DateUtil::getDatetime()
);
if (array_key_exists($tagVal, $intrusionItems)) {
$intrusionItems[$tagVal]['name'][] = $newIntrusionItem['name'][0];
} else {
$intrusionItems[$tagVal] = $newIntrusionItem;
}
}
// log details to database
foreach ($intrusionItems as $tag => $intrusionItem) {
$intrusionItem['name'] = implode(", ", $intrusionItem['name']);
// create new ZIntrusion instance
$obj = new SecurityCenter_DBObject_Intrusion();
//.........这里部分代码省略.........
示例13: getUserIdValue
/**
* {@inheritdoc}
*/
public function getUserIdValue(ClassMetadata $meta, $field)
{
return \SessionUtil::getVar('uid', 0);
}
示例14: editAction
/**
* @Route("/edit/{cid}/{dr}/{mode}", requirements={"cid" = "^[1-9]\d*$", "dr" = "^[1-9]\d*$", "mode" = "edit|new"})
* @Method("GET")
*
* edit category
*
* @param Request $request
* @param integer $cid
* @param integer $dr
* @param string $mode new|edit
*
* @return Response symfony response object
*
* @throws AccessDeniedException Thrown if the user doesn't have permission to edit or add the category
*/
public function editAction(Request $request, $cid = 0, $dr = 1, $mode = "new")
{
$editCat = '';
$languages = ZLanguage::getInstalledLanguages();
// indicates that we're editing
if ($mode == 'edit') {
if (!SecurityUtil::checkPermission('ZikulaCategoriesModule::category', '::', ACCESS_EDIT)) {
throw new AccessDeniedException();
}
if (!$cid) {
$request->getSession()->getFlashBag()->add('error', $this->__('Error! Cannot determine valid \'cid\' for edit mode in \'ZikulaCategoriesModule_admin_edit\'.'));
return new RedirectResponse($this->get('router')->generate('zikulacategoriesmodule_admin_view', array(), RouterInterface::ABSOLUTE_URL));
}
$editCat = CategoryUtil::getCategoryByID($cid);
if (!$editCat) {
$request->getSession()->getFlashBag()->add('error', $this->__('Sorry! No such item found.'));
return new RedirectResponse($this->get('router')->generate('zikulacategoriesmodule_admin_view', array(), RouterInterface::ABSOLUTE_URL));
}
} else {
// new category creation
if (!SecurityUtil::checkPermission('ZikulaCategoriesModule::category', '::', ACCESS_ADD)) {
throw new AccessDeniedException();
}
// since we inherit the domain settings from the parent, we get
// the inherited (and merged) object from session
if (isset($_SESSION['newCategory']) && $_SESSION['newCategory']) {
$editCat = $_SESSION['newCategory'];
unset($_SESSION['newCategory']);
$category = new CategoryEntity();
// need this for validation info
} elseif (FormUtil::getValidationErrors()) {
// if we're back from validation get the posted data from session
$newCatActionData = \SessionUtil::getVar('newCatActionData');
\SessionUtil::delVar('newCatActionData');
$editCat = new CategoryEntity();
$editCat = $editCat->toArray();
$editCat = array_merge($editCat, $newCatActionData);
unset($editCat['path']);
unset($editCat['ipath']);
$category = new CategoryEntity();
// need this for validation info
} else {
// someone just pressed 'new' -> populate defaults
$category = new CategoryEntity();
$editCat['sort_value'] = '0';
}
}
$allCats = CategoryUtil::getSubCategories($dr, true, true, true, false, true);
// now remove the categories which are below $editCat ...
// you should not be able to set these as a parent category as it creates a circular hierarchy (see bug #4992)
if (isset($editCat['ipath'])) {
$cSlashEdit = StringUtil::countInstances($editCat['ipath'], '/');
foreach ($allCats as $k => $v) {
$cSlashCat = StringUtil::countInstances($v['ipath'], '/');
if ($cSlashCat >= $cSlashEdit && strpos($v['ipath'], $editCat['ipath']) !== false) {
unset($allCats[$k]);
}
}
}
$selector = CategoryUtil::getSelector_Categories($allCats, 'id', isset($editCat['parent_id']) ? $editCat['parent_id'] : 0, 'category[parent_id]', isset($defaultValue) ? $defaultValue : null, null, 0, null, false, false, true, 1, false, 'form-control');
$attributes = isset($editCat['__ATTRIBUTES__']) ? $editCat['__ATTRIBUTES__'] : array();
$this->view->assign('mode', $mode)->assign('category', $editCat)->assign('attributes', $attributes)->assign('languages', $languages)->assign('categorySelector', $selector);
if ($mode == 'edit') {
$this->view->assign('haveSubcategories', CategoryUtil::haveDirectSubcategories($cid))->assign('haveLeafSubcategories', CategoryUtil::haveDirectSubcategories($cid, false, true));
}
return $this->response($this->view->fetch('Admin/edit.tpl'));
}
示例15: selectWherePaginated
/**
* Selects a list of objects with a given where clause and pagination parameters.
*
* @param string $where The where clause to use when retrieving the collection (optional) (default='').
* @param string $orderBy The order-by clause to use when retrieving the collection (optional) (default='').
* @param integer $currentPage Where to start selection
* @param integer $resultsPerPage Amount of items to select
* @param boolean $useJoins Whether to include joining related objects (optional) (default=true).
* @param boolean $slimMode If activated only some basic fields are selected without using any joins (optional) (default=false).
*
* @return Array with retrieved collection and amount of total records affected by this query.
*/
public function selectWherePaginated($where = '', $orderBy = '', $currentPage = 1, $resultsPerPage = 25, $useJoins = true, $slimMode = false)
{
$qb = $this->genericBaseQuery($where, $orderBy, $useJoins, $slimMode);
$page = $currentPage;
// check if we have any filters set
$parameters = $this->getViewQuickNavParameters('', array());
$hasFilters = false;
foreach ($parameters as $k => $v) {
if (!is_numeric($v) && $v != '' || is_numeric($v) && $v > 0) {
$hasFilters = true;
break;
}
}
if (!$hasFilters) {
if ($page > 1 || isset($_GET['pos'])) {
// store current page in session
SessionUtil::setVar('MUVideoMoviesCurrentPage', $page);
} else {
// restore current page from session
$page = SessionUtil::getVar('MUVideoMoviesCurrentPage', 1);
System::queryStringSetVar('pos', $page);
}
}
list($query, $count) = $this->getSelectWherePaginatedQuery($qb, $page, $resultsPerPage);
$result = $this->retrieveCollectionResult($query, $orderBy, true);
return array($result, $count);
}