当前位置: 首页>>代码示例>>PHP>>正文


PHP RightsUtil类代码示例

本文整理汇总了PHP中RightsUtil的典型用法代码示例。如果您正苦于以下问题:PHP RightsUtil类的具体用法?PHP RightsUtil怎么用?PHP RightsUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RightsUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makeModelClassNamesAndSearchAttributeData

 protected static function makeModelClassNamesAndSearchAttributeData($partialTerm, User $user, $scopeData)
 {
     assert('is_string($partialTerm)');
     assert('$user->id > 0');
     assert('$scopeData == null || is_array($scopeData)');
     $modelClassNamesAndSearchAttributeData = array();
     $modelNamesAndLabels = WorkflownQueuesSearchForm::getInQueueSearchableModelNamesAndLabels();
     foreach ($modelNamesAndLabels as $modelClassName => $notUsed) {
         $moduleClassName = $modelClassName::getModuleClassName();
         $module = Yii::app()->findModule($moduleClassName::getDirectoryName());
         $globalSearchFormClassName = $moduleClassName::getGlobalSearchFormClassName();
         if ($globalSearchFormClassName != null && RightsUtil::canUserAccessModule(get_class($module), $user) && ($scopeData == null || in_array($modelClassName, $scopeData))) {
             $searchAttributes = MixedTermSearchUtil::getGlobalSearchAttributeByModuleAndPartialTerm($module, $partialTerm);
             if (!empty($searchAttributes)) {
                 $model = new $modelClassName(false);
                 assert('$model instanceof RedBeanModel');
                 $searchForm = new $globalSearchFormClassName($model);
                 assert('$searchForm instanceof SearchForm');
                 $metadataAdapter = new SearchDataProviderMetadataAdapter($searchForm, $user->id, $searchAttributes);
                 $metadata = $metadataAdapter->getAdaptedMetadata(false);
                 $modelClassNamesAndSearchAttributeData[$globalSearchFormClassName] = array($modelClassName => $metadata);
             }
         }
     }
     return $modelClassNamesAndSearchAttributeData;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:26,代码来源:WorkflowInQueuesModelAutoCompleteUtil.php

示例2: canCurrentUserPushDashboardOrLayout

 /**
  * Validates if current user has rights to push dashboard to users
  * @return bool
  */
 public static function canCurrentUserPushDashboardOrLayout()
 {
     if (RightsUtil::doesUserHaveAllowByRightName('ZurmoModule', ZurmoModule::RIGHT_PUSH_DASHBOARD_OR_LAYOUT, Yii::app()->user->userModel)) {
         return true;
     }
     return false;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:11,代码来源:PushDashboardUtil.php

示例3: renderEmailMessageToMatchContent

 /**
  * @return string content
  * @param EmailMessage object $emailMessage
  * @param User object $user
  */
 public static function renderEmailMessageToMatchContent(EmailMessage $emailMessage, $user)
 {
     $userCanAccessContacts = RightsUtil::canUserAccessModule('ContactsModule', $user);
     $userCanAccessLeads = RightsUtil::canUserAccessModule('LeadsModule', $user);
     $userCanCreateContact = RightsUtil::doesUserHaveAllowByRightName('ContactsModule', ContactsModule::getCreateRight(), $user);
     $userCanCreateLead = RightsUtil::doesUserHaveAllowByRightName('LeadsModule', LeadsModule::getCreateRight(), $user);
     if ($userCanAccessLeads && $userCanAccessContacts) {
         $selectForm = new AnyContactSelectForm();
     } elseif (!$userCanAccessLeads && $userCanAccessContacts) {
         $selectForm = new ContactSelectForm();
     } else {
         $selectForm = new LeadSelectForm();
     }
     if ($userCanCreateContact && $userCanCreateLead) {
         $gridSize = 3;
     } elseif ($userCanCreateContact || $userCanCreateLead) {
         $gridSize = 2;
     } else {
         $gridSize = 1;
     }
     $contact = new Contact();
     self::resolveEmailAddressAndNameToContact($emailMessage, $contact);
     $view = new ArchivedEmailMatchingView('default', 'emailMessages', $emailMessage, $contact, $selectForm, $userCanAccessLeads, $userCanAccessContacts, $userCanCreateContact, $userCanCreateLead, $gridSize);
     return $view->render();
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:30,代码来源:ArchivedEmailMatchingUtil.php

示例4: renderContent

 protected function renderContent()
 {
     $content = $this->renderTitleContent();
     $content .= '<ul class="configuration-list">';
     $modules = Module::getModuleObjects();
     $moduleClassNamesAndLabels = array();
     foreach ($modules as $module) {
         $moduleTreeMenuItems = $module->getDesignerMenuItems();
         if ($module->isEnabled() && !empty($moduleTreeMenuItems)) {
             $moduleClassNamesAndLabels[get_class($module)] = $module::getModuleLabelByTypeAndLanguage('Plural');
         }
     }
     asort($moduleClassNamesAndLabels);
     foreach ($moduleClassNamesAndLabels as $moduleClassName => $label) {
         if (RightsUtil::canUserAccessModule($moduleClassName, Yii::app()->user->userModel)) {
             $route = $this->moduleId . '/' . $this->controllerId . '/modulesMenu/';
             $content .= ZurmoHtml::openTag('li');
             $content .= '<h4>' . $label . '</h4>';
             $content .= ZurmoHtml::link(ZurmoHtml::wrapLabel(Zurmo::t('Core', 'Configure')), Yii::app()->createUrl($route, array('moduleClassName' => $moduleClassName)), array('class' => 'white-button'));
             $content .= ZurmoHtml::closeTag('li');
         }
     }
     $content .= '</ul>';
     return $content;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:25,代码来源:DesignerPageMenuView.php

示例5: getImportRulesTypesForCurrentUser

 /**
  * Based on the current user, return the importRules types and their display labels.  Only include import rules
  * that the user has a right to access its corresponding module.
  * @return array of import rules types and display labels.
  */
 public static function getImportRulesTypesForCurrentUser()
 {
     //todo: cache results to improve performance if needed.
     $importRulesTypes = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $rulesClassNames = $module::getAllClassNamesByPathFolder('rules');
         foreach ($rulesClassNames as $ruleClassName) {
             $classToEvaluate = new ReflectionClass($ruleClassName);
             if (is_subclass_of($ruleClassName, 'ImportRules') && !$classToEvaluate->isAbstract()) {
                 $moduleClassNames = $ruleClassName::getModuleClassNames();
                 $addToArray = true;
                 foreach ($moduleClassNames as $moduleClassNameToCheckAccess) {
                     if (!RightsUtil::canUserAccessModule($moduleClassNameToCheckAccess, Yii::app()->user->userModel) || !RightsUtil::doesUserHaveAllowByRightName($moduleClassNameToCheckAccess, $moduleClassNameToCheckAccess::getCreateRight(), Yii::app()->user->userModel)) {
                         $addToArray = false;
                     }
                 }
                 if ($addToArray) {
                     $importRulesTypes[$ruleClassName::getType()] = $ruleClassName::getDisplayLabel();
                 }
             }
         }
     }
     return $importRulesTypes;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:30,代码来源:ImportRulesUtil.php

示例6: testResolvePortletsForCurrentUser

 public function testResolvePortletsForCurrentUser()
 {
     $betty = User::getByUsername('betty');
     $this->assertFalse(RightsUtil::canUserAccessModule('AccountsModule', $betty));
     $this->assertFalse(RightsUtil::canUserAccessModule('ContactsModule', $betty));
     $this->assertFalse(RightsUtil::canUserAccessModule('TasksModule', $betty));
     Yii::app()->user->userModel = $betty;
     $portlet1 = new Portlet();
     $portlet1->viewType = 'AccountsRelatedList';
     $portlet2 = new Portlet();
     $portlet2->viewType = 'ContactsRelatedList';
     $portlet3 = new Portlet();
     $portlet3->viewType = 'TasksMyList';
     $portlets = array();
     $portlets[0][0] = $portlet1;
     $portlets[0][1] = $portlet2;
     $portlets[0][2] = $portlet3;
     $portlets[1][0] = $portlet3;
     $portlets[1][1] = $portlet1;
     $portlets[1][2] = $portlet3;
     $this->assertEquals(2, count($portlets));
     $resolvedPortlets = PortletsSecurityUtil::resolvePortletsForCurrentUser($portlets);
     $comparePortlets = array();
     $comparePortlets[0][0] = $portlet3;
     $comparePortlets[1][0] = $portlet3;
     $comparePortlets[1][1] = $portlet3;
     $this->assertEquals(0, count($resolvedPortlets));
     Yii::app()->user->userModel = User::getByUsername('super');
     $resolvedPortlets = PortletsSecurityUtil::resolvePortletsForCurrentUser($portlets);
     $this->assertEquals($portlets, $resolvedPortlets);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:31,代码来源:PortletsSecurityUtilTest.php

示例7: getAllModuleRightsDataByPermitable

 /**
  * @return array of all module rights data
  */
 public static function getAllModuleRightsDataByPermitable(Permitable $permitable)
 {
     $data = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module instanceof SecurableModule) {
             $moduleClassName = get_class($module);
             $rights = $moduleClassName::getRightsNames();
             $rightLabels = $moduleClassName::getTranslatedRightsLabels();
             $reflectionClass = new ReflectionClass($moduleClassName);
             if (!empty($rights)) {
                 $rightsData = array();
                 foreach ($rights as $right) {
                     if (!isset($rightLabels[$right])) {
                         throw new NotSupportedException($right);
                     }
                     $explicit = $permitable->getExplicitActualRight($moduleClassName, $right);
                     $inherited = $permitable->getInheritedActualRight($moduleClassName, $right);
                     $effective = $permitable->getEffectiveRight($moduleClassName, $right);
                     $constants = $reflectionClass->getConstants();
                     $constantId = array_search($right, $constants);
                     $rightsData[$constantId] = array('displayName' => $rightLabels[$right], 'explicit' => RightsUtil::getRightStringFromRight($explicit), 'inherited' => RightsUtil::getRightStringFromRight($inherited), 'effective' => RightsUtil::getRightStringFromRight($effective));
                 }
                 $data[$moduleClassName] = ArrayUtil::subValueSort($rightsData, 'displayName', 'asort');
             }
         }
     }
     return $data;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:32,代码来源:RightsUtil.php

示例8: canUserAccessPortlet

 /**
  * In order for a user to have access to an accountContactAffiliation portlet, the user must have access rights
  * to the Accounts and Contacts module as well as rights to the AccountContactAffiliations module.
  * @param User $user
  * @return bool
  */
 public function canUserAccessPortlet(User $user)
 {
     if (RightsUtil::canUserAccessModule('AccountsModule', $user) && RightsUtil::canUserAccessModule('ContactsModule', $user)) {
         return true;
     }
     return false;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:13,代码来源:AccountContactAffiliationsRelatedListPortletRules.php

示例9: getDefaultRoute

 /**
  * @return string
  */
 protected function getDefaultRoute()
 {
     if (RightsUtil::doesUserHaveAllowByRightName('ContactWebFormsModule', ContactWebFormsModule::getCreateRight(), Yii::app()->user->userModel)) {
         return Yii::app()->createUrl('contactWebForms/default/create/');
     }
     return null;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:10,代码来源:ContactWebFormsCreateMenuActionElement.php

示例10: renderControlEditable

 /**
  * Override so it only render if to recipient is a Contact
  * and the user has the right to access Email Templates
  * @return string
  */
 protected function renderControlEditable()
 {
     if ($this->shouldUseTemplate() && RightsUtil::canUserAccessModule('EmailTemplatesModule', Yii::app()->user->userModel)) {
         return parent::renderControlEditable();
     }
     return null;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:12,代码来源:EmailMessageEmailTemplateElement.php

示例11: resolveModelElementTypeByActionSecurity

 /**
  * @param string $modelClassName
  * @param User $user
  * @param $canAccess
  * @return string
  */
 public static function resolveModelElementTypeByActionSecurity($modelClassName, $user, &$canAccess)
 {
     assert('is_string($modelClassName)');
     assert('$user instanceof User && $user->id > 0');
     if ($modelClassName == 'Contact') {
         $canAccessContacts = RightsUtil::canUserAccessModule('ContactsModule', $user);
         $canAccessLeads = RightsUtil::canUserAccessModule('LeadsModule', $user);
         if ($canAccessContacts && $canAccessLeads) {
             return 'AllStatesContact';
         } elseif (!$canAccessContacts && $canAccessLeads) {
             return 'Lead';
         } elseif ($canAccessContacts && !$canAccessLeads) {
             return 'Contact';
         } else {
             $canAccess = false;
             return 'Contact';
         }
     } else {
         $moduleClassName = $modelClassName::getModuleClassName();
         if (!RightsUtil::canUserAccessModule($moduleClassName, $user)) {
             $canAccess = false;
         }
         return $modelClassName;
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:31,代码来源:RelatedItemRelationToModelElementUtil.php

示例12: canUserAccessModuleInAVariableState

 /**
  * @param User $user
  * @return bool
  */
 public static function canUserAccessModuleInAVariableState(User $user)
 {
     assert('$user->id > 0');
     if (RightsUtil::canUserAccessModule('ContactsModule', $user) || RightsUtil::canUserAccessModule('LeadsModule', $user)) {
         return true;
     }
     return false;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:12,代码来源:ContactsReportRules.php

示例13: render

 /**
  * @return string
  */
 public function render()
 {
     if (RightsUtil::canUserAccessModule('ProductTemplatesModule', Yii::app()->user->userModel)) {
         return ZurmoHtml::link($this->resolveLabelAndWrap(), $this->route, $this->getHtmlOptions());
     } else {
         return '';
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:11,代码来源:ProductTemplatesLinkActionElement.php

示例14: preFilter

 protected function preFilter($filterChain)
 {
     if (RightsUtil::doesUserHaveAllowByRightName($this->moduleClassName, $this->rightName, Yii::app()->user->userModel)) {
         return true;
     }
     static::processAccessFailure();
     Yii::app()->end(0, false);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:8,代码来源:RightsControllerFilter.php

示例15: getMenuItems

 protected function getMenuItems()
 {
     $items = array();
     if (RightsUtil::doesUserHaveAllowByRightName('CampaignsModule', CampaignsModule::getCreateRight(), Yii::app()->user->userModel)) {
         $items[] = array('label' => Zurmo::t('CampaignsModule', 'Create Campaign'), 'url' => Yii::app()->createUrl('campaigns/default/create'));
         return $items;
     }
     return null;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:9,代码来源:CampaignsMenuActionElement.php


注:本文中的RightsUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。