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


PHP ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem方法代码示例

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


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

示例1: resolveValueAndSetToModel

 /**
  * Utilized to create or update model attribute values after a workflow's triggers are fired as true.
  * Currently only works with creating new and creating new related models. Not designed to support updating
  * existing models.
  * @param WorkflowActionProcessingModelAdapter $adapter
  * @param $attribute
  * @throws FailedToResolveExplicitReadWriteModelPermissionsException
  * @throws NotSupportedException
  */
 public function resolveValueAndSetToModel(WorkflowActionProcessingModelAdapter $adapter, $attribute)
 {
     assert('is_string($attribute)');
     if ($adapter->getModel()->id < 0) {
         throw new NotSupportedException();
     }
     if ($this->type == self::TYPE_DYNAMIC_SAME_AS_TRIGGERED_MODEL) {
         $triggeredModel = $adapter->getTriggeredModel();
         if (null == ($explicitReadWriteModelPermissions = $triggeredModel->getExplicitReadWriteModelPermissionsForWorkflow())) {
             $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($adapter->getTriggeredModel());
         }
     } elseif ($this->type == self::TYPE_DYNAMIC_OWNER) {
         //Do nothing, by default this will take.
         return;
     } elseif ($this->type == self::TYPE_DYNAMIC_EVERYONE_GROUP) {
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($adapter->getModel());
         $explicitReadWriteModelPermissions->addReadWritePermitable(Group::getByName(Group::EVERYONE_GROUP_NAME));
     } else {
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($adapter->getModel());
         try {
             $group = Group::getById((int) $this->type);
             $explicitReadWriteModelPermissions->addReadWritePermitable($group);
         } catch (NotFoundException $e) {
             //todo: handle exception better
             return;
         }
     }
     $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($adapter->getModel(), $explicitReadWriteModelPermissions);
     if (!$success) {
         throw new FailedToResolveExplicitReadWriteModelPermissionsException();
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:41,代码来源:ExplicitReadWriteModelPermissionsWorkflowActionAttributeForm.php

示例2: makeReportBySavedCalendar

 /**
  * @param $savedCalendar
  * @return Report
  */
 public static function makeReportBySavedCalendar(SavedCalendar $savedCalendar)
 {
     $report = new Report();
     if ($savedCalendar->id > 0) {
         $report->setId((int) $savedCalendar->id);
     }
     $report->setDescription($savedCalendar->description);
     if ($savedCalendar->moduleClassName != null) {
         $report->setModuleClassName($savedCalendar->moduleClassName);
     }
     if ($savedCalendar->name != null) {
         $report->setName($savedCalendar->name);
     }
     $report->setOwner($savedCalendar->owner);
     $report->setType(Report::TYPE_ROWS_AND_COLUMNS);
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($savedCalendar);
     $report->setExplicitReadWriteModelPermissions($explicitReadWriteModelPermissions);
     if ($savedCalendar->serializedData != null) {
         $unserializedData = unserialize($savedCalendar->serializedData);
         if (isset($unserializedData['filtersStructure'])) {
             $report->setFiltersStructure($unserializedData['filtersStructure']);
         }
         CalendarUtil::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_FILTERS], $report, 'Filter');
     }
     return $report;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:30,代码来源:SavedCalendarToReportAdapter.php

示例3: getExplicitReadWriteModelPermissions

 protected function getExplicitReadWriteModelPermissions()
 {
     if ($this->explicitReadWriteModelPermissions != null) {
         return $this->explicitReadWriteModelPermissions;
     }
     $this->explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($this->model);
     return $this->explicitReadWriteModelPermissions;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:8,代码来源:DerivedExplicitReadWriteModelPermissionsElement.php

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

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

示例6: makeReportBySavedReport

 /**
  * @param $savedReport
  * @return Report
  */
 public static function makeReportBySavedReport($savedReport)
 {
     $report = new Report();
     if ($savedReport->id > 0) {
         $report->setId((int) $savedReport->id);
     }
     $report->setDescription($savedReport->description);
     $report->setModuleClassName($savedReport->moduleClassName);
     $report->setName($savedReport->name);
     $report->setOwner($savedReport->owner);
     $report->setType($savedReport->type);
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($savedReport);
     $report->setExplicitReadWriteModelPermissions($explicitReadWriteModelPermissions);
     if ($savedReport->serializedData != null) {
         $unserializedData = unserialize($savedReport->serializedData);
         if (isset($unserializedData['filtersStructure'])) {
             $report->setFiltersStructure($unserializedData['filtersStructure']);
         }
         if (isset($unserializedData['currencyConversionType'])) {
             $report->setCurrencyConversionType((int) $unserializedData['currencyConversionType']);
         }
         if (isset($unserializedData['spotConversionCurrencyCode'])) {
             $report->setSpotConversionCurrencyCode($unserializedData['spotConversionCurrencyCode']);
         }
         self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_FILTERS], $report, 'Filter');
         self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_ORDER_BYS], $report, 'OrderBy');
         self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_GROUP_BYS], $report, 'GroupBy');
         self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_DISPLAY_ATTRIBUTES], $report, 'DisplayAttribute');
         self::makeComponentFormAndPopulateReportFromData($unserializedData[ComponentForReportForm::TYPE_DRILL_DOWN_DISPLAY_ATTRIBUTES], $report, 'DrillDownDisplayAttribute');
         if (isset($unserializedData['chart'])) {
             $moduleClassName = $report->getModuleClassName();
             $modelClassName = $moduleClassName::getPrimaryModelName();
             $adapter = ModelRelationsAndAttributesToSummationReportAdapter::make($moduleClassName, $modelClassName, $report->getType());
             $chart = new ChartForReportForm(ReportUtil::makeDataAndLabelsForSeriesOrRange($adapter->getAttributesForChartSeries($report->getGroupBys(), $report->getDisplayAttributes())), ReportUtil::makeDataAndLabelsForSeriesOrRange($adapter->getAttributesForChartRange($report->getDisplayAttributes())));
             $chart->setAttributes($unserializedData['chart']);
             $report->setChart($chart);
         }
     }
     return $report;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:44,代码来源:SavedReportToReportAdapter.php

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

