本文整理汇总了PHP中Zend_Session_Namespace::getNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Session_Namespace::getNamespace方法的具体用法?PHP Zend_Session_Namespace::getNamespace怎么用?PHP Zend_Session_Namespace::getNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Session_Namespace
的用法示例。
在下文中一共展示了Zend_Session_Namespace::getNamespace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAuthorized
/**
* Checks whether the user is authorized to use a specific module
* @param \Zend_Session_Namespace $session The session namespace
* @param string $url The URL to check against
* @return boolean
*/
public static function isAuthorized(\Zend_Session_Namespace $session, $url)
{
$authorized = false;
$module = Functions::getModuleNameFromURL($url);
switch ($session->getNamespace()) {
case 'internal':
$visitor_ip = $_SERVER['HTTP_X_FORWARDED_FOR'] ?: $_SERVER['REMOTE_ADDR'];
$authorized = static::cidrCheck($visitor_ip, unserialize(ALLOWED_IPS)) && static::checkUserPrivileges($session->user_name, $module);
break;
case 'student':
$authorized = $module === 'student';
break;
case 'faculty':
$authorized = $module === 'faculty';
break;
case 'professor':
$authorized = $module === 'professor';
break;
case 'cron':
$authorized = true;
break;
default:
throw new \InvalidArgumentException('Invalid user class.');
}
// @TODO Move to a callback function
if (!$authorized) {
header('Location: https://' . URL_CUSTOM_HANDLERS . '/403.php');
exit;
}
return $authorized;
}
示例2: testGetNameSpaceMethod
/**
* test for method getNamespace()
*
* @group ZF-1982
* @return void
*/
public function testGetNameSpaceMethod()
{
Zend_Session::$_unitTestEnabled = true;
$namespace = array('FooBar', 'Foo_Bar', 'Foo-Bar', 'Foo1000');
foreach ($namespace as $v) {
$s = new Zend_Session_Namespace($v);
$this->assertEquals($v, $s->getNamespace());
}
}
示例3: getProgressBar
/**
* The Zend ProgressBar handles the communication through
* an adapter interface.
*
* @return \Zend_ProgressBar
*/
public function getProgressBar()
{
if (!$this->progressBar instanceof \Zend_ProgressBar) {
$this->setProgressBar(new \Zend_ProgressBar($this->getProgressBarAdapter(), 0, 100, $this->_session->getNamespace() . '_pb'));
}
return $this->progressBar;
}
示例4: getUserId
/**
* Gets the user ID
* @param \Zend_Session_Namespace $session The session object
* @return int|null
*/
private function getUserId(\Zend_Session_Namespace $session = null)
{
if ($session === null) {
return null;
}
switch ($session->getNamespace()) {
case 'internal':
case 'student':
case 'faculty':
return (int) $session->user_id;
case 'cron':
return CRON_USER_ID;
case 'professor':
default:
return null;
}
}