当前位置: 首页>>代码示例>>PHP>>正文


PHP UserSession::get方法代码示例

本文整理汇总了PHP中UserSession::get方法的典型用法代码示例。如果您正苦于以下问题:PHP UserSession::get方法的具体用法?PHP UserSession::get怎么用?PHP UserSession::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserSession的用法示例。


在下文中一共展示了UserSession::get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: modules

	public static function modules()
	{
		$session = UserSession::get();
		if ($session)
		{
			$user = $session->user();
			if (!Acl::isAllowed($user->username, 'admin'))
			{
				return null;
			}
		}
		else
		{
			return null;
		}	
		
		CoOrg::loadPluginInfo('admin');
		$modules = array();
		foreach (self::$_modules as $m)
		{
			if ($m->isAllowed($user))
			{
				$modules[] = $m;
			}
		}
		usort($modules, array('Admin', 'cmpModule'));
		return $modules;
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:28,代码来源:admin.model.php

示例2: save

	public function save($subject, $body, $commentOn,
	                     $name = null, $email = null, $website = null)
	{
		$commentClass = $this->_commentClass;
		$comment = new $commentClass;
		$comment->title = $subject;
		$comment->comment = $body;
		
		if (UserSession::get())
		{
			$comment->author = UserSession::get()->user();
			$comment->spamStatus = PropertySpamStatus::OK;
		}
		else
		{
			$publicProfile = new AnonProfile;
			$publicProfile->name = $name;
			$publicProfile->email = $email;
			$publicProfile->website = $website;
			$publicProfile->IP = Session::IP();
			$comment->anonAuthor = $publicProfile;
			
			if ($this->checkSpamStatus($comment, $publicProfile) === false)
			{
				$this->newComment = $comment;
				$this->commentRequests = $this->_commentRequests;
				$this->renderErrorSave($commentOn);
				return;
			}
		}
		if ($comment->spamStatus != PropertySpamStatus::SPAM)
		{
			try
			{
				$commentOn->comments[] = $comment;
				if ($comment->spamStatus == PropertySpamStatus::OK)
				{
					$this->notice(t('Your comment has been posted'));
				}
				$this->beforeSuccess($commentOn, $comment);
				$this->redirectOnSuccess($commentOn);
			}
			catch (ValidationException $e)
			{
				$this->error(t('Your comment was not posted'));
				$this->newComment = $comment;
				$this->commentRequests = $this->_commentRequests;
				$this->renderErrorSave($commentOn);
			}
		}
		else
		{
			$this->notice(t('Your comment has been marked as spam, and will not appear'));
			$this->redirectOnSuccess($commentOn);
		}
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:56,代码来源:comments.controller.php

示例3: renderErrorSave

	protected function renderErrorSave($commentOn)
	{
		if ($this->_captcha)
		{
			$this->commentCaptcha = $this->_captcha;
		}
		else if (!UserSession::get())
		{
			$this->commentCaptcha = Mollom::refresh();
		}
		parent::renderErrorSave($commentOn);
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:12,代码来源:captcha.comments.controller.php

示例4: testLoginAndLogout

	public function testLoginAndLogout()
	{
		$session = new UserSession('Nathan', 'nathan');
		$session->save();
		
		$this->assertNotNull(UserSession::get());
		$this->assertEquals('Nathan', UserSession::get()->username);
		$user = UserSession::get()->user();
		$this->assertEquals('Nathan', $user->username);
		$this->assertEquals('nathan@email.com', $user->email);
		
		$session->delete();
		
		$this->assertNull(UserSession::get());
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:15,代码来源:usersession.model.Test.php

示例5: run

	public function run($widgetParams, $orient, $request)
	{
		if (UserSession::get() &&
		    Acl::isAllowed(UserSession::get()->username, 'admin'))
		{
			if (substr($request, 0, strpos($request, '/')) == 'admin')
			{
				$this->menu = Admin::modules();
			}
			else
			{
				$this->menu = array(new FakeAdminModule);
			}
			return $this->render('widgets/admin-menu');
		}
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:16,代码来源:menu.aside.php

示例6: setUp

	public function setUp()
	{
		parent::setUp();
		I18n::setLanguage('');
		Session::destroy();
		if ($s = UserSession::get())
		{
			$s->delete();
		}
		Session::$site = 'http://www.test.info/';
		Session::$referrer = 'http://www.test.info/some/part/of/the/site';
		unlink(COORG_TEST_CONFIG);
		copy(COORG_TEST_CONFIG_CLEAN, COORG_TEST_CONFIG);
		$config = new Config(COORG_TEST_CONFIG);
		$config->set('site/title', 'The Site');
		$config->set('defaultLanguage', '');
		CoOrg::init($config, 'app', 'plugins');
		CoOrgSmarty::clearAll();
		Header::$redirect = '__none__';
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:20,代码来源:coorg.test.class.php

示例7: update

	/**
	 * @Acl allow :loggedIn
	*/
	public function update($firstName, $lastName, $birthDate, $gender,
	                       $intrests, $biography, $website, $from = null)
	{
		$profile = UserSession::get()->user()->profile;
		$profile->firstName = $firstName;
		$profile->lastName = $lastName;
		$profile->birthDate = $birthDate;
		$profile->gender = $gender;
		$profile->intrests = $intrests;
		$profile->biography = $biography;
		$profile->website = $website;
		$avatar = Session::getFileUpload('avatar');
		$profile->avatar = $avatar;
		
		try
		{
			$avatar->setAutoStore($profile->username, $profile->avatar_extension);
			$profile->save();
			$this->notice(t('Profile updated'));
			if ($from)
			{
				$this->redirect($from);
			}
			else
			{
				$this->redirect('user/profile/show', $profile->username);
			}
		}
		catch (ValidationException $e)
		{
			$avatar->persist();
			$this->error(t('Profile not updated'));
			$this->from = $from;
			$this->profile = $profile;
			$this->render('profile/edit');
		}
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:40,代码来源:user.profile.controller.php

示例8: translateSave

	/**
	 * @post
	 * @before get $year $month $day $id $fromLanguage
	 * @Acl allow blog-translator
	 * @Acl owns $:_blog
	*/
	public function translateSave($year, $month, $day, $id, $fromLanguage,
	                              $title, $text, $language)
	{
		$original = $this->_blog;

		try
		{
			$t = $original->translate(UserSession::get()->username, $title, $text, $language);
			$this->notice(t('Your translation of the blog is saved'));
			if ($language == CoOrg::getLanguage())
			{
				$this->redirect('blog/show', $year, $month, $day, $t->ID);
			}
			else
			{
				$this->redirect('blog/show', $year, $month, $day, $t->ID, $language);
			}
		}
		catch (ValidationException $e)
		{
			$this->error(t('Blog translation is not saved'));
			$this->originalBlog = $original;
			$blog = new Blog($title, '', $text, '');
			$blog->language = $language;
			$this->translatedBlog = $blog;
			$this->render('translate');
		}
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:34,代码来源:blog.controller.php

示例9: update

	/**
	 * @before find $ID
	*/
	public function update($ID, $title, $language, $content, $redirect = null, $preview = null)
	{
		$this->_page->title = $title;
		$this->_page->content = $content;
		$this->_page->lastEditorID = UserSession::get()->username;
		if ($preview)
		{
			$this->preview = 'true';
			$this->page = $this->_page;
			if ($redirect) $this->redirect = $redirect;
			$this->render('admin/edit');
		}
		else
		{
			try
			{
				$this->_page->save();
				$this->notice(t('Page updated'));
				if ($redirect)
				{
					$this->redirect($redirect);
				}
				else
				{
					$this->redirect('page/show', $ID);
				}
			}
			catch (ValidationException $e)
			{
				$this->page = $this->_page;
				if ($redirect) $this->redirect = $redirect;
				$this->error(t('Page is not saved'));
				$this->render('admin/edit');
			}
		}
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:39,代码来源:admin.page.controller.php

示例10: logout

	public function logout()
	{
		$session = UserSession::get();
		if ($session != null)
		{
			$session->delete();
		}
		
		$this->notice(t('You are now logged out'));
		$this->redirect('/');
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:11,代码来源:user.controller.php

示例11: out

	public function out()
	{
		if ($this->_allowed === null)
		{
			$this->_allowed = $this->_onlyDenied;
		}
		if (!$this->_allowed && !UserSession::get())
		{
			$this->error('You should be logged in to view this page');
			$this->redirect = $this->coorgRequest;
			$this->render('login');
			return false;
		}
		else if (!$this->_allowed)
		{
			$this->error('You don\'t have the rights to view this page');
			$this->redirect('/');
			return false;
		}
		return true;
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:21,代码来源:acl.before.php


注:本文中的UserSession::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。