コード例 #1
0
ファイル: Basic.php プロジェクト: prashantgajare/civicrm-core
 /**
  * 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();
 }
コード例 #2
0
 /**
  * This function sets the default values for the form.
  * default values are retrieved from the database
  *
  * @access public
  *
  * @return None
  */
 function setDefaultValues()
 {
     if (!$this->_defaults) {
         $this->_defaults = array();
         $formArray = array('Component', 'Localization');
         $formMode = FALSE;
         if (in_array($this->_name, $formArray)) {
             $formMode = TRUE;
         }
         CRM_Core_BAO_ConfigSetting::retrieve($this->_defaults);
         CRM_Core_Config_Defaults::setValues($this->_defaults, $formMode);
         $list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, TRUE, NULL, 'name'));
         $cRlist = array_flip(CRM_Core_OptionGroup::values('contact_reference_options', FALSE, FALSE, TRUE, NULL, 'name'));
         $listEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
         $cRlistEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
         $autoSearchFields = array();
         if (!empty($list) && !empty($listEnabled)) {
             $autoSearchFields = array_combine($list, $listEnabled);
         }
         $cRSearchFields = array();
         if (!empty($cRlist) && !empty($cRlistEnabled)) {
             $cRSearchFields = array_combine($cRlist, $cRlistEnabled);
         }
         //Set defaults for autocomplete and contact reference options
         $this->_defaults['autocompleteContactSearch'] = array('1' => 1) + $autoSearchFields;
         $this->_defaults['autocompleteContactReference'] = array('1' => 1) + $cRSearchFields;
         $this->_defaults['enableSSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL', NULL, 0);
         $this->_defaults['verifySSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL', NULL, 1);
         $sql = "\nSELECT time_format\nFROM   civicrm_preferences_date\nWHERE  time_format IS NOT NULL\nAND    time_format <> ''\nLIMIT  1\n";
         $this->_defaults['timeInputFormat'] = CRM_Core_DAO::singleValueQuery($sql);
     }
     return $this->_defaults;
 }
コード例 #3
0
ファイル: Basic.php プロジェクト: vincent1892/contact_report
 /**
  * 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();
 }
コード例 #4
0
 /**
  * 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, '&nbsp;&nbsp;', 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();
 }
コード例 #5
0
 /**
  * This function provides the HTML form elements that are specific
  * to the Individual Contact Type
  *
  * @param CRM_Core_Form $form form object
  * @param int $inlineEditMode ( 1 for contact summary
  * top bar form and 2 for display name edit )
  *
  * @access public
  * @return void
  */
 public static function buildQuickForm(&$form, $inlineEditMode = NULL)
 {
     $form->applyFilter('__ALL__', 'trim');
     if (!$inlineEditMode || $inlineEditMode == 1) {
         $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
         //prefix
         $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
         if (isset($nameFields['Prefix']) && !empty($prefix)) {
             $form->addSelect('prefix_id', array('class' => 'four', 'placeholder' => ' '));
         }
         $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
         if (isset($nameFields['Formal Title'])) {
             $form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']);
         }
         // first_name
         if (isset($nameFields['First Name'])) {
             $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
         }
         //middle_name
         if (isset($nameFields['Middle Name'])) {
             $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
         }
         // last_name
         if (isset($nameFields['Last Name'])) {
             $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
         }
         // suffix
         $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
         if (isset($nameFields['Suffix']) && $suffix) {
             $form->addSelect('suffix_id', array('class' => 'four', 'placeholder' => ' '));
         }
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addElement('text', 'nick_name', ts('Nickname'), 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"');
         //Current Employer Element
         $employerDataURL = CRM_Utils_System::url('civicrm/ajax/rest', 'className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&employee_id=' . $form->_contactId, 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'), CRM_Utils_Array::value('source', $attributes));
     }
     if (!$inlineEditMode) {
         $checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
         if ($checkSimilar == null) {
             $checkSimilar = 0;
         }
         $form->assign('checkSimilar', $checkSimilar);
         //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', '', '');
     }
 }
コード例 #6
0
 public function testSetValueOptions()
 {
     $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
     $addressOptions['county'] = 1;
     CRM_Core_BAO_Setting::setValueOption(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', $addressOptions);
     $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
     $this->assertEquals($addressOptions['county'], 1, 'County was set but did not stick in db');
 }
コード例 #7
0
ファイル: Individual.php プロジェクト: kidaa30/yes
 /**
  * This function provides the HTML form elements that are specific
  * to the Individual Contact Type
  *
  * @param CRM_Core_Form $form
  *   Form object.
  * @param int $inlineEditMode
  *   ( 1 for contact summary.
  * top bar form and 2 for display name edit )
  *
  * @return void
  */
 public static function buildQuickForm(&$form, $inlineEditMode = NULL)
 {
     $form->applyFilter('__ALL__', 'trim');
     if (!$inlineEditMode || $inlineEditMode == 1) {
         $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
         //prefix
         $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
         if (isset($nameFields['Prefix']) && !empty($prefix)) {
             $form->addSelect('prefix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Prefix')));
         }
         $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
         if (isset($nameFields['Formal Title'])) {
             $form->addElement('text', 'formal_title', ts('Title'), $attributes['formal_title']);
         }
         // first_name
         if (isset($nameFields['First Name'])) {
             $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
         }
         //middle_name
         if (isset($nameFields['Middle Name'])) {
             $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
         }
         // last_name
         if (isset($nameFields['Last Name'])) {
             $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
         }
         // suffix
         $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
         if (isset($nameFields['Suffix']) && $suffix) {
             $form->addSelect('suffix_id', array('class' => 'eight', 'placeholder' => ' ', 'label' => ts('Suffix')));
         }
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addElement('text', 'nick_name', ts('Nickname'), 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"');
         //Current Employer Element
         $props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE);
         $form->addEntityRef('employer_id', ts('Current Employer'), $props);
         $attributes['source']['class'] = 'big';
         $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
     }
     if (!$inlineEditMode) {
         $checkSimilar = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_ajax_check_similar', NULL, TRUE);
         if ($checkSimilar == NULL) {
             $checkSimilar = 0;
         }
         $form->assign('checkSimilar', $checkSimilar);
         //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', '', '');
     }
 }
コード例 #8
0
ファイル: Activity.php プロジェクト: kcristiano/civicrm-core
 /**
  * Class constructor.
  *
  * @param int $contactId
  *   Contact whose activities we want to display.
  * @param int $permission
  *   The permission we have for this contact.
  *
  * @param bool $admin
  * @param string $context
  * @param null $activityTypeIDs
  *
  * @return \CRM_Activity_Selector_Activity
  */
 public function __construct($contactId, $permission, $admin = FALSE, $context = 'activity', $activityTypeIDs = NULL)
 {
     $this->_contactId = $contactId;
     $this->_permission = $permission;
     $this->_admin = $admin;
     $this->_context = $context;
     $this->_activityTypeIDs = $activityTypeIDs;
     // get all enabled view componentc (check if case is enabled)
     $this->_viewOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options', TRUE, NULL, TRUE);
 }
コード例 #9
0
ファイル: Batch.php プロジェクト: rajeshrhino/civicrm-core
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     // initialize the task and row fields
     parent::preProcess();
     //get the contact read only fields to display.
     $readOnlyFields = array_merge(array('sort_name' => ts('Name')), CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE));
     //get the read only field data.
     $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
     $contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_memberIds, 'CiviMember', $returnProperties);
     $this->assign('contactDetails', $contactDetails);
     $this->assign('readOnlyFields', $readOnlyFields);
 }
