/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_action == CRM_Core_Action::DELETE) { if ($this->_id && ($tag = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'name', 'parent_id'))) { CRM_Core_Session::setStatus(ts("This tag cannot be deleted! You must Delete all its child tags ('%1', etc) prior to deleting this tag.", array(1 => $tag))); $url = CRM_Utils_System::url('civicrm/admin/tag', "reset=1"); CRM_Utils_System::redirect($url); return true; } else { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); } } else { $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'name'), true); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_Tag', $this->_id)); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'description')); //@lobo haven't a clue why the checkbox isn't displayed (it should be checked by default $this->add('checkbox', 'is_selectable', ts("If it's a tag or a category")); $allTag = array('' => '- ' . ts('select') . ' -') + CRM_Core_PseudoConstant::tag(); if ($this->_id) { unset($allTag[$this->_id]); } $this->add('select', 'parent_id', ts('Parent Tag'), $allTag); parent::buildQuickForm(); } }
function __construct() { $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-fields', 'fields' => array('display_name' => array('title' => ts('Contact Name'), 'no_repeat' => true, 'default' => true), 'id' => array('no_display' => true, 'required' => true)), 'group_bys' => array('id' => array('title' => ts('Contact'), 'default' => true))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => true)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'no_repeat' => true)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', 'fields' => array('country_id' => array('title' => ts('Country')), 'state_province_id' => array('title' => ts('State/Province'))), 'group_bys' => array('country_id' => array('title' => ts('Country')), 'state_province_id' => array('title' => ts('State/Province')))), 'civicrm_contribution_type' => array('dao' => 'CRM_Contribute_DAO_ContributionType', 'fields' => array('contribution_type' => null), 'grouping' => 'contri-fields', 'group_bys' => array('contribution_type' => array('name' => 'id'))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contribution_source' => null, 'total_amount1' => array('name' => 'total_amount', 'alias' => 'contribution1', 'title' => ts('Range One Stat'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => true, 'required' => true, 'statistics' => array('sum' => ts('Total Amount'), 'count' => ts('Count')), 'clause' => ' contribution1_total_amount_count, contribution1_total_amount_sum'), 'total_amount2' => array('name' => 'total_amount', 'alias' => 'contribution2', 'title' => ts('Range Two Stat'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => true, 'required' => true, 'statistics' => array('sum' => ts('Total Amount'), 'count' => ts('Count')), 'clause' => ' contribution2_total_amount_count, contribution2_total_amount_sum')), 'grouping' => 'contri-fields', 'filters' => array('receive_date1' => array('title' => ts('Date Range One'), 'default' => 'previous.year', 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, 'name' => 'receive_date', 'alias' => 'contribution1'), 'receive_date2' => array('title' => ts('Date Range Two'), 'default' => 'this.year', 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, 'name' => 'receive_date', 'alias' => 'contribution2'), 'total_amount1' => array('title' => ts('Range One Amount'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, 'name' => 'receive_date', 'dbAlias' => 'contribution1_total_amount_sum'), 'total_amount2' => array('title' => ts('Range Two Amount'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, 'name' => 'receive_date', 'dbAlias' => 'contribution2_total_amount_sum'), 'contribution_status_id' => array('operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array('1'))), 'group_bys' => array('contribution_source' => null)), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', '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()))), 'civicrm_tag' => array('dao' => 'CRM_Core_DAO_Tag', 'filters' => array('tid' => array('name' => 'tag_id', 'title' => ts('Tag'), 'tag' => true, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::tag())))); parent::__construct(); }
function __construct() { $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Contact Name'), 'required' => true, 'no_repeat' => true), 'gender_id' => array('title' => ts('Gender'), 'default' => true), 'birth_date' => array('title' => ts('Birthdate'), 'default' => false), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name' => array('title' => ts('Contact Name')), 'contact_type' => array('title' => ts('Contact Type'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('-select-'), 'Individual' => ts('Individual'), 'Organization' => ts('Organization'), 'Household' => ts('Household')), 'default' => 'Individual'), 'id' => array('title' => ts('Contact ID'), 'no_display' => true)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => true)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', 'fields' => array('street_address' => array('default' => false), 'city' => array('default' => true), 'postal_code' => null, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'), 'default' => false))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => null), 'grouping' => 'contact-fields'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('id' => array('title' => ts('Activity ID'), 'no_display' => true, 'required' => true))), 'civicrm_case' => array('dao' => 'CRM_Case_DAO_Case', 'fields' => array('id' => array('title' => ts('Case ID'), 'required' => true), 'start_date' => array('title' => ts('Case Start'), 'required' => true), 'end_date' => array('title' => ts('Case End'), 'required' => true)), 'filters' => array('case_id_filter' => array('name' => 'id', 'title' => ts('Cases?'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array(1 => ts('Exclude non-case'), 2 => ts('Exclude cases'), 3 => ts('Include Both')), 'default' => 3), 'start_date' => array('title' => ts('Case Start'), 'operatorType' => CRM_Report_Form::OP_DATE), 'end_date' => array('title' => ts('Case End'), 'operatorType' => CRM_Report_Form::OP_DATE))), '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()))), 'civicrm_tag' => array('dao' => 'CRM_Core_DAO_Tag', 'filters' => array('tid' => array('name' => 'tag_id', 'title' => ts('Tag'), 'tag' => true, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::tag())))); $open_case_val = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name'); $crmDAO =& CRM_Core_DAO::executeQuery("SELECT cg.table_name, cg.extends AS ext, cf.label, cf.column_name FROM civicrm_custom_group cg INNER JOIN civicrm_custom_field cf ON cg.id = cf.custom_group_id\nwhere (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_column_value='{$open_case_val}') AND cg.is_active=1 AND cf.is_active=1 ORDER BY cg.table_name"); $curTable = ''; $curExt = ''; $curFields = array(); while ($crmDAO->fetch()) { if ($curTable == '') { $curTable = $crmDAO->table_name; $curExt = $crmDAO->ext; } elseif ($curTable != $crmDAO->table_name) { $this->_columns[$curTable] = array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => $curFields, 'ext' => $curExt); $curTable = $crmDAO->table_name; $curExt = $crmDAO->ext; $curFields = array(); } $curFields[$crmDAO->column_name] = array('title' => $crmDAO->label); } if (!empty($curFields)) { $this->_columns[$curTable] = array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => $curFields, 'ext' => $curExt); } $this->_genders = CRM_Core_PseudoConstant::gender(); parent::__construct(); }
function buildForm(&$form) { $this->setTitle(ts('Include / Exclude Search')); $groups = CRM_Core_PseudoConstant::group(); $tags = CRM_Core_PseudoConstant::tag(); if (count($groups) == 0 || count($tags) == 0) { CRM_Core_Session::setStatus(ts("Atleast one Group and Tag must be present, for Custom Group / Tag search.")); $url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'); CRM_Utils_System::redirect($url); } $inG =& $form->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $outG =& $form->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $andOr = array('1' => ts('Show contacts that meet the Groups criteria AND the Tags criteria'), '0' => ts('Show contacts that meet the Groups criteria OR the Tags criteria')); $form->addRadio('andOr', ts('AND/OR'), $andOr, TRUE, '<br />', TRUE); $int =& $form->addElement('advmultiselect', 'includeTags', ts('Include Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $outt =& $form->addElement('advmultiselect', 'excludeTags', ts('Exclude Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); //add/remove buttons for groups $inG->setButtonAttributes('add', array('value' => ts('Add >>'))); $outG->setButtonAttributes('add', array('value' => ts('Add >>'))); $inG->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $outG->setButtonAttributes('remove', array('value' => ts('<< Remove'))); //add/remove buttons for tags $int->setButtonAttributes('add', array('value' => ts('Add >>'))); $outt->setButtonAttributes('add', array('value' => ts('Add >>'))); $int->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $outt->setButtonAttributes('remove', array('value' => ts('<< Remove'))); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags')); }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { // add select for tag $this->_tags = array('' => ' - select tag - ') + CRM_Core_PseudoConstant::tag(); $this->add('select', 'tag_id', ts('Select Tag'), $this->_tags, true); $this->addDefaultButtons(ts('Tag Contacts')); }
function __construct() { // UI for selecting columns to appear in the report list // array conatining the columns, group_bys and filters build and provided to Form $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Member Name'), 'no_repeat' => true, 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'grouping' => 'contact-fields'), 'civicrm_membership_type' => array('dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', 'filters' => array('tid' => array('name' => 'id', 'title' => ts('Membership Types'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType()))), 'civicrm_membership' => array('dao' => 'CRM_Member_DAO_Membership', 'grouping' => 'member-fields', 'fields' => array('membership_type_id' => array('title' => 'Membership Type', 'required' => true, 'type' => CRM_Utils_Type::T_STRING), 'membership_start_date' => array('title' => ts('Current Cycle Start Date')), 'membership_end_date' => array('title' => ts('Membership Lapse Date'), 'required' => true)), 'filters' => array('membership_end_date' => array('title' => 'Lapsed Memberships', 'operatorType' => CRM_Report_Form::OP_DATE))), 'civicrm_membership_status' => array('dao' => 'CRM_Member_DAO_MembershipStatus', 'alias' => 'mem_status', 'fields' => array('name' => array('title' => ts('Current Status'), 'required' => true)), 'grouping' => 'member-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_address' => null, 'city' => null, 'postal_code' => null, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'), 'default' => true)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => null), 'grouping' => 'contact-fields'), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', '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()))), 'civicrm_tag' => array('dao' => 'CRM_Core_DAO_Tag', 'filters' => array('tagid' => array('name' => 'tag_id', 'title' => ts('Tag'), 'tag' => true, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::tag())))); parent::__construct(); }
function buildForm(&$form) { $groups =& CRM_Core_PseudoConstant::group(); $tags =& CRM_Core_PseudoConstant::tag(); if (count($groups) == 0 || count($tags) == 0) { CRM_Core_Session::setStatus(ts("Atleast one Group and Tag must be present, for Custom Group / Tag search.")); $url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'); CRM_Utils_System::redirect($url); } $inG =& $form->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $outG =& $form->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $andOr =& $form->addElement('checkbox', 'andOr', 'Combine With (AND, Uncheck For OR)', null, array('checked' => 'checked')); $int =& $form->addElement('advmultiselect', 'includeTags', ts('Include Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $outt =& $form->addElement('advmultiselect', 'excludeTags', ts('Exclude Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); //add/remove buttons for groups $inG->setButtonAttributes('add', array('value' => ts('Add >>'))); $outG->setButtonAttributes('add', array('value' => ts('Add >>'))); $inG->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $outG->setButtonAttributes('remove', array('value' => ts('<< Remove'))); //add/remove buttons for tags $int->setButtonAttributes('add', array('value' => ts('Add >>'))); $outt->setButtonAttributes('add', array('value' => ts('Add >>'))); $int->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $outt->setButtonAttributes('remove', array('value' => ts('<< Remove'))); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags')); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { // get categories for the contact id $entityTag =& CRM_Core_BAO_EntityTag::getTag($this->_contactId); $this->assign('tagged', $entityTag); // get the list of all the categories $allTag =& CRM_Core_PseudoConstant::tag(); // need to append the array with the " checked " if contact is tagged with the tag foreach ($allTag as $tagID => $varValue) { if (in_array($tagID, $entityTag)) { $tagAttribute = array('onclick' => "return changeRowColor(\"rowidtag_{$tagID}\")", 'checked' => 'checked', 'id' => "tag_{$tagID}"); } else { $tagAttribute = array('onclick' => "return changeRowColor(\"rowidtag_{$tagID}\")", 'id' => "tag_{$tagID}"); } $tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute); } $this->addGroup($tagChk, 'tagList', null, null, true); $tags = new CRM_Core_BAO_Tag(); $tree = $tags->getTree(); $this->assign('tree', $tags->getTree()); $this->assign('tag', $allTag); if ($this->_action & CRM_Core_Action::BROWSE) { $this->freeze(); } else { $this->addButtons(array(array('type' => 'next', 'name' => ts('Update Tags'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); } }
/** * Build the form * * @access public * @return void */ function buildQuickForm() { // add select for tag $this->_tags = CRM_Core_PseudoConstant::tag(); foreach ($this->_tags as $tagID => $tagName) { $this->_tagElement =& $this->addElement('checkbox', "tag[{$tagID}]", null, $tagName); } $this->addDefaultButtons(ts('Tag Contacts')); }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { //get the data from the session $dataValues = $this->get('dataValues'); $mapper = $this->get('mapper'); $invalidRowCount = $this->get('invalidRowCount'); $conflictRowCount = $this->get('conflictRowCount'); $mismatchCount = $this->get('unMatchCount'); $columnNames = $this->get('columnNames'); //assign column names $this->assign('columnNames', $columnNames); //get the mapping name displayed if the mappingId is set $mappingId = $this->get('loadMappingId'); if ($mappingId) { $mapDAO = new CRM_Core_DAO_Mapping(); $mapDAO->id = $mappingId; $mapDAO->find(TRUE); $this->assign('loadedMapping', $mappingId); $this->assign('savedName', $mapDAO->name); } $this->assign('rowDisplayCount', 2); $groups = CRM_Core_PseudoConstant::group(); $this->set('groups', $groups); $tag = CRM_Core_PseudoConstant::tag(); if ($tag) { $this->set('tag', $tag); } if ($invalidRowCount) { $urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Import_Parser'; $this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } if ($conflictRowCount) { $urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Import_Parser'; $this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } if ($mismatchCount) { $urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Import_Parser'; $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } $properties = array('mapper', 'locations', 'phones', 'ims', 'dataValues', 'columnCount', 'totalRowCount', 'validRowCount', 'invalidRowCount', 'conflictRowCount', 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', 'related', 'relatedContactDetails', 'relatedContactLocType', 'relatedContactPhoneType', 'relatedContactImProvider', 'websites', 'relatedContactWebsiteType'); foreach ($properties as $property) { $this->assign($property, $this->get($property)); } $statusID = $this->get('statusID'); if (!$statusID) { $statusID = md5(uniqid(rand(), TRUE)); $this->set('statusID', $statusID); } $statusUrl = CRM_Utils_System::url('civicrm/ajax/status', "id={$statusID}", FALSE, NULL, FALSE); $this->assign('statusUrl', $statusUrl); $showColNames = TRUE; if ('CRM_Import_DataSource_CSV' == $this->get('dataSource') && !$this->get('skipColumnHeader')) { $showColNames = FALSE; } $this->assign('showColNames', $showColNames); }
function __construct() { $yearsInPast = 8; $yearsInFuture = 2; $date = CRM_Core_SelectValues::date('custom', null, $yearsInPast, $yearsInFuture); $count = $date['maxYear']; while ($date['minYear'] <= $count) { $optionYear[$date['minYear']] = $date['minYear']; $date['minYear']++; } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-field', 'fields' => array('display_name' => array('title' => ts('Donor Name'), 'default' => true, 'required' => true)), 'filters' => array('sort_name' => array('title' => ts('Donor Name'), 'operator' => 'like'))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'grouping' => 'contact-field', 'fields' => array('email' => array('title' => ts('Email'), 'default' => true))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-field', 'fields' => array('phone' => array('title' => ts('Phone No'), 'default' => true))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contact_id' => array('title' => ts('contactId'), 'no_display' => true, 'required' => true, 'no_repeat' => true), 'total_amount' => array('title' => ts('Total Amount'), 'no_display' => true, 'required' => true, 'no_repeat' => true), 'receive_date' => array('title' => ts('Year'), 'no_display' => true, 'required' => true, 'no_repeat' => true)), 'filters' => array('yid' => array('name' => 'receive_date', 'title' => ts('This Year'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => date('Y'), 'clause' => "contribution_civireport.contact_id NOT IN\n((SELECT distinct contri.contact_id FROM civicrm_contribution contri \n WHERE YEAR(contri.receive_date) = \$value AND contri.is_test = 0) ) AND contribution_civireport.contact_id IN ((SELECT distinct contri.contact_id FROM civicrm_contribution contri \n WHERE YEAR(contri.receive_date) = (\$value-1) AND contri.is_test = 0) ) "), 'contribution_status_id' => array('operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array('1')))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', '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()))), 'civicrm_tag' => array('dao' => 'CRM_Core_DAO_Tag', 'filters' => array('tid' => array('name' => 'tag_id', 'title' => ts('Tag'), 'tag' => true, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::tag())))); parent::__construct(); }
function buildForm(&$form) { $form->add('select', 'contact_type', ts('Find...'), CRM_Core_SelectValues::contactType()); // 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::tag(); $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')); }
/** * * @param <type> $params * @return <type> */ function civicrm_entity_tag_display(&$params) { if (!array_key_exists('contact_id', $params)) { return civicrm_create_error(ts('contact_id is a required field')); } require_once 'CRM/Core/BAO/EntityTag.php'; $values =& CRM_Core_BAO_EntityTag::getTag($params['contact_id']); $result = array(); $tags = CRM_Core_PseudoConstant::tag(); foreach ($values as $v) { $result[] = $tags[$v]; } return implode(',', $result); }
/** * Function to set variables up before form is built * * @return void * @access public */ function preProcess() { $skipColumnHeader = $this->controller->exportValue('UploadFile', 'skipColumnHeader'); //get the data from the session $dataValues = $this->get('dataValues'); $mapper = $this->get('mapper'); $invalidRowCount = $this->get('invalidRowCount'); $conflictRowCount = $this->get('conflictRowCount'); $mismatchCount = $this->get('unMatchCount'); //get the mapping name displayed if the mappingId is set $mappingId = $this->get('loadMappingId'); if ($mappingId) { $mapDAO =& new CRM_Core_DAO_Mapping(); $mapDAO->id = $mappingId; $mapDAO->find(true); $this->assign('loadedMapping', $mappingId); $this->assign('savedName', $mapDAO->name); } if ($skipColumnHeader) { $this->assign('skipColumnHeader', $skipColumnHeader); $this->assign('rowDisplayCount', 3); } else { $this->assign('rowDisplayCount', 2); } $groups =& CRM_Core_PseudoConstant::group(); $this->set('groups', $groups); $tag =& CRM_Core_PseudoConstant::tag(); if ($tag) { $this->set('tag', $tag); } if ($invalidRowCount) { $this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=1')); } if ($conflictRowCount) { $this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=2')); } if ($mismatchCount) { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=4')); } $properties = array('mapper', 'locations', 'phones', 'dataValues', 'columnCount', 'totalRowCount', 'validRowCount', 'invalidRowCount', 'conflictRowCount', 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', 'related', 'relatedContactDetails', 'relatedContactLocType', 'relatedContactPhoneType'); foreach ($properties as $property) { $this->assign($property, $this->get($property)); } }
function buildForm(&$form) { /** * You can define a custom title for the search form */ $this->setTitle('Find Contribution Amounts by Tag'); /** * Define the search form fields here */ $form->addDate('start_date', ts('Contribution Date From'), false, array('formatType' => 'custom')); $form->addDate('end_date', ts('...through'), false, array('formatType' => 'custom')); $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::tag(); $form->addElement('select', 'tag', ts('Tagged'), $tag); /** * If you are using the sample template, this array tells the template fields to render * for the search form. */ $form->assign('elements', array('start_date', 'end_date', 'tag')); }
/** * Function to build the form * * @return None * @access public */ function buildQuickForm() { // get categories for the contact id $entityTag =& CRM_Core_BAO_EntityTag::getTag('civicrm_contact', $this->_contactId); // get the list of all the categories $allTag =& CRM_Core_PseudoConstant::tag(); // need to append the array with the " checked " if contact is tagged with the tag foreach ($allTag as $tagID => $varValue) { $strChecked = ''; if (in_array($tagID, $entityTag)) { $strChecked = 'checked'; } $tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', array('onclick' => "return changeRowColor('rowid{$tagID}')", $strChecked => 'checked', 'id' => $tagID)); } $this->addGroup($tagChk, 'tagList'); $this->assign('tag', $allTag); if ($this->_action & CRM_CORE_ACTION_BROWSE) { $this->freeze(); } else { $this->addButtons(array(array('type' => 'next', 'name' => ts('Update Tags'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')))); } }
/** * processing needed for buildForm and later * * @return void * @access public */ function preProcess() { /** * set the varios class variables */ $this->_group =& CRM_Core_PseudoConstant::group(); $this->_groupIterator =& CRM_Core_PseudoConstant::groupIterator(); $this->_tag =& CRM_Core_PseudoConstant::tag(); $this->_done = false; /** * set the button names */ $this->_searchButtonName = $this->getButtonName('refresh'); $this->_printButtonName = $this->getButtonName('next', 'print'); $this->_actionButtonName = $this->getButtonName('next', 'action'); /* * we allow the controller to set force/reset externally, useful when we are being * driven by the wizard framework */ $this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_groupID = CRM_Utils_Request::retrieve('gid', 'Positive', $this); $this->_amtgID = CRM_Utils_Request::retrieve('amtgID', 'Positive', $this); $this->_ssID = CRM_Utils_Request::retrieve('ssID', 'Positive', $this); $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this); $this->_ufGroupID = CRM_Utils_Request::retrieve('id', 'Positive', $this); // reset from session, CRM-3526 $session =& CRM_Core_Session::singleton(); if ($this->_force && $session->get('selectedSearchContactIds')) { $session->resetScope('selectedSearchContactIds'); } // if we dont get this from the url, use default if one exsts $config =& CRM_Core_Config::singleton(); if ($this->_ufGroupID == null && $config->defaultSearchProfileID != null) { $this->_ufGroupID = $config->defaultSearchProfileID; } /* * assign context to drive the template display, make sure context is valid */ $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, false, 'search'); if (!CRM_Utils_Array::value($this->_context, self::validContext())) { $this->_context = 'search'; $this->set('context', $this->_context); } $this->assign('context', $this->_context); $this->set('selectorName', $this->_selectorName); // get user submitted values // get it from controller only if form has been submitted, else preProcess has set this // $this->controller->isModal( ) returns true if page is // valid, i.e all the validations are true if (!empty($_POST) && !$this->controller->isModal()) { $this->_formValues = $this->controller->exportValues($this->_name); $this->normalizeFormValues(); $this->_params =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->_returnProperties =& $this->returnProperties(); // also get the uf group id directly from the post value $this->_ufGroupID = CRM_Utils_Array::value('uf_group_id', $_POST, $this->_ufGroupID); $this->_formValues['uf_group_id'] = $this->_ufGroupID; $this->set('id', $this->_ufGroupID); } else { $this->_formValues = $this->get('formValues'); $this->_params =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $this->_returnProperties =& $this->returnProperties(); } if (empty($this->_formValues)) { //check if group is a smart group (fix for CRM-1255) if ($this->_groupID) { if ($ssId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_groupID, 'saved_search_id')) { $this->_ssID = $ssId; } } // fix for CRM-1907 if (isset($this->_ssID) && $this->_context != 'smog') { // we only retrieve the saved search values if out current values are null $this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID); //fix for CRM-1505 if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'mapping_id')) { $this->_params =& CRM_Contact_BAO_SavedSearch::getSearchParams($this->_ssID); } else { $this->_params =& CRM_Contact_BAO_Query::convertFormValues($this->_formValues); } $this->_returnProperties =& $this->returnProperties(); } else { if (isset($this->_ufGroupID)) { // also set the uf group id if not already present $this->_formValues['uf_group_id'] = $this->_ufGroupID; } } } $this->assign('id', CRM_Utils_Array::value('uf_group_id', $this->_formValues)); require_once 'CRM/Contact/BAO/Contact.php'; $menuItems = CRM_Contact_BAO_Contact::contextMenu(); $primaryActions = CRM_Utils_Array::value('primaryActions', $menuItems, array()); $this->_contextMenu = CRM_Utils_Array::value('moreActions', $menuItems, array()); $this->assign('contextMenu', $primaryActions + $this->_contextMenu); // CRM_Core_Error::debug( 'f', $this->_formValues ); // CRM_Core_Error::debug( 'p', $this->_params ); eval('$selector =& new ' . $this->_selectorName . '( $this->_customSearchClass, $this->_formValues, $this->_params, $this->_returnProperties, $this->_action, false, true, $this->_context );'); $controller =& new CRM_Contact_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $this->get(CRM_Utils_Sort::SORT_ID), CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TRANSFER); $controller->setEmbedded(true); if ($this->_force) { $this->postProcess(); /* * Note that we repeat this, since the search creates and stores * values that potentially change the controller behavior. i.e. things * like totalCount etc */ $sortID = null; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION)); } $controller =& new CRM_Contact_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TRANSFER); $controller->setEmbedded(true); } $controller->moveFromSessionToTemplate(); }
/** * where / qill clause for tag * * @return void * @access public */ function tag() { if (!CRM_Utils_Array::value('tag', $this->_params)) { return; } if (count($this->_params['tag']) > 1) { $this->_useDistinct = true; } $names = array(); $tagNames =& CRM_Core_PseudoConstant::tag(); foreach ($this->_params['tag'] as $id => $dontCare) { $names[] = $tagNames[$id]; } $this->_qill[] = ts('Tagged as -') . ' ' . implode(' ' . ts('or') . ' ', $names); $this->_where[] = 'tag_id IN (' . implode(',', array_keys($this->_params['tag'])) . ')'; $this->_tables['civicrm_entity_tag'] = $this->_whereTables['civicrm_entity_tag'] = 1; }
/** * Given a contact id and a field set, return the values from the db * for this contact * * @param int $id the contact id * @param array $fields the profile fields of interest * @param array $values the values for the above fields * @param boolean $searchable searchable or not * @param array $componentWhere component condition * * @return void * @access public * @static */ public static function getValues($cid, &$fields, &$values, $searchable = true, $componentWhere = null) { if (empty($cid)) { return null; } $options = array(); $studentFields = array(); if (CRM_Core_Permission::access('Quest', false)) { //student fields ( check box ) require_once 'CRM/Quest/BAO/Student.php'; $studentFields = CRM_Quest_BAO_Student::$multipleSelectFields; } // get the contact details (hier) $returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($fields); $params = array(array('contact_id', '=', $cid, 0, 0)); // add conditions specified by components. eg partcipant_id etc if (!empty($componentWhere)) { $params = array_merge($params, $componentWhere); } $query =& new CRM_Contact_BAO_Query($params, $returnProperties, $fields); $options =& $query->_options; $details = $query->searchQuery(); if (!$details->fetch()) { return; } $config =& CRM_Core_Config::singleton(); require_once 'CRM/Core/PseudoConstant.php'; $locationTypes = $imProviders = array(); $locationTypes = CRM_Core_PseudoConstant::locationType(); $imProviders = CRM_Core_PseudoConstant::IMProvider(); //start of code to set the default values foreach ($fields as $name => $field) { // fix for CRM-3962 if ($name == 'id') { $name = 'contact_id'; } $index = $field['title']; $params[$index] = $values[$index] = ''; $customFieldName = null; $elements = array('email_greeting_custom' => 'email_greeting', 'postal_greeting_custom' => 'postal_greeting', 'addressee_custom' => 'addressee'); if (isset($details->{$name}) || $name == 'group' || $name == 'tag') { //hack for CRM-665 // to handle gender / suffix / prefix if (in_array($name, array('gender', 'individual_prefix', 'individual_suffix'))) { $values[$index] = $details->{$name}; $name = $name . '_id'; $params[$index] = $details->{$name}; } else { if (in_array($name, array('email_greeting', 'postal_greeting', 'addressee'))) { $dname = $name . '_display'; $values[$index] = $details->{$dname}; $name = $name . '_id'; $params[$index] = $details->{$name}; } else { if (in_array($name, array('state_province', 'country', 'county'))) { $values[$index] = $details->{$name}; $idx = $name . '_id'; $params[$index] = $details->{$idx}; } else { if ($name === 'preferred_communication_method') { $communicationFields = CRM_Core_PseudoConstant::pcm(); $pref = array(); $compref = array(); $pref = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $details->{$name}); foreach ($pref as $k) { if ($k) { $compref[] = $communicationFields[$k]; } } $params[$index] = $details->{$name}; $values[$index] = implode(",", $compref); } else { if ($name == 'group') { $groups = CRM_Contact_BAO_GroupContact::getContactGroup($cid, 'Added', null, false, true); $title = array(); $ids = array(); foreach ($groups as $g) { if ($g['visibility'] != 'User and User Admin Only') { $title[] = $g['title']; if ($g['visibility'] == 'Public Pages') { $ids[] = $g['group_id']; } } } $values[$index] = implode(', ', $title); $params[$index] = implode(',', $ids); } else { if ($name == 'tag') { require_once 'CRM/Core/BAO/EntityTag.php'; $entityTags =& CRM_Core_BAO_EntityTag::getTag($cid); $allTags =& CRM_Core_PseudoConstant::tag(); $title = array(); foreach ($entityTags as $tagId) { $title[] = $allTags[$tagId]; } $values[$index] = implode(', ', $title); $params[$index] = implode(',', $entityTags); } else { if (array_key_exists($name, $studentFields)) { require_once 'CRM/Core/OptionGroup.php'; $paramsNew = array($name => $details->{$name}); if ($name == 'test_tutoring') { $names = array($name => array('newName' => $index, 'groupName' => 'test')); } else { if (substr($name, 0, 4) == 'cmr_') { //for readers group $names = array($name => array('newName' => $index, 'groupName' => substr($name, 0, -3))); } else { $names = array($name => array('newName' => $index, 'groupName' => $name)); } } CRM_Core_OptionGroup::lookupValues($paramsNew, $names, false); $values[$index] = $paramsNew[$index]; $params[$index] = $paramsNew[$name]; } else { $processed = false; if (CRM_Core_Permission::access('Quest', false)) { require_once 'CRM/Quest/BAO/Student.php'; $processed = CRM_Quest_BAO_Student::buildStudentForm($this, $field); } if (!$processed) { if (substr($name, 0, 7) === 'do_not_' or substr($name, 0, 3) === 'is_') { if ($details->{$name}) { $values[$index] = '[ x ]'; } } else { require_once 'CRM/Core/BAO/CustomField.php'; if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) { $htmlType = $field['html_type']; $dataType = $field['data_type']; if ($htmlType == 'File') { $fileURL = CRM_Core_BAO_CustomField::getFileURL($cid, $cfID); $params[$index] = $values[$index] = $fileURL['file_url']; } else { $customVal = null; if (isset($dao) && ($dao->data_type == 'Int' || $dao->data_type == 'Boolean')) { $customVal = (int) $details->{$name}; } else { if (isset($dao) && $dao->data_type == 'Float') { $customVal = (double) $details->{$name}; } else { if (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name}))) { $customVal = $details->{$name}; } } } //CRM-4582 if (CRM_Utils_System::isNull($customVal)) { continue; } $params[$index] = $customVal; $values[$index] = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options); if ($htmlType == 'Autocomplete-Select') { $params[$index] = $values[$index]; } if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'is_search_range')) { $customFieldName = "{$name}_from"; } } } else { if ($name == 'home_URL' && !empty($details->{$name})) { $url = CRM_Utils_System::fixURL($details->{$name}); $values[$index] = "<a href=\"{$url}\">{$details->{$name}}</a>"; } else { if (in_array($name, array('birth_date', 'deceased_date', 'membership_start_date', 'membership_end_date', 'join_date'))) { require_once 'CRM/Utils/Date.php'; $values[$index] = CRM_Utils_Date::customFormat($details->{$name}); $params[$index] = CRM_Utils_Date::isoToMysql($details->{$name}); } else { $values[$index] = $details->{$name}; } } } } } } } } } } } } } else { if (strpos($name, '-') !== false) { list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $name, 3); if ($id == 'Primary') { // fix for CRM-1543 // not sure why we'd every use Primary location type id // we need to fix the source if we are using it // $locationTypeName = CRM_Contact_BAO_Contact::getPrimaryLocationType( $cid ); $locationTypeName = 1; } else { $locationTypeName = CRM_Utils_Array::value($id, $locationTypes); } if (!$locationTypeName) { continue; } $detailName = "{$locationTypeName}-{$fieldName}"; $detailName = str_replace(' ', '_', $detailName); if (in_array($fieldName, array('phone', 'im', 'email', 'openid'))) { if ($type) { $detailName .= "-{$type}"; } } if (in_array($fieldName, array('state_province', 'country', 'county'))) { $values[$index] = $details->{$detailName}; $idx = $detailName . '_id'; $params[$index] = $details->{$idx}; } else { if ($fieldName == 'im') { $providerId = $detailName . '-provider_id'; $providerName = $imProviders[$details->{$providerId}]; if ($providerName) { $values[$index] = $details->{$detailName} . " (" . $providerName . ")"; } else { $values[$index] = $details->{$detailName}; } $params[$index] = $details->{$detailName}; } else { $values[$index] = $params[$index] = $details->{$detailName}; } } } } if ($field['visibility'] == "Public Pages and Listings" && CRM_Core_Permission::check('profile listings and forms')) { if (CRM_Utils_System::isNull($params[$index])) { $params[$index] = $values[$index]; } if (!isset($params[$index])) { continue; } $customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name']); if (!$customFieldName) { $fieldName = $field['name']; } else { $fieldName = $customFieldName; } $url = null; if (CRM_Core_BAO_CustomField::getKeyID($field['name'])) { $htmlType = $field['html_type']; if ($htmlType == 'Link') { $url = $params[$index]; } else { if (in_array($htmlType, array('CheckBox', 'Multi-Select', 'AdvMulti-Select', 'Multi-Select State/Province', 'Multi-Select Country'))) { $valSeperator = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR; $selectedOptions = explode($valSeperator, $params[$index]); foreach ($selectedOptions as $key => $multiOption) { if ($multiOption) { $eachOption = $valSeperator . $multiOption . $valSeperator; $url[] = CRM_Utils_System::url('civicrm/profile', 'reset=1&force=1&gid=' . $field['group_id'] . '&' . urlencode($fieldName) . '=' . urlencode($eachOption)); } } } else { $url = CRM_Utils_System::url('civicrm/profile', 'reset=1&force=1&gid=' . $field['group_id'] . '&' . urlencode($fieldName) . '=' . urlencode($params[$index])); } } } else { $url = CRM_Utils_System::url('civicrm/profile', 'reset=1&force=1&gid=' . $field['group_id'] . '&' . urlencode($fieldName) . '=' . urlencode($params[$index])); } if ($url && !empty($values[$index]) && $searchable) { if (is_array($url) && !empty($url)) { $links = array(); $eachMultiValue = explode(', ', $values[$index]); foreach ($eachMultiValue as $key => $valueLabel) { $links[] = '<a href="' . $url[$key] . '">' . $valueLabel . '</a>'; } $values[$index] = implode(', ', $links); } else { $values[$index] = '<a href="' . $url . '">' . $values[$index] . '</a>'; } } } } }
function buildForm(&$form) { $config =& CRM_Core_Config::singleton(); $countryDefault = $config->defaultContactCountry; $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::tag(); $form->addElement('select', 'tag', ts('Tag'), $tag); $form->add('text', 'distance', ts('Distance')); $form->add('text', 'street_address', ts('Street Address')); $form->add('text', 'city', ts('City')); $form->add('text', 'postal_code', ts('Postal Code')); $stateCountryMap = array(); $stateCountryMap[] = array('state_province' => 'state_province_id', 'country' => 'country_id'); $defaults = array(); if ($countryDefault) { $stateProvince = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvinceForCountry($countryDefault); $defaults['country_id'] = $countryDefault; } else { $stateProvince = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince(); } $form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince); $country = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(); $form->add('select', 'country_id', ts('Country'), $country, true); $form->add('text', 'distance', ts('Radius for Proximity Search (in km)'), null, true); // state country js, CRM-5233 require_once 'CRM/Core/BAO/Address.php'; CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap); CRM_Core_BAO_Address::fixAllStateSelects($form, $defaults); /** * You can define a custom title for the search form */ $this->setTitle('Proximity Search'); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('tag', 'street_address', 'city', 'postal_code', 'country_id', 'state_province_id', 'distance')); }
/** * Given a contact id and a field set, return the values from the db * for this contact * * @param int $id the contact id * @param array $fields the profile fields of interest * @param array $values the values for the above fields * @return void * @access public * @static */ function getValues($cid, &$fields, &$values) { $options = array(); // get the contact details (hier) $returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($fields); $params = array('id' => $cid); $query =& new CRM_Contact_BAO_Query($params, $returnProperties, $fields); $options =& $query->_options; $details = $query->searchQuery(); if (!$details->fetch()) { return; } require_once 'CRM/Core/PseudoConstant.php'; $locationTypes = CRM_Core_PseudoConstant::locationType(); //start of code to set the default values foreach ($fields as $name => $field) { $index = $field['title']; $params[$index] = $values[$index] = ''; if ($details->{$name} || $name == 'group' || $name == 'tag') { //hack for CRM-665 //to handle custom data (checkbox) to be written // to handle gender / suffix / prefix if (in_array($name, array('gender', 'individual_prefix', 'individual_suffix'))) { $values[$index] = $details->{$name}; $name = $name . '_id'; $params[$index] = $details->{$name}; } else { if (in_array($name, array('state_province', 'country'))) { $values[$index] = $details->{$name}; $idx = $name . '_id'; $params[$index] = $details->{$idx}; } else { if (substr($name, 0, 7) === 'do_not_' or substr($name, 0, 3) === 'is_') { if ($details->{$name}) { $values[$index] = '[ x ]'; } } else { if ($name == 'group') { $groups = CRM_Contact_BAO_GroupContact::getContactGroup($cid, 'Added', null, false, true); $title = array(); $ids = array(); foreach ($groups as $g) { if ($g['visibility'] != 'User and User Admin Only') { $title[] = $g['title']; if ($g['visibility'] == 'Public User Pages and Listings') { $ids[] = $g['group_id']; } } } $values[$index] = implode(', ', $title); $params[$index] = implode(',', $ids); } else { if ($name == 'tag') { require_once 'CRM/Core/BAO/EntityTag.php'; $entityTags =& CRM_Core_BAO_EntityTag::getTag('civicrm_contact', $cid); $allTags =& CRM_Core_PseudoConstant::tag(); $title = array(); foreach ($entityTags as $tagId) { $title[] = $allTags[$tagId]; } $values[$index] = implode(', ', $title); $params[$index] = implode(',', $entityTags); } else { require_once 'CRM/Core/BAO/CustomField.php'; if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) { $params[$index] = $details->{$name}; $values[$index] = CRM_Core_BAO_CustomField::getDisplayValue($details->{$name}, $cfID, $options); } else { $values[$index] = $details->{$name}; } } } } } } } else { if (strpos($name, '-') !== false) { list($fieldName, $id, $type) = explode('-', $name); $locationTypeName = CRM_Utils_Array::value($id, $locationTypes); if (!$locationTypeName) { continue; } $detailName = "{$locationTypeName}-{$fieldName}"; if (in_array($fieldName, array('phone', 'im', 'email'))) { if ($type) { $detailName .= "-{$type}"; } else { $detailName .= '-1'; } } if (in_array($fieldName, array('state_province', 'country'))) { $values[$index] = $details->{$detailName}; $idx = $detailName . '_id'; $params[$index] = $details->{$idx}; } else { $values[$index] = $params[$index] = $details->{$detailName}; } } } if ($field['visibility'] == "Public User Pages and Listings" && CRM_Utils_System::checkPermission('profile listings and forms')) { if (CRM_Utils_System::isNull($params[$index])) { $params[$index] = $values[$index]; } if (empty($params[$index])) { continue; } $fieldName = $field['name']; $url = CRM_Utils_System::url('civicrm/profile', 'reset=1&force=1&gid=' . $field['group_id'] . '&' . urlencode($fieldName) . '=' . urlencode($params[$index])); if (!empty($values[$index])) { $values[$index] = '<a href="' . $url . '">' . $values[$index] . '</a>'; } } } }
/** * Given a contact id and a field set, return the values from the db * for this contact * * @param int $id the contact id * @param array $fields the profile fields of interest * @param array $values the values for the above fields * @param boolean $searchable searchable or not * @param array $componentWhere component condition * @param boolean $absolute return urls in absolute form (useful when sending an email) * * @return void * @access public * @static */ public static function getValues($cid, &$fields, &$values, $searchable = TRUE, $componentWhere = NULL, $absolute = FALSE) { if (empty($cid) && empty($componentWhere)) { return NULL; } $options = $studentFields = array(); if (CRM_Core_Permission::access('Quest', FALSE)) { //student fields ( check box ) $studentFields = CRM_Quest_BAO_Student::$multipleSelectFields; } // get the contact details (hier) $returnProperties = CRM_Contact_BAO_Contact::makeHierReturnProperties($fields); $params = $cid ? array(array('contact_id', '=', $cid, 0, 0)) : array(); // add conditions specified by components. eg partcipant_id etc if (!empty($componentWhere)) { $params = array_merge($params, $componentWhere); } $query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields); $options =& $query->_options; $details = $query->searchQuery(); if (!$details->fetch()) { return; } $config = CRM_Core_Config::singleton(); $locationTypes = $imProviders = array(); $locationTypes = CRM_Core_PseudoConstant::locationType(); $imProviders = CRM_Core_PseudoConstant::IMProvider(); $websiteTypes = CRM_Core_PseudoConstant::websiteType(); $multipleFields = array('url'); $nullIndex = $nullValueIndex = ' '; //start of code to set the default values foreach ($fields as $name => $field) { // fix for CRM-3962 if ($name == 'id') { $name = 'contact_id'; } $index = $field['title']; //handle for the label not set for the field if (empty($field['title'])) { $index = $nullIndex; $nullIndex .= $nullIndex; } //handle the case to avoid re-write where the profile field labels are the same if (CRM_Utils_Array::value($index, $values)) { $index .= $nullValueIndex; $nullValueIndex .= $nullValueIndex; } $params[$index] = $values[$index] = ''; $customFieldName = NULL; // hack for CRM-665 if (isset($details->{$name}) || $name == 'group' || $name == 'tag') { // to handle gender / suffix / prefix if (in_array($name, array('gender', 'individual_prefix', 'individual_suffix'))) { $values[$index] = $details->{$name}; $name = $name . '_id'; $params[$index] = $details->{$name}; } elseif (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes)) { $dname = $name . '_display'; $values[$index] = $details->{$dname}; $name = $name . '_id'; $params[$index] = $details->{$name}; } elseif (in_array($name, array('state_province', 'country', 'county'))) { $values[$index] = $details->{$name}; $idx = $name . '_id'; $params[$index] = $details->{$idx}; } elseif ($name === 'preferred_communication_method') { $communicationFields = CRM_Core_PseudoConstant::pcm(); $pref = $compref = array(); $pref = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name}); foreach ($pref as $k) { if ($k) { $compref[] = $communicationFields[$k]; } } $params[$index] = $details->{$name}; $values[$index] = implode(',', $compref); } elseif ($name === 'preferred_language') { $languages = CRM_Core_PseudoConstant::languages(); $params[$index] = $details->{$name}; $values[$index] = $languages[$details->{$name}]; } elseif ($name == 'group') { $groups = CRM_Contact_BAO_GroupContact::getContactGroup($cid, 'Added', NULL, FALSE, TRUE); $title = $ids = array(); foreach ($groups as $g) { // CRM-8362: User and User Admin visibility groups should be included in display if user has // VIEW permission on that group $groupPerm = CRM_Contact_BAO_Group::checkPermission($g['group_id'], $g['title']); if ($g['visibility'] != 'User and User Admin Only' || CRM_Utils_Array::key(CRM_Core_Permission::VIEW, $groupPerm)) { $title[] = $g['title']; if ($g['visibility'] == 'Public Pages') { $ids[] = $g['group_id']; } } } $values[$index] = implode(', ', $title); $params[$index] = implode(',', $ids); } elseif ($name == 'tag') { $entityTags = CRM_Core_BAO_EntityTag::getTag($cid); $allTags = CRM_Core_PseudoConstant::tag(); $title = array(); foreach ($entityTags as $tagId) { $title[] = $allTags[$tagId]; } $values[$index] = implode(', ', $title); $params[$index] = implode(',', $entityTags); } elseif (array_key_exists($name, $studentFields)) { $paramsNew = array($name => $details->{$name}); if ($name == 'test_tutoring') { $names = array($name => array('newName' => $index, 'groupName' => 'test')); // for readers group } elseif (substr($name, 0, 4) == 'cmr_') { $names = array($name => array('newName' => $index, 'groupName' => substr($name, 0, -3))); } else { $names = array($name => array('newName' => $index, 'groupName' => $name)); } CRM_Core_OptionGroup::lookupValues($paramsNew, $names, FALSE); $values[$index] = $paramsNew[$index]; $params[$index] = $paramsNew[$name]; } elseif ($name == 'activity_status_id') { $activityStatus = CRM_Core_PseudoConstant::activityStatus(); $values[$index] = $activityStatus[$details->{$name}]; $params[$index] = $details->{$name}; } elseif ($name == 'activity_date_time') { $values[$index] = CRM_Utils_Date::customFormat($details->{$name}); $params[$index] = $details->{$name}; } elseif ($name == 'contact_sub_type') { $values[$index] = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ', ', trim($details->{$name}, CRM_Core_DAO::VALUE_SEPARATOR)); $params[$index] = $details->{$name}; } else { $processed = FALSE; if (CRM_Core_Permission::access('Quest', FALSE)) { $processed = CRM_Quest_BAO_Student::buildStudentForm($this, $field); } if (!$processed) { if (substr($name, 0, 7) === 'do_not_' || substr($name, 0, 3) === 'is_') { if ($details->{$name}) { $values[$index] = '[ x ]'; } } else { if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) { $htmlType = $field['html_type']; $dataType = $field['data_type']; // field_type is only set when we are retrieving profile values // when sending email, we call the same function to get custom field // values etc, i.e. emulating a profile $fieldType = CRM_Utils_Array::value('field_type', $field); if ($htmlType == 'File') { $entityId = $cid; if (!$cid && $fieldType == 'Activity' && CRM_Utils_Array::value(2, $componentWhere[0])) { $entityId = $componentWhere[0][2]; } $fileURL = CRM_Core_BAO_CustomField::getFileURL($entityId, $cfID, NULL, $absolute); $params[$index] = $values[$index] = $fileURL['file_url']; } else { $customVal = NULL; if (isset($dao) && property_exists($dao, 'data_type') && ($dao->data_type == 'Int' || $dao->data_type == 'Boolean')) { $customVal = (int) $details->{$name}; } elseif (isset($dao) && property_exists($dao, 'data_type') && $dao->data_type == 'Float') { $customVal = (double) $details->{$name}; } elseif (!CRM_Utils_System::isNull(explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name}))) { $customVal = $details->{$name}; } //CRM-4582 if (CRM_Utils_System::isNull($customVal)) { continue; } $params[$index] = $customVal; $values[$index] = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options); if ($htmlType == 'Autocomplete-Select') { $params[$index] = $values[$index]; } if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'is_search_range')) { $customFieldName = "{$name}_from"; } } } elseif ($name == 'image_URL') { list($width, $height) = getimagesize($details->{$name}); list($thumbWidth, $thumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($width, $height); $image_URL = '<img src="' . $details->{$name} . '" height= ' . $thumbHeight . ' width= ' . $thumbWidth . ' />'; $values[$index] = "<a href='#' onclick='contactImagePopUp(\"{$details->{$name}}\", {$width}, {$height});'>{$image_URL}</a>"; } elseif (in_array($name, array('birth_date', 'deceased_date', 'membership_start_date', 'membership_end_date', 'join_date'))) { $values[$index] = CRM_Utils_Date::customFormat($details->{$name}); $params[$index] = CRM_Utils_Date::isoToMysql($details->{$name}); } else { $dao = ''; if ($index == 'Campaign') { $dao = 'CRM_Campaign_DAO_Campaign'; } elseif ($index == 'Contribution Page') { $dao = 'CRM_Contribute_DAO_ContributionPage'; } if ($dao) { $value = CRM_Core_DAO::getFieldValue($dao, $details->{$name}, 'title'); } else { $value = $details->{$name}; } $values[$index] = $value; } } } } } elseif (strpos($name, '-') !== FALSE) { list($fieldName, $id, $type) = CRM_Utils_System::explode('-', $name, 3); if (!in_array($fieldName, $multipleFields)) { if ($id == 'Primary') { // fix for CRM-1543 // not sure why we'd every use Primary location type id // we need to fix the source if we are using it // $locationTypeName = CRM_Contact_BAO_Contact::getPrimaryLocationType( $cid ); $locationTypeName = 1; } else { $locationTypeName = CRM_Utils_Array::value($id, $locationTypes); } if (!$locationTypeName) { continue; } $detailName = "{$locationTypeName}-{$fieldName}"; $detailName = str_replace(' ', '_', $detailName); if (in_array($fieldName, array('phone', 'im', 'email', 'openid'))) { if ($type) { $detailName .= "-{$type}"; } } if (in_array($fieldName, array('state_province', 'country', 'county'))) { $values[$index] = $details->{$detailName}; $idx = $detailName . '_id'; $params[$index] = $details->{$idx}; } elseif ($fieldName == 'im') { $providerId = $detailName . '-provider_id'; $providerName = $imProviders[$details->{$providerId}]; if ($providerName) { $values[$index] = $details->{$detailName} . " (" . $providerName . ")"; } else { $values[$index] = $details->{$detailName}; } $params[$index] = $details->{$detailName}; } else { $values[$index] = $params[$index] = $details->{$detailName}; } } else { $detailName = "website-{$id}-{$fieldName}"; $url = CRM_Utils_System::fixURL($details->{$detailName}); if ($details->{$detailName}) { $websiteTypeId = "website-{$id}-website_type_id"; $websiteType = $websiteTypes[$details->{$websiteTypeId}]; $values[$index] = "<a href=\"{$url}\">{$details->{$detailName}} ( {$websiteType} )</a>"; } else { $values[$index] = ''; } } } if (CRM_Utils_Array::value('visibility', $field) == 'Public Pages and Listings' && CRM_Core_Permission::check('profile listings and forms')) { if (CRM_Utils_System::isNull($params[$index])) { $params[$index] = $values[$index]; } if (!isset($params[$index])) { continue; } $customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name']); if (!$customFieldName) { $fieldName = $field['name']; } else { $fieldName = $customFieldName; } $url = NULL; if (CRM_Core_BAO_CustomField::getKeyID($field['name'])) { $htmlType = $field['html_type']; if ($htmlType == 'Link') { $url = $params[$index]; } elseif (in_array($htmlType, array('CheckBox', 'Multi-Select', 'AdvMulti-Select', 'Multi-Select State/Province', 'Multi-Select Country'))) { $valSeperator = CRM_Core_DAO::VALUE_SEPARATOR; $selectedOptions = explode($valSeperator, $params[$index]); foreach ($selectedOptions as $key => $multiOption) { if ($multiOption) { $url[] = CRM_Utils_System::url('civicrm/profile', 'reset=1&force=1&gid=' . $field['group_id'] . '&' . urlencode($fieldName) . '=' . urlencode($multiOption)); } } } else { $url = CRM_Utils_System::url('civicrm/profile', 'reset=1&force=1&gid=' . $field['group_id'] . '&' . urlencode($fieldName) . '=' . urlencode($params[$index])); } } else { $url = CRM_Utils_System::url('civicrm/profile', 'reset=1&force=1&gid=' . $field['group_id'] . '&' . urlencode($fieldName) . '=' . urlencode($params[$index])); } if ($url && !empty($values[$index]) && $searchable) { if (is_array($url) && !empty($url)) { $links = array(); $eachMultiValue = explode(', ', $values[$index]); foreach ($eachMultiValue as $key => $valueLabel) { $links[] = '<a href="' . $url[$key] . '">' . $valueLabel . '</a>'; } $values[$index] = implode(', ', $links); } else { $values[$index] = '<a href="' . $url . '">' . $values[$index] . '</a>'; } } } } }
/** * This function is to build form elements * params object $form object of the form * * @param Object $form the form object that we are operating on * @param int $contactId contact id * @param int $type what components are we interested in * @param boolean $visibility visibility of the field * @param string $groupName if used for building group block * @param string $tagName if used for building tag block * @param string $fieldName this is used in batch profile(i.e to build multiple blocks) * * @static * @access public */ static function buildQuickForm(&$form, $contactId = 0, $type = CRM_Contact_Form_Edit_TagsandGroups::ALL, $visibility = false, $isRequired = null, $groupName = 'Groups(s)', $tagName = 'Tag(s)', $fieldName = null) { $type = (int) $type; if ($type & CRM_Contact_Form_Edit_TagsandGroups::GROUP) { $fName = 'group'; if ($fieldName) { $fName = $fieldName; } $elements = array(); $groupID = isset($form->_grid) ? $form->_grid : null; if ($groupID && $visibility) { $ids = '= ' . $groupID; } else { if ($visibility) { $group =& CRM_Core_PseudoConstant::allGroup(); } else { $group =& CRM_Core_PseudoConstant::group(); } $ids = implode(',', array_keys($group)); $ids = 'IN (' . $ids . ')'; } if ($groupID || !empty($group)) { $sql = "\n SELECT id, title, description, visibility\n FROM civicrm_group\n WHERE id {$ids}\n ORDER BY title\n "; $dao = CRM_Core_DAO::executeQuery($sql); $attributes['skiplabel'] = true; while ($dao->fetch()) { // make sure that this group has public visibility if ($visibility && $dao->visibility == 'User and User Admin Only') { continue; } $form->_tagGroup[$fName][$dao->id]['description'] = $dao->description; $elements[] =& $form->addElement('advcheckbox', $dao->id, null, $dao->title, $attributes); } if (!empty($elements)) { $form->addGroup($elements, $fName, $groupName, ' '); $form->assign('groupCount', count($elements)); if ($isRequired) { $form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required'); } } } } if ($type & CRM_Contact_Form_Edit_TagsandGroups::TAG) { $fName = 'tag'; if ($fieldName) { $fName = $fieldName; } $form->_tagGroup[$fName] = 1; $elements = array(); $tag =& CRM_Core_PseudoConstant::tag(); foreach ($tag as $id => $name) { $elements[] =& HTML_QuickForm::createElement('checkbox', $id, null, $name); } if (!empty($elements)) { $form->addGroup($elements, $fName, $tagName, '<br />'); $form->assign('tagCount', count($elements)); } if ($isRequired) { $form->addRule($fName, ts('%1 is a required field.', array(1 => $tagName)), 'required'); } } $form->assign('tagGroup', $form->_tagGroup); }
/** * where / qill clause for tag * * @return void * @access public */ function tag(&$values) { list($name, $op, $value, $grouping, $wildcard) = $values; $tagNames = CRM_Core_PseudoConstant::tag(); if (is_array($value)) { if (count($value) > 1) { $this->_useDistinct = TRUE; } foreach ($value as $id => $dontCare) { $names[] = $tagNames[$id]; } $names = implode(' ' . ts('or') . ' ', $names); $value = implode(',', array_keys($value)); } else { $names = CRM_Utils_Array::value($value, $tagNames); } $etTable = "`civicrm_entity_tag-" . $value . "`"; $this->_tables[$etTable] = $this->_whereTables[$etTable] = " LEFT JOIN civicrm_entity_tag {$etTable} ON ( {$etTable}.entity_id = contact_a.id AND {$etTable}.entity_table = 'civicrm_contact' ) "; // CRM-10338 if (in_array($op, array('IS NULL', 'IS NOT NULL'))) { $this->_where[$grouping][] = "{$etTable}.tag_id {$op}"; } else { $this->_where[$grouping][] = "{$etTable}.tag_id {$op} (" . $value . ')'; } $this->_qill[$grouping][] = ts('Tagged %1', array(1 => $op)) . ' ' . $names; }
/** * * @param <type> $params * * @return <type> * @todo EM 7 Jan 2011 - believe this should be deleted * @deprecated */ function civicrm_api3_entity_tag_display($params) { civicrm_api3_verify_one_mandatory($params, NULL, array('entity_id', 'contact_id')); $entityID = NULL; $entityTable = 'civicrm_contact'; if (!($entityID = CRM_Utils_Array::value('entity_id', $params))) { $entityID = CRM_Utils_Array::value('contact_id', $params); } if (CRM_Utils_Array::value('entity_table', $params)) { $entityTable = $params['entity_table']; } require_once 'CRM/Core/BAO/EntityTag.php'; $values = CRM_Core_BAO_EntityTag::getTag($entityID, $entityTable); $result = array(); $tags = CRM_Core_PseudoConstant::tag(); foreach ($values as $v) { $result[] = $tags[$v]; } return implode(',', $result); }
/** * * @param <type> $params * * @return <type> */ function civicrm_entity_tag_display(&$params) { if (!is_array($params)) { return civicrm_create_error(ts('params should be an array.')); } $entityID = NULL; $entityTable = 'civicrm_contact'; if (!($entityID = CRM_Utils_Array::value('entity_id', $params))) { $entityID = CRM_Utils_Array::value('contact_id', $params); } if (empty($entityID)) { return civicrm_create_error(ts('entity_id is a required field.')); } if (CRM_Utils_Array::value('entity_table', $params)) { $entityTable = $params['entity_table']; } require_once 'CRM/Core/BAO/EntityTag.php'; $values = CRM_Core_BAO_EntityTag::getTag($entityID, $entityTable); $result = array(); $tags = CRM_Core_PseudoConstant::tag(); foreach ($values as $v) { $result[] = $tags[$v]; } return implode(',', $result); }
function __construct() { $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Contact Name'), 'required' => true, 'no_repeat' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name' => array('title' => ts('Contact Name')), 'source' => array('title' => ts('Contact Source'), 'type' => CRM_Utils_Type::T_STRING), 'id' => array('title' => ts('Contact ID'), 'no_display' => true)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => true)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', 'fields' => array('street_address' => array('default' => true), 'city' => array('default' => true), 'postal_code' => null, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'), 'default' => true)), '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()))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => null), '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()))), 'civicrm_tag' => array('dao' => 'CRM_Core_DAO_Tag', 'filters' => array('tid' => array('name' => 'tag_id', 'title' => ts('Tag'), 'tag' => true, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::tag())))); parent::__construct(); }
/** * This function is to build form elements * params object $form object of the form * * @param Object $form the form object that we are operating on * @param int $contactId contact id * @param int $type what components are we interested in * * @static * @access public */ function buildGroupTagBlock(&$form, $contactId = 0, $type = CRM_CONTACT_FORM_GROUPTAG_ALL, $visibility = false, $isRequired = null, $groupName = 'Groups(s)', $tagName = 'Tag(s)') { $type = (int) $type; if ($type & CRM_CONTACT_FORM_GROUPTAG_GROUP) { $elements = array(); if ($visibility) { $group =& CRM_Core_PseudoConstant::allGroup(); } else { $group =& CRM_Core_PseudoConstant::group(); } foreach ($group as $id => $name) { if ($visibility) { // make sure that this group has public visibility. not very efficient $dao =& new CRM_Contact_DAO_Group(); $dao->id = $id; if ($dao->find(true)) { if ($dao->visibility == 'User and User Admin Only') { continue; } } else { continue; } } $elements[] =& HTML_QuickForm::createElement('checkbox', $id, null, $name); } if (!empty($elements)) { $form->addGroup($elements, 'group', $groupName, '<br />'); if ($isRequired) { $form->addRule('group', ts('%1 is a required field.', array(1 => $groupName)), 'required'); } } } if ($type & CRM_CONTACT_FORM_GROUPTAG_TAG) { $elements = array(); $tag =& CRM_Core_PseudoConstant::tag(); foreach ($tag as $id => $name) { $elements[] =& HTML_QuickForm::createElement('checkbox', $id, null, $name); } if (!empty($elements)) { $form->addGroup($elements, 'tag', $tagName, '<br />'); } if ($isRequired) { $form->addRule('tag', ts('%1 is a required field.', array(1 => $tagName)), 'required'); } } }
/** * Function to build the array for display the profile fields * * @param array $params key value. * @param int $gid profile Id * @param array $groupTitle Profile Group Title. * @param array $values formatted array of key value * * @return None * @access public */ function displayProfile(&$params, $gid, &$groupTitle, &$values) { if ($gid) { require_once 'CRM/Core/BAO/UFGroup.php'; require_once 'CRM/Profile/Form.php'; require_once 'CRM/Event/PseudoConstant.php'; $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); if ($contactID) { if (CRM_Core_BAO_UFGroup::filterUFGroups($gid, $contactID)) { $fields = CRM_Core_BAO_UFGroup::getFields($gid, false, CRM_Core_Action::VIEW); } } else { $fields = CRM_Core_BAO_UFGroup::getFields($gid, false, CRM_Core_Action::ADD); } if (is_array($fields)) { // unset any email-* fields since we already collect it, CRM-2888 foreach (array_keys($fields) as $fieldName) { if (substr($fieldName, 0, 6) == 'email-') { unset($fields[$fieldName]); } } } foreach ($fields as $v) { if (CRM_Utils_Array::value('groupTitle', $v)) { $groupTitle['groupTitle'] = $v["groupTitle"]; break; } } $config = CRM_Core_Config::singleton(); require_once 'CRM/Core/PseudoConstant.php'; $locationTypes = $imProviders = array(); $locationTypes = CRM_Core_PseudoConstant::locationType(); $imProviders = CRM_Core_PseudoConstant::IMProvider(); //start of code to set the default values foreach ($fields as $name => $field) { $index = $field['title']; $customFieldName = null; if ($name === 'organization_name') { $values[$index] = $params[$name]; } if ('state_province' == substr($name, 0, 14)) { if ($params[$name]) { $values[$index] = CRM_Core_PseudoConstant::stateProvince($params[$name]); } else { $values[$index] = ''; } } else { if ('country' == substr($name, 0, 7)) { if ($params[$name]) { $values[$index] = CRM_Core_PseudoConstant::country($params[$name]); } else { $values[$index] = ''; } } else { if ('county' == substr($name, 0, 6)) { if ($params[$name]) { $values[$index] = CRM_Core_PseudoConstant::county($params[$name]); } else { $values[$index] = ''; } } else { if ('gender' == substr($name, 0, 6)) { $gender = CRM_Core_PseudoConstant::gender(); $values[$index] = $gender[$params[$name]]; } else { if ('individual_prefix' == substr($name, 0, 17)) { $prefix = CRM_Core_PseudoConstant::individualPrefix(); $values[$index] = $prefix[$params[$name]]; } else { if ('individual_suffix' == substr($name, 0, 17)) { $suffix = CRM_Core_PseudoConstant::individualSuffix(); $values[$index] = $suffix[$params[$name]]; } else { if (in_array($name, array('addressee', 'email_greeting', 'postal_greeting'))) { $filterCondition = array('greeting_type' => $name); $greeting =& CRM_Core_PseudoConstant::greeting($filterCondition); $values[$index] = $greeting[$params[$name]]; } else { if ($name === 'preferred_communication_method') { $communicationFields = CRM_Core_PseudoConstant::pcm(); $pref = array(); $compref = array(); $pref = $params[$name]; if (is_array($pref)) { foreach ($pref as $k => $v) { if ($v) { $compref[] = $communicationFields[$k]; } } } $values[$index] = implode(",", $compref); } else { if ($name == 'group') { require_once 'CRM/Contact/BAO/GroupContact.php'; $groups = CRM_Contact_BAO_GroupContact::getGroupList(); $title = array(); foreach ($params[$name] as $gId => $dontCare) { if ($dontCare) { $title[] = $groups[$gId]; } } $values[$index] = implode(', ', $title); } else { if ($name == 'tag') { require_once 'CRM/Core/BAO/EntityTag.php'; $entityTags = $params[$name]; $allTags =& CRM_Core_PseudoConstant::tag(); $title = array(); if (is_array($entityTags)) { foreach ($entityTags as $tagId => $dontCare) { $title[] = $allTags[$tagId]; } } $values[$index] = implode(', ', $title); } else { if ('participant_role_id' == $name) { $roles = CRM_Event_PseudoConstant::participantRole(); $values[$index] = $roles[$params[$name]]; } else { if ('participant_status_id' == $name) { $status = CRM_Event_PseudoConstant::participantStatus(); $values[$index] = $status[$params[$name]]; } else { if (strpos($name, '-') !== false) { list($fieldName, $id) = CRM_Utils_System::explode('-', $name, 2); $detailName = str_replace(' ', '_', $name); if (in_array($fieldName, array('state_province', 'country', 'county'))) { $values[$index] = $params[$detailName]; $idx = $detailName . '_id'; $values[$index] = $params[$idx]; } else { if ($fieldName == 'im') { $providerName = null; if ($providerId = $detailName . '-provider_id') { $providerName = CRM_Utils_Array::value($params[$providerId], $imProviders); } if ($providerName) { $values[$index] = $params[$detailName] . " (" . $providerName . ")"; } else { $values[$index] = $params[$detailName]; } } else { $values[$index] = $params[$detailName]; } } } else { if (substr($name, 0, 7) === 'do_not_' or substr($name, 0, 3) === 'is_') { if ($params[$name]) { $values[$index] = '[ x ]'; } } else { require_once 'CRM/Core/BAO/CustomField.php'; if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) { $query = "\nSELECT html_type, data_type\nFROM civicrm_custom_field\nWHERE id = {$cfID}\n"; $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); $dao->fetch(); $htmlType = $dao->html_type; $dataType = $dao->data_type; if ($htmlType == 'File') { //$fileURL = CRM_Core_BAO_CustomField::getFileURL( $contactID, $cfID ); //$params[$index] = $values[$index] = $fileURL['file_url']; $values[$index] = $params[$index]; } else { if ($dao->data_type == 'Int' || $dao->data_type == 'Boolean') { $customVal = (int) $params[$name]; } else { if ($dao->data_type == 'Float') { $customVal = (double) $params[$name]; } else { if ($dao->data_type == 'Date') { $date = CRM_Utils_Date::format($params[$name], null, 'invalidDate'); if ($date != 'invalidDate') { $customVal = $date; } } else { $customVal = $params[$name]; } } } //take the custom field options $returnProperties = array($name => 1); require_once 'CRM/Contact/BAO/Query.php'; $query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields); $options =& $query->_options; $displayValue = CRM_Core_BAO_CustomField::getDisplayValue($customVal, $cfID, $options); //Hack since we dont have function to check empty. //FIXME in 2.3 using crmIsEmptyArray() $customValue = true; if (is_array($customVal) && is_array($displayValue)) { $customValue = array_diff($customVal, $displayValue); } //use difference of arrays if (empty($customValue) || !$customValue) { $values[$index] = ''; } else { $values[$index] = $displayValue; } if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'is_search_range')) { $customFieldName = "{$name}_from"; } } } else { if ($name == 'home_URL' && !empty($params[$name])) { $url = CRM_Utils_System::fixURL($params[$name]); $values[$index] = "<a href=\"{$url}\">{$params[$name]}</a>"; } else { if (in_array($name, array('birth_date', 'deceased_date', 'participant_register_date'))) { require_once 'CRM/Utils/Date.php'; $values[$index] = CRM_Utils_Date::customFormat(CRM_Utils_Date::format($params[$name])); } else { $values[$index] = $params[$name]; } } } } } } } } } } } } } } } } } } } }
function __construct() { $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Contact Name'), 'required' => true, 'no_repeat' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('id' => array('title' => ts('Contact ID'), 'no_display' => true), 'display_name' => array('title' => ts('Contact Name'))), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', 'fields' => array('street_address' => null, 'city' => null, 'postal_code' => null, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'), 'default' => true))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => true)), 'grouping' => 'contact-fields'), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contact_id' => array('no_display' => true, 'required' => true), 'contribution_id' => array('title' => ts('Contribution'), 'no_repeat' => true, 'default' => true), 'total_amount' => array('default' => true), 'contribution_type_id' => array('title' => ts('Contribution Type'), 'default' => true), 'trxn_id' => null, 'receive_date' => array('default' => true), 'receipt_date' => null, 'contribution_status_id' => array('default' => true), 'contribution_source' => null)), 'civicrm_membership' => array('dao' => 'CRM_Member_DAO_Membership', 'fields' => array('contact_id' => array('no_display' => true, 'required' => true), 'membership_id' => array('title' => ts('Membership'), 'no_repeat' => true, 'default' => true), 'membership_type_id' => array('default' => true), 'join_date' => null, 'membership_start_date' => array('title' => ts('Start Date'), 'default' => true), 'membership_end_date' => array('title' => ts('End Date'), 'default' => true), 'status_id' => null, 'source' => array('title' => 'Membership Source'))), 'civicrm_participant' => array('dao' => 'CRM_Event_DAO_Participant', 'fields' => array('contact_id' => array('no_display' => true, 'required' => true), 'participant_id' => array('title' => ts('Participant'), 'no_repeat' => true, 'default' => true), 'event_id' => array('default' => true), 'participant_status_id' => array('title' => ts('Status'), 'default' => true), 'role_id' => array('title' => ts('Role'), 'default' => true), 'participant_register_date' => array('title' => ts('Register Date'), 'default' => true), 'fee_level' => array('title' => ts('Fee Level'), 'default' => true), 'fee_amount' => array('title' => ts('Fee Amount'), 'default' => true))), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('relationship_id' => array('name' => 'id', 'title' => ts('Relationship'), 'no_repeat' => true, 'default' => true), 'relationship_type_id' => array('title' => ts('Relationship Type'), 'default' => true), 'contact_id_b' => array('title' => ts('Relationship With'), 'default' => true), 'start_date' => array('title' => 'Start Date ', 'type' => CRM_Report_Form::OP_DATE), 'end_date' => array('title' => 'End Date ', 'type' => CRM_Report_Form::OP_DATE))), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('id' => array('title' => ts('Activity'), 'no_repeat' => true, 'default' => true), 'activity_type_id' => array('title' => ts('Activity Type'), 'default' => true), 'subject' => array('title' => ts('Subject'), 'default' => true), 'source_contact_id' => array('title' => ts('Added By'), 'default' => true), 'activity_date_time' => array('title' => ts('Activity Date'), 'default' => true), 'activity_status_id' => array('name' => 'status_id', 'title' => ts('Activity Status'), 'default' => true)), 'grouping' => 'activity-fields'), 'civicrm_activity_target' => array('dao' => 'CRM_Activity_DAO_ActivityTarget', 'fields' => array('target_contact_id' => array('title' => ts('With Contact'), 'default' => true)), 'grouping' => 'activity-fields'), 'civicrm_activity_assignment' => array('dao' => 'CRM_Activity_DAO_ActivityAssignment', 'fields' => array('assignee_contact_id' => array('title' => ts('Assigned To'), 'default' => true)), 'grouping' => 'activity-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()))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => null), 'grouping' => 'contact-fields'), 'civicrm_tag' => array('dao' => 'CRM_Core_DAO_Tag', 'filters' => array('tid' => array('name' => 'tag_id', 'title' => ts('Tag'), 'tag' => true, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::tag())))); parent::__construct(); }