示例8: testProcessWithDefaultSender

 public function testProcessWithDefaultSender()
 {
     $message = new EmailMessageForWorkflowForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_CREATED_BY_USER));
     $message->emailTemplateId = self::$emailTemplate->id;
     $message->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
     $message->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients));
     $model = new WorkflowModelTestItem();
     $model->lastName = 'the lastName';
     $model->string = 'the string';
     $model->phone = 'the phone';
     $saved = $model->save();
     $this->assertTrue($saved);
     $helper = new WorkflowEmailMessageProcessingHelper($message, $model, Yii::app()->user->userModel);
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $helper->process();
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $emailMessages = EmailMessage::getAllByFolderType(EmailFolder::TYPE_OUTBOX);
     $this->assertEquals('some subject the lastName', $emailMessages[0]->subject);
     $this->assertEquals('text content the phone', $emailMessages[0]->content->textContent);
     $this->assertEquals('html content the string', $emailMessages[0]->content->htmlContent);
     $this->assertEquals('System User', $emailMessages[0]->sender->fromName);
     $this->assertEquals('notification@zurmoalerts.com', $emailMessages[0]->sender->fromAddress);
     $this->assertEquals(1, $emailMessages[0]->recipients->count());
     $this->assertEquals('super@zurmo.com', $emailMessages[0]->recipients[0]->toAddress);
     $this->assertEquals(self::$emailTemplate->files[0]->fileContent->content, $emailMessages[0]->files[0]->fileContent->content);
     //Assert explicit permissions are correct
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($emailMessages[0]);
     $this->assertTrue($explicitReadWriteModelPermissions instanceof ExplicitReadWriteModelPermissions);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(self::$alphaGroup, $readWritePermitables[self::$alphaGroup->getClassId('Permitable')]);
     $emailMessages[0]->delete();
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:36,代码来源:WorkflowEmailMessageProcessingHelperTest.php

