本文整理汇总了PHP中ContactsUtil类的典型用法代码示例。如果您正苦于以下问题:PHP ContactsUtil类的具体用法?PHP ContactsUtil怎么用?PHP ContactsUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContactsUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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('[email protected]', $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
示例16: actionModalListAllContacts
public function actionModalListAllContacts()
{
$modalListLinkProvider = new SelectFromRelatedEditModalListLinkProvider($_GET['modalTransferInformation']['sourceIdFieldId'], $_GET['modalTransferInformation']['sourceNameFieldId'], $_GET['modalTransferInformation']['modalId']);
$adapterName = ContactsUtil::resolveContactStateAdapterByModulesUserHasAccessTo('LeadsModule', 'ContactsModule', Yii::app()->user->userModel);
if ($adapterName === false) {
$messageView = new AccessFailureView();
$view = new AccessFailurePageView($messageView);
echo $view->render();
Yii::app()->end(0, false);
}
echo ModalSearchListControllerUtil::setAjaxModeAndRenderModalSearchList($this, $modalListLinkProvider, $adapterName);
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:12,代码来源:VariableContactStateController.php
示例17: setAttributeMetadataFromForm
public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
{
$modelClassName = get_class($this->model);
$attributeName = $attributeForm->attributeName;
$attributeLabels = $attributeForm->attributeLabels;
$elementType = $attributeForm->getAttributeTypeName();
$isRequired = (bool) $attributeForm->isRequired;
$isAudited = (bool) $attributeForm->isAudited;
$contactStatesData = $attributeForm->contactStatesData;
$contactStatesLabels = $attributeForm->contactStatesLabels;
$startingStateOrder = (int) $attributeForm->startingStateOrder;
$contactStatesDataExistingValues = $attributeForm->contactStatesDataExistingValues;
if ($contactStatesDataExistingValues == null) {
$contactStatesDataExistingValues = array();
}
if ($attributeForm instanceof ContactStateAttributeForm) {
//update order on existing states.
//delete removed states
$states = ContactState::getAll('order');
$stateNames = array();
foreach ($states as $state) {
if (in_array($state->name, $contactStatesData)) {
$stateNames[] = $state->name;
$state->order = array_search($state->name, $contactStatesData);
$state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $state->order);
$saved = $state->save();
assert('$saved');
} elseif (in_array($state->name, $contactStatesDataExistingValues)) {
$order = array_search($state->name, $contactStatesDataExistingValues);
$state->name = $contactStatesData[$order];
$state->order = $order;
$state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $state->order);
$saved = $state->save();
assert('$saved');
$stateNames[] = $state->name;
} else {
$stateNames[] = $state->name;
$state->delete();
}
}
//add new states with correct order.
foreach ($contactStatesData as $order => $name) {
if (!in_array($name, $stateNames)) {
$state = new ContactState();
$state->name = $name;
$state->order = $order;
$state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $order);
$saved = $state->save();
assert('$saved');
}
}
//Set starting state by order.
ContactsUtil::setStartingStateByOrder($startingStateOrder);
ModelMetadataUtil::addOrUpdateRelation($modelClassName, $attributeName, $attributeLabels, $elementType, $isRequired, $isAudited, 'ContactState');
} else {
throw new NotSupportedException();
}
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:58,代码来源:ContactStateModelAttributesAdapter.php
示例18: testSuperUserConvertAction
/**
* @depends testSuperUserCreateAction
*/
public function testSuperUserConvertAction()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$startingLeadState = LeadsUtil::getStartingState();
$startingContactState = ContactsUtil::getStartingState();
$leads = Contact::getByName('myNewLead myNewLeadson');
$this->assertEquals(1, count($leads));
$lead = $leads[0];
$this->assertTrue($lead->state == $startingLeadState);
//Test just going to the convert page.
$this->setGetArray(array('id' => $lead->id));
$this->resetPostArray();
//Test trying to convert by skipping account creation
$this->runControllerWithNoExceptionsAndGetContent('leads/default/convert');
$this->setGetArray(array('id' => $lead->id));
$this->setPostArray(array('AccountSkip' => 'Not Used'));
$this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
$leadId = $lead->id;
$lead->forget();
$contact = Contact::getById($leadId);
$this->assertTrue($contact->state == $startingContactState);
//Test trying to convert by creating a new account.
$lead5 = LeadTestHelper::createLeadbyNameForOwner('superLead5', $super);
$this->assertTrue($lead5->state == $startingLeadState);
$this->setGetArray(array('id' => $lead5->id));
$this->setPostArray(array('Account' => array('name' => 'someAccountName')));
$this->assertEquals(0, count(Account::getAll()));
$this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
$this->assertEquals(1, count(Account::getAll()));
$lead5Id = $lead5->id;
$lead5->forget();
$contact5 = Contact::getById($lead5Id);
$this->assertTrue($contact5->state == $startingContactState);
$this->assertEquals('someAccountName', $contact5->account->name);
//Test trying to convert by selecting an existing account
$account = AccountTestHelper::createAccountbyNameForOwner('someNewAccount', $super);
$lead6 = LeadTestHelper::createLeadbyNameForOwner('superLead6', $super);
$this->assertTrue($lead6->state == $startingLeadState);
$this->setGetArray(array('id' => $lead6->id));
$this->setPostArray(array('AccountSelectForm' => array('accountId' => $account->id, 'accountName' => 'someNewAccount')));
$this->assertEquals(2,
|
请发表评论