protected function beforeAction($action)
 {
     if (!TsTranslation::model()->isAccessEnabled()) {
         if (Yii::app()->request->isAjaxRequest) {
             echo '{"ok":0, "message":"You have no permission to do this action!"}';
             Yii::app()->end();
         } else {
             throw new CHttpException(403, 'You have no permission to do this action!');
         }
     }
     return parent::beforeAction($action);
 }
Example #2
0
 public function init()
 {
     parent::init();
     /** @var $app CWebApplication */
     $app = Yii::app();
     $this->assetsUrl = $app->assetManager->publish(__DIR__ . '/assets');
     $this->viewPath = __DIR__ . '/views';
     /** @var $yiiTwigRenderer ETwigViewRenderer */
     $yiiTwigRenderer = Yii::app()->getComponent('viewRenderer');
     /** @var $twig_LoaderInterface Twig_Loader_Filesystem */
     $twig_LoaderInterface = $yiiTwigRenderer->getTwig()->getLoader();
     $twig_LoaderInterface->addPath($this->viewPath);
 }
Example #3
0
 function init()
 {
     parent::init();
     //为flash上传设置session
     $sessionName = session_name();
     if (isset($_GET[$sessionName]) && strlen($_GET[$sessionName]) > 0) {
         $_COOKIE[$sessionName] = $_GET[$sessionName];
     }
     //TODO:更详细的权限检查需要自己做
     if (Yii::app()->user->isGuest) {
         echo json_encode(array('state' => '没有权限'));
         Yii::app()->end();
     }
     Yii::import('ext.baiduUeditor.*');
     $this->_config = (require_once 'config.php');
     require_once 'Uploader.class.php';
 }
Example #4
0
 public function render($view, $data = null, $return = false)
 {
     return parent::render($view, $data, $return);
 }