コード例 #1
0
 protected function renderContent()
 {
     $placedViewTypes = $this->getPlacedViewTypes();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module->isEnabled()) {
             $p = $module->getParentModule();
             $viewClassNames = $module::getViewClassNames();
             foreach ($viewClassNames as $className) {
                 $viewReflectionClass = new ReflectionClass($className);
                 if (!$viewReflectionClass->isAbstract()) {
                     $portletRules = PortletRulesFactory::createPortletRulesByView($className);
                     if ($portletRules != null && $portletRules->allowOnDashboard()) {
                         if ($portletRules->allowMultiplePlacementOnDashboard() && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true || !$portletRules->allowMultiplePlacementOnDashboard() && !in_array($portletRules->getType(), $placedViewTypes) && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true) {
                             $metadata = $className::getMetadata();
                             $url = Yii::app()->createUrl($this->moduleId . '/defaultPortlet/add', array('uniqueLayoutId' => $this->uniqueLayoutId, 'dashboardId' => $this->dashboardId, 'portletType' => $portletRules->getType()));
                             if (isset($metadata['perUser']['title'])) {
                                 $title = $metadata['perUser']['title'];
                             } else {
                                 continue;
                             }
                             MetadataUtil::resolveEvaluateSubString($title);
                             $sortablePortlets[$title] = array('url' => $url, 'title' => $title, 'portletRules' => $portletRules);
                         }
                     }
                 }
             }
         }
     }
     return PortletUtil::renderAddPortletsContent($sortablePortlets);
 }
コード例 #2
0
 protected function renderContent()
 {
     $placedViewTypes = Portlet::getPlacedViewTypesByLayoutIdAndUser($this->uniqueLayoutId, Yii::app()->user->userModel->id);
     $modules = Module::getModuleObjects();
     $sortablePortlets = array();
     foreach ($modules as $module) {
         if ($module->isEnabled()) {
             $p = $module->getParentModule();
             $viewClassNames = $module::getViewClassNames();
             foreach ($viewClassNames as $className) {
                 $viewReflectionClass = new ReflectionClass($className);
                 if (!$viewReflectionClass->isAbstract()) {
                     $portletRules = PortletRulesFactory::createPortletRulesByView($className);
                     if ($viewReflectionClass->implementsInterface('RelatedPortletViewInterface')) {
                         if ($this->resolveLayoutIdInAllowedOnPortletViewClassNames($className) && $className::allowMultiplePlacement() == false && !in_array($portletRules->getType(), $placedViewTypes) && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true) {
                             $metadata = $className::getMetadata();
                             $url = Yii::app()->createUrl($this->moduleId . '/defaultPortlet/add', array('uniqueLayoutId' => $this->uniqueLayoutId, 'modelId' => $this->modelId, 'portletType' => $portletRules->getType()));
                             $title = $metadata['perUser']['title'];
                             MetadataUtil::resolveEvaluateSubString($title);
                             $sortablePortlets[$title] = array('url' => $url, 'title' => $title, 'portletRules' => $portletRules);
                         }
                     }
                 }
             }
         }
     }
     if (empty($sortablePortlets)) {
         $messageView = new NoPortletsToPlaceView();
         return $messageView->render();
     }
     //Sort by title
     ksort($sortablePortlets);
     return PortletUtil::renderAddPortletsContent($sortablePortlets);
 }
コード例 #3
0
 protected function renderContent()
 {
     $placedViewTypes = Portlet::getPlacedViewTypesByLayoutIdAndUser($this->uniqueLayoutId, Yii::app()->user->userModel->id);
     $content = '<ul class="available-portlets">';
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module->isEnabled()) {
             $p = $module->getParentModule();
             $viewClassNames = $module::getViewClassNames();
             foreach ($viewClassNames as $className) {
                 $viewReflectionClass = new ReflectionClass($className);
                 if (!$viewReflectionClass->isAbstract()) {
                     $portletRules = PortletRulesFactory::createPortletRulesByView($className);
                     if ($portletRules != null && $portletRules->allowOnDashboard()) {
                         if ($portletRules->allowMultiplePlacementOnDashboard() && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true || !$portletRules->allowMultiplePlacementOnDashboard() && !in_array($portletRules->getType(), $placedViewTypes) && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true) {
                             $metadata = $className::getMetadata();
                             $url = Yii::app()->createUrl($this->moduleId . '/defaultPortlet/add', array('uniqueLayoutId' => $this->uniqueLayoutId, 'dashboardId' => $this->dashboardId, 'portletType' => $portletRules->getType()));
                             $onClick = 'window.location.href = "' . $url . '"';
                             $content .= '<li>';
                             $title = $metadata['perUser']['title'];
                             MetadataUtil::resolveEvaluateSubString($title);
                             $label = '<span>\\</span>' . $title;
                             $content .= ZurmoHtml::link(Zurmo::t('HomeModule', $label), null, array('onclick' => $onClick));
                             $content .= '</li>';
                         }
                     }
                 }
             }
         }
     }
     $content .= '</ul>';
     return $content;
 }
コード例 #4
0
 protected function renderContent()
 {
     $placedViewTypes = Portlet::getPlacedViewTypesByLayoutIdAndUser($this->uniqueLayoutId, Yii::app()->user->userModel->id);
     $content = '<ul class="available-portlets">';
     $modules = Module::getModuleObjects();
     $sortablePortlets = array();
     foreach ($modules as $module) {
         if ($module->isEnabled()) {
             $p = $module->getParentModule();
             $viewClassNames = $module::getViewClassNames();
             foreach ($viewClassNames as $className) {
                 $viewReflectionClass = new ReflectionClass($className);
                 if (!$viewReflectionClass->isAbstract()) {
                     $portletRules = PortletRulesFactory::createPortletRulesByView($className);
                     if ($viewReflectionClass->implementsInterface('RelatedPortletViewInterface')) {
                         if ($this->resolveLayoutIdInAllowedOnPortletViewClassNames($className) && $className::allowMultiplePlacement() == false && !in_array($portletRules->getType(), $placedViewTypes) && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true) {
                             $metadata = $className::getMetadata();
                             $url = Yii::app()->createUrl($this->moduleId . '/defaultPortlet/add', array('uniqueLayoutId' => $this->uniqueLayoutId, 'modelId' => $this->modelId, 'portletType' => $portletRules->getType()));
                             $title = $metadata['perUser']['title'];
                             MetadataUtil::resolveEvaluateSubString($title);
                             $sortablePortlets[$title] = $url;
                         }
                     }
                 }
             }
         }
     }
     if (empty($sortablePortlets)) {
         $messageView = new NoPortletsToPlaceView();
         return $messageView->render();
     }
     //Sort by title
     ksort($sortablePortlets);
     foreach ($sortablePortlets as $title => $url) {
         $onClick = 'window.location.href = "' . $url . '"';
         $content .= '<li>';
         $label = '<span>\\</span>' . $title;
         $content .= ZurmoHtml::link(Zurmo::t('HomeModule', $label), null, array('onclick' => $onClick));
         $content .= '</li>';
     }
     $content .= '</ul>';
     return $content;
 }
コード例 #5
0
 public function testDoesCurrentUserHavePermissionToAddPortlet()
 {
     $betty = User::getByUsername('betty');
     Yii::app()->user->userModel = $betty;
     $portletRules = new RelatedListPortletRules('ProductsForAccountRelatedListView');
     $this->assertFalse(PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules));
     $betty->setRight('ProductsModule', ProductsModule::RIGHT_ACCESS_PRODUCTS);
     $saved = $betty->save();
     $this->assertTrue($saved);
     $this->assertTrue(PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules));
 }