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


PHP ContactsUtil类代码示例

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


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

示例1: testResolveContactToSenderOrRecipientForReceivedEmail

 public function testResolveContactToSenderOrRecipientForReceivedEmail()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $message1 = self::$message1;
     $contact = new Contact();
     $contact->firstName = 'Jason';
     $contact->lastName = 'Green';
     $contact->state = ContactsUtil::getStartingState();
     $saved = $contact->save();
     $this->assertTrue($saved);
     $contactId = $contact->id;
     $contact->forget();
     $contact = Contact::getById($contactId);
     $this->assertNull($contact->primaryEmail->emailAddress);
     ArchivedEmailMatchingUtil::resolveContactToSenderOrRecipient($message1, $contact);
     $saved = $message1->save();
     $this->assertTrue($saved);
     $messageId = $message1->id;
     $message1->forget();
     $contact->forget();
     RedBeanModel::forgetAll();
     //simulates crossing page requests
     $message1 = EmailMessage::getById($messageId);
     $contact = Contact::getById($contactId);
     $this->assertEquals(1, $message1->sender->personsOrAccounts->count());
     $castedDownModel = EmailMessageMashableActivityRules::castDownItem($message1->sender->personsOrAccounts[0]);
     $this->assertEquals('Contact', get_class($castedDownModel));
     $this->assertEquals($contact->id, $castedDownModel->id);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:30,代码来源:ArchivedEmailMatchingUtilTest.php

示例2: sanitizeValue

 /**
  * Given a contact state id, attempt to get and return a contact state object. If the id is invalid, then an
  * InvalidValueToSanitizeException will be thrown.
  * @param string $modelClassName
  * @param string $attributeName
  * @param mixed $value
  * @param array $mappingRuleData
  */
 public static function sanitizeValue($modelClassName, $attributeName, $value, $mappingRuleData)
 {
     assert('is_string($modelClassName)');
     assert('$attributeName == null');
     assert('$mappingRuleData == null');
     if ($value == null) {
         return $value;
     }
     try {
         if ((int) $value <= 0) {
             $states = ContactState::getByName($value);
             if (count($states) > 1) {
                 throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'The status specified is not unique and is invalid.'));
             } elseif (count($states) == 0) {
                 throw new NotFoundException();
             }
             $state = $states[0];
         } else {
             $state = ContactState::getById($value);
         }
         $startingState = ContactsUtil::getStartingState();
         if (!static::resolvesValidStateByOrder($state->order, $startingState->order)) {
             throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'The status specified is invalid.'));
         }
         return $state;
     } catch (NotFoundException $e) {
         throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'The status specified does not exist.'));
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:37,代码来源:ContactStateSanitizerUtil.php