コード例 #10
0
ファイル: Individual.php プロジェクト: GuGuss/civicrm-core
 /**
  * This function provides the HTML form elements that are specific to the Individual Contact Type.
  *
  * @param CRM_Core_Form $form
  *   Form object.
  * @param int $inlineEditMode
  *   ( 1 for contact summary.
  * top bar form and 2 for display name edit )
  */
 public static function buildQuickForm(&$form, $inlineEditMode = NULL)
 {
     $form->applyFilter('__ALL__', 'trim');
     if (!$inlineEditMode || $inlineEditMode == 1) {
         $nameFields = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 2');
         // Use names instead of labels to build form.
         $nameFields = array_keys($nameFields);
         // Fixme: dear god why? these come out in a format that is NOT the name of the fields.
         foreach ($nameFields as &$fix) {
             $fix = str_replace(' ', '_', strtolower($fix));
             if ($fix == 'prefix' || $fix == 'suffix') {
                 // God, why god?
                 $fix .= '_id';
             }
         }
         foreach ($nameFields as $name) {
             $props = array();
             if ($name == 'prefix_id' || $name == 'suffix_id') {
                 $options = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name);
                 // Skip if we have no options available
                 if (!CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', $name)) {
                     //continue;
                 }
                 $props = array('class' => 'eight', 'placeholder' => ' ', 'label' => $name == 'prefix_id' ? ts('Prefix') : ts('Suffix'));
             }
             $form->addField($name, $props);
         }
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addField('nick_name');
         // job title
         // override the size for UI to look better
         $form->addField('job_title', array('size' => '30'));
         //Current Employer Element
         $props = array('api' => array('params' => array('contact_type' => 'Organization')), 'create' => TRUE);
         $form->addField('employer_id', $props);
         $form->addField('contact_source', array('class' => 'big'));
     }
     if (!$inlineEditMode) {
         $checkSimilar = Civi::settings()->get('contact_ajax_check_similar');
         if ($checkSimilar == NULL) {
             $checkSimilar = 0;
         }
         $form->assign('checkSimilar', $checkSimilar);
         //External Identifier Element
         $form->addField('external_identifier', array('label' => 'External ID'));
         $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
         CRM_Core_ShowHideBlocks::links($form, 'demographics', '', '');
     }
 }
コード例 #11
0
 /**
  * Function to build user dashboard
  *
  * @return void
  * @access public
  */
 function buildUserDashBoard()
 {
     //build component selectors
     $dashboardElements = array();
     $config = CRM_Core_Config::singleton();
     $this->_userOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'user_dashboard_options');
     $this->assign('contactId', $this->_contactId);
     if (!empty($this->_userOptions['PCP'])) {
         //My Personal campaign pages
         $dashboardElements[] = array('class' => 'crm-dashboard-pcp', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/Pages.tpl', 'sectionTitle' => ts('My fundraising pages'), 'weight' => 40);
         $pcpInfo = civicrm_api('pcpteams', 'getContactPcp', array('version' => 3, 'contact_id' => $this->_contactId, 'is_active' => 1));
         $this->assign('pcpInfo', isset($pcpInfo['values']) ? $pcpInfo['values'] : NULL);
         //My Teams
         $dashboardElements[] = array('class' => 'crm-dashboard-permissionedOrgs', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/Teams.tpl', 'sectionTitle' => ts('My Teams'), 'weight' => 40);
         $teamInfo = civicrm_api('pcpteams', 'getMyTeamInfo', array('version' => 3, 'contact_id' => $this->_contactId));
         $this->assign('teamInfo', isset($teamInfo['values']) ? $teamInfo['values'] : NULL);
         $is_admin = FALSE;
         foreach ($teamInfo['values'] as $team) {
             if ($team['role'] == 'Admin') {
                 $is_admin = TRUE;
                 break;
             }
         }
         //Team Members
         if ($is_admin) {
             $dashboardElements[] = array('class' => 'crm-dashboard-permissionedteammembers', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/TeamMembers.tpl', 'sectionTitle' => ts('Team Members'), 'weight' => 41);
             $teamMemberInfo = civicrm_api('pcpteams', 'getTeamMembers', array('version' => 3, 'contact_id' => $this->_contactId));
             $this->assign('teamMemberInfo', isset($teamMemberInfo['values']) ? $teamMemberInfo['values'] : NULL);
         }
         //New Team Member Requests
         if ($is_admin) {
             $dashboardElements[] = array('class' => 'crm-dashboard-permissionednewteamreq', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/TeamMemberRequests.tpl', 'sectionTitle' => ts('New Team Member Requests'), 'weight' => 43);
             $teamRequestInfo = civicrm_api('pcpteams', 'getTeamRequest', array('version' => 3, 'contact_id' => $this->_contactId));
             $this->assign('teamRequestInfo', isset($teamRequestInfo['values']) ? $teamRequestInfo['values'] : NULL);
         }
         //My Pending Team Requests
         $dashboardElements[] = array('class' => 'crm-dashboard-permissionedteamreq', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/TeamRequests.tpl', 'sectionTitle' => ts('My Pending Team Requests'), 'weight' => 42);
         $teamPendingInfo = civicrm_api('pcpteams', 'getMyPendingTeam', array('version' => 3, 'contact_id' => $this->_contactId));
         $this->assign('teamPendingInfo', isset($teamPendingInfo['values']) ? $teamPendingInfo['values'] : NULL);
         //Archived (inactive) Pages
         $dashboardElements[] = array('class' => 'crm-dashboard-permissionedinactive', 'templatePath' => 'CRM/Pcpteams/Page/Dashboard/PagesDisabled.tpl', 'sectionTitle' => ts('Archived Pages'), 'weight' => 44);
         $pcpInactiveInfo = civicrm_api('pcpteams', 'getContactPcp', array('version' => 3, 'contact_id' => $this->_contactId, 'is_active' => 0));
         $this->assign('pcpInactiveInfo', isset($pcpInactiveInfo['values']) ? $pcpInactiveInfo['values'] : NULL);
     }
     // usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc'));
     $this->assign('dashboardElements', $dashboardElements);
 }
コード例 #12
0
ファイル: Basic.php プロジェクト: nielosz/civicrm-core
 /**
  * Class constructor.
  *
  * @param array $formValues
  */
 public function __construct(&$formValues)
 {
     parent::__construct($formValues);
     $this->_columns = array('' => 'contact_type', ts('Name') => 'sort_name', ts('Address') => 'street_address', ts('City') => 'city', ts('State') => 'state_province', ts('Postal') => 'postal_code', ts('Country') => 'country', ts('Email') => 'email', ts('Phone') => 'phone');
     $params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
     $returnProperties = array();
     $returnProperties['contact_sub_type'] = 1;
     $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
     foreach ($this->_columns as $name => $field) {
         if (in_array($field, array('street_address', 'city', 'state_province', 'postal_code', 'country')) && empty($addressOptions[$field])) {
             unset($this->_columns[$name]);
             continue;
         }
         $returnProperties[$field] = 1;
     }
     $this->_query = new CRM_Contact_BAO_Query($params, $returnProperties, NULL, FALSE, FALSE, 1, FALSE, FALSE);
 }
コード例 #13
0
 /**
  * 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 (CRM_Utils_Array::value('contactType', $searchOptions)) {
         $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)) {
         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();
 }
コード例 #14
0
 /**
  * @return array
  */
 public function run()
 {
     $config =& CRM_Core_Config::singleton();
     // do check for geocoding.
     $processGeocode = FALSE;
     if (empty($config->geocodeMethod)) {
         if (CRM_Utils_String::strtobool($this->geocoding) === TRUE) {
             $this->returnMessages[] = ts('Error: You need to set a mapping provider under Administer > System Settings > Mapping and Geocoding');
             $this->returnError = 1;
             $this->returnResult();
         }
     } else {
         $processGeocode = TRUE;
         // user might want to over-ride.
         if (CRM_Utils_String::strtobool($this->geocoding) === FALSE) {
             $processGeocode = FALSE;
         }
     }
     // do check for parse street address.
     $parseAddress = FALSE;
     $parseAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'), FALSE);
     $parseStreetAddress = FALSE;
     if (!$parseAddress) {
         if (CRM_Utils_String::strtobool($this->parse) === TRUE) {
             $this->returnMessages[] = ts('Error: You need to enable Street Address Parsing under Administer > Localization > Address Settings.');
             $this->returnError = 1;
             return $this->returnResult();
         }
     } else {
         $parseStreetAddress = TRUE;
         // user might want to over-ride.
         if (CRM_Utils_String::strtobool($this->parse) === FALSE) {
             $parseStreetAddress = FALSE;
         }
     }
     // don't process.
     if (!$parseStreetAddress && !$processGeocode) {
         $this->returnMessages[] = ts('Error: Both Geocode mapping as well as Street Address Parsing are disabled. You must configure one or both options to use this script.');
         $this->returnError = 1;
         return $this->returnResult();
     }
     // do check for parse street address.
     return $this->processContacts($config, $processGeocode, $parseStreetAddress);
 }
コード例 #15
0
ファイル: Basic.php プロジェクト: nielosz/civicrm-core
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     $this->addSortNameField();
     $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, FALSE, array('class' => 'crm-select2'));
     }
     // add select for groups
     if (!empty($searchOptions['groups'])) {
         $this->addField('group', array('entity' => 'group_contact', 'label' => ts('in'), 'placeholder' => ts('- any group -')));
     }
     if (!empty($searchOptions['tags'])) {
         // tag criteria
         if (!empty($this->_tag)) {
             $this->addField('tag', array('entity' => 'entity_tag', 'label' => ts('with'), 'placeholder' => ts('- any tag -')));
         }
     }
     parent::buildQuickForm();
 }
コード例 #16
0
ファイル: Batch.php プロジェクト: kcristiano/civicrm-core
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     // Initialize the task and row fields.
     parent::preProcess();
     // Get the contact read only fields to display.
     $readOnlyFields = array_merge(array('sort_name' => ts('Added By'), 'target_sort_name' => ts('With Contact')), CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE));
     // Get the read only field data.
     $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
     $contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_activityHolderIds, 'Activity', $returnProperties);
     $readOnlyFields['assignee_display_name'] = ts('Assigned to');
     if (!empty($contactDetails)) {
         foreach ($contactDetails as $key => $value) {
             $assignee = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($key);
             foreach ($assignee as $keys => $values) {
                 $assigneeContact[] = CRM_Contact_BAO_Contact::displayname($values);
             }
             $contactDetails[$key]['assignee_display_name'] = !empty($assigneeContact) ? implode(';', $assigneeContact) : NULL;
         }
     }
     $this->assign('contactDetails', $contactDetails);
     $this->assign('readOnlyFields', $readOnlyFields);
 }
