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


PHP ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions方法代码示例

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


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

示例1: saveModelFromSanitizedData

 public function saveModelFromSanitizedData($sanitizedData, $model, &$savedSuccessfully, &$modelToStringValue)
 {
     //note: the logic for ExplicitReadWriteModelPermission might still need to be moved up into the
     //post method above, not sure how this is coming in from API.
     $explicitReadWriteModelPermissions = static::resolveAndMakeExplicitReadWriteModelPermissions($sanitizedData, $model);
     $readyToUseData = ExplicitReadWriteModelPermissionsUtil::removeIfExistsFromPostData($sanitizedData);
     $sanitizedOwnerData = PostUtil::sanitizePostDataToJustHavingElementForSavingModel($readyToUseData, 'owner');
     $sanitizedDataWithoutOwner = PostUtil::removeElementFromPostDataForSavingModel($readyToUseData, 'owner');
     $model->setAttributes($sanitizedDataWithoutOwner);
     $this->afterSetAttributesDuringSave($model, $explicitReadWriteModelPermissions);
     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;
             $this->afterSuccessfulSave($model);
         }
     } else {
     }
     return $model;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:32,代码来源:ZurmoControllerUtil.php

示例2: setContactModelPermissionsByContactWebForm

 public static function setContactModelPermissionsByContactWebForm(SecurableItem $model, ContactWebForm $contactWebForm)
 {
     if ($model instanceof SecurableItem && count($model->permissions) === 0) {
         $defaultPermission = ContactWebFormAdapter::resolveAndGetDefaultPermissionSetting($contactWebForm);
         $nonEveryoneGroup = $contactWebForm->defaultPermissionGroupSetting;
         $type = DerivedExplicitReadWriteModelPermissionsElement::resolveUserPermissionConfigurationToPermissionType($defaultPermission);
         $postData = array('explicitReadWriteModelPermissions' => compact('type', 'nonEveryoneGroup'));
         $explicitReadWritePermissions = self::resolveAndMakeExplicitReadWriteModelPermissions($postData, $model);
         $updated = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($model, $explicitReadWritePermissions);
         if (!$updated) {
             throw new NotSupportedException();
         }
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:14,代码来源:ContactWebFormsZurmoControllerUtil.php

示例3: actionAfterSuccessfulModelSave

 /**
  * Override to process the note as a social item when needed.
  * (non-PHPdoc)
  * @see ZurmoBaseController::actionAfterSuccessfulModelSave()
  */
 protected function actionAfterSuccessfulModelSave($model, $modelToStringValue, $redirectUrlParams = null)
 {
     assert('$model instanceof Note');
     if (ArrayUtil::getArrayValue(PostUtil::getData(), 'postToProfile')) {
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($model);
         $socialItem = new SocialItem();
         $socialItem->note = $model;
         $saved = $socialItem->save();
         if (!$saved) {
             throw new FailedToSaveModelException();
         }
         ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($socialItem, $explicitReadWriteModelPermissions);
     }
     parent::actionAfterSuccessfulModelSave($model, $modelToStringValue, $redirectUrlParams);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:20,代码来源:DefaultController.php

示例4: makeAll

 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     assert('$demoDataHelper->isSetRange("Account")');
     $conversations = array();
     foreach (self::getConversationData() as $randomConversationData) {
         $postData = array();
         $conversation = new Conversation();
         $conversation->setScenario('importModel');
         $conversation->owner = $demoDataHelper->getRandomByModelName('User');
         $conversation->createdByUser = $conversation->owner;
         $conversation->conversationItems->add($demoDataHelper->getRandomByModelName('Account'));
         $conversation->subject = $randomConversationData['subject'];
         $conversation->description = $randomConversationData['description'];
         //Add some comments
         foreach ($randomConversationData['comments'] as $commentDescription) {
             $comment = new Comment();
             $comment->setScenario('importModel');
             $comment->createdByUser = $demoDataHelper->getRandomByModelName('User');
             $comment->description = $commentDescription;
             $conversation->comments->add($comment);
             self::addItemIdToPostData($postData, $comment->createdByUser->getClassId('Item'));
         }
         //Add Super user
         $comment = new Comment();
         $comment->description = 'Great idea guys. Keep it coming.';
         $conversation->comments->add($comment);
         self::addItemIdToPostData($postData, Yii::app()->user->userModel->getClassId('Item'));
         $saved = $conversation->save();
         assert('$saved');
         //any user who has made a comment should be added as a participant and resolve permissions
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
         ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
         $saved = $conversation->save();
         assert('$saved');
         $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
         $saved = $conversation->save();
         assert('$success');
         $conversations[] = $conversation->id;
     }
     $demoDataHelper->setRangeByModelName('Conversation', $conversations[0], $conversations[count($conversations) - 1]);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:46,代码来源:ConversationsDemoDataMaker.php

示例5: makeMeetingsCategoryAndMonthStartTimeByOwner

 public static function makeMeetingsCategoryAndMonthStartTimeByOwner()
 {
     $report = new Report();
     $report->setModuleClassName('MeetingsModule');
     $report->setName('Meettings Category And Month Start Time By Owner');
     $report->setType(Report::TYPE_MATRIX);
     $report->setOwner(Yii::app()->user->userModel);
     $report->setFiltersStructure('');
     $report->setCurrencyConversionType(Report::CURRENCY_CONVERSION_TYPE_BASE);
     $groupBy = new GroupByForReportForm('MeetingsModule', 'Meeting', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'startDateTime__Month';
     $groupBy->axis = 'x';
     $report->addGroupBy($groupBy);
     $groupBy = new GroupByForReportForm('MeetingsModule', 'Meeting', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'category';
     $groupBy->axis = 'x';
     $report->addGroupBy($groupBy);
     $groupBy = new GroupByForReportForm('MeetingsModule', 'Meeting', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'owner__User';
     $groupBy->axis = 'y';
     $report->addGroupBy($groupBy);
     $displayAttribute = new DisplayAttributeForReportForm('MeetingsModule', 'Meeting', $report->getType());
     $displayAttribute->attributeIndexOrDerivedType = 'Count';
     $report->addDisplayAttribute($displayAttribute);
     $savedReport = new SavedReport();
     SavedReportToReportAdapter::resolveReportToSavedReport($report, $savedReport);
     //set explicit
     $saved = $savedReport->save();
     assert('$saved');
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($savedReport);
     $explicitReadWriteModelPermissions->addReadWritePermitable(Group::getByName(Group::EVERYONE_GROUP_NAME));
     $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($savedReport, $explicitReadWriteModelPermissions);
     assert('$success');
     $saved = $savedReport->save();
     assert('$saved');
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:36,代码来源:ReportsDemoDataMaker.php

示例6: importByImportRulesRowData

 /**
  * Given a row of data, resolve each value of the row for import and either create or update an existing model.
  * @param object $importRules
  * @param array $rowData
  * @param array $mappingData
  * @param object $importRowDataResultsUtil
  */
 public static function importByImportRulesRowData(ImportRules $importRules, $rowBean, $mappingData, ImportRowDataResultsUtil $importRowDataResultsUtil, ExplicitReadWriteModelPermissions $explicitReadWriteModelPermissions)
 {
     assert('$rowBean instanceof RedBean_OODBBean');
     assert('is_array($mappingData)');
     $makeNewModel = true;
     $modelClassName = $importRules->getModelClassName();
     $externalSystemId = null;
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $afterSaveActionsData = array();
     //Process the 'id' column first if available.
     if (false !== ($idColumnName = static::getIdColumnNameByMappingData($mappingData))) {
         $columnMappingData = $mappingData[$idColumnName];
         $attributeImportRules = AttributeImportRulesFactory::makeByImportRulesTypeAndAttributeIndexOrDerivedType($importRules::getType(), $columnMappingData['attributeIndexOrDerivedType']);
         $valueReadyToSanitize = static::resolveValueToSanitizeByValueAndColumnType($rowBean->{$idColumnName}, $columnMappingData['type']);
         $attributeValueData = $attributeImportRules->resolveValueForImport($valueReadyToSanitize, $columnMappingData, $importSanitizeResultsUtil);
         assert('count($attributeValueData) == 0 || count($attributeValueData) == 1');
         if (isset($attributeValueData['id']) && $attributeValueData['id'] != null) {
             $model = $modelClassName::getById($attributeValueData['id']);
             $makeNewModel = false;
         } elseif (isset($attributeValueData[ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME]) && $attributeValueData[ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME] != null) {
             $externalSystemId = $attributeValueData[ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME];
         }
     }
     if ($makeNewModel) {
         $model = new $modelClassName();
         $model->setScenario('importModel');
     }
     //Process the rest of the mapped colummns. ignoring owner.
     foreach ($mappingData as $columnName => $columnMappingData) {
         if ($columnMappingData['attributeIndexOrDerivedType'] != null && $columnMappingData['attributeIndexOrDerivedType'] != 'owner' && $idColumnName != $columnName) {
             static::sanitizeValueAndPopulateModel($rowBean, $importRules, $model, $columnName, $modelClassName, $columnMappingData, $importSanitizeResultsUtil, $afterSaveActionsData);
         }
     }
     //Process the owner column if present
     foreach ($mappingData as $columnName => $columnMappingData) {
         if ($columnMappingData['attributeIndexOrDerivedType'] != null && $columnMappingData['attributeIndexOrDerivedType'] == 'owner' && $idColumnName != $columnName) {
             static::sanitizeValueAndPopulateModel($rowBean, $importRules, $model, $columnName, $modelClassName, $columnMappingData, $importSanitizeResultsUtil, $afterSaveActionsData);
         }
     }
     $validated = $model->validate();
     if ($validated && $importSanitizeResultsUtil->shouldSaveModel()) {
         $saved = $model->save();
         if ($saved) {
             static::processAfterSaveActions($afterSaveActionsData, $model);
             if ($externalSystemId != null) {
                 ExternalSystemIdUtil::updateByModel($model, $externalSystemId);
             }
             $importRowDataResultsUtil->addMessage(Zurmo::t('ImportModule', 'Record saved correctly.'));
             if ($makeNewModel) {
                 if ($model instanceof SecurableItem) {
                     try {
                         $resolved = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($model, $explicitReadWriteModelPermissions);
                         $importRowDataResultsUtil->setStatusToCreated();
                         if (!$resolved) {
                             $importRowDataResultsUtil->addMessage('The record saved, but there was a problem ' . 'setting the security permissions. It will at least be viewable by the owner.');
                             $importRowDataResultsUtil->setStatusToError();
                         }
                     } catch (AccessDeniedSecurityException $e) {
                         $importRowDataResultsUtil->addMessage('The record saved, but you do not have permissions ' . 'to set the security the way you did. The record will only be viewable by the owner.');
                         $importRowDataResultsUtil->setStatusToError();
                     }
                 } else {
                     $importRowDataResultsUtil->setStatusToCreated();
                 }
             } else {
                 $importRowDataResultsUtil->setStatusToUpdated();
             }
         } else {
             $importRowDataResultsUtil->addMessage('The record failed to save. Reason unknown.');
             $importRowDataResultsUtil->setStatusToError();
         }
     } else {
         if (!$importSanitizeResultsUtil->shouldSaveModel()) {
             $importRowDataResultsUtil->addMessages($importSanitizeResultsUtil->getMessages());
         }
         $messages = RedBeanModelErrorsToMessagesUtil::makeMessagesByModel($model);
         if (count($messages) > 0) {
             $importRowDataResultsUtil->addMessages($messages);
         }
         $importRowDataResultsUtil->setStatusToError();
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:89,代码来源:ImportUtil.php

示例7: resolveExplicitPermissionsForEmailMessage

 protected static function resolveExplicitPermissionsForEmailMessage(EmailMessage &$emailMessage, MarketingList $marketingList)
 {
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($marketingList);
     ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($emailMessage, $explicitReadWriteModelPermissions);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:5,代码来源:AutoresponderAndCampaignItemsUtil.php

示例8: testMissionReadUnreadStatus

 public function testMissionReadUnreadStatus()
 {
     $steven = User::getByUsername('steven');
     $sally = User::getByUsername('sally');
     $mary = User::getByUsername('mary');
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $mission = new Mission();
     $mission->owner = $steven;
     $mission->description = 'My test mission description';
     $mission->status = Mission::STATUS_AVAILABLE;
     $this->assertTrue($mission->save());
     $missionId = $mission->id;
     $explicitReadWriteModelPermissions = new ExplicitReadWriteModelPermissions();
     $explicitReadWriteModelPermissions->addReadWritePermitable(Group::getByName(Group::EVERYONE_GROUP_NAME));
     ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($mission, $explicitReadWriteModelPermissions);
     $mission = Mission::getById($missionId);
     //Confirm users have mission marked as unread but not owner
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $sally));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $mary));
     //Super reads the mission
     $this->setGetArray(array('id' => $missionId));
     $this->runControllerWithNoExceptionsAndGetContent('missions/default/details');
     $mission = Mission::getById($missionId);
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $sally));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $mary));
     //Mary marks mission as read and post a comment
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('mary');
     MissionsUtil::markUserHasReadLatest($mission, $mary);
     $this->setGetArray(array('relatedModelId' => $missionId, 'relatedModelClassName' => 'Mission', 'relatedModelRelationName' => 'comments', 'redirectUrl' => 'someRedirect'));
     $this->setPostArray(array('Comment' => array('description' => 'Mary\'s new comment')));
     $this->runControllerWithRedirectExceptionAndGetContent('comments/default/inlineCreateSave');
     $mission = Mission::getById($missionId);
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $sally));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $mary));
     //Sally reads and takes the mission
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('sally');
     $this->setGetArray(array('id' => $missionId));
     $this->resetPostArray();
     $this->runControllerWithNoExceptionsAndGetContent('missions/default/details');
     $mission = Mission::getById($missionId);
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $sally));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $mary));
     $this->setGetArray(array('status' => Mission::STATUS_TAKEN, 'id' => $missionId));
     $this->runControllerWithNoExceptionsAndGetContent('missions/default/ajaxChangeStatus');
     //Every user other than owner and takenby are marked as read latest
     $mission = Mission::getById($missionId);
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $sally));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $mary));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:59,代码来源:MissionsUserWalkthroughTest.php

