Пример #1
0
 public static function resolveBreadCrumbViewForDetailsControllerAction(CController $controller, $stickySearchKey, RedBeanModel $model)
 {
     assert('is_string($stickySearchKey)');
     if (ArrayUtil::getArrayValue(GetUtil::getData(), 'stickyOffset') !== null && StickySearchUtil::getDataByKey($stickySearchKey) != null) {
         $stickyLoadUrl = Yii::app()->createUrl($controller->getModule()->getId() . '/' . $controller->getId() . '/renderStickyListBreadCrumbContent', array('stickyKey' => $stickySearchKey, 'stickyOffset' => ArrayUtil::getArrayValue(GetUtil::getData(), 'stickyOffset'), 'stickyModelId' => $model->id));
     } else {
         $stickyLoadUrl = null;
     }
     $className = static::resolveStickyDetailsAndRelationsBreadCrumbViewClassName();
     return new $className($controller->getId(), $controller->getModule()->getId(), static::resolveBreadcrumbLinks($model), $controller->getModule()->getModuleLabelByTypeAndLanguage('Plural'), $stickyLoadUrl);
 }
 /**
  * @return rendered content from view as string.
  */
 public static function renderList(CController $controller, $dataProvider)
 {
     assert('$dataProvider instanceof RedBeanModelDataProvider');
     $auditEventsListView = new AuditEventsModalListView($controller->getId(), $controller->getModule()->getId(), 'AuditEvent', $dataProvider, 'modal');
     $view = new ModalView($controller, $auditEventsListView);
     return $view->render();
 }
Пример #3
0
 /**
  * Checks whether the Web user is allowed to perform the specified action.
  * @param CWebUser $user the user object
  * @param CController $controller the controller currently being executed
  * @param CAction $action the action to be performed
  * @param string $ip the request IP address
  * @param string $verb the request verb (GET, POST, etc.)
  * @return integer 1 if the user is allowed, -1 if the user is denied, 0 if the rule does not apply to the user
  */
 public function isUserAllowed($user, $controller, $action, $ip, $verb)
 {
     try {
         /*
         			$sesMod = $user->getState('modType');
         			$oCurMod = $controller->getModule();
         			if( $oCurMod != NULL ){
         				if( ($oCurMod->getId() == 'ad' && $sesMod == 'pub') ||
         					($oCurMod->getId() == 'pub' && $sesMod == 'ad') )
         					
         				throw new CHttpException(EXCEPTION_NO_RIGHTS, Yii::t('general', 'pub_ad_mod_confused'));	
         			}
         */
         echo 'user access';
         return false;
         $aPerm = $user->perm;
         $aAction = $aPerm[$controller->getId()]['_p'];
         if (is_array($aAction) && in_array(strtolower($action->getId()), $aAction)) {
             return true;
         } else {
             throw new CHttpException(EXCEPTION_NO_RIGHTS, Yii::t('general', 'sorry, you have no rights to do this'));
         }
     } catch (Exception $e) {
         throw new CHttpException(EXCEPTION_NO_RIGHTS, Yii::t('general', 'sorry, you have no rights to do this'));
     }
 }
 /**
  * @return rendered content from view as string.
  */
 public static function renderList(CController $controller, $dataProvider, $action)
 {
     assert('$dataProvider instanceof RedBeanModelDataProvider');
     $modalListLinkProvider = new UserDetailsModalListLinkProvider('users', 'default', 'details');
     $usersListView = new UsersByModelModalListView($controller->getId(), $controller->getModule()->getId(), $action, 'User', $modalListLinkProvider, $dataProvider, 'modal');
     $view = new ModalView($controller, $usersListView);
     return $view->render();
 }
 /**
  * @return rendered content from view as string.
  */
 protected static function renderModalSearchList(CController $controller, $modalListLinkProvider, $stateMetadataAdapterClassName = null)
 {
     assert('$modalListLinkProvider instanceof ModalListLinkProvider');
     $className = $controller->getModule()->getPluralCamelCasedName() . 'ModalSearchAndListView';
     $modelClassName = $controller->getModule()->getPrimaryModelName();
     $searchViewClassName = $className::getSearchViewClassName();
     if ($searchViewClassName::getModelForMetadataClassName() != null) {
         $formModelClassName = $searchViewClassName::getModelForMetadataClassName();
         $model = new $modelClassName(false);
         $searchModel = new $formModelClassName($model);
     } else {
         throw new NotSupportedException();
     }
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('modalListPageSize', get_class($controller->getModule()));
     $dataProvider = $controller->makeRedBeanDataProviderByDataCollection($searchModel, $pageSize, $stateMetadataAdapterClassName);
     $searchAndListView = new $className($controller->getId(), $controller->getModule()->getId(), $controller->getAction()->getId(), $modalListLinkProvider, $searchModel, $model, $dataProvider, 'modal');
     $view = new ModalView($controller, $searchAndListView);
     return $view->render();
 }
