Esempio n. 1
0
 /**
  * build the form elements for a phone object
  *
  * @param CRM_Core_Form $form       reference to the form object
  * @param int           $addressBlockCount block number to build
  * @param boolean       $blockEdit         is it block edit
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form, $addressBlockCount = NULL, $blockEdit = FALSE)
 {
     // passing this via the session is AWFUL. we need to fix this
     if (!$addressBlockCount) {
         $blockId = $form->get('Phone_Block_Count') ? $form->get('Phone_Block_Count') : 1;
     } else {
         $blockId = $addressBlockCount;
     }
     $form->applyFilter('__ALL__', 'trim');
     //phone type select
     $form->addElement('select', "phone[{$blockId}][phone_type_id]", ts('Phone'), CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'));
     //main phone number with crm_phone class
     $form->addElement('text', "phone[{$blockId}][phone]", ts('Phone'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'), array('class' => 'crm_phone twelve')));
     // phone extension
     $form->addElement('text', "phone[{$blockId}][phone_ext]", ts('Extension'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone_ext'));
     if (isset($form->_contactType) || $blockEdit) {
         //Block type select
         $form->addElement('select', "phone[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'));
         //is_Primary radio
         $js = array('id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
         $form->addElement('radio', "phone[{$blockId}][is_primary]", '', '', '1', $js);
     }
     // TODO: set this up as a group, we need a valid phone_type_id if we have a  phone number
     // $form->addRule( "location[$locationId][phone][$locationId][phone]", ts('Phone number is not valid.'), 'phone' );
 }
Esempio n. 2
0
 /**
  * build the form elements for an email object
  *
  * @param CRM_Core_Form $form       reference to the form object
  * @param array         $location   the location object to store all the form elements in
  * @param int           $locationId the locationId we are dealing with
  * @param int           $count      the number of blocks to create
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form, $addressBlockCount = null)
 {
     // passing this via the session is AWFUL. we need to fix this
     if (!$addressBlockCount) {
         $blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1;
     } else {
         $blockId = $addressBlockCount;
     }
     $form->applyFilter('__ALL__', 'trim');
     //Email box
     $form->addElement('text', "email[{$blockId}][email]", ts('Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'));
     $form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email');
     if (isset($form->_contactType)) {
         //Block type
         $form->addElement('select', "email[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType());
         //On-hold checkbox
         $form->addElement('advcheckbox', "email[{$blockId}][on_hold]", null);
         //Bulkmail checkbox
         $js = array('id' => "Email_" . $blockId . "_IsBulkmail", 'onClick' => 'singleSelect( this.id );');
         $form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", null, '', $js);
         //is_Primary radio
         $js = array('id' => "Email_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );');
         $form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js);
         if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') {
             $form->add('textarea', "email[{$blockId}][signature_text]", ts('Signature (Text)'), array('rows' => 2, 'cols' => 40));
             $form->addWysiwyg("email[{$blockId}][signature_html]", ts('Signature (HTML)'), array('rows' => 2, 'cols' => 40));
         }
     }
 }
 /**
  * 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', '', '');
     }
 }
Esempio n. 4
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 )
  *
  * @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', '', '');
     }
 }
Esempio n. 5
0
 /**
  * build the form elements for an Website object
  *
  * @param CRM_Core_Form $form       reference to the form object
  * @param array         $location   the location object to store all the form elements in
  * @param int           $locationId the locationId we are dealing with
  * @param int           $count      the number of blocks to create
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form)
 {
     $blockId = $form->get('Website_Block_Count') ? $form->get('Website_Block_Count') : 1;
     $form->applyFilter('__ALL__', 'trim');
     //Website type select
     $form->addElement('select', "website[{$blockId}][website_type_id]", '', CRM_Core_PseudoConstant::websiteType());
     //Website box
     $form->addElement('text', "website[{$blockId}][url]", ts('Website'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) this.value='http://'; else return false", 'onblur' => "if ( this.value == 'http://') this.value=''; else return false")));
     $form->addRule("website[{$blockId}][url]", ts('Enter a valid web location beginning with \'http://\' or \'https://\'. EXAMPLE: http://www.mysite.org/'), 'url');
 }
Esempio n. 6
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 )
  */
 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', '', '');
     }
 }
Esempio n. 7
0
 /**
  * build the form elements for an IM object
  *
  * @param CRM_Core_Form $form       reference to the form object
  * @param array         $location   the location object to store all the form elements in
  * @param int           $locationId the locationId we are dealing with
  * @param int           $count      the number of blocks to create
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form)
 {
     $blockId = $form->get('IM_Block_Count') ? $form->get('IM_Block_Count') : 1;
     $form->applyFilter('__ALL__', 'trim');
     //IM provider select
     $form->addElement('select', "im[{$blockId}][provider_id]", '', CRM_Core_PseudoConstant::IMProvider());
     //Block type select
     $form->addElement('select', "im[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType());
     //IM box
     $form->addElement('text', "im[{$blockId}][name]", ts('Instant Messenger'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_IM', 'name'));
     //is_Primary radio
     $js = array('id' => "IM_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );');
     $form->addElement('radio', "im[{$blockId}][is_primary]", '', '', '1', $js);
 }
Esempio n. 8
0
 /**
  * build the form elements for an Website object
  *
  * @param CRM_Core_Form $form       reference to the form object
  * @param int           $blockCount block number to build
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form, $blockCount = NULL)
 {
     if (!$blockCount) {
         $blockId = $form->get('Website_Block_Count') ? $form->get('Website_Block_Count') : 1;
     } else {
         $blockId = $blockCount;
     }
     $form->applyFilter('__ALL__', 'trim');
     //Website type select
     $form->addSelect("website[{$blockId}][website_type_id]", array('entity' => 'website', 'class' => 'eight'));
     //Website box
     $form->addElement('text', "website[{$blockId}][url]", ts('Website'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) {  this.value='http://';} else return false", 'onblur' => "if ( this.value == 'http://') {  this.value='';} else return false")));
     $form->addRule("website[{$blockId}][url]", ts('Enter a valid web location beginning with \'http://\' or \'https://\'. EXAMPLE: http://www.mysite.org/'), 'url');
 }
Esempio n. 9
0
 /**
  * Build the form object elements for an Website object.
  *
  * @param CRM_Core_Form $form
  *   Reference to the form object.
  * @param int $blockCount
  *   Block number to build.
  */
 public static function buildQuickForm(&$form, $blockCount = NULL)
 {
     if (!$blockCount) {
         $blockId = $form->get('Website_Block_Count') ? $form->get('Website_Block_Count') : 1;
     } else {
         $blockId = $blockCount;
     }
     $form->applyFilter('__ALL__', 'trim');
     //Website type select
     $form->addField("website[{$blockId}][website_type_id]", array('entity' => 'website', 'class' => 'eight'));
     //Website box
     $form->addField("website[{$blockId}][url]", array('entity' => 'website'));
     $form->addRule("website[{$blockId}][url]", ts('Enter a valid web address beginning with \'http://\' or \'https://\'.'), 'url');
 }