コード例 #17
0
ファイル: Basic.php プロジェクト: nyimbi/civicrm-core
 /**
  * Build the form object.
  */
 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');
     if (!empty($searchOptions['contactType'])) {
         $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements();
         $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();
 }
コード例 #18
0
 /**
  * Set default values for the form.
  *
  * Default values are retrieved from the database.
  */
 public function setDefaultValues()
 {
     if (!$this->_defaults) {
         $this->_defaults = array();
         $formArray = array('Component', 'Localization');
         $formMode = FALSE;
         if (in_array($this->_name, $formArray)) {
             $formMode = TRUE;
         }
         CRM_Core_BAO_ConfigSetting::retrieve($this->_defaults);
         CRM_Core_Config_Defaults::setValues($this->_defaults, $formMode);
         $list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, TRUE, NULL, 'name'));
         $cRlist = array_flip(CRM_Core_OptionGroup::values('contact_reference_options', FALSE, FALSE, TRUE, NULL, 'name'));
         $listEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
         $cRlistEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
         $autoSearchFields = array();
         if (!empty($list) && !empty($listEnabled)) {
             $autoSearchFields = array_combine($list, $listEnabled);
         }
         $cRSearchFields = array();
         if (!empty($cRlist) && !empty($cRlistEnabled)) {
             $cRSearchFields = array_combine($cRlist, $cRlistEnabled);
         }
         //Set defaults for autocomplete and contact reference options
         $this->_defaults['autocompleteContactSearch'] = array('1' => 1) + $autoSearchFields;
         $this->_defaults['autocompleteContactReference'] = array('1' => 1) + $cRSearchFields;
         // we can handle all the ones defined in the metadata here. Others to be converted
         foreach ($this->_settings as $setting => $group) {
             $settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting));
             $this->_defaults[$setting] = civicrm_api('setting', 'getvalue', array('version' => 3, 'name' => $setting, 'group' => $group, 'default_value' => CRM_Utils_Array::value('default', $settingMetaData['values'][$setting])));
         }
         $this->_defaults['enableSSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL', NULL, 0);
         $this->_defaults['verifySSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL', NULL, 1);
     }
     return $this->_defaults;
 }
