From: Monish Deb Date: Mon, 14 Mar 2016 12:54:59 +0000 (+0530) Subject: Merge pull request #7969 from monishdeb/CRM-18224 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=14ebbc190343b9f12f668aad9a59d721f233eaf2;hp=38c304a54f26b7214bbcf77eb179a6faf5cd9845;p=civicrm-core.git Merge pull request #7969 from monishdeb/CRM-18224 CRM-18224 fix --- diff --git a/CRM/Contact/Form/Task/AddToHousehold.php b/CRM/Contact/Form/Task/AddToHousehold.php index b6a1443b32..95298009b3 100644 --- a/CRM/Contact/Form/Task/AddToHousehold.php +++ b/CRM/Contact/Form/Task/AddToHousehold.php @@ -93,7 +93,7 @@ class CRM_Contact_Form_Task_AddToHousehold extends CRM_Contact_Form_Task_AddToPa $this->set('searchDone', 0); if (!empty($_POST['_qf_AddToHousehold_refresh'])) { - $searchParams['contact_type'] = array('Household' => 'Household'); + $searchParams['contact_type'] = 'Household'; $searchParams['rel_contact'] = $this->params['name']; $this->search($this, $searchParams); $this->set('searchDone', 1); diff --git a/CRM/Contact/Form/Task/AddToOrganization.php b/CRM/Contact/Form/Task/AddToOrganization.php index d1eb806a43..145d77323a 100644 --- a/CRM/Contact/Form/Task/AddToOrganization.php +++ b/CRM/Contact/Form/Task/AddToOrganization.php @@ -101,7 +101,7 @@ class CRM_Contact_Form_Task_AddToOrganization extends CRM_Contact_Form_Task_AddT $this->set('searchDone', 0); if (!empty($_POST['_qf_AddToOrganization_refresh'])) { - $searchParams['contact_type'] = array('Organization' => 'Organization'); + $searchParams['contact_type'] = 'Organization'; $searchParams['rel_contact'] = $this->params['name']; $this->search($this, $searchParams); $this->set('searchDone', 1); diff --git a/CRM/Contribute/BAO/Premium.php b/CRM/Contribute/BAO/Premium.php index 1d7449b4ca..eff02f0cd2 100644 --- a/CRM/Contribute/BAO/Premium.php +++ b/CRM/Contribute/BAO/Premium.php @@ -34,6 +34,7 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { /** * Product information. + * * @var array */ private static $productInfo; @@ -53,7 +54,7 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { * @param array $defaults * (reference ) an assoc array to hold the flattened values. * - * @return CRM_Contribute_BAO_ManagePremium + * @return CRM_Contribute_DAO_Product */ public static function retrieve(&$params, &$defaults) { $premium = new CRM_Contribute_DAO_Product(); @@ -84,12 +85,8 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { * Delete financial Types. * * @param int $premiumID - * */ public static function del($premiumID) { - //check dependencies - - //delete from financial Type table $premium = new CRM_Contribute_DAO_Premium(); $premium->id = $premiumID; $premium->delete(); @@ -102,8 +99,7 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { * @param int $pageID * @param bool $formItems * @param int $selectedProductID - * @param null $selectedOption - * + * @param string $selectedOption */ public static function buildPremiumBlock(&$form, $pageID, $formItems = FALSE, $selectedProductID = NULL, $selectedOption = NULL) { $form->add('hidden', "selectProduct", $selectedProductID, array('id' => 'selectProduct')); @@ -175,7 +171,6 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { * @param CRM_Core_Form $form * @param int $productID * @param int $premiumProductID - * */ public function buildPremiumPreviewBlock($form, $productID, $premiumProductID = NULL) { if ($premiumProductID) { @@ -213,7 +208,6 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { * Delete premium associated w/ contribution page. * * @param int $contributionPageID - * */ public static function deletePremium($contributionPageID) { if (!$contributionPageID) { diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 4e286e3997..2c90c8159d 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -705,6 +705,11 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $name = CRM_Utils_Array::value($contributionStatus, $statusName); switch ($name) { case 'Completed': + // [CRM-17498] Removing unsupported status change options. + unset($status[CRM_Utils_Array::key('Pending', $statusName)]); + unset($status[CRM_Utils_Array::key('Failed', $statusName)]); + unset($status[CRM_Utils_Array::key('Partially paid', $statusName)]); + unset($status[CRM_Utils_Array::key('Pending refund', $statusName)]); case 'Cancelled': case 'Chargeback': case 'Refunded': diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 16a6ef8933..509a3ea29d 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -77,7 +77,7 @@ class CRM_Core_PseudoConstant { * States/provinces abbreviations * @var array */ - private static $stateProvinceAbbreviation; + private static $stateProvinceAbbreviation = array(); /** * Country. @@ -738,22 +738,22 @@ class CRM_Core_PseudoConstant { * array reference of all State/Province abbreviations. */ public static function stateProvinceAbbreviation($id = FALSE, $limit = TRUE) { - if ($id > 1) { - $query = " -SELECT abbreviation + if ($id && is_numeric($id)) { + if (!array_key_exists($id, (array) self::$stateProvinceAbbreviation)) { + $query = "SELECT abbreviation FROM civicrm_state_province WHERE id = %1"; - $params = array( - 1 => array( - $id, - 'Integer', - ), - ); - return CRM_Core_DAO::singleValueQuery($query, $params); + $params = array( + 1 => array( + $id, + 'Integer', + ), + ); + self::$stateProvinceAbbreviation[$id] = CRM_Core_DAO::singleValueQuery($query, $params); + } + return self::$stateProvinceAbbreviation[$id]; } - - if (!self::$stateProvinceAbbreviation || !$id) { - + else { $whereClause = FALSE; if ($limit) { @@ -774,15 +774,6 @@ WHERE id = %1"; self::populate(self::$stateProvinceAbbreviation, 'CRM_Core_DAO_StateProvince', TRUE, 'abbreviation', 'is_active', $whereClause); } - if ($id) { - if (array_key_exists($id, self::$stateProvinceAbbreviation)) { - return self::$stateProvinceAbbreviation[$id]; - } - else { - $result = NULL; - return $result; - } - } return self::$stateProvinceAbbreviation; } diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index d2e0b6f72e..0426c6cca6 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -979,11 +979,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $$moniker = $result['values'][$cid]; } - static $fields = array(); - if (empty($fields)) { - $fields = CRM_Contact_DAO_Contact::fields(); - CRM_Core_DAO::freeResult(); - } + $fields = CRM_Contact_DAO_Contact::fields(); // FIXME: there must be a better way foreach (array('main', 'other') as $moniker) { diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index 0bb887c7d5..c17e424ee9 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -98,6 +98,7 @@ class CRM_Export_BAO_Export { */ public static function defaultReturnProperty($exportMode) { // hack to add default return property based on export mode + $property = NULL; if ($exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT) { $property = 'contribution_id'; } @@ -119,9 +120,6 @@ class CRM_Export_BAO_Export { elseif ($exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) { $property = 'activity_id'; } - elseif ($exportMode == CRM_Export_Form_Select::CONTACT_EXPORT) { - $property = 'contact_id'; - } return $property; } @@ -434,7 +432,9 @@ class CRM_Export_BAO_Export { } } } - $returnProperties[self::defaultReturnProperty($exportMode)] = 1; + if (!empty(self::defaultReturnProperty($exportMode))) { + $returnProperties[self::defaultReturnProperty($exportMode)] = 1; + } } else { $primary = TRUE; @@ -560,7 +560,7 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c list($select, $from, $where, $having) = $query->query(); if ($mergeSameHousehold == 1) { - if (!$returnProperties['id']) { + if (empty($returnProperties['id'])) { $returnProperties['id'] = 1; } diff --git a/CRM/Export/Form/Select.php b/CRM/Export/Form/Select.php index c2dac7b530..4349d3427a 100644 --- a/CRM/Export/Form/Select.php +++ b/CRM/Export/Form/Select.php @@ -444,7 +444,7 @@ FROM {$this->_componentTable} * @return string */ public function getTitle() { - return ts('Export All or Selected Fields'); + return ts('Export Options'); } /** diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index b6835b2385..7b5137e7ba 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -1013,11 +1013,13 @@ SELECT pledge.contact_id as contact_id, if (empty($details['reminder_date'])) { $nextReminderDate = new DateTime($details['scheduled_date']); + $details['initial_reminder_day'] = empty($details['initial_reminder_day']) ? 0 : $details['initial_reminder_day']; $nextReminderDate->modify("-" . $details['initial_reminder_day'] . "day"); $nextReminderDate = $nextReminderDate->format("Ymd"); } else { $nextReminderDate = new DateTime($details['reminder_date']); + $details['additional_reminder_day'] = empty($details['additional_reminder_day']) ? 0 : $details['additional_reminder_day']; $nextReminderDate->modify("+" . $details['additional_reminder_day'] . "day"); $nextReminderDate = $nextReminderDate->format("Ymd"); } diff --git a/CRM/UF/Page/Field.php b/CRM/UF/Page/Field.php index c2cec5186e..7fb6b880eb 100644 --- a/CRM/UF/Page/Field.php +++ b/CRM/UF/Page/Field.php @@ -125,8 +125,8 @@ class CRM_UF_Page_Field extends CRM_Core_Page { $isGroupReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'is_reserved'); $this->assign('isGroupReserved', $isGroupReserved); - $profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid); - if ($profileType == 'Contribution' || $profileType == 'Membership' || $profileType == 'Activity' || $profileType == 'Participant') { + $isMixedProfile = CRM_Core_BAO_UFField::checkProfileType($this->_gid); + if ($isMixedProfile) { $this->assign('skipCreate', TRUE); } diff --git a/CRM/UF/Page/Group.php b/CRM/UF/Page/Group.php index 273dfab8fa..aa60dd5e57 100644 --- a/CRM/UF/Page/Group.php +++ b/CRM/UF/Page/Group.php @@ -351,10 +351,13 @@ class CRM_UF_Page_Group extends CRM_Core_Page { $groupTypes = self::extractGroupTypes($value['group_type']); // drop Create, Edit and View mode links if profile group_type is one of the following: - $groupComponents = array('Contribution', 'Membership', 'Activity', 'Participant', 'Case'); - $componentFound = array_intersect($groupComponents, array_keys($groupTypes)); - if (!empty($componentFound)) { + // Contribution, Membership, Activity, Participant, Case, Grant + $isMixedProfile = CRM_Core_BAO_UFField::checkProfileType($id); + if ($isMixedProfile) { $action -= CRM_Core_Action::ADD; + $action -= CRM_Core_Action::ADVANCED; + $action -= CRM_Core_Action::BASIC; + $action -= CRM_Core_Action::PROFILE; } $ufGroup[$id]['group_type'] = self::formatGroupTypes($groupTypes); diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 292d18fa52..b3f8dcb443 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -691,7 +691,7 @@ abstract class CRM_Utils_System_Base { public function getTimeZoneOffset() { $timezone = $this->getTimeZoneString(); if ($timezone) { - if ($timezone == 'UTC') { + if ($timezone == 'UTC' || $timezone == 'Etc/UTC') { // CRM-17072 Let's short-circuit all the zero handling & return it here! return '+00:00'; } diff --git a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php index 6e46bfe5e9..75d65ed1b6 100644 --- a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php +++ b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php @@ -1186,6 +1186,7 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { public function testContactModifiedAnniversary() { $contact = $this->callAPISuccess('Contact', 'create', $this->fixtures['contact_birthdate']); $this->_testObjects['CRM_Contact_DAO_Contact'][] = $contact['id']; + $modifiedDate = $this->callAPISuccess('Contact', 'getvalue', array('id' => $contact['id'], 'return' => 'modified_date')); $actionSchedule = $this->fixtures['sched_contact_mod_anniv']; $actionScheduleDao = CRM_Core_BAO_ActionSchedule::add($actionSchedule); $this->assertTrue(is_numeric($actionScheduleDao->id)); @@ -1197,7 +1198,7 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { ), array( // On the eve of 3 years after they were modified, send an email. - 'time' => date('Y-m-d H:i:s', strtotime($contact['values'][$contact['id']]['modified_date'] . ' +3 years -23 hours')), + 'time' => date('Y-m-d H:i:s', strtotime($modifiedDate . ' +3 years -1 day')), 'recipients' => array(array('test-bday@example.com')), ), ));