/**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (!Yii::$app->user->isGuest) {
         throw new HttpException(401, 'Your are already logged in! - Logout first!');
     }
     return parent::beforeAction($action);
 }
 /**
  * Automatically loads the underlying contentContainer (User/Space) by using
  * the uguid/sguid request parameter
  *
  * @return boolean
  */
 public function init()
 {
     $spaceGuid = Yii::$app->request->get('sguid', '');
     $userGuid = Yii::$app->request->get('uguid', '');
     if ($spaceGuid != "") {
         $this->contentContainer = Space::findOne(['guid' => $spaceGuid]);
         if ($this->contentContainer == null) {
             throw new \yii\web\HttpException(404, Yii::t('base', 'Space not found!'));
         }
         $this->attachBehavior('SpaceControllerBehavior', array('class' => \humhub\modules\space\behaviors\SpaceController::className(), 'space' => $this->contentContainer));
         $this->subLayout = "@humhub/modules/space/views/space/_layout";
     } elseif ($userGuid != "") {
         $this->contentContainer = User::findOne(['guid' => $userGuid]);
         if ($this->contentContainer == null) {
             throw new \yii\web\HttpException(404, Yii::t('base', 'User not found!'));
         }
         $this->attachBehavior('ProfileControllerBehavior', ['class' => \humhub\modules\user\behaviors\ProfileController::className(), 'user' => $this->contentContainer]);
         $this->subLayout = "@humhub/modules/user/views/profile/_layout";
     } else {
         throw new \yii\web\HttpException(500, Yii::t('base', 'Could not determine content container!'));
     }
     /**
      * Auto check access rights to this container
      */
     if ($this->contentContainer != null) {
         if ($this->autoCheckContainerAccess) {
             $this->checkContainerAccess();
         }
     }
     if (!$this->checkModuleIsEnabled()) {
         throw new HttpException(405, Yii::t('base', 'Module is not on this content container enabled!'));
     }
     return parent::init();
 }
 public function beforeAction($action)
 {
     if (!Yii::$app->user->getIdentity()->isModuleEnabled('calendar')) {
         throw new HttpException('500', 'Calendar module is not enabled for your user!');
     }
     return parent::beforeAction($action);
 }
 public function beforeAction($action)
 {
     if (function_exists('opcache_reset')) {
         opcache_reset();
     }
     /**
      * Load language
      */
     $languages = $this->module->getLanguages();
     if (count($languages) == 0) {
         throw new HttpException(404, 'No language available!');
     }
     $this->language = Yii::$app->request->get('language', array_values($languages)[0]);
     if (!in_array($this->language, $languages)) {
         throw new HttpException(404, 'Language not found!');
     }
     /**
      * Load given Module Class
      */
     $this->moduleId = Yii::$app->request->get('moduleId', 'core');
     if (!in_array($this->moduleId, array_keys($this->module->getModuleIds()))) {
         throw new HttpException(404, 'Module not found!');
     }
     /**
      * Load given File 
      */
     $files = $this->module->getFiles($this->moduleId, $this->language);
     if (count($files) == 0) {
         throw new HttpException(400, 'Files not found!');
     }
     $this->file = Yii::$app->request->get('file', '');
     if (!in_array($this->file, $this->module->getFiles($this->moduleId, $this->language))) {
         $this->file = array_values($files)[0];
     }
     /**
      * Get Messages
      */
     $this->messages = array();
     $this->messageFileName = $this->module->getTranslationFile($this->moduleId, $this->language, $this->file);
     if (file_exists($this->messageFileName)) {
         $this->messages = $this->module->getTranslationMessages($this->messageFileName);
     }
     return parent::beforeAction($action);
 }
 /**
  * Before each config controller action check if
  *  - Database Connection works
  *  - Database Migrated Up
  *  - Not already configured (e.g. update)
  *
  * @param boolean
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         // Flush Caches
         Yii::$app->cache->flush();
         // Database Connection seems not to work
         if (!$this->module->checkDBConnection()) {
             $this->redirect(Url::to(['/installer/setup']));
             return false;
         }
         // When not at index action, verify that database is not already configured
         if ($action->id != 'finished') {
             if ($this->module->isConfigured()) {
                 $this->redirect(Url::to(['finished']));
                 return false;
             }
         }
         return true;
     }
     return false;
 }
 public function init()
 {
     $this->appendPageTitle(\Yii::t('SearchModule.base', 'Search'));
     return parent::init();
 }
Exemple #7
0
 public function init()
 {
     $this->appendPageTitle(\Yii::t('AdminModule.base', 'Administration'));
     return parent::init();
 }
 /**
  * Automatically loads the by content or content addon given by parameter.
  * className & id
  *
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     $modelClass = Yii::$app->request->get('contentModel');
     $pk = (int) Yii::$app->request->get('contentId');
     // Fixme
     if ($modelClass == '') {
         $modelClass = Yii::$app->request->post('contentModel');
         $pk = (int) Yii::$app->request->post('contentId');
     }
     if ($modelClass == "" || $pk == "") {
         throw new HttpException(500, 'Model & ID parameter required!');
     }
     \humhub\libs\Helpers::CheckClassType($modelClass, array(ContentAddonActiveRecord::className(), ContentActiveRecord::className()));
     $target = $modelClass::findOne(['id' => $pk]);
     if ($target === null) {
         throw new HttpException(500, 'Could not find underlying content or content addon record!');
     }
     if ($target instanceof ContentAddonActiveRecord) {
         $this->parentContentAddon = $target;
         $this->parentContent = $target->getSource();
     } else {
         $this->parentContent = $target;
     }
     if (!$this->parentContent->content->canRead()) {
         throw new HttpException(403, 'Access denied!');
     }
     $this->contentModel = get_class($target);
     $this->contentId = $target->getPrimaryKey();
     return parent::beforeAction($action);
 }
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         // Directly redirect guests to login page - if guest access isn't enabled
         if (Yii::$app->user->isGuest && Yii::$app->getModule('user')->settings->get('auth.allowGuestAccess') != 1) {
             Yii::$app->user->loginRequired();
             return false;
         }
         return true;
     }
     return false;
 }
Exemple #10
0
 public function init()
 {
     $this->appendPageTitle(\Yii::t('DirectoryModule.base', 'Directory'));
     return parent::init();
 }
 public function init()
 {
     $this->appendPageTitle(\Yii::t('DashboardModule.base', 'Dashboard'));
     return parent::init();
 }
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     // Remove authClient from session - if already exists
     Yii::$app->session->remove('authClient');
     return parent::beforeAction($action);
 }
 public function init()
 {
     $this->appendPageTitle(\Yii::t('UserModule.base', 'My Account'));
     return parent::init();
 }