コード例 #19
0
ファイル: Contact.php プロジェクト: nganivet/civicrm-core
 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  * @param array $errors
  *   List of errors to be posted back to the form.
  * @param int $contactId
  *   Contact id if doing update.
  *
  * @return bool
  *   email/openId
  */
 public static function formRule($fields, &$errors, $contactId = NULL)
 {
     $config = CRM_Core_Config::singleton();
     // validations.
     //1. for each block only single value can be marked as is_primary = true.
     //2. location type id should be present if block data present.
     //3. check open id across db and other each block for duplicate.
     //4. at least one location should be primary.
     //5. also get primaryID from email or open id block.
     // take the location blocks.
     $blocks = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 1');
     $otherEditOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 0');
     //get address block inside.
     if (array_key_exists('Address', $otherEditOptions)) {
         $blocks['Address'] = $otherEditOptions['Address'];
     }
     $openIds = array();
     $primaryID = FALSE;
     foreach ($blocks as $name => $label) {
         $hasData = $hasPrimary = array();
         $name = strtolower($name);
         if (!empty($fields[$name]) && is_array($fields[$name])) {
             foreach ($fields[$name] as $instance => $blockValues) {
                 $dataExists = self::blockDataExists($blockValues);
                 if (!$dataExists && $name == 'address') {
                     $dataExists = CRM_Utils_Array::value('use_shared_address', $fields['address'][$instance]);
                 }
                 if ($dataExists) {
                     // skip remaining checks for website
                     if ($name == 'website') {
                         continue;
                     }
                     $hasData[] = $instance;
                     if (!empty($blockValues['is_primary'])) {
                         $hasPrimary[] = $instance;
                         if (!$primaryID && in_array($name, array('email', 'openid')) && !empty($blockValues[$name])) {
                             $primaryID = $blockValues[$name];
                         }
                     }
                     if (empty($blockValues['location_type_id'])) {
                         $errors["{$name}[{$instance}][location_type_id]"] = ts('The Location Type should be set if there is  %1 information.', array(1 => $label));
                     }
                 }
                 if ($name == 'openid' && !empty($blockValues[$name])) {
                     $oid = new CRM_Core_DAO_OpenID();
                     $oid->openid = $openIds[$instance] = CRM_Utils_Array::value($name, $blockValues);
                     $cid = isset($contactId) ? $contactId : 0;
                     if ($oid->find(TRUE) && $oid->contact_id != $cid) {
                         $errors["{$name}[{$instance}][openid]"] = ts('%1 already exist.', array(1 => $blocks['OpenID']));
                     }
                 }
             }
             if (empty($hasPrimary) && !empty($hasData)) {
                 $errors["{$name}[1][is_primary]"] = ts('One %1 should be marked as primary.', array(1 => $label));
             }
             if (count($hasPrimary) > 1) {
                 $errors["{$name}[" . array_pop($hasPrimary) . "][is_primary]"] = ts('Only one %1 can be marked as primary.', array(1 => $label));
             }
         }
     }
     //do validations for all opend ids they should be distinct.
     if (!empty($openIds) && count(array_unique($openIds)) != count($openIds)) {
         foreach ($openIds as $instance => $value) {
             if (!array_key_exists($instance, array_unique($openIds))) {
                 $errors["openid[{$instance}][openid]"] = ts('%1 already used.', array(1 => $blocks['OpenID']));
             }
         }
     }
     // street number should be digit + suffix, CRM-5450
     $parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'));
     if ($parseStreetAddress) {
         if (isset($fields['address']) && is_array($fields['address'])) {
             $invalidStreetNumbers = array();
             foreach ($fields['address'] as $cnt => $address) {
                 if ($streetNumber = CRM_Utils_Array::value('street_number', $address)) {
                     $parsedAddress = CRM_Core_BAO_Address::parseStreetAddress($address['street_number']);
                     if (empty($parsedAddress['street_number'])) {
                         $invalidStreetNumbers[] = $cnt;
                     }
                 }
             }
             if (!empty($invalidStreetNumbers)) {
                 $first = $invalidStreetNumbers[0];
                 foreach ($invalidStreetNumbers as &$num) {
                     $num = CRM_Contact_Form_Contact::ordinalNumber($num);
                 }
                 $errors["address[{$first}][street_number]"] = ts('The street number you entered for the %1 address block(s) is not in an expected format. Street numbers may include numeric digit(s) followed by other characters. You can still enter the complete street address (unparsed) by clicking "Edit Complete Street Address".', array(1 => implode(', ', $invalidStreetNumbers)));
             }
         }
     }
     return $primaryID;
 }
