From 59d63f8b4683113e23cd4a5f8ca83693ac528e48 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Oct 2014 11:24:46 +0000 Subject: [PATCH] Removed trailing whitespaces --- CRM/Activity/Form/Activity.php | 8 +- CRM/Core/BAO/RecurringEntity.php | 180 +++++++++--------- CRM/Core/Form/RecurringEntity.php | 52 ++--- CRM/Core/Page/AJAX/RecurringEntity.php | 16 +- CRM/Event/Form/ManageEvent.php | 6 +- CRM/Event/Form/ManageEvent/Repeat.php | 52 ++--- templates/CRM/Activity/Form/Activity.tpl | 4 +- templates/CRM/Core/Form/RecurringEntity.hlp | 2 +- templates/CRM/Core/Form/RecurringEntity.tpl | 52 ++--- .../Form/ManageEvent/ConfirmRepeatMode.tpl | 12 +- templates/CRM/Event/Form/ManageEvent/Tab.tpl | 2 +- .../CRM/Core/BAO/RecurringEntityTest.php | 48 ++--- 12 files changed, 217 insertions(+), 217 deletions(-) diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 572356ab42..00bde84dd8 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -122,7 +122,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { protected $_values = array(); protected $unsavedWarn = TRUE; - + /** * The _fields var can be used by sub class to set/unset/edit the * form fields based on their requirement @@ -503,12 +503,12 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { } $this->set('values', $this->_values); } - + if ($this->_action & CRM_Core_Action::UPDATE) { CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity'); } } - + /** * This function sets the default values for the form. For edit/view mode * the default values are retrieved from the database @@ -960,7 +960,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { $params['entity_table'] = 'civicrm_activity'; $scheduleReminderDetails = array(); if (!empty($params['entity_id']) && !empty($params['entity_table'])) { - $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($params['entity_id'], $params['entity_table']); + $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($params['entity_id'], $params['entity_table']); if ($checkParentExistsForThisId) { $params['parent_entity_id'] = $checkParentExistsForThisId; $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($checkParentExistsForThisId, $params['entity_table']); diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index a138831372..083e9c4ffc 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -33,10 +33,10 @@ * */ -require_once 'packages/When/When.php'; +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; @@ -46,18 +46,18 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { public $overwriteColumns = array(); public $intervalDateColumns = array(); public $excludeDates = array(); - + public $linkedEntities = array(); public $isRecurringEntityRecord = TRUE; protected $recursion = NULL; - + public static $_entitiesToBeDeleted = array(); public static $status = NULL; - - static $_recurringEntityHelper = + + static $_recurringEntityHelper = array( 'civicrm_event' => array( 'helper_class' => 'CRM_Event_DAO_Event', @@ -68,10 +68,10 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 'helper_class' => 'CRM_Activity_DAO_Activity', 'delete_func' => 'delete', 'pre_delete_func' => '' - ) - ); - - static $_dateColumns = + ) + ); + + static $_dateColumns = array( 'civicrm_event' => array( 'dateColumns' => array('start_date'), @@ -83,7 +83,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { ) ); - static $_tableDAOMapper = + static $_tableDAOMapper = array( 'civicrm_event' => 'CRM_Event_DAO_Event', 'civicrm_price_set_entity' => 'CRM_Price_DAO_PriceSetEntity', @@ -94,7 +94,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 'civicrm_activity_contact' => 'CRM_Activity_DAO_ActivityContact', ); - static $_updateSkipFields = + static $_updateSkipFields = array( 'civicrm_event' => array('start_date', 'end_date'), 'civicrm_tell_friend' => array('entity_id'), @@ -102,32 +102,32 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 'civicrm_activity' => array('activity_date_time'), ); - static $_linkedEntitiesInfo = + static $_linkedEntitiesInfo = array( 'civicrm_tell_friend' => array( - 'entity_id_col' => 'entity_id', + 'entity_id_col' => 'entity_id', 'entity_table_col' => 'entity_table' ), 'civicrm_price_set_entity' => array( - 'entity_id_col' => 'entity_id', + 'entity_id_col' => 'entity_id', 'entity_table_col' => 'entity_table', 'is_multirecord' => TRUE, ), 'civicrm_uf_join' => array( - 'entity_id_col' => 'entity_id', + 'entity_id_col' => 'entity_id', 'entity_table_col' => 'entity_table', 'is_multirecord' => TRUE, ), 'civicrm_pcp_block' => array( - 'entity_id_col' => 'entity_id', + 'entity_id_col' => 'entity_id', 'entity_table_col' => 'entity_table' ), ); - + static function getStatus() { return self::$status; } - + static function setStatus($status) { self::$status = $status; } @@ -176,7 +176,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * @return object */ static function quickAdd($parentId, $entityId, $entityTable) { - $params = + $params = array( 'parent_id' => $parentId, 'entity_id' => $entityId, @@ -209,7 +209,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function generates all new entities based on object vars - * + * * @return array */ function generate() { @@ -220,12 +220,12 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function builds a "When" object based on schedule/reminder params - * + * * @return object When object */ function generateRecursion() { // return if already generated - if (is_a($this->recursion, 'When')) { + if (is_a($this->recursion, 'When')) { return $this->recursion; } @@ -245,7 +245,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * Generate new DAOs and along with entries in civicrm_recurring_entity table - * + * * @return array */ function generateEntities() { @@ -274,7 +274,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $newCriteria[$col] = $val; } // create main entities - $obj = CRM_Core_BAO_RecurringEntity::copyCreateEntity($this->entity_table, + $obj = CRM_Core_BAO_RecurringEntity::copyCreateEntity($this->entity_table, $findCriteria, $newCriteria, $this->isRecurringEntityRecord @@ -289,7 +289,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $newCriteria[$col] = $obj->id; } // create linked entities - $linkedObj = CRM_Core_BAO_RecurringEntity::copyCreateEntity($linkedInfo['table'], + $linkedObj = CRM_Core_BAO_RecurringEntity::copyCreateEntity($linkedInfo['table'], $linkedInfo['findCriteria'], $newCriteria, CRM_Utils_Array::value('isRecurringEntityRecord', $linkedInfo, TRUE) @@ -309,16 +309,16 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } /** - * This function iterates through when object criterias and + * This function iterates through when object criterias and * generates recursive dates based on that - * + * * @return array array of dates */ function generateRecursiveDates() { $this->generateRecursion(); $recursionDates = array(); - if (is_a($this->recursion, 'When')) { + if (is_a($this->recursion, 'When')) { $initialCount = CRM_Utils_Array::value('start_action_offset', $this->schedule); $exRangeStart = $exRangeEnd = NULL; @@ -382,16 +382,16 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function gets all the children for a particular parent entity - * + * * @param int $parentId Parent entity id * @param string $entityTable Name of the entity table * @param boolean $includeParent If true parent id is included in result set and vice versa * @param int $mode 1. retrieve only one entity. 2. retrieve all future entities in the repeating set. 3. all entities in the repeating set. * @param int $initiatorId the instance where this function is invoked from - * + * * @access public * @static - * + * * @return array an array of child ids */ static public function getEntitiesForParent($parentId, $entityTable, $includeParent = TRUE, $mode = 3, $initiatorId = NULL) { @@ -399,7 +399,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { if (!$initiatorId) { $initiatorId = $parentId; - } + } $queryParams = array( 1 => array($parentId, 'Integer'), @@ -425,7 +425,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $recurringEntityID = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_recurring_entity WHERE entity_id = %3 AND entity_table = %2", $queryParams); if ($recurringEntityID) { $query .= $includeParent ? " AND id >= %4" : " AND id > %4"; - $query .= " ORDER BY id ASC"; // FIXME: change to order by dates + $query .= " ORDER BY id ASC"; // FIXME: change to order by dates $queryParams[4] = array($recurringEntityID, 'Integer'); } else { @@ -443,17 +443,17 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } /** - * This function when passed an entity id checks if it has parent and + * This function when passed an entity id checks if it has parent and * returns all other entities that are connected to same parent. - * + * * @param int $entityId entity id * @param string $entityTable Entity table name * @param boolean $includeParent Include parent in result set * @param int $mode 1. retrieve only one entity. 2. retrieve all future entities in the repeating set. 3. all entities in the repeating set. - * + * * @access public * @static - * + * * @return array array of connected ids */ static public function getEntitiesFor($entityId, $entityTable, $includeParent = TRUE, $mode = 3) { @@ -466,25 +466,25 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function gets the parent for the entity id passed to it - * + * * @param int $entityId entity ID * @param string $entityTable Entity table name * @param boolean $includeParent Include parent in result set - * + * * @access public * @static - * - * @return int unsigned $parentId Parent ID + * + * @return int unsigned $parentId Parent ID */ static public function getParentFor($entityId, $entityTable, $includeParent = TRUE) { $query = " - SELECT parent_id + SELECT parent_id FROM civicrm_recurring_entity WHERE entity_id = %1 AND entity_table = %2"; if (!$includeParent) { $query .= " AND parent_id != %1"; } - $parentId = + $parentId = CRM_Core_DAO::singleValueQuery($query, array( 1 => array($entityId, 'Integer'), @@ -496,15 +496,15 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function copies the information from parent entity and creates other entities with same information - * + * * @param string $entityTable Entity table name * @param array $fromCriteria array of all the fields & values on which basis to copy * @param array $newParams array of all the fields & values to be copied besides the other fields * @param boolean $createRecurringEntity if to create a record in recurring_entity table - * + * * @access public * @static - * + * * @return object */ static public function copyCreateEntity($entityTable, $fromCriteria, $newParams, $createRecurringEntity = TRUE) { @@ -529,12 +529,12 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function acts as a listener to dao->update whenever there is an update, * and propagates any changes to all related entities present in recurring entity table - * + * * @param object $event An object of /Civi/Core/DAO/Event/PostUpdate containing dao object that was just updated - * + * * @access public * @static - * + * * @return void */ static public function triggerUpdate($event) { @@ -553,7 +553,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { return FALSE; } $key = "{$obj->__table}_{$obj->id}"; - + if (array_key_exists($key, $processedEntities)) { // already processed return NULL; @@ -602,12 +602,12 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function acts as a listener to dao->save, * and creates entries for linked entities in recurring entity table - * + * * @param object $event An object of /Civi/Core/DAO/Event/PostUpdate containing dao object that was just inserted - * + * * @access public * @static - * + * * @return void */ static public function triggerInsert($event) { @@ -630,7 +630,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { return FALSE; } $key = "{$obj->__table}_{$obj->id}"; - + if (array_key_exists($key, $processedEntities)) { // already being processed. Exit recursive calls. return NULL; @@ -649,7 +649,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { if (empty($hasaRecurringRecord)) { // check if its a linked entity - if (array_key_exists($obj->__table, self::$_linkedEntitiesInfo) && + if (array_key_exists($obj->__table, self::$_linkedEntitiesInfo) && !CRM_Utils_Array::value('is_multirecord', self::$_linkedEntitiesInfo[$obj->__table])) { $linkedDAO = new self::$_tableDAOMapper[$obj->__table](); $linkedDAO->id = $obj->id; @@ -659,7 +659,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $pEntityID = $linkedDAO->$idCol; $pEntityTable = $linkedDAO->$tableCol; - + // find all parent recurring entity set $pRepeatingEntities = self::getEntitiesFor($pEntityID, $pEntityTable); @@ -691,7 +691,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $idCol => $val['id'], $tableCol => $val['table'] ); - $linkedObj = CRM_Core_BAO_RecurringEntity::copyCreateEntity($obj->__table, + $linkedObj = CRM_Core_BAO_RecurringEntity::copyCreateEntity($obj->__table, array('id' => $obj->id), $newCriteria, TRUE @@ -712,12 +712,12 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function acts as a listener to dao->delete, and deletes an entry from recurring_entity table - * + * * @param object $event An object of /Civi/Core/DAO/Event/PostUpdate containing dao object that was just deleted * * @access public * @static - * + * * @return void */ static public function triggerDelete($event) { @@ -754,13 +754,13 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function deletes main entity and related linked entities from recurring-entity table - * + * * @param int $entityId Entity id * @param string $entityTable Name of the entity table - * + * * @access public * @static - * + * * @return boolean|object Returns either boolean value or CRM_Core_DAO_RecurringEntity object */ static public function delEntity($entityId, $entityTable, $isDelLinkedEntities = FALSE) { @@ -797,12 +797,12 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function maps values posted from form to civicrm_action_schedule columns - * + * * @param array $formParams and array of form values posted - * - * @return array + * + * @return array */ - function mapFormValuesToDB($formParams = array()) { + function mapFormValuesToDB($formParams = array()) { $dbParams = array(); if (CRM_Utils_Array::value('used_for', $formParams)) { $dbParams['used_for'] = $formParams['used_for']; @@ -852,14 +852,14 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } } - //For "Ends" - After: + //For "Ends" - After: if ($formParams['ends'] == 1) { if (CRM_Utils_Array::value('start_action_offset', $formParams)) { $dbParams['start_action_offset'] = $formParams['start_action_offset']; } } - //For "Ends" - On: + //For "Ends" - On: if ($formParams['ends'] == 2) { if (CRM_Utils_Array::value('repeat_absolute_date', $formParams)) { $dbParams['absolute_date'] = CRM_Utils_Date::processDate($formParams['repeat_absolute_date']); @@ -870,12 +870,12 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function gets all the columns of civicrm_action_schedule table based on id(primary key) - * + * * @param int $scheduleReminderId primary key of civicrm_action_schedule table - * + * * @access public * @static - * + * * @return object */ static public function getScheduleReminderDetailsById($scheduleReminderId) { @@ -896,9 +896,9 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function is a wrapper of getScheduleReminderDetailsById function - * + * * @param int $scheduleReminderId primary key of civicrm_action_schedule table - * + * * @return array */ function getScheduleParams($scheduleReminderId) { @@ -914,9 +914,9 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function takes criterias saved in civicrm_action_schedule table * and creates recursion rule - * + * * @param array $scheduleReminderDetails array of repeat criterias saved in civicrm_action_schedule table - * + * * @return object When object */ function getRecursionFromSchedule($scheduleReminderDetails = array()) { @@ -959,7 +959,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } } - //month + //month if ($scheduleReminderDetails['repetition_frequency_unit'] == 'month') { if ($scheduleReminderDetails['entity_status']) { $startActionDate = explode(" ", $scheduleReminderDetails['entity_status']); @@ -1012,19 +1012,19 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { return $r; } - + /** * This function gets time difference between the two datetime object - * + * * @param DateTime $startDate Start Date * @param DateTime $endDate End Date - * + * * @access public * @static - * + * * @return object DateTime object which contain time difference */ - static public function getInterval($startDate, $endDate) { + static public function getInterval($startDate, $endDate) { if ($startDate && $endDate) { $startDate = new DateTime($startDate); $endDate = new DateTime($endDate); @@ -1034,20 +1034,20 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { /** * This function gets all columns from civicrm_action_schedule on the basis of event id - * + * * @param int $entityId Entity ID * @param string $used_for Specifies for which entity type it's used for - * + * * @access public * @static - * + * * @return object */ public static function getReminderDetailsByEntityId($entityId, $used_for) { if ($entityId) { $query = " SELECT * - FROM civicrm_action_schedule + FROM civicrm_action_schedule WHERE entity_value = %1"; if ($used_for) { $query .= " AND used_for = %2"; @@ -1061,10 +1061,10 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } return $dao; } - + /** * Update mode column in civicrm_recurring_entity table for event related tabs - * + * * @params int $entityId event id * @params string $linkedEntityTable Linked entity table name for this event * @return array @@ -1090,7 +1090,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $result['entityId'] = $defaults['id']; $result['entityTable'] = $entityTable; } - } + } return $result; - } + } } diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index 05c7ce94be..540dcdb884 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -42,43 +42,43 @@ class CRM_Core_Form_RecurringEntity { * Current entity id */ protected static $_entityId = NULL; - + /** * Schedule Reminder ID */ protected static $_scheduleReminderID = NULL; - + /** * Schedule Reminder data */ protected static $_scheduleReminderDetails = array(); - + /** * Parent Entity ID */ protected static $_parentEntityId = NULL; - + /** - * Exclude date information + * Exclude date information */ public static $_excludeDateInfo = array(); - + /** * Entity Table */ public static $_entityTable; - + /** * Checks current entityID has parent */ public static $_hasParent = FALSE; - + static function preProcess($entityTable) { self::$_entityId = (int) CRM_Utils_Request::retrieve('id', 'Positive'); self::$_entityTable = $entityTable; - + if (self::$_entityId && $entityTable) { - $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor(self::$_entityId, $entityTable); + $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor(self::$_entityId, $entityTable); if ($checkParentExistsForThisId) { self::$_hasParent = TRUE; self::$_parentEntityId = $checkParentExistsForThisId; @@ -101,7 +101,7 @@ class CRM_Core_Form_RecurringEntity { } } } - + /** * This function sets the default values for the form. For edit/view mode * the default values are retrieved from the database @@ -144,13 +144,13 @@ class CRM_Core_Form_RecurringEntity { } return $defaults; } - + static function buildQuickForm(&$form) { $form->assign('currentEntityId', self::$_entityId); $form->assign('entityTable', self::$_entityTable); $form->assign('scheduleReminderId', self::$_scheduleReminderID); $form->assign('hasParent', self::$_hasParent); - + $form->_freqUnits = array('hour' => 'hour') + CRM_Core_OptionGroup::values('recur_frequency_units'); foreach ($form->_freqUnits as $val => $label) { if ($label == "day") { @@ -199,8 +199,8 @@ class CRM_Core_Form_RecurringEntity { $form->addDate('exclude_date', ts('Exclude Date(s)'), FALSE); $select = $form->add('select', 'exclude_date_list', ts(''), self::$_excludeDateInfo, FALSE, array('style' => 'width:150px;', 'size' => 4)); $select->setMultiple(TRUE); - $form->addElement('button','add_to_exclude_list','>>','onClick="addToExcludeList(document.getElementById(\'exclude_date\').value);"'); - $form->addElement('button','remove_from_exclude_list', '<<', 'onClick="removeFromExcludeList(\'exclude_date_list\')"'); + $form->addElement('button','add_to_exclude_list','>>','onClick="addToExcludeList(document.getElementById(\'exclude_date\').value);"'); + $form->addElement('button','remove_from_exclude_list', '<<', 'onClick="removeFromExcludeList(\'exclude_date_list\')"'); $form->addElement('hidden', 'copyExcludeDates', '', array('id' => 'copyExcludeDates')); $form->addElement('hidden', 'allowRepeatConfigToSubmit', '', array('id' => 'allowRepeatConfigToSubmit')); $form->addButtons(array( @@ -338,9 +338,9 @@ class CRM_Core_Form_RecurringEntity { } $actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams); - //exclude dates + //exclude dates $excludeDateList = array(); - if (CRM_Utils_Array::value('copyExcludeDates', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) { + if (CRM_Utils_Array::value('copyExcludeDates', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) { //Since we get comma separated values lets get them in array $excludeDates = array(); $excludeDates = explode(",", $params['copyExcludeDates']); @@ -354,7 +354,7 @@ class CRM_Core_Form_RecurringEntity { if ($optionGroupIdExists) { CRM_Core_BAO_OptionGroup::del($optionGroupIdExists); } - $optionGroupParams = + $optionGroupParams = array( 'name' => $type.'_repeat_exclude_dates_'.$actionScheduleObj->entity_value, 'title' => $type.' recursion', @@ -366,7 +366,7 @@ class CRM_Core_Form_RecurringEntity { $oldWeight= 0; $fieldValues = array('option_group_id' => $opGroup->id); foreach($excludeDates as $val) { - $optionGroupValue = + $optionGroupValue = array( 'option_group_id' => $opGroup->id, 'label' => CRM_Utils_Date::processDate($val), @@ -394,7 +394,7 @@ class CRM_Core_Form_RecurringEntity { if (CRM_Utils_Array::value('pre_delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) && CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']])) { call_user_func(array( - CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['helper_class'], + CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['helper_class'], call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], array($params['entity_id']))) ); } @@ -405,8 +405,8 @@ class CRM_Core_Form_RecurringEntity { if (!empty(CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted)) { foreach (CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted as $eid) { $result = civicrm_api3( - ucfirst(strtolower($apiType)), - CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], + ucfirst(strtolower($apiType)), + CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], array( 'sequential' => 1, 'id' => $eid, @@ -421,8 +421,8 @@ class CRM_Core_Form_RecurringEntity { $getRelatedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table'], FALSE); foreach ($getRelatedEntities as $key => $value) { $result = civicrm_api3( - ucfirst(strtolower($apiType)), - CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], + ucfirst(strtolower($apiType)), + CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], array( 'sequential' => 1, 'id' => $value['id'], @@ -453,7 +453,7 @@ class CRM_Core_Form_RecurringEntity { $recursion->linkedEntities = $linkedEntities; } - $recurResult = $recursion->generate(); + $recurResult = $recursion->generate(); $status = ts('Repeat Configuration has been saved'); CRM_Core_Session::setStatus($status, ts('Saved'), 'success'); @@ -471,5 +471,5 @@ class CRM_Core_Form_RecurringEntity { public function getTitle() { return ts('Repeat Entity'); } - + } diff --git a/CRM/Core/Page/AJAX/RecurringEntity.php b/CRM/Core/Page/AJAX/RecurringEntity.php index ba0a69f4e7..0e5c2d9c71 100644 --- a/CRM/Core/Page/AJAX/RecurringEntity.php +++ b/CRM/Core/Page/AJAX/RecurringEntity.php @@ -13,10 +13,10 @@ */ class CRM_Core_Page_AJAX_RecurringEntity { - + public static function updateMode() { if (CRM_Utils_Array::value('mode', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST) && CRM_Utils_Array::value('entityTable', $_REQUEST)) { - + $finalResult = array(); $mode = CRM_Utils_Type::escape($_REQUEST['mode'], 'Integer'); $entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer'); @@ -36,7 +36,7 @@ class CRM_Core_Page_AJAX_RecurringEntity { $dao->entity_id = $entityId; $dao->entity_table = $entityTable; } - + if ($dao->find(TRUE)) { $dao->mode = $mode; $dao->save(); @@ -49,7 +49,7 @@ class CRM_Core_Page_AJAX_RecurringEntity { echo json_encode($finalResult); CRM_Utils_System::civiExit(); } - + public static function generatePreview() { $params = $formValues = $genericResult = array(); $formValues = $_REQUEST; @@ -57,7 +57,7 @@ class CRM_Core_Page_AJAX_RecurringEntity { CRM_Utils_Array::value('entity_table', $formValues)) { $startDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'][0]; $endDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['intervalDateColumns'][0]; - + $recursion = new CRM_Core_BAO_RecurringEntity(); if (CRM_Utils_Array::value('dateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) { $recursion->dateColumns = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns']; @@ -69,7 +69,7 @@ class CRM_Core_Page_AJAX_RecurringEntity { if (CRM_Utils_Array::value('excludeDateRangeColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) { $recursion->excludeDateRangeColumns = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['excludeDateRangeColumns']; } - + if (CRM_Utils_Array::value('entity_id', $formValues)) { $parentEventId = CRM_Core_BAO_RecurringEntity::getParentFor($formValues['entity_id'], $formValues['entity_table']); } @@ -87,7 +87,7 @@ class CRM_Core_Page_AJAX_RecurringEntity { } } - $result = $recursion->generateRecursiveDates(); + $result = $recursion->generateRecursiveDates(); foreach ($result as $key => $value) { if ($startDateColumnName) { @@ -99,7 +99,7 @@ class CRM_Core_Page_AJAX_RecurringEntity { } } } - + //Show the list of participants registered for the events if any if ($formValues['entity_table'] == "civicrm_event") { $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', TRUE); diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php index 4961b9e99b..f8a3f0e413 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -84,7 +84,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { * the participant records */ protected $_campaignID = NULL; - + /** * Check if repeating event */ @@ -101,7 +101,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { if (in_array('CiviEvent', $config->enableComponents)) { $this->assign('CiviEvent', TRUE); } - + $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST'); $this->assign('action', $this->_action); @@ -187,7 +187,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { } $this->_templateId = (int) CRM_Utils_Request::retrieve('template_id', 'Integer', $this); - + //Is a repeating event if ($this->_isRepeatingEvent) { $isRepeatingEntity = TRUE; diff --git a/CRM/Event/Form/ManageEvent/Repeat.php b/CRM/Event/Form/ManageEvent/Repeat.php index e947fd65fb..8f85e84a98 100644 --- a/CRM/Event/Form/ManageEvent/Repeat.php +++ b/CRM/Event/Form/ManageEvent/Repeat.php @@ -12,24 +12,24 @@ * @author Priyanka */ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { - + /** * Parent Event Start Date */ protected $_parentEventStartDate = NULL; - + /** * Parent Event End Date */ protected $_parentEventEndDate = NULL; - - + + function preProcess() { parent::preProcess(); CRM_Core_Form_RecurringEntity::preProcess('civicrm_event'); $this->assign('currentEventId', $this->_id); - - $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event'); + + $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event'); //If this ID has parent, send parent id if ($checkParentExistsForThisId) { /** @@ -59,7 +59,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]); } } - } + } $this->assign('rows', $manageEvent); } } @@ -71,7 +71,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { $this->_parentEventStartDate = $parentEventAttributes->start_date; $this->_parentEventEndDate = $parentEventAttributes->end_date; } - + /** * This function sets the default values for the form. For edit/view mode * the default values are retrieved from the database @@ -82,7 +82,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { */ function setDefaultValues() { $defaults = array(); - + //Always pass current event's start date by default $currentEventStartDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'start_date', 'id'); list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($currentEventStartDate, 'activityDateTime'); @@ -92,14 +92,14 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { $defaults = array_merge($defaults, $recurringEntityDefaults); return $defaults; } - + public function buildQuickForm() { CRM_Core_Form_RecurringEntity::buildQuickForm($this); } - + public function postProcess() { if ($this->_id) { - $params = $this->controller->exportValues($this->_name); + $params = $this->controller->exportValues($this->_name); if ($this->_parentEventStartDate && $this->_parentEventEndDate) { $interval = CRM_Core_BAO_RecurringEntity::getInterval($this->_parentEventStartDate, $this->_parentEventEndDate); $params['intervalDateColumns'] = array('end_date' => $interval); @@ -112,12 +112,12 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { $url = 'civicrm/event/manage/repeat'; $urlParams = "action=update&reset=1&id={$this->_id}"; - + $linkedEntities = array( array( 'table' => 'civicrm_price_set_entity', 'findCriteria' => array( - 'entity_id' => $this->_id, + 'entity_id' => $this->_id, 'entity_table' => 'civicrm_event' ), 'linkedColumns' => array('entity_id'), @@ -126,7 +126,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { array( 'table' => 'civicrm_uf_join', 'findCriteria' => array( - 'entity_id' => $this->_id, + 'entity_id' => $this->_id, 'entity_table' => 'civicrm_event' ), 'linkedColumns' => array('entity_id'), @@ -135,7 +135,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { array( 'table' => 'civicrm_tell_friend', 'findCriteria' => array( - 'entity_id' => $this->_id, + 'entity_id' => $this->_id, 'entity_table' => 'civicrm_event' ), 'linkedColumns' => array('entity_id'), @@ -144,7 +144,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { array( 'table' => 'civicrm_pcp_block', 'findCriteria' => array( - 'entity_id' => $this->_id, + 'entity_id' => $this->_id, 'entity_table' => 'civicrm_event' ), 'linkedColumns' => array('entity_id'), @@ -156,17 +156,17 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { } else { CRM_Core_Error::fatal("Could not find Event ID"); - } + } } - + /** * This function gets the number of participant count for the list of related event ids - * + * * @param array $listOfRelatedEntities list of related event ids - * + * * @access public * @static - * + * * @return array */ static public function getParticipantCountforEvent($listOfRelatedEntities = array()) { @@ -175,10 +175,10 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { return $entity['id']; }, $listOfRelatedEntities)); if ($implodeRelatedEntities) { - $query = "SELECT p.event_id as event_id, - concat_ws(' ', e.title, concat_ws(' - ', DATE_FORMAT(e.start_date, '%b %d %Y %h:%i %p'), DATE_FORMAT(e.end_date, '%b %d %Y %h:%i %p'))) as event_data, + $query = "SELECT p.event_id as event_id, + concat_ws(' ', e.title, concat_ws(' - ', DATE_FORMAT(e.start_date, '%b %d %Y %h:%i %p'), DATE_FORMAT(e.end_date, '%b %d %Y %h:%i %p'))) as event_data, count(p.id) as participant_count - FROM civicrm_participant p, civicrm_event e + FROM civicrm_participant p, civicrm_event e WHERE p.event_id = e.id AND p.event_id IN ({$implodeRelatedEntities}) GROUP BY p.event_id"; $dao = CRM_Core_DAO::executeQuery($query); @@ -191,7 +191,7 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { } return $participantDetails; } - + /** * This function checks if there was any registraion for related event ids, * and returns array of ids with no regsitrations diff --git a/templates/CRM/Activity/Form/Activity.tpl b/templates/CRM/Activity/Form/Activity.tpl index a6c2162435..4926cc1370 100644 --- a/templates/CRM/Activity/Form/Activity.tpl +++ b/templates/CRM/Activity/Form/Activity.tpl @@ -204,7 +204,7 @@ {/if} - + {if $action eq 2 OR $action eq 1} @@ -229,7 +229,7 @@ {/if} - + {if $action neq 4} {* Don't include "Schedule Follow-up" section in View mode. *} diff --git a/templates/CRM/Core/Form/RecurringEntity.hlp b/templates/CRM/Core/Form/RecurringEntity.hlp index 3b7171e2ce..8c7cebc556 100644 --- a/templates/CRM/Core/Form/RecurringEntity.hlp +++ b/templates/CRM/Core/Form/RecurringEntity.hlp @@ -34,7 +34,7 @@
  • Daily:  your event repeats daily or after every few days
  • Weekly:  your event repeats on one or more days every week
  • Monthly:  your event repeats on one or more days every month
  • -
  • Yearly:  your event repeats yearly or after every few years
  • +
  • Yearly:  your event repeats yearly or after every few years
  • For eg - You would select option "monthly", if your event occurs every month. {/ts} diff --git a/templates/CRM/Core/Form/RecurringEntity.tpl b/templates/CRM/Core/Form/RecurringEntity.tpl index ef984d0b29..828c020726 100644 --- a/templates/CRM/Core/Form/RecurringEntity.tpl +++ b/templates/CRM/Core/Form/RecurringEntity.tpl @@ -89,7 +89,7 @@
    -
    +
    {literal} -{/literal} +{/literal} {*Hide Summary*} {if empty($scheduleReminderId)} {literal} diff --git a/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl b/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl index dd5aadc1f0..aec4a7d912 100644 --- a/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl +++ b/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl @@ -50,7 +50,7 @@ {if $hasParent || $isRepeatingEntity} {literal} {/literal} diff --git a/templates/CRM/Event/Form/ManageEvent/Tab.tpl b/templates/CRM/Event/Form/ManageEvent/Tab.tpl index 1f1a1e08c7..00ea9b8254 100644 --- a/templates/CRM/Event/Form/ManageEvent/Tab.tpl +++ b/templates/CRM/Event/Form/ManageEvent/Tab.tpl @@ -86,7 +86,7 @@ CRM.$(function($) { event.stopPropagation(); return false; }); - + $('#crm-participant-link').click(function(event) { $('#crm-participant-list').toggle(); $('#crm-event-links-list').hide(); diff --git a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php index 07b7c4aa75..0d82282973 100644 --- a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php +++ b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php @@ -52,7 +52,7 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { protected function setUp() { parent::setUp(); } - + /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. @@ -86,13 +86,13 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { 'used_for' => 'activity' ); - $generatedEntities = $recursion->generate(); + $generatedEntities = $recursion->generate(); $this->assertEquals(5, count($generatedEntities['civicrm_activity']), "Cehck if number of iterations are 5"); $expectedDates = array( - '20141025103000', - '20141227103000', - '20150328103000', - '20150627103000', + '20141025103000', + '20141227103000', + '20150328103000', + '20150627103000', '20150926103000' ); foreach ($generatedEntities['civicrm_activity'] as $entityID) { @@ -117,9 +117,9 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { } $resultDates = array_diff($actualDates, $expectedDates); $this->assertEquals(0, count($resultDates), "Check if all the value in expected array matches actual array"); - + } - + /** * Testing Event Generation through Entity Recursion */ @@ -135,7 +135,7 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { $daoEvent->is_active = 1; $daoEvent->save(); $this->assertDBNotNull('CRM_Event_DAO_Event', $daoEvent->id, 'id', 'id', 'Check DB if event was created'); - + //Create tell a friend for event $daoTellAFriend = new CRM_Friend_DAO_Friend(); $daoTellAFriend->entity_table = 'civicrm_event'; @@ -164,17 +164,17 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { array( 'table' => 'civicrm_tell_friend', 'findCriteria' => array( - 'entity_id' => $recursion->entity_id, + 'entity_id' => $recursion->entity_id, 'entity_table' => 'civicrm_event' ), 'linkedColumns' => array('entity_id'), 'isRecurringEntityRecord' => TRUE, ), ); - + $interval = $recursion->getInterval($daoEvent->start_date, $daoEvent->end_date); $recursion->intervalDateColumns = array('end_date' => $interval); - $generatedEntities = $recursion->generate(); + $generatedEntities = $recursion->generate(); $this->assertArrayHasKey('civicrm_event', $generatedEntities, 'Check if generatedEntities has civicrm_event as required key'); $expectedDates = array( '20141027103000' => '20141029103000', @@ -182,7 +182,7 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { '20141110103000' => '20141112103000', '20141117103000' => '20141119103000' ); - + $this->assertCount($recursion->schedule['start_action_offset'], $generatedEntities['civicrm_event'], 'Check if the number of events created are right'); $actualDates = array(); foreach($generatedEntities['civicrm_event'] as $key => $val) { @@ -191,16 +191,16 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { $endDate = date('YmdHis', strtotime(CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $val, 'end_date', 'id'))); $actualDates[$startDate] = $endDate; } - + $resultDates = array_diff($actualDates, $expectedDates); $this->assertEquals(0, count($resultDates), "Check if all the value in expected array matches actual array"); - + foreach($generatedEntities['civicrm_tell_friend'] as $key => $val) { $this->assertDBNotNull('CRM_Friend_DAO_Friend', $val, 'id', 'id', 'Check if friends were created in loop'); $this->assertDBCompareValue('CRM_Friend_DAO_Friend', $val, 'entity_id', 'id', $generatedEntities['civicrm_event'][$key], 'Check DB if correct FK was maintained with event for Friend'); } $this->assertCount($recursion->schedule['start_action_offset'], $generatedEntities['civicrm_tell_friend'], 'Check if the number of tell a friend records are right'); - + // set mode to ALL, i.e any change to changing event affects all related recurring activities $recursion->mode(3); @@ -212,16 +212,16 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { foreach ($generatedEntities['civicrm_event'] as $entityID) { $this->assertDBCompareValue('CRM_Event_DAO_Event', $entityID, 'title', 'id', 'Event Changed', 'Check if title was updated'); } - - end($generatedEntities['civicrm_event']); + + end($generatedEntities['civicrm_event']); $key = key($generatedEntities['civicrm_event']); - + end($generatedEntities['civicrm_tell_friend']); $actKey = key($generatedEntities['civicrm_tell_friend']); - + //Check if both(event/tell a friend) keys are same $this->assertEquals($key, $actKey, "Check if both the keys are same"); - + //Cross check event exists before we test deletion $searchParamsEventBeforeDelete = array( 'entity_id' => $generatedEntities['civicrm_event'][$key], @@ -232,7 +232,7 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { 'entity_table' => 'civicrm_event' ); $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParamsEventBeforeDelete, $expectedValuesEventBeforeDelete); - + //Cross check event exists before we test deletion $searchParamsTellAFriendBeforeDelete = array( 'entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], @@ -243,7 +243,7 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { 'entity_table' => 'civicrm_tell_friend' ); $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParamsTellAFriendBeforeDelete, $expectedValuesTellAFriendBeforeDelete); - + //Delete an event from recurring set and respective linked entity should be deleted from civicrm_recurring_entity_table $daoRecurEvent = new CRM_Event_DAO_Event(); $daoRecurEvent->id = $generatedEntities['civicrm_event'][$key]; @@ -251,7 +251,7 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { $daoRecurEvent->delete(); $daoRecurEvent->free(); } - + //Check if this event_id was deleted $this->assertDBNull('CRM_Event_DAO_Event', $generatedEntities['civicrm_event'][$key], 'id', 'id', 'Check if event was deleted'); $searchParams = array( -- 2.25.1