Esempio n. 10
0
 /**
  * Build the form object elements for an email object.
  *
  * @param CRM_Core_Form $form
  *   Reference to the form object.
  * @param int $blockCount
  *   Block number to build.
  * @param bool $blockEdit
  *   Is it block edit.
  */
 public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE)
 {
     // passing this via the session is AWFUL. we need to fix this
     if (!$blockCount) {
         $blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1;
     } else {
         $blockId = $blockCount;
     }
     $form->applyFilter('__ALL__', 'trim');
     //Email box
     $form->addField("email[{$blockId}][email]", array('entity' => 'email'));
     $form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email');
     if (isset($form->_contactType) || $blockEdit) {
         //Block type
         $form->addField("email[{$blockId}][location_type_id]", array('entity' => 'email', 'placeholder' => NULL, 'class' => 'eight'));
         //TODO: Refactor on_hold field to select.
         $multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail();
         //On-hold select
         if ($multipleBulk) {
             $holdOptions = array(0 => ts('- select -'), 1 => ts('On Hold Bounce'), 2 => ts('On Hold Opt Out'));
             $form->addElement('select', "email[{$blockId}][on_hold]", '', $holdOptions);
         } else {
             $form->addField("email[{$blockId}][on_hold]", array('entity' => 'email', 'type' => 'advcheckbox'));
         }
         //Bulkmail checkbox
         $form->assign('multipleBulk', $multipleBulk);
         if ($multipleBulk) {
             $js = array('id' => "Email_" . $blockId . "_IsBulkmail");
             $form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", NULL, '', $js);
         } else {
             $js = array('id' => "Email_" . $blockId . "_IsBulkmail");
             if (!$blockEdit) {
                 $js['onClick'] = 'singleSelect( this.id );';
             }
             $form->addElement('radio', "email[{$blockId}][is_bulkmail]", '', '', '1', $js);
         }
         //is_Primary radio
         $js = array('id' => "Email_" . $blockId . "_IsPrimary");
         if (!$blockEdit) {
             $js['onClick'] = 'singleSelect( this.id );';
         }
         $form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js);
         if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') {
             $form->add('textarea', "email[{$blockId}][signature_text]", ts('Signature (Text)'), array('rows' => 2, 'cols' => 40));
             $form->add('wysiwyg', "email[{$blockId}][signature_html]", ts('Signature (HTML)'), array('rows' => 2, 'cols' => 40));
         }
     }
 }