コード例 #20
0
 /**
  * get colunmn headers for search selector
  *
  *
  * @return array $_columnHeaders
  * @access private
  */
 private static function &_getColumnHeaders()
 {
     if (!isset(self::$_columnHeaders)) {
         $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
         self::$_columnHeaders = array('contact_type' => array('desc' => ts('Contact Type')), 'sort_name' => array('name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING));
         $defaultAddress = array('street_address' => array('name' => ts('Address')), 'city' => array('name' => ts('City'), 'sort' => 'city', 'direction' => CRM_Utils_Sort::DONTCARE), 'state_province' => array('name' => ts('State'), 'sort' => 'state_province', 'direction' => CRM_Utils_Sort::DONTCARE), 'postal_code' => array('name' => ts('Postal'), 'sort' => 'postal_code', 'direction' => CRM_Utils_Sort::DONTCARE), 'country' => array('name' => ts('Country'), 'sort' => 'country', 'direction' => CRM_Utils_Sort::DONTCARE));
         foreach ($defaultAddress as $columnName => $column) {
             if (!empty($addressOptions[$columnName])) {
                 self::$_columnHeaders[$columnName] = $column;
             }
         }
         self::$_columnHeaders['email'] = array('name' => ts('Email'), 'sort' => 'email', 'direction' => CRM_Utils_Sort::DONTCARE);
         self::$_columnHeaders['phone'] = array('name' => ts('Phone'));
     }
     return self::$_columnHeaders;
 }
コード例 #21
0
ファイル: AJAX.php プロジェクト: kcristiano/civicrm-core
 /**
  * Ajax callback for custom fields of type ContactReference
  *
  * Todo: Migrate contact reference fields to use EntityRef
  */
 public static function contactReference()
 {
     $name = CRM_Utils_Array::value('term', $_GET);
     $name = CRM_Utils_Type::escape($name, 'String');
     $cfID = CRM_Utils_Type::escape($_GET['id'], 'Positive');
     // check that this is a valid, active custom field of Contact Reference type
     $params = array('id' => $cfID);
     $returnProperties = array('filter', 'data_type', 'is_active');
     $cf = array();
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $cf, $returnProperties);
     if (!$cf['id'] || !$cf['is_active'] || $cf['data_type'] != 'ContactReference') {
         CRM_Utils_System::civiExit('error');
     }
     if (!empty($cf['filter'])) {
         $filterParams = array();
         parse_str($cf['filter'], $filterParams);
         $action = CRM_Utils_Array::value('action', $filterParams);
         if (!empty($action) && !in_array($action, array('get', 'lookup'))) {
             CRM_Utils_System::civiExit('error');
         }
         if (!empty($filterParams['group'])) {
             $filterParams['group'] = explode(',', $filterParams['group']);
         }
     }
     $list = array_keys(CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options'), '1');
     $return = array_unique(array_merge(array('sort_name'), $list));
     $limit = Civi::settings()->get('search_autocomplete_count');
     $params = array('offset' => 0, 'rowCount' => $limit, 'version' => 3);
     foreach ($return as $fld) {
         $params["return.{$fld}"] = 1;
     }
     if (!empty($action)) {
         $excludeGet = array('reset', 'key', 'className', 'fnName', 'json', 'reset', 'context', 'timestamp', 'limit', 'id', 's', 'q', 'action');
         foreach ($_GET as $param => $val) {
             if (empty($val) || in_array($param, $excludeGet) || strpos($param, 'return.') !== FALSE || strpos($param, 'api.') !== FALSE) {
                 continue;
             }
             $params[$param] = $val;
         }
     }
     if ($name) {
         $params['sort_name'] = $name;
     }
     $params['sort'] = 'sort_name';
     // tell api to skip permission chk. dgg
     $params['check_permissions'] = 0;
     // add filter variable to params
     if (!empty($filterParams)) {
         $params = array_merge($params, $filterParams);
     }
     $contact = civicrm_api('Contact', 'Get', $params);
     if (!empty($contact['is_error'])) {
         CRM_Utils_System::civiExit('error');
     }
     $contactList = array();
     foreach ($contact['values'] as $value) {
         $view = array();
         foreach ($return as $fld) {
             if (!empty($value[$fld])) {
                 $view[] = $value[$fld];
             }
         }
         $contactList[] = array('id' => $value['id'], 'text' => implode(' :: ', $view));
     }
     if (!empty($_GET['is_unit_test'])) {
         return $contactList;
     }
     CRM_Utils_JSON::output($contactList);
 }
コード例 #22
0
ファイル: Address.php プロジェクト: FundingWorks/civicrm-core
 /**
  * Build form for address input fields.
  *
  * @param CRM_Core_Form $form
  * @param int $addressBlockCount
  *   The index of the address array (if multiple addresses on a page).
  * @param bool $sharing
  *   False, if we want to skip the address sharing features.
  * @param bool $inlineEdit
  *   True when edit used in inline edit.
  */
 public static function buildQuickForm(&$form, $addressBlockCount = NULL, $sharing = TRUE, $inlineEdit = FALSE)
 {
     // passing this via the session is AWFUL. we need to fix this
     if (!$addressBlockCount) {
         $blockId = $form->get('Address_Block_Count') ? $form->get('Address_Block_Count') : 1;
     } else {
         $blockId = $addressBlockCount;
     }
     $config = CRM_Core_Config::singleton();
     $countryDefault = $config->defaultContactCountry;
     $form->applyFilter('__ALL__', 'trim');
     $js = array();
     if (!$inlineEdit) {
         $js = array('onChange' => 'checkLocation( this.id );', 'placeholder' => NULL);
     }
     //make location type required for inline edit
     $form->addField("address[{$blockId}][location_type_id]", array('entity' => 'address', 'class' => 'eight') + $js, $inlineEdit);
     if (!$inlineEdit) {
         $js = array('id' => 'Address_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
     }
     $form->addField("address[{$blockId}][is_primary]", array('entity' => 'address', 'label' => ts('Primary location for this contact'), 'text' => ts('Primary location for this contact')) + $js);
     if (!$inlineEdit) {
         $js = array('id' => 'Address_' . $blockId . '_IsBilling', 'onClick' => 'singleSelect( this.id );');
     }
     $form->addField("address[{$blockId}][is_billing]", array('entity' => 'address', 'label' => ts('Primary location for this contact'), 'text' => ts('Primary location for this contact')) + $js);
     // hidden element to store master address id
     $form->addField("address[{$blockId}][master_id]", array('entity' => 'address', 'type' => 'hidden'));
     $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
     $elements = array('address_name', 'street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'country_id', 'state_province_id', 'county_id', 'geo_code_1', 'geo_code_2', 'street_number', 'street_name', 'street_unit');
     foreach ($elements as $name) {
         //Remove id from name, to allow comparison against enabled addressOtions.
         $nameWithoutID = strpos($name, '_id') !== FALSE ? substr($name, 0, -3) : $name;
         // Skip fields which are not enabled in the address options.
         if (empty($addressOptions[$nameWithoutID])) {
             $continue = TRUE;
             //Don't skip street parsed fields when parsing is enabled.
             if (in_array($nameWithoutID, array('street_number', 'street_name', 'street_unit')) && !empty($addressOptions['street_address_parsing'])) {
                 $continue = FALSE;
             }
             if ($continue) {
                 continue;
             }
         }
         if ($name == 'address_name') {
             $name = 'name';
         }
         $params = array('entity' => 'address');
         if ($name == 'postal_code_suffix') {
             $params['label'] = ts('Suffix');
         }
         $form->addField("address[{$blockId}][{$name}]", $params);
     }
     $entityId = NULL;
     if (!empty($form->_values['address']) && !empty($form->_values['address'][$blockId])) {
         $entityId = $form->_values['address'][$blockId]['id'];
     }
     // CRM-11665 geocode override option
     $geoCode = FALSE;
     if (!empty($config->geocodeMethod)) {
         $geoCode = TRUE;
         $form->addElement('checkbox', "address[{$blockId}][manual_geo_code]", ts('Override automatic geocoding'));
     }
     $form->assign('geoCode', $geoCode);
     // Process any address custom data -
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $form, $entityId);
     if (isset($groupTree) && is_array($groupTree)) {
         // use simplified formatted groupTree
         $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $form);
         // make sure custom fields are added /w element-name in the format - 'address[$blockId][custom-X]'
         foreach ($groupTree as $id => $group) {
             foreach ($group['fields'] as $fldId => $field) {
                 $groupTree[$id]['fields'][$fldId]['element_custom_name'] = $field['element_name'];
                 $groupTree[$id]['fields'][$fldId]['element_name'] = "address[{$blockId}][{$field['element_name']}]";
             }
         }
         $defaults = array();
         CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
         // since we change element name for address custom data, we need to format the setdefault values
         $addressDefaults = array();
         foreach ($defaults as $key => $val) {
             if (empty($val)) {
                 continue;
             }
             // inorder to set correct defaults for checkbox custom data, we need to converted flat key to array
             // this works for all types custom data
             $keyValues = explode('[', str_replace(']', '', $key));
             $addressDefaults[$keyValues[0]][$keyValues[1]][$keyValues[2]] = $val;
         }
         $form->setDefaults($addressDefaults);
         // we setting the prefix to 'dnc_' below, so that we don't overwrite smarty's grouptree var.
         // And we can't set it to 'address_' because we want to set it in a slightly different format.
         CRM_Core_BAO_CustomGroup::buildQuickForm($form, $groupTree, FALSE, 'dnc_');
         // during contact editing : if no address is filled
         // required custom data must not produce 'required' form rule error
         // more handling done in formRule func
         if (!$inlineEdit) {
             CRM_Contact_Form_Edit_Address::storeRequiredCustomDataInfo($form, $groupTree);
         }
         $template = CRM_Core_Smarty::singleton();
         $tplGroupTree = $template->get_template_vars('address_groupTree');
         $tplGroupTree = empty($tplGroupTree) ? array() : $tplGroupTree;
         $form->assign('address_groupTree', $tplGroupTree + array($blockId => $groupTree));
         // unset the temp smarty var that got created
         $form->assign('dnc_groupTree', NULL);
     }
     // address custom data processing ends ..
     if ($sharing) {
         // shared address
         $form->addElement('checkbox', "address[{$blockId}][use_shared_address]", NULL, ts('Use another contact\'s address'));
         // Override the default profile links to add address form
         $profileLinks = CRM_Core_BAO_UFGroup::getCreateLinks(array('new_individual', 'new_organization', 'new_household'), 'shared_address');
         $form->addEntityRef("address[{$blockId}][master_contact_id]", ts('Share With'), array('create' => $profileLinks));
     }
 }
コード例 #23
0
 /**
  * Call preprocess.
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', $this, TRUE, NULL, $_REQUEST);
     $this->assign('blockId', $this->_locBlockNo);
     $addressSequence = CRM_Core_BAO_Address::addressSequence();
     $this->assign('addressSequence', $addressSequence);
     $this->_values = array();
     $this->_addressId = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE, NULL, $_REQUEST);
     $this->_action = CRM_Core_Action::ADD;
     if ($this->_addressId) {
         $params = array('id' => $this->_addressId);
         $address = CRM_Core_BAO_Address::getValues($params, FALSE, 'id');
         $this->_values['address'][$this->_locBlockNo] = array_pop($address);
         $this->_action = CRM_Core_Action::UPDATE;
     } else {
         $this->_addressId = 0;
     }
     $this->assign('action', $this->_action);
     $this->assign('addressId', $this->_addressId);
     // parse street address, CRM-5450
     $this->_parseStreetAddress = $this->get('parseStreetAddress');
     if (!isset($this->_parseStreetAddress)) {
         $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
         $this->_parseStreetAddress = FALSE;
         if (!empty($addressOptions['street_address']) && !empty($addressOptions['street_address_parsing'])) {
             $this->_parseStreetAddress = TRUE;
         }
         $this->set('parseStreetAddress', $this->_parseStreetAddress);
     }
     $this->assign('parseStreetAddress', $this->_parseStreetAddress);
 }
コード例 #24
0
 /**
  * build form for address input fields
  *
  * @param object  $form - CRM_Core_Form (or subclass)
  * @param int     $addressBlockCount - the index of the address array (if multiple addresses on a page)
  * @param boolean $sharing - false, if we want to skip the address sharing features
  * @param boolean $inlineEdit true when edit used in inline edit
  *
  * @return void
  *
  * @access public
  * @static
  */
 static function buildQuickForm(&$form, $addressBlockCount = NULL, $sharing = TRUE, $inlineEdit = FALSE)
 {
     // passing this via the session is AWFUL. we need to fix this
     if (!$addressBlockCount) {
         $blockId = $form->get('Address_Block_Count') ? $form->get('Address_Block_Count') : 1;
     } else {
         $blockId = $addressBlockCount;
     }
     $config = CRM_Core_Config::singleton();
     $countryDefault = $config->defaultContactCountry;
     $form->applyFilter('__ALL__', 'trim');
     $js = array();
     if (!$inlineEdit) {
         $js = array('onChange' => 'checkLocation( this.id );');
     }
     $form->addSelect("address[{$blockId}][location_type_id]", array('entity' => 'address', 'class' => 'eight') + $js);
     if (!$inlineEdit) {
         $js = array('id' => 'Address_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
     } else {
         //make location type required for inline edit
         $form->addRule("address[{$blockId}][location_type_id]", ts('%1 is a required field.', array(1 => ts('Location Type'))), 'required');
     }
     $form->addElement('checkbox', "address[{$blockId}][is_primary]", ts('Primary location for this contact'), ts('Primary location for this contact'), $js);
     if (!$inlineEdit) {
         $js = array('id' => 'Address_' . $blockId . '_IsBilling', 'onClick' => 'singleSelect( this.id );');
     }
     $form->addElement('checkbox', "address[{$blockId}][is_billing]", ts('Billing location for this contact'), ts('Billing location for this contact'), $js);
     // hidden element to store master address id
     $form->addElement('hidden', "address[{$blockId}][master_id]");
     $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
     $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
     $elements = array('address_name' => array(ts('Address Name'), $attributes['address_name'], NULL), 'street_address' => array(ts('Street Address'), $attributes['street_address'], NULL), 'supplemental_address_1' => array(ts('Supplemental Address 1'), $attributes['supplemental_address_1'], NULL), 'supplemental_address_2' => array(ts('Supplemental Address 2'), $attributes['supplemental_address_2'], NULL), 'city' => array(ts('City'), $attributes['city'], NULL), 'postal_code' => array(ts('Zip / Postal Code'), array_merge($attributes['postal_code'], array('class' => 'crm_postal_code')), NULL), 'postal_code_suffix' => array(ts('Postal Code Suffix'), array('size' => 4, 'maxlength' => 12, 'class' => 'crm_postal_code_suffix'), NULL), 'county_id' => array(ts('County'), $attributes['county_id'], NULL), 'state_province_id' => array(ts('State / Province'), $attributes['state_province_id'], NULL), 'country_id' => array(ts('Country'), $attributes['country_id'], NULL), 'geo_code_1' => array(ts('Latitude'), array('size' => 9, 'maxlength' => 11), NULL), 'geo_code_2' => array(ts('Longitude'), array('size' => 9, 'maxlength' => 11), NULL), 'street_number' => array(ts('Street Number'), $attributes['street_number'], NULL), 'street_name' => array(ts('Street Name'), $attributes['street_name'], NULL), 'street_unit' => array(ts('Apt/Unit/Suite'), $attributes['street_unit'], NULL));
     $stateCountryMap = array();
     foreach ($elements as $name => $v) {
         list($title, $attributes, $select) = $v;
         $nameWithoutID = strpos($name, '_id') !== FALSE ? substr($name, 0, -3) : $name;
         if (empty($addressOptions[$nameWithoutID])) {
             $continue = TRUE;
             if (in_array($nameWithoutID, array('street_number', 'street_name', 'street_unit')) && !empty($addressOptions['street_address_parsing'])) {
                 $continue = FALSE;
             }
             if ($continue) {
                 continue;
             }
         }
         if (!$attributes) {
             $attributes = $attributes[$name];
         }
         //build normal select if country is not present in address block
         if ($name == 'state_province_id' && !$addressOptions['country']) {
             $select = 'stateProvince';
         }
         if (!$select) {
             if ($name == 'country_id' || $name == 'state_province_id' || $name == 'county_id') {
                 if ($name == 'country_id') {
                     $stateCountryMap[$blockId]['country'] = "address_{$blockId}_{$name}";
                     $selectOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country();
                 } elseif ($name == 'state_province_id') {
                     $stateCountryMap[$blockId]['state_province'] = "address_{$blockId}_{$name}";
                     if ($countryDefault) {
                         $selectOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($countryDefault);
                     } else {
                         $selectOptions = array('' => ts('- select a country -'));
                     }
                 } elseif ($name == 'county_id') {
                     $stateCountryMap[$blockId]['county'] = "address_{$blockId}_{$name}";
                     if ($form->getSubmitValue("address[{$blockId}][state_province_id]")) {
                         $selectOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::countyForState($form->getSubmitValue("address[{$blockId}][state_province_id]"));
                     } elseif ($form->getSubmitValue("address[{$blockId}][county_id]")) {
                         $selectOptions = array('' => ts('- select -')) + CRM_Core_PseudoConstant::county();
                     } else {
                         $selectOptions = array('' => ts('- select a state -'));
                     }
                 }
                 $form->addElement('select', "address[{$blockId}][{$name}]", $title, $selectOptions);
             } else {
                 if ($name == 'address_name') {
                     $name = 'name';
                 }
                 $form->addElement('text', "address[{$blockId}][{$name}]", $title, $attributes);
             }
         } else {
             if ($name == 'state_province_id') {
                 $stateCountryMap[$blockId]['state_province'] = "address_{$blockId}_{$name}";
             }
             $form->addElement('select', "address[{$blockId}][{$name}]", $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::$select());
         }
     }
     CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap);
     $entityId = NULL;
     if (!empty($form->_values['address']) && !empty($form->_values['address'][$blockId])) {
         $entityId = $form->_values['address'][$blockId]['id'];
     }
     // CRM-11665 geocode override option
     $geoCode = FALSE;
     if (!empty($config->geocodeMethod)) {
         $geoCode = TRUE;
         $form->addElement('checkbox', "address[{$blockId}][manual_geo_code]", ts('Override automatic geocoding'));
     }
     $form->assign('geoCode', $geoCode);
     // Process any address custom data -
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $form, $entityId);
     if (isset($groupTree) && is_array($groupTree)) {
         // use simplified formatted groupTree
         $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $form);
         // make sure custom fields are added /w element-name in the format - 'address[$blockId][custom-X]'
         foreach ($groupTree as $id => $group) {
             foreach ($group['fields'] as $fldId => $field) {
                 $groupTree[$id]['fields'][$fldId]['element_custom_name'] = $field['element_name'];
                 $groupTree[$id]['fields'][$fldId]['element_name'] = "address[{$blockId}][{$field['element_name']}]";
             }
         }
         $defaults = array();
         CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
         // since we change element name for address custom data, we need to format the setdefault values
         $addressDefaults = array();
         foreach ($defaults as $key => $val) {
             if (empty($val)) {
                 continue;
             }
             // inorder to set correct defaults for checkbox custom data, we need to converted flat key to array
             // this works for all types custom data
             $keyValues = explode('[', str_replace(']', '', $key));
             $addressDefaults[$keyValues[0]][$keyValues[1]][$keyValues[2]] = $val;
         }
         $form->setDefaults($addressDefaults);
         // we setting the prefix to 'dnc_' below, so that we don't overwrite smarty's grouptree var.
         // And we can't set it to 'address_' because we want to set it in a slightly different format.
         CRM_Core_BAO_CustomGroup::buildQuickForm($form, $groupTree, FALSE, 'dnc_');
         // during contact editing : if no address is filled
         // required custom data must not produce 'required' form rule error
         // more handling done in formRule func
         if (!$inlineEdit) {
             CRM_Contact_Form_Edit_Address::storeRequiredCustomDataInfo($form, $groupTree);
         }
         $template = CRM_Core_Smarty::singleton();
         $tplGroupTree = $template->get_template_vars('address_groupTree');
         $tplGroupTree = empty($tplGroupTree) ? array() : $tplGroupTree;
         $form->assign('address_groupTree', $tplGroupTree + array($blockId => $groupTree));
         // unset the temp smarty var that got created
         $form->assign('dnc_groupTree', NULL);
     }
     // address custom data processing ends ..
     if ($sharing) {
         // shared address
         $form->addElement('checkbox', "address[{$blockId}][use_shared_address]", NULL, ts('Use another contact\'s address'));
         // get the reserved for address
         $profileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'shared_address', 'id', 'name');
         if (!$profileId) {
             CRM_Core_Error::fatal(ts('Your install is missing required "Shared Address" profile.'));
         }
         CRM_Contact_Form_NewContact::buildQuickForm($form, $blockId, array($profileId));
     }
 }
