本文整理汇总了PHP中ContactState类的典型用法代码示例。如果您正苦于以下问题:PHP ContactState类的具体用法?PHP ContactState怎么用?PHP ContactState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContactState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: loadStartingData
/**
* Used on first load to install ContactState data
* and the startingState for the Contacts module.
* @return true/false if data was in fact loaded.
*/
public static function loadStartingData()
{
if (count(ContactState::GetAll()) != 0) {
return false;
}
$data = array(Zurmo::t('Core', 'New'), Zurmo::t('Core', 'In Progress'), Zurmo::t('ContactsModule', 'Recycled'), Zurmo::t('ContactsModule', 'Dead'), Zurmo::t('ContactsModule', 'Qualified'), Zurmo::t('ZurmoModule', 'Customer'));
$order = 0;
$startingStateId = null;
foreach ($data as $stateName) {
$state = new ContactState();
$state->name = $stateName;
$state->order = $order;
$saved = $state->save();
assert('$saved');
if ($stateName == Zurmo::t('ContactsModule', 'Qualified')) {
$startingStateId = $state->id;
}
$order++;
}
if ($startingStateId == null) {
throw new NotSupportedException();
}
$metadata = ContactsModule::getMetadata();
$metadata['global']['startingStateId'] = $startingStateId;
ContactsModule::setMetadata($metadata);
assert('count(ContactState::GetAll()) == 6');
return true;
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:33,代码来源:ContactsModule.php
示例2: testLoad
public function testLoad()
{
$customFieldData = CustomFieldData::getByName('Titles');
$this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('AccountTypes');
$this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('LeadSources');
$this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('Industries');
$this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('MeetingCategories');
$this->assertEquals(0, count(unserialize($customFieldData->serializedData)));
$this->assertEquals(0, ContactState::getCount());
// do a getAll to ensure we create base currency
$baseCurrency = Currency::getAll();
$this->assertCount(1, $baseCurrency);
$this->assertEquals(1, Currency::getCount());
$messageLogger = new MessageLogger();
DefaultDataUtil::load($messageLogger);
$customFieldData = CustomFieldData::getByName('Titles');
$this->assertEquals(4, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('AccountTypes');
$this->assertEquals(3, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('LeadSources');
$this->assertEquals(4, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('Industries');
$this->assertEquals(9, count(unserialize($customFieldData->serializedData)));
$customFieldData = CustomFieldData::getByName('MeetingCategories');
$this->assertEquals(2, count(unserialize($customFieldData->serializedData)));
$this->assertEquals(6, ContactState::getCount());
$this->assertEquals(1, Currency::getCount());
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:32,代码来源:DefaultDataUtilTest.php
示例3: 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 mixed $value
* @return sanitized value
* @throws InvalidValueToSanitizeException
* @throws NotFoundException
*/
public function sanitizeValue($value)
{
assert('$this->attributeName == 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', '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('ZurmoModule', 'Status specified is invalid.'));
}
return $state;
} catch (NotFoundException $e) {
throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'Status specified does not exist.'));
}
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:35,代码来源:ContactStateSanitizerUtil.php
示例4: testGetExportValue
public function testGetExportValue()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$data = array();
$contactStates = ContactState::getByName('Qualified');
$contact = new Contact();
$contact->owner = $super;
$contact->firstName = 'Super';
$contact->lastName = 'Man';
$contact->jobTitle = 'Superhero';
$contact->description = 'Some Description';
$contact->department = 'Red Tape';
$contact->officePhone = '1234567890';
$contact->mobilePhone = '0987654321';
$contact->officeFax = '1222222222';
$contact->state = $contactStates[0];
$this->assertTrue($contact->save());
$adapter = new ContactStateRedBeanModelAttributeValueToExportValueAdapter($contact, 'state');
$adapter->resolveData($data);
$compareData = array($contactStates[0]->name);
$this->assertEquals($compareData, $data);
$data = array();
$adapter->resolveHeaderData($data);
$compareData = array($contact->getAttributeLabel('state'));
$this->assertEquals($compareData, $data);
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:27,代码来源:ContactStateRedBeanModelAttributeValueToExportValueAdapterTest.php
示例5: testCreateAndGetContactWebFormById
public function testCreateAndGetContactWebFormById()
{
$allAttributes = ContactWebFormsUtil::getAllAttributes();
$placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
$contactFormAttributes = ContactWebFormsUtil::getAllPlacedAttributes($allAttributes, $placedAttributes);
$attributes = array_keys($contactFormAttributes);
$this->assertTrue(ContactsModule::loadStartingData());
$contactStates = ContactState::getByName('New');
$contactWebForm = new ContactWebForm();
$contactWebForm->name = 'Test Form';
$contactWebForm->redirectUrl = 'http://google.com';
$contactWebForm->submitButtonLabel = 'Save';
$contactWebForm->defaultState = $contactStates[0];
$contactWebForm->serializedData = serialize($attributes);
$contactWebForm->defaultOwner = Yii::app()->user->userModel;
$this->assertTrue($contactWebForm->save());
$id = $contactWebForm->id;
unset($contactWebForm);
$contactWebForm = ContactWebForm::getById($id);
$this->assertEquals('Test Form', $contactWebForm->name);
$this->assertEquals('http://google.com', $contactWebForm->redirectUrl);
$this->assertEquals('Save', $contactWebForm->submitButtonLabel);
$this->assertEquals('New', $contactWebForm->defaultState->name);
$this->assertEquals($attributes, unserialize($contactWebForm->serializedData));
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:25,代码来源:ContactWebFormTest.php
示例6: 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, $contactStatesDataExistingValues)) {
//todo: just don't match up the swap
$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;
} elseif (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');
} 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:RamaKavanan,项目名称:InitialVersion,代码行数:59,代码来源:ContactStateModelAttributesAdapter.php
示例7: resolveValueAndSetToModel
/**
* Utilized to create or update model attribute values after a workflow's triggers are fired as true.
* @param WorkflowActionProcessingModelAdapter $adapter
* @param string $attribute
* @throws NotSupportedException
*/
public function resolveValueAndSetToModel(WorkflowActionProcessingModelAdapter $adapter, $attribute)
{
assert('is_string($attribute)');
if ($this->type == WorkflowActionAttributeForm::TYPE_STATIC) {
$adapter->getModel()->{$attribute} = ContactState::getById((int) $this->value);
//todo: what if it doesn't exist anymore?
} else {
throw new NotSupportedException();
}
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:16,代码来源:ContactStateWorkflowActionAttributeForm.php
示例8: testCreateAndGetContactWebFormEntryById
public function testCreateAndGetContactWebFormEntryById()
{
$allAttributes = ContactWebFormsUtil::getAllAttributes();
$placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
$contactFormAttributes = ContactWebFormsUtil::getAllPlacedAttributes($allAttributes, $placedAttributes);
$attributes = array_keys($contactFormAttributes);
$this->assertTrue(ContactsModule::loadStartingData());
$contactStates = ContactState::getByName('New');
$contactWebForm = new ContactWebForm();
$contactWebForm->name = 'Test Form';
$contactWebForm->redirectUrl = 'http://google.com';
$contactWebForm->submitButtonLabel = 'Save';
$contactWebForm->defaultState = $contactStates[0];
$contactWebForm->defaultOwner = Yii::app()->user->userModel;
$contactWebForm->serializedData = serialize($attributes);
$contactWebForm->save();
$contact = new Contact();
$contact->owner = $contactWebForm->defaultOwner;
$contact->state = $contactWebForm->defaultState;
$contact->firstName = 'Super';
$contact->lastName = 'Man';
$contact->jobTitle = 'Superhero';
$contact->companyName = 'Test Inc.';
if ($contact->validate()) {
$contactWebFormEntryStatus = ContactWebFormEntry::STATUS_SUCCESS;
$contactWebFormEntryMessage = ContactWebFormEntry::STATUS_SUCCESS_MESSAGE;
} else {
$contactWebFormEntryStatus = ContactWebFormEntry::STATUS_ERROR;
$contactWebFormEntryMessage = ContactWebFormEntry::STATUS_ERROR_MESSAGE;
}
$contact->save();
foreach ($contactFormAttributes as $attributeName => $attributeValue) {
$contactFormAttributes[$attributeName] = $contact->{$attributeName};
}
$contactFormAttributes['owner'] = $contactWebForm->defaultOwner->id;
$contactFormAttributes['state'] = $contactWebForm->defaultState->id;
$contactWebFormEntry = new ContactWebFormEntry();
$contactWebFormEntry->serializedData = serialize($contactFormAttributes);
$contactWebFormEntry->status = $contactWebFormEntryStatus;
$contactWebFormEntry->message = $contactWebFormEntryMessage;
$contactWebFormEntry->contactWebForm = $contactWebForm;
$contactWebFormEntry->contact = $contact;
$this->assertTrue($contactWebFormEntry->save());
$contactWebFormEntryId = $contactWebFormEntry->id;
unset($contactWebFormEntry);
$contactWebFormEntry = ContactWebFormEntry::getById($contactWebFormEntryId);
$this->assertEquals('Test Form', $contactWebFormEntry->contactWebForm->name);
$this->assertEquals('Super', $contactWebFormEntry->contact->firstName);
$this->assertEquals('Man', $contactWebFormEntry->contact->lastName);
$contactFormAttributes = unserialize($contactWebFormEntry->serializedData);
$this->assertEquals('Super', $contactFormAttributes['firstName']);
$this->assertEquals('Man', $contactFormAttributes['lastName']);
$this->assertEquals('Superhero', $contactFormAttributes['jobTitle']);
$this->assertEquals('Test Inc.', $contactFormAttributes['companyName']);
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:55,代码来源:ContactWebFormEntryTest.php
示例9: testSanitizeValueBySanitizerTypesForContactStateTypeThatIsRequired
public function testSanitizeValueBySanitizerTypesForContactStateTypeThatIsRequired()
{
$contactStates = ContactState::getAll();
$this->assertEquals(6, count($contactStates));
//Test a required contact state with no value or default value.
$importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
$columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultStateId' => null)));
$sanitizerUtilTypes = ContactStateAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
$sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'Contact', null, null, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
$this->assertNull($sanitizedValue);
$this->assertFalse($importSanitizeResultsUtil->shouldSaveModel());
$messages = $importSanitizeResultsUtil->getMessages();
$this->assertEquals(1, count($messages));
$compareMessage = 'Contact - The status is required. Neither a value nor a default was specified.';
$this->assertEquals($compareMessage, $messages[0]);
//Test a required contact state with a valid value, and a default value. The valid value should come through.
$importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
$columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultStateId' => $contactStates[4]->id)));
$sanitizerUtilTypes = ContactStateAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
$sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'Contact', null, $contactStates[5]->id, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
$this->assertEquals($contactStates[5], $sanitizedValue);
$this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
$messages = $importSanitizeResultsUtil->getMessages();
$this->assertEquals(0, count($messages));
//Test a required contact state with no value, and a default value.
$importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
$columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultStateId' => $contactStates[4]->id)));
$sanitizerUtilTypes = ContactStateAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
$sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'Contact', null, null, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
$this->assertEquals($contactStates[4], $sanitizedValue);
$this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
$messages = $importSanitizeResultsUtil->getMessages();
$this->assertEquals(0, count($messages));
//Test a required contact state with a value that is invalid
$importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
$columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultValue' => null)));
$sanitizerUtilTypes = ContactStateAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
$sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'Contact', null, 'somethingnotright', 'column_0', $columnMappingData, $importSanitizeResultsUtil);
$this->assertFalse($importSanitizeResultsUtil->shouldSaveModel());
$messages = $importSanitizeResultsUtil->getMessages();
$this->assertEquals(1, count($messages));
$compareMessage = 'Contact - Status specified does not exist.';
$this->assertEquals($compareMessage, $messages[0]);
//Test a required contact state with a state that is for leads, not contacts.
$importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
$columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('DefaultContactStateIdMappingRuleForm' => array('defaultValue' => null)));
$sanitizerUtilTypes = ContactStateAttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
$sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'Contact', null, $contactStates[1]->id, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
$this->assertFalse($importSanitizeResultsUtil->shouldSaveModel());
$messages = $importSanitizeResultsUtil->getMessages();
$this->assertEquals(1, count($messages));
$compareMessage = 'Contact - Status specified is invalid.';
$this->assertEquals($compareMessage, $messages[0]);
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:54,代码来源:ContactImportSanitizerUtilTest.php
示例10: 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
示例11: testCasingInsensitivity
/**
* @depends testGetModelsByFullName
*/
public function testCasingInsensitivity()
{
Yii::app()->user->userModel = User::getByUsername('super');
$user = User::getByUsername('billy');
ContactsModule::loadStartingData();
$states = ContactState::GetAll();
$contact = new Contact();
$contact->owner = $user;
$contact->title->value = 'Mr.';
$contact->firstName = 'super';
$contact->lastName = 'man';
$contact->state = $states[0];
$this->assertTrue($contact->save());
$id = $contact->id;
$this->assertNotEmpty($id);
unset($contact);
$contacts = ZurmoModelSearch::getModelsByFullName('Contact', 'Super Man');
$this->assertEquals(2, count($contacts));
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:22,代码来源:ZurmoModelSearchTest.php
示例12: makeAll
public function makeAll(&$demoDataHelper)
{
assert('$demoDataHelper instanceof DemoDataHelper');
assert('$demoDataHelper->isSetRange("User")');
$contactStates = ContactState::getAll();
$statesBeginningWithStartingState = $this->getStatesBeforeOrStartingWithStartingState($contactStates);
$contacts = array();
for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
$contact = new Contact();
$contact->owner = $demoDataHelper->getRandomByModelName('User');
$contact->state = RandomDataUtil::getRandomValueFromArray($statesBeginningWithStartingState);
$this->populateModel($contact);
$saved = $contact->save();
assert('$saved');
$contacts[] = $contact->id;
}
//We can use dummy model name here ContactsThatAreLeads, so we can distinct between contacts are leads
$demoDataHelper->setRangeByModelName('ContactsThatAreLeads', $contacts[0], $contacts[count($contacts) - 1]);
}
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:19,代码来源:LeadsDemoDataMaker.php
示例13: createContactWebFormByName
public static function createContactWebFormByName($name, $owner = null)
{
if ($owner === null) {
$owner = Yii::app()->user->userModel;
}
$placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
ContactsModule::loadStartingData();
$contactStates = ContactState::getByName('New');
$contactWebForm = new ContactWebForm();
$contactWebForm->name = $name;
$contactWebForm->redirectUrl = 'http://www.zurmo.com/';
$contactWebForm->submitButtonLabel = 'Save';
$contactWebForm->defaultState = $contactStates[0];
$contactWebForm->serializedData = serialize($placedAttributes);
$contactWebForm->defaultOwner = $owner;
$saved = $contactWebForm->save();
assert('$saved');
return $contactWebForm;
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:19,代码来源:ContactWebFormTestHelper.php
示例14: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$loaded = ContactsModule::loadStartingData();
assert($loaded);
// Not Coding Standard
$contactStates = ContactState::getByName('New');
self::$newState = $contactStates[0];
$contactStates = ContactState::getByName('In progress');
self::$inProgressState = $contactStates[0];
$contactStates = ContactState::getByName('Recycled');
self::$recycledState = $contactStates[0];
$contactStates = ContactState::getByName('Dead');
self::$deadState = $contactStates[0];
$contactStates = ContactState::getByName('Qualified');
self::$qualifiedState = $contactStates[0];
$contactStates = ContactState::getByName('Customer');
self::$customerState = $contactStates[0];
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:19,代码来源:WorkflowTriggersUtilForLikeContactStateTest.php
示例15: makeAll
public function makeAll(&$demoDataHelper)
{
assert('$demoDataHelper instanceof DemoDataHelper');
assert('$demoDataHelper->isSetRange("User")');
assert('$demoDataHelper->isSetRange("Account")');
$contactStates = ContactState::getAll();
$statesBeginningWithStartingState = $this->getStatesBeforeOrStartingWithStartingState($contactStates);
$contacts = array();
for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
$contact = new Contact();
$contact->account = $demoDataHelper->getRandomByModelName('Account');
$contact->state = RandomDataUtil::getRandomValueFromArray($statesBeginningWithStartingState);
$contact->owner = $contact->account->owner;
$this->populateModel($contact);
$saved = $contact->save();
assert('$saved');
$contacts[] = $contact->id;
}
$demoDataHelper->setRangeByModelName('Contact', $contacts[0], $contacts[count($contacts) - 1]);
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:20,代码来源:ContactsDemoDataMaker.php
示例16: sanitizeValue
/**
* Contact state is required. If the value provided is null then the sanitizer will attempt use a default
* value if provided. If this is missing then a InvalidValueToSanitizeException will be thrown.
* @param mixed $value
* @return sanitized value
* @throws InvalidValueToSanitizeException
*/
public function sanitizeValue($value)
{
assert('$this->attributeName == null');
assert('is_string($value) || $value == null || $value instanceof ContactState');
$modelClassName = $this->modelClassName;
$model = new $modelClassName(false);
if ($value == null) {
if (isset($this->mappingRuleData['defaultStateId']) && $this->mappingRuleData['defaultStateId'] != null) {
try {
$state = ContactState::getById((int) $this->mappingRuleData['defaultStateId']);
} catch (NotFoundException $e) {
throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'The default status specified does not exist.'));
}
return $state;
} else {
throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'The status is required. Neither a value nor a default was specified.'));
}
}
return $value;
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:27,代码来源:ContactStateRequiredSanitizerUtil.php
示例17: testRenderHtmlContentLabelFromContactAndKeyword
public function testRenderHtmlContentLabelFromContactAndKeyword()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$contact = new Contact();
$contact->firstName = 'johnny';
$contact->lastName = 'five';
$contact->owner = $super;
$contact->state = ContactState::getById(5);
$contact->primaryEmail = new Email();
$contact->primaryEmail->emailAddress = '[email protected]';
$this->assertTrue($contact->save());
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$contact2 = new Contact();
$contact2->firstName = 'johnny';
$contact2->lastName = 'six';
$contact2->owner = $super;
$contact2->state = ContactState::getById(5);
$contact2->primaryEmail = new Email();
$contact2->primaryEmail->emailAddress = '[email protected]';
$contact2->secondaryEmail = new Email();
$contact2->secondaryEmail->emailAddress = '[email protected]';
$this->assertTrue($contact2->save());
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$contact3 = new Contact();
$contact3->firstName = 'johnny';
$contact3->lastName = 'seven';
$contact3->owner = $super;
$contact3->state = ContactState::getById(5);
$this->assertTrue($contact3->save());
$content = MultipleContactsForMeetingElement::renderHtmlContentLabelFromContactAndKeyword($contact, 'asdad');
$this->assertEquals('johnny five  <b>[email protected]</b>', $content);
$content = MultipleContactsForMeetingElement::renderHtmlContentLabelFromContactAndKeyword($contact2, 'b@b');
$this->assertEquals('johnny six  <b>[email protected]</b>', $content);
$content = MultipleContactsForMeetingElement::renderHtmlContentLabelFromContactAndKeyword($contact2, 'cc');
$this->assertEquals('johnny six  <b>[email protected]</b>', $content);
$content = MultipleContactsForMeetingElement::renderHtmlContentLabelFromContactAndKeyword($contact3, 'cx');
$this->assertEquals('johnny seven', $content);
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:41,代码来源:MultipleContactsForMeetingElementTest.php
示例18: testUsingStateAdapters
public function testUsingStateAdapters()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$contactStates = ContactState::getAll();
$this->assertTrue(count($contactStates) > 1);
$firstContactState = $contactStates[0];
$lastContactState = $contactStates[count($contactStates) - 1];
$contact = new Contact();
$contact->title->value = 'Mr.';
$contact->firstName = 'Sallyy';
$contact->lastName = 'Sallyyson';
$contact->owner = $super;
$contact->state = $firstContactState;
$contact->primaryEmail = new Email();
$contact->primaryEmail->emailAddress = '[email protected]';
$contact->secondaryEmail = new Email();
$contact->secondaryEmail->emailAddress = '[email protected]';
$this->assertTrue($contact->save());
$data = ContactSearch::getContactsByPartialFullNameOrAnyEmailAddress('sally', 5);
$this->assertEquals(2, count($data));
$data = ContactSearch::getContactsByPartialFullName('sally', 5);
$this->assertEquals(2, count($data));
//Use contact state adapter
$data = ContactSearch::getContactsByPartialFullNameOrAnyEmailAddress('sally', 5, 'ContactsStateMetadataAdapter');
$this->assertEquals(1, count($data));
$this->assertEquals($lastContactState, $data[0]->state);
$data = ContactSearch::getContactsByPartialFullName('sally', 5, 'ContactsStateMetadataAdapter');
$this->assertEquals(1, count($data));
$this->assertEquals($lastContactState, $data[0]->state);
//Use lead state adapter
$data = ContactSearch::getContactsByPartialFullNameOrAnyEmailAddress('sally', 5, 'LeadsStateMetadataAdapter');
$this->assertEquals(1, count($data));
$this->assertEquals($firstContactState, $data[0]->state);
$data = ContactSearch::getContactsByPartialFullName('sally', 5, 'LeadsStateMetadataAdapter');
$this->assertEquals(1, count($data));
$this->assertEquals($firstContactState, $data[0]->state);
}
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:38,代码来源:ContactSearchTest.php
示例19: testCreateAndGetContactWebFormById
public function testCreateAndGetContactWebFormById()
{
ContactWebFormTestHelper::deleteAllContactWebForms();
$placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
$this->assertTrue(ContactsModule::loadStartingData());
$contactStates = ContactState::getByName('New');
$contactWebForm = new ContactWebForm();
$contactWebForm->name = 'Test Form';
$contactWebForm->redirectUrl = 'http://zurmo.com';
$contactWebForm->submitButtonLabel = 'Save';
$contactWebForm->defaultState = $contactStates[0];
$contactWebForm->serializedData = serialize($placedAttributes);
$contactWebForm->defaultOwner = Yii::app()->user->userModel;
$this->assertTrue($contactWebForm->save());
$id = $contactWebForm->id;
unset($contactWebForm);
$contactWebForm = ContactWebForm::getById($id);
$this->assertEquals('Test Form', $contactWebForm->name);
$this->assertEquals('http://zurmo.com', $contactWebForm->redirectUrl);
$this->assertEquals('Save', $contactWebForm->submitButtonLabel);
$this->assertEquals('New', $contactWebForm->defaultState->name);
$this->assertEquals($placedAttributes, unserialize($contactWebForm->serializedData));
$this->assertNull($contactWebForm->defaultPermissionSetting);
$this->assertNull($contactWebForm->defaultPermissionGroupSetting);
$contactWebForm->name = 'New Test Form';
$contactWebForm->redirectUrl = 'http://zurmo.org';
$contactWebForm->submitButtonLabel = 'Save and Redirect';
$contactWebForm->defaultPermissionSetting = UserConfigurationForm::DEFAULT_PERMISSIONS_SETTING_EVERYONE;
$this->assertTrue($contactWebForm->save());
$id = $contactWebForm->id;
unset($contactWebForm);
$contactWebForm = ContactWebForm::getById($id);
$this->assertEquals('New Test Form', $contactWebForm->name);
$this->assertEquals('http://zurmo.org', $contactWebForm->redirectUrl);
$this->assertEquals('Save and Redirect', $contactWebForm->submitButtonLabel);
$this->assertEquals($contactWebForm->defaultPermissionSetting, UserConfigurationForm::DEFAULT_PERMISSIONS_SETTING_EVERYONE);
$this->assertNull($contactWebForm->defaultPermissionGroupSetting);
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:38,代码来源:ContactWebFormTest.php
示例20: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$user = SecurityTestHelper::createSuperAdmin();
Yii::app()->user->userModel = $user;
ContactsModule::loadStartingData();
$contactData = array('Sam' => '123-456-789', 'Sally' => '123-456-789', 'Sarah' => '123-456-789', 'Jason' => '123-456-789', 'James' => '123-456-789', 'Roger' => '987-654-321');
$contactStates = ContactState::getAll();
$lastContactState = $contactStates[count($contactStates) - 1];
foreach ($contactData as $firstName => $phone) {
$contact = new Contact();
$contact->title->value = 'Mr.';
$contact->firstName = $firstName;
$contact->lastName = 'son';
$contact->owner = $user;
$contact->state = $lastContactState;
$contact->mobilePhone = $phone;
$contact->officePhone = $phone . 'X';
$contact->primaryEmail->emailAddress = strtolower($firstName) . '@zurmoland.com';
$contact->secondaryEmail->emailAddress = strtolower($firstName) . '@zurmoworld.com';
$contact->save();
}
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:23,代码来源:ContactDedupeRulesTest.php
注:本文中的ContactState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论