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


PHP ExplicitReadWriteModelPermissionsUtil::resolveByPostDataAndModelThenMake方法代码示例

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


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

示例1: resolveAndMakeExplicitReadWriteModelPermissions

 protected static function resolveAndMakeExplicitReadWriteModelPermissions($sanitizedData, $model)
 {
     if ($model instanceof SecurableItem) {
         return ExplicitReadWriteModelPermissionsUtil::resolveByPostDataAndModelThenMake($sanitizedData, $model);
     } else {
         return null;
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:8,代码来源:ZurmoControllerUtil.php

示例2: testProductSaveWithPermissions

 public function testProductSaveWithPermissions()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $contacts = Contact::getAll();
     $accounts = Account::getByName('superAccount');
     $opportunities = Opportunity::getByName('superOpportunity');
     $productTemplates = ProductTemplate::getByName('superProductTemplate');
     $account = $accounts[0];
     $user = $account->owner;
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $explicitReadWriteModelPermissions = new ExplicitReadWriteModelPermissions();
     $currencyHelper = Yii::app()->currencyHelper;
     $currencyCode = $currencyHelper->getBaseCode();
     $currency = Currency::getByCode($currencyCode);
     $postData = array('productTemplate' => array('id' => $productTemplates[0]->id), 'name' => 'ProductPermissionTest', 'quantity' => 6, 'account' => array('id' => $accounts[0]->id), 'contact' => array('id' => $contacts[0]->id), 'opportunity' => array('id' => ''), 'type' => ProductTemplate::TYPE_PRODUCT, 'priceFrequency' => ProductTemplate::PRICE_FREQUENCY_ONE_TIME, 'sellPrice' => array('currency' => array('id' => $currency->id), 'value' => 210), 'stage' => array('value' => 'Open'), 'owner' => array('id' => $user->id), 'explicitReadWriteModelPermissions' => array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP, 'nonEveryoneGroup' => ''));
     $model = new Product();
     $sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel($model, $postData);
     if ($model instanceof SecurableItem) {
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::resolveByPostDataAndModelThenMake($sanitizedPostData, $model);
     } else {
         $explicitReadWriteModelPermissions = null;
     }
     $readyToUseData = ExplicitReadWriteModelPermissionsUtil::removeIfExistsFromPostData($sanitizedPostData);
     $sanitizedOwnerData = PostUtil::sanitizePostDataToJustHavingElementForSavingModel($readyToUseData, 'owner');
     $sanitizedDataWithoutOwner = PostUtil::removeElementFromPostDataForSavingModel($readyToUseData, 'owner');
     $model->setAttributes($sanitizedDataWithoutOwner);
     if ($model->validate()) {
         $modelToStringValue = strval($model);
         if ($sanitizedOwnerData != null) {
             $model->setAttributes($sanitizedOwnerData);
         }
         if ($model instanceof OwnedSecurableItem) {
             $passedOwnerValidation = $model->validate(array('owner'));
         } else {
             $passedOwnerValidation = true;
         }
         if ($passedOwnerValidation && $model->save(false)) {
             if ($explicitReadWriteModelPermissions != null) {
                 $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($model, $explicitReadWriteModelPermissions);
                 //todo: handle if success is false, means adding/removing permissions save failed.
             }
             $savedSuccessfully = true;
         }
     } else {
     }
     $this->assertEquals('ProductPermissionTest', $model->name);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:47,代码来源:ProductTest.php

示例3: actionSave

 public function actionSave($builtType)
 {
     $postData = PostUtil::getData();
     $emailTemplate = null;
     $this->resolveEmailTemplateByPostData($postData, $emailTemplate, $builtType);
     $emailTemplateToWizardFormAdapter = new EmailTemplateToWizardFormAdapter($emailTemplate);
     $model = $emailTemplateToWizardFormAdapter->makeFormByBuiltType();
     if (isset($postData['ajax']) && $postData['ajax'] === 'edit-form') {
         $this->actionValidate($postData, $model);
     }
     $unmuteScoring = false;
     if ($emailTemplate->isBuilderTemplate() && ($emailTemplate->isDraft || !isset($emailTemplate->isDraft))) {
         Yii::app()->gameHelper->muteScoringModelsOnSave();
         $unmuteScoring = true;
     }
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::resolveByPostDataAndModelThenMake($postData[get_class($model)], $emailTemplate);
     if ($emailTemplate->save()) {
         if ($unmuteScoring) {
             Yii::app()->gameHelper->unmuteScoringModelsOnSave();
         }
         if ($explicitReadWriteModelPermissions != null) {
             ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($emailTemplate, $explicitReadWriteModelPermissions);
         }
         $modelClassName = $emailTemplate->modelClassName;
         $moduleClassName = $modelClassName::getModuleClassName();
         echo CJSON::encode(array('id' => $emailTemplate->id, 'redirectToList' => false, 'moduleClassName' => $moduleClassName));
         Yii::app()->end(0, false);
     } else {
         throw new FailedToSaveModelException();
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:31,代码来源:DefaultController.php

示例4: testResolveByPostDataAndModelThenMake

 /**
  * @depends testResolveExplicitReadWriteModelPermissions
  */
 public function testResolveByPostDataAndModelThenMake()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $accounts = Account::getByName('aTestAccount');
     $this->assertEquals(1, count($accounts));
     $account = $accounts[0];
     $group3 = Group::getByName('Group3');
     //Remove group 2 and 4, and add group 3.
     $postData = array('explicitReadWriteModelPermissions' => array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_NONEVERYONE_GROUP, 'nonEveryoneGroup' => $group3->id));
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::resolveByPostDataAndModelThenMake($postData, $account);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     $this->assertEquals($group3, $readWritePermitables[$group3->id]);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:19,代码来源:ExplicitReadWriteModelPermissionsUtilTest.php

示例5: actionSave

 public function actionSave($type, $id = null, $isBeingCopied = false)
 {
     $postData = PostUtil::getData();
     $savedReport = null;
     $report = null;
     $this->resolveSavedReportAndReportByPostData($postData, $savedReport, $report, $type, $id, (bool) $isBeingCopied);
     $reportToWizardFormAdapter = new ReportToWizardFormAdapter($report);
     $model = $reportToWizardFormAdapter->makeFormByType();
     if (isset($postData['ajax']) && $postData['ajax'] === 'edit-form') {
         $errorData = ReportUtil::validateReportWizardForm($postData, $model);
         echo CJSON::encode($errorData);
         Yii::app()->end(0, false);
     }
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::resolveByPostDataAndModelThenMake($postData[get_class($model)], $savedReport);
     SavedReportToReportAdapter::resolveReportToSavedReport($report, $savedReport);
     if ($savedReport->id > 0) {
         ControllerSecurityUtil::resolveCanCurrentUserAccessModule($savedReport->moduleClassName);
     }
     ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($savedReport);
     if ($savedReport->save()) {
         StickyReportUtil::clearDataByKey($savedReport->id);
         if ($explicitReadWriteModelPermissions != null) {
             ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($savedReport, $explicitReadWriteModelPermissions);
         }
         //i can do a safety check on perms, then do flash here, on the jscript we can go to list instead and this should come up...
         //make sure you add to list of things to test.
         $redirectToList = $this->resolveAfterSaveHasPermissionsProblem($savedReport, $postData[get_class($model)]['name']);
         echo CJSON::encode(array('id' => $savedReport->id, 'redirectToList' => $redirectToList));
         Yii::app()->end(0, false);
     } else {
         throw new FailedToSaveModelException();
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:33,代码来源:DefaultController.php

示例6: testProjectSaveWithPermissions

 public function testProjectSaveWithPermissions()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $user = Yii::app()->user->userModel;
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $explicitReadWriteModelPermissions = new ExplicitReadWriteModelPermissions();
     $postData = array('name' => 'ProjectPermissionTest', 'description' => 'Test Description', 'owner' => array('id' => $user->id), 'explicitReadWriteModelPermissions' => array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP, 'nonEveryoneGroup' => ''));
     $model = new Project();
     $sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel($model, $postData);
     if ($model instanceof SecurableItem) {
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::resolveByPostDataAndModelThenMake($sanitizedPostData, $model);
     } else {
         $explicitReadWriteModelPermissions = null;
     }
     $readyToUseData = ExplicitReadWriteModelPermissionsUtil::removeIfExistsFromPostData($sanitizedPostData);
     $sanitizedOwnerData = PostUtil::sanitizePostDataToJustHavingElementForSavingModel($readyToUseData, 'owner');
     $sanitizedDataWithoutOwner = PostUtil::removeElementFromPostDataForSavingModel($readyToUseData, 'owner');
     $model->setAttributes($sanitizedDataWithoutOwner);
     if ($model->validate()) {
         $modelToStringValue = strval($model);
         if ($sanitizedOwnerData != null) {
             $model->setAttributes($sanitizedOwnerData);
         }
         if ($model instanceof OwnedSecurableItem) {
             $passedOwnerValidation = $model->validate(array('owner'));
         } else {
             $passedOwnerValidation = true;
         }
         if ($passedOwnerValidation && $model->save(false)) {
             if ($explicitReadWriteModelPermissions != null) {
                 $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($model, $explicitReadWriteModelPermissions);
                 //todo: handle if success is false, means adding/removing permissions save failed.
             }
             $savedSuccessfully = true;
         }
     } else {
     }
     $this->assertEquals('ProjectPermissionTest', $model->name);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:39,代码来源:ProjectTest.php


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