本文整理汇总了PHP中CController::beforeAction方法的典型用法代码示例。如果您正苦于以下问题:PHP CController::beforeAction方法的具体用法?PHP CController::beforeAction怎么用?PHP CController::beforeAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CController
的用法示例。
在下文中一共展示了CController::beforeAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeAction
protected function beforeAction($action)
{
if (Yii::app()->request->isAjaxRequest) {
$this->layout = false;
}
return parent::beforeAction($action);
}
示例2: beforeAction
public function beforeAction($action)
{
$dynamicTheme = "dark";
if (isset($_POST['change'])) {
$dynamicTheme = $_POST['change'];
if (isset(Yii::app()->request->cookies['dynamicTheme']->value)) {
if (Yii::app()->request->cookies['dynamicTheme']->value != $dynamicTheme) {
Yii::app()->request->cookies['dynamicTheme']->value = $dynamicTheme;
}
// if
}
// if
$cookie = new CHttpCookie("dynamicTheme", $dynamicTheme);
$cookie->expire = time() + 60 * 60 * 24 * 180;
Yii::app()->request->cookies['dynamicTheme'] = $cookie;
unset($_POST['change']);
}
// if isset $_POST['change']
if (isset(Yii::app()->request->cookies['dynamicTheme']->value)) {
$dynamicTheme = Yii::app()->request->cookies['dynamicTheme']->value;
} else {
$cookie = new CHttpCookie("dynamicTheme", $dynamicTheme);
$cookie->expire = time() + 60 * 60 * 24 * 180;
Yii::app()->request->cookies['dynamicTheme'] = $cookie;
}
// else
return parent::beforeAction($action);
}
示例3: beforeAction
public function beforeAction($action)
{
$controller = ucfirst(strtolower($this->getId()));
$action = ucfirst(strtolower($this->getAction()->getId()));
$module = '';
if (isset($this->module->id)) {
$module = ucfirst($this->module->id);
}
$operation = $module . $controller . $action;
/*if(false){//*/
if (!Yii::app()->adminUser->checkAccess($operation)) {
if (Yii::app()->request->isAjaxRequest) {
Yii::app()->user->setFlash('error', 'Not Authorized Action.');
throw new CHttpException(401, 'Unauthorized request.');
Yii::app()->end();
$content_type_arr = Yii::app()->request->getAcceptTypes();
$index = preg_match("/application\\/json/", $content_type_arr) || preg_match("/application\\/jsonp/", $content_type_arr);
} else {
if (Yii::app()->adminUser->isGuest) {
$this->redirect(array('/admin/user/login'));
} else {
$this->redirect(array('/admin/accessdenied'));
}
}
} else {
/*$unreadmessage = ContactMessage::model()->getUnreadCount();
Yii::app()->params['unread_message'] = $unreadmessage;*/
}
return parent::beforeAction($this->getAction());
}
示例4: beforeAction
protected function beforeAction($action)
{
parent::beforeAction($action);
if (Yii::app()->user->isGuest) {
if (isset(Yii::app()->request->cookies['prefLang'])) {
$sChosenLanguage = Yii::app()->request->cookies['prefLang']->value;
} else {
$sPrefferedLang = Yii::app()->request->getPreferredLanguage();
if ($sPrefferedLang !== false && strpos($sPrefferedLang, "ru") !== false) {
$sChosenLanguage = "ru";
} else {
$sChosenLanguage = "uk_ua";
}
$cookie = new CHttpCookie('prefLangId', $sChosenLanguage);
$cookie->expire = time() + 86400 * 7;
Yii::app()->request->cookies['prefLang'] = $cookie;
}
} else {
$sChosenLanguage = Yii::app()->user->getLanguage();
}
switch ($sChosenLanguage) {
case "ru":
Yii::app()->language = "ru";
break;
default:
Yii::app()->language = "uk_ua";
}
return true;
}
示例5: beforeAction
public function beforeAction($action)
{
if (!parent::beforeAction($action)) {
return false;
}
if (isset(Yii::app()->user->usIdent)) {
// Obtiene la clasificación de los equipos
$clasificacion = Clasificacion::model()->with('equipos')->findAll(array('order' => 'posicion ASC'));
Yii::app()->setParams(array('clasificacion' => $clasificacion));
// Obtiene la información del usuario
$usuario = Usuarios::model()->with('recursos')->findByPK(Yii::app()->user->usIdent);
Yii::app()->setParams(array('usuario' => $usuario));
// Obtiene la información de la mensajeria
//Saca la lista de los emails recibidos por el usuario y que ademas no los haya leido
$mensajeria = Emails::model()->findAllByAttributes(array('id_usuario_to' => Yii::app()->user->usIdent, 'leido' => 0));
$countmens = count($mensajeria);
Yii::app()->setParams(array('countmens' => $countmens));
// Obtiene la información de las notificaciones
//Saca la lista de las notinicaciones recibidas por el usuario y que ademas no haya leido
$notificaciones = Usrnotif::model()->findAllByAttributes(array('usuarios_id_usuario' => Yii::app()->user->usIdent, 'leido' => 0));
$countnot = count($notificaciones);
Yii::app()->setParams(array('countnot' => $countnot));
}
Yii::app()->setParams(array('bgclass' => 'bg-estadio-fuera'));
return true;
}
示例6: beforeAction
public function beforeAction($action)
{
if (Yum::module()->enableOnlineStatus && !Yii::app()->user->isGuest) {
Yii::app()->user->data()->setLastAction();
}
return parent::beforeAction($action);
}
示例7: beforeAction
public function beforeAction($action)
{
if (Yii::app()->user->isGuest && $action->controller != 'SiteController' && $action->id != 'login') {
$this->redirect(Yii::app()->user->loginUrl);
}
return parent::beforeAction($action);
}
示例8: beforeAction
/**
* Register any values that needed on beforeAction
* @param CAction $action action
* @return boolean whether the action is allowed ?
*/
public function beforeAction($action)
{
$this->registers();
$this->notifications();
$this->renderJS(array('baseURL' => Yii::app()->baseUrl), array());
return parent::beforeAction($action);
}
示例9: beforeAction
/**
* Set the base before action functions for the application
**/
public function beforeAction($action)
{
// Set the page class
$this->pageClass = Yii::app()->controller->id . '-' . Yii::app()->controller->action->id;
// Return parent before action for rules
return parent::beforeAction($action);
}
示例10: beforeAction
protected function beforeAction($action)
{
if (oreInstall::isInstalled()) {
throw404();
}
$this->setLangInstall();
return parent::beforeAction($action);
}
示例11: beforeAction
protected function beforeAction($action)
{
if (YII_DEBUG) {
Yii::app()->assetManager->forceCopy = true;
}
Yii::app()->assetManager->publish(Yii::getPathOfAlias('bootstrap.assets'), false, -1, YII_DEBUG);
return parent::beforeAction($action);
}
示例12: beforeAction
protected function beforeAction($action)
{
// var_dump( $action);
// var_dump(Yii::app()->admin->loginUrl);
if (Yii::app()->admin->isGuest && $action->getId() != 'login') {
$this->redirect(Yii::app()->admin->loginUrl);
}
return parent::beforeAction($action);
}
示例13: beforeAction
public function beforeAction($action) {
if(!Yum::module()->enableRESTapi)
throw new CHttpException(404);
else if($this->_checkAuth())
return parent::beforeAction($action);
else
throw new CHttpException(403);
}
示例14: beforeAction
public function beforeAction($action)
{
if (Yii::app()->user->isGuest && ($action->id != 'login'))
{
$this->redirect(array('/users/user/login', 'redirect' => urlencode($_SERVER['REQUEST_URI'])));
}
return parent::beforeAction($action);
}
示例15: beforeAction
public function beforeAction($action)
{
Yii::import('application.vendors.*');
require_once 'MyFunctions.php';
$myFunc = new MyFunctions();
$myFunc->counter();
return parent::beforeAction($action);
//return true;
}