示例9: testSuperUserCompleteMatchVariations

 public function testSuperUserCompleteMatchVariations()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/matchingList');
     $message1 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message1Id = $message1->id;
     $message2 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message2Id = $message2->id;
     $message3 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $contact = ContactTestHelper::createContactByNameForOwner('gail', $super);
     $startingContactState = ContactsUtil::getStartingState();
     $startingLeadState = LeadsUtil::getStartingState();
     //test validating selecting an existing contact
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'select-contact-form-' . $message1->id, 'AnyContactSelectForm' => array($message1->id => array('contactId' => $contact->id, 'contactName' => 'Some Name'))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test validating creating a new contact
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'contact-inline-create-form-' . $message1->id, 'Contact' => array($message1->id => array('firstName' => 'Gail', 'lastName' => 'Green', 'officePhone' => '456765421', 'state' => array('id' => $startingContactState->id)))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test validating creating a new lead
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'lead-inline-create-form-' . $message1->id, 'Lead' => array($message1->id => array('firstName' => 'Gail', 'lastName' => 'Green', 'officePhone' => '456765421', 'state' => array('id' => $startingLeadState->id)))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test selecting existing contact and saving
     $this->assertNull($contact->primaryEmail->emailAddress);
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('AnyContactSelectForm' => array($message1->id => array('contactId' => $contact->id, 'contactName' => 'Some Name'))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $message1->forget();
     $message1 = EmailMessage::getById($message1Id);
     $this->assertNull($contact->primaryEmail->emailAddress);
     $this->assertCount(1, $message1->sender->personsOrAccounts);
     $this->assertTrue($message1->sender->personsOrAccounts[0]->isSame($contact));
     $this->assertEquals('Archived', $message1->folder);
     //assert subject of the email going to edit.
     $this->setGetArray(array('id' => $contact->id));
     $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
     $this->assertEquals('A test unmatched archived received email', $message1->subject);
     //edit subject of email message.
     $this->setGetArray(array('id' => $message1->id));
     $createEmailMessageFormData = array('subject' => 'A test unmatched archived received email edited');
     $this->setPostArray(array('ajax' => 'edit-form', 'EmailMessage' => $createEmailMessageFormData));
     $this->runControllerWithRedirectExceptionAndGetUrl('emailMessages/default/edit');
     //assert subject is edited or not.
     $this->setGetArray(array('id' => $contact->id));
     $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
     $this->assertEquals('A test unmatched archived received email edited', $message1->subject);
     //delete email message.
     $this->setGetArray(array('id' => $message1->id));
     $this->runControllerWithRedirectExceptionAndGetUrl('emailMessages/default/delete', true);
     //assert subject not present.
     try {
         EmailMessage::getById($message1->id);
         $this->fail();
     } catch (NotFoundException $e) {
         //success
     }
     //Test the default permission was setted
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($message1);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
     //test creating new contact and saving
     $this->assertEquals(1, Contact::getCount());
     $this->setGetArray(array('id' => $message2->id));
     $this->setPostArray(array('Contact' => array($message2->id => array('firstName' => 'George', 'lastName' => 'Patton', 'officePhone' => '456765421', 'state' => array('id' => $startingContactState->id)))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $message2->forget();
     $message2 = EmailMessage::getById($message2Id);
     $this->assertEquals(2, Contact::getCount());
     $contacts = Contact::getByName('George Patton');
     $contact = $contacts[0];
     $this->assertCount(1, $message2->sender->personsOrAccounts);
     $this->assertTrue($message2->sender->personsOrAccounts[0]->isSame($contact));
     $this->assertEquals('Archived', $message2->folder);
     //Test the default permission was setted
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($message2);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
     //test creating new lead and saving
     $this->assertEquals(2, Contact::getCount());
     $this->setGetArray(array('id' => $message3->id));
     $this->setPostArray(array('Lead' => array($message3->id => array('firstName' => 'Billy', 'lastName' => 'Kid', 'officePhone' => '456765421', 'state' => array('id' => $startingLeadState->id)))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $this->assertEquals(3, Contact::getCount());
     $contacts = Contact::getByName('Billy Kid');
     $contact = $contacts[0];
     $this->assertCount(1, $message3->sender->personsOrAccounts);
     $this->assertTrue($message3->sender->personsOrAccounts[0]->isSame($contact));
     $this->assertEquals('Archived', $message3->folder);
     //Test the default permission was setted
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($message3);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:96,代码来源:ArchivedEmailMatchingUserWalkthroughTest.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: testProcessDueCampaignItemWithReturnPathHeaders

 /**
  * @depends testProcessDueCampaignItemWithOptout
  */
 public function testProcessDueCampaignItemWithReturnPathHeaders()
 {
     ZurmoConfigurationUtil::setByModuleName('EmailMessagesModule', 'bounceReturnPath', 'bounce@zurmo.com');
     $email = new Email();
     $email->emailAddress = 'demo@zurmo.com';
     $contact = ContactTestHelper::createContactByNameForOwner('contact 09', $this->user);
     $contact->primaryEmail = $email;
     $this->assertTrue($contact->save());
     $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 09', 'description', 'CustomFromName', 'custom@from.com');
     $campaign = CampaignTestHelper::createCampaign('campaign 09', 'subject 09', 'Dr. [[FIRST^NAME]] [[LAST^NAME]]', '<b>[[LAST^NAME]]</b>, [[FIRST^NAME]]', null, null, null, null, null, null, $marketingList);
     $processed = 0;
     $campaignItem = CampaignItemTestHelper::createCampaignItem($processed, $campaign, $contact);
     CampaignItemsUtil::processDueItem($campaignItem);
     $this->assertEquals(1, $campaignItem->processed);
     $emailMessage = $campaignItem->emailMessage;
     $this->assertEquals($marketingList->owner, $emailMessage->owner);
     $marketingListPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($marketingList);
     $emailMessagePermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($emailMessage);
     $this->assertEquals($marketingListPermissions, $emailMessagePermissions);
     $this->assertEquals($campaign->subject, $emailMessage->subject);
     $this->assertNotEquals($campaign->textContent, $emailMessage->content->textContent);
     $this->assertNotEquals($campaign->htmlContent, $emailMessage->content->htmlContent);
     $this->assertTrue(strpos($emailMessage->content->textContent, 'Dr. contact 09 contact 09son') !== false);
     $this->assertTrue(strpos($emailMessage->content->textContent, '/marketingLists/external/') !== false);
     $this->assertEquals(2, substr_count($emailMessage->content->textContent, '/marketingLists/external/'));
     $this->assertTrue(strpos($emailMessage->content->htmlContent, '<b>contact 09son</b>, contact 09') !== false);
     $this->assertTrue(strpos($emailMessage->content->htmlContent, '/marketingLists/external/') !== false);
     $this->assertEquals(2, substr_count($emailMessage->content->htmlContent, '/marketingLists/external/'));
     $this->assertEquals('support@zurmo.com', $emailMessage->sender->fromAddress);
     $this->assertEquals('Support Team', $emailMessage->sender->fromName);
     $this->assertEquals(1, $emailMessage->recipients->count());
     $recipients = $emailMessage->recipients;
     $this->assertEquals(strval($contact), $recipients[0]->toName);
     $this->assertEquals($email->emailAddress, $recipients[0]->toAddress);
     $this->assertEquals(EmailMessageRecipient::TYPE_TO, $recipients[0]->type);
     $this->assertEquals($contact, $recipients[0]->personOrAccount);
     $headersArray = array('zurmoItemId' => $campaignItem->id, 'zurmoItemClass' => get_class($campaignItem), 'zurmoPersonId' => $contact->getClassId('Person'), 'Return-Path' => 'bounce@zurmo.com');
     $expectedHeaders = serialize($headersArray);
     $this->assertEquals($expectedHeaders, $emailMessage->headers);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:43,代码来源:CampaignItemsUtilTest.php

示例12: testGetUnreadConversationCount

 /**
  * @depends testResolveConversationParticipantsForExplicitModelPermissions
  */
 public function testGetUnreadConversationCount()
 {
     $super = User::getByUsername('super');
     $mary = User::getByUsername('mary');
     $count = Conversation::getUnreadCountByUser($super);
     $account2 = AccountTestHelper::createAccountByNameForOwner('anAccount2', $super);
     $conversation = new Conversation();
     $conversation->owner = $super;
     $conversation->subject = 'My test subject2';
     $conversation->description = 'My test description2';
     $conversation->conversationItems->add($account2);
     $this->assertTrue($conversation->save());
     //when super adds a comment, it should remain same count
     $comment = new Comment();
     $comment->description = 'This is my first comment';
     $conversation->comments->add($comment);
     $this->assertTrue($conversation->save());
     $count = Conversation::getUnreadCountByUser($super);
     $this->assertEquals(1, $count);
     //Add mary as a participant
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
     $postData = array();
     $postData['itemIds'] = $super->getClassId('Item') . ',' . $mary->getClassId('Item');
     // Not Coding Standard
     ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
     $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
     $this->assertTrue($success);
     $conversation->save();
     //when mary adds a comment, super's count should go up (assumming count was previously 0)
     Yii::app()->user->userModel = $mary;
     $comment = new Comment();
     $comment->description = 'This is mary\'s first comment';
     $conversation->comments->add($comment);
     $this->assertTrue($conversation->save());
     Yii::app()->user->userModel = $super;
     $count = Conversation::getUnreadCountByUser($super);
     $this->assertEquals(2, $count);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:41,代码来源:ConversationTest.php

示例13: testRegularUserCreateAccountAndChangeExplicitPermissions

 /**
  * @depends testRegularUserEditExistingAccountAndChangeExplicitPermissions
  */
 public function testRegularUserCreateAccountAndChangeExplicitPermissions()
 {
     $nobody = $this->logoutCurrentUserLoginNewUserAndGetByUsername('nobody');
     $group1 = Group::getByName('Group1');
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     //Create an account for nobody with no explicit permissions.
     $this->resetGetArray();
     $postData = array('type' => null);
     $this->setPostArray(array('Account' => array('name' => 'myNewAccount', 'officePhone' => '456765421', 'explicitReadWriteModelPermissions' => $postData)));
     //Make sure the redirect is to the details view and not the list view.
     $this->runControllerWithRedirectExceptionAndGetContent('accounts/default/create');
     // Not Coding Standard
     //Confirm the permissions are set right based on how the account was saved.
     $accounts = Account::getByName('myNewAccount');
     $this->assertEquals(1, count($accounts));
     $accountId = $accounts[0]->id;
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem(Account::getById($accountId));
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals(0, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     //Create an account for nobody and add explicit permissions for the everyone group.
     $this->resetGetArray();
     $postData = array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP);
     $this->setPostArray(array('Account' => array('name' => 'myNewAccount2', 'officePhone' => '456765421', 'explicitReadWriteModelPermissions' => $postData)));
     //Make sure the redirect is to the details view and not the list view.
     $this->runControllerWithRedirectExceptionAndGetContent('accounts/default/create');
     // Not Coding Standard
     //Confirm the permissions are set right based on how the account was saved.
     $accounts = Account::getByName('myNewAccount2');
     $this->assertEquals(1, count($accounts));
     $accountId = $accounts[0]->id;
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem(Account::getById($accountId));
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
     //Create an account for nobody and add explicit permissions for a non-everyone group.
     $this->resetGetArray();
     $postData = array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_NONEVERYONE_GROUP, 'nonEveryoneGroup' => $group1->id);
     $this->setPostArray(array('Account' => array('name' => 'myNewAccount3', 'officePhone' => '456765421', 'explicitReadWriteModelPermissions' => $postData)));
     //Make sure the redirect is to the details view and not the list view.
     $this->runControllerWithRedirectExceptionAndGetContent('accounts/default/create');
     // Not Coding Standard
     //Confirm the permissions are set right based on how the account was saved.
     $accounts = Account::getByName('myNewAccount3');
     $this->assertEquals(1, count($accounts));
     $accountId = $accounts[0]->id;
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem(Account::getById($accountId));
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     $this->assertEquals($group1, $readWritePermitables[$group1->getClassId('Permitable')]);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:59,代码来源:AccountPermissionsRegularUserWalkthroughTest.php

示例14: testEditOfTheLeadUserForTheCustomFieldsPlacedForLeadsModule

 /**
  * @depends testEditOfTheLeadUserForTheTagCloudFieldAfterRemovingAllTagsPlacedForLeadsModule
  */
 public function testEditOfTheLeadUserForTheCustomFieldsPlacedForLeadsModule()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Retrieve the the super user id.
     $superUserId = $super->id;
     //Retrieve the lead id.
     $leadId = self::getModelIdByModelNameAndName('Contact', 'Sarah Williams Edit');
     //Set the date and datetime variable values here.
     $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
     $dateAssert = date('Y-m-d');
     $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
     $datetimeAssert = date('Y-m-d H:i:') . "00";
     $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
     //Retrieve the Lead State (Status) Id based on the name.
     $leadState = ContactState::getByName('In Progress');
     $leadStateId = $leadState[0]->id;
     $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
     //Edit and save the lead.
     $this->setGetArray(array('id' => $leadId));
     $this->setPostArray(array('Contact' => array('title' => array('value' => 'Mrs.'), 'firstName' => 'Sarah', 'lastName' => 'Williams Edit', 'jobTitle' => 'Sales Director Edit', 'companyName' => 'ABC Telecom Edit', 'industry' => array('value' => 'Banking'), 'website' => 'http://www.companyedit.com', 'department' => 'Sales Edit', 'officePhone' => '739-742-3005', 'source' => array('value' => 'Inbound Call'), 'mobilePhone' => '285-300-8232', 'officeFax' => '255-454-1914', 'state' => array('id' => $leadStateId), 'owner' => array('id' => $superUserId), 'primaryEmail' => array('emailAddress' => 'info@myNewLead.com', 'optOut' => '0', 'isInvalid' => '0'), 'secondaryEmail' => array('emailAddress' => 'info@myNewLeadEdit.com', 'optOut' => '0', 'isInvalid' => '0'), 'primaryAddress' => array('street1' => '26378 South Arlington Ave', 'street2' => '', 'city' => 'San Jose', 'state' => 'CA', 'postalCode' => '95131', 'country' => 'USA'), 'secondaryAddress' => array('street1' => '1652 North Cedar Court', 'street2' => '', 'city' => 'Phoenix', 'state' => 'AZ', 'postalCode' => '85003', 'country' => 'USA'), 'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission), 'description' => 'This is a Edit Description', 'checkboxCstm' => '0', 'currencyCstm' => array('value' => 40, 'currency' => array('id' => $baseCurrency->id)), 'dateCstm' => $date, 'datetimeCstm' => $datetime, 'decimalCstm' => '12', 'picklistCstm' => array('value' => 'b'), 'multiselectCstm' => array('values' => array('gg', 'hh')), 'tagcloudCstm' => array('values' => array('reading', 'surfing')), 'countrylistCstm' => array('value' => 'aaaa'), 'statelistCstm' => array('value' => 'aaa1'), 'citylistCstm' => array('value' => 'ab1'), 'integerCstm' => '11', 'phoneCstm' => '259-784-2069', 'radioCstm' => array('value' => 'e'), 'textCstm' => 'This is a test Edit Text', 'textareaCstm' => 'This is a test Edit TextArea', 'urlCstm' => 'http://wwww.abc-edit.com'), 'save' => 'Save'));
     $this->runControllerWithRedirectExceptionAndGetUrl('leads/default/edit');
     //Check the details if they are saved properly for the custom fields after the edit.
     $lead = Contact::getById($leadId);
     //Retrieve the permission of the lead.
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($lead);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals($lead->title->value, 'Mrs.');
     $this->assertEquals($lead->firstName, 'Sarah');
     $this->assertEquals($lead->lastName, 'Williams Edit');
     $this->assertEquals($lead->state->id, $leadStateId);
     $this->assertEquals($lead->jobTitle, 'Sales Director Edit');
     $this->assertEquals($lead->companyName, 'ABC Telecom Edit');
     $this->assertEquals($lead->industry->value, 'Banking');
     $this->assertEquals($lead->website, 'http://www.companyedit.com');
     $this->assertEquals($lead->department, 'Sales Edit');
     $this->assertEquals($lead->officePhone, '739-742-3005');
     $this->assertEquals($lead->source->value, 'Inbound Call');
     $this->assertEquals($lead->mobilePhone, '285-300-8232');
     $this->assertEquals($lead->officeFax, '255-454-1914');
     $this->assertEquals($lead->primaryEmail->emailAddress, 'info@myNewLead.com');
     $this->assertEquals($lead->primaryEmail->optOut, '0');
     $this->assertEquals($lead->primaryEmail->isInvalid, '0');
     $this->assertEquals($lead->secondaryEmail->emailAddress, 'info@myNewLeadEdit.com');
     $this->assertEquals($lead->secondaryEmail->optOut, '0');
     $this->assertEquals($lead->secondaryEmail->isInvalid, '0');
     $this->assertEquals($lead->primaryAddress->street1, '26378 South Arlington Ave');
     $this->assertEquals($lead->primaryAddress->street2, '');
     $this->assertEquals($lead->primaryAddress->city, 'San Jose');
     $this->assertEquals($lead->primaryAddress->state, 'CA');
     $this->assertEquals($lead->primaryAddress->postalCode, '95131');
     $this->assertEquals($lead->primaryAddress->country, 'USA');
     $this->assertEquals($lead->secondaryAddress->street1, '1652 North Cedar Court');
     $this->assertEquals($lead->secondaryAddress->street2, '');
     $this->assertEquals($lead->secondaryAddress->city, 'Phoenix');
     $this->assertEquals($lead->secondaryAddress->state, 'AZ');
     $this->assertEquals($lead->secondaryAddress->postalCode, '85003');
     $this->assertEquals($lead->secondaryAddress->country, 'USA');
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     $this->assertEquals($lead->description, 'This is a Edit Description');
     $this->assertEquals($lead->checkboxCstm, '0');
     $this->assertEquals($lead->currencyCstm->value, 40);
     $this->assertEquals($lead->currencyCstm->currency->id, $baseCurrency->id);
     $this->assertEquals($lead->dateCstm, $dateAssert);
     $this->assertEquals($lead->datetimeCstm, $datetimeAssert);
     $this->assertEquals($lead->decimalCstm, '12');
     $this->assertEquals($lead->picklistCstm->value, 'b');
     $this->assertEquals($lead->integerCstm, 11);
     $this->assertEquals($lead->phoneCstm, '259-784-2069');
     $this->assertEquals($lead->radioCstm->value, 'e');
     $this->assertEquals($lead->textCstm, 'This is a test Edit Text');
     $this->assertEquals($lead->textareaCstm, 'This is a test Edit TextArea');
     $this->assertEquals($lead->urlCstm, 'http://wwww.abc-edit.com');
     $this->assertEquals($lead->countrylistCstm->value, 'aaaa');
     $this->assertEquals($lead->statelistCstm->value, 'aaa1');
     $this->assertEquals($lead->citylistCstm->value, 'ab1');
     $this->assertContains('gg', $lead->multiselectCstm->values);
     $this->assertContains('hh', $lead->multiselectCstm->values);
     $this->assertContains('reading', $lead->tagcloudCstm->values);
     $this->assertContains('surfing', $lead->tagcloudCstm->values);
     $metadata = CalculatedDerivedAttributeMetadata::getByNameAndModelClassName('calcnumber', 'Contact');
     $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $lead);
     $this->assertEquals(23, $testCalculatedValue);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:88,代码来源:LeadsDesignerSuperUserWalkthroughTest.php

示例15: resolveExplicitPermissions

 protected static function resolveExplicitPermissions(RedBeanModel $model, RedBeanModel $copyToModel)
 {
     if ($model instanceof SecurableItem) {
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($model);
         ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissionsForDisplay($copyToModel, $explicitReadWriteModelPermissions);
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:7,代码来源:ZurmoCopyModelUtil.php


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