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


PHP RightsUtil::canUserAccessModule方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: render

 /**
  * @return string
  */
 public function render()
 {
     if (RightsUtil::canUserAccessModule('ProductTemplatesModule', Yii::app()->user->userModel)) {
         return parent::render();
     } else {
         return '';
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:11,代码来源:ProductTemplatesMenuActionElement.php

示例12: resolveElementInformationDuringFormLayoutRender

 /**
  * Override to handle special cases for the user status attribute.
  * @see DetailsView::resolveElementInformationDuringFormLayoutRender()
  */
 protected function resolveElementInformationDuringFormLayoutRender(&$elementInformation)
 {
     if ($elementInformation['type'] == 'DerivedUserStatus' && !UserStatusUtil::canUserEditStatusOnAnotherUser(Yii::app()->user->userModel, $this->model)) {
         $elementInformation['type'] = 'ReadOnlyDerivedUserStatus';
     }
     if ($elementInformation['attributeName'] == 'role' && !RightsUtil::canUserAccessModule('RolesModule', Yii::app()->user->userModel)) {
         $elementInformation['type'] = 'ReadOnlyModel';
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:13,代码来源:UserEditView.php

示例13: testCanUserAccessModule

 public function testCanUserAccessModule()
 {
     $user = User::getByUsername('billy');
     $this->assertTrue(RightsUtil::canUserAccessModule('HomeModule', $user));
     $this->assertFalse(RightsUtil::canUserAccessModule('AccountsModule', $user));
     $user->setRight('AccountsModule', AccountsModule::RIGHT_ACCESS_ACCOUNTS);
     $saved = $user->save();
     $this->assertTrue($saved);
     $this->assertTrue(RightsUtil::canUserAccessModule('AccountsModule', $user));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:10,代码来源:RightsUtilTest.php

示例14: canCurrentUserCanAccessModule

 /**
  * @param string $moduleClassName
  * @return bool
  */
 public static function canCurrentUserCanAccessModule($moduleClassName)
 {
     assert('is_string($moduleClassName)');
     if ($moduleClassName::getStateMetadataAdapterClassName() != null) {
         $workflowRules = WorkflowRules::makeByModuleClassName($moduleClassName);
         return $workflowRules->canUserAccessModuleInAVariableState(Yii::app()->user->userModel);
     } else {
         return RightsUtil::canUserAccessModule($moduleClassName, Yii::app()->user->userModel);
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:14,代码来源:WorkflowSecurityUtil.php

示例15: resolveCanCurrentUserAccessAction

 /**
  * @param int $userId
  */
 public static function resolveCanCurrentUserAccessAction($userId)
 {
     if (Yii::app()->user->userModel->id == $userId || RightsUtil::canUserAccessModule('SendGridModule', Yii::app()->user->userModel)) {
         return;
     }
     $messageView = new AccessFailureView();
     $view = new AccessFailurePageView($messageView);
     echo $view->render();
     Yii::app()->end(0, false);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:13,代码来源:SendGridAccessUtil.php


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