/** * 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(); }
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']); } }
/** * 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(); }
/** * 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']; }
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); } }
/** * 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(); }
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); }
/** * 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(); } }
/** * 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(); }
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(); }
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); }
/** * 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(); }
/** * 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)); } }
/** * 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']; }
/** * 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(); }
/** * Various pre defined contact super types. * * @return array */ public static function contactType() { static $contactType = NULL; if (!$contactType) { $contactType = CRM_Contact_BAO_ContactType::basicTypePairs(); } return $contactType; }
/** * various pre defined contact super types * @static */ static function &contactType() { static $contactType = NULL; if (!$contactType) { $contactType = array('' => ts('- any contact type -')); $contactType = $contactType + CRM_Contact_BAO_ContactType::basicTypePairs(); } return $contactType; }
/** * various pre defined contact super types * @static */ static function &contactType() { static $contactType = null; if (!$contactType) { require_once 'CRM/Contact/BAO/ContactType.php'; $contactType = array('' => ts('- any contact type -')); $contactType = $contactType + CRM_Contact_BAO_ContactType::basicTypePairs(); } return $contactType; }
/** * This function provides the HTML form elements that are specific to the Individual Contact Type * * @access public * @return None */ public function buildQuickForm(&$form, $action = null) { $form->applyFilter('__ALL__', 'trim'); //prefix $prefix = CRM_Core_PseudoConstant::individualPrefix(); if (!empty($prefix)) { $form->addElement('select', 'prefix_id', ts('Prefix'), array('' => '') + $prefix); } $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact'); // first_name $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']); //middle_name $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']); // last_name $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']); // suffix $suffix = CRM_Core_PseudoConstant::individualSuffix(); if ($suffix) { $form->addElement('select', 'suffix_id', ts('Suffix'), array('' => '') + $suffix); } // nick_name $form->addElement('text', 'nick_name', ts('Nick Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name')); // job title // override the size for UI to look better $attributes['job_title']['size'] = 30; $form->addElement('text', 'job_title', ts('Job title'), $attributes['job_title'], 'size="30"'); if ($action & CRM_Core_Action::UPDATE) { $mailToHouseholdID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $form->_contactId, 'mail_to_household_id', 'id'); $form->assign('mailToHouseholdID', $mailToHouseholdID); } //Shared Address Element require_once 'CRM/Contact/BAO/ContactType.php'; if (CRM_Contact_BAO_ContactType::isActive('Household')) { $label = CRM_Contact_BAO_ContactType::getLabel('Household'); $form->addElement('checkbox', 'use_household_address', null, ts('Use %1 Address', array(1 => $label))); } $housholdDataURL = CRM_Utils_System::url('civicrm/ajax/search', "hh=1", false, null, false); $form->assign('housholdDataURL', $housholdDataURL); $form->add('text', 'shared_household', ts('Select Household')); $form->add('hidden', 'shared_household_id', '', array('id' => 'shared_household_id')); //Home Url Element $form->addElement('text', 'home_URL', ts('Website'), array_merge(CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'home_URL'), array('onfocus' => "if (!this.value) this.value='http://'; else return false", 'onblur' => "if ( this.value == 'http://') this.value=''; else return false"))); $form->addRule('home_URL', ts('Enter a valid web location beginning with \'http://\' or \'https://\'. EXAMPLE: http://www.mysite.org/'), 'url'); //Current Employer Element $employerDataURL = CRM_Utils_System::url('civicrm/ajax/contactlist', 'org=1', false, null, false); $form->assign('employerDataURL', $employerDataURL); $form->addElement('text', 'current_employer', ts('Current Employer'), ''); $form->addElement('hidden', 'current_employer_id', '', array('id' => 'current_employer_id')); $form->addElement('text', 'contact_source', ts('Source')); //External Identifier Element $form->add('text', 'external_identifier', ts('External Id'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'), false); $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier')); $config =& CRM_Core_Config::singleton(); CRM_Core_ShowHideBlocks::links($form, 'demographics', '', ''); }
/** * Method to get groups * * @return array * @access protected */ protected function getSubtypes() { $subTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(); $options = array(); foreach ($subTypes as $name => $type) { if (!empty($type['parent_id'])) { $options[$name] = $type['parent_label'] . ' - ' . $type['label']; } } return $options; }
/** * Implementation of hook_civicrm_install * * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install */ function pcpteams_civicrm_install() { //create custom group from xml file // Create OptionGroup, OptionValues, RelationshipType, CustomGroup and CustomFields $extensionDir = dirname(__FILE__) . DIRECTORY_SEPARATOR; $customDataXMLFile = $extensionDir . '/xml/CustomGroupData.xml'; $import = new CRM_Utils_Migrate_Import(); $import->run($customDataXMLFile); //Create Contact Subtype $params = array('parent_id' => 3, 'is_active' => 1, 'is_reserved' => 0); foreach (array(CRM_Pcpteams_Constant::C_CONTACT_SUB_TYPE_TEAM, CRM_Pcpteams_Constant::C_CONTACTTYPE_IN_MEM, CRM_Pcpteams_Constant::C_CONTACTTYPE_IN_CELEB, CRM_Pcpteams_Constant::C_CONTACTTYPE_BRANCH, CRM_Pcpteams_Constant::C_CONTACTTYPE_PARTNER) as $subTypes) { if (!CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $subTypes, 'id', 'name')) { $params['name'] = $subTypes; $params['label'] = str_replace('_', ' ', $subTypes); CRM_Contact_BAO_ContactType::add($params); } } //set foreignkey $sql = "ALTER TABLE `civicrm_value_pcp_custom_set`\n MODIFY `team_pcp_id` int(10) unsigned DEFAULT NULL,\n ADD CONSTRAINT `FK_civicrm_value_pcp_custom_set_team_pcp_id` FOREIGN KEY (`team_pcp_id`) REFERENCES `civicrm_pcp` (`id`) ON DELETE SET NULL"; CRM_Core_DAO::executeQuery($sql); //set foreignkey for pcp_a_b and pcp_b_a on delete make null $alterSql = "ALTER TABLE `civicrm_value_pcp_relationship_set`\n MODIFY `pcp_a_b` int(10) unsigned DEFAULT NULL, MODIFY `pcp_b_a` int(10) unsigned DEFAULT NULL,\n ADD CONSTRAINT `FK_civicrm_value_pcp_relationship_set_pcp_a_b` FOREIGN KEY (`pcp_a_b`) REFERENCES `civicrm_pcp` (`id`) ON DELETE SET NULL,\n ADD CONSTRAINT `FK_civicrm_value_pcp_relationship_set_pcp_b_a` FOREIGN KEY (`pcp_b_a`) REFERENCES `civicrm_pcp` (`id`) ON DELETE SET NULL\n "; CRM_Core_DAO::executeQuery($alterSql); //invite team $messageHtmlSampleTeamInviteFile = $extensionDir . '/message_templates/msg_tpl_invite_members_to_team.tpl'; $messageHtml = file_get_contents($messageHtmlSampleTeamInviteFile); $message_params['invite_team'] = array('sequential' => 1, 'version' => 3, 'msg_title' => CRM_Pcpteams_Constant::C_MSG_TPL_INVITE_TEAM, 'msg_subject' => (string) '{$inviteeFirstName} you have been invited to join {$teamName} and support Leukaemia and Lymphoma Research', 'is_default' => 1, 'msg_html' => $messageHtml); //join team $messageHtmlSampleTeamInviteFile = $extensionDir . '/message_templates/msg_tpl_join_request_to_team.tpl'; $messageHtml = file_get_contents($messageHtmlSampleTeamInviteFile); $message_params['join_team'] = array('sequential' => 1, 'version' => 3, 'msg_title' => CRM_Pcpteams_Constant::C_MSG_TPL_JOIN_REQUEST, 'msg_subject' => (string) '{$userFirstName} {$userlastName} has requested to join Team {$teamName} please authorise', 'is_default' => 1, 'msg_html' => $messageHtml); //leave team $messageHtmlSampleTeamInviteFile = $extensionDir . '/message_templates/msg_tpl_leave_team.tpl'; $messageHtml = file_get_contents($messageHtmlSampleTeamInviteFile); $message_params['leave_team'] = array('sequential' => 1, 'version' => 3, 'msg_title' => CRM_Pcpteams_Constant::C_MSG_TPL_LEAVE_TEAM, 'msg_subject' => (string) '{$userFirstName} {$userLastName} has decided to leave Team {$teamName}', 'is_default' => 1, 'msg_html' => $messageHtml); //decline join request $messageHtmlSampleTeamInviteFile = $extensionDir . '/message_templates/msg_tpl_decline_request_to_team.tpl'; $messageHtml = file_get_contents($messageHtmlSampleTeamInviteFile); $message_params['decline_team'] = array('sequential' => 1, 'version' => 3, 'msg_title' => CRM_Pcpteams_Constant::C_MSG_TPL_JOIN_REQ_DECLINE_TEAM, 'msg_subject' => (string) '{$userFirstName} {$userLastName} your request to join {$teamName} has been turned down', 'is_default' => 1, 'msg_html' => $messageHtml); //approve join request $messageHtmlSampleTeamInviteFile = $extensionDir . '/message_templates/msg_tpl_approve_request_to_team.tpl'; $messageHtml = file_get_contents($messageHtmlSampleTeamInviteFile); $message_params['decline_team'] = array('sequential' => 1, 'version' => 3, 'msg_title' => CRM_Pcpteams_Constant::C_MSG_TPL_JOIN_REQ_APPROVE_TEAM, 'msg_subject' => (string) '{$userFirstName} {$userLastName} your request to join {$teamName} has been approved', 'is_default' => 1, 'msg_html' => $messageHtml); $ogId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', CRM_Pcpteams_Constant::C_OG_MSG_TPL_WORKFLOW, 'id', 'name'); foreach ($message_params as $key => $message_param) { $opValue = civicrm_api3('OptionValue', 'getsingle', array('version' => 3, 'option_group_id' => $ogId, 'name' => $message_param['msg_title'])); if ($opValue['id']) { $message_param['workflow_id'] = $opValue['id']; } $result = civicrm_api3('MessageTemplate', 'create', $message_param); } return _pcpteams_civix_civicrm_install(); }
/** * Returns a user friendly text explaining the condition params * e.g. 'Older than 65' * * @return string * @access public */ public function userFriendlyConditionParams() { $params = $this->getActionParameters(); $label = ts('Set contact subtype to: '); $subTypeLabels = array(); $subTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(); foreach ($params['sub_type'] as $sub_type) { $subTypeLabels[] = $subTypes[$sub_type]['parent_label'] . ' - ' . $subTypes[$sub_type]['label']; } $label .= implode(', ', $subTypeLabels); return $label; }
/** * Function to actually build the form * * @return void * @access public */ public function buildQuickForm() { require_once "CRM/Core/BAO/UFGroup.php"; require_once "CRM/Contact/BAO/ContactType.php"; $types = array_merge(array('Contact', 'Individual', 'Contribution', 'Membership'), CRM_Contact_BAO_ContactType::subTypes('Individual')); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); if (empty($profiles)) { $this->assign('noProfile', true); } $this->add('select', 'custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), array('' => ts('- select -')) + $profiles); $this->add('select', 'custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), array('' => ts('- select -')) + $profiles); $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this->_id); parent::buildQuickForm(); }
function buildForm(&$form) { $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 categories $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); // text for sort_name $form->add('text', 'sort_name', ts('Name')); $form->assign('elements', array('sort_name', 'contact_type', 'group', 'tag')); }
function browse() { $basicType = CRM_Contact_BAO_ContactType::contactTypeInfo(true); $subType = CRM_Contact_BAO_ContactType::subTypeInfo(null, true); $rows = array_merge($basicType, $subType); foreach ($rows as $key => $value) { $mask = null; if (CRM_Utils_Array::value('is_reserved', $value)) { $mask -= CRM_Core_Action::DELETE + 1; } $rows[$key]['action'] = CRM_Core_Action::formLink(self::links(), $mask, array('id' => $value['id'])); } $this->assign('rows', $rows); }
public static function initTasks() { if (!self::$_tasks) { self::$_tasks = array(self::GROUP_CONTACTS => array('title' => ts('Add Contacts to Group'), 'class' => 'CRM_Contact_Form_Task_AddToGroup'), self::REMOVE_CONTACTS => array('title' => ts('Remove Contacts from Group'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup'), self::TAG_CONTACTS => array('title' => ts('Tag Contacts (assign tags)'), 'class' => 'CRM_Contact_Form_Task_AddToTag'), self::REMOVE_TAGS => array('title' => ts('Untag Contacts (remove tags)'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag'), self::EXPORT_CONTACTS => array('title' => ts('Export Contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), self::EMAIL_CONTACTS => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => TRUE), self::DELETE_CONTACTS => array('title' => ts('Delete Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::RECORD_CONTACTS => array('title' => ts('Record Activity for Contacts'), 'class' => 'CRM_Activity_Form_Activity'), self::SAVE_SEARCH => array('title' => ts('New Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => TRUE), self::SAVE_SEARCH_UPDATE => array('title' => ts('Update Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => TRUE), self::PRINT_CONTACTS => array('title' => ts('Print Selected Rows'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => FALSE), self::LABEL_CONTACTS => array('title' => ts('Mailing Labels'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => TRUE), self::BATCH_UPDATE => array('title' => ts('Batch Update via Profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => TRUE), self::PRINT_FOR_CONTACTS => array('title' => ts('Print PDF Letter for Contacts'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => TRUE), self::EMAIL_UNHOLD => array('title' => ts('Unhold Emails'), 'class' => 'CRM_Contact_Form_Task_Unhold'), self::COMMUNICATION_PREFS => array('title' => ts('Alter Contact Communication Preferences'), 'class' => 'CRM_Contact_Form_Task_AlterPreferences'), self::RESTORE => array('title' => ts('Restore Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::DELETE_PERMANENTLY => array('title' => ts('Delete Permanently'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE)); //CRM-16329, if SMS provider is configured show sms action. $providersCount = CRM_SMS_BAO_Provider::activeProviderCount(); if ($providersCount) { self::$_tasks[self::SMS_CONTACTS] = array('title' => ts('Send SMS to Contacts'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => TRUE); } if (CRM_Contact_BAO_ContactType::isActive('Household')) { $label = CRM_Contact_BAO_ContactType::getLabel('Household'); self::$_tasks[self::HOUSEHOLD_CONTACTS] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold'); } if (CRM_Contact_BAO_ContactType::isActive('Organization')) { $label = CRM_Contact_BAO_ContactType::getLabel('Organization'); self::$_tasks[self::ORGANIZATION_CONTACTS] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization'); } if (CRM_Core_Permission::check('merge duplicate contacts')) { self::$_tasks[self::MERGE_CONTACTS] = array('title' => ts('Merge Contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => TRUE); } //CRM-4418, check for delete if (!CRM_Core_Permission::check('delete contacts')) { unset(self::$_tasks[self::DELETE_CONTACTS]); } //show map action only if map provider and geoprovider are set (Google doesn't need geoprovider) // should fix this to be more flexible as providers are added ?? $config = CRM_Core_Config::singleton(); if ($config->mapProvider && ($config->mapProvider == 'Google' || ($config->mapProvider == 'OpenStreetMaps' || $config->geoProvider == 'Google'))) { self::$_tasks[self::MAP_CONTACTS] = array('title' => ts('Map Contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => FALSE); } if (CRM_Core_Permission::access('CiviEvent')) { self::$_tasks[self::ADD_EVENT] = array('title' => ts('Add Contacts to Event'), 'class' => 'CRM_Event_Form_Participant'); } if (defined('CIVICRM_CIVIMAIL_UI_LEGACY')) { if (CRM_Core_Permission::access('CiviMail')) { self::$_tasks[self::CREATE_MAILING] = 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); } elseif (CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) { self::$_tasks[self::CREATE_MAILING] = array('title' => ts('Create a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test'), 'result' => FALSE); } } else { if (CRM_Core_Permission::access('CiviMail') || CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) { self::$_tasks[self::CREATE_MAILING] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => 'CRM_Mailing_Form_Task_AdhocMailing', 'result' => FALSE); } } self::$_tasks += CRM_Core_Component::taskList(); CRM_Utils_Hook::searchTasks('contact', self::$_tasks); asort(self::$_tasks); } }
static function relatedContactInfo($contactId) { $return = array(); if (empty($contactId)) { return $return; } $phone = CRM_Core_BAO_Phone::allPhones($contactId, TRUE, NULL, array('is_primary' => 1)); $contactSubType = CRM_Contact_BAO_Contact::getContactSubType($contactId); $contactType = CRM_Contact_BAO_ContactType::getLabel($contactSubType[0]); $gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'PCP_Supporter_Profile', 'id', 'name'); $updateURL = CRM_Utils_System::url('civicrm/profile/edit', "reset=1&gid={$gid}&cid={$contactId}"); // $updateURL =CRM_Utils_System::url('civicrm/pcp/support', "action=browse&component=event&id={$params['pcpId']}"); $return = array('name' => CRM_Contact_BAO_Contact::displayName($contactId), 'type' => $contactType, 'email' => CRM_Contact_BAO_Contact::getPrimaryEmail($contactId), 'phone' => !empty($phone) && isset($phone[1]['phone']) ? $phone[1]['phone'] : NULL, 'action' => "<a href={$updateURL}>Update Contact Information</a>"); return $return; }
public function setUp() { parent::setUp(); $params = array('label' => 'indiv_student', 'name' => 'indiv_student', 'parent_id' => 1, 'is_active' => 1); $result = CRM_Contact_BAO_ContactType::add($params); $this->student = $params['name']; $params = array('label' => 'indiv_parent', 'name' => 'indiv_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']; $params = array('label' => 'org_team', 'name' => 'org_team', 'parent_id' => 3, 'is_active' => 1); $result = CRM_Contact_BAO_ContactType::add($params); $this->team = $params['name']; }
/** * Given a contact type, get the contact image. * * @param string $contactType * Contact type. * @param bool $urlOnly * If we need to return only image url. * @param int $contactId * Contact id. * @param bool $addProfileOverlay * If profile overlay class should be added. * * @return string */ public static function getImage($contactType, $urlOnly = FALSE, $contactId = NULL, $addProfileOverlay = TRUE) { static $imageInfo = array(); $contactType = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($contactType, CRM_Core_DAO::VALUE_SEPARATOR)); $contactType = $contactType[0]; if (!array_key_exists($contactType, $imageInfo)) { $imageInfo[$contactType] = array(); $typeInfo = array(); $params = array('name' => $contactType); CRM_Contact_BAO_ContactType::retrieve($params, $typeInfo); if (!empty($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}')\" 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 = CRM_Utils_Array::value('name', $typeInfo); } // do not add title since it hides contact name if ($addProfileOverlay) { $imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$type}-icon\"></div>"; } else { $imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$type}-icon\" title=\"{$contactType}\"></div>"; } $imageInfo[$contactType]['url'] = NULL; } } if ($addProfileOverlay) { static $summaryOverlayProfileId = NULL; if (!$summaryOverlayProfileId) { $summaryOverlayProfileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'summary_overlay', 'id', 'name'); } $profileURL = CRM_Utils_System::url('civicrm/profile/view', "reset=1&gid={$summaryOverlayProfileId}&id={$contactId}&snippet=4"); $imageInfo[$contactType]['summary-link'] = '<a href="' . $profileURL . '" class="crm-summary-link">' . $imageInfo[$contactType]['image'] . '</a>'; } else { $imageInfo[$contactType]['summary-link'] = $imageInfo[$contactType]['image']; } return $urlOnly ? $imageInfo[$contactType]['url'] : $imageInfo[$contactType]['summary-link']; }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { // text for sort_name or email criteria $this->add('text', 'sort_name', ts('Name or Email')); require_once 'CRM/Core/BAO/Preferences.php'; $searchOptions = CRM_Core_BAO_Preferences::valueOptions('advanced_search_options'); if (CRM_Utils_Array::value('contactType', $searchOptions)) { require_once 'CRM/Contact/BAO/ContactType.php'; $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); $this->add('select', 'contact_type', ts('is...'), $contactTypes); } if (CRM_Utils_Array::value('groups', $searchOptions)) { $config = CRM_Core_Config::singleton(); if ($config->groupTree) { $this->add('hidden', 'group', null, array('id' => 'group')); $group = CRM_Utils_Array::value('group', $this->_formValues); $selectedGroups = explode(',', $group); if (is_array($selectedGroups)) { $groupNames = null; $groupIds = array(); foreach ($selectedGroups as $groupId) { if ($groupNames) { $groupNames .= '<br/>'; } $groupNames .= $this->_group[$groupId]; } $groupIds[] = $groupId; } $this->assign('groupIds', implode(',', $groupIds)); $this->assign('groupNames', $groupNames); } else { // add select for groups $group = array('' => ts('- any group -')) + $this->_group; $this->_groupElement =& $this->addElement('select', 'group', ts('in'), $group); } } if (CRM_Utils_Array::value('tags', $searchOptions)) { // tag criteria if (!empty($this->_tag)) { $tag = array('' => ts('- any tag -')) + $this->_tag; $this->_tagElement =& $this->addElement('select', 'tag', ts('with'), $tag); } } parent::buildQuickForm(); }