Пример #6
0
 protected static function makeHeaderView(CController $controller)
 {
     $headerView = null;
     $settingsMenuItems = MenuUtil::getOrderedAccessibleHeaderMenuForCurrentUser();
     $settingsMenuItems = static::resolveHeaderMenuItemsForMobile($settingsMenuItems);
     $userMenuItems = static::getAndResolveUserMenuItemsForHeader();
     $applicationName = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'applicationName');
     if (Yii::app()->userInterface->isMobile()) {
         $headerView = new MobileHeaderView($settingsMenuItems, $userMenuItems, $applicationName);
     } else {
         $shortcutsCreateMenuItems = MenuUtil::getAccessibleShortcutsCreateMenuByCurrentUser();
         $moduleNamesAndLabels = GlobalSearchUtil::getGlobalSearchScopingModuleNamesAndLabelsDataByUser(Yii::app()->user->userModel);
         $sourceUrl = Yii::app()->createUrl('zurmo/default/globalSearchAutoComplete');
         GlobalSearchUtil::resolveModuleNamesAndLabelsDataWithAllOption($moduleNamesAndLabels);
         $headerView = new HeaderView($controller->getId(), $controller->getModule()->getId(), $settingsMenuItems, $userMenuItems, $shortcutsCreateMenuItems, $moduleNamesAndLabels, $sourceUrl, $applicationName);
     }
     return $headerView;
 }
Пример #7
0
 /**
  * Returns whether or not the given title is the default page title.
  * @param mixed $pageTitle the page title
  * @param CController $controller the controller
  * @return bool
  */
 protected function isDefaultPageTitle($pageTitle, $controller)
 {
     $name = ucfirst(basename($controller->getId()));
     return is_string($pageTitle) && ($pageTitle === Yii::app()->name . ' - ' . ucfirst($controller->getAction()->getId()) . ' ' . $name || $pageTitle === Yii::app()->name . ' - ' . $name);
 }
Пример #8
0
 /**
  * Map modal view for map popup..
  * @return rendered content from view as string.
  */
 protected function renderModalMapView(CController $controller, $modalMapAddressData, $stateMetadataAdapterClassName = null)
 {
     $renderAndMapModalView = new AddressMapModalView($controller->getId(), $controller->getModule()->getId(), $modalMapAddressData, 'modal');
     $view = new ModalView($controller, $renderAndMapModalView);
     return $view->render();
 }
 /**
  * Given a controller, two contained views, construct the gridview
  * used by the designer page view.
  * @param CController $controller
  * @param View $containedView
  * @param View $secondContainedView
  * @param array $breadCrumbLinks
  * @param $breadcrumbViewClassName
  * @param array $cssClasses
  * @return GridView
  */
 public static function makeTwoViewsWithBreadcrumbsForCurrentUser(CController $controller, View $containedView, View $secondContainedView, $breadCrumbLinks, $breadcrumbViewClassName, $cssClasses = array())
 {
     assert('is_array($breadCrumbLinks)');
     $gridView = new GridView(3, 1);
     $gridView->setCssClasses($cssClasses);
     $gridView->setView(new $breadcrumbViewClassName($controller->getId(), $controller->getModule()->getId(), $breadCrumbLinks), 0, 0);
     $gridView->setView($containedView, 1, 0);
     $gridView->setView($secondContainedView, 2, 0);
     return static::makeStandardViewForCurrentUser($controller, $gridView);
 }
Пример #10
0
 /**
  * Gets the action instances for the given controller
  * @param \CController $controller the controller to get actions for
  *
  * @return \CAction[] the controller actions
  */
 public function getActionInstances(\CController $controller)
 {
     $controllerId = $controller->getId();
     $module = $controller->getModule();
     if (!is_object($module)) {
         $module = \Yii::app();
     }
     $uniqueId = $this->getModuleUniqueId($module);
     if (!isset($this->_data[$uniqueId])) {
         $this->_data[$uniqueId] = array();
     }
     if (!isset($this->_data[$uniqueId]['controllers'])) {
         $this->getControllerInstances($module);
     }
     if (!isset($this->_data[$uniqueId]['controllers'][$controllerId]['actions'])) {
         $this->_data[$uniqueId]['controllers'][$controllerId]['actions'] = $this->createActionInstances($controller);
     }
     return $this->_data[$uniqueId]['controllers'][$controllerId]['actions'];
 }
Пример #11
0
 /**
  * The pre-filter for controller actions.
  * This method is invoked before the currently requested controller action and all its filters
  * are executed. You may override this method with logic that needs to be done
  * before all controller actions.
  * @param CController $controller the controller
  * @param CAction $action the action
  * @return boolean whether the action should be executed.
  */
 public function beforeControllerAction($controller, $action)
 {
     /**
      * Plugin event done before all web controller action
      * Can set run to false to deactivate action
      */
     $event = new PluginEvent('beforeControllerAction');
     $event->set('controller', $controller->getId());
     $event->set('action', $action->getId());
     App()->getPluginManager()->dispatchEvent($event);
     return $event->get("run", parent::beforeControllerAction($controller, $action));
 }
Пример #12
0
 /**
  * @param CController $controller the controller
  * @return boolean whether the rule applies to the controller
  */
 protected function isControllerMatched($controller)
 {
     return empty($this->controllers) || in_array(strtolower($controller->getId()), $this->controllers);
 }
Пример #13
0
 /**
  * @return CAction|void
  */
 public function getId($value = null)
 {
     if (empty($value)) {
         return parent::getId();
     } elseif ($value === parent::getId()) {
         return true;
     }
 }