示例9: resolveEmailMessage

 protected static function resolveEmailMessage(EmailTemplate $emailTemplate, Contact $contact = null, $htmlContent, $emailAddress = null)
 {
     // TODO: @Shoaibi: Critical: Refactor this and AutoresponderAndCampaignItemsUtil
     $emailMessage = new EmailMessage();
     $emailMessage->subject = $emailTemplate->subject;
     $emailContent = new EmailMessageContent();
     $emailContent->textContent = $emailTemplate->textContent;
     // we do not need to do : EmailTemplateSerializedDataToHtmlUtil::resolveHtmlByEmailTemplateModel($emailTemplate);
     // check __set of EmailTemplate.
     $emailContent->htmlContent = $htmlContent;
     $emailMessage->content = $emailContent;
     $emailMessage->sender = static::resolveSender();
     static::resolveRecipient($emailMessage, $contact, $emailAddress);
     $box = EmailBox::resolveAndGetByName(EmailBox::USER_DEFAULT_NAME);
     $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
     Yii::app()->emailHelper->sendImmediately($emailMessage);
     $emailMessage->owner = $emailTemplate->owner;
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($emailTemplate);
     ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($emailMessage, $explicitReadWriteModelPermissions);
     if (!$emailMessage->save()) {
         throw new FailedToSaveModelException("Unable to save EmailMessage");
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:23,代码来源:DefaultController.php

示例10: testResolveConversationHasManyParticipantsFromPost

 public function testResolveConversationHasManyParticipantsFromPost()
 {
     $super = Yii::app()->user->userModel;
     $mary = UserTestHelper::createBasicUser('mary');
     $steven = User::getByUsername('steven');
     $conversation = new Conversation();
     $conversation->owner = Yii::app()->user->userModel;
     $conversation->subject = 'My test subject2';
     $conversation->description = 'My test description2';
     $this->assertTrue($conversation->save());
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals(0, count($readWritePermitables));
     //test no existing participants. Do not add owner of conversation
     $postData = array();
     $postData['itemIds'] = $super->getClassId('Item');
     ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals(0, count($readWritePermitables));
     $this->assertEquals(0, $conversation->conversationParticipants->count());
     //test adding 2 more participants
     $postData = array();
     $postData['itemIds'] = $super->getClassId('Item') . ',' . $steven->getClassId('Item') . ',' . $mary->getClassId('Item');
     // Not Coding Standard
     ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals(2, count($readWritePermitables));
     $this->assertEquals(2, $conversation->conversationParticipants->count());
     $this->assertTrue($conversation->save());
     $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
     $this->assertTrue($success);
     //Just making sure the readWrite count is still 2
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals(2, count($readWritePermitables));
     //test removing a participant (remove steven)
     $postData = array();
     $postData['itemIds'] = $super->getClassId('Item') . ',' . $mary->getClassId('Item');
     // Not Coding Standard
     ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
     $this->assertTrue($conversation->save());
     $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
     $this->assertTrue($success);
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(1, $conversation->conversationParticipants->count());
     $this->assertEquals($mary, $conversation->conversationParticipants[0]->person);
     //test removing all participants.
     $postData = array();
     $postData['itemIds'] = '';
     ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
     $this->assertTrue($conversation->save());
     $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
     $this->assertTrue($success);
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals(0, count($readWritePermitables));
     $this->assertEquals(0, $conversation->conversationParticipants->count());
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:60,代码来源:ConversationParticipantsUtilTest.php

示例11: makeOpportunitiesByStage

 public static function makeOpportunitiesByStage()
 {
     $report = new Report();
     $report->setModuleClassName('OpportunitiesModule');
     $report->setName('Opportunities by Stage');
     $report->setType(Report::TYPE_SUMMATION);
     $report->setOwner(Yii::app()->user->userModel);
     $report->setFiltersStructure('');
     $report->setCurrencyConversionType(Report::CURRENCY_CONVERSION_TYPE_BASE);
     $groupBy = new GroupByForReportForm('OpportunitiesModule', 'Opportunity', $report->getType());
     $groupBy->attributeIndexOrDerivedType = 'stage';
     $groupBy->axis = 'x';
     $report->addGroupBy($groupBy);
     $displayAttribute = new DisplayAttributeForReportForm('OpportunitiesModule', 'Opportunity', $report->getType());
     $displayAttribute->attributeIndexOrDerivedType = 'stage';
     $report->addDisplayAttribute($displayAttribute);
     $displayAttribute = new DisplayAttributeForReportForm('OpportunitiesModule', 'Opportunity', $report->getType());
     $displayAttribute->attributeIndexOrDerivedType = 'Count';
     $report->addDisplayAttribute($displayAttribute);
     $displayAttribute = new DisplayAttributeForReportForm('OpportunitiesModule', 'Opportunity', $report->getType());
     $displayAttribute->attributeIndexOrDerivedType = 'amount__Summation';
     $report->addDisplayAttribute($displayAttribute);
     $chart = new ChartForReportForm();
     $chart->type = 'Column2D';
     $chart->firstSeries = 'stage';
     $chart->firstRange = 'amount__Summation';
     $report->setChart($chart);
     $savedReport = new SavedReport();
     SavedReportToReportAdapter::resolveReportToSavedReport($report, $savedReport);
     //set explicit
     $saved = $savedReport->save();
     assert('$saved');
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($savedReport);
     $explicitReadWriteModelPermissions->addReadWritePermitable(Group::getByName(Group::EVERYONE_GROUP_NAME));
     $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($savedReport, $explicitReadWriteModelPermissions);
     assert('$success');
     $saved = $savedReport->save();
     assert('$saved');
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:39,代码来源:ReportsDemoDataMaker.php

示例12: resolveEmailMessage

 protected static function resolveEmailMessage($textContent, $htmlContent, Item $itemOwnerModel, Contact $contact, MarketingList $marketingList, $itemId, $itemClass)
 {
     $emailMessage = new EmailMessage();
     $emailMessage->subject = $itemOwnerModel->subject;
     $emailContent = new EmailMessageContent();
     $emailContent->textContent = $textContent;
     $emailContent->htmlContent = $htmlContent;
     $emailMessage->content = $emailContent;
     $emailMessage->sender = static::resolveSender($marketingList, $itemOwnerModel);
     static::resolveRecipient($emailMessage, $contact);
     static::resolveAttachments($emailMessage, $itemOwnerModel);
     static::resolveHeaders($emailMessage, $itemId, $itemClass, $contact->getClassId('Person'));
     if ($emailMessage->recipients->count() == 0) {
         throw new MissingRecipientsForEmailMessageException();
     }
     $boxName = static::resolveEmailBoxName(get_class($itemOwnerModel));
     $box = EmailBox::resolveAndGetByName($boxName);
     $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
     Yii::app()->emailHelper->send($emailMessage);
     $emailMessage->owner = $marketingList->owner;
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($marketingList);
     ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($emailMessage, $explicitReadWriteModelPermissions);
     if (!$emailMessage->save()) {
         throw new FailedToSaveModelException("Unable to save EmailMessage");
     }
     return $emailMessage;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:27,代码来源:AutoresponderAndCampaignItemsUtil.php

示例13: sanitizeValue

 /**
  * Given a value that is either a zurmo id or an external system id, resolve that the
  * value is valid.  The value presented can also be a 'name' value.  If the name is not found as a model
  * in the system, then a new related model will be created using this name.
  * NOTE - If the related model has other required attributes that have no default values,
  * then there will be a problem saving this new model. This is too be resolved at some point.
  * If the value is not valid then an InvalidValueToSanitizeException is thrown.
  * @param mixed $value
  * @return sanitized value
  * @throws InvalidValueToSanitizeException
  * @throws NotFoundException
  * @throws NotSupportedException
  */
 public function sanitizeValue($value)
 {
     assert('is_string($this->attributeName) && $this->attributeName != "id"');
     if ($value == null) {
         return $value;
     }
     $modelClassName = $this->modelClassName;
     $relationModelClassName = $modelClassName::getRelationModelClassName($this->attributeName);
     if ($this->mappingRuleData["type"] == RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_ID) {
         try {
             if ((int) $value <= 0) {
                 throw new NotFoundException();
             }
             return $relationModelClassName::getById((int) $value);
         } catch (NotFoundException $e) {
             throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'ID specified did not match any existing records.'));
         }
     } elseif ($this->mappingRuleData["type"] == RelatedModelValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID) {
         try {
             return static::getModelByExternalSystemIdAndModelClassName($value, $relationModelClassName);
         } catch (NotFoundException $e) {
             throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Other ID specified did not match any existing records.'));
         }
     } else {
         if (!method_exists($relationModelClassName, 'getByName')) {
             throw new NotSupportedException();
         }
         try {
             $modelsFound = $relationModelClassName::getByName($value);
             if (!is_array($modelsFound)) {
                 $modelsFound = array($modelsFound);
             }
         } catch (NotFoundException $e) {
             $modelsFound = array();
         }
         if (count($modelsFound) == 0) {
             $newRelatedModel = new $relationModelClassName();
             $newRelatedModel->name = $value;
             $saved = $newRelatedModel->save();
             //Todo: need to handle this more gracefully. The use case where a related model is needed to be made
             //but there are some required attributes that do not have defaults. As a result, since those extra
             //defaults cannot be specified at this time, an error must be thrown.
             if (!$saved) {
                 throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'A new related model could not be created because there are unspecified required attributes on that related model.'));
             } else {
                 $this->importSanitizeResultsUtil->addRelatedModelMessage(Zurmo::t('ImportModule', '{modelLabel} saved correctly: {linkToModel}', array('{modelLabel}' => $newRelatedModel->getModelLabelByTypeAndLanguage('Singular'), '{linkToModel}' => ImportUtil::resolveLinkMessageToModel($newRelatedModel))));
                 if ($newRelatedModel instanceof SecurableItem && $this->explicitReadWriteModelPermissions instanceof ExplicitReadWriteModelPermissions) {
                     $resolved = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($newRelatedModel, $this->explicitReadWriteModelPermissions);
                     if (!$resolved) {
                         $this->importSanitizeResultsUtil->addRelatedModelMessage('The record saved, but there was a problem ' . 'setting the security permissions. It will at least be viewable by the owner.');
                     }
                 }
             }
             return $newRelatedModel;
         } else {
             return $modelsFound[0];
         }
     }
     exit;
 }
开发者ID:KulturedKitsch,项目名称:kulturedkitsch.info,代码行数:73,代码来源:RelatedModelNameOrIdValueTypeSanitizerUtil.php

示例14: testResolveExplicitReadWriteModelPermissions

 /**
  * @depends testMakeBySecurableItem
  */
 public function testResolveExplicitReadWriteModelPermissions()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $accounts = Account::getByName('aTestAccount');
     $this->assertEquals(1, count($accounts));
     $account = $accounts[0];
     $accountId = $account->id;
     $group4 = Group::getByName('Group4');
     $group3 = Group::getByName('Group3');
     $group2 = Group::getByName('Group2');
     $explicitReadWriteModelPermissions = new ExplicitReadWriteModelPermissions();
     $explicitReadWriteModelPermissions->addReadWritePermitableToRemove($group3);
     $explicitReadWriteModelPermissions->addReadWritePermitable($group4);
     ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($account, $explicitReadWriteModelPermissions);
     $account->forget();
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem(Account::getById($accountId));
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals(2, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     $this->assertEquals($group2, $readWritePermitables[$group2->getClassId('Permitable')]);
     $this->assertEquals($group4, $readWritePermitables[$group4->getClassId('Permitable')]);
     //Test adding group4 again. The _read count should be the same
     $account = Account::getById($accountId);
     $sanitizedData = array();
     $sanitizedData['explicitReadWriteModelPermissions'] = array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_NONEVERYONE_GROUP, 'nonEveryoneGroup' => $group4->id);
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::resolveByPostDataAndModelThenMake($sanitizedData, $account);
     ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($account, $explicitReadWriteModelPermissions);
     $this->assertEquals(array(array('G' . $group4->id, 1)), AccountReadPermissionsOptimizationBaseTest::getAccountMungeRows($account));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:33,代码来源:ExplicitReadWriteModelPermissionsUtilTest.php

示例15: updatePermitables

 /**
  * Updates permitables for current model.
  * @param ExplicitReadWriteModelPermissions $explicitReadWriteModelPermissions
  * @return bool
  * @throws NotSupportedException
  */
 protected function updatePermitables(ExplicitReadWriteModelPermissions $explicitReadWriteModelPermissions)
 {
     $this->isSaving = false;
     $this->resolvePermitablesToAttach($explicitReadWriteModelPermissions);
     $this->resolvePermitablesToDetach($explicitReadWriteModelPermissions);
     $permissionsUpdated = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($this, $explicitReadWriteModelPermissions);
     if (!$permissionsUpdated || !$this->save(false)) {
         throw new NotSupportedException('Unable to update permissions of model');
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:16,代码来源:SecurableItem.php


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