From: unknown Date: Wed, 22 Oct 2014 20:34:55 +0000 (+0100) Subject: some code improvements X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6a95720dfd6a8efe579521cce01d59243874e86a;p=civicrm-core.git some code improvements --- diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index 3e636dd971..a138831372 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -36,7 +36,8 @@ require_once 'packages/When/When.php'; class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { - + + CONST RUNNING = 1; public $schedule = array(); public $scheduleId = NULL; public $scheduleFormValues = array(); @@ -123,6 +124,13 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { ), ); + static function getStatus() { + return self::$status; + } + + static function setStatus($status) { + self::$status = $status; + } /** * Function to save records in civicrm_recujrring_entity table * @@ -241,7 +249,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * @return array */ function generateEntities() { - self::$status = "Running"; + self::setStatus(self::RUNNING); $newEntities = array(); $findCriteria = array(); @@ -628,7 +636,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { return NULL; } - if (self::$status == 'Running') { + if (self::getStatus() == self::RUNNING) { // if recursion->generate() is doing some work, lets not intercept return NULL; } diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index 327214a1ca..9560e0a5f1 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -242,7 +242,7 @@ class CRM_Core_Form_RecurringEntity { //Ends if (CRM_Utils_Array::value('ends', $values)) { if ($values['ends'] == 1) { - if ($values['start_action_offset'] == "") { + if (empty($values['start_action_offset'])) { $errors['start_action_offset'] = ts('This is a required field'); } else if ($values['start_action_offset'] > 30) { @@ -250,7 +250,7 @@ class CRM_Core_Form_RecurringEntity { } } if ($values['ends'] == 2) { - if ($values['repeat_absolute_date'] != "") { + if (CRM_Utils_Array::value('repeat_absolute_date', $values)) { $entityStartDate = CRM_Utils_Date::processDate($values['repetition_start_date']); $end = CRM_Utils_Date::processDate($values['repeat_absolute_date']); if (($end < $entityStartDate) && ($end != 0)) { @@ -269,7 +269,7 @@ class CRM_Core_Form_RecurringEntity { //Repeats BY if (CRM_Utils_Array::value('repeats_by', $values)) { if ($values['repeats_by'] == 1) { - if ($values['limit_to'] != "") { + if (CRM_Utils_Array::value('limit_to', $values)) { if ($values['limit_to'] < 1 && $values['limit_to'] > 31) { $errors['limit_to'] = ts('Invalid day of the month'); } @@ -279,7 +279,7 @@ class CRM_Core_Form_RecurringEntity { } } if ($values['repeats_by'] == 2) { - if ($values['entity_status_1'] != "" ) { + if (CRM_Utils_Array::value('entity_status_1', $values)) { $dayOfTheWeekNo = array(first, second, third, fourth, last); if (!in_array($values['entity_status_1'], $dayOfTheWeekNo)) { $errors['entity_status_1'] = ts('Invalid option'); @@ -288,7 +288,7 @@ class CRM_Core_Form_RecurringEntity { else { $errors['entity_status_1'] = ts('Invalid option'); } - if ($values['entity_status_2'] != "" ) { + if (CRM_Utils_Array::value('entity_status_2', $values)) { if (!in_array($values['entity_status_2'], $dayOfTheWeek)) { $errors['entity_status_2'] = ts('Invalid day name'); }