From: Tim Otten Date: Tue, 6 Jan 2015 21:09:20 +0000 (-0800) Subject: INFRA-132 - CRM/Core - phpcbf X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2aa397bc9ba4608d4146278d55dedd4080c53aec;p=civicrm-core.git INFRA-132 - CRM/Core - phpcbf --- diff --git a/CRM/Core/Action.php b/CRM/Core/Action.php index 832cb52d90..4c7f8923f7 100644 --- a/CRM/Core/Action.php +++ b/CRM/Core/Action.php @@ -64,8 +64,8 @@ class CRM_Core_Action { RENEW = 32768, DETACH = 65536, REVERT = 131072, - CLOSE = 262144, - REOPEN = 524288, + CLOSE = 262144, + REOPEN = 524288, MAX_ACTION = 1048575; //make sure MAX_ACTION = 2^n - 1 ( n = total number of actions ) @@ -277,7 +277,6 @@ class CRM_Core_Action { } } - $mainLinks = $url; if ($enclosedAllInSingleUL) { $allLinks = ''; diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 762063f1d6..c5ed9d45d7 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -689,11 +689,12 @@ AND cas.entity_value = $id AND while ($actionSchedule->fetch()) { $extraSelect = $extraJoin = $extraWhere = $extraOn = ''; - if ($actionSchedule->from_email) + if ($actionSchedule->from_email) { $fromEmailAddress = "$actionSchedule->from_name <$actionSchedule->from_email>"; + } - $activityTypeID = false; - $activityStatusID = false; + $activityTypeID = FALSE; + $activityStatusID = FALSE; if ($actionSchedule->record_activity) { if ($mapping->entity == 'civicrm_membership') { $activityTypeID = @@ -818,7 +819,7 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL elseif ($field == 'registration_url') { $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $dao->event_id, TRUE, NULL, FALSE); } - elseif (in_array($field, array('start_date','end_date','join_date','activity_date_time'))) { + elseif (in_array($field, array('start_date', 'end_date', 'join_date', 'activity_date_time'))) { $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Date::customFormat($dao->$field); } elseif ($field == 'balance') { @@ -954,7 +955,7 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL ); $status = implode(',', $status); - $anniversary = false; + $anniversary = FALSE; if (!CRM_Utils_System::isNull($mapping->entity_recipient)) { if ($mapping->entity_recipient == 'event_contacts') { @@ -1077,7 +1078,7 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL $notINClause = self::permissionedRelationships($contactField); $membershipStatus = CRM_Member_PseudoConstant::membershipStatus(NULL, "(is_current_member = 1 OR name = 'Expired')", 'id'); - $mStatus = implode (',', $membershipStatus); + $mStatus = implode(',', $membershipStatus); $where[] = "e.status_id IN ({$mStatus})"; } @@ -1106,7 +1107,7 @@ WHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL if (in_array(2, $status_)) { // anniversary mode: $dateField = 'DATE_ADD(e.' . $dateDBField . ', INTERVAL ROUND(DATEDIFF(DATE(' . $now . '), e.' . $dateDBField . ') / 365) YEAR)'; - $anniversary = true; + $anniversary = TRUE; } else { // regular mode: @@ -1250,7 +1251,7 @@ LEFT JOIN {$reminderJoinClause} if ($addWhere) { $addWhereClause = "AND {$addWhere}"; } - $insertAdditionalSql =" + $insertAdditionalSql = " INSERT INTO civicrm_action_log (contact_id, entity_id, entity_table, action_schedule_id) {$addSelect} FROM ({$contactTable}) @@ -1388,7 +1389,7 @@ WHERE m.owner_membership_id IS NOT NULL AND if (!empty($excludeIds)) { $clause = "AND {$field} NOT IN ( " .implode(', ', $excludeIds) . ' ) '; - return $clause; + return $clause; } return NULL; } diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index e241c59009..d7af70f013 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -498,7 +498,8 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { if ($count > 1) { foreach (array( 'state', 'state_name', 'country', 'world_region') as $fld) { - if (isset($address->$fld))unset($address->$fld); + if (isset($address->$fld)) { unset($address->$fld); + } } } $stree = $address->street_address; @@ -1024,20 +1025,20 @@ SELECT is_primary, if ($count > 2) { break; } - if(count($first_names) == 1){ - $family = $first_names[current(array_keys($first_names))]['addressee_display']; - } - else { - // collapse the tree to summarize - $family = trim(implode(" & ", array_keys($first_names)) . " " . $last_name); - } - if ($count) { - $processedNames .= "\n" . $family; - } - else { - // build display_name string - $processedNames = $family; - } + if(count($first_names) == 1){ + $family = $first_names[current(array_keys($first_names))]['addressee_display']; + } + else { + // collapse the tree to summarize + $family = trim(implode(" & ", array_keys($first_names)) . " " . $last_name); + } + if ($count) { + $processedNames .= "\n" . $family; + } + else { + // build display_name string + $processedNames = $family; + } $count++; } $rows[$data['ID']]['addressee'] = $rows[$data['ID']]['addressee_display'] = $rows[$data['ID']]['display_name'] = $processedNames; @@ -1223,6 +1224,7 @@ SELECT is_primary, $params['condition'] = 'country_id IN (' . implode(',', (array) $props['country_id']) . ')'; } break; + // Filter country list based on site defaults case 'country_id': if ($context != 'get' && $context != 'validate') { @@ -1232,16 +1234,19 @@ SELECT is_primary, } } break; + // Filter county list based on chosen state case 'county_id': if (!empty($props['state_province_id'])) { $params['condition'] = 'state_province_id IN (' . implode(',', (array) $props['state_province_id']) . ')'; } break; + // Not a real field in this entity case 'world_region': return CRM_Core_PseudoConstant::worldRegion(); - break; + + break; } return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); } diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index 461b22428a..4d45db3347 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -517,13 +517,13 @@ class CRM_Core_BAO_Block { uasort($locations, 'self::primaryComparison'); } -/** - * compare 2 locations to see which should go first based on is_primary - * (sort function for sortPrimaryFirst) - * @param array $location1 - * @param array $location2 - * @return number - */ + /** + * compare 2 locations to see which should go first based on is_primary + * (sort function for sortPrimaryFirst) + * @param array $location1 + * @param array $location2 + * @return number + */ public static function primaryComparison($location1, $location2){ $l1 = CRM_Utils_Array::value('is_primary', $location1); $l2 = CRM_Utils_Array::value('is_primary', $location2); diff --git a/CRM/Core/BAO/CMSUser.php b/CRM/Core/BAO/CMSUser.php index cdaebe3a51..88aaf2f511 100644 --- a/CRM/Core/BAO/CMSUser.php +++ b/CRM/Core/BAO/CMSUser.php @@ -419,7 +419,7 @@ class CRM_Core_BAO_CMSUser { /** * Check if a cms user already exists. * - * @param Array $contact + * @param array $contactArray of contact-details. * Array of contact-details. * * @return uid if user exists, false otherwise diff --git a/CRM/Core/BAO/Cache.php b/CRM/Core/BAO/Cache.php index 31776e24eb..525eacf22f 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -249,28 +249,28 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { public static function storeSessionToCache($names, $resetSession = TRUE) { foreach ($names as $key => $sessionName) { if (is_array($sessionName)) { - $value = null; + $value = NULL; if (!empty($_SESSION[$sessionName[0]][$sessionName[1]])) { $value = $_SESSION[$sessionName[0]][$sessionName[1]]; } self::setItem($value, 'CiviCRM Session', "{$sessionName[0]}_{$sessionName[1]}"); - if ($resetSession) { - $_SESSION[$sessionName[0]][$sessionName[1]] = NULL; - unset($_SESSION[$sessionName[0]][$sessionName[1]]); - } + if ($resetSession) { + $_SESSION[$sessionName[0]][$sessionName[1]] = NULL; + unset($_SESSION[$sessionName[0]][$sessionName[1]]); } + } else { - $value = null; + $value = NULL; if (!empty($_SESSION[$sessionName])) { $value = $_SESSION[$sessionName]; } self::setItem($value, 'CiviCRM Session', $sessionName); - if ($resetSession) { - $_SESSION[$sessionName] = NULL; - unset($_SESSION[$sessionName]); - } + if ($resetSession) { + $_SESSION[$sessionName] = NULL; + unset($_SESSION[$sessionName]); } } + } self::cleanup(); } @@ -321,7 +321,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { * @return void * @static */ - public static function cleanup($session = false, $table = false, $prevNext = false) { + public static function cleanup($session = FALSE, $table = FALSE, $prevNext = FALSE) { // clean up the session cache every $cacheCleanUpNumber probabilistically $cleanUpNumber = 757; @@ -330,7 +330,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { $timeIntervalMins = 30; if (mt_rand(1, 100000) % $cleanUpNumber == 0) { - $session = $table = $prevNext = true; + $session = $table = $prevNext = TRUE; } if ( ! $session && ! $table && ! $prevNext ) { diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index be7850a27c..24fee26246 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -243,7 +243,7 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { * * @param int $id * Id of the database record. - * @param boolean $is_active + * @param bool $is_activeValue we want to set the is_active field. * Value we want to set the is_active field. * * @return Object DAO object on sucess, null otherwise @@ -1120,6 +1120,7 @@ ORDER BY civicrm_custom_group.weight, case 'Group': $tableName = 'civicrm_group'; break; + // DRAFTING: Verify if we cannot make it pluggable case 'Activity': @@ -1145,6 +1146,7 @@ ORDER BY civicrm_custom_group.weight, case 'Grant': $tableName = 'civicrm_grant'; break; + // need to add cases for Location, Address } @@ -1454,7 +1456,6 @@ ORDER BY civicrm_custom_group.weight, } } - if (!isset($groupTree[$groupID]['fields'][$fieldId]['customValue'])) { // field exists in db so populate value from "form". $groupTree[$groupID]['fields'][$fieldId]['customValue'] = array(); @@ -2080,8 +2081,8 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $retValue = $value; break; } - // note that if its not text / textarea, the code falls thru and executes - // the below case also + // note that if its not text / textarea, the code falls thru and executes + // the below case also case 'StateProvince': case 'Country': $options = array(); @@ -2310,8 +2311,8 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT } list($className) = explode('::', $callback); - require_once(str_replace('_', DIRECTORY_SEPARATOR, $className) . - '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $className) . + '.php'; $objTypes[$ovValues['value']] = call_user_func_array($callback, $args); } diff --git a/CRM/Core/BAO/CustomOption.php b/CRM/Core/BAO/CustomOption.php index 2dd00e5ae0..179abf99ab 100644 --- a/CRM/Core/BAO/CustomOption.php +++ b/CRM/Core/BAO/CustomOption.php @@ -65,7 +65,7 @@ class CRM_Core_BAO_CustomOption { * * @param int $fieldID * Field whose options are needed. - * @param boolean $inactiveNeeded + * @param bool $inactiveNeededDo we need inactive options ?. * Do we need inactive options ?. * * @return array $customOption all active options for fieldId @@ -271,7 +271,8 @@ WHERE id = %2"; $query = " UPDATE {$dao->tableName} SET {$dao->columnName} = REPLACE( {$dao->columnName}, %1, %2 )"; - $queryParams = array(1 => array($oldString, 'String'), + $queryParams = array( + 1 => array($oldString, 'String'), 2 => array($newString, 'String'), ); break; diff --git a/CRM/Core/BAO/CustomQuery.php b/CRM/Core/BAO/CustomQuery.php index 6cfabd34ee..b36e4daf0a 100644 --- a/CRM/Core/BAO/CustomQuery.php +++ b/CRM/Core/BAO/CustomQuery.php @@ -538,6 +538,7 @@ SELECT label, value case 'IS EMPTY': $op = 'IS NULL'; break; + case 'IS NOT EMPTY': $op = 'IS NOT NULL'; break; diff --git a/CRM/Core/BAO/CustomValueTable.php b/CRM/Core/BAO/CustomValueTable.php index a3d59bed39..15d6290e00 100644 --- a/CRM/Core/BAO/CustomValueTable.php +++ b/CRM/Core/BAO/CustomValueTable.php @@ -279,6 +279,7 @@ class CRM_Core_BAO_CustomValueTable { case 'Int': return 'int'; + // the below three are FK's, and have constraints added to them case 'ContactReference': @@ -457,7 +458,7 @@ AND $cond if ($formatMultiRecordField) { if($file[$tableName][$fieldID] == 'File') { if($fileid = $dao->$fieldName) { - $fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName,$entityID); + $fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName, $entityID); $result["{$dao->id}"]["{$fieldID}"] = $fileurl[$dao->$fieldName]; } } @@ -471,7 +472,7 @@ AND $cond else { if($file[$tableName][$fieldID] == 'File') { if($fileid = $dao->$fieldName) { - $fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName,$entityID); + $fileurl = CRM_Core_BAO_File::paperIconAttachment($tableName, $entityID); $result[$fieldID] = $fileurl[$dao->$fieldName]; } } @@ -572,7 +573,7 @@ AND cf.id IN ( $fieldIDList ) case 'Country': case 'Money': case 'Float': - $fieldValue['value'] = (int)0; + $fieldValue['value'] = (int) 0; break; } } diff --git a/CRM/Core/BAO/Dashboard.php b/CRM/Core/BAO/Dashboard.php index dedcf89956..d100387e2d 100644 --- a/CRM/Core/BAO/Dashboard.php +++ b/CRM/Core/BAO/Dashboard.php @@ -343,7 +343,7 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { * @return void * @static */ - public static function saveDashletChanges($columns, $contactID=NULL) { + public static function saveDashletChanges($columns, $contactID = NULL) { $session = CRM_Core_Session::singleton(); if (!$contactID) { $contactID = $session->get('userID'); @@ -545,8 +545,8 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { * @return void * @static */ - public static function resetDashletCache($contactID = null) { - $whereClause = null; + public static function resetDashletCache($contactID = NULL) { + $whereClause = NULL; $params = array(); if ($contactID) { $whereClause = "WHERE contact_id = %1"; diff --git a/CRM/Core/BAO/Discount.php b/CRM/Core/BAO/Discount.php index 0eff753524..770fe2850f 100644 --- a/CRM/Core/BAO/Discount.php +++ b/CRM/Core/BAO/Discount.php @@ -50,7 +50,7 @@ class CRM_Core_BAO_Discount extends CRM_Core_DAO_Discount { * @return boolean * @static */ - public static function del($entityId,$entityTable) { + public static function del($entityId, $entityTable) { // delete all discount records with the selected discounted id $discount = new CRM_Core_DAO_Discount( ); $discount->entity_id = $entityId; @@ -84,7 +84,7 @@ class CRM_Core_BAO_Discount extends CRM_Core_DAO_Discount { * Determine whether the given table/id * has discount associated with it * - * @param integer $entityId + * @param int $entityIdEntity id to be searched. * Entity id to be searched. * @param string $entityTable * Entity table to be searched. diff --git a/CRM/Core/BAO/Domain.php b/CRM/Core/BAO/Domain.php index fba2870043..6cb255d2bb 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -71,7 +71,7 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { * @return null|object CRM_Core_BAO_Domain * @static */ - public static function &getDomain($reset = null) { + public static function &getDomain($reset = NULL) { static $domain = NULL; if (!$domain || $reset) { $domain = new CRM_Core_BAO_Domain(); @@ -83,20 +83,20 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { return $domain; } - /** - * Change active domain (ie. to perform a temporary action) such as changing - * config for all domains - * - * Switching around the global domain variable is very risky business. This - * is ONLY used as a hack to allow CRM_Core_BAO_Setting::setItems to manipulate - * the civicrm_domain.config_backend in multiple domains. When/if config_backend - * goes away, this hack should be removed. - * - * @param int $domainID - * Id for domain you want to set as current. - * @deprecated - * @see http://issues.civicrm.org/jira/browse/CRM-11204 - */ + /** + * Change active domain (ie. to perform a temporary action) such as changing + * config for all domains + * + * Switching around the global domain variable is very risky business. This + * is ONLY used as a hack to allow CRM_Core_BAO_Setting::setItems to manipulate + * the civicrm_domain.config_backend in multiple domains. When/if config_backend + * goes away, this hack should be removed. + * + * @param int $domainID + * Id for domain you want to set as current. + * @deprecated + * @see http://issues.civicrm.org/jira/browse/CRM-11204 + */ public static function setDomain($domainID) { CRM_Core_Config::domainID($domainID); self::getDomain($domainID); @@ -111,8 +111,8 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { * @see CRM_Core_BAO_Domain::setDomain */ public static function resetDomain() { - CRM_Core_Config::domainID(null, true); - self::getDomain(null, true); + CRM_Core_Config::domainID(NULL, TRUE); + self::getDomain(NULL, TRUE); CRM_Core_Config::singleton(TRUE, TRUE); } @@ -121,7 +121,7 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { * * @return null|string */ - public static function version($skipUsingCache = false) { + public static function version($skipUsingCache = FALSE) { return CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', CRM_Core_Config::domainID(), 'version', @@ -139,7 +139,7 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { */ public function &getLocationValues() { if ($this->_location == NULL) { - $domain = self::getDomain(null); + $domain = self::getDomain(NULL); $params = array( 'contact_id' => $domain->contact_id ); @@ -269,7 +269,7 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { CRM_Core_Config::domainID(), 'name' ); $groupID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', - $title, 'id', 'title', true + $title, 'id', 'title', TRUE ); if (empty($groupID) && !empty($title)) { $groupParams = array( diff --git a/CRM/Core/BAO/Email.php b/CRM/Core/BAO/Email.php index 99015fb0ff..e5ee11cb20 100644 --- a/CRM/Core/BAO/Email.php +++ b/CRM/Core/BAO/Email.php @@ -90,9 +90,9 @@ UPDATE civicrm_email SET is_bulkmail = 0 WHERE contact_id = {$params['contact_id']} "; - if($hook == 'edit'){ - $sql .= " AND id <> {$params['id']}"; - } + if($hook == 'edit'){ + $sql .= " AND id <> {$params['id']}"; + } CRM_Core_DAO::executeQuery($sql); } @@ -200,7 +200,6 @@ ORDER BY civicrm_email.is_primary DESC, email_id ASC "; $entityId = $entityElements['entity_id']; $entityTable = $entityElements['entity_table']; - $sql = " SELECT email, ltype.name as locationType, e.is_primary as is_primary, e.on_hold as on_hold,e.id as email_id, e.location_type_id as locationTypeId FROM civicrm_loc_block loc, civicrm_email e, civicrm_location_type ltype, {$entityTable} ev WHERE ev.id = %1 diff --git a/CRM/Core/BAO/EntityTag.php b/CRM/Core/BAO/EntityTag.php index 5be2c20a1d..441b8169ed 100644 --- a/CRM/Core/BAO/EntityTag.php +++ b/CRM/Core/BAO/EntityTag.php @@ -46,7 +46,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * Name of the entity table usually 'civicrm_contact'. * * @return array( - ) reference $tag array of category id's the contact belongs to. + ) reference $tag array of category id's the contact belongs to. * * @static */ @@ -345,7 +345,8 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * Merge two tags: tag B into tag A. */ public function mergeTags($tagAId, $tagBId) { - $queryParams = array(1 => array($tagBId, 'Integer'), + $queryParams = array( + 1 => array($tagBId, 'Integer'), 2 => array($tagAId, 'Integer'), ); diff --git a/CRM/Core/BAO/Tag.php b/CRM/Core/BAO/Tag.php index e58209512d..4625c39ec5 100644 --- a/CRM/Core/BAO/Tag.php +++ b/CRM/Core/BAO/Tag.php @@ -128,8 +128,8 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { */ public static function getTagsUsedFor($usedFor = array('civicrm_contact'), $buildSelect = TRUE, - $all = FALSE, - $parentId = NULL + $all = FALSE, + $parentId = NULL ) { $tags = array(); @@ -198,7 +198,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { */ static function getTags($usedFor = 'civicrm_contact', &$tags = array(), - $parentId = NULL, + $parentId = NULL, $separator = '  ', $formatSelectable = FALSE ) { @@ -392,7 +392,8 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { // if we modify parent tag, then we need to update all children if ($tag->parent_id === 'null') { CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET used_for=%1 WHERE parent_id = %2", - array(1 => array($params['used_for'], 'String'), + array( + 1 => array($params['used_for'], 'String'), 2 => array($tag->id, 'Integer'), ) ); diff --git a/CRM/Core/BAO/UFField.php b/CRM/Core/BAO/UFField.php index 24cc27cf20..8bd5e6137e 100644 --- a/CRM/Core/BAO/UFField.php +++ b/CRM/Core/BAO/UFField.php @@ -607,7 +607,7 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; * * TODO Why is this function in this class? It seems to be about the UFGroup. */ - public static function calculateProfileType($ufGroupType, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType= FALSE) { + public static function calculateProfileType($ufGroupType, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType = FALSE) { // profile types $contactTypes = array('Contact', 'Individual', 'Household', 'Organization'); $subTypes = CRM_Contact_BAO_ContactType::subTypes(); @@ -808,7 +808,10 @@ SELECT id list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2); $profileFields = civicrm_api3('uf_field', 'get', array_merge($profileFilter, - array('is_active' => 1, 'return' => 'field_name, is_required', 'options' => array( + array( + 'is_active' => 1, + 'return' => 'field_name, is_required', + 'options' => array( 'limit' => 0, )) )); @@ -824,7 +827,7 @@ SELECT id 'postal_code', 'country' ); - $requiredBillingFields = array_diff($validBillingFields, array('middle_name','supplemental_address_1')); + $requiredBillingFields = array_diff($validBillingFields, array('middle_name', 'supplemental_address_1')); $validProfileFields = array(); $requiredProfileFields = array(); diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index a5eedeb73a..e1178aea75 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -87,8 +87,9 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { elseif (array_key_exists($type, $validSubTypes)) { $cType = CRM_Utils_Array::value('parent', $validSubTypes[$type]); } - if ($cType) + if ($cType) { break; + } } return $cType; @@ -241,7 +242,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { if ($considerSelector) { // drop the fields not meant for the selector foreach ($subset as $name => $field) { - if (!$field['in_selector']) unset($subset[$name]); + if (!$field['in_selector']) { unset($subset[$name]); + } } } $fields = array_merge($fields, $subset); @@ -990,7 +992,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { // Create a unique, non-empty index for each field. $index = $field['title']; - if ($index === '') $index = ' '; + if ($index === '') { $index = ' '; + } while (array_key_exists($index, $values)) { $index .= ' '; } @@ -1696,7 +1699,6 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $p[2] = array($moduleName, 'String'); } - // add permissioning for profiles only if not registration if (!$skipPermission) { $permissionClause = CRM_Core_Permission::ufGroupClause($op, 'civicrm_uf_group.'); @@ -3014,7 +3016,6 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) $data['location'][$loc]['email'][$loc]['email'] = $primaryEmail; } - return $data; } diff --git a/CRM/Core/BAO/UFMatch.php b/CRM/Core/BAO/UFMatch.php index e2f223b6f7..0e8d7ed47c 100644 --- a/CRM/Core/BAO/UFMatch.php +++ b/CRM/Core/BAO/UFMatch.php @@ -628,7 +628,7 @@ AND domain_id = %4 * Uf id. * * return array $ufValues uf values. - ** + * * * * @return array */ diff --git a/CRM/Core/BAO/WordReplacement.php b/CRM/Core/BAO/WordReplacement.php index a50f313b09..3fdc7fec2f 100644 --- a/CRM/Core/BAO/WordReplacement.php +++ b/CRM/Core/BAO/WordReplacement.php @@ -114,7 +114,7 @@ class CRM_Core_BAO_WordReplacement extends CRM_Core_DAO_WordReplacement { * @return WordReplacement array */ public static function create($params) { - if(array_key_exists("domain_id",$params) === FALSE) { + if(array_key_exists("domain_id", $params) === FALSE) { $params["domain_id"] = CRM_Core_Config::domainID(); } $wordReplacement = new CRM_Core_DAO_WordReplacement(); @@ -166,7 +166,7 @@ WHERE domain_id = %1 $overrides = array(); while ($dao->fetch()) { - if ($dao->is_active==1) { + if ($dao->is_active == 1) { $overrides['enabled'][$dao->match_type][$dao->find_word] = $dao->replace_word; } else { @@ -248,9 +248,9 @@ WHERE domain_id = %1 $wordMatchArray = array(); // Traverse Language array foreach ($localeCustomArray as $localCustomData) { - // Traverse status array "enabled" "disabled" + // Traverse status array "enabled" "disabled" foreach ($localCustomData as $status => $matchTypes) { - $params["is_active"] = ($status == "enabled")?TRUE:FALSE; + $params["is_active"] = ($status == "enabled") ? TRUE : FALSE; // Traverse Match Type array "wildcardMatch" "exactMatch" foreach ($matchTypes as $matchType => $words) { $params["match_type"] = $matchType; diff --git a/CRM/Core/Base.php b/CRM/Core/Base.php index c4ae8acc2c..5d95e807ec 100644 --- a/CRM/Core/Base.php +++ b/CRM/Core/Base.php @@ -46,5 +46,6 @@ class CRM_Core_Base { /** * Constructor */ - public function __construct() {} + public function __construct() { + } } diff --git a/CRM/Core/Block.php b/CRM/Core/Block.php index 799033e72d..d566719541 100644 --- a/CRM/Core/Block.php +++ b/CRM/Core/Block.php @@ -63,7 +63,8 @@ class CRM_Core_Block { * Class constructor * */ - public function __construct() {} + public function __construct() { + } /** * Initialises the $_properties array @@ -301,7 +302,8 @@ class CRM_Core_Block { case self::ADD: $defaultLocation = CRM_Core_BAO_LocationType::getDefault(); $defaultPrimaryLocationId = $defaultLocation->id; - $values = array('postURL' => CRM_Utils_System::url('civicrm/contact/add', 'reset=1&ct=Individual'), + $values = array( + 'postURL' => CRM_Utils_System::url('civicrm/contact/add', 'reset=1&ct=Individual'), 'primaryLocationType' => $defaultPrimaryLocationId, ); @@ -315,11 +317,12 @@ class CRM_Core_Block { ); break; - case self::LANGSWITCH: + case self::LANGSWITCH: // gives the currentPath without trailing empty lcMessages to be completed $values = array('queryString' => CRM_Utils_System::getLinksUrl('lcMessages', TRUE, FALSE, FALSE)); self::setProperty(self::LANGSWITCH, 'templateValues', $values); break; + case self::FULLTEXT_SEARCH: $urlArray = array( 'fullTextSearchID' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', @@ -380,7 +383,8 @@ class CRM_Core_Block { // new email (select recipients) $shortCuts = array_merge($shortCuts, array( - array('path' => 'civicrm/activity/email/add', + array( + 'path' => 'civicrm/activity/email/add', 'query' => 'atype=3&action=add&reset=1&context=standalone', 'ref' => 'new-email', 'title' => ts('Email'), @@ -388,7 +392,8 @@ class CRM_Core_Block { if (CRM_Core_Permission::check('edit groups')) { $shortCuts = array_merge($shortCuts, array( - array('path' => 'civicrm/group/add', + array( + 'path' => 'civicrm/group/add', 'query' => 'reset=1', 'ref' => 'new-group', 'title' => ts('Group'), @@ -397,7 +402,8 @@ class CRM_Core_Block { if (CRM_Core_Permission::check('administer CiviCRM')) { $shortCuts = array_merge($shortCuts, array( - array('path' => 'civicrm/admin/tag', + array( + 'path' => 'civicrm/admin/tag', 'query' => 'reset=1&action=add', 'ref' => 'new-tag', 'title' => ts('Tag'), @@ -464,7 +470,8 @@ class CRM_Core_Block { static $dashboardLinks = array(); if (CRM_Core_Permission::check('access Contact Dashboard')) { $dashboardLinks = array( - array('path' => 'civicrm/user', + array( + 'path' => 'civicrm/user', 'query' => 'reset=1', 'title' => ts('My Contact Dashboard'), )); @@ -500,7 +507,8 @@ class CRM_Core_Block { if (!($shortCuts)) { $shortCuts = array( - array('path' => 'civicrm/mailing/send', + array( + 'path' => 'civicrm/mailing/send', 'query' => 'reset=1', 'title' => ts('Send Mailing'), ), @@ -591,7 +599,7 @@ class CRM_Core_Block { // do nothing } // require 'access CiviCRM' permissons, except for the language switch block - elseif (!CRM_Core_Permission::check('access CiviCRM') && $id!=self::LANGSWITCH) { + elseif (!CRM_Core_Permission::check('access CiviCRM') && $id != self::LANGSWITCH) { return NULL; } elseif ($id == self::ADD) { @@ -636,7 +644,6 @@ class CRM_Core_Block { self::getProperty($id, 'templateValues') ); - return $block; } diff --git a/CRM/Core/ClassLoader.php b/CRM/Core/ClassLoader.php index 0022213d32..4ab4e32236 100644 --- a/CRM/Core/ClassLoader.php +++ b/CRM/Core/ClassLoader.php @@ -164,7 +164,7 @@ class CRM_Core_ClassLoader { // "require_once" is nice because it's simple and throws // intelligible errors. The down side is that autoloaders // down the chain cannot try to find the file if we fail. - require_once ($file); + require_once $file; } } } diff --git a/CRM/Core/CodeGen/Config.php b/CRM/Core/CodeGen/Config.php index fffbaa17e3..9acf881daf 100644 --- a/CRM/Core/CodeGen/Config.php +++ b/CRM/Core/CodeGen/Config.php @@ -47,8 +47,9 @@ class CRM_Core_CodeGen_Config extends CRM_Core_CodeGen_BaseTask { switch ($cms) { case 'drupal': $candidates[] = "../drupal/civicrm.config.php.drupal"; - $candidates[] = "../../drupal/civicrm.config.php.drupal"; + $candidates[] = "../../drupal/civicrm.config.php.drupal"; break; + case 'wordpress': $candidates[] = "../../civicrm.config.php.wordpress"; $candidates[] = "../WordPress/civicrm.config.php.wordpress"; diff --git a/CRM/Core/CodeGen/I18n.php b/CRM/Core/CodeGen/I18n.php index f450a99d42..156a7e9118 100644 --- a/CRM/Core/CodeGen/I18n.php +++ b/CRM/Core/CodeGen/I18n.php @@ -18,7 +18,7 @@ class CRM_Core_CodeGen_I18n extends CRM_Core_CodeGen_BaseTask { for ($i = 0; $i < count($matches[0]); $i++) { $langs[$matches[1][$i]] = $matches[2][$i]; } - file_put_contents('../install/langs.php', "tables = $this->orderTables($this->tables); // add archive tables here - $archiveTables = array( ); + $archiveTables = array(); foreach ($this->tables as $name => $table ) { if ( $table['archive'] == 'true' ) { $name = 'archive_' . $table['name']; @@ -302,7 +302,8 @@ class CRM_Core_CodeGen_Specification { $field['rows'] = isset($fieldXML->html) ? $this->value('rows', $fieldXML->html) : NULL; $field['cols'] = isset($fieldXML->html) ? $this->value('cols', $fieldXML->html) : NULL; break; - break; + + break; case 'datetime': $field['sqlType'] = $field['phpType'] = $type; @@ -451,7 +452,7 @@ class CRM_Core_CodeGen_Specification { /** need to make sure there is a field of type name */ if (!array_key_exists($name, $fields)) { - echo "primary key $name in $table->name does not have a field definition, ignoring\n"; + echo "primary key $name in $table->name does not have a field definition, ignoring\n"; return; } @@ -476,14 +477,14 @@ class CRM_Core_CodeGen_Specification { $index = array(); // empty index name is fine - $indexName = trim((string)$indexXML->name); + $indexName = trim((string) $indexXML->name); $index['name'] = $indexName; $index['field'] = array(); // populate fields foreach ($indexXML->fieldName as $v) { - $fieldName = (string)($v); - $length = (string)($v['length']); + $fieldName = (string) ($v); + $length = (string) ($v['length']); if (strlen($length) > 0) { $fieldName = "$fieldName($length)"; } @@ -542,7 +543,7 @@ class CRM_Core_CodeGen_Specification { /** need to make sure there is a field of type name */ if (!array_key_exists($name, $fields)) { - echo "foreign $name in $currentTableName does not have a field definition, ignoring\n"; + echo "foreign $name in $currentTableName does not have a field definition, ignoring\n"; return; } diff --git a/CRM/Core/Component.php b/CRM/Core/Component.php index b8bcbc5b78..bdd7186089 100644 --- a/CRM/Core/Component.php +++ b/CRM/Core/Component.php @@ -99,7 +99,7 @@ class CRM_Core_Component { $cr->find(FALSE); while ($cr->fetch()) { $infoClass = $cr->namespace . '_' . self::COMPONENT_INFO_CLASS; - require_once (str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php'; $infoObject = new $infoClass($cr->name, $cr->namespace, $cr->id); if ($infoObject->info['name'] !== $cr->name) { CRM_Core_Error::fatal("There is a discrepancy between name in component registry and in info file ({$cr->name})."); @@ -453,7 +453,7 @@ class CRM_Core_Component { $infoFile = $crmFolderDir . "/{$subDir}/" . self::COMPONENT_INFO_CLASS . '.php'; if (file_exists($infoFile)) { $infoClass = 'CRM_' . $subDir . '_' . self::COMPONENT_INFO_CLASS; - require_once (str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $infoClass) . '.php'; $infoObject = new $infoClass(NULL, NULL, NULL); $components[$infoObject->info['name']] = $infoObject; unset($infoObject); diff --git a/CRM/Core/Component/Info.php b/CRM/Core/Component/Info.php index f9c0b07b21..17f1288172 100644 --- a/CRM/Core/Component/Info.php +++ b/CRM/Core/Component/Info.php @@ -370,7 +370,7 @@ abstract class CRM_Core_Component_Info { */ private function _instantiate($cl) { $className = $this->namespace . '_' . $cl; - require_once (str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; return new $className(); } } diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index c94461856a..94d4457072 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -527,7 +527,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { $this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->mapProvider; } - require_once (str_replace('_', DIRECTORY_SEPARATOR, $this->userFrameworkClass) . '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $this->userFrameworkClass) . '.php'; $class = $this->userFrameworkClass; // redundant with _setUserFrameworkConfig $this->userSystem = new $class(); diff --git a/CRM/Core/Config/Defaults.php b/CRM/Core/Config/Defaults.php index f389622b75..666a9d7ad9 100644 --- a/CRM/Core/Config/Defaults.php +++ b/CRM/Core/Config/Defaults.php @@ -236,7 +236,6 @@ class CRM_Core_Config_Defaults { while running upgrade, to avoid any serious non-recoverable error which might hinder the upgrade process. */ - $args = array(); if (isset($_GET[$config->userFrameworkURLVar])) { $args = explode('/', $_GET[$config->userFrameworkURLVar]); diff --git a/CRM/Core/Controller.php b/CRM/Core/Controller.php index 48cda51967..0e4ff02611 100644 --- a/CRM/Core/Controller.php +++ b/CRM/Core/Controller.php @@ -170,7 +170,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * Name of session if we want unique scope, used only by Controller_Simple. * @param bool $addSequence * Should we add a unique sequence number to the end of the key. - * @param bool $ignoreKey + * @param bool $ignoreKey * Should we not set a qfKey for this controller (for standalone forms). * * @internal param bool $whether controller is modal @@ -252,7 +252,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { } } - // if the request has a reset value, initialize the controller session + // if the request has a reset value, initialize the controller session if (!empty($_GET['reset'])) { $this->reset(); @@ -267,7 +267,6 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { // and created the scope etc $this->set('qfKey', $this->_key); - // also retrieve and store destination in session $this->_destination = CRM_Utils_Request::retrieve( 'civicrmDestination', @@ -457,10 +456,10 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { $ext = CRM_Extension_System::singleton()->getMapper(); if ($ext->isExtensionClass($className)) { - require_once ($ext->classToPath($className)); + require_once $ext->classToPath($className); } else { - require_once (str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'); + require_once str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; } $$stateName = new $className($stateMachine->find($className), $action, 'post', $formName); if ($title) { @@ -514,7 +513,8 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * * @return void */ - public function process() {} + public function process() { + } /** * Store the variable with the value in the form scope @@ -637,7 +637,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * The value to append. * @param bool $merge */ - public function append($tpl_var, $value=NULL, $merge=FALSE) { + public function append($tpl_var, $value = NULL, $merge = FALSE) { self::$_template->append($tpl_var, $value, $merge); } @@ -648,7 +648,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * * @return array */ - public function get_template_vars($name=null) { + public function get_template_vars($name = NULL) { return self::$_template->get_template_vars($name); } diff --git a/CRM/Core/Controller/Simple.php b/CRM/Core/Controller/Simple.php index d27171db0a..0c7a4addfb 100644 --- a/CRM/Core/Controller/Simple.php +++ b/CRM/Core/Controller/Simple.php @@ -57,10 +57,10 @@ class CRM_Core_Controller_Simple extends CRM_Core_Controller { function __construct( $path, $title, - $mode = NULL, - $imageUpload = FALSE, - $addSequence = FALSE, - $ignoreKey = FALSE, + $mode = NULL, + $imageUpload = FALSE, + $addSequence = FALSE, + $ignoreKey = FALSE, $attachUpload = FALSE ) { // by definition a single page is modal :). We use the form name as the scope for this controller @@ -77,7 +77,6 @@ class CRM_Core_Controller_Simple extends CRM_Core_Controller { $mode = $savedAction; } - $this->_stateMachine->addSequentialPages($params, $mode); $this->addPages($this->_stateMachine, $mode); diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index 81c8f1e71c..abf22266ad 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -114,7 +114,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { * @return object * @static */ - public static function &singleton($package = NULL, $msgCallback = FALSE, $contextCallback = FALSE, $throwPEAR_Error = FALSE, $stackClass = 'PEAR_ErrorStack') { + public static function &singleton($package = NULL, $msgCallback = FALSE, $contextCallback = FALSE, $throwPEAR_Error = FALSE, $stackClass = 'PEAR_ErrorStack') { if (self::$_singleton === NULL) { self::$_singleton = new CRM_Core_Error('CiviCRM'); } @@ -325,7 +325,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { $details = 'A fatal error was triggered'; if ($message) { $details .= ': ' . $message; - } + } throw new Exception($details, $code); } @@ -536,8 +536,8 @@ class CRM_Core_Error extends PEAR_ErrorStack { static function debug_var($variable_name, $variable, $print = TRUE, - $log = TRUE, - $comp = '' + $log = TRUE, + $comp = '' ) { // check if variable is set if (!isset($variable)) { @@ -605,9 +605,9 @@ class CRM_Core_Error extends PEAR_ErrorStack { public static function debug_query($string) { if ( defined( 'CIVICRM_DEBUG_LOG_QUERY' ) ) { if ( CIVICRM_DEBUG_LOG_QUERY == 'backtrace' ) { - CRM_Core_Error::backtrace( $string, true ); + CRM_Core_Error::backtrace( $string, TRUE ); } else if ( CIVICRM_DEBUG_LOG_QUERY ) { - CRM_Core_Error::debug_var( 'Query', $string, false, true ); + CRM_Core_Error::debug_var( 'Query', $string, FALSE, TRUE ); } } } @@ -621,7 +621,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { $dao = CRM_Core_DAO::executeQuery($query); $results = array(); while ($dao->fetch()) { - $results[] = (array)$dao; + $results[] = (array) $dao; } CRM_Core_Error::debug_var('dao result', array('query' => $query, 'results' => $results)); } @@ -692,7 +692,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { foreach (self::parseBacktrace($backTrace, $showArgs, $maxArgLen) as $idx => $trace) { $message .= sprintf("#%s %s\n", $idx, $trace); } - $message .= sprintf("#%s {main}\n", 1+$idx); + $message .= sprintf("#%s {main}\n", 1 + $idx); return $message; } @@ -729,25 +729,32 @@ class CRM_Core_Error extends PEAR_ErrorStack { case 'boolean': $args[] = $arg ? 'TRUE' : 'FALSE'; break; + case 'integer': case 'double': $args[] = $arg; break; + case 'string': $args[] = '"' . CRM_Utils_String::ellipsify(addcslashes((string) $arg, "\r\n\t\""), $maxArgLen). '"'; break; + case 'array': $args[] = '(Array:'.count($arg).')'; break; + case 'object': $args[] = 'Object(' . get_class($arg) . ')'; break; + case 'resource': $args[] = 'Resource'; break; + case 'NULL': $args[] = 'NULL'; break; + default: $args[] = "($type)"; break; @@ -788,11 +795,11 @@ class CRM_Core_Error extends PEAR_ErrorStack { $msg .= ''; foreach (array('Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo') as $f) { $msg .= sprintf('%s%s', $f, call_user_func(array($ei->getCause(), "get$f"))); - } + } $msg .= ''; - } + } $ei = $ei->getCause(); - } + } $msg .= $e->toHtml(); } else { $msg .= '

' . get_class($e) . ': "' . htmlentities($e->getMessage()) . '"

'; diff --git a/CRM/Core/Exception.php b/CRM/Core/Exception.php index 855b947515..c66707f37a 100644 --- a/CRM/Core/Exception.php +++ b/CRM/Core/Exception.php @@ -48,7 +48,7 @@ class CRM_Core_Exception extends PEAR_Exception { * @param array $errorData * @param null $previous */ - public function __construct($message, $error_code = 0, $errorData = array(), $previous = null) { + public function __construct($message, $error_code = 0, $errorData = array(), $previous = NULL) { parent::__construct(ts($message)); $this->errorData = $errorData + array('error_code' => $error_code); } diff --git a/CRM/Core/Form/Date.php b/CRM/Core/Form/Date.php index f244db0d74..6c6614708f 100644 --- a/CRM/Core/Form/Date.php +++ b/CRM/Core/Form/Date.php @@ -32,7 +32,7 @@ * $Id$ * */ -Class CRM_Core_Form_Date { +class CRM_Core_Form_Date { /** * Various Date Formats @@ -253,7 +253,7 @@ Class CRM_Core_Form_Date { array('class' => 'crm-select2') ); - $form->addDateRange($fieldName, $from, $to, $fromLabel, $dateFormat, FALSE, $displayTime); + $form->addDateRange($fieldName, $from, $to, $fromLabel, $dateFormat, FALSE, $displayTime); } } diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index 7081143b0a..e9b481427e 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -1,487 +1,491 @@ -id; - } - } - if ($entityTable) { - CRM_Core_OptionValue::getValues(array('name' => $entityTable.'_repeat_exclude_dates_'.self::$_parentEntityId), $optionValue); - $excludeOptionValues = array(); - if (!empty($optionValue)) { - foreach($optionValue as $key => $val) { - $excludeOptionValues[$val['value']] = date('m/d/Y', strtotime($val['value'])); - } - self::$_excludeDateInfo = $excludeOptionValues; - } - } - } - - /** - * Set default values for the form. For edit/view mode - * the default values are retrieved from the database - * - * - * @return None - */ - public static function setDefaultValues() { - $defaults = array(); - if (self::$_scheduleReminderID) { - $defaults['repetition_frequency_unit'] = self::$_scheduleReminderDetails->repetition_frequency_unit; - $defaults['repetition_frequency_interval'] = self::$_scheduleReminderDetails->repetition_frequency_interval; - $defaults['start_action_condition'] = array_flip(explode(",",self::$_scheduleReminderDetails->start_action_condition)); - foreach($defaults['start_action_condition'] as $key => $val) { - $val = 1; - $defaults['start_action_condition'][$key] = $val; - } - $defaults['start_action_offset'] = self::$_scheduleReminderDetails->start_action_offset; - if (self::$_scheduleReminderDetails->start_action_offset) { - $defaults['ends'] = 1; - } - list($defaults['repeat_absolute_date']) = CRM_Utils_Date::setDateDefaults(self::$_scheduleReminderDetails->absolute_date); - if (self::$_scheduleReminderDetails->absolute_date) { - $defaults['ends'] = 2; - } - $defaults['limit_to'] = self::$_scheduleReminderDetails->limit_to; - if (self::$_scheduleReminderDetails->limit_to) { - $defaults['repeats_by'] = 1; - } - $explodeStartActionCondition = array(); - if (self::$_scheduleReminderDetails->entity_status) { - $explodeStartActionCondition = explode(" ", self::$_scheduleReminderDetails->entity_status); - $defaults['entity_status_1'] = $explodeStartActionCondition[0]; - $defaults['entity_status_2'] = $explodeStartActionCondition[1]; - } - if (self::$_scheduleReminderDetails->entity_status) { - $defaults['repeats_by'] = 2; - } - } - return $defaults; - } - - public static function buildQuickForm(&$form) { - if (self::$_entityTable) { - $entityType = explode("_", self::$_entityTable); - if ($entityType[1]) { - $form->assign('entityType', ucwords($entityType[1])); - } - } - $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") { - $label = "dai"; - } - $freqUnitsDisplay[$val] = ts('%1ly', array(1 => $label)); - } - // echo "
";print_r($freqUnitsDisplay);
-    $dayOfTheWeek = array('monday'   => 'Monday',
-                          'tuesday'   => 'Tuesday',
-                          'wednesday' => 'Wednesday',
-                          'thursday'  => 'Thursday',
-                          'friday'    => 'Friday',
-                          'saturday'  => 'Saturday',
-                          'sunday'    => 'Sunday'
-                         );
-    $form->add('select', 'repetition_frequency_unit', ts('Repeats:'), $freqUnitsDisplay);
-    $numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30);
-    $form->add('select', 'repetition_frequency_interval', ts('Repeats every:'), $numericOptions, '', array('style' => 'width:55px;'));
-    $form->addDateTime('repetition_start_date', ts('Repetition Start Date'), FALSE, array('formatType' => 'activityDateTime'));
-    foreach($dayOfTheWeek as $key => $val) {
-        $startActionCondition[] = $form->createElement('checkbox', $key, NULL, substr($val." ", 0, 3));
-    }
-    $form->addGroup($startActionCondition, 'start_action_condition', ts('Repeats on'));
-    $roptionTypes = array('1' => ts('day of the month'),
-        '2' => ts('day of the week'),
-      );
-    $form->addRadio('repeats_by', ts("Repeats By:"), $roptionTypes, array(), NULL);
-    $getMonths = CRM_Core_SelectValues::getNumericOptions(1, 31);
-    $form->add('select', 'limit_to', '', $getMonths, FALSE, array('style' => 'width:55px;'));
-    $dayOfTheWeekNo = array('first'  => 'First',
-                            'second'=> 'Second',
-                            'third' => 'Third',
-                            'fourth'=> 'Fourth',
-                            'last'  => 'Last'
-                         );
-    $form->add('select', 'entity_status_1', ts(''), $dayOfTheWeekNo);
-    $form->add('select', 'entity_status_2', ts(''), $dayOfTheWeek);
-    $eoptionTypes = array('1' => ts('After'),
-        '2' => ts('On'),
-      );
-    $form->addRadio('ends', ts("Ends:"), $eoptionTypes, array(), NULL);
-    $form->add('text', 'start_action_offset', ts(''), array('size' => 3, 'maxlength' => 2));
-    $form->addFormRule(array('CRM_Core_Form_RecurringEntity', 'formRule'));
-    $form->addDate('repeat_absolute_date', ts('On'), FALSE, array('formatType' => 'mailing'));
-    $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('hidden', 'copyExcludeDates', '', array('id' => 'copyExcludeDates'));
-    $form->addElement('hidden', 'allowRepeatConfigToSubmit', '', array('id' => 'allowRepeatConfigToSubmit'));
-    $form->addButtons(array(
-        array(
-          'type' => 'submit',
-          'name' => ts('Save'),
-          'isDefault' => TRUE,
-        ),
-        array(
-          'type' => 'cancel',
-          'name' => ts('Cancel')
-        ),
-      )
-    );
-  }
-
-  /**
-   * Global validation rules for the form
-   *
+id;
+      }
+    }
+    if ($entityTable) {
+      CRM_Core_OptionValue::getValues(array('name' => $entityTable.'_repeat_exclude_dates_'.self::$_parentEntityId), $optionValue);
+      $excludeOptionValues = array();
+      if (!empty($optionValue)) {
+        foreach($optionValue as $key => $val) {
+          $excludeOptionValues[$val['value']] = date('m/d/Y', strtotime($val['value']));
+        }
+        self::$_excludeDateInfo = $excludeOptionValues;
+      }
+    }
+  }
+
+  /**
+   * Set default values for the form. For edit/view mode
+   * the default values are retrieved from the database
+   *
+   *
+   * @return None
+   */
+  public static function setDefaultValues() {
+    $defaults = array();
+    if (self::$_scheduleReminderID) {
+      $defaults['repetition_frequency_unit'] = self::$_scheduleReminderDetails->repetition_frequency_unit;
+      $defaults['repetition_frequency_interval'] = self::$_scheduleReminderDetails->repetition_frequency_interval;
+      $defaults['start_action_condition'] = array_flip(explode(",", self::$_scheduleReminderDetails->start_action_condition));
+      foreach($defaults['start_action_condition'] as $key => $val) {
+        $val = 1;
+        $defaults['start_action_condition'][$key] = $val;
+      }
+      $defaults['start_action_offset'] = self::$_scheduleReminderDetails->start_action_offset;
+      if (self::$_scheduleReminderDetails->start_action_offset) {
+        $defaults['ends'] = 1;
+      }
+      list($defaults['repeat_absolute_date']) = CRM_Utils_Date::setDateDefaults(self::$_scheduleReminderDetails->absolute_date);
+      if (self::$_scheduleReminderDetails->absolute_date) {
+        $defaults['ends'] = 2;
+      }
+      $defaults['limit_to'] = self::$_scheduleReminderDetails->limit_to;
+      if (self::$_scheduleReminderDetails->limit_to) {
+        $defaults['repeats_by'] = 1;
+      }
+      $explodeStartActionCondition = array();
+      if (self::$_scheduleReminderDetails->entity_status) {
+        $explodeStartActionCondition = explode(" ", self::$_scheduleReminderDetails->entity_status);
+        $defaults['entity_status_1'] = $explodeStartActionCondition[0];
+        $defaults['entity_status_2'] = $explodeStartActionCondition[1];
+      }
+      if (self::$_scheduleReminderDetails->entity_status) {
+        $defaults['repeats_by'] = 2;
+      }
+    }
+    return $defaults;
+  }
+
+  public static function buildQuickForm(&$form) {
+    if (self::$_entityTable) {
+      $entityType = explode("_", self::$_entityTable);
+      if ($entityType[1]) {
+        $form->assign('entityType', ucwords($entityType[1]));
+      }
+    }
+    $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") {
+        $label = "dai";
+      }
+      $freqUnitsDisplay[$val] = ts('%1ly', array(1 => $label));
+    }
+    // echo "
";print_r($freqUnitsDisplay);
+    $dayOfTheWeek = array(
+    'monday'   => 'Monday',
+                          'tuesday'   => 'Tuesday',
+                          'wednesday' => 'Wednesday',
+                          'thursday'  => 'Thursday',
+                          'friday'    => 'Friday',
+                          'saturday'  => 'Saturday',
+                          'sunday'    => 'Sunday'
+                         );
+    $form->add('select', 'repetition_frequency_unit', ts('Repeats:'), $freqUnitsDisplay);
+    $numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30);
+    $form->add('select', 'repetition_frequency_interval', ts('Repeats every:'), $numericOptions, '', array('style' => 'width:55px;'));
+    $form->addDateTime('repetition_start_date', ts('Repetition Start Date'), FALSE, array('formatType' => 'activityDateTime'));
+    foreach($dayOfTheWeek as $key => $val) {
+      $startActionCondition[] = $form->createElement('checkbox', $key, NULL, substr($val." ", 0, 3));
+    }
+    $form->addGroup($startActionCondition, 'start_action_condition', ts('Repeats on'));
+    $roptionTypes = array(
+    '1' => ts('day of the month'),
+        '2' => ts('day of the week'),
+      );
+    $form->addRadio('repeats_by', ts("Repeats By:"), $roptionTypes, array(), NULL);
+    $getMonths = CRM_Core_SelectValues::getNumericOptions(1, 31);
+    $form->add('select', 'limit_to', '', $getMonths, FALSE, array('style' => 'width:55px;'));
+    $dayOfTheWeekNo = array(
+    'first'  => 'First',
+                            'second' => 'Second',
+                            'third' => 'Third',
+                            'fourth' => 'Fourth',
+                            'last'  => 'Last'
+                         );
+    $form->add('select', 'entity_status_1', ts(''), $dayOfTheWeekNo);
+    $form->add('select', 'entity_status_2', ts(''), $dayOfTheWeek);
+    $eoptionTypes = array(
+    '1' => ts('After'),
+        '2' => ts('On'),
+      );
+    $form->addRadio('ends', ts("Ends:"), $eoptionTypes, array(), NULL);
+    $form->add('text', 'start_action_offset', ts(''), array('size' => 3, 'maxlength' => 2));
+    $form->addFormRule(array('CRM_Core_Form_RecurringEntity', 'formRule'));
+    $form->addDate('repeat_absolute_date', ts('On'), FALSE, array('formatType' => 'mailing'));
+    $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('hidden', 'copyExcludeDates', '', array('id' => 'copyExcludeDates'));
+    $form->addElement('hidden', 'allowRepeatConfigToSubmit', '', array('id' => 'allowRepeatConfigToSubmit'));
+    $form->addButtons(array(
+        array(
+          'type' => 'submit',
+          'name' => ts('Save'),
+          'isDefault' => TRUE,
+        ),
+        array(
+          'type' => 'cancel',
+          'name' => ts('Cancel')
+        ),
+      )
+    );
+  }
+
+  /**
+   * Global validation rules for the form
+   *
    * @param array $fields
    *   Posted values of the form .
-   *
-   * @return array list of errors to be posted back to the form
-   * @static
-   */
-  public static function formRule($values) {
-    $errors = array();
-    //Process this function only when you get this variable
-    if ($values['allowRepeatConfigToSubmit'] == 1) {
-      $dayOfTheWeek = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
-      //Repeats
-      if (!CRM_Utils_Array::value('repetition_frequency_unit', $values)) {
-        $errors['repetition_frequency_unit'] = ts('This is a required field');
-      }
-      //Repeats every
-      if (!CRM_Utils_Array::value('repetition_frequency_interval', $values)) {
-        $errors['repetition_frequency_interval'] = ts('This is a required field');
-      }
-      //Ends
-      if (CRM_Utils_Array::value('ends', $values)) {
-        if ($values['ends'] == 1) {
-          if (empty($values['start_action_offset'])) {
-            $errors['start_action_offset'] = ts('This is a required field');
-          }
-          else if ($values['start_action_offset'] > 30) {
-            $errors['start_action_offset'] = ts('Occurrences should be less than or equal to 30');
-          }
-        }
-        if ($values['ends'] == 2) {
-          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)) {
-              $errors['repeat_absolute_date'] = ts('End date should be after current entity\'s start date');
-            }
-          }
-          else {
-            $errors['repeat_absolute_date'] = ts('This is a required field');
-          }
-        }
-      }
-      else {
-        $errors['ends'] = ts('This is a required field');
-      }
-
-      //Repeats BY
-      if (CRM_Utils_Array::value('repeats_by', $values)) {
-        if ($values['repeats_by'] == 1) {
-          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');
-            }
-          }
-          else {
-            $errors['limit_to'] = ts('Invalid day of the month');
-          }
-        }
-        if ($values['repeats_by'] == 2) {
-          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');
-            }
-          }
-          else {
-            $errors['entity_status_1'] = ts('Invalid option');
-          }
-          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');
-            }
-          }
-          else {
-            $errors['entity_status_2'] = ts('Invalid day name');
-          }
-        }
-      }
-    }
-    return $errors;
-  }
-
-  /**
-   * Process the form submission
-   *
-   *
-   * @return None
-   */
-  public static function postProcess($params = array(), $type, $linkedEntities = array()) {
-    //Check entity_id not present in params take it from class variable
-    if (!CRM_Utils_Array::value('entity_id', $params)) {
-      $params['entity_id'] = self::$_entityId;
-    }
-    //Process this function only when you get this variable
-    if ($params['allowRepeatConfigToSubmit'] == 1) {
-      if (CRM_Utils_Array::value('entity_table', $params) && CRM_Utils_Array::value('entity_id', $params) && $type) {
-        $params['used_for'] = $type;
-        if (!CRM_Utils_Array::value('parent_entity_id', $params)) {
-          $params['parent_entity_id'] = self::$_parentEntityId;
-        }
-        if (CRM_Utils_Array::value('schedule_reminder_id', $params)) {
-          $params['id'] = $params['schedule_reminder_id'];
-        }
-        else {
-          $params['id'] = self::$_scheduleReminderID;
-        }
-
-        //Save post params to the schedule reminder table
-        $recurobj = new CRM_Core_BAO_RecurringEntity();
-        $dbParams = $recurobj->mapFormValuesToDB($params);
-
-        //Delete repeat configuration and rebuild
-        if (CRM_Utils_Array::value('id', $params)) {
-          CRM_Core_BAO_ActionSchedule::del($params['id']);
-          unset($params['id']);
-        }
-        $actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams);
-
-        //exclude dates
-        $excludeDateList = array();
-        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']);
-
-          //Check if there exists any values for this option group
-          $optionGroupIdExists = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
-              $type.'_repeat_exclude_dates_'.$params['parent_entity_id'],
-              'id',
-              'name'
-            );
-          if ($optionGroupIdExists) {
-            CRM_Core_BAO_OptionGroup::del($optionGroupIdExists);
-          }
-          $optionGroupParams =
-              array(
-                'name'        => $type.'_repeat_exclude_dates_'.$actionScheduleObj->entity_value,
-                'title'       => $type.' recursion',
-                'is_reserved' => 0,
-                'is_active'   => 1
-              );
-          $opGroup = CRM_Core_BAO_OptionGroup::add($optionGroupParams);
-          if ($opGroup->id) {
-            $oldWeight= 0;
-            $fieldValues = array('option_group_id' => $opGroup->id);
-            foreach($excludeDates as $val) {
-              $optionGroupValue =
-                  array(
-                    'option_group_id' =>  $opGroup->id,
-                    'label'           =>  CRM_Utils_Date::processDate($val),
-                    'value'           =>  CRM_Utils_Date::processDate($val),
-                    'name'            =>  $opGroup->name,
-                    'description'     =>  'Used for recurring '.$type,
-                    'weight'          =>  CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues),
-                    'is_active'       =>  1
-                  );
-              $excludeDateList[] = $optionGroupValue['value'];
-              CRM_Core_BAO_OptionValue::add($optionGroupValue);
-            }
-          }
-        }
-
-        //Set type for API
-        $apiEntityType = array();
-        $apiEntityType = explode("_", $type);
-        if (!empty($apiEntityType[1])) {
-          $apiType = $apiEntityType[1];
-        }
-        //Delete relations if any from recurring entity tables before inserting new relations for this entity id
-        if ($params['entity_id']) {
-          //If entity has any pre delete function, consider that first
-          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'],
-                call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], array($params['entity_id'])))
-              );
-          }
-          //Ready to execute delete on entities if it has delete function set
-          if (CRM_Utils_Array::value('delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) &&
-            CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']])) {
-            //Check if pre delete function has some ids to be deleted
-            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'],
-                  array(
-                    'sequential' => 1,
-                    'id' => $eid,
-                  )
-                );
-                if ($result['error']) {
-                  CRM_Core_Error::statusBounce('Error creating recurring list');
-                }
-              }
-            }
-            else {
-              $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'],
-                  array(
-                    'sequential' => 1,
-                    'id' => $value['id'],
-                  )
-                );
-                if ($result['error']) {
-                  CRM_Core_Error::statusBounce('Error creating recurring list');
-                }
-              }
-            }
-          }
-
-          // find all entities from the recurring set. At this point we 'll get entities which were not deleted 
-          // for e.g due to participants being present. We need to delete them from recurring tables anyway.
-          $pRepeatingEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table']);
-          foreach($pRepeatingEntities as $val) {
-            CRM_Core_BAO_RecurringEntity::delEntity($val['id'], $val['table'], TRUE);
-          }
-        }
-
-        $recursion = new CRM_Core_BAO_RecurringEntity();
-        $recursion->dateColumns  = $params['dateColumns'];
-        $recursion->scheduleId   = $actionScheduleObj->id;
-
-        if (!empty($excludeDateList)) {
-          $recursion->excludeDates = $excludeDateList;
-          $recursion->excludeDateRangeColumns = $params['excludeDateRangeColumns'];
-        }
-        if (CRM_Utils_Array::value('intervalDateColumns', $params)) {
-          $recursion->intervalDateColumns = $params['intervalDateColumns'];
-        }
-        $recursion->entity_id = $params['entity_id'];
-        $recursion->entity_table = $params['entity_table'];
-        if (!empty($linkedEntities)) {
-          $recursion->linkedEntities = $linkedEntities;
-        }
-
-        $recurResult = $recursion->generate();
-
-        $status = ts('Repeat Configuration has been saved');
-        CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
-      }
-    }
-  }
-
-  /**
-   * Return a descriptive name for the page, used in wizard header
-   *
-   * @return string
-   */
-  public function getTitle() {
-    return ts('Repeat Entity');
-  }
-
-}
+   *
+   * @return array list of errors to be posted back to the form
+   * @static
+   */
+  public static function formRule($values) {
+    $errors = array();
+    //Process this function only when you get this variable
+    if ($values['allowRepeatConfigToSubmit'] == 1) {
+      $dayOfTheWeek = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
+      //Repeats
+      if (!CRM_Utils_Array::value('repetition_frequency_unit', $values)) {
+        $errors['repetition_frequency_unit'] = ts('This is a required field');
+      }
+      //Repeats every
+      if (!CRM_Utils_Array::value('repetition_frequency_interval', $values)) {
+        $errors['repetition_frequency_interval'] = ts('This is a required field');
+      }
+      //Ends
+      if (CRM_Utils_Array::value('ends', $values)) {
+        if ($values['ends'] == 1) {
+          if (empty($values['start_action_offset'])) {
+            $errors['start_action_offset'] = ts('This is a required field');
+          }
+          else if ($values['start_action_offset'] > 30) {
+            $errors['start_action_offset'] = ts('Occurrences should be less than or equal to 30');
+          }
+        }
+        if ($values['ends'] == 2) {
+          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)) {
+              $errors['repeat_absolute_date'] = ts('End date should be after current entity\'s start date');
+            }
+          }
+          else {
+            $errors['repeat_absolute_date'] = ts('This is a required field');
+          }
+        }
+      }
+      else {
+        $errors['ends'] = ts('This is a required field');
+      }
+
+      //Repeats BY
+      if (CRM_Utils_Array::value('repeats_by', $values)) {
+        if ($values['repeats_by'] == 1) {
+          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');
+            }
+          }
+          else {
+            $errors['limit_to'] = ts('Invalid day of the month');
+          }
+        }
+        if ($values['repeats_by'] == 2) {
+          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');
+            }
+          }
+          else {
+            $errors['entity_status_1'] = ts('Invalid option');
+          }
+          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');
+            }
+          }
+          else {
+            $errors['entity_status_2'] = ts('Invalid day name');
+          }
+        }
+      }
+    }
+    return $errors;
+  }
+
+  /**
+   * Process the form submission
+   *
+   *
+   * @return None
+   */
+  public static function postProcess($params = array(), $type, $linkedEntities = array()) {
+    //Check entity_id not present in params take it from class variable
+    if (!CRM_Utils_Array::value('entity_id', $params)) {
+      $params['entity_id'] = self::$_entityId;
+    }
+    //Process this function only when you get this variable
+    if ($params['allowRepeatConfigToSubmit'] == 1) {
+      if (CRM_Utils_Array::value('entity_table', $params) && CRM_Utils_Array::value('entity_id', $params) && $type) {
+        $params['used_for'] = $type;
+        if (!CRM_Utils_Array::value('parent_entity_id', $params)) {
+          $params['parent_entity_id'] = self::$_parentEntityId;
+        }
+        if (CRM_Utils_Array::value('schedule_reminder_id', $params)) {
+          $params['id'] = $params['schedule_reminder_id'];
+        }
+        else {
+          $params['id'] = self::$_scheduleReminderID;
+        }
+
+        //Save post params to the schedule reminder table
+        $recurobj = new CRM_Core_BAO_RecurringEntity();
+        $dbParams = $recurobj->mapFormValuesToDB($params);
+
+        //Delete repeat configuration and rebuild
+        if (CRM_Utils_Array::value('id', $params)) {
+          CRM_Core_BAO_ActionSchedule::del($params['id']);
+          unset($params['id']);
+        }
+        $actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams);
+
+        //exclude dates
+        $excludeDateList = array();
+        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']);
+
+          //Check if there exists any values for this option group
+          $optionGroupIdExists = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
+              $type.'_repeat_exclude_dates_'.$params['parent_entity_id'],
+              'id',
+              'name'
+            );
+          if ($optionGroupIdExists) {
+            CRM_Core_BAO_OptionGroup::del($optionGroupIdExists);
+          }
+          $optionGroupParams =
+              array(
+                'name'        => $type.'_repeat_exclude_dates_'.$actionScheduleObj->entity_value,
+                'title'       => $type.' recursion',
+                'is_reserved' => 0,
+                'is_active'   => 1
+              );
+          $opGroup = CRM_Core_BAO_OptionGroup::add($optionGroupParams);
+          if ($opGroup->id) {
+            $oldWeight = 0;
+            $fieldValues = array('option_group_id' => $opGroup->id);
+            foreach($excludeDates as $val) {
+              $optionGroupValue =
+                  array(
+                    'option_group_id' => $opGroup->id,
+                    'label'           => CRM_Utils_Date::processDate($val),
+                    'value'           => CRM_Utils_Date::processDate($val),
+                    'name'            => $opGroup->name,
+                    'description'     => 'Used for recurring '.$type,
+                    'weight'          => CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues),
+                    'is_active'       => 1
+                  );
+              $excludeDateList[] = $optionGroupValue['value'];
+              CRM_Core_BAO_OptionValue::add($optionGroupValue);
+            }
+          }
+        }
+
+        //Set type for API
+        $apiEntityType = array();
+        $apiEntityType = explode("_", $type);
+        if (!empty($apiEntityType[1])) {
+          $apiType = $apiEntityType[1];
+        }
+        //Delete relations if any from recurring entity tables before inserting new relations for this entity id
+        if ($params['entity_id']) {
+          //If entity has any pre delete function, consider that first
+          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'],
+                call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], array($params['entity_id'])))
+              );
+          }
+          //Ready to execute delete on entities if it has delete function set
+          if (CRM_Utils_Array::value('delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) &&
+            CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']])) {
+            //Check if pre delete function has some ids to be deleted
+            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'],
+                  array(
+                    'sequential' => 1,
+                    'id' => $eid,
+                  )
+                );
+                if ($result['error']) {
+                  CRM_Core_Error::statusBounce('Error creating recurring list');
+                }
+              }
+            }
+            else {
+              $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'],
+                  array(
+                    'sequential' => 1,
+                    'id' => $value['id'],
+                  )
+                );
+                if ($result['error']) {
+                  CRM_Core_Error::statusBounce('Error creating recurring list');
+                }
+              }
+            }
+          }
+
+          // find all entities from the recurring set. At this point we 'll get entities which were not deleted
+          // for e.g due to participants being present. We need to delete them from recurring tables anyway.
+          $pRepeatingEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table']);
+          foreach($pRepeatingEntities as $val) {
+            CRM_Core_BAO_RecurringEntity::delEntity($val['id'], $val['table'], TRUE);
+          }
+        }
+
+        $recursion = new CRM_Core_BAO_RecurringEntity();
+        $recursion->dateColumns  = $params['dateColumns'];
+        $recursion->scheduleId   = $actionScheduleObj->id;
+
+        if (!empty($excludeDateList)) {
+          $recursion->excludeDates = $excludeDateList;
+          $recursion->excludeDateRangeColumns = $params['excludeDateRangeColumns'];
+        }
+        if (CRM_Utils_Array::value('intervalDateColumns', $params)) {
+          $recursion->intervalDateColumns = $params['intervalDateColumns'];
+        }
+        $recursion->entity_id = $params['entity_id'];
+        $recursion->entity_table = $params['entity_table'];
+        if (!empty($linkedEntities)) {
+          $recursion->linkedEntities = $linkedEntities;
+        }
+
+        $recurResult = $recursion->generate();
+
+        $status = ts('Repeat Configuration has been saved');
+        CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
+      }
+    }
+  }
+
+  /**
+   * Return a descriptive name for the page, used in wizard header
+   *
+   * @return string
+   */
+  public function getTitle() {
+    return ts('Repeat Entity');
+  }
+
+}
diff --git a/CRM/Core/Menu.php b/CRM/Core/Menu.php
index 0698cea81a..d1a4895492 100644
--- a/CRM/Core/Menu.php
+++ b/CRM/Core/Menu.php
@@ -275,7 +275,6 @@ class CRM_Core_Menu {
 
     self::build($menuArray);
 
-
     $config = CRM_Core_Config::singleton();
 
     foreach ($menuArray as $path => $item) {
@@ -319,8 +318,11 @@ class CRM_Core_Menu {
         'title' => $item['title'],
         'desc' => CRM_Utils_Array::value('desc', $item),
         'id' => strtr($item['title'], array(
-          '(' => '_', ')' => '', ' ' => '',
-            ',' => '_', '/' => '_',
+          '(' => '_',
+      ')' => '',
+      ' ' => '',
+            ',' => '_',
+      '/' => '_',
           )
         ),
         'url' => CRM_Utils_System::url($path, $query,
@@ -422,7 +424,6 @@ class CRM_Core_Menu {
       }
     }
 
-
     if (!$all) {
       // remove all collapsed menu items from the array
       foreach ($values as $weight => $v) {
@@ -701,7 +702,7 @@ UNION (
     // Once we have another example of a 'cleanup' we should generalize the clause below so it grabs string
     // which follows upgrade/ and checks for existence of a function in Cleanup class.
     if ($path == 'civicrm/upgrade/cleanup425') {
-      $menuPath['page_callback'] = array('CRM_Upgrade_Page_Cleanup','cleanup425');
+      $menuPath['page_callback'] = array('CRM_Upgrade_Page_Cleanup', 'cleanup425');
       $menuPath['access_arguments'][0][] = 'administer CiviCRM';
       $menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu');
     }
diff --git a/CRM/Core/OptionGroup.php b/CRM/Core/OptionGroup.php
index 6102935c09..38b026b375 100644
--- a/CRM/Core/OptionGroup.php
+++ b/CRM/Core/OptionGroup.php
@@ -271,10 +271,10 @@ WHERE  v.option_group_id = g.id
    *   Reference array of fieldnames we want transformed.
    *                           Array key = 'postName' (field name submitted by form in $params).
    *                           Array value = array(
-     'newName' => $newName, 'groupName' => $groupName).
+  'newName' => $newName, 'groupName' => $groupName).
    *
    *
-   * @param boolean $flip
+   * @param bool $flip
    *
    * @return void
    *
@@ -358,7 +358,8 @@ WHERE  v.option_group_id = g.id
     if ($onlyActiveValue) {
       $query .= " AND  v.is_active = 1 ";
     }
-    $p = array(1 => array($groupName, 'String'),
+    $p = array(
+    1 => array($groupName, 'String'),
       2 => array($value, 'Integer'),
     );
     $dao = CRM_Core_DAO::executeQuery($query, $p);
@@ -380,7 +381,7 @@ WHERE  v.option_group_id = g.id
   static function getValue($groupName,
     $label,
     $labelField = 'label',
-    $labelType  = 'String',
+    $labelType = 'String',
     $valueField = 'value'
   ) {
     if (empty($label)) {
@@ -398,7 +399,8 @@ WHERE  v.option_group_id = g.id
   AND  v.$labelField     = %2
 ";
 
-    $p = array(1 => array($groupName, 'String'),
+    $p = array(
+    1 => array($groupName, 'String'),
       2 => array($label, $labelType),
     );
     $dao = CRM_Core_DAO::executeQuery($query, $p);
@@ -579,7 +581,8 @@ SELECT v.label
  WHERE g.id = v.option_group_id
    AND g.name  = %1
    AND v.value = %2";
-    $params = array(1 => array($groupName, 'String'),
+    $params = array(
+    1 => array($groupName, 'String'),
       2 => array($value, 'String'),
     );
     return CRM_Core_DAO::singleValueQuery($query, $params);
@@ -611,7 +614,8 @@ WHERE  v.option_group_id = g.id
       $query .= " AND  v.is_active = 1";
     }
 
-    $p = array(1 => array($groupName, 'String'),
+    $p = array(
+    1 => array($groupName, 'String'),
       2 => array($fieldValue, $fieldType),
     );
     $dao = CRM_Core_DAO::executeQuery($query, $p);
diff --git a/CRM/Core/OptionValue.php b/CRM/Core/OptionValue.php
index 3f94ed40a1..c0b899f302 100644
--- a/CRM/Core/OptionValue.php
+++ b/CRM/Core/OptionValue.php
@@ -179,7 +179,7 @@ class CRM_Core_OptionValue {
    * @param array $groupParams
    *   Array containing group fields whose option-values is to retrieved/saved.
    * @param $action
-   * @param integer $optionValueID
+   * @param int $optionValueIDHas the id of the optionValue being edited, disabled ..etc.
    *   Has the id of the optionValue being edited, disabled ..etc.
    *
    * @return CRM_Core_DAO_OptionValue
@@ -381,7 +381,7 @@ class CRM_Core_OptionValue {
    * @param string $orderBy
    *   For orderBy clause.
    *
-   * @param boolean $isActive
+   * @param bool $isActiveDo you want only active option values?.
    *   Do you want only active option values?.
    *
    * @return array of option-values
diff --git a/CRM/Core/Page.php b/CRM/Core/Page.php
index ffc980765e..561cb3dac2 100644
--- a/CRM/Core/Page.php
+++ b/CRM/Core/Page.php
@@ -305,7 +305,7 @@ class CRM_Core_Page {
    *   The value to append.
    * @param bool $merge
    */
-  public function append($tpl_var, $value=NULL, $merge=FALSE) {
+  public function append($tpl_var, $value = NULL, $merge = FALSE) {
     self::$_template->append($tpl_var, $value, $merge);
   }
 
@@ -316,7 +316,7 @@ class CRM_Core_Page {
    *
    * @return array
    */
-  public function get_template_vars($name=null) {
+  public function get_template_vars($name = NULL) {
     return self::$_template->get_template_vars($name);
   }
 
diff --git a/CRM/Core/Page/AJAX.php b/CRM/Core/Page/AJAX.php
index aeb5f95963..cec7e7dd8a 100644
--- a/CRM/Core/Page/AJAX.php
+++ b/CRM/Core/Page/AJAX.php
@@ -82,6 +82,7 @@ class CRM_Core_Page_AJAX {
           $wrapper->run($className);
         }
         break;
+
       default:
         CRM_Core_Error::debug_log_message('Unsupported inline request type: ' . var_export($type, TRUE));
     }
@@ -105,7 +106,7 @@ class CRM_Core_Page_AJAX {
     // return false if $id is null and
     // $context is not civicrm_event or civicrm_contribution_page
     if (!$id || !in_array($context, array('civicrm_event', 'civicrm_contribution_page'))) {
-      return false;
+      return FALSE;
     }
     $priceSetId = CRM_Price_BAO_PriceSet::getFor($context, $id, NULL);
     if ($priceSetId) {
@@ -122,7 +123,7 @@ class CRM_Core_Page_AJAX {
       }
     }
     if (!$result) {
-      $priceSetId = null;
+      $priceSetId = NULL;
     }
     CRM_Utils_JSON::output($priceSetId);
   }
@@ -139,7 +140,7 @@ class CRM_Core_Page_AJAX {
    *
    * @return bool
    */
-  public static function checkAuthz($type, $className, $fnName = null) {
+  public static function checkAuthz($type, $className, $fnName = NULL) {
     switch ($type) {
       case 'method':
         if (!preg_match('/^CRM_[a-zA-Z0-9]+_Page_AJAX$/', $className)) {
@@ -159,6 +160,7 @@ class CRM_Core_Page_AJAX {
           return FALSE;
         }
         return class_exists($className);
+
       default:
         return FALSE;
     }
@@ -203,7 +205,7 @@ class CRM_Core_Page_AJAX {
    */
   public static function setJsHeaders() {
     // Encourage browsers to cache for a long time - 1 year
-    $year = 60*60*24*364;
+    $year = 60 * 60 * 24 * 364;
     header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + $year));
     header('Content-Type:	application/javascript');
     header("Cache-Control: max-age=$year, public");
@@ -219,7 +221,7 @@ class CRM_Core_Page_AJAX {
    *   Array key to use as the key.
    * @deprecated
    */
-  public static function autocompleteResults($results, $val='label', $key='id') {
+  public static function autocompleteResults($results, $val = 'label', $key = 'id') {
     $output = array();
     if (is_array($results)) {
       foreach ($results as $k => $v) {
diff --git a/CRM/Core/Page/AJAX/Location.php b/CRM/Core/Page/AJAX/Location.php
index 3ca27474d1..2bd4241b9a 100644
--- a/CRM/Core/Page/AJAX/Location.php
+++ b/CRM/Core/Page/AJAX/Location.php
@@ -69,62 +69,61 @@ class CRM_Core_Page_AJAX_Location {
     $config = CRM_Core_Config::singleton();
     $addressSequence = array_flip($config->addressSequence());
 
-
-      $profileFields = CRM_Core_BAO_UFGroup::getFields($ufId, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE,
+    $profileFields = CRM_Core_BAO_UFGroup::getFields($ufId, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE,
         NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL
       );
-      $website = CRM_Core_BAO_Website::getValues($entityBlock, $values);
+    $website = CRM_Core_BAO_Website::getValues($entityBlock, $values);
 
-      foreach ($location as $fld => $values) {
-        if (is_array($values) && !empty($values)) {
-          $locType = $values[1]['location_type_id'];
-          if ($fld == 'email') {
-            $elements["onbehalf_{$fld}-{$locType}"] = array(
+    foreach ($location as $fld => $values) {
+      if (is_array($values) && !empty($values)) {
+        $locType = $values[1]['location_type_id'];
+        if ($fld == 'email') {
+          $elements["onbehalf_{$fld}-{$locType}"] = array(
               'type' => 'Text',
               'value' => $location[$fld][1][$fld],
             );
-            unset($profileFields["{$fld}-{$locType}"]);
-          }
-          elseif ($fld == 'phone') {
-            $phoneTypeId = $values[1]['phone_type_id'];
-            $elements["onbehalf_{$fld}-{$locType}-{$phoneTypeId}"] = array(
+          unset($profileFields["{$fld}-{$locType}"]);
+        }
+        elseif ($fld == 'phone') {
+          $phoneTypeId = $values[1]['phone_type_id'];
+          $elements["onbehalf_{$fld}-{$locType}-{$phoneTypeId}"] = array(
               'type' => 'Text',
               'value' => $location[$fld][1][$fld],
             );
-            unset($profileFields["{$fld}-{$locType}-{$phoneTypeId}"]);
-          }
-          elseif ($fld == 'im') {
-            $providerId = $values[1]['provider_id'];
-            $elements["onbehalf_{$fld}-{$locType}"] = array(
+          unset($profileFields["{$fld}-{$locType}-{$phoneTypeId}"]);
+        }
+        elseif ($fld == 'im') {
+          $providerId = $values[1]['provider_id'];
+          $elements["onbehalf_{$fld}-{$locType}"] = array(
               'type' => 'Text',
               'value' => $location[$fld][1][$fld],
             );
-            $elements["onbehalf_{$fld}-{$locType}provider_id"] = array(
+          $elements["onbehalf_{$fld}-{$locType}provider_id"] = array(
               'type' => 'Select',
               'value' => $location[$fld][1]['provider_id'],
             );
-            unset($profileFields["{$fld}-{$locType}-{$providerId}"]);
-          }
+          unset($profileFields["{$fld}-{$locType}-{$providerId}"]);
         }
       }
+    }
 
-      if (!empty($website)) {
-        foreach ($website as $key => $val) {
-          $websiteTypeId = $values[1]['website_type_id'];
-          $elements["onbehalf_url-1"] = array(
+    if (!empty($website)) {
+      foreach ($website as $key => $val) {
+        $websiteTypeId = $values[1]['website_type_id'];
+        $elements["onbehalf_url-1"] = array(
             'type' => 'Text',
             'value' => $website[1]['url'],
           );
-          $elements["onbehalf_url-1-website_type_id"] = array(
+        $elements["onbehalf_url-1-website_type_id"] = array(
             'type' => 'Select',
             'value' => $website[1]['website_type_id'],
           );
-          unset($profileFields["url-1"]);
-        }
+        unset($profileFields["url-1"]);
       }
+    }
 
-      $locTypeId = isset($location['address'][1]) ? $location['address'][1]['location_type_id'] : NULL;
-      $addressFields = array(
+    $locTypeId = isset($location['address'][1]) ? $location['address'][1]['location_type_id'] : NULL;
+    $addressFields = array(
         'street_address',
         'supplemental_address_1',
         'supplemental_address_2',
@@ -135,66 +134,66 @@ class CRM_Core_Page_AJAX_Location {
         'country',
       );
 
-      foreach ($addressFields as $field) {
-        if (array_key_exists($field, $addressSequence)) {
-          $addField = $field;
-          $type = 'Text';
-          if (in_array($field, array('state_province', 'country', 'county'))) {
-            $addField = "{$field}_id";
-            $type = 'Select';
-          }
-          $elements["onbehalf_{$field}-{$locTypeId}"] = array(
+    foreach ($addressFields as $field) {
+      if (array_key_exists($field, $addressSequence)) {
+        $addField = $field;
+        $type = 'Text';
+        if (in_array($field, array('state_province', 'country', 'county'))) {
+          $addField = "{$field}_id";
+          $type = 'Select';
+        }
+        $elements["onbehalf_{$field}-{$locTypeId}"] = array(
             'type' => $type,
-            'value' =>  isset($location['address'][1]) ? $location['address'][1][$addField] : null,
+            'value' => isset($location['address'][1]) ? $location['address'][1][$addField] : NULL,
           );
-          unset($profileFields["{$field}-{$locTypeId}"]);
-        }
+        unset($profileFields["{$field}-{$locTypeId}"]);
       }
+    }
 
-      //set custom field defaults
-      $defaults = array();
-      CRM_Core_BAO_UFGroup::setProfileDefaults($cid, $profileFields, $defaults, TRUE, NULL, NULL, TRUE);
+    //set custom field defaults
+    $defaults = array();
+    CRM_Core_BAO_UFGroup::setProfileDefaults($cid, $profileFields, $defaults, TRUE, NULL, NULL, TRUE);
 
-      if (!empty($defaults)) {
-        foreach ($profileFields as $key => $val) {
-          if (array_key_exists($key, $defaults)) {
-            $htmlType = CRM_Utils_Array::value('html_type', $val);
-            if ($htmlType == 'Radio') {
-              $elements["onbehalf_{$key}"]['type'] = $htmlType;
-              $elements["onbehalf_{$key}"]['value'] = $defaults[$key];
-            }
-            elseif ($htmlType == 'CheckBox') {
-              $elements["onbehalf_{$key}"]['type'] = $htmlType;
-              foreach ($defaults[$key] as $k => $v) {
-                $elements["onbehalf_{$key}"]['value'][$k] = $v;
-              }
-            }
-            elseif ($htmlType == 'Multi-Select') {
-              foreach ($defaults[$key] as $k => $v) {
-                $elements["onbehalf_{$key}"]['type'] = $htmlType;
-                $elements["onbehalf_{$key}"]['value'][$k] = $v;
-              }
-            }
-            elseif ($htmlType == 'Autocomplete-Select') {
-              $elements["onbehalf_{$key}"]['type'] = $htmlType;
-              $elements["onbehalf_{$key}"]['value'] = $defaults[$key];
-              $elements["onbehalf_{$key}"]['id'] = $defaults["{$key}_id"];
-            }
-            elseif ($htmlType == 'Select Date') {
-              $elements["onbehalf_{$key}"]['type'] = $htmlType;
-              $elements["onbehalf_{$key}"]['value'] = $defaults[$key];
-              $elements["onbehalf_{$key}_display"]['value'] = $defaults[$key];
+    if (!empty($defaults)) {
+      foreach ($profileFields as $key => $val) {
+        if (array_key_exists($key, $defaults)) {
+          $htmlType = CRM_Utils_Array::value('html_type', $val);
+          if ($htmlType == 'Radio') {
+            $elements["onbehalf_{$key}"]['type'] = $htmlType;
+            $elements["onbehalf_{$key}"]['value'] = $defaults[$key];
+          }
+          elseif ($htmlType == 'CheckBox') {
+            $elements["onbehalf_{$key}"]['type'] = $htmlType;
+            foreach ($defaults[$key] as $k => $v) {
+              $elements["onbehalf_{$key}"]['value'][$k] = $v;
             }
-            else {
+          }
+          elseif ($htmlType == 'Multi-Select') {
+            foreach ($defaults[$key] as $k => $v) {
               $elements["onbehalf_{$key}"]['type'] = $htmlType;
-              $elements["onbehalf_{$key}"]['value'] = $defaults[$key];
+              $elements["onbehalf_{$key}"]['value'][$k] = $v;
             }
           }
+          elseif ($htmlType == 'Autocomplete-Select') {
+            $elements["onbehalf_{$key}"]['type'] = $htmlType;
+            $elements["onbehalf_{$key}"]['value'] = $defaults[$key];
+            $elements["onbehalf_{$key}"]['id'] = $defaults["{$key}_id"];
+          }
+          elseif ($htmlType == 'Select Date') {
+            $elements["onbehalf_{$key}"]['type'] = $htmlType;
+            $elements["onbehalf_{$key}"]['value'] = $defaults[$key];
+            $elements["onbehalf_{$key}_display"]['value'] = $defaults[$key];
+          }
           else {
-            $elements["onbehalf_{$key}"]['value'] = '';
+            $elements["onbehalf_{$key}"]['type'] = $htmlType;
+            $elements["onbehalf_{$key}"]['value'] = $defaults[$key];
           }
         }
+        else {
+          $elements["onbehalf_{$key}"]['value'] = '';
+        }
       }
+    }
 
     CRM_Utils_JSON::output($elements);
   }
diff --git a/CRM/Core/Page/AJAX/RecurringEntity.php b/CRM/Core/Page/AJAX/RecurringEntity.php
index edfa0bdcdc..c45a7fbb6a 100644
--- a/CRM/Core/Page/AJAX/RecurringEntity.php
+++ b/CRM/Core/Page/AJAX/RecurringEntity.php
@@ -1,117 +1,117 @@
-entity_id = $result['entityId'];
-        $dao->entity_table = $result['entityTable'];
-      }
-      else {
-        $dao->entity_id = $entityId;
-        $dao->entity_table = $entityTable;
-      }
-
-      if ($dao->find(TRUE)) {
-        $dao->mode = $mode;
-        $dao->save();
-        $finalResult['status'] = 'Done';
-      }
-      else {
-        $finalResult['status'] = 'Error';
-      }
-    }
-    echo json_encode($finalResult);
-    CRM_Utils_System::civiExit();
-  }
-
-  public static function generatePreview() {
-    $params = $formValues = $genericResult = array();
-    $formValues = $_REQUEST;
-    if (!empty($formValues) &&
-        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'];
-        }
-        $recursion->scheduleFormValues = $formValues;
-        if (!empty($formValues['exclude_date_list'])) {
-          $recursion->excludeDates = $formValues['exclude_date_list'];
-        }
-        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']);
-        }
-
-        //Check if there is any enddate column defined to find out the interval between the two range
-        if (CRM_Utils_Array::value('intervalDateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
-          $daoName = CRM_Core_BAO_RecurringEntity::$_tableDAOMapper[$formValues['entity_table']];
-          if ($parentEventId) {
-            $startDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $startDateColumnName);
-            $endDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $endDateColumnName);
-          }
-          if ($endDate) {
-              $interval  = $recursion->getInterval($startDate, $endDate);
-              $recursion->intervalDateColumns = array($endDateColumnName => $interval);
-          }
-        }
-
-        $result = $recursion->generateRecursiveDates();
-
-        foreach ($result as $key => $value) {
-          if ($startDateColumnName) {
-            $result[$key]['start_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value[$startDateColumnName]));
-          }
-          if ($value[$endDateColumnName]) {
-            if ($endDateColumnName) {
-              $result[$key]['end_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value[$endDateColumnName]));
-            }
-          }
-        }
-
-        //Show the list of participants registered for the events if any
-        if ($formValues['entity_table'] == "civicrm_event" && !empty($parentEventId)) {
-          $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', TRUE);
-          if ($getConnectedEntities) {
-            $participantDetails = CRM_Event_Form_ManageEvent_Repeat::getParticipantCountforEvent($getConnectedEntities);
-            if (!empty($participantDetails['countByName'])) {
-              $result['participantData'] = $participantDetails['countByName'];
-            }
-          }
-        }
-    }
-    echo json_encode($result);
-    CRM_Utils_System::civiExit();
-  }
-}
+entity_id = $result['entityId'];
+        $dao->entity_table = $result['entityTable'];
+      }
+      else {
+        $dao->entity_id = $entityId;
+        $dao->entity_table = $entityTable;
+      }
+
+      if ($dao->find(TRUE)) {
+        $dao->mode = $mode;
+        $dao->save();
+        $finalResult['status'] = 'Done';
+      }
+      else {
+        $finalResult['status'] = 'Error';
+      }
+    }
+    echo json_encode($finalResult);
+    CRM_Utils_System::civiExit();
+  }
+
+  public static function generatePreview() {
+    $params = $formValues = $genericResult = array();
+    $formValues = $_REQUEST;
+    if (!empty($formValues) &&
+        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'];
+      }
+      $recursion->scheduleFormValues = $formValues;
+      if (!empty($formValues['exclude_date_list'])) {
+        $recursion->excludeDates = $formValues['exclude_date_list'];
+      }
+      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']);
+      }
+
+      //Check if there is any enddate column defined to find out the interval between the two range
+      if (CRM_Utils_Array::value('intervalDateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
+        $daoName = CRM_Core_BAO_RecurringEntity::$_tableDAOMapper[$formValues['entity_table']];
+        if ($parentEventId) {
+          $startDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $startDateColumnName);
+          $endDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $endDateColumnName);
+        }
+        if ($endDate) {
+          $interval  = $recursion->getInterval($startDate, $endDate);
+          $recursion->intervalDateColumns = array($endDateColumnName => $interval);
+        }
+      }
+
+      $result = $recursion->generateRecursiveDates();
+
+      foreach ($result as $key => $value) {
+        if ($startDateColumnName) {
+          $result[$key]['start_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value[$startDateColumnName]));
+        }
+        if ($value[$endDateColumnName]) {
+          if ($endDateColumnName) {
+            $result[$key]['end_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value[$endDateColumnName]));
+          }
+        }
+      }
+
+      //Show the list of participants registered for the events if any
+      if ($formValues['entity_table'] == "civicrm_event" && !empty($parentEventId)) {
+        $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', TRUE);
+        if ($getConnectedEntities) {
+          $participantDetails = CRM_Event_Form_ManageEvent_Repeat::getParticipantCountforEvent($getConnectedEntities);
+          if (!empty($participantDetails['countByName'])) {
+            $result['participantData'] = $participantDetails['countByName'];
+          }
+        }
+      }
+    }
+    echo json_encode($result);
+    CRM_Utils_System::civiExit();
+  }
+}
diff --git a/CRM/Core/Page/Angular.php b/CRM/Core/Page/Angular.php
index c11188e82f..ee221d3a82 100644
--- a/CRM/Core/Page/Angular.php
+++ b/CRM/Core/Page/Angular.php
@@ -54,7 +54,7 @@ class CRM_Core_Page_Angular extends CRM_Core_Page {
       }
       if (!empty($module['js'])) {
         foreach ($module['js'] as $file) {
-          $res->addScriptFile($module['ext'], $file, self::DEFAULT_MODULE_WEIGHT  + (++$headOffset), 'html-header', TRUE);
+          $res->addScriptFile($module['ext'], $file, self::DEFAULT_MODULE_WEIGHT + (++$headOffset), 'html-header', TRUE);
         }
       }
     }
diff --git a/CRM/Core/Page/Basic.php b/CRM/Core/Page/Basic.php
index 1c099622dc..81c9902d63 100644
--- a/CRM/Core/Page/Basic.php
+++ b/CRM/Core/Page/Basic.php
@@ -118,7 +118,8 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
    *
    * @return void
    */
-  public function addValues($controller) {}
+  public function addValues($controller) {
+  }
 
   /**
    * Class constructor
@@ -155,7 +156,7 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
     // get 'id' if present
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
 
-    require_once (str_replace('_', DIRECTORY_SEPARATOR, $this->getBAOName()) . ".php");
+    require_once str_replace('_', DIRECTORY_SEPARATOR, $this->getBAOName()) . ".php";
 
     if ($id) {
       if (!$this->checkPermission($id, NULL)) {
@@ -163,8 +164,7 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
       }
     }
 
-    if ($this->_action &
-      (CRM_Core_Action::VIEW |
+    if ($this->_action & (CRM_Core_Action::VIEW |
         CRM_Core_Action::ADD |
         CRM_Core_Action::UPDATE |
         CRM_Core_Action::COPY |
diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php
index c6cd405655..7345ab67bf 100644
--- a/CRM/Core/Payment.php
+++ b/CRM/Core/Payment.php
@@ -107,21 +107,21 @@ abstract class CRM_Core_Payment {
       return CRM_Core_DAO::$_nullObject;
     }
 
-    $cacheKey = "{$mode}_{$paymentProcessor['id']}_" . (int)isset($paymentForm);
+    $cacheKey = "{$mode}_{$paymentProcessor['id']}_" . (int) isset($paymentForm);
 
     if (!isset(self::$_singleton[$cacheKey]) || $force) {
       $config = CRM_Core_Config::singleton();
       $ext = CRM_Extension_System::singleton()->getMapper();
       if ($ext->isExtensionKey($paymentProcessor['class_name'])) {
         $paymentClass = $ext->keyToClass($paymentProcessor['class_name'], 'payment');
-        require_once ($ext->classToPath($paymentClass));
+        require_once $ext->classToPath($paymentClass);
       }
       else {
         $paymentClass = 'CRM_Core_' . $paymentProcessor['class_name'];
         if (empty($paymentClass)) {
           throw new CRM_Core_Exception('no class provided');
         }
-        require_once (str_replace('_', DIRECTORY_SEPARATOR, $paymentClass) . '.php');
+        require_once str_replace('_', DIRECTORY_SEPARATOR, $paymentClass) . '.php';
       }
 
       //load the object.
@@ -130,7 +130,7 @@ abstract class CRM_Core_Payment {
 
     //load the payment form for required processor.
     //if ($paymentForm !== NULL) {
-      //self::$_singleton[$cacheKey]->setForm($paymentForm);
+    //self::$_singleton[$cacheKey]->setForm($paymentForm);
     //}
 
     return self::$_singleton[$cacheKey];
@@ -596,10 +596,11 @@ abstract class CRM_Core_Payment {
       $extension_instance_found = TRUE;
     }
 
-    if (!$extension_instance_found) CRM_Core_Error::fatal(
+    if (!$extension_instance_found) { CRM_Core_Error::fatal(
       "No extension instances of the '{$params['processor_name']}' payment processor were found.
" . "$method method is unsupported in legacy payment processors." - ); + ); + } // Exit here on web requests, allowing just the plain text response to be echoed if ($method == 'handlePaymentNotification') { @@ -629,17 +630,19 @@ abstract class CRM_Core_Payment { public function subscriptionURL($entityID = NULL, $entity = NULL, $action = 'cancel') { // Set URL switch ($action) { - case 'cancel' : + case 'cancel': $url = 'civicrm/contribute/unsubscribe'; break; - case 'billing' : + + case 'billing': //in notify mode don't return the update billing url if (!$this->isSupported('updateSubscriptionBillingInfo')) { return NULL; } $url = 'civicrm/contribute/updatebilling'; break; - case 'update' : + + case 'update': $url = 'civicrm/contribute/updaterecur'; break; } @@ -653,17 +656,17 @@ abstract class CRM_Core_Payment { // Find related Contact if ($entityID) { switch ($entity) { - case 'membership' : + case 'membership': $contactID = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $entityID, "contact_id"); $entityArg = 'mid'; break; - case 'contribution' : + case 'contribution': $contactID = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $entityID, "contact_id"); $entityArg = 'coid'; break; - case 'recur' : + case 'recur': $sql = " SELECT con.contact_id FROM civicrm_contribution_recur rec diff --git a/CRM/Core/Payment/AuthorizeNet.php b/CRM/Core/Payment/AuthorizeNet.php index 5e8b4afedf..7e891d9b96 100644 --- a/CRM/Core/Payment/AuthorizeNet.php +++ b/CRM/Core/Payment/AuthorizeNet.php @@ -377,7 +377,7 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { $fields['x_customer_ip'] = $this->_getParam('ip_address'); $fields['x_email'] = $this->_getParam('email'); $fields['x_invoice_num'] = substr($this->_getParam('invoiceID'), 0, 20); - $fields['x_amount'] = $amount; + $fields['x_amount'] = $amount; $fields['x_currency_code'] = $this->_getParam('currencyID'); $fields['x_description'] = $this->_getParam('description'); $fields['x_cust_id'] = $this->_getParam('contactID'); @@ -601,10 +601,10 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { public function &error($errorCode = NULL, $errorMessage = NULL) { $e = CRM_Core_Error::singleton(); if ($errorCode) { - $e->push($errorCode, 0, array( ), $errorMessage); + $e->push($errorCode, 0, array(), $errorMessage); } else { - $e->push(9001, 0, array( ), 'Unknown System Error.'); + $e->push(9001, 0, array(), 'Unknown System Error.'); } return $e; } diff --git a/CRM/Core/Payment/AuthorizeNetIPN.php b/CRM/Core/Payment/AuthorizeNetIPN.php index 4957fbb559..6257cc4d6a 100644 --- a/CRM/Core/Payment/AuthorizeNetIPN.php +++ b/CRM/Core/Payment/AuthorizeNetIPN.php @@ -325,7 +325,7 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr throw new CRM_Core_Exception("Could not find an entry for $name"); } return $value; -} + } /** * @param $ids diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index f9afb4f399..55056becfb 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -391,7 +391,7 @@ class CRM_Core_Payment_BaseIPN { } if (!empty($memberships)) { - $membershipsUpdate = array( ); + $membershipsUpdate = array(); foreach ($memberships as $membershipTypeIdKey => $membership) { if ($membership) { $format = '%Y%m%d'; @@ -452,7 +452,8 @@ LIMIT 1;"; (array) $membership ); - $formatedParams = array('status_id' => CRM_Utils_Array::value('id', $calcStatus, 2), + $formatedParams = array( + 'status_id' => CRM_Utils_Array::value('id', $calcStatus, 2), 'join_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $dates), $format), 'start_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $dates), $format), 'end_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $dates), $format), @@ -583,7 +584,7 @@ LIMIT 1;"; //add lineitems for recurring payments if (!empty($objects['contributionRecur']) && $objects['contributionRecur']->id) { if ($addLineItems) { - $input ['line_item'] = $this->addRecurLineItems($objects['contributionRecur']->id, $contribution); + $input['line_item'] = $this->addRecurLineItems($objects['contributionRecur']->id, $contribution); } else { // this is just to prevent e-notices when we call recordFinancialAccounts - per comments on that line - intention is somewhat unclear @@ -614,9 +615,8 @@ LIMIT 1;"; // it would be good if someone added some comments or refactored this if ($contribution->id) { $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array('labelColumn' => 'name', 'flip' => 1)); - if ((empty($input['prevContribution']) && $paymentProcessorId) || (!$input['prevContribution']->is_pay_later && -- $input['prevContribution']->contribution_status_id == $contributionStatuses['Pending'])) { - $input['payment_processor'] = $paymentProcessorId; + if ((empty($input['prevContribution']) && $paymentProcessorId) || (!$input['prevContribution']->is_pay_later && - $input['prevContribution']->contribution_status_id == $contributionStatuses['Pending'])) { + $input['payment_processor'] = $paymentProcessorId; } $input['contribution_status_id'] = $contributionStatuses['Completed']; $input['total_amount'] = $input['amount']; @@ -821,7 +821,7 @@ LIMIT 1;"; $contribution = &$objects['contribution']; - $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array('labelColumn' => 'name','flip' => 1)); + $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array('labelColumn' => 'name', 'flip' => 1)); $input['skipComponentSync'] = CRM_Utils_Array::value('skipComponentSync', $params); if ($statusId == $contributionStatuses['Cancelled']) { $baseIPN->cancelled($objects, $transaction, $input); diff --git a/CRM/Core/Payment/Elavon.php b/CRM/Core/Payment/Elavon.php index 90daeb5a81..d514873e2c 100644 --- a/CRM/Core/Payment/Elavon.php +++ b/CRM/Core/Payment/Elavon.php @@ -122,7 +122,6 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment { $requestFields['ssl_customer_code'] = '1111'; $requestFields['ssl_salestax'] = 0.0; - /************************************************************************************ * Fields available from civiCRM not implemented for Elavon * @@ -226,12 +225,14 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment { $errorDesc = curl_error($ch); // Paranoia - in the unlikley event that 'curl' errno fails - if ($errorNum == 0) - $errorNum = 9005; + if ($errorNum == 0) { + $errorNum = 9005; + } // Paranoia - in the unlikley event that 'curl' error fails - if (strlen($errorDesc) == 0) - $errorDesc = "Connection to payment gateway failed"; + if (strlen($errorDesc) == 0) { + $errorDesc = "Connection to payment gateway failed"; + } if ($errorNum = 60) { return self::errorExit($errorNum, "Curl error - " . $errorDesc . " Try this link for more information http://curl.haxx.se/docs/sslcerts.html"); } @@ -273,7 +274,6 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment { * fix for CRM-2566 **********************************************************/ - if ($processorResponse['errorCode']) { return self::errorExit(9010, "Error: [" . $processorResponse['errorCode'] . " " . $processorResponse['errorName'] . " " . $processorResponse['errorMessage'] . "] - from payment processor"); } diff --git a/CRM/Core/Payment/FirstData.php b/CRM/Core/Payment/FirstData.php index 15a18c87c6..ff83bbe9f4 100644 --- a/CRM/Core/Payment/FirstData.php +++ b/CRM/Core/Payment/FirstData.php @@ -199,7 +199,6 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment { $port = "1129"; $host = $this->_paymentProcessor['url_site'] . ":" . $port . "/LSGSXML"; - //---------------------------------------------------------------------------------------------------- // Check to see if we have a duplicate before we send //---------------------------------------------------------------------------------------------------- @@ -211,20 +210,16 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment { //---------------------------------------------------------------------------------------------------- $requestxml = lphp::buildXML($requestFields); - - /*---------------------------------------------------------------------------------------------------- // Send to the payment information using cURL /---------------------------------------------------------------------------------------------------- */ - $ch = curl_init($host); if (!$ch) { return self::errorExit(9004, 'Could not initiate connection to payment gateway'); } - curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $requestxml); curl_setopt($ch, CURLOPT_SSLCERT, $key); @@ -253,12 +248,14 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment { $errorDesc = curl_error($ch); // Paranoia - in the unlikley event that 'curl' errno fails - if ($errorNum == 0) - $errorNum = 9005; + if ($errorNum == 0) { + $errorNum = 9005; + } // Paranoia - in the unlikley event that 'curl' error fails - if (strlen($errorDesc) == 0) - $errorDesc = "Connection to payment gateway failed"; + if (strlen($errorDesc) == 0) { + $errorDesc = "Connection to payment gateway failed"; + } if ($errorNum == 60) { return self::errorExit($errorNum, "Curl error - " . $errorDesc . " Try this link for more information http://curl.haxx.se/docs/sslcerts.html"); } diff --git a/CRM/Core/Payment/GoogleIPN.php b/CRM/Core/Payment/GoogleIPN.php index 9ca575835c..6dbd487545 100644 --- a/CRM/Core/Payment/GoogleIPN.php +++ b/CRM/Core/Payment/GoogleIPN.php @@ -298,9 +298,9 @@ class CRM_Core_Payment_GoogleIPN extends CRM_Core_Payment_BaseIPN { $ids['related_contact'] = NULL; $ids['onbehalf_dupe_alert'] = NULL; if ($contribution->trxn_id) { - list($ids['membership'], $ids['related_contact'], $ids['onbehalf_dupe_alert']) = explode(CRM_Core_DAO::VALUE_SEPARATOR, + list($ids['membership'], $ids['related_contact'], $ids['onbehalf_dupe_alert']) = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contribution->trxn_id - ); + ); } foreach (array( 'membership', 'related_contact', 'onbehalf_dupe_alert') as $fld) { @@ -543,7 +543,7 @@ WHERE contribution_recur_id = {$ids['contributionRecur']} // lets retrieve the private-data & order-no $privateData = NULL; if (array_key_exists('shopping-cart', $data[$root])) { - $privateData = $data[$root]['shopping-cart']['merchant-private-data']['VALUE']; + $privateData = $data[$root]['shopping-cart']['merchant-private-data']['VALUE']; } if (empty($privateData) && array_key_exists('order-summary', $data[$root]) && array_key_exists('shopping-cart', $data[$root]['order-summary'])) { @@ -583,65 +583,65 @@ WHERE contribution_recur_id = {$ids['contributionRecur']} case "merchant-calculation-callback": break; - case "new-order-notification": { - $response->SendAck($serial, FALSE); - $ipn->newOrderNotify($data[$root], $privateData, $module); - break; + case "new-order-notification":{ + $response->SendAck($serial, FALSE); + $ipn->newOrderNotify($data[$root], $privateData, $module); + break; } - case "order-state-change-notification": { - $response->SendAck($serial, FALSE); - $new_financial_state = $data[$root]['new-financial-order-state']['VALUE']; - $new_fulfillment_order = $data[$root]['new-fulfillment-order-state']['VALUE']; + case "order-state-change-notification":{ + $response->SendAck($serial, FALSE); + $new_financial_state = $data[$root]['new-financial-order-state']['VALUE']; + $new_fulfillment_order = $data[$root]['new-fulfillment-order-state']['VALUE']; - switch ($new_financial_state) { - case 'CHARGEABLE': - break; + switch ($new_financial_state) { + case 'CHARGEABLE': + break; - case 'CHARGED': - case 'PAYMENT_DECLINED': - case 'CANCELLED': - case 'CANCELLED_BY_GOOGLE': - $ipn->orderStateChange($new_financial_state, $data[$root], $privateData, $module); - break; + case 'CHARGED': + case 'PAYMENT_DECLINED': + case 'CANCELLED': + case 'CANCELLED_BY_GOOGLE': + $ipn->orderStateChange($new_financial_state, $data[$root], $privateData, $module); + break; - case 'REVIEWING': - case 'CHARGING': - break; + case 'REVIEWING': + case 'CHARGING': + break; - default: - break; - } - break; + default: + break; + } + break; } - case "authorization-amount-notification": { - $response->SendAck($serial, FALSE); - $new_financial_state = $data[$root]['order-summary']['financial-order-state']['VALUE']; - $new_fulfillment_order = $data[$root]['order-summary']['fulfillment-order-state']['VALUE']; - - switch ($new_financial_state) { - case 'CHARGEABLE': - // For google-handled subscriptions chargeorder needn't be initiated, - // assuming auto-charging is turned on. - //$request->SendProcessOrder($data[$root]['google-order-number']['VALUE']); - //$request->SendChargeOrder($data[$root]['google-order-number']['VALUE'],''); - break; - - case 'CHARGED': - case 'PAYMENT_DECLINED': - case 'CANCELLED': - break; - - case 'REVIEWING': - case 'CHARGING': - case 'CANCELLED_BY_GOOGLE': - break; - - default: - break; - } - break; + case "authorization-amount-notification":{ + $response->SendAck($serial, FALSE); + $new_financial_state = $data[$root]['order-summary']['financial-order-state']['VALUE']; + $new_fulfillment_order = $data[$root]['order-summary']['fulfillment-order-state']['VALUE']; + + switch ($new_financial_state) { + case 'CHARGEABLE': + // For google-handled subscriptions chargeorder needn't be initiated, + // assuming auto-charging is turned on. + //$request->SendProcessOrder($data[$root]['google-order-number']['VALUE']); + //$request->SendChargeOrder($data[$root]['google-order-number']['VALUE'],''); + break; + + case 'CHARGED': + case 'PAYMENT_DECLINED': + case 'CANCELLED': + break; + + case 'REVIEWING': + case 'CHARGING': + case 'CANCELLED_BY_GOOGLE': + break; + + default: + break; + } + break; } case "charge-amount-notification": @@ -682,7 +682,7 @@ WHERE contribution_recur_id = {$ids['contributionRecur']} foreach ($lookup as $name => $googleName) { if (array_key_exists($googleName, $dataRoot['buyer-billing-address'])) { - $value = $dataRoot['buyer-billing-address'][$googleName]['VALUE']; + $value = $dataRoot['buyer-billing-address'][$googleName]['VALUE']; } $input[$name] = $value ? $value : NULL; } diff --git a/CRM/Core/Payment/IATS.php b/CRM/Core/Payment/IATS.php index a53077024d..616d26d288 100644 --- a/CRM/Core/Payment/IATS.php +++ b/CRM/Core/Payment/IATS.php @@ -126,11 +126,11 @@ class CRM_Core_Payment_IATS extends CRM_Core_Payment { // beginning of modified sample code from IATS php api include IATS supplied api library if ($isRecur) { - include_once ('Services/IATS/iats_reoccur.php'); + include_once 'Services/IATS/iats_reoccur.php'; $iatslink1 = new iatslinkReoccur; } else { - include_once ('Services/IATS/iatslink.php'); + include_once 'Services/IATS/iatslink.php'; $iatslink1 = new iatslink; } @@ -225,7 +225,7 @@ class CRM_Core_Payment_IATS extends CRM_Core_Payment { default: die('Invalid frequency unit!'); - break; + break; } $endDate = date('Y-m-d', $endTime); $startDate = date('Y-m-d', $startTime); diff --git a/CRM/Core/Payment/PayJunction.php b/CRM/Core/Payment/PayJunction.php index e77af14209..c25ea1fb3e 100644 --- a/CRM/Core/Payment/PayJunction.php +++ b/CRM/Core/Payment/PayJunction.php @@ -60,7 +60,7 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { * @return object * @static */ - public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = false) { + public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { if (!empty($paymentProcessor['id'])) { $cacheKey = $paymentProcessor['id']; } @@ -135,7 +135,6 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { // set customer info (level 3 data) for the transaction $pjpgTxn->setCustInfo($pjpgCustInfo); - // empty installments convert to 999 because PayJunction do not allow open end donation if ($params['installments'] == "") { $params['installments'] = "999"; diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index 448d377fc4..2d8009ac80 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -286,7 +286,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { } public function main() { - //@todo - this could be refactored like PayPalProIPN & a test could be added + //@todo - this could be refactored like PayPalProIPN & a test could be added $objects = $ids = $input = array(); $component = CRM_Utils_Array::value('module', $_GET); diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index 7ba916439c..0368b5c362 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -60,7 +60,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { $this->_mode = $mode; $this->_paymentProcessor = $paymentProcessor; $this->_processorName = ts('PayPal Pro'); - $paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(false, null, 'name'); + $paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(FALSE, NULL, 'name'); if ($this->_paymentProcessor['payment_processor_type_id'] == CRM_Utils_Array::key('PayPal_Standard', $paymentProcessorType)) { $this->_processorName = ts('PayPal Standard'); @@ -402,7 +402,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { */ public function checkConfig() { $error = array(); - $paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(false, null, 'name'); + $paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(FALSE, NULL, 'name'); if ( $this->_paymentProcessor['payment_processor_type_id'] == CRM_Utils_Array::key('PayPal_Standard', $paymentProcessorType) || $this->_paymentProcessor['payment_processor_type_id'] == CRM_Utils_Array::key('PayPal', $paymentProcessorType) diff --git a/CRM/Core/Payment/PayPalProIPN.php b/CRM/Core/Payment/PayPalProIPN.php index 595c9fd3a7..e2736d9d6b 100644 --- a/CRM/Core/Payment/PayPalProIPN.php +++ b/CRM/Core/Payment/PayPalProIPN.php @@ -218,7 +218,6 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { recurring_payment_suspended_due_to_max_failed_payment RP Profile Suspended due to Max Failed Payment */ - //set transaction type $txnType = $this->retrieve('txn_type', 'String'); //Changes for paypal pro recurring payment @@ -226,7 +225,7 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { $contributionStatuses = $contributionStatuses['values']; switch ($txnType) { case 'recurring_payment_profile_created': - if(in_array($recur->contribution_status_id, array(array_search('Pending',$contributionStatuses), array_search('In Progress',$contributionStatuses))) + if(in_array($recur->contribution_status_id, array(array_search('Pending', $contributionStatuses), array_search('In Progress', $contributionStatuses))) && !empty($recur->processor_id)) { echo "already handled"; return; @@ -311,7 +310,7 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { $objects['contribution'] = &$contribution; } // CRM-13737 - am not aware of any reason why payment_date would not be set - this if is a belt & braces - $objects['contribution']->receive_date = !empty($input['payment_date']) ? date('YmdHis', strtotime($input['payment_date'])): $now; + $objects['contribution']->receive_date = !empty($input['payment_date']) ? date('YmdHis', strtotime($input['payment_date'])) : $now; $this->single($input, $ids, $objects, TRUE, $first @@ -427,7 +426,8 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contribution_id = %1 WHERE m.contribution_recur_id = %2 LIMIT 1"; - $sqlParams = array(1 => array($ids['contribution'], 'Integer'), + $sqlParams = array( + 1 => array($ids['contribution'], 'Integer'), 2 => array($ids['contributionRecur'], 'Integer'), ); if ($membershipId = CRM_Core_DAO::singleValueQuery($sql, $sqlParams)) { @@ -518,15 +518,15 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr * only contribute is handled */ public function handlePaymentExpress() { - //@todo - loads of copy & paste / code duplication but as this not going into core need to try to - // keep discreet - // also note that a lot of the complexity above could be removed if we used - // http://stackoverflow.com/questions/4848227/validate-that-ipn-call-is-from-paypal - // as membership id etc can be derived by the load objects fn + //@todo - loads of copy & paste / code duplication but as this not going into core need to try to + // keep discreet + // also note that a lot of the complexity above could be removed if we used + // http://stackoverflow.com/questions/4848227/validate-that-ipn-call-is-from-paypal + // as membership id etc can be derived by the load objects fn $objects = $ids = $input = array(); $isFirst = FALSE; $input['txnType'] = $this->retrieve('txn_type', 'String'); - if($input['txnType'] != 'recurring_payment') { + if($input['txnType'] != 'recurring_payment') { throw new CRM_Core_Exception('Paypal IPNS not handled other than recurring_payments'); } $input['invoice'] = self::getValue('i', FALSE); @@ -538,12 +538,12 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr $contributionRecur = civicrm_api3('contribution_recur', 'getsingle', array('return' => 'contact_id, id', 'invoice_id' => $input['invoice'])); $ids['contact'] = $contributionRecur['contact_id']; $ids['contributionRecur'] = $contributionRecur['id']; - $result = civicrm_api3('contribution', 'getsingle', array('invoice_id' => $input['invoice'], )); + $result = civicrm_api3('contribution', 'getsingle', array('invoice_id' => $input['invoice'] )); $ids['contribution'] = $result['id']; //@todo hard - coding 'pending' for now if($result['contribution_status_id'] == 2) { - $isFirst = True; + $isFirst = TRUE; } // arg api won't get this - fix it $ids['contributionPage'] = CRM_Core_DAO::singleValueQuery("SELECT contribution_page_id FROM civicrm_contribution WHERE invoice_id = %1", array(1 => array($ids['contribution'], 'Integer'))); diff --git a/CRM/Core/Payment/PayflowPro.php b/CRM/Core/Payment/PayflowPro.php index e103f278c1..0ecaa28ba7 100644 --- a/CRM/Core/Payment/PayflowPro.php +++ b/CRM/Core/Payment/PayflowPro.php @@ -202,8 +202,7 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { case '2 weeks': $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m"), date("d") + 14, date("Y")); - $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (14 * $payflow_query_array['TERM']) - , date("Y ") + $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (14 * $payflow_query_array['TERM']), date("Y ") ); $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']); $payflow_query_array['PAYPERIOD'] = "BIWK"; @@ -214,8 +213,7 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { case '4 weeks': $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m"), date("d") + 28, date("Y") ); - $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (28 * $payflow_query_array['TERM']) - , date("Y") + $params['end_date'] = mktime(0, 0, 0, date("m"), date("d") + (28 * $payflow_query_array['TERM']), date("Y") ); $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date']); $payflow_query_array['PAYPERIOD'] = "FRWK"; @@ -238,8 +236,7 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { break; case '3 months': - $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m") + 3, date("d") - , date("Y") + $params['next_sched_contribution_date'] = mktime(0, 0, 0, date("m") + 3, date("d"), date("Y") ); $params['end_date'] = mktime(0, 0, 0, date("m") + (3 * $payflow_query_array['TERM']), @@ -259,8 +256,7 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { (6 * $payflow_query_array['TERM']), date("d"), date("Y") ); - $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date' - ] + $payflow_query_array['START'] = date('mdY', $params['next_sched_contribution_date'] ); $payflow_query_array['PAYPERIOD'] = "SMYR"; $params['frequency_unit'] = "month"; @@ -589,12 +585,14 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { $errorDesc = curl_error($ch); //Paranoia - in the unlikley event that 'curl' errno fails - if ($errorNum == 0) - $errorNum = 9005; + if ($errorNum == 0) { + $errorNum = 9005; + } // Paranoia - in the unlikley event that 'curl' error fails - if (strlen($errorDesc) == 0) - $errorDesc = "Connection to payment gateway failed"; + if (strlen($errorDesc) == 0) { + $errorDesc = "Connection to payment gateway failed"; + } if ($errorNum = 60) { return self::errorExit($errorNum, "Curl error - " . $errorDesc . " Try this link for more information http://curl.haxx.se/d @@ -660,7 +658,6 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { //$recurringProfileID = "RT0000000001"; // c $trythis = $this->getRecurringTransactionStatus($recurringProfileID,17); - /* *Create the array of variables to be sent to the processor from the $params array * passed into this function diff --git a/CRM/Core/Payment/PaymentExpress.php b/CRM/Core/Payment/PaymentExpress.php index 991ec83e13..ffe15b8abb 100644 --- a/CRM/Core/Payment/PaymentExpress.php +++ b/CRM/Core/Payment/PaymentExpress.php @@ -195,7 +195,6 @@ class CRM_Core_Payment_PaymentExpress extends CRM_Core_Payment { ); } - /* * Build the private data string to pass to DPS, which they will give back to us with the * @@ -207,7 +206,7 @@ class CRM_Core_Payment_PaymentExpress extends CRM_Core_Payment { $privateData = "a={$params['contactID']},b={$params['contributionID']},c={$params['contributionTypeID']},d={$params['invoiceID']}"; if ($component == 'event') { - $merchantRef = substr($params['contactID'] . "-" . $params['contributionID'] . " " . substr($params['description'], 27, 20), 0, 24); + $merchantRef = substr($params['contactID'] . "-" . $params['contributionID'] . " " . substr($params['description'], 27, 20), 0, 24); $privateData .= ",f={$params['participantID']},g={$params['eventID']}"; } elseif ($component == 'contribute') { @@ -239,7 +238,6 @@ class CRM_Core_Payment_PaymentExpress extends CRM_Core_Payment { * determine whether method is pxaccess or pxpay by whether signature (mac key) is defined */ - if (empty($this->_paymentProcessor['signature'])) { /* * Processor is pxpay @@ -277,7 +275,7 @@ class CRM_Core_Payment_PaymentExpress extends CRM_Core_Payment { } else { $processortype = "pxaccess"; - require_once ('PaymentExpress/pxaccess.inc.php'); + require_once 'PaymentExpress/pxaccess.inc.php'; // URL $PxAccess_Url = $this->_paymentProcessor['url_site']; // User ID diff --git a/CRM/Core/Payment/PaymentExpressIPN.php b/CRM/Core/Payment/PaymentExpressIPN.php index 62cf077502..8ad592d8b8 100644 --- a/CRM/Core/Payment/PaymentExpressIPN.php +++ b/CRM/Core/Payment/PaymentExpressIPN.php @@ -209,7 +209,7 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { /** - /** + /** * The function returns the component(Event/Contribute..)and whether it is Test or not * * @param array $privateData @@ -278,12 +278,12 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { } return array($isTest, $component, $duplicateTransaction); - } + } /** * This method is handles the response that will be invoked by the * notification or request sent by the payment processor. - *hex string from paymentexpress is passed to this function as hex string. Code based on googleIPN + * hex string from paymentexpress is passed to this function as hex string. Code based on googleIPN * mac_key is only passed if the processor is pxaccess as it is used for decryption * $dps_method is either pxaccess or pxpay */ @@ -332,7 +332,7 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { $DPStxnRef = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, 'DpsTxnRef'); $qfKey = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "TxnData1"); $privateData = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "TxnData2"); - list($component,$paymentProcessorID,) =explode(',', CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "TxnData3")); + list($component, $paymentProcessorID,) = explode(',', CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "TxnData3")); $amount = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "AmountSettlement"); $merchantReference = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "MerchantReference"); } @@ -344,7 +344,7 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { } elseif ($dps_method == "pxaccess") { - require_once ('PaymentExpress/pxaccess.inc.php'); + require_once 'PaymentExpress/pxaccess.inc.php'; global $pxaccess; $pxaccess = new PxAccess($dps_url, $dps_user, $dps_key, $mac_key); #getResponse method in PxAccess object returns PxPayResponse object @@ -353,7 +353,7 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { $qfKey = $rsp->getTxnData1(); $privateData = $rsp->getTxnData2(); - list($component,$paymentProcessorID) = explode(',',$rsp->getTxnData3()); + list($component, $paymentProcessorID) = explode(',', $rsp->getTxnData3()); $success = $rsp->getSuccess(); $authCode = $rsp->getAuthCode(); $DPStxnRef = $rsp->getDpsTxnRef(); @@ -388,14 +388,12 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { list($mode, $component, $duplicateTransaction) = self::getContext($privateData, $transactionReference); $mode = $mode ? 'test' : 'live'; - $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID, $mode ); $ipn = self::singleton($mode, $component, $paymentProcessor); - //Check status and take appropriate action if ($success == 1) { diff --git a/CRM/Core/Payment/PaymentExpressUtils.php b/CRM/Core/Payment/PaymentExpressUtils.php index 06c1adda2d..b19011c1af 100644 --- a/CRM/Core/Payment/PaymentExpressUtils.php +++ b/CRM/Core/Payment/PaymentExpressUtils.php @@ -50,7 +50,7 @@ class CRM_Core_Payment_PaymentExpressUtils { if (is_array($element)) { $xml = ''; foreach ($element as $elem => $value) { - $xml .= self::_valueXml($elem, $value); + $xml .= self::_valueXml($elem, $value); } return $xml; } diff --git a/CRM/Core/Payment/ProcessorForm.php b/CRM/Core/Payment/ProcessorForm.php index bb2d546c8a..114b527607 100644 --- a/CRM/Core/Payment/ProcessorForm.php +++ b/CRM/Core/Payment/ProcessorForm.php @@ -45,7 +45,7 @@ class CRM_Core_Payment_ProcessorForm { * * @throws Exception */ - public static function preProcess(&$form, $type = NULL, $mode = NULL ) { + public static function preProcess(&$form, $type = NULL, $mode = NULL) { if ($type) { $form->_type = $type; } @@ -70,7 +70,6 @@ class CRM_Core_Payment_ProcessorForm { // saving the country/state list in the session (which could be huge) CRM_Core_Payment_Form::setPaymentFieldsByProcessor($form, $form->_paymentProcessor); - $form->assign_by_ref('paymentProcessor', $form->_paymentProcessor); // check if this is a paypal auto return and redirect accordingly diff --git a/CRM/Core/Payment/Realex.php b/CRM/Core/Payment/Realex.php index a9b63b33c4..c1901c6001 100644 --- a/CRM/Core/Payment/Realex.php +++ b/CRM/Core/Payment/Realex.php @@ -89,7 +89,7 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { * @return object * @static */ - public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = false) { + public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { if (!empty($paymentProcessor['id'])) { $cacheKey = $paymentProcessor['id']; } @@ -172,7 +172,6 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { $hashme = "$sha1hash.{$this->_getParam('secret')}"; $sha1hash = sha1($hashme); - // Generate the request xml that is send to Realex Payments. $request_xml = " {$this->_getParam('merchant_ref')} @@ -361,7 +360,7 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { * Format the params from the form ready for sending to Realex. Also perform some validation */ public function setRealexFields(&$params) { - if ((int)$params['amount'] <= 0) { + if ((int) $params['amount'] <= 0) { return self::error(9001, ts('Amount must be positive')); } @@ -432,17 +431,17 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { $this->_setParam('currency', $config->defaultCurrency); // Format the expiry date to MMYY - $expmonth = (string)$params['month']; + $expmonth = (string) $params['month']; $expmonth = (strlen($expmonth) === 1) ? '0' . $expmonth : $expmonth; - $expyear = substr((string)$params['year'], 2, 2); + $expyear = substr((string) $params['year'], 2, 2); $this->_setParam('exp_date', $expmonth . $expyear); if (isset($params['credit_card_start_date']) && (strlen($params['credit_card_start_date']['M']) !== 0) && (strlen($params['credit_card_start_date']['Y']) !== 0) ) { - $startmonth = (string)$params['credit_card_start_date']['M']; + $startmonth = (string) $params['credit_card_start_date']['M']; $startmonth = (strlen($startmonth) === 1) ? '0' . $startmonth : $startmonth; - $startyear = substr((string)$params['credit_card_start_date']['Y'], 2, 2); + $startyear = substr((string) $params['credit_card_start_date']['Y'], 2, 2); $this->_setParam('start_date', $startmonth . $startyear); } diff --git a/CRM/Core/Payment/eWAY.php b/CRM/Core/Payment/eWAY.php index 8c59057244..4dfce475e7 100644 --- a/CRM/Core/Payment/eWAY.php +++ b/CRM/Core/Payment/eWAY.php @@ -137,7 +137,7 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { * @return object * @static */ - public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = false) { + public static function &singleton($mode, &$paymentProcessor, &$paymentForm = NULL, $force = FALSE) { if (!empty($paymentProcessor['id'])) { $cacheKey = $paymentProcessor['id']; } @@ -194,7 +194,6 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { $country = $params['country']; */ - //------------------------------------------------------------- // Prepare some composite data from _paymentProcessor fields //------------------------------------------------------------- @@ -325,12 +324,14 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { $errorDesc = curl_error($submit); // Paranoia - in the unlikley event that 'curl' errno fails - if ($errorNum == 0) - $errorNum = 9005; + if ($errorNum == 0) { + $errorNum = 9005; + } // Paranoia - in the unlikley event that 'curl' error fails - if (strlen($errorDesc) == 0) - $errorDesc = "Connection to eWAY payment gateway failed"; + if (strlen($errorDesc) == 0) { + $errorDesc = "Connection to eWAY payment gateway failed"; + } return self::errorExit($errorNum, $errorDesc); } @@ -417,7 +418,6 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { } */ - //============= // Success ! //============= @@ -528,7 +528,6 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { // Initialization call is required to use CiviCRM APIs. civicrm_initialize(TRUE); - list($fromName, $fromEmail) = CRM_Core_BAO_Domain::getNameAndEmail(); $from = "$fromName <$fromEmail>"; diff --git a/CRM/Core/Permission/Base.php b/CRM/Core/Permission/Base.php index eb1869b588..ba9365e0e3 100644 --- a/CRM/Core/Permission/Base.php +++ b/CRM/Core/Permission/Base.php @@ -56,11 +56,15 @@ class CRM_Core_Permission_Base { list ($civiPrefix, $name) = CRM_Utils_String::parsePrefix(':', $perm, NULL); switch ($civiPrefix) { case $nativePrefix: - return $name; // pass through + return $name; + + // pass through case 'cms': return CRM_Utils_Array::value($name, $map, CRM_Core_Permission::ALWAYS_DENY_PERMISSION); + case NULL: return $name; + default: return CRM_Core_Permission::ALWAYS_DENY_PERMISSION; } diff --git a/CRM/Core/Permission/Drupal6.php b/CRM/Core/Permission/Drupal6.php index b81a37d42b..a195f52ec6 100644 --- a/CRM/Core/Permission/Drupal6.php +++ b/CRM/Core/Permission/Drupal6.php @@ -137,8 +137,8 @@ class CRM_Core_Permission_Drupal6 extends CRM_Core_Permission_DrupalBase { $query = db_query($sql); while ($result = db_fetch_object($query)) { - $uids[] = $result->uid; - } + $uids[] = $result->uid; + } $_cache[$roleName] = self::getContactEmails($uids); return $_cache[$roleName]; @@ -171,11 +171,11 @@ class CRM_Core_Permission_Drupal6 extends CRM_Core_Permission_DrupalBase { $query = db_query($sql); while ($result = db_fetch_object($query)) { - $uids[] = $result->uid; - } + $uids[] = $result->uid; + } - $_cache[$permissionName] = self::getContactEmails($uids); - return $_cache[$permissionName]; + $_cache[$permissionName] = self::getContactEmails($uids); + return $_cache[$permissionName]; } /** diff --git a/CRM/Core/Permission/DrupalBase.php b/CRM/Core/Permission/DrupalBase.php index e417956745..e788541e08 100644 --- a/CRM/Core/Permission/DrupalBase.php +++ b/CRM/Core/Permission/DrupalBase.php @@ -100,7 +100,6 @@ class CRM_Core_Permission_DrupalBase extends CRM_Core_Permission_Base { $this->_viewPermissionedGroups[$groupKey] = $groups; } - $ids = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_saved_search', $groups); if (!empty($ids)) { foreach (array_values($ids) as $id) { @@ -245,7 +244,7 @@ class CRM_Core_Permission_DrupalBase extends CRM_Core_Permission_Base { $emails = array(); while ($dao->fetch()) { - $emails[] = $dao->email; + $emails[] = $dao->email; } return implode(', ', $emails); diff --git a/CRM/Core/Permission/Joomla.php b/CRM/Core/Permission/Joomla.php index a012cac210..b98112281c 100644 --- a/CRM/Core/Permission/Joomla.php +++ b/CRM/Core/Permission/Joomla.php @@ -84,11 +84,14 @@ class CRM_Core_Permission_Joomla extends CRM_Core_Permission_Base { switch($civiPrefix) { case 'Joomla': return explode(':', $name); + case 'cms': // FIXME: This needn't be DENY, but we don't currently have any translations. return CRM_Core_Permission::ALWAYS_DENY_PERMISSION; + case NULL: return array('civicrm.' . CRM_Utils_String::munge(strtolower($name)), 'com_civicrm'); + default: return CRM_Core_Permission::ALWAYS_DENY_PERMISSION; } diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 8907b56434..26000e203b 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -1550,12 +1550,12 @@ WHERE id = %1"; */ public static function &visibility($column = 'label') { if (!isset(self::$visibility)) { - self::$visibility = array( ); + self::$visibility = array(); } if (!isset(self::$visibility[$column])) { self::$visibility[$column] = CRM_Core_OptionGroup::values('visibility', FALSE, FALSE, FALSE, NULL, $column); - } + } return self::$visibility[$column]; } @@ -1823,10 +1823,10 @@ WHERE id = %1 * * @return array - array reference of all Option Group Name */ - public static function accountOptionValues($optionGroupName, $id = null, $condition = null) { + public static function accountOptionValues($optionGroupName, $id = NULL, $condition = NULL) { $cacheKey = $optionGroupName . '_' . $condition; if (empty(self::$accountOptionValues[$cacheKey])) { - self::$accountOptionValues[$cacheKey] = CRM_Core_OptionGroup::values($optionGroupName, false, false, false, $condition); + self::$accountOptionValues[$cacheKey] = CRM_Core_OptionGroup::values($optionGroupName, FALSE, FALSE, FALSE, $condition); } if ($id) { return CRM_Utils_Array::value($id, self::$accountOptionValues[$cacheKey]); diff --git a/CRM/Core/QuickForm/Action/Refresh.php b/CRM/Core/QuickForm/Action/Refresh.php index 2c48660f1a..f5efbc4d8e 100644 --- a/CRM/Core/QuickForm/Action/Refresh.php +++ b/CRM/Core/QuickForm/Action/Refresh.php @@ -67,7 +67,6 @@ class CRM_Core_QuickForm_Action_Refresh extends CRM_Core_QuickForm_Action { $data['values'][$pageName] = $page->exportValues(); $data['valid'][$pageName] = $page->validate(); - // Modal form and page is invalid: don't go further if ($page->controller->isModal() && !$data['valid'][$pageName]) { return $page->handle('display'); diff --git a/CRM/Core/QuickForm/GroupMultiSelect.php b/CRM/Core/QuickForm/GroupMultiSelect.php index c37ea58751..eb7b1c9c08 100644 --- a/CRM/Core/QuickForm/GroupMultiSelect.php +++ b/CRM/Core/QuickForm/GroupMultiSelect.php @@ -74,7 +74,7 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu } } - if (is_array($this->_values) && in_array((string)$option['attr']['value'], $this->_values)) { + if (is_array($this->_values) && in_array((string) $option['attr']['value'], $this->_values)) { // The items is *selected* $checked = ' checked="checked"'; } @@ -146,7 +146,7 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu foreach ($this->_options as $option) { if (is_array($this->_values) && - in_array((string)$option['attr']['value'], $this->_values) + in_array((string) $option['attr']['value'], $this->_values) ) { // Get the post order $key = array_search($option['attr']['value'], $this->_values); diff --git a/CRM/Core/Region.php b/CRM/Core/Region.php index 9b0384ea5a..25d37829e4 100644 --- a/CRM/Core/Region.php +++ b/CRM/Core/Region.php @@ -122,7 +122,7 @@ class CRM_Core_Region { if (!isset($snippet['name'])) { $snippet['name'] = count($this->_snippets); } - $this->_snippets[ $snippet['name'] ] = $snippet; + $this->_snippets[$snippet['name']] = $snippet; $this->_isSorted = FALSE; return $snippet; } @@ -177,21 +177,25 @@ class CRM_Core_Region { case 'markup': $html .= $snippet['markup']; break; + case 'template': $tmp = $smarty->get_template_vars('snippet'); $smarty->assign('snippet', $snippet); $html .= $smarty->fetch($snippet['template']); $smarty->assign('snippet', $tmp); break; + case 'callback': $args = isset($snippet['arguments']) ? $snippet['arguments'] : array(&$snippet, &$html); $html .= call_user_func_array($snippet['callback'], $args); break; + case 'scriptUrl': if (!$allowCmsOverride || !$cms->addScriptUrl($snippet['scriptUrl'], $this->_name)) { $html .= sprintf("\n", $snippet['scriptUrl']); } break; + case 'jquery': $snippet['script'] = sprintf("CRM.\$(function(\$) {\n%s\n});", $snippet['jquery']); // no break - continue processing as script @@ -200,16 +204,19 @@ class CRM_Core_Region { $html .= sprintf("\n", $snippet['script']); } break; + case 'styleUrl': if (!$allowCmsOverride || !$cms->addStyleUrl($snippet['styleUrl'], $this->_name)) { $html .= sprintf("\n", $snippet['styleUrl']); } break; + case 'style': if (!$allowCmsOverride || !$cms->addStyle($snippet['style'], $this->_name)) { $html .= sprintf("\n", $snippet['style']); } break; + default: require_once 'CRM/Core/Error.php'; CRM_Core_Error::fatal( ts( 'Snippet type %1 is unrecognized', @@ -226,11 +233,15 @@ class CRM_Core_Region { * @return int */ public static function _cmpSnippet($a, $b) { - if ($a['weight'] < $b['weight']) return -1; - if ($a['weight'] > $b['weight']) return 1; + if ($a['weight'] < $b['weight']) { return -1; + } + if ($a['weight'] > $b['weight']) { return 1; + } // fallback to name sort; don't really want to do this, but it makes results more stable - if ($a['name'] < $b['name']) return -1; - if ($a['name'] > $b['name']) return 1; + if ($a['name'] < $b['name']) { return -1; + } + if ($a['name'] > $b['name']) { return 1; + } return 0; } @@ -241,10 +252,10 @@ class CRM_Core_Region { * HTML. * public function addMarkup($markup) { - return $this->add(array( - 'type' => 'markup', - 'markup' => $markup, - )); + return $this->add(array( + 'type' => 'markup', + 'markup' => $markup, + )); } /** @@ -256,10 +267,10 @@ class CRM_Core_Region { * Path to the Smarty template file. * public function addTemplate($template) { - return $this->add(array( - 'type' => 'template', - 'template' => $template, - )); + return $this->add(array( + 'type' => 'template', + 'template' => $template, + )); } /** @@ -270,11 +281,11 @@ class CRM_Core_Region { * Optional, array of parameters for callback; if omitted, the default arguments are ($snippetSpec, $html). * public function addCallback($callback, $arguments = FALSE) { - return $this->add(array( - 'type' => 'callback', - 'callback' => $callback, - 'arguments' => $arguments, - )); + return $this->add(array( + 'type' => 'callback', + 'callback' => $callback, + 'arguments' => $arguments, + )); } */ } diff --git a/CRM/Core/Report/Excel.php b/CRM/Core/Report/Excel.php index 5437970d17..a15077ef13 100644 --- a/CRM/Core/Report/Excel.php +++ b/CRM/Core/Report/Excel.php @@ -43,7 +43,7 @@ class CRM_Core_Report_Excel { * @param string $rows * (reference ) result set rows. * @param null $titleHeader - * @param boolean $print + * @param bool $printShould the output be printed. * Should the output be printed. * * @param bool $outputHeader diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 3e8de7b627..f21384b25e 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -260,9 +260,9 @@ class CRM_Core_Resources { $region = self::isAjaxMode() ? 'ajax-snippet' : 'html-header'; $resources = $this; CRM_Core_Region::instance($region)->add(array( - 'callback' => function(&$snippet, &$html) use ($resources) { - $html .= "\n" . $resources->renderSetting(); - }, + 'callback' => function(&$snippet, &$html) use ($resources) { + $html .= "\n" . $resources->renderSetting(); + }, 'weight' => -100000, )); $this->addedSettings = TRUE; @@ -532,7 +532,8 @@ class CRM_Core_Resources { $this->addScriptUrl(CRM_Utils_System::url('civicrm/ajax/l10n-js/' . $config->lcMessages, array('r' => $this->getCacheCode())), $jsWeight++, $region); // Add global settings - $settings = array('config' => array( + $settings = array( + 'config' => array( 'ajaxPopupsEnabled' => $this->ajaxPopupsEnabled, 'isFrontend' => $config->userFrameworkFrontend, )); @@ -735,7 +736,10 @@ class CRM_Core_Resources { $filters['event'] = array( array('key' => 'event_type_id', 'value' => ts('Event Type')), - array('key' => 'start_date', 'value' => ts('Start Date'), 'options' => array( + array( + 'key' => 'start_date', + 'value' => ts('Start Date'), + 'options' => array( array('key' => '{">":"now"}', 'value' => ts('Upcoming')), array('key' => '{"BETWEEN":["now - 3 month","now"]}', 'value' => ts('Past 3 Months')), array('key' => '{"BETWEEN":["now - 6 month","now"]}', 'value' => ts('Past 6 Months')), diff --git a/CRM/Core/ScheduledJob.php b/CRM/Core/ScheduledJob.php index 96a84f2e7b..fc96115de5 100644 --- a/CRM/Core/ScheduledJob.php +++ b/CRM/Core/ScheduledJob.php @@ -120,5 +120,6 @@ class CRM_Core_ScheduledJob { return FALSE; } - public function __destruct() {} + public function __destruct() { + } } diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 54a06e2f53..283143a069 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -96,7 +96,7 @@ class CRM_Core_SelectValues { * Membership type unit * @static */ - public static function membershipTypeUnitList( ) { + public static function membershipTypeUnitList() { return self::unitList('duration'); } @@ -355,7 +355,8 @@ class CRM_Core_SelectValues { * return array */ public static function mailingComponents() { - return array('Header' => ts('Header'), + return array( + 'Header' => ts('Header'), 'Footer' => ts('Footer'), 'Reply' => ts('Reply Auto-responder'), 'OptOut' => ts('Opt-out Message'), @@ -565,7 +566,8 @@ class CRM_Core_SelectValues { public static function contactTokens() { static $tokens = NULL; if (!$tokens) { - $additionalFields = array('checksum' => array('title' => ts('Checksum')), + $additionalFields = array( + 'checksum' => array('title' => ts('Checksum')), 'contact_id' => array('title' => ts('Internal Contact ID')), ); $exportFields = array_merge(CRM_Contact_BAO_Contact::exportableFields(), $additionalFields); @@ -696,7 +698,6 @@ class CRM_Core_SelectValues { gives proper result */ - return $dateInputFormats; } @@ -743,7 +744,7 @@ class CRM_Core_SelectValues { public static function getNumericOptions($start = 0, $end = 10) { $numericOptions = array(); for ($i = $start; $i <= $end; $i++) { - $numericOptions[$i] = $i; + $numericOptions[$i] = $i; } return $numericOptions; } @@ -808,7 +809,7 @@ class CRM_Core_SelectValues { * Extension types */ public static function getExtensionTypes() { - return array( + return array( 'payment' => ts('Payment'), 'search' => ts('Search'), 'report' => ts('Report'), diff --git a/CRM/Core/Selector/Controller.php b/CRM/Core/Selector/Controller.php index 52f819266e..8ba8865ccd 100644 --- a/CRM/Core/Selector/Controller.php +++ b/CRM/Core/Selector/Controller.php @@ -367,7 +367,6 @@ class CRM_Core_Selector_Controller { self::$_template->assign("{$this->_prefix}summary", $summary); } - // always store the current pageID and sortID $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ID, $this->_pager->getCurrentPageID() diff --git a/CRM/Core/Session.php b/CRM/Core/Session.php index 9661794026..a018d5636e 100644 --- a/CRM/Core/Session.php +++ b/CRM/Core/Session.php @@ -86,7 +86,7 @@ class CRM_Core_Session { * @return CRM_Core_Session */ public function __construct() { - $this->_session = null; + $this->_session = NULL; } /** @@ -125,7 +125,7 @@ class CRM_Core_Session { // FIXME: This belongs in CRM_Utils_System_* if ($config->userSystem->is_drupal && function_exists('drupal_session_start')) { // https://issues.civicrm.org/jira/browse/CRM-14356 - if (! (isset($GLOBALS['lazy_session']) && $GLOBALS['lazy_session'] == true)) { + if (! (isset($GLOBALS['lazy_session']) && $GLOBALS['lazy_session'] == TRUE)) { drupal_session_start(); } $_SESSION = array(); @@ -275,7 +275,7 @@ class CRM_Core_Session { $this->createScope($prefix, TRUE); if (empty($this->_session) || empty($this->_session[$this->_key])) { - return null; + return NULL; } if (empty($prefix)) { @@ -283,7 +283,7 @@ class CRM_Core_Session { } else { if (empty($this->_session[$this->_key][$prefix])) { - return null; + return NULL; } $session =& $this->_session[$this->_key][$prefix]; } @@ -343,7 +343,7 @@ class CRM_Core_Session { $this->set($name, time(), 'timer'); return $ts ? $ts : 'not set'; } - return false; + return FALSE; } /** diff --git a/CRM/Core/Smarty.php b/CRM/Core/Smarty.php index 1c31f5dd18..7c941d8cba 100644 --- a/CRM/Core/Smarty.php +++ b/CRM/Core/Smarty.php @@ -87,7 +87,7 @@ class CRM_Core_Smarty extends Smarty { parent::__construct(); } - private function initialize( ) { + private function initialize() { $config = CRM_Core_Config::singleton(); if (isset($config->customTemplateDir) && $config->customTemplateDir) { diff --git a/CRM/Core/Smarty/plugins/block.crmRegion.php b/CRM/Core/Smarty/plugins/block.crmRegion.php index f6ecb0c34e..4f185d7fb7 100644 --- a/CRM/Core/Smarty/plugins/block.crmRegion.php +++ b/CRM/Core/Smarty/plugins/block.crmRegion.php @@ -18,7 +18,8 @@ */ function smarty_block_crmRegion($params, $content, &$smarty, &$repeat) { - if ($repeat) return; + if ($repeat) { return; + } require_once 'CRM/Core/Region.php'; $region = CRM_Core_Region::instance($params['name'], FALSE); if ($region) { diff --git a/CRM/Core/Smarty/plugins/function.crmResURL.php b/CRM/Core/Smarty/plugins/function.crmResURL.php index 3c3cf38803..dfeae38457 100644 --- a/CRM/Core/Smarty/plugins/function.crmResURL.php +++ b/CRM/Core/Smarty/plugins/function.crmResURL.php @@ -49,5 +49,5 @@ function smarty_function_crmResURL($params, &$smarty) { if (!array_key_exists('file', $params)) { $params['file'] = NULL; } - return $res->getUrl($params['ext'], $params['file'], $params['addCacheCode']); + return $res->getUrl($params['ext'], $params['file'], $params['addCacheCode']); } diff --git a/CRM/Core/Smarty/plugins/function.sectionTotal.php b/CRM/Core/Smarty/plugins/function.sectionTotal.php index db58a038c8..89065a3427 100644 --- a/CRM/Core/Smarty/plugins/function.sectionTotal.php +++ b/CRM/Core/Smarty/plugins/function.sectionTotal.php @@ -75,7 +75,6 @@ function smarty_function_sectionTotal($params, &$smarty) { // concatenate with pipes to build the right key $totalsKey = implode(CRM_Core_DAO::VALUE_SEPARATOR, $sectionValues); - // return the corresponding total return $smarty->_tpl_vars['sectionTotals'][$totalsKey]; } diff --git a/CRM/Core/Smarty/plugins/modifier.mb_truncate.php b/CRM/Core/Smarty/plugins/modifier.mb_truncate.php index 43e75d8d9f..05ec0a4166 100644 --- a/CRM/Core/Smarty/plugins/modifier.mb_truncate.php +++ b/CRM/Core/Smarty/plugins/modifier.mb_truncate.php @@ -84,7 +84,8 @@ function smarty_modifier_mb_truncate($string, $length = 80, $etc = '...', return $substr($string, 0, $length) . $etc; } - else return $string; + else { return $string; + } } /* vim: set expandtab: */ diff --git a/CRM/Core/Smarty/resources/String.php b/CRM/Core/Smarty/resources/String.php index 2e570ea9b4..efa177eaa8 100644 --- a/CRM/Core/Smarty/resources/String.php +++ b/CRM/Core/Smarty/resources/String.php @@ -63,7 +63,9 @@ function civicrm_smarty_resource_string_get_secure($tpl_name, &$smarty_obj) { * @param string $tpl_name * @param $smarty_obj */ -function civicrm_smarty_resource_string_get_trusted($tpl_name, &$smarty_obj) {} +function civicrm_smarty_resource_string_get_trusted($tpl_name, &$smarty_obj) { + +} function civicrm_smarty_register_string_resource() { $template = CRM_Core_Smarty::singleton(); diff --git a/CRM/Core/StateMachine.php b/CRM/Core/StateMachine.php index 9c95648647..3e7f7f92ff 100644 --- a/CRM/Core/StateMachine.php +++ b/CRM/Core/StateMachine.php @@ -225,8 +225,8 @@ class CRM_Core_StateMachine { */ public function &getState($name) { if (isset($this->_states[$name])) { - return $this->_states[$name]; - } + return $this->_states[$name]; + } /* * This is a gross hack for ajax driven requests where @@ -239,7 +239,7 @@ class CRM_Core_StateMachine { } } - return null; + return NULL; } /** @@ -395,6 +395,6 @@ class CRM_Core_StateMachine { */ public function shouldReset() { return TRUE; -} + } } diff --git a/CRM/Core/TemporaryErrorScope.php b/CRM/Core/TemporaryErrorScope.php index eaf744a1ac..6ab382b1d0 100644 --- a/CRM/Core/TemporaryErrorScope.php +++ b/CRM/Core/TemporaryErrorScope.php @@ -72,7 +72,7 @@ class CRM_Core_TemporaryErrorScope { public static function getActive() { return array( '_PEAR_default_error_mode' => $GLOBALS['_PEAR_default_error_mode'], - '_PEAR_default_error_options' =>$GLOBALS['_PEAR_default_error_options'], + '_PEAR_default_error_options' => $GLOBALS['_PEAR_default_error_options'], 'modeException' => CRM_Core_Error::$modeException, ); } diff --git a/CRM/Core/Transaction.php b/CRM/Core/Transaction.php index 075859e855..91dece866f 100644 --- a/CRM/Core/Transaction.php +++ b/CRM/Core/Transaction.php @@ -245,7 +245,7 @@ class CRM_Core_Transaction { * See php manual call_user_func_array for details. * @param int $id */ - static public function addCallback($phase, $callback, $params = null, $id = NULL) { + static public function addCallback($phase, $callback, $params = NULL, $id = NULL) { $frame = \Civi\Core\Transaction\Manager::singleton()->getBaseFrame(); $frame->addCallback($phase, $callback, $params, $id); }