本文整理汇总了PHP中CRM_Contact_BAO_ContactType类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_ContactType类的具体用法?PHP CRM_Contact_BAO_ContactType怎么用?PHP CRM_Contact_BAO_ContactType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Contact_BAO_ContactType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object.
*
*
* @return void
*/
public function buildQuickForm()
{
// text for sort_name or email criteria
$config = CRM_Core_Config::singleton();
$label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email');
$this->add('text', 'sort_name', $label);
$searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options');
$shortCuts = array();
//@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
// this is loaded onto then replace with something like '__' & test
$separator = CRM_Core_DAO::VALUE_SEPARATOR;
if (!empty($searchOptions['contactType'])) {
$contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
$this->add('select', 'contact_type', ts('is...'), $contactTypes, FALSE, array('class' => 'crm-select2'));
}
// add select for groups
if (!empty($searchOptions['groups'])) {
$this->addSelect('group', array('entity' => 'group_contact', 'label' => ts('in'), 'context' => 'search', 'placeholder' => ts('- any group -')));
}
if (!empty($searchOptions['tags'])) {
// tag criteria
if (!empty($this->_tag)) {
$this->addSelect('tag', array('entity' => 'entity_tag', 'label' => ts('with'), 'context' => 'search', 'placeholder' => ts('- any tag -')));
}
}
parent::buildQuickForm();
}
示例2: buildForm
function buildForm(&$form)
{
/**
* You can define a custom title for the search form
*/
$this->setTitle('Multiple Value Custom Group Search and Export');
$form->add('text', 'sort_name', ts('Contact Name'), TRUE);
// add select for contact type
$contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
$form->add('select', 'contact_type', ts('Find...'), $contactTypes);
// add select for groups
$group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group();
$form->addElement('select', 'group', ts('in'), $group);
// add select for tags
$tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$form->addElement('select', 'tag', ts('Tagged'), $tag);
if (empty($this->_groupTree)) {
CRM_Core_Error::statusBounce(ts("Atleast one Custom Group must be present, for Custom Group search."), CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'));
}
// add the checkbox for custom_groups
foreach ($this->_groupTree as $groupID => $group) {
if ($groupID == 'info') {
continue;
}
$form->addElement('checkbox', "custom_group[{$groupID}]", NULL, $group['title']);
}
}
示例3: buildQuickForm
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm()
{
// Register 'contact_1' model
$entities = array();
$entities[] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel');
$allowCoreTypes = array_merge(array('Contact', 'Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
$allowSubTypes = array();
// Register 'contribution_1'
$financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'financial_type_id');
$allowCoreTypes[] = 'Contribution';
//CRM-15427
$allowSubTypes['ContributionType'] = array($financialTypeId);
$entities[] = array('entity_name' => 'contribution_1', 'entity_type' => 'ContributionModel', 'entity_sub_type' => '*');
// If applicable, register 'membership_1'
$member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
if ($member && $member['is_active']) {
//CRM-15427
$entities[] = array('entity_name' => 'membership_1', 'entity_type' => 'MembershipModel', 'entity_sub_type' => '*');
$allowCoreTypes[] = 'Membership';
$allowSubTypes['MembershipType'] = explode(',', $member['membership_types']);
}
//CRM-15427
$this->addProfileSelector('custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE);
$this->addProfileSelector('custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE);
$this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this->_id);
parent::buildQuickForm();
}
示例4: getImage
/**
* given a contact type, get the contact image
*
* @param string $contact_type
*
* @return string
* @access public
* @static
*/
static function getImage($contactType, $urlOnly = false)
{
static $imageInfo = array();
if (!array_key_exists($contactType, $imageInfo)) {
$imageInfo[$contactType] = array();
$params = array('name' => $contactType);
CRM_Contact_BAO_ContactType::retrieve($params, $typeInfo);
if ($typeInfo['image_URL']) {
$imageUrl = $typeInfo['image_URL'];
$config =& CRM_Core_Config::singleton();
if (!preg_match("/^(\\/|(http(s)?:)).+\$/i", $imageUrl)) {
$imageUrl = $config->resourceBase . $imageUrl;
}
$imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$typeInfo['name']}-icon\" style=\"background: url('{$imageUrl}')\"></div>";
$imageInfo[$contactType]['url'] = $imageUrl;
} else {
$isSubtype = array_key_exists('parent_id', $typeInfo) && $typeInfo['parent_id'] ? true : false;
if ($isSubtype) {
$type = CRM_Contact_BAO_ContactType::getBasicType($typeInfo['name']) . "-subtype";
} else {
$type = $typeInfo['name'];
}
$imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$type}-icon\"></div>";
$imageInfo[$contactType]['url'] = null;
}
}
return $urlOnly ? $imageInfo[$contactType]['url'] : $imageInfo[$contactType]['image'];
}
示例5: initTasks
static function initTasks()
{
if (!self::$_tasks) {
self::$_tasks = array(1 => array('title' => ts('Add Contacts to Group'), 'class' => 'CRM_Contact_Form_Task_AddToGroup', 'result' => true), 2 => array('title' => ts('Remove Contacts from Group'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup', 'result' => true), 3 => array('title' => ts('Tag Contacts (assign tags)'), 'class' => 'CRM_Contact_Form_Task_AddToTag', 'result' => true), 4 => array('title' => ts('Untag Contacts (remove tags)'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag', 'result' => true), 5 => array('title' => ts('Export Contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => false), 6 => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => false), 7 => array('title' => ts('Send SMS to Contacts'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => true), 8 => array('title' => ts('Delete Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => false), 11 => array('title' => ts('Record Activity for Contacts'), 'class' => 'CRM_Activity_Form_Activity', 'result' => true), 13 => array('title' => ts('New Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => true), 14 => array('title' => ts('Update Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => true), 15 => array('title' => ts('Print Contacts'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => false), 16 => array('title' => ts('Mailing Labels'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => true), 17 => array('title' => ts('Batch Update via Profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => true), 19 => array('title' => ts('Print PDF Letter for Contacts'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => true), 21 => array('title' => ts('Merge Contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => true));
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
$label = CRM_Contact_BAO_ContactType::getLabel('Household');
self::$_tasks[9] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold', 'result' => true);
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
$label = CRM_Contact_BAO_ContactType::getLabel('Organization');
self::$_tasks[10] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization', 'result' => true);
}
//CRM-4418, check for delete
if (!CRM_Core_Permission::check('delete contacts')) {
unset(self::$_tasks[8]);
}
//show map action only if map provider and key is set
$config =& CRM_Core_Config::singleton();
if ($config->mapProvider && $config->mapAPIKey) {
self::$_tasks[12] = array('title' => ts('Map Contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => false);
}
if (CRM_Core_Permission::access('CiviEvent')) {
self::$_tasks[18] = array('title' => ts('Add Contacts to Event'), 'class' => 'CRM_Event_Form_Participant', 'result' => true);
}
if (CRM_Core_Permission::access('CiviMail')) {
self::$_tasks[20] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test', 'CRM_Mailing_Form_Schedule'), 'result' => false);
}
self::$_tasks += CRM_Core_Component::taskList();
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
asort(self::$_tasks);
}
}
示例6: hrjobcontract_civicrm_uninstall
/**
* Implementation of hook_civicrm_uninstall
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
*/
function hrjobcontract_civicrm_uninstall()
{
$subTypeInfo = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
$sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider');
foreach ($sub_type_name as $sub_type_name) {
$subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name));
$orid = array_key_exists($subTypeName, $subTypeInfo);
if ($orid) {
$id = $subTypeInfo[$subTypeName]['id'];
CRM_Contact_BAO_ContactType::del($id);
}
}
$jobContractMenu = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'job_contracts', 'id', 'name');
if (!empty($jobContractMenu)) {
CRM_Core_BAO_Navigation::processDelete($jobContractMenu);
}
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_navigation WHERE name IN ('job_contracts', 'import_export_job_contracts', 'jobImport', 'hoursType', 'pay_scale','hours_location', 'hrjc_contact_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason')");
CRM_Core_BAO_Navigation::resetNavigation();
//delete custom groups and field
$customGroup = civicrm_api3('CustomGroup', 'get', array('name' => "HRJobContract_Summary"));
$customGroupData = CRM_Utils_Array::first($customGroup['values']);
if (!empty($customGroupData['id'])) {
civicrm_api3('CustomGroup', 'delete', array('id' => $customGroupData['id']));
}
$customGroup = civicrm_api3('CustomGroup', 'get', array('name' => "HRJobContract_Summary"));
$customGroupData = CRM_Utils_Array::first($customGroup['values']);
if (!empty($customGroupData['id'])) {
civicrm_api3('CustomGroup', 'delete', array('id' => $customGroupData['id']));
}
//delete all option group and values
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_group WHERE name IN ('job_contracts', 'hoursType', 'pay_scale','hours_location', 'hrjc_contact_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason', 'hrjc_contract_type', 'hrjc_level_type', 'hrjc_department', 'hrjc_hours_type', 'hrjc_pay_grade', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_location', 'hrjc_pension_type', 'hrjc_region', 'hrjc_pay_scale')");
//delete job contract files to entities relations
CRM_Core_DAO::executeQuery("DELETE FROM civicrm_entity_file WHERE entity_table LIKE 'civicrm_hrjobcontract_%'");
return _hrjobcontract_civix_civicrm_uninstall();
}
示例7: setUp
public function setUp()
{
parent::setUp();
//create contact subtypes
$params = array('label' => 'indivi_student', 'name' => 'indivi_student', 'parent_id' => 1, 'is_active' => 1);
$result = CRM_Contact_BAO_ContactType::add($params);
$this->student = $params['name'];
$params = array('label' => 'indivi_parent', 'name' => 'indivi_parent', 'parent_id' => 1, 'is_active' => 1);
$result = CRM_Contact_BAO_ContactType::add($params);
$this->parent = $params['name'];
$params = array('label' => 'org_sponsor', 'name' => 'org_sponsor', 'parent_id' => 3, 'is_active' => 1);
$result = CRM_Contact_BAO_ContactType::add($params);
$this->sponsor = $params['name'];
//create contacts
$params = array('first_name' => 'Anne', 'last_name' => 'Grant', 'contact_type' => 'Individual');
$this->individual = Contact::create($params);
$params = array('first_name' => 'Bill', 'last_name' => 'Adams', 'contact_type' => 'Individual', 'contact_sub_type' => $this->student);
$this->indivi_student = Contact::create($params);
$params = array('first_name' => 'Alen', 'last_name' => 'Adams', 'contact_type' => 'Individual', 'contact_sub_type' => $this->parent);
$this->indivi_parent = Contact::create($params);
$params = array('organization_name' => 'Compumentor', 'contact_type' => 'Organization');
$this->organization = Contact::create($params);
$params = array('organization_name' => 'Conservation Corp', 'contact_type' => 'Organization', 'contact_sub_type' => $this->sponsor);
$this->organization_sponsor = Contact::create($params);
}
示例8: buildQuickForm
/**
* Function to build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
$this->setPageTitle(ts('Relationship Type'));
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'label_a_b', ts('Relationship Label-A to B'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_a_b'), TRUE);
$this->addRule('label_a_b', ts('Label already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_a_b'));
$this->add('text', 'label_b_a', ts('Relationship Label-B to A'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_b_a'));
$this->addRule('label_b_a', ts('Label already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_b_a'));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'description'));
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, '__');
// add select for contact type
$contactTypeA =& $this->add('select', 'contact_types_a', ts('Contact Type A') . ' ', array('' => ts('All Contacts')) + $contactTypes);
$contactTypeB =& $this->add('select', 'contact_types_b', ts('Contact Type B') . ' ', array('' => ts('All Contacts')) + $contactTypes);
$isActive =& $this->add('checkbox', 'is_active', ts('Enabled?'));
//only selected field should be allow for edit, CRM-4888
if ($this->_id && CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $this->_id, 'is_reserved')) {
foreach (array('contactTypeA', 'contactTypeB', 'isActive') as $field) {
${$field}->freeze();
}
}
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
}
}
示例9: buildQuickForm
/**
* Build the form
*
* @access public
*
* @return void
*/
function buildQuickForm()
{
// text for sort_name or email criteria
$config = CRM_Core_Config::singleton();
$label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email');
$this->add('text', 'sort_name', $label);
$searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options');
$shortCuts = array();
//@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
// this is loaded onto then replace with something like '__' & test
$separator = CRM_Core_DAO::VALUE_SEPARATOR;
if (!empty($searchOptions['contactType'])) {
$contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
$this->add('select', 'contact_type', ts('is...'), $contactTypes, FALSE, array('class' => 'crm-select2'));
}
if (!empty($searchOptions['groups'])) {
// Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
$groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, ' ', TRUE);
// add select for groups
$group = array('' => ts('- any group -')) + $groupHierarchy;
$this->add('select', 'group', ts('in'), $group, FALSE, array('class' => 'crm-select2'));
}
if (!empty($searchOptions['tags'])) {
// tag criteria
if (!empty($this->_tag)) {
$tag = array('' => ts('- any tag -')) + $this->_tag;
$this->add('select', 'tag', ts('with'), $tag, FALSE, array('class' => 'crm-select2'));
}
}
parent::buildQuickForm();
}
示例10: __construct
function __construct()
{
$contact_type = CRM_Contact_BAO_ContactType::getSelectElements(false, true, '_');
$this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name_a' => array('title' => ts('Contact A'), 'name' => 'display_name', 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name_a' => array('title' => ts('Contact A'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING)), 'grouping' => 'conact_a_fields'), 'civicrm_contact_b' => array('dao' => 'CRM_Contact_DAO_Contact', 'alias' => 'contact_b', 'fields' => array('display_name_b' => array('title' => ts('Contact B'), 'name' => 'display_name', 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name_b' => array('title' => ts('Contact B'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING)), 'grouping' => 'conact_b_fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email_a' => array('title' => ts('Email of Contact A'), 'name' => 'email')), 'grouping' => 'conact_a_fields'), 'civicrm_email_b' => array('dao' => 'CRM_Core_DAO_Email', 'alias' => 'email_b', 'fields' => array('email_b' => array('title' => ts('Email of Contact B'), 'name' => 'email')), 'grouping' => 'conact_b_fields'), 'civicrm_relationship_type' => array('dao' => 'CRM_Contact_DAO_RelationshipType', 'fields' => array('label_a_b' => array('title' => ts('Relationship A-B '), 'default' => true), 'label_b_a' => array('title' => ts('Relationship B-A '), 'default' => true)), 'filters' => array('contact_type_a' => array('title' => ts('Contact Type A'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING), 'contact_type_b' => array('title' => ts('Contact Type B'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING)), 'grouping' => 'relation-fields'), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('start_date' => array('title' => ts('Relationship Start Date')), 'end_date' => array('title' => ts('Relationship End Date')), 'description' => array('title' => ts('Description'))), 'filters' => array('is_active' => array('title' => ts('Relationship Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => '- Any -', 1 => 'Active', 0 => 'Inactive'), 'type' => CRM_Utils_Type::T_INT), 'relationship_type_id' => array('title' => ts('Relationship'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => '- any relationship type -') + CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, null, true), 'type' => CRM_Utils_Type::T_INT)), 'grouping' => 'relation-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'filters' => array('country_id' => array('title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince())), 'grouping' => 'contact-fields'), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_Group', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => true, 'options' => CRM_Core_PseudoConstant::group()))));
$this->_tagFilter = true;
parent::__construct();
}
示例11: setUp
function setUp()
{
parent::setUp();
$students = 'indivi_student' . substr(sha1(rand()), 0, 7);
$params = array('label' => $students, 'name' => $students, 'parent_id' => 1, 'is_active' => 1);
$result = CRM_Contact_BAO_ContactType::add($params);
$this->student = $params['name'];
$parents = 'indivi_parent' . substr(sha1(rand()), 0, 7);
$params = array('label' => $parents, 'name' => $parents, 'parent_id' => 1, 'is_active' => 1);
$result = CRM_Contact_BAO_ContactType::add($params);
$this->parent = $params['name'];
$orgs = 'org_sponsor' . substr(sha1(rand()), 0, 7);
$params = array('label' => $orgs, 'name' => $orgs, 'parent_id' => 3, 'is_active' => 1);
$result = CRM_Contact_BAO_ContactType::add($params);
$this->sponsor = $params['name'];
$this->indiviParams = array('first_name' => 'Anne', 'last_name' => 'Grant', 'contact_type' => 'Individual');
$this->individual = Contact::create($this->indiviParams);
$this->indiviStudentParams = array('first_name' => 'Bill', 'last_name' => 'Adams', 'contact_type' => 'Individual', 'contact_sub_type' => $this->student);
$this->indiviStudent = Contact::create($this->indiviStudentParams);
$this->indiviParentParams = array('first_name' => 'Alen', 'last_name' => 'Adams', 'contact_type' => 'Individual', 'contact_sub_type' => $this->parent);
$this->indiviParent = Contact::create($this->indiviParentParams);
$this->organizationParams = array('organization_name' => 'Compumentor', 'contact_type' => 'Organization');
$this->organization = Contact::create($this->organizationParams);
$this->orgSponsorParams = array('organization_name' => 'Conservation Corp', 'contact_type' => 'Organization', 'contact_sub_type' => $this->sponsor);
$this->orgSponsor = Contact::create($this->orgSponsorParams);
$this->householdParams = array('household_name' => "John Doe's home", 'contact_type' => 'Household');
$this->household = Contact::create($this->householdParams);
}
示例12: buildQuickForm
/**
* Build the form
*
* @access public
*
* @return void
*/
function buildQuickForm()
{
// text for sort_name or email criteria
$config = CRM_Core_Config::singleton();
$label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email');
$this->add('text', 'sort_name', $label);
$searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options');
if (!empty($searchOptions['contactType'])) {
$contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
$this->add('select', 'contact_type', ts('is...'), $contactTypes);
}
if (!empty($searchOptions['groups'])) {
// Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
$groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, ' ', TRUE);
// add select for groups
$group = array('' => ts('- any group -')) + $groupHierarchy;
$this->_groupElement =& $this->addElement('select', 'group', ts('in'), $group);
}
if (!empty($searchOptions['tags'])) {
// tag criteria
if (!empty($this->_tag)) {
$tag = array('' => ts('- any tag -')) + $this->_tag;
$this->_tagElement =& $this->addElement('select', 'tag', ts('with'), $tag);
}
}
parent::buildQuickForm();
}
示例13: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'label_a_b', ts('Relationship Label-A to B'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_a_b'), true);
$this->addRule('label_a_b', ts('Label already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_a_b'));
$this->add('text', 'label_b_a', ts('Relationship Label-B to A'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'label_b_a'));
$this->addRule('label_b_a', ts('Label already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_b_a'));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_RelationshipType', 'description'));
require_once 'CRM/Contact/BAO/ContactType.php';
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
// add select for contact type
$contactTypeA =& $this->add('select', 'contact_types_a', ts('Contact Type A') . ' ', array('' => ts('- select -')) + $contactTypes);
$contactTypeB =& $this->add('select', 'contact_types_b', ts('Contact Type B') . ' ', array('' => ts('- select -')) + $contactTypes);
$isActive =& $this->add('checkbox', 'is_active', ts('Enabled?'));
//only selected field should be allow for edit, CRM-4888
if ($this->_id && CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $this->_id, 'is_reserved')) {
foreach (array('contactTypeA', 'contactTypeB', 'isActive') as $field) {
${$field}->freeze();
}
}
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
$url = CRM_Utils_System::url('civicrm/admin/reltype&reset=1');
$location = "window.location='{$url}'";
$this->addElement('button', 'done', ts('Done'), array('onclick' => $location));
}
}
示例14: getImage
/**
* given a contact type, get the contact image
*
* @param string $contact_type
*
* @return string
* @access public
* @static
*/
static function getImage($contactType, $urlOnly = false, $contactId = null)
{
static $imageInfo = array();
if (!array_key_exists($contactType, $imageInfo)) {
$imageInfo[$contactType] = array();
$typeInfo = array();
$params = array('name' => $contactType);
require_once 'CRM/Contact/BAO/ContactType.php';
CRM_Contact_BAO_ContactType::retrieve($params, $typeInfo);
if (CRM_Utils_Array::value('image_URL', $typeInfo)) {
$imageUrl = $typeInfo['image_URL'];
$config = CRM_Core_Config::singleton();
if (!preg_match("/^(\\/|(http(s)?:)).+\$/i", $imageUrl)) {
$imageUrl = $config->resourceBase . $imageUrl;
}
$imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$typeInfo['name']}-icon\" style=\"background: url('{$imageUrl}')\" title=\"{$contactType}\"></div>";
$imageInfo[$contactType]['url'] = $imageUrl;
} else {
$isSubtype = array_key_exists('parent_id', $typeInfo) && $typeInfo['parent_id'] ? true : false;
if ($isSubtype) {
$type = CRM_Contact_BAO_ContactType::getBasicType($typeInfo['name']) . "-subtype";
} else {
$type = $typeInfo['name'];
}
$imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$type}-icon\" title=\"{$contactType}\"></div>";
$imageInfo[$contactType]['url'] = null;
}
}
$summaryOvelayProfileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'summary_overlay', 'id', 'name');
$profileURL = CRM_Utils_System::url('civicrm/profile/view', "reset=1&gid={$summaryOvelayProfileId}&id={$contactId}&snippet=4");
$imageInfo[$contactType]['summary-link'] = '<a href="' . $profileURL . '" class="crm-summary-link">' . $imageInfo[$contactType]["image"] . '</a>';
return $urlOnly ? $imageInfo[$contactType]['url'] : $imageInfo[$contactType]['summary-link'];
}
示例15: __construct
/**
* Class constructor.
*/
public function __construct()
{
$contact_type = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, '_');
$this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name_a' => array('title' => ts('Contact A'), 'name' => 'sort_name', 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_type_a' => array('title' => ts('Contact Type (Contact A)'), 'name' => 'contact_type'), 'contact_sub_type_a' => array('title' => ts('Contact Subtype (Contact A)'), 'name' => 'contact_sub_type')), 'filters' => array('sort_name_a' => array('title' => ts('Contact A'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_type_a' => array('title' => ts('Contact Type A'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING)), 'grouping' => 'contact_a_fields'), 'civicrm_contact_b' => array('dao' => 'CRM_Contact_DAO_Contact', 'alias' => 'contact_b', 'fields' => array('sort_name_b' => array('title' => ts('Contact B'), 'name' => 'sort_name', 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_type_b' => array('title' => ts('Contact Type (Contact B)'), 'name' => 'contact_type'), 'contact_sub_type_b' => array('title' => ts('Contact Subtype (Contact B)'), 'name' => 'contact_sub_type')), 'filters' => array('sort_name_b' => array('title' => ts('Contact B'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_type_b' => array('title' => ts('Contact Type B'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING)), 'grouping' => 'contact_b_fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email_a' => array('title' => ts('Email (Contact A)'), 'name' => 'email')), 'grouping' => 'contact_a_fields'), 'civicrm_email_b' => array('dao' => 'CRM_Core_DAO_Email', 'alias' => 'email_b', 'fields' => array('email_b' => array('title' => ts('Email (Contact B)'), 'name' => 'email')), 'grouping' => 'contact_b_fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone_a', 'fields' => array('phone_a' => array('title' => ts('Phone (Contact A)'), 'name' => 'phone'), 'phone_ext_a' => array('title' => ts('Phone Ext (Contact A)'), 'name' => 'phone_ext')), 'grouping' => 'contact_a_fields'), 'civicrm_phone_b' => array('dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone_b', 'fields' => array('phone_b' => array('title' => ts('Phone (Contact B)'), 'name' => 'phone'), 'phone_ext_b' => array('title' => ts('Phone Ext (Contact B)'), 'name' => 'phone_ext')), 'grouping' => 'contact_b_fields'), 'civicrm_relationship_type' => array('dao' => 'CRM_Contact_DAO_RelationshipType', 'fields' => array('label_a_b' => array('title' => ts('Relationship A-B '), 'default' => TRUE), 'label_b_a' => array('title' => ts('Relationship B-A '), 'default' => TRUE)), 'grouping' => 'relation-fields'), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('start_date' => array('title' => ts('Relationship Start Date')), 'end_date' => array('title' => ts('Relationship End Date')), 'description' => array('title' => ts('Description')), 'relationship_id' => array('title' => ts('Rel ID'), 'name' => 'id')), 'filters' => array('is_active' => array('title' => ts('Relationship Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => '- Any -', 1 => 'Active', 0 => 'Inactive'), 'type' => CRM_Utils_Type::T_INT), 'is_valid' => array('title' => ts('Relationship Dates Validity'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array(NULL => ts('- Any -'), 1 => ts('Not expired'), 0 => ts('Expired')), 'type' => CRM_Utils_Type::T_INT), 'relationship_type_id' => array('title' => ts('Relationship'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE), 'type' => CRM_Utils_Type::T_INT), 'start_date' => array('title' => ts('Start Date'), 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'type' => CRM_Utils_Type::T_DATE)), 'grouping' => 'relation-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'filters' => array('country_id' => array('title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince())), 'grouping' => 'contact-fields'));
$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
parent::__construct();
}