Esempio n. 11
0
 /**
  * build the form elements for an open id object
  *
  * @param CRM_Core_Form $form       reference to the form object
  * @param array         $location   the location object to store all the form elements in
  * @param int           $locationId the locationId we are dealing with
  * @param int           $count      the number of blocks to create
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form)
 {
     $blockId = $form->get('OpenID_Block_Count') ? $form->get('OpenID_Block_Count') : 1;
     $form->applyFilter('__ALL__', 'trim');
     $form->addElement('text', "openid[{$blockId}][openid]", ts('OpenID'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OpenID', 'openid'));
     $form->addRule("openid[{$blockId}][openid]", ts('OpenID is not a valid URL.'), 'url');
     //Block type
     $form->addElement('select', "openid[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType());
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework == 'Standalone') {
         $js = array('id' => "OpenID_" . $blockId . "_IsLogin", 'onClick' => 'singleSelect( this.id );');
         $form->addElement('advcheckbox', "openid[{$blockId}][allowed_to_login]", null, '', $js);
     }
     //is_Primary radio
     $js = array('id' => "OpenID_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );');
     $form->addElement('radio', "openid[{$blockId}][is_primary]", '', '', '1', $js);
 }
Esempio n. 12
0
 /**
  * This function provides the HTML form elements that are specific.
  * to the Household 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) {
         // household_name
         $form->addField('household_name');
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addField('nick_name');
         $form->addField('contact_source', array('label' => ts('Source')));
     }
     if (!$inlineEditMode) {
         $form->addField('external_identifier', array('label' => ts('External ID')));
         $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
     }
 }
Esempio n. 13
0
 /**
  * This function provides the HTML form elements that are specific.
  * to the Household 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)
 {
     $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact');
     $form->applyFilter('__ALL__', 'trim');
     if (!$inlineEditMode || $inlineEditMode == 1) {
         // household_name
         $form->add('text', 'household_name', ts('Household Name'), $attributes['household_name']);
     }
     if (!$inlineEditMode || $inlineEditMode == 2) {
         // nick_name
         $form->addElement('text', 'nick_name', ts('Nickname'), $attributes['nick_name']);
         $form->addElement('text', 'contact_source', ts('Source'), CRM_Utils_Array::value('source', $attributes));
     }
     if (!$inlineEditMode) {
         $form->add('text', 'external_identifier', ts('External ID'), $attributes['external_identifier'], FALSE);
         $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'));
     }
 }
Esempio n. 14
0
 /**
  * build the form elements for a phone object
  *
  * @param CRM_Core_Form $form       reference to the form object
  * @param array         $location   the location object to store all the form elements in
  * @param int           $locationId the locationId we are dealing with
  * @param int           $count      the number of blocks to create
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form)
 {
     $blockId = $form->get('Phone_Block_Count') ? $form->get('Phone_Block_Count') : 1;
     $form->applyFilter('__ALL__', 'trim');
     //phone type select
     $form->addElement('select', "phone[{$blockId}][phone_type_id]", ts('Phone'), CRM_Core_PseudoConstant::phoneType());
     //phone box
     $form->addElement('text', "phone[{$blockId}][phone]", ts('Phone'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
     if (isset($form->_contactType)) {
         //Block type select
         $form->addElement('select', "phone[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType());
         //is_Primary radio
         $js = array('id' => "Phone_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );');
         $form->addElement('radio', "phone[{$blockId}][is_primary]", '', '', '1', $js);
     }
     // TODO: set this up as a group, we need a valid phone_type_id if we have a  phone number
     // $form->addRule( "location[$locationId][phone][$locationId][phone]", ts('Phone number is not valid.'), 'phone' );
 }
Esempio n. 15
0
 /**
  * Build the form object elements for an open id object.
  *
  * @param CRM_Core_Form $form
  *   Reference to the form object.
  * @param int $blockCount
  *   Block number to build.
  * @param bool $blockEdit
  *   Is it block edit.
  */
 public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE)
 {
     if (!$blockCount) {
         $blockId = $form->get('OpenID_Block_Count') ? $form->get('OpenID_Block_Count') : 1;
     } else {
         $blockId = $blockCount;
     }
     $form->applyFilter('__ALL__', 'trim');
     $form->addElement('text', "openid[{$blockId}][openid]", ts('OpenID'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OpenID', 'openid'));
     $form->addRule("openid[{$blockId}][openid]", ts('OpenID is not a valid URL.'), 'url');
     //Block type
     $form->addElement('select', "openid[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'));
     //is_Primary radio
     $js = array('id' => "OpenID_" . $blockId . "_IsPrimary");
     if (!$blockEdit) {
         $js['onClick'] = 'singleSelect( this.id );';
     }
     $form->addElement('radio', "openid[{$blockId}][is_primary]", '', '', '1', $js);
 }
Esempio n. 16
0
 /**
  * build the form elements for an email object
  *
  * @param CRM_Core_Form $form       reference to the form object
  * @param array         $location   the location object to store all the form elements in
  * @param int           $locationId the locationId we are dealing with
  * @param int           $count      the number of blocks to create
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form)
 {
     $blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1;
     $form->applyFilter('__ALL__', 'trim');
     //Email box
     $form->addElement('text', "email[{$blockId}][email]", ts('Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'));
     $form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email');
     if (isset($form->_contactType)) {
         //Block type
         $form->addElement('select', "email[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::locationType());
         //On-hold checkbox
         $form->addElement('advcheckbox', "email[{$blockId}][on_hold]", null);
         //Bulkmail checkbox
         $js = array('id' => "Email_" . $blockId . "_IsBulkmail", 'onClick' => 'singleSelect( this.id );');
         $form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", null, '', $js);
         //is_Primary radio
         $js = array('id' => "Email_" . $blockId . "_IsPrimary", 'onClick' => 'singleSelect( this.id );');
         $form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js);
     }
 }
Esempio n. 17
0
 /**
  * build the form elements for an IM object
  *
  * @param CRM_Core_Form $form       reference to the form object
  * @param int           $blockCount block number to build
  * @param boolean       $blockEdit  is it block edit
  *
  * @return void
  * @access public
  * @static
  */
 static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE)
 {
     if (!$blockCount) {
         $blockId = $form->get('IM_Block_Count') ? $form->get('IM_Block_Count') : 1;
     } else {
         $blockId = $blockCount;
     }
     $form->applyFilter('__ALL__', 'trim');
     //IM provider select
     $form->addSelect("im[{$blockId}][provider_id]", array('entity' => 'im', 'class' => 'eight', 'placeholder' => NULL));
     //Block type select
     $form->addSelect("im[{$blockId}][location_type_id]", array('entity' => 'im', 'class' => 'eight', 'placeholder' => NULL));
     //IM box
     $form->addElement('text', "im[{$blockId}][name]", ts('Instant Messenger'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_IM', 'name'));
     //is_Primary radio
     $js = array('id' => 'IM_' . $blockId . '_IsPrimary');
     if (!$blockEdit) {
         $js['onClick'] = 'singleSelect( this.id );';
     }
     $form->addElement('radio', "im[{$blockId}][is_primary]", '', '', '1', $js);
 }
Esempio n. 18
0
 /**
  * Build the form object elements for a phone object.
  *
  * @param CRM_Core_Form $form
  *   Reference to the form object.
  * @param int $addressBlockCount
  *   Block number to build.
  * @param bool $blockEdit
  *   Is it block edit.
  */
 public static function buildQuickForm(&$form, $addressBlockCount = NULL, $blockEdit = FALSE)
 {
     // passing this via the session is AWFUL. we need to fix this
     if (!$addressBlockCount) {
         $blockId = $form->get('Phone_Block_Count') ? $form->get('Phone_Block_Count') : 1;
     } else {
         $blockId = $addressBlockCount;
     }
     $form->applyFilter('__ALL__', 'trim');
     //phone type select
     $form->addField("phone[{$blockId}][phone_type_id]", array('entity' => 'phone', 'class' => 'eight', 'placeholder' => NULL));
     //main phone number with crm_phone class
     $form->addField("phone[{$blockId}][phone]", array('entity' => 'phone', 'class' => 'crm_phone twelve'));
     $form->addField("phone[{$blockId}][phone_ext]", array('entity' => 'phone'));
     if (isset($form->_contactType) || $blockEdit) {
         //Block type select
         $form->addField("phone[{$blockId}][location_type_id]", array('entity' => 'phone', 'class' => 'eight', 'placeholder' => NULL));
         //is_Primary radio
         $js = array('id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
         $form->addElement('radio', "phone[{$blockId}][is_primary]", '', '', '1', $js);
     }
     // TODO: set this up as a group, we need a valid phone_type_id if we have a  phone number
     // $form->addRule( "location[$locationId][phone][$locationId][phone]", ts('Phone number is not valid.'), 'phone' );
 }
Esempio n. 19
0
 /**
  * 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));
     }
 }
Esempio n. 20
0
 /**
  * Build form elements.
  *
  * @param CRM_Core_Form $form
  */
 public static function buildQuickForm(&$form)
 {
     $form->applyFilter('__ALL__', 'trim');
     $form->addField('subject', array('entity' => 'note', 'size' => '60'));
     $form->addField('note', array('entity' => 'note', 'rows' => 3));
 }
 /**
  * Build the mapping form.
  *
  * @param CRM_Core_Form $form
  * @param string $mappingType
  *   (Export/Import/Search Builder).
  * @param int $mappingId
  * @param int $columnNo
  * @param int $blockCount
  *   (no of blocks shown).
  * @param NULL $exportMode
  *
  * @return void
  */
 public static function buildMappingForm(&$form, $mappingType = 'Export', $mappingId = NULL, $columnNo, $blockCount = 3, $exportMode = NULL)
 {
     $name = "Map";
     $columnCount = array('1' => $columnNo);
     $form->applyFilter('saveMappingName', 'trim');
     //to save the current mappings
     if (!isset($mappingId)) {
         $saveDetailsName = ts('Save this field mapping');
         $form->add('text', 'saveMappingName', ts('Name'));
         $form->add('text', 'saveMappingDesc', ts('Description'));
     } else {
         $form->assign('loadedMapping', $mappingId);
         $params = array('id' => $mappingId);
         $temp = array();
         $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
         $form->assign('savedName', $mappingDetails->name);
         $form->add('hidden', 'mappingId', $mappingId);
         $form->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
         $saveDetailsName = ts('Save as a new field mapping');
         $form->add('text', 'saveMappingName', ts('Name'));
         $form->add('text', 'saveMappingDesc', ts('Description'));
     }
     $form->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
     $form->addFormRule(array('CRM_Export_Form_Map', 'formRule'), $form->get('mappingTypeId'));
     $defaults = array();
     $hasLocationTypes = array();
     $hasRelationTypes = array();
     $fields = array();
     if ($mappingType == 'Export') {
         $required = TRUE;
     }
     $fields = CRM_Contact_BAO_Relationship::fields();
     // add custom fields
     $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Relationship'));
     ksort($fields);
     // add component fields
     $compArray = array();
     foreach ($fields as $key => $value) {
         //CRM-2676, replacing the conflict for same custom field name from different custom group.
         $customGroupName = self::getCustomGroupName($key);
         if ($customGroupName) {
             $relatedMapperFields[$key] = $mapperFields[$key] = $customGroupName . ': ' . $value['title'];
         } else {
             $relatedMapperFields[$key] = $mapperFields[$key] = $value['title'];
         }
     }
     $mapperKeys = array_keys($mapperFields);
     $sel1 = array('' => ts('- select field -')) + $mapperFields;
     if (isset($mappingId)) {
         $colCnt = 0;
         list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue) = CRM_Core_BAO_Mapping::getMappingFields($mappingId);
         $blkCnt = count($mappingName);
         if ($blkCnt >= $blockCount) {
             $blockCount = $blkCnt + 1;
         }
         for ($x = 1; $x < $blockCount; $x++) {
             if (isset($mappingName[$x])) {
                 $colCnt = count($mappingName[$x]);
                 if ($colCnt >= $columnCount[$x]) {
                     $columnCount[$x] = $colCnt;
                 }
             }
         }
     }
     $form->_blockCount = $blockCount;
     $form->_columnCount = $columnCount;
     $form->set('blockCount', $form->_blockCount);
     $form->set('columnCount', $form->_columnCount);
     $defaults = $noneArray = $nullArray = array();
     //used to warn for mismatch column count or mismatch mapping
     $warning = 0;
     for ($x = 1; $x < $blockCount; $x++) {
         for ($i = 0; $i < $columnCount[$x]; $i++) {
             $sel =& $form->addElement('hierselect', "mapper[{$x}][{$i}]", ts('Mapper for Field %1', array(1 => $i)), NULL);
             $jsSet = FALSE;
             if (isset($mappingId)) {
                 //TODO opgeslagen mappings
             }
             //Fix for Export
             $j = 7;
             $formValues = $form->exportValues();
             if (!$jsSet) {
                 if (empty($formValues)) {
                     // Incremented length for third select box(relationship type)
                     for ($k = 1; $k < $j; $k++) {
                         $noneArray[] = array($x, $i, $k);
                     }
                 } else {
                     if (!empty($formValues['mapper'][$x])) {
                         foreach ($formValues['mapper'][$x] as $value) {
                             for ($k = 1; $k < $j; $k++) {
                                 if (!isset($formValues['mapper'][$x][$i][$k]) || !$formValues['mapper'][$x][$i][$k]) {
                                     $noneArray[] = array($x, $i, $k);
                                 } else {
                                     $nullArray[] = array($x, $i, $k);
                                 }
                             }
                         }
                     } else {
                         for ($k = 1; $k < $j; $k++) {
                             $noneArray[] = array($x, $i, $k);
                         }
                     }
                 }
             }
             //Fix for Export
             $sel->setOptions(array($sel1));
         }
         $title = ts('Select more fields');
         $form->addElement('submit', "addMore[{$x}]", $title, array('class' => 'submit-link'));
     }
     //end of block for
     $js = "<script type='text/javascript'>\n";
     $formName = "document.{$name}";
     if (!empty($nullArray)) {
         $js .= "var nullArray = [";
         $elements = array();
         $seen = array();
         foreach ($nullArray as $element) {
             $key = "{$element[0]}, {$element[1]}, {$element[2]}";
             if (!isset($seen[$key])) {
                 $elements[] = "[{$key}]";
                 $seen[$key] = 1;
             }
         }
         $js .= implode(', ', $elements);
         $js .= "]";
         $js .= "\n                for (var i=0;i<nullArray.length;i++) {\n                    if ( {$formName}['mapper['+nullArray[i][0]+']['+nullArray[i][1]+']['+nullArray[i][2]+']'] ) {\n                        {$formName}['mapper['+nullArray[i][0]+']['+nullArray[i][1]+']['+nullArray[i][2]+']'].style.display = '';\n                    }\n                }\n";
     }
     if (!empty($noneArray)) {
         $js .= "var noneArray = [";
         $elements = array();
         $seen = array();
         foreach ($noneArray as $element) {
             $key = "{$element[0]}, {$element[1]}, {$element[2]}";
             if (!isset($seen[$key])) {
                 $elements[] = "[{$key}]";
                 $seen[$key] = 1;
             }
         }
         $js .= implode(', ', $elements);
         $js .= "]";
         $js .= "\n                for (var i=0;i<noneArray.length;i++) {\n                    if ( {$formName}['mapper['+noneArray[i][0]+']['+noneArray[i][1]+']['+noneArray[i][2]+']'] ) {\n  {$formName}['mapper['+noneArray[i][0]+']['+noneArray[i][1]+']['+noneArray[i][2]+']'].style.display = 'none';\n                    }\n                }\n";
     }
     $js .= "</script>\n";
     $form->assign('initHideBoxes', $js);
     $form->assign('columnCount', $columnCount);
     $form->assign('blockCount', $blockCount);
     $form->setDefaults($defaults);
     $form->setDefaultAction('refresh');
 }
Esempio n. 22
0
 /**
  * Build the mapping form.
  *
  * @param CRM_Core_Form $form
  * @param string $mappingType
  *   (Export/Import/Search Builder).
  * @param int $mappingId
  * @param int $columnNo
  * @param int $blockCount
  *   (no of blocks shown).
  * @param NULL $exportMode
  *
  * @return void
  */
 public static function buildMappingForm(&$form, $mappingType = 'Export', $mappingId = NULL, $columnNo, $blockCount = 3, $exportMode = NULL)
 {
     if ($mappingType == 'Export') {
         $name = "Map";
         $columnCount = array('1' => $columnNo);
     } elseif ($mappingType == 'Search Builder') {
         $name = "Builder";
         $columnCount = $columnNo;
     }
     //get the saved mapping details
     if ($mappingType == 'Export') {
         $form->applyFilter('saveMappingName', 'trim');
         //to save the current mappings
         if (!isset($mappingId)) {
             $saveDetailsName = ts('Save this field mapping');
             $form->add('text', 'saveMappingName', ts('Name'));
             $form->add('text', 'saveMappingDesc', ts('Description'));
         } else {
             $form->assign('loadedMapping', $mappingId);
             $params = array('id' => $mappingId);
             $temp = array();
             $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp);
             $form->assign('savedName', $mappingDetails->name);
             $form->add('hidden', 'mappingId', $mappingId);
             $form->addElement('checkbox', 'updateMapping', ts('Update this field mapping'), NULL);
             $saveDetailsName = ts('Save as a new field mapping');
             $form->add('text', 'saveMappingName', ts('Name'));
             $form->add('text', 'saveMappingDesc', ts('Description'));
         }
         $form->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)"));
         $form->addFormRule(array('CRM_Export_Form_Map', 'formRule'), $form->get('mappingTypeId'));
     } elseif ($mappingType == 'Search Builder') {
         $form->addElement('submit', 'addBlock', ts('Also include contacts where'), array('class' => 'submit-link'));
     }
     $defaults = array();
     $hasLocationTypes = array();
     $hasRelationTypes = array();
     $fields = array();
     if ($mappingType == 'Export') {
         $required = TRUE;
     } elseif ($mappingType == 'Search Builder') {
         $required = FALSE;
     }
     $contactType = array('Individual', 'Household', 'Organization');
     foreach ($contactType as $value) {
         $contactFields = CRM_Contact_BAO_Contact::exportableFields($value, FALSE, $required);
         $contactFields = array_merge($contactFields, CRM_Contact_BAO_Query_Hook::singleton()->getFields());
         // exclude the address options disabled in the Address Settings
         $fields[$value] = CRM_Core_BAO_Address::validateAddressOptions($contactFields);
         ksort($fields[$value]);
         if ($mappingType == 'Export') {
             $relationships = array();
             $relationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $value);
             asort($relationshipTypes);
             foreach ($relationshipTypes as $key => $var) {
                 list($type) = explode('_', $key);
                 $relationships[$key]['title'] = $var;
                 $relationships[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/';
                 $relationships[$key]['export'] = TRUE;
                 $relationships[$key]['relationship_type_id'] = $type;
                 $relationships[$key]['related'] = TRUE;
                 $relationships[$key]['hasRelationType'] = 1;
             }
             if (!empty($relationships)) {
                 $fields[$value] = array_merge($fields[$value], array('related' => array('title' => ts('- related contact info -'))), $relationships);
             }
         }
     }
     //get the current employer for mapping.
     if ($required) {
         $fields['Individual']['current_employer']['title'] = ts('Current Employer');
     }
     // add component fields
     $compArray = array();
     //we need to unset groups, tags, notes for component export
     if ($exportMode != CRM_Export_Form_Select::CONTACT_EXPORT) {
         foreach (array('groups', 'tags', 'notes') as $value) {
             unset($fields['Individual'][$value]);
             unset($fields['Household'][$value]);
             unset($fields['Organization'][$value]);
         }
     }
     if ($mappingType == 'Search Builder') {
         //build the common contact fields array.
         $fields['Contact'] = array();
         foreach ($fields['Individual'] as $key => $value) {
             if (!empty($fields['Household'][$key]) && !empty($fields['Organization'][$key])) {
                 $fields['Contact'][$key] = $value;
                 unset($fields['Organization'][$key], $fields['Household'][$key], $fields['Individual'][$key]);
             }
         }
         if (array_key_exists('note', $fields['Contact'])) {
             $noteTitle = $fields['Contact']['note']['title'];
             $fields['Contact']['note']['title'] = $noteTitle . ': ' . ts('Body and Subject');
             $fields['Contact']['note_body'] = array('title' => $noteTitle . ': ' . ts('Body Only'), 'name' => 'note_body');
             $fields['Contact']['note_subject'] = array('title' => $noteTitle . ': ' . ts('Subject Only'), 'name' => 'note_subject');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT) {
         if (CRM_Core_Permission::access('CiviContribute')) {
             $fields['Contribution'] = CRM_Contribute_BAO_Contribution::exportableFields();
             foreach (array('contribution_contact_id', 'contribution_soft_credit_name', 'contribution_soft_credit_amount', 'contribution_soft_credit_type', 'contribution_soft_credit_contribution_id') as $element) {
                 unset($fields['Contribution'][$element]);
             }
             $compArray['Contribution'] = ts('Contribution');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
         if (CRM_Core_Permission::access('CiviEvent')) {
             $fields['Participant'] = CRM_Event_BAO_Participant::exportableFields();
             //get the component payment fields
             if ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT) {
                 $componentPaymentFields = array();
                 foreach (CRM_Export_BAO_Export::componentPaymentFields() as $payField => $payTitle) {
                     $componentPaymentFields[$payField] = array('title' => $payTitle);
                 }
                 $fields['Participant'] = array_merge($fields['Participant'], $componentPaymentFields);
             }
             $compArray['Participant'] = ts('Participant');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::MEMBER_EXPORT) {
         if (CRM_Core_Permission::access('CiviMember')) {
             $fields['Membership'] = CRM_Member_BAO_Membership::getMembershipFields($exportMode);
             unset($fields['Membership']['membership_contact_id']);
             $compArray['Membership'] = ts('Membership');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::PLEDGE_EXPORT) {
         if (CRM_Core_Permission::access('CiviPledge')) {
             $fields['Pledge'] = CRM_Pledge_BAO_Pledge::exportableFields();
             unset($fields['Pledge']['pledge_contact_id']);
             $compArray['Pledge'] = ts('Pledge');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
         if (CRM_Core_Permission::access('CiviCase')) {
             $fields['Case'] = CRM_Case_BAO_Case::exportableFields();
             $compArray['Case'] = ts('Case');
             $fields['Activity'] = CRM_Activity_BAO_Activity::exportableFields('Case');
             $compArray['Activity'] = ts('Case Activity');
             unset($fields['Case']['case_contact_id']);
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::GRANT_EXPORT) {
         if (CRM_Core_Permission::access('CiviGrant')) {
             $fields['Grant'] = CRM_Grant_BAO_Grant::exportableFields();
             unset($fields['Grant']['grant_contact_id']);
             if ($mappingType == 'Search Builder') {
                 unset($fields['Grant']['grant_type_id']);
             }
             $compArray['Grant'] = ts('Grant');
         }
     }
     if ($mappingType == 'Search Builder' || $exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
         $fields['Activity'] = CRM_Activity_BAO_Activity::exportableFields('Activity');
         $compArray['Activity'] = ts('Activity');
     }
     //Contact Sub Type For export
     $contactSubTypes = array();
     $subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
     foreach ($subTypes as $subType => $val) {
         //adding subtype specific relationships CRM-5256
         $csRelationships = array();
         if ($mappingType == 'Export') {
             $subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], FALSE, 'label', TRUE, $subType);
             foreach ($subTypeRelationshipTypes as $key => $var) {
                 if (!array_key_exists($key, $fields[$val['parent']])) {
                     list($type) = explode('_', $key);
                     $csRelationships[$key]['title'] = $var;
                     $csRelationships[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/';
                     $csRelationships[$key]['export'] = TRUE;
                     $csRelationships[$key]['relationship_type_id'] = $type;
                     $csRelationships[$key]['related'] = TRUE;
                     $csRelationships[$key]['hasRelationType'] = 1;
                 }
             }
         }
         $fields[$subType] = $fields[$val['parent']] + $csRelationships;
         //custom fields for sub type
         $subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($subType);
         $fields[$subType] += $subTypeFields;
         if (!empty($subTypeFields) || !empty($csRelationships)) {
             $contactSubTypes[$subType] = $val['label'];
         }
     }
     unset($subTypes);
     foreach ($fields as $key => $value) {
         foreach ($value as $key1 => $value1) {
             //CRM-2676, replacing the conflict for same custom field name from different custom group.
             $customGroupName = self::getCustomGroupName($key1);
             if ($customGroupName) {
                 $relatedMapperFields[$key][$key1] = $mapperFields[$key][$key1] = $customGroupName . ': ' . $value1['title'];
             } else {
                 $relatedMapperFields[$key][$key1] = $mapperFields[$key][$key1] = $value1['title'];
             }
             if (isset($value1['hasLocationType'])) {
                 $hasLocationTypes[$key][$key1] = $value1['hasLocationType'];
             }
             if (isset($value1['hasRelationType'])) {
                 $hasRelationTypes[$key][$key1] = $value1['hasRelationType'];
                 unset($relatedMapperFields[$key][$key1]);
             }
         }
         if (array_key_exists('related', $relatedMapperFields[$key])) {
             unset($relatedMapperFields[$key]['related']);
         }
     }
     $mapperKeys = array_keys($mapperFields);
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
     $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
     // FIXME: dirty hack to make the default option show up first.  This
     // avoids a mozilla browser bug with defaults on dynamically constructed
     // selector widgets.
     if ($defaultLocationType) {
         $defaultLocation = $locationTypes[$defaultLocationType->id];
         unset($locationTypes[$defaultLocationType->id]);
         $locationTypes = array($defaultLocationType->id => $defaultLocation) + $locationTypes;
     }
     $locationTypes = array(' ' => ts('Primary')) + $locationTypes;
     // since we need a hierarchical list to display contact types & subtypes,
     // this is what we going to display in first selector
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, FALSE);
     if ($mappingType == 'Search Builder') {
         $contactTypes = array('Contact' => ts('Contacts')) + $contactTypes;
     }
     $sel1 = array('' => ts('- select record type -')) + $contactTypes + $compArray;
     foreach ($sel1 as $key => $sel) {
         if ($key) {
             // sort everything BUT the contactType which is sorted seperately by
             // an initial commit of CRM-13278 (check ksort above)
             if (!in_array($key, $contactType)) {
                 asort($mapperFields[$key]);
             }
             $sel2[$key] = array('' => ts('- select field -')) + $mapperFields[$key];
         }
     }
     $sel3[''] = NULL;
     $sel5[''] = NULL;
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
     asort($phoneTypes);
     foreach ($sel1 as $k => $sel) {
         if ($k) {
             foreach ($locationTypes as $key => $value) {
                 if (trim($key) != '') {
                     $sel4[$k]['phone'][$key] =& $phoneTypes;
                     $sel4[$k]['im'][$key] =& $imProviders;
                 }
             }
         }
     }
     foreach ($sel1 as $k => $sel) {
         if ($k) {
             foreach ($mapperFields[$k] as $key => $value) {
                 if (isset($hasLocationTypes[$k][$key])) {
                     $sel3[$k][$key] = $locationTypes;
                 } else {
                     $sel3[$key] = NULL;
                 }
             }
         }
     }
     // Array for core fields and relationship custom data
     $relationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE);
     if ($mappingType == 'Export') {
         foreach ($sel1 as $k => $sel) {
             if ($k) {
                 foreach ($mapperFields[$k] as $field => $dontCare) {
                     if (isset($hasRelationTypes[$k][$field])) {
                         list($id, $first, $second) = explode('_', $field);
                         // FIX ME: For now let's not expose custom data related to relationship
                         $relationshipCustomFields = array();
                         //$relationshipCustomFields    = self::getRelationTypeCustomGroupData( $id );
                         //asort($relationshipCustomFields);
                         $relationshipType = new CRM_Contact_BAO_RelationshipType();
                         $relationshipType->id = $id;
                         if ($relationshipType->find(TRUE)) {
                             $direction = "contact_sub_type_{$second}";
                             if (isset($relationshipType->{$direction})) {
                                 $relatedFields = array_merge((array) $relatedMapperFields[$relationshipType->{$direction}], (array) $relationshipCustomFields);
                             } else {
                                 $target_type = 'contact_type_' . $second;
                                 $relatedFields = array_merge((array) $relatedMapperFields[$relationshipType->{$target_type}], (array) $relationshipCustomFields);
                             }
                         }
                         $relationshipType->free();
                         asort($relatedFields);
                         $sel5[$k][$field] = $relatedFields;
                     }
                 }
             }
         }
         //Location Type for relationship fields
         foreach ($sel5 as $k => $v) {
             if ($v) {
                 foreach ($v as $rel => $fields) {
                     foreach ($fields as $field => $fieldLabel) {
                         if (isset($hasLocationTypes[$k][$field])) {
                             $sel6[$k][$rel][$field] = $locationTypes;
                         }
                     }
                 }
             }
         }
         //PhoneTypes for  relationship fields
         $sel7[''] = NULL;
         foreach ($sel6 as $k => $rel) {
             if ($k) {
                 foreach ($rel as $phonekey => $phonevalue) {
                     foreach ($locationTypes as $locType => $loc) {
                         if (trim($locType) != '') {
                             $sel7[$k][$phonekey]['phone'][$locType] =& $phoneTypes;
                             $sel7[$k][$phonekey]['im'][$locType] =& $imProviders;
                         }
                     }
                 }
             }
         }
     }
     //special fields that have location, hack for primary location
     $specialFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'phone', 'email', 'im');
     if (isset($mappingId)) {
         $colCnt = 0;
         list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, $mappingRelation, $mappingOperator, $mappingValue) = CRM_Core_BAO_Mapping::getMappingFields($mappingId);
         $blkCnt = count($mappingName);
         if ($blkCnt >= $blockCount) {
             $blockCount = $blkCnt + 1;
         }
         for ($x = 1; $x < $blockCount; $x++) {
             if (isset($mappingName[$x])) {
                 $colCnt = count($mappingName[$x]);
                 if ($colCnt >= $columnCount[$x]) {
                     $columnCount[$x] = $colCnt;
                 }
             }
         }
     }
     $form->_blockCount = $blockCount;
     $form->_columnCount = $columnCount;
     $form->set('blockCount', $form->_blockCount);
     $form->set('columnCount', $form->_columnCount);
     $defaults = $noneArray = $nullArray = array();
     //used to warn for mismatch column count or mismatch mapping
     $warning = 0;
     for ($x = 1; $x < $blockCount; $x++) {
         for ($i = 0; $i < $columnCount[$x]; $i++) {
             $sel =& $form->addElement('hierselect', "mapper[{$x}][{$i}]", ts('Mapper for Field %1', array(1 => $i)), NULL);
             $jsSet = FALSE;
             if (isset($mappingId)) {
                 $locationId = isset($mappingLocation[$x][$i]) ? $mappingLocation[$x][$i] : 0;
                 if (isset($mappingName[$x][$i])) {
                     if (is_array($mapperFields[$mappingContactType[$x][$i]])) {
                         if (isset($mappingRelation[$x][$i])) {
                             $contactDetails = strtolower(str_replace(" ", "_", $mappingName[$x][$i]));
                             $relLocationId = isset($mappingLocation[$x][$i]) ? $mappingLocation[$x][$i] : 0;
                             if (!$relLocationId && in_array($mappingName[$x][$i], $specialFields)) {
                                 $relLocationId = " ";
                             }
                             $relPhoneType = isset($mappingPhoneType[$x][$i]) ? $mappingPhoneType[$x][$i] : NULL;
                             $defaults["mapper[{$x}][{$i}]"] = array($mappingContactType[$x][$i], $mappingRelation[$x][$i], $locationId, $phoneType, $mappingName[$x][$i], $relLocationId, $relPhoneType);
                             if (!$locationId) {
                                 $noneArray[] = array($x, $i, 2);
                             }
                             if (!$phoneType && !$imProvider) {
                                 $noneArray[] = array($x, $i, 3);
                             }
                             if (!$mappingName[$x][$i]) {
                                 $noneArray[] = array($x, $i, 4);
                             }
                             if (!$relLocationId) {
                                 $noneArray[] = array($x, $i, 5);
                             }
                             if (!$relPhoneType) {
                                 $noneArray[] = array($x, $i, 6);
                             }
                             $noneArray[] = array($x, $i, 2);
                         } else {
                             $phoneType = isset($mappingPhoneType[$x][$i]) ? $mappingPhoneType[$x][$i] : NULL;
                             $imProvider = isset($mappingImProvider[$x][$i]) ? $mappingImProvider[$x][$i] : NULL;
                             if (!$locationId && in_array($mappingName[$x][$i], $specialFields)) {
                                 $locationId = " ";
                             }
                             $defaults["mapper[{$x}][{$i}]"] = array($mappingContactType[$x][$i], $mappingName[$x][$i], $locationId, $phoneType);
                             if (!$mappingName[$x][$i]) {
                                 $noneArray[] = array($x, $i, 1);
                             }
                             if (!$locationId) {
                                 $noneArray[] = array($x, $i, 2);
                             }
                             if (!$phoneType && !$imProvider) {
                                 $noneArray[] = array($x, $i, 3);
                             }
                             $noneArray[] = array($x, $i, 4);
                             $noneArray[] = array($x, $i, 5);
                             $noneArray[] = array($x, $i, 6);
                         }
                         $jsSet = TRUE;
                         if (CRM_Utils_Array::value($i, CRM_Utils_Array::value($x, $mappingOperator))) {
                             $defaults["operator[{$x}][{$i}]"] = CRM_Utils_Array::value($i, $mappingOperator[$x]);
                         }
                         if (CRM_Utils_Array::value($i, CRM_Utils_Array::value($x, $mappingValue))) {
                             $defaults["value[{$x}][{$i}]"] = CRM_Utils_Array::value($i, $mappingValue[$x]);
                         }
                     }
                 }
             }
             //Fix for Search Builder
             if ($mappingType == 'Export') {
                 $j = 7;
             } else {
                 $j = 4;
             }
             $formValues = $form->exportValues();
             if (!$jsSet) {
                 if (empty($formValues)) {
                     // Incremented length for third select box(relationship type)
                     for ($k = 1; $k < $j; $k++) {
                         $noneArray[] = array($x, $i, $k);
                     }
                 } else {
                     if (!empty($formValues['mapper'][$x])) {
                         foreach ($formValues['mapper'][$x] as $value) {
                             for ($k = 1; $k < $j; $k++) {
                                 if (!isset($formValues['mapper'][$x][$i][$k]) || !$formValues['mapper'][$x][$i][$k]) {
                                     $noneArray[] = array($x, $i, $k);
                                 } else {
                                     $nullArray[] = array($x, $i, $k);
                                 }
                             }
                         }
                     } else {
                         for ($k = 1; $k < $j; $k++) {
                             $noneArray[] = array($x, $i, $k);
                         }
                     }
                 }
             }
             //Fix for Search Builder
             if ($mappingType == 'Export') {
                 if (!isset($mappingId) || $i >= count(reset($mappingName))) {
                     if (isset($formValues['mapper']) && isset($formValues['mapper'][$x][$i][1]) && array_key_exists($formValues['mapper'][$x][$i][1], $relationshipTypes)) {
                         $sel->setOptions(array($sel1, $sel2, $sel5, $sel6, $sel7, $sel3, $sel4));
                     } else {
                         $sel->setOptions(array($sel1, $sel2, $sel3, $sel4, $sel5, $sel6, $sel7));
                     }
                 } else {
                     $sel->setOptions(array($sel1, $sel2, $sel3, $sel4, $sel5, $sel6, $sel7));
                 }
             } else {
                 $sel->setOptions(array($sel1, $sel2, $sel3, $sel4));
             }
             if ($mappingType == 'Search Builder') {
                 //CRM -2292, restricted array set
                 $operatorArray = array('' => ts('-operator-')) + CRM_Core_SelectValues::getSearchBuilderOperators();
                 $form->add('select', "operator[{$x}][{$i}]", '', $operatorArray);
                 $form->add('text', "value[{$x}][{$i}]", '');
             }
         }
         //end of columnCnt for
         if ($mappingType == 'Search Builder') {
             $title = ts('Another search field');
         } else {
             $title = ts('Select more fields');
         }
         $form->addElement('submit', "addMore[{$x}]", $title, array('class' => 'submit-link'));
     }
     //end of block for
     $js = "<script type='text/javascript'>\n";
     $formName = "document.{$name}";
     if (!empty($nullArray)) {
         $js .= "var nullArray = [";
         $elements = array();
         $seen = array();
         foreach ($nullArray as $element) {
             $key = "{$element[0]}, {$element[1]}, {$element[2]}";
             if (!isset($seen[$key])) {
                 $elements[] = "[{$key}]";
                 $seen[$key] = 1;
             }
         }
         $js .= implode(', ', $elements);
         $js .= "]";
         $js .= "\n                for (var i=0;i<nullArray.length;i++) {\n                    if ( {$formName}['mapper['+nullArray[i][0]+']['+nullArray[i][1]+']['+nullArray[i][2]+']'] ) {\n                        {$formName}['mapper['+nullArray[i][0]+']['+nullArray[i][1]+']['+nullArray[i][2]+']'].style.display = '';\n                    }\n                }\n";
     }
     if (!empty($noneArray)) {
         $js .= "var noneArray = [";
         $elements = array();
         $seen = array();
         foreach ($noneArray as $element) {
             $key = "{$element[0]}, {$element[1]}, {$element[2]}";
             if (!isset($seen[$key])) {
                 $elements[] = "[{$key}]";
                 $seen[$key] = 1;
             }
         }
         $js .= implode(', ', $elements);
         $js .= "]";
         $js .= "\n                for (var i=0;i<noneArray.length;i++) {\n                    if ( {$formName}['mapper['+noneArray[i][0]+']['+noneArray[i][1]+']['+noneArray[i][2]+']'] ) {\n  {$formName}['mapper['+noneArray[i][0]+']['+noneArray[i][1]+']['+noneArray[i][2]+']'].style.display = 'none';\n                    }\n                }\n";
     }
     $js .= "</script>\n";
     $form->assign('initHideBoxes', $js);
     $form->assign('columnCount', $columnCount);
     $form->assign('blockCount', $blockCount);
     $form->setDefaults($defaults);
     $form->setDefaultAction('refresh');
 }
Esempio n. 23
0
 /**
  * @param CRM_Core_Form $form
  */
 public function buildForm(&$form)
 {
     $config = CRM_Core_Config::singleton();
     $form->applyFilter('__ALL__', 'trim');
     $form->add('text', 'text', ts('Find'), TRUE);
     // also add a select box to allow the search to be constrained
     $tables = array('' => ts('All tables'));
     foreach ($this->_partialQueries as $partialQuery) {
         /** @var $partialQuery CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery */
         if ($partialQuery->isActive()) {
             $tables[$partialQuery->getName()] = $partialQuery->getLabel();
         }
     }
     $form->add('select', 'table', ts('Tables'), $tables);
     $form->assign('csID', $form->get('csid'));
     // also add the limit constant
     $form->assign('limit', self::LIMIT);
     // set form defaults
     if (!empty($form->_formValues)) {
         $defaults = array();
         if (isset($form->_formValues['text'])) {
             $defaults['text'] = $form->_formValues['text'];
         }
         if (isset($form->_formValues['table'])) {
             $defaults['table'] = $form->_formValues['table'];
             $form->assign('table', $form->_formValues['table']);
         }
         $form->setDefaults($defaults);
     }
     /**
      * You can define a custom title for the search form
      */
     $this->setTitle(ts('Full-text Search'));
     $searchService = CRM_Core_BAO_File::getSearchService();
     $form->assign('allowFileSearch', !empty($searchService) && CRM_Core_Permission::check('access uploaded files'));
 }