コード例 #25
0
ファイル: Utils.php プロジェクト: FundingWorks/civicrm-core
 /**
  * This function retrieve component related contact information.
  *
  * @param array $componentIds
  *   Array of component Ids.
  * @param string $componentName
  * @param array $returnProperties
  *   Array of return elements.
  *
  * @return array
  *   array of contact info.
  */
 public static function contactDetails($componentIds, $componentName, $returnProperties = array())
 {
     $contactDetails = array();
     if (empty($componentIds) || !in_array($componentName, array('CiviContribute', 'CiviMember', 'CiviEvent', 'Activity'))) {
         return $contactDetails;
     }
     if (empty($returnProperties)) {
         $autocompleteContactSearch = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
         $returnProperties = array_fill_keys(array_merge(array('sort_name'), array_keys($autocompleteContactSearch)), 1);
     }
     $compTable = NULL;
     if ($componentName == 'CiviContribute') {
         $compTable = 'civicrm_contribution';
     } elseif ($componentName == 'CiviMember') {
         $compTable = 'civicrm_membership';
     } elseif ($componentName == 'Activity') {
         $compTable = 'civicrm_activity';
         $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     } else {
         $compTable = 'civicrm_participant';
     }
     $select = $from = array();
     foreach ($returnProperties as $property => $ignore) {
         $value = in_array($property, array('city', 'street_address')) ? 'address' : $property;
         switch ($property) {
             case 'sort_name':
                 if ($componentName == 'Activity') {
                     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
                     $select[] = "contact.{$property} as {$property}";
                     $from[$value] = "\nINNER JOIN civicrm_activity_contact acs ON (acs.activity_id = {$compTable}.id AND acs.record_type_id = {$sourceID})\nINNER JOIN civicrm_contact contact ON ( contact.id = acs.contact_id )";
                 } else {
                     $select[] = "{$property} as {$property}";
                     $from[$value] = "INNER JOIN civicrm_contact contact ON ( contact.id = {$compTable}.contact_id )";
                 }
                 break;
             case 'target_sort_name':
                 $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
                 $select[] = "contact_target.sort_name as {$property}";
                 $from[$value] = "\nINNER JOIN civicrm_activity_contact act ON (act.activity_id = {$compTable}.id AND act.record_type_id = {$targetID})\nINNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_id )";
                 break;
             case 'email':
             case 'phone':
             case 'city':
             case 'street_address':
                 $select[] = "{$property} as {$property}";
                 // Grab target contact properties if this is for activity
                 if ($componentName == 'Activity') {
                     $from[$value] = "LEFT JOIN civicrm_{$value} {$value} ON ( contact_target.id = {$value}.contact_id AND {$value}.is_primary = 1 ) ";
                 } else {
                     $from[$value] = "LEFT JOIN civicrm_{$value} {$value} ON ( contact.id = {$value}.contact_id AND {$value}.is_primary = 1 ) ";
                 }
                 break;
             case 'country':
             case 'state_province':
                 $select[] = "{$property}.name as {$property}";
                 if (!in_array('address', $from)) {
                     // Grab target contact properties if this is for activity
                     if ($componentName == 'Activity') {
                         $from['address'] = 'LEFT JOIN civicrm_address address ON ( contact_target.id = address.contact_id AND address.is_primary = 1) ';
                     } else {
                         $from['address'] = 'LEFT JOIN civicrm_address address ON ( contact.id = address.contact_id AND address.is_primary = 1) ';
                     }
                 }
                 $from[$value] = " LEFT JOIN civicrm_{$value} {$value} ON ( address.{$value}_id = {$value}.id  ) ";
                 break;
         }
     }
     //finally retrieve contact details.
     if (!empty($select) && !empty($from)) {
         $fromClause = implode(' ', $from);
         $selectClause = implode(', ', $select);
         $whereClause = "{$compTable}.id IN (" . implode(',', $componentIds) . ')';
         $query = "\n  SELECT  contact.id as contactId, {$compTable}.id as componentId, {$selectClause}\n    FROM  {$compTable} as {$compTable} {$fromClause}\n   WHERE  {$whereClause}\nGroup By  componentId";
         $contact = CRM_Core_DAO::executeQuery($query);
         while ($contact->fetch()) {
             $contactDetails[$contact->componentId]['contact_id'] = $contact->contactId;
             foreach ($returnProperties as $property => $ignore) {
                 $contactDetails[$contact->componentId][$property] = $contact->{$property};
             }
         }
         $contact->free();
     }
     return $contactDetails;
 }
