From: Tim Otten Date: Tue, 6 Jan 2015 21:09:20 +0000 (-0800) Subject: INFRA-132 - CRM/Custom - phpcbf X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e8646905c58d7a2d23962482b6ada14c39fff249;p=civicrm-core.git INFRA-132 - CRM/Custom - phpcbf --- diff --git a/CRM/Custom/Form/ChangeFieldType.php b/CRM/Custom/Form/ChangeFieldType.php index 64edf894c0..d6f4544374 100644 --- a/CRM/Custom/Form/ChangeFieldType.php +++ b/CRM/Custom/Form/ChangeFieldType.php @@ -272,7 +272,8 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { continue; } $value = CRM_Core_DAO::VALUE_SEPARATOR . $dao->{$column} . CRM_Core_DAO::VALUE_SEPARATOR; - $params = array(1 => array((string)$value, 'String'), + $params = array( + 1 => array((string) $value, 'String'), 2 => array($dao->id, 'Integer'), ); CRM_Core_DAO::executeQuery($updateSql, $params); @@ -289,7 +290,8 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { $dao = CRM_Core_DAO::executeQuery($selectSql); while ($dao->fetch()) { $values = self::explode($dao->{$column}); - $params = array(1 => array((string)array_shift($values), 'String'), + $params = array( + 1 => array((string) array_shift($values), 'String'), 2 => array($dao->id, 'Integer'), ); CRM_Core_DAO::executeQuery($updateSql, $params); diff --git a/CRM/Custom/Form/CustomData.php b/CRM/Custom/Form/CustomData.php index 62738b6749..4fbb0f69c3 100644 --- a/CRM/Custom/Form/CustomData.php +++ b/CRM/Custom/Form/CustomData.php @@ -43,7 +43,7 @@ class CRM_Custom_Form_CustomData { * @param null|string $subName * @param null|string $subType * @param null|int $groupCount - * @param null|String $type + * @param string $type * @param null|int $entityID * @param null $onlySubType * diff --git a/CRM/Custom/Form/DeleteField.php b/CRM/Custom/Form/DeleteField.php index d7abf16031..b531dc0dda 100644 --- a/CRM/Custom/Form/DeleteField.php +++ b/CRM/Custom/Form/DeleteField.php @@ -63,7 +63,6 @@ class CRM_Custom_Form_DeleteField extends CRM_Core_Form { public function preProcess() { $this->_id = $this->get('id'); - $defaults = array(); $params = array('id' => $this->_id); CRM_Core_BAO_CustomField::retrieve($params, $defaults); diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 0af9ef704d..b40f7ddb85 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -132,18 +132,28 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { if (self::$_dataToLabels == NULL) { self::$_dataToLabels = array( - array('Text' => ts('Text'), 'Select' => ts('Select'), - 'Radio' => ts('Radio'), 'CheckBox' => ts('CheckBox'), 'Multi-Select' => ts('Multi-Select'), + array( + 'Text' => ts('Text'), + 'Select' => ts('Select'), + 'Radio' => ts('Radio'), + 'CheckBox' => ts('CheckBox'), + 'Multi-Select' => ts('Multi-Select'), 'AdvMulti-Select' => ts('Adv Multi-Select (obsolete)'), 'Autocomplete-Select' => ts('Autocomplete-Select'), ), - array('Text' => ts('Text'), 'Select' => ts('Select'), + array( + 'Text' => ts('Text'), + 'Select' => ts('Select'), 'Radio' => ts('Radio'), ), - array('Text' => ts('Text'), 'Select' => ts('Select'), + array( + 'Text' => ts('Text'), + 'Select' => ts('Select'), 'Radio' => ts('Radio'), ), - array('Text' => ts('Text'), 'Select' => ts('Select'), + array( + 'Text' => ts('Text'), + 'Select' => ts('Select'), 'Radio' => ts('Radio'), ), array('TextArea' => ts('TextArea'), 'RichTextEditor' => ts('Rich Text Editor')), @@ -322,7 +332,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $optionTypes = array('1' => ts('Create a new set of options')); } else { - $optionTypes = array('1' => ts('Create a new set of options'), + $optionTypes = array( + '1' => ts('Create a new set of options'), '2' => ts('Reuse an existing set'), ); @@ -341,7 +352,6 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { 'onclick' => "showOptionSelect();"), '
' ); - $contactGroups = CRM_Core_PseudoConstant::group(); asort($contactGroups); @@ -575,9 +585,10 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $name = CRM_Utils_String::munge($title, '_', 64); $gId = $self->_gid; // CRM-7564 $query = 'select count(*) from civicrm_custom_field where ( name like %1 OR label like %2 ) and id != %3 and custom_group_id = %4'; - $fldCnt = CRM_Core_DAO::singleValueQuery($query, array(1 => array($name, 'String'), + $fldCnt = CRM_Core_DAO::singleValueQuery($query, array( + 1 => array($name, 'String'), 2 => array($title, 'String'), - 3 => array((int)$self->_id, 'Integer'), + 3 => array((int) $self->_id, 'Integer'), 4 => array($gId, 'Integer'), )); if ($fldCnt) { diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index 4153d002c6..a3d623ba10 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -124,9 +124,10 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $title = $fields['title']; $name = CRM_Utils_String::munge($title, '_', 64); $query = 'select count(*) from civicrm_custom_group where ( name like %1 OR title like %2 ) and id != %3'; - $grpCnt = CRM_Core_DAO::singleValueQuery($query, array(1 => array($name, 'String'), + $grpCnt = CRM_Core_DAO::singleValueQuery($query, array( + 1 => array($name, 'String'), 2 => array($title, 'String'), - 3 => array((int)$self->_id, 'Integer'), + 3 => array((int) $self->_id, 'Integer'), )); if ($grpCnt) { $errors['title'] = ts('Custom group \'%1\' already exists in Database.', array(1 => $title)); @@ -149,7 +150,7 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { } if (!empty($fields['is_multiple'])) { - $self->assign('showMultiple', TRUE); + $self->assign('showMultiple', TRUE); } if (empty($fields['is_multiple']) && $fields['style'] == 'Tab with table') { diff --git a/CRM/Custom/Form/Option.php b/CRM/Custom/Form/Option.php index ad68ce8301..30a5d7443b 100644 --- a/CRM/Custom/Form/Option.php +++ b/CRM/Custom/Form/Option.php @@ -218,7 +218,6 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { ) ); - // if view mode pls freeze it with the done button. if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); diff --git a/CRM/Custom/Import/Form/MapField.php b/CRM/Custom/Import/Form/MapField.php index eef135f941..319cac424c 100644 --- a/CRM/Custom/Import/Form/MapField.php +++ b/CRM/Custom/Import/Form/MapField.php @@ -52,7 +52,7 @@ class CRM_Custom_Import_Form_MapField extends CRM_Contact_Import_Form_MapField { public function buildQuickForm() { parent::buildQuickForm(); $this->addFormRule(array('CRM_Custom_Import_Form_MapField', 'formRule')); - } + } /** * Global validation rules for the form diff --git a/CRM/Custom/Import/Parser.php b/CRM/Custom/Import/Parser.php index ad9aff845b..e08e3a7520 100644 --- a/CRM/Custom/Import/Parser.php +++ b/CRM/Custom/Import/Parser.php @@ -243,7 +243,6 @@ abstract class CRM_Custom_Import_Parser extends CRM_Contact_Import_Parser { fclose($fd); - if ($mode == self::MODE_PREVIEW || $mode == self::MODE_IMPORT) { $customHeaders = $mapper; diff --git a/CRM/Custom/Import/Parser/Api.php b/CRM/Custom/Import/Parser/Api.php index 3905d638ac..e638069085 100644 --- a/CRM/Custom/Import/Parser/Api.php +++ b/CRM/Custom/Import/Parser/Api.php @@ -82,43 +82,43 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { * @see CRM_Custom_Import_Parser_BaseClass::summary() */ public function summary(&$values) { - $erroneousField = NULL; - $response = $this->setActiveFieldValues($values, $erroneousField); - $errorRequired = FALSE; - $missingField = ''; - $this->_params = &$this->getActiveFieldParams(); - - $formatted = $this->_params; - $this->_updateWithId = FALSE; - $this->_parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'), FALSE); - - $this->_params = $this->getActiveFieldParams(); - foreach ($this->_requiredFields as $requiredField) { - if (empty($this->_params[$requiredField])) { - $errorRequired = TRUE; - $missingField .= ' ' . $requiredField; - CRM_Contact_Import_Parser_Contact::addToErrorMsg($this->_entity, $requiredField); - } - } - - if ($errorRequired) { - array_unshift($values, ts('Missing required field(s) :') . $missingField); - return CRM_Import_Parser::ERROR; - } - - $errorMessage = NULL; - - $contactType = $this->_contactType ? $this->_contactType : 'Organization'; - CRM_Contact_Import_Parser_Contact::isErrorInCustomData($this->_params , $errorMessage, $contactType, NULL); - - // pseudoconstants - if ($errorMessage) { - $tempMsg = "Invalid value for field(s) : $errorMessage"; - array_unshift($values, $tempMsg); - $errorMessage = NULL; - return CRM_Import_Parser::ERROR; - } - return CRM_Import_Parser::VALID; + $erroneousField = NULL; + $response = $this->setActiveFieldValues($values, $erroneousField); + $errorRequired = FALSE; + $missingField = ''; + $this->_params = &$this->getActiveFieldParams(); + + $formatted = $this->_params; + $this->_updateWithId = FALSE; + $this->_parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options'), FALSE); + + $this->_params = $this->getActiveFieldParams(); + foreach ($this->_requiredFields as $requiredField) { + if (empty($this->_params[$requiredField])) { + $errorRequired = TRUE; + $missingField .= ' ' . $requiredField; + CRM_Contact_Import_Parser_Contact::addToErrorMsg($this->_entity, $requiredField); + } + } + + if ($errorRequired) { + array_unshift($values, ts('Missing required field(s) :') . $missingField); + return CRM_Import_Parser::ERROR; + } + + $errorMessage = NULL; + + $contactType = $this->_contactType ? $this->_contactType : 'Organization'; + CRM_Contact_Import_Parser_Contact::isErrorInCustomData($this->_params, $errorMessage, $contactType, NULL); + + // pseudoconstants + if ($errorMessage) { + $tempMsg = "Invalid value for field(s) : $errorMessage"; + array_unshift($values, $tempMsg); + $errorMessage = NULL; + return CRM_Import_Parser::ERROR; + } + return CRM_Import_Parser::VALID; } /** @@ -155,7 +155,7 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { $formatted['id'] = $this->_params['contact_id']; $setDateFields = array_intersect_key($this->_params, array_flip($this->_dateFields)); - CRM_Contact_Import_Parser_Contact::formatCommonData($this->_params, $formatted, $formatted) ; + CRM_Contact_Import_Parser_Contact::formatCommonData($this->_params, $formatted, $formatted); foreach($formatted['custom'] as $key => $val) { $this->_params['custom_'.$key] = $val[-1]['value']; } @@ -203,7 +203,8 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { * * @return void */ - public function fini() {} + public function fini() { + } /** * Return the field ids and names (with groups) for import purpose. @@ -215,7 +216,7 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { * * @static */ - public function getGroupFieldsForImport( $id ) { + public function getGroupFieldsForImport($id) { $importableFields = array(); $params = array('custom_group_id' => $id); $allFields = civicrm_api3('custom_field', 'get', $params); diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index fdd68e5773..97af1b2a63 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -231,7 +231,6 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { */ public function run() { - $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0 ); diff --git a/CRM/Custom/Page/Group.php b/CRM/Custom/Page/Group.php index 8a9d732bfa..ed5595d8c2 100644 --- a/CRM/Custom/Page/Group.php +++ b/CRM/Custom/Page/Group.php @@ -244,7 +244,7 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { $subTypes = array(); $subTypes['Activity'] = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE); - $subTypes['Contribution'] = CRM_Contribute_PseudoConstant::financialType( ); + $subTypes['Contribution'] = CRM_Contribute_PseudoConstant::financialType( ); $subTypes['Membership'] = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE); $subTypes['Event'] = CRM_Core_OptionGroup::values('event_type'); $subTypes['Grant'] = CRM_Core_OptionGroup::values('grant_type'); @@ -257,7 +257,6 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { $subTypes['Household'] = CRM_Contact_BAO_ContactType::subTypePairs('Household', FALSE, NULL); $subTypes['Organization'] = CRM_Contact_BAO_ContactType::subTypePairs('Organization', FALSE, NULL); - $relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Individual'); $relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Organization'); $relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Household'); diff --git a/CRM/Custom/Page/Option.php b/CRM/Custom/Page/Option.php index 04b4dfa163..a12afd0f73 100644 --- a/CRM/Custom/Page/Option.php +++ b/CRM/Custom/Page/Option.php @@ -141,7 +141,8 @@ class CRM_Custom_Page_Option extends CRM_Core_Page { SELECT id, label FROM civicrm_custom_field WHERE option_group_id = %1"; - $params = array(1 => array($optionGroupID, 'Integer'), + $params = array( + 1 => array($optionGroupID, 'Integer'), 2 => array($this->_fid, 'Integer'), ); $dao = CRM_Core_DAO::executeQuery($query, $params); @@ -282,7 +283,8 @@ ORDER BY weight, label } //as url contain $gid so append breadcrumb dynamically. - $breadcrumb = array(array('title' => ts('Custom Data Fields'), + $breadcrumb = array(array( + 'title' => ts('Custom Data Fields'), 'url' => CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&gid=' . $this->_gid), )); CRM_Utils_System::appendBreadCrumb($breadcrumb); @@ -308,10 +310,8 @@ ORDER BY weight, label $this, FALSE, 0 ); - // what action to take ? - if (($action & - (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | + if (($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::VIEW | CRM_Core_Action::DELETE ) ) ||