X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FForm%2FContact.php;h=2efd276617f2072121acc07a188759481db118da;hb=307f2fed1913bd66a833fc947e1ab8bd01c8cab5;hp=2ca53a78969caa36deb6f003306714c64256a195;hpb=14587a78e3e7b90d9a139f38593ae0e87c8f609d;p=civicrm-core.git diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index 2ca53a7896..2efd276617 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -1,7 +1,7 @@ _action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); $this->_dedupeButtonName = $this->getButtonName('refresh', 'dedupe'); @@ -385,14 +382,13 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { } /** - * This function sets the default values for the form. Note that in edit/view mode + * Set default values for the form. Note that in edit/view mode * the default values are retrieved from the database * - * @access public * * @return void */ - function setDefaultValues() { + public function setDefaultValues() { $defaults = $this->_values; $params = array(); @@ -454,11 +450,11 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { } /** - * do the set default related to location type id, + * Do the set default related to location type id, * primary location, default country * */ - function blockSetDefaults(&$defaults) { + public function blockSetDefaults(&$defaults) { $locationTypeKeys = array_filter(array_keys(CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id')), 'is_int'); sort($locationTypeKeys); @@ -551,23 +547,6 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $defaults[$name][1]['is_primary'] = TRUE; } } - - // set defaults for country-state widget - if (!empty($defaults['address']) && is_array($defaults['address'])) { - foreach ($defaults['address'] as $blockId => $values) { - CRM_Contact_Form_Edit_Address::fixStateSelect($this, - "address[$blockId][country_id]", - "address[$blockId][state_province_id]", - "address[$blockId][county_id]", - CRM_Utils_Array::value('country_id', - $values, $config->defaultContactCountry - ), - CRM_Utils_Array::value('state_province_id', - $values, $config->defaultContactStateProvince - ) - ); - } - } } /** @@ -575,10 +554,9 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { * All local rules are added near the element * * @return void - * @access public * @see valid_date */ - function addRules() { + public function addRules() { // skip adding formRules when custom data is build if ($this->_addBlockName || ($this->_action & CRM_Core_Action::DELETE)) { return; @@ -601,16 +579,15 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { } /** - * global validation rules for the form + * Global validation rules for the form * * @param array $fields posted values of the form * @param array $errors list of errors to be posted back to the form * @param int $contactId contact id if doing update. * * @return bool $primaryID email/openId@static - * @access public */ - static function formRule($fields, &$errors, $contactId = NULL) { + public static function formRule($fields, &$errors, $contactId = NULL) { $config = CRM_Core_Config::singleton(); // validations. @@ -732,10 +709,9 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { } /** - * Function to actually build the form + * Build the form object * * @return void - * @access public */ public function buildQuickForm() { //load form for child blocks @@ -839,16 +815,18 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 'subName' => 'view', 'isDefault' => TRUE, ), - array( + ); + if (CRM_Core_Permission::check('add contacts')) { + $buttons[] = array( 'type' => 'upload', 'name' => ts('Save and New'), 'spacing' => '                 ', 'subName' => 'new', - ), - array( - 'type' => 'cancel', - 'name' => ts('Cancel'), - ), + ); + } + $buttons[] = array( + 'type' => 'cancel', + 'name' => ts('Cancel'), ); if (!empty($this->_values['contact_sub_type'])) { @@ -864,7 +842,6 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { /** * Form submission of new/edit contact is processed. * - * @access public * * @return void */ @@ -1075,15 +1052,14 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { } /** - * is there any real significant data in the hierarchical location array + * Is there any real significant data in the hierarchical location array * * @param array $fields the hierarchical value representation of this location * * @return boolean true if data exists, false otherwise * @static - * @access public */ - static function blockDataExists(&$fields) { + public static function blockDataExists(&$fields) { if (!is_array($fields)) { return FALSE; } @@ -1119,16 +1095,15 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { } /** - * Function to that checks for duplicate contacts + * That checks for duplicate contacts * * @param array $fields fields array which are submitted * @param $errors * @param int $contactID contact id * @param string $contactType contact type * - * @internal param array $error error message array */ - static function checkDuplicateContacts(&$fields, &$errors, $contactID, $contactType) { + public static function checkDuplicateContacts(&$fields, &$errors, $contactID, $contactType) { // if this is a forced save, ignore find duplicate rule if (empty($fields['_qf_Contact_upload_duplicate'])) { @@ -1191,13 +1166,9 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { /** * Use the form name to create the tpl file name * - * @return string - * @access public - */ - /** * @return string */ - function getTemplateFileName() { + public function getTemplateFileName() { if ($this->_contactSubType) { $templateFile = "CRM/Contact/Form/Edit/SubType/{$this->_contactSubType}.tpl"; $template = CRM_Core_Form::getTemplate(); @@ -1214,13 +1185,11 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { * This function either parse street address in to child * elements or build street address from child elements. * - * @params $params an array of key value consist of address blocks. - * - * @param $params + * @param $params array of key value consist of address blocks. * * @return array $parseSuccess as array of sucess/fails for each address block@static */ - function parseAddress(&$params) { + public function parseAddress(&$params) { $parseSuccess = $parsedFields = array(); if (!is_array($params['address']) || CRM_Utils_System::isNull($params['address']) @@ -1298,14 +1267,14 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { } /** - * check parse result and if some address block fails then this + * Check parse result and if some address block fails then this * function return the status message for all address blocks. * * @param $parseResult an array of address blk instance and its status. * * @return null|string $statusMsg string status message for all address blocks.@static */ - static function parseAddressStatusMsg($parseResult) { + public static function parseAddressStatusMsg($parseResult) { $statusMsg = NULL; if (!is_array($parseResult) || empty($parseResult)) { return $statusMsg; @@ -1336,7 +1305,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { * @return ordinal number for given number. * @static */ - static function ordinalNumber($number) { + public static function ordinalNumber($number) { if (empty($number)) { return NULL; } @@ -1371,7 +1340,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { * * @return null|string $updateMembershipMsg string status message for updated membership. */ - function updateMembershipStatus($deceasedParams) { + public function updateMembershipStatus($deceasedParams) { $updateMembershipMsg = NULL; $contactId = CRM_Utils_Array::value('contact_id', $deceasedParams); $deceasedDate = CRM_Utils_Array::value('deceased_date', $deceasedParams); @@ -1459,4 +1428,3 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { return $updateMembershipMsg; } } -