コード例 #26
0
ファイル: Address.php プロジェクト: nganivet/civicrm-core
 /**
  * Validate the address fields based on the address options enabled.
  * in the Address Settings
  *
  * @param array $fields
  *   An array of importable/exportable contact fields.
  *
  * @return array
  *   an array of contact fields and only the enabled address options
  */
 public static function validateAddressOptions($fields)
 {
     static $addressOptions = NULL;
     if (!$addressOptions) {
         $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
     }
     if (is_array($fields) && !empty($fields)) {
         foreach ($addressOptions as $key => $value) {
             if (!$value && isset($fields[$key])) {
                 unset($fields[$key]);
             }
         }
     }
     return $fields;
 }
コード例 #27
0
ファイル: Advanced.php プロジェクト: hguru/224Civi
 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     $this->set('context', 'advanced');
     $this->_searchPane = CRM_Utils_Array::value('searchPane', $_GET);
     $this->_searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options');
     if (!$this->_searchPane || $this->_searchPane == 'basic') {
         CRM_Contact_Form_Search_Criteria::basic($this);
     }
     $allPanes = array();
     $paneNames = array(ts('Address Fields') => 'location', ts('Custom Fields') => 'custom', ts('Activities') => 'activity', ts('Relationships') => 'relationship', ts('Demographics') => 'demographics', ts('Notes') => 'notes', ts('Change Log') => 'changeLog');
     //check if there are any custom data searchable fields
     $groupDetails = array();
     $extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), CRM_Contact_BAO_ContactType::subTypes());
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     // if no searchable fields unset panel
     if (empty($groupDetails)) {
         unset($paneNames[ts('Custom Fields')]);
     }
     foreach ($paneNames as $name => $type) {
         if (!$this->_searchOptions[$type]) {
             unset($paneNames[$name]);
         }
     }
     $components = CRM_Core_Component::getEnabledComponents();
     $componentPanes = array();
     foreach ($components as $name => $component) {
         if (in_array($name, array_keys($this->_searchOptions)) && $this->_searchOptions[$name] && CRM_Core_Permission::access($component->name)) {
             $componentPanes[$name] = $component->registerAdvancedSearchPane();
             $componentPanes[$name]['name'] = $name;
         }
     }
     usort($componentPanes, array('CRM_Utils_Sort', 'cmpFunc'));
     foreach ($componentPanes as $name => $pane) {
         // FIXME: we should change the use of $name here to keyword
         $paneNames[$pane['title']] = $pane['name'];
     }
     $hookPanes = array();
     CRM_Contact_BAO_Query_Hook::singleton()->registerAdvancedSearchPane($hookPanes);
     $paneNames = array_merge($paneNames, $hookPanes);
     $this->_paneTemplatePath = array();
     foreach ($paneNames as $name => $type) {
         if (!array_key_exists($type, $this->_searchOptions) && !in_array($type, $hookPanes)) {
             continue;
         }
         $allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/contact/search/advanced', "snippet=1&searchPane={$type}&qfKey={$this->controller->_key}"), 'open' => 'false', 'id' => $type);
         // see if we need to include this paneName in the current form
         if ($this->_searchPane == $type || CRM_Utils_Array::value("hidden_{$type}", $_POST) || CRM_Utils_Array::value("hidden_{$type}", $this->_formValues)) {
             $allPanes[$name]['open'] = 'true';
             if (CRM_Utils_Array::value($type, $components)) {
                 $c = $components[$type];
                 $this->add('hidden', "hidden_{$type}", 1);
                 $c->buildAdvancedSearchPaneForm($this);
                 $this->_paneTemplatePath[$type] = $c->getAdvancedSearchPaneTemplatePath();
             } else {
                 if (in_array($type, $hookPanes)) {
                     CRM_Contact_BAO_Query_Hook::singleton()->buildAdvancedSearchPaneForm($this, $type);
                     CRM_Contact_BAO_Query_Hook::singleton()->setAdvancedSearchPaneTemplatePath($this->_paneTemplatePath, $type);
                 } else {
                     CRM_Contact_Form_Search_Criteria::$type($this);
                     $template = ucfirst($type);
                     $this->_paneTemplatePath[$type] = "CRM/Contact/Form/Search/Criteria/{$template}.tpl";
                 }
             }
         }
     }
     $this->assign('allPanes', $allPanes);
     if (!$this->_searchPane) {
         parent::buildQuickForm();
     } else {
         $this->assign('suppressForm', TRUE);
     }
 }
