/** * 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 */ function buildIMBlock(&$form, &$location, $locationId, $count) { for ($i = 1; $i <= $count; $i++) { $label = $i == 1 ? ts('Instant Messenger (preferred)') : ts('Instant Messenger'); CRM_Core_ShowHideBlocks::linksForArray($form, $i, $count, "location[{$locationId}][im]", ts('another IM'), ts('hide this IM')); $location[$locationId]['im'][$i]['service_id'] = $form->addElement('select', "location[{$locationId}][im][{$i}][provider_id]", $label, array('' => ts('- select service -')) + CRM_Core_PseudoConstant::IMProvider()); $location[$locationId]['im'][$i]['name'] = $form->addElement('text', "location[{$locationId}][im][{$i}][name]", null, CRM_Core_DAO::getAttribute('CRM_Core_DAO_IM', 'name')); } }
/** * 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 */ function buildEmailBlock(&$form, &$location, $locationId, $count) { for ($i = 1; $i <= $count; $i++) { $label = $i == 1 ? ts('Email (preferred)') : ts('Email'); CRM_Core_ShowHideBlocks::linksForArray($form, $i, $count, "location[{$locationId}][email]", ts('another email'), ts('hide this email')); $location[$locationId]['email'][$i]['email'] = $form->addElement('text', "location[{$locationId}][email][{$i}][email]", $label, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email')); $form->addRule("location[{$locationId}][email][{$i}][email]", ts('Email is not valid.'), 'email'); } }
/** * 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 */ function buildPhoneBlock(&$form, &$location, $locationId, $count) { for ($i = 1; $i <= $count; $i++) { $label = $i == 1 ? ts('Phone (preferred)') : ts('Phone'); CRM_Core_ShowHideBlocks::linksForArray($form, $i, $count, "location[{$locationId}][phone]", ts('another phone'), ts('hide this phone')); $location[$locationId]['phone'][$i]['phone_type'] = $form->addElement('select', "location[{$locationId}][phone][{$i}][phone_type]", null, CRM_Core_SelectValues::phoneType()); $location[$locationId]['phone'][$i]['phone'] = $form->addElement('text', "location[{$locationId}][phone][{$i}][phone]", $label, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone')); // 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][$i][phone]", ts('Phone number is not valid.'), 'phone' ); } }
/** * function to build location block * * @param object $form the object of the form (QF Object) * @param int $maxLocationBlocks no of location blocks * * @static * @access public */ function &buildLocationBlock(&$form, $maxLocationBlocks) { $location = array(); for ($locationId = 1; $locationId <= $maxLocationBlocks; $locationId++) { $location[$locationId]['location_type_id'] = $form->addElement('select', "location[{$locationId}][location_type_id]", null, CRM_Core_PseudoConstant::locationType()); $location[$locationId]['is_primary'] = $form->addElement('checkbox', "location[{$locationId}][is_primary]", ts('Primary location for this contact'), ts('Primary location for this contact'), array('onchange' => "location_is_primary_onclick('" . $form->getName() . "', {$locationId}, {$maxLocationBlocks});")); $location[$locationId]['name'] = $form->addElement('text', "location[{$locationId}][name]", ts('Location Name'), CRM_Core_PseudoConstant::locationType()); CRM_Contact_Form_Address::buildAddressBlock($form, $location, $locationId); CRM_Contact_Form_Phone::buildPhoneBlock($form, $location, $locationId, CRM_CONTACT_FORM_LOCATION_BLOCKS); CRM_Contact_Form_Email::buildEmailBlock($form, $location, $locationId, CRM_CONTACT_FORM_LOCATION_BLOCKS); CRM_Contact_Form_IM::buildIMBlock($form, $location, $locationId, CRM_CONTACT_FORM_LOCATION_BLOCKS); CRM_Core_ShowHideBlocks::linksForArray($form, $locationId, $maxLocationBlocks, "location", '', ''); } return $location; }