示例3: resolveDisplayedValueForRelatedAttribute

 /**
  * Resolves value for related attribute
  * @param string $attribute
  * @param string $relatedAttribute
  * @return string
  */
 protected function resolveDisplayedValueForRelatedAttribute($attribute, $relatedAttribute)
 {
     if ($this->element instanceof LeadStateDropDownElement) {
         $label = ContactsUtil::resolveStateLabelByLanguage($this->model->{$attribute}, Yii::app()->language);
         return Yii::app()->format->text($label);
     }
     return $this->model->{$attribute}->{$relatedAttribute};
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:14,代码来源:LeadModelAttributeAndElementDataToMergeItem.php

示例4: getStateIds

 public function getStateIds()
 {
     $states = ContactState::getAll('order');
     $startingStateOrder = ContactsUtil::getStartingStateOrder($states);
     $stateIds = array();
     foreach ($states as $state) {
         if ($this->shouldIncludeState($state->order, $startingStateOrder)) {
             $stateIds[] = $state->id;
         }
     }
     return $stateIds;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:12,代码来源:ContactsStateMetadataAdapter.php

示例5: testImportSwitchingOwnerButShouldStillCreate

 /**
  * Test when a normal user who can only view records he owns, tries to import records assigned to another user.
  */
 public function testImportSwitchingOwnerButShouldStillCreate()
 {
     $super = User::getByUsername('super');
     $jim = User::getByUsername('jim');
     Yii::app()->user->userModel = $jim;
     //Confirm Jim can can only view ImportModelTestItems he owns.
     $item = NamedSecurableItem::getByName('ContactsModule');
     $this->assertEquals(Permission::NONE, $item->getEffectivePermissions($jim));
     $testModels = Contact::getAll();
     $this->assertEquals(0, count($testModels));
     $import = new Import();
     $serializedData['importRulesType'] = 'Contacts';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.contacts.tests.unit.files'));
     $this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $ownerColumnMappingData = array('attributeIndexOrDerivedType' => 'owner', 'type' => 'extraColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => $super->id), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID)));
     $startingStateId = ContactsUtil::getStartingState()->id;
     $mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('firstName'), 'column_1' => ImportMappingUtil::makeStringColumnMappingData('lastName'), 'column_2' => $ownerColumnMappingData, 'column_3' => ContactImportTestHelper::makeStateColumnMappingData($startingStateId, 'extraColumn'));
     $importRules = ImportRulesUtil::makeImportRulesByType('Contacts');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //3 models are created, but Jim can't see them since they are assigned to someone else.
     $testModels = Contact::getAll();
     $this->assertEquals(0, count($testModels));
     //Using super, should see all 3 models created.
     Yii::app()->user->userModel = $super;
     $testModels = Contact::getAll();
     $this->assertEquals(3, count($testModels));
     foreach ($testModels as $model) {
         $this->assertEquals(array(Permission::NONE, Permission::NONE), $model->getExplicitActualPermissions($jim));
     }
     //Confirm 4 rows were processed as 'created'.
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
     //Confirm that 0 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 0 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
     //Clear out data in table
     Contact::deleteAll();
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:55,代码来源:ContactImportTest.php

示例6: createContactWithAccountByNameForOwner

 public static function createContactWithAccountByNameForOwner($firstName, $owner, $account)
 {
     ContactsModule::loadStartingData();
     $contact = new Contact();
     $contact->firstName = $firstName;
     $contact->lastName = $firstName . 'son';
     $contact->owner = $owner;
     $contact->account = $account;
     $contact->state = ContactsUtil::getStartingState();
     $saved = $contact->save();
     assert('$saved');
     return $contact;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:13,代码来源:ContactTestHelper.php

示例7: testSuperUserCompleteMatchVariations

 public function testSuperUserCompleteMatchVariations()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/matchingList');
     $message1 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message2 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $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);
     $this->assertEquals('bob.message@zurmotest.com', $contact->primaryEmail->emailAddress);
     $this->assertTrue($message1->sender->personOrAccount->isSame($contact));
     $this->assertEquals('Archived', $message1->folder);
     //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);
     $this->assertEquals(2, Contact::getCount());
     $contacts = Contact::getByName('George Patton');
     $contact = $contacts[0];
     $this->assertTrue($message2->sender->personOrAccount->isSame($contact));
     $this->assertEquals('Archived', $message2->folder);
     //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->assertTrue($message3->sender->personOrAccount->isSame($contact));
     $this->assertEquals('Archived', $message3->folder);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:51,代码来源:ArchivedEmailMatchingUserWalkthroughTest.php

示例8: testListContactStates

 /**
  * @depends testGetContactState
  */
 public function testListContactStates()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $contactStates = ContactsUtil::getContactStateDataFromStartingStateLabelByLanguage(Yii::app()->language);
     $compareData = array();
     foreach ($contactStates as $contactState) {
         $compareData[] = $this->getModelToApiDataUtilData($contactState);
     }
     $response = $this->createApiCallWithRelativeUrl('listContactStates/', 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(count($compareData), count($response['data']['items']));
     $this->assertEquals(count($compareData), $response['data']['totalCount']);
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals($compareData, $response['data']['items']);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:22,代码来源:ApiRestContactStateTest.php

示例9: actionLoadContactsSampler

 /**
  * Special method to load contacts for marketing functional test.
  */
 public function actionLoadContactsSampler()
 {
     if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel)) {
         throw new NotSupportedException();
     }
     //Load 12 contacts so there is sufficient data for marketing list pagination testing and mass delete.
     for ($i = 1; $i <= 12; $i++) {
         $firstName = 'Test';
         $lastName = 'Contact';
         $owner = Yii::app()->user->userModel;
         $contact = new Contact();
         $contact->firstName = $firstName;
         $contact->lastName = $lastName . ' ' . $i;
         $contact->owner = $owner;
         $contact->state = ContactsUtil::getStartingState();
         $saved = $contact->save();
         assert('$saved');
         if (!$saved) {
             throw new NotSupportedException();
         }
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:25,代码来源:DemoController.php

示例10: resolveStates

 protected function resolveStates()
 {
     return ContactsUtil::getContactStateDataFromStartingStateOnAndKeyedById();
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:4,代码来源:ContactStateSanitizerUtil.php

示例11: actionCreateFromRelation

 public function actionCreateFromRelation($relationAttributeName, $relationModelId, $relationModuleId, $redirectUrl)
 {
     $contact = $this->resolveNewModelByRelationInformation(new Contact(), $relationAttributeName, (int) $relationModelId, $relationModuleId);
     ContactsUtil::resolveAddressesFromRelatedAccount($contact);
     $this->actionCreateByModel($contact, $redirectUrl);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:6,代码来源:DefaultController.php

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

示例13: resolveRecordSharingPerformanceTime

 public function resolveRecordSharingPerformanceTime($count)
 {
     $groupMembers = array();
     // create group
     $this->resetGetArray();
     $this->setPostArray(array('Group' => array('name' => "Group {$count}")));
     $this->runControllerWithRedirectExceptionAndGetUrl('/zurmo/group/create');
     $group = Group::getByName("Group {$count}");
     $this->assertNotNull($group);
     $this->assertEquals("Group {$count}", strval($group));
     $group->setRight('ContactsModule', ContactsModule::getAccessRight());
     $group->setRight('ContactsModule', ContactsModule::getCreateRight());
     $group->setRight('ContactsModule', ContactsModule::getDeleteRight());
     $this->assertTrue($group->save());
     $groupId = $group->id;
     $group->forgetAll();
     $group = Group::getById($groupId);
     $this->resetGetArray();
     for ($i = 0; $i < $count; $i++) {
         $username = static::$baseUsername . "_{$i}_of_{$count}";
         // Populate group
         $this->setPostArray(array('UserPasswordForm' => array('firstName' => 'Some', 'lastName' => 'Body', 'username' => $username, 'newPassword' => 'myPassword123', 'newPassword_repeat' => 'myPassword123', 'officePhone' => '456765421', 'userStatus' => 'Active')));
         $this->runControllerWithRedirectExceptionAndGetContent('/users/default/create');
         $user = User::getByUsername($username);
         $this->assertNotNull($user);
         $groupMembers['usernames'][] = $user->username;
         $groupMembers['ids'][] = $user->id;
     }
     $this->assertCount($count, $groupMembers['ids']);
     // set user's group
     $this->setGetArray(array('id' => $groupId));
     $this->setPostArray(array('GroupUserMembershipForm' => array('userMembershipData' => $groupMembers['ids'])));
     $this->runControllerWithRedirectExceptionAndGetUrl('/zurmo/group/editUserMembership');
     $group->forgetAll();
     $group = Group::getById($groupId);
     $this->assertCount($count, $group->users);
     foreach ($groupMembers['ids'] as $userId) {
         $user = User::getById($userId);
         $this->assertEquals($group->id, $user->groups[0]->id);
         $this->assertTrue(RightsUtil::doesUserHaveAllowByRightName('ContactsModule', ContactsModule::getAccessRight(), $user));
         $this->assertTrue(RightsUtil::doesUserHaveAllowByRightName('ContactsModule', ContactsModule::getCreateRight(), $user));
         $this->assertTrue(RightsUtil::doesUserHaveAllowByRightName('ContactsModule', ContactsModule::getDeleteRight(), $user));
     }
     $this->clearAllCaches();
     // go ahead and create contact with group given readwrite, use group's first member to confirm he has create access
     $this->logoutCurrentUserLoginNewUserAndGetByUsername($groupMembers['usernames'][0]);
     $this->resetGetArray();
     $startingState = ContactsUtil::getStartingState();
     $this->setPostArray(array('Contact' => array('firstName' => 'John', 'lastName' => 'Doe', 'officePhone' => '456765421', 'state' => array('id' => $startingState->id), 'explicitReadWriteModelPermissions' => array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_NONEVERYONE_GROUP, 'nonEveryoneGroup' => $groupId))));
     $startTime = microtime(true);
     $url = $this->runControllerWithRedirectExceptionAndGetUrl('/contacts/default/create');
     $timeTakenForSave = microtime(true) - $startTime;
     $johnDoeContactId = intval(substr($url, strpos($url, 'id=') + 3));
     $johnDoeContact = Contact::getById($johnDoeContactId);
     $this->assertNotNull($johnDoeContact);
     $this->resetPostArray();
     $this->setGetArray(array('id' => $johnDoeContactId));
     $content = $this->runControllerWithNoExceptionsAndGetContent('/contacts/default/details');
     $this->assertContains('Who can read and write ' . strval($group), $content);
     $this->clearAllCaches();
     $this->resetPostArray();
     // ensure group members have access
     foreach ($groupMembers['usernames'] as $member) {
         $user = $this->logoutCurrentUserLoginNewUserAndGetByUsername($member);
         $this->assertNotNull($user);
         $this->setGetArray(array('id' => $johnDoeContactId));
         $this->runControllerWithNoExceptionsAndGetContent('/contacts/default/details');
         $this->runControllerWithNoExceptionsAndGetContent('/contacts/default/edit');
     }
     return $timeTakenForSave;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:71,代码来源:ZurmoRecordSharingPerformanceBenchmarkTest.php

示例14: testSuperUserModifyContactStatesDefaultValueItemsInDropDown

 /**
  * @depends testLayoutsLoadOkAfterCustomFieldsPlacedForContactsModule
  */
 public function testSuperUserModifyContactStatesDefaultValueItemsInDropDown()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //test existing ContactState changes to labels.
     $extraPostData = array('startingStateOrder' => '4', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('New', 'In ProgressD', 'RecycledC', 'QualifiedA', 'CustomerF', 'YRE'), 'contactStatesDataExistingValues' => array('New', 'In Progress', 'Recycled', 'Qualified', 'Customer', 'YRE'));
     $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState', $extraPostData, 'state');
     $compareData = array('New', 'In ProgressD', 'RecycledC', 'QualifiedA', 'CustomerF', 'YRE');
     $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder());
     //todo: test that the changed labels, updated the existing data if any existed.
     //Removing ContactStates items
     $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('New', 'RecycledC', 'QualifiedA'));
     $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState', $extraPostData, 'state');
     $compareData = array('New', 'RecycledC', 'QualifiedA');
     $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder());
     //Adding ContactStates items
     $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('New', 'RecycledC', 'QualifiedA', 'NewItem', 'NewItem2'));
     $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState', $extraPostData, 'state');
     $compareData = array('New', 'RecycledC', 'QualifiedA', 'NewItem', 'NewItem2');
     $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder());
     //Changing order of ContactStates items
     $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('New', 'NewItem2', 'RecycledC', 'QualifiedA', 'NewItem'));
     $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState', $extraPostData, 'state');
     $compareData = array('New', 'NewItem2', 'RecycledC', 'QualifiedA', 'NewItem');
     $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder());
     //test trying to save 2 ContactStates with the same name (QualifiedA is twice)
     $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('New', 'NewItem2', 'QualifiedA', 'QualifiedA', 'NewItem'));
     $this->setGetArray(array('moduleClassName' => 'ContactsModule', 'attributeTypeName' => 'ContactState', 'attributeName' => 'state'));
     $this->setPostArray(array('ajax' => 'edit-form', 'ContactStateAttributeForm' => array_merge(array('attributeLabels' => $this->createAttributeLabelGoodValidationPostData('state'), 'attributeName' => 'state'), $extraPostData)));
     $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/attributeEdit');
     $this->assertTrue(strlen($content) > 50);
     //approximate, but should definetely be larger than 50.
     //test trying to save 0 ContactStates
     $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array());
     $this->setPostArray(array('ajax' => 'edit-form', 'ContactStateAttributeForm' => array_merge(array('attributeLabels' => $this->createAttributeLabelGoodValidationPostData('state'), 'attributeName' => 'state'), $extraPostData)));
     $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/attributeEdit');
     $this->assertTrue(strlen($content) > 50);
     //approximate, but should definetely be larger than 50.
     //test trying to save contact states that are shorter than the minimum length.
     $extraPostData = array('startingStateOrder' => '2', 'isAudited' => '1', 'isRequired' => '1', 'contactStatesData' => array('NA', ' NB', 'NC'));
     $this->setPostArray(array('ajax' => 'edit-form', 'ContactStateAttributeForm' => array_merge(array('attributeLabels' => $this->createAttributeLabelGoodValidationPostData('state'), 'attributeName' => 'state'), $extraPostData)));
     $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/attributeEdit');
     $this->assertTrue(strlen($content) > 50);
     //approximate, but should definetely be larger than 50.
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:47,代码来源:ContactsDesignerSuperUserWalkthroughTest.php

示例15: afterDelete

 protected function afterDelete()
 {
     parent::afterDelete();
     ContactsUtil::resolveMarketingListMembersByContact($this);
 }
开发者ID:spiogit,项目名称:cna-seed-project,代码行数:5,代码来源:Contact.php


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