コード例 #28
0
ファイル: Inline.php プロジェクト: kidaa30/yes
 /**
  * Render change log footer markup for a contact and supply count.
  *
  * Needed for refreshing the contact summary screen
  *
  * @param int $cid
  * @param bool $includeCount
  * @return array
  */
 public static function renderFooter($cid, $includeCount = TRUE)
 {
     // Load change log footer from template.
     $smarty = CRM_Core_Smarty::singleton();
     $smarty->assign('contactId', $cid);
     $smarty->assign('external_identifier', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'external_identifier'));
     $smarty->assign('lastModified', CRM_Core_BAO_Log::lastModified($cid, 'civicrm_contact'));
     $viewOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options', TRUE);
     $smarty->assign('changeLog', $viewOptions['log']);
     $ret = array('markup' => $smarty->fetch('CRM/common/contactFooter.tpl'));
     if ($includeCount) {
         $ret['count'] = CRM_Contact_BAO_Contact::getCountComponent('log', $cid);
     }
     return array('changeLog' => $ret);
 }
コード例 #29
0
ファイル: Export.php プロジェクト: jenlampton/civicrm-core
 /**
  * Exclude contacts who are deceased, have "Do not mail" privacy setting,
  * or have no street address
  * @param $exportTempTable
  * @param $headerRows
  * @param $sqlColumns
  * @param $exportParams
  */
 public static function postalMailingFormat($exportTempTable, &$headerRows, &$sqlColumns, $exportParams)
 {
     $whereClause = array();
     if (array_key_exists('is_deceased', $sqlColumns)) {
         $whereClause[] = 'is_deceased = 1';
     }
     if (array_key_exists('do_not_mail', $sqlColumns)) {
         $whereClause[] = 'do_not_mail = 1';
     }
     if (array_key_exists('street_address', $sqlColumns)) {
         $addressWhereClause = " ( (street_address IS NULL) OR (street_address = '') ) ";
         // check for supplemental_address_1
         if (array_key_exists('supplemental_address_1', $sqlColumns)) {
             $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
             if (!empty($addressOptions['supplemental_address_1'])) {
                 $addressWhereClause .= " AND ( (supplemental_address_1 IS NULL) OR (supplemental_address_1 = '') ) ";
                 // enclose it again, since we are doing an AND in between a set of ORs
                 $addressWhereClause = "( {$addressWhereClause} )";
             }
         }
         $whereClause[] = $addressWhereClause;
     }
     if (!empty($whereClause)) {
         $whereClause = implode(' OR ', $whereClause);
         $query = "\nDELETE\nFROM   {$exportTempTable}\nWHERE  {$whereClause}";
         CRM_Core_DAO::singleValueQuery($query);
     }
     // unset temporary columns that were added for postal mailing format
     if (!empty($exportParams['postal_mailing_export']['temp_columns'])) {
         $unsetKeys = array_keys($sqlColumns);
         foreach ($unsetKeys as $headerKey => $sqlColKey) {
             if (array_key_exists($sqlColKey, $exportParams['postal_mailing_export']['temp_columns'])) {
                 unset($sqlColumns[$sqlColKey], $headerRows[$headerKey]);
             }
         }
     }
 }
コード例 #30
0
ファイル: Batch.php プロジェクト: FundingWorks/civicrm-core
 /**
  * Parse street address.
  *
  * @param array $contactValues
  *   Contact values.
  * @param CRM_Core_Form $form
  *   Form object.
  */
 public static function parseStreetAddress(&$contactValues, &$form)
 {
     if (!is_array($contactValues) || !is_array($form->_fields)) {
         return;
     }
     static $parseAddress;
     $addressFldKey = 'street_address';
     if (!isset($parseAddress)) {
         $parseAddress = FALSE;
         foreach ($form->_fields as $key => $fld) {
             if (strpos($key, $addressFldKey) !== FALSE) {
                 $parseAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'), FALSE);
                 break;
             }
         }
     }
     if (!$parseAddress) {
         return;
     }
     $allParseValues = array();
     foreach ($contactValues as $key => $value) {
         if (strpos($key, $addressFldKey) !== FALSE) {
             $locTypeId = substr($key, strlen($addressFldKey) + 1);
             // parse address field.
             $parsedFields = CRM_Core_BAO_Address::parseStreetAddress($value);
             //street address consider to be parsed properly,
             //If we get street_name and street_number.
             if (empty($parsedFields['street_name']) || empty($parsedFields['street_number'])) {
                 $parsedFields = array_fill_keys(array_keys($parsedFields), '');
             }
             //merge parse values.
             foreach ($parsedFields as $fldKey => $parseVal) {
                 if ($locTypeId) {
                     $fldKey .= "-{$locTypeId}";
                 }
                 $allParseValues[$fldKey] = $parseVal;
             }
         }
     }
     //finally merge all parse values
     if (!empty($allParseValues)) {
         $contactValues += $allParseValues;
     }
 }