From 3bdcd4ec1d5b00a96dc1bc1f76e19a491a2996b0 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 12 Oct 2016 14:23:23 -0400 Subject: [PATCH] CRM-19028 - Change get(userID) to getLoggedInContactID() --- CRM/ACL/API.php | 6 ++---- CRM/ACL/BAO/ACL.php | 3 +-- CRM/Activity/BAO/Activity.php | 16 +++++----------- CRM/Activity/BAO/ICalendar.php | 3 +-- CRM/Activity/Form/Activity.php | 2 +- CRM/Activity/Form/ActivityFilter.php | 3 +-- CRM/Contact/Page/DashBoard.php | 3 +-- CRM/Core/BAO/Dashboard.php | 4 ++-- CRM/Core/Session.php | 2 +- CRM/Dedupe/Finder.php | 2 +- CRM/Event/BAO/Event.php | 3 +-- CRM/Mailing/Page/View.php | 2 +- CRM/Report/Form/Instance.php | 2 +- 13 files changed, 19 insertions(+), 32 deletions(-) diff --git a/CRM/ACL/API.php b/CRM/ACL/API.php index 3d0c090dc9..113bcce0e9 100644 --- a/CRM/ACL/API.php +++ b/CRM/ACL/API.php @@ -57,8 +57,7 @@ class CRM_ACL_API { */ public static function check($str, $contactID = NULL) { if ($contactID == NULL) { - $session = CRM_Core_Session::singleton(); - $contactID = $session->get('userID'); + $contactID = CRM_Core_Session::getLoggedInContactID(); } if (!$contactID) { @@ -164,8 +163,7 @@ class CRM_ACL_API { $includedGroups = NULL ) { if ($contactID == NULL) { - $session = CRM_Core_Session::singleton(); - $contactID = $session->get('userID'); + $contactID = CRM_Core_Session::getLoggedInContactID(); } if (!$contactID) { diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 54962f9cfa..e3002f65f5 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -126,8 +126,7 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { 'GroupContact' => CRM_Contact_DAO_GroupContact::getTableName(), ); - $session = CRM_Core_Session::singleton(); - $contact_id = $session->get('userID'); + $contact_id = CRM_Core_Session::getLoggedInContactID(); $where = " {$t['ACL']}.operation = '" . CRM_Utils_Type::escape($operation, 'String') . "'"; diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 35cd6d52db..6d892bf809 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -625,8 +625,7 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { * @return bool */ public static function logActivityAction($activity, $logMessage = NULL) { - $session = CRM_Core_Session::singleton(); - $id = $session->get('userID'); + $id = CRM_Core_Session::getLoggedInContactID(); if (!$id) { $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); @@ -1194,8 +1193,7 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND ) { // get the contact details of logged in contact, which we set as from email if ($userID == NULL) { - $session = CRM_Core_Session::singleton(); - $userID = $session->get('userID'); + $userID = CRM_Core_Session::getLoggedInContactID(); } list($fromDisplayName, $fromEmail, $fromDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID); @@ -1381,8 +1379,7 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND $userID = NULL ) { if ($userID == NULL) { - $session = CRM_Core_Session::singleton(); - $userID = $session->get('userID'); + $userID = CRM_Core_Session::getLoggedInContactID(); } $text = &$activityParams['sms_text_message']; @@ -1881,8 +1878,7 @@ SELECT display_name $activityParams['id'] = $activity->activity_id; } // create activity with target contacts - $session = CRM_Core_Session::singleton(); - $id = $session->get('userID'); + $id = CRM_Core_Session::getLoggedInContactID(); if ($id) { $activityParams['source_contact_id'] = $id; $activityParams['target_contact_id'][] = $activity->contact_id; @@ -2069,11 +2065,9 @@ AND cl.modified_id = c.id return NULL; } - $session = CRM_Core_Session::singleton(); - $followupParams = array(); $followupParams['parent_id'] = $activityId; - $followupParams['source_contact_id'] = $session->get('userID'); + $followupParams['source_contact_id'] = CRM_Core_Session::getLoggedInContactID(); $followupParams['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name'); $followupParams['activity_type_id'] = $params['followup_activity_type_id']; diff --git a/CRM/Activity/BAO/ICalendar.php b/CRM/Activity/BAO/ICalendar.php index 7ccdf0bffd..128803bc8c 100644 --- a/CRM/Activity/BAO/ICalendar.php +++ b/CRM/Activity/BAO/ICalendar.php @@ -115,8 +115,7 @@ class CRM_Activity_BAO_ICalendar { * @return string */ private function getPrimaryEmail() { - $session = &CRM_Core_Session::singleton(); - $uid = $session->get('userID'); + $uid = CRM_Core_Session::getLoggedInContactID(); $primary = ''; $emails = CRM_Core_BAO_Email::allEmails($uid); foreach ($emails as $eid => $e) { diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 9100fc80f2..5d2d1fd8a4 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -228,7 +228,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { } $session = CRM_Core_Session::singleton(); - $this->_currentUserId = $session->get('userID'); + $this->_currentUserId = CRM_Core_Session::getLoggedInContactID(); $this->_currentlyViewedContactId = $this->get('contactId'); if (!$this->_currentlyViewedContactId) { diff --git a/CRM/Activity/Form/ActivityFilter.php b/CRM/Activity/Form/ActivityFilter.php index 19b19acdc6..6718e53f1c 100644 --- a/CRM/Activity/Form/ActivityFilter.php +++ b/CRM/Activity/Form/ActivityFilter.php @@ -57,8 +57,7 @@ class CRM_Activity_Form_ActivityFilter extends CRM_Core_Form { public function setDefaultValues() { // CRM-11761 retrieve user's activity filter preferences $defaults = array(); - $session = CRM_Core_Session::singleton(); - $userID = $session->get('userID'); + $userID = CRM_Core_Session::getLoggedInContactID(); if ($userID) { $defaults = Civi::service('settings_manager') ->getBagByContact(NULL, $userID) diff --git a/CRM/Contact/Page/DashBoard.php b/CRM/Contact/Page/DashBoard.php index 3f5f09a2e6..3b3d4d6cb9 100644 --- a/CRM/Contact/Page/DashBoard.php +++ b/CRM/Contact/Page/DashBoard.php @@ -47,8 +47,7 @@ class CRM_Contact_Page_DashBoard extends CRM_Core_Page { $this->assign('contactDashlets', CRM_Core_BAO_Dashboard::getContactDashletsForJS()); CRM_Utils_System::setTitle(ts('CiviCRM Home')); - $session = CRM_Core_Session::singleton(); - $contactID = $session->get('userID'); + $contactID = CRM_Core_Session::getLoggedInContactID(); // call hook to get html from other modules // ignored but needed to prevent warnings diff --git a/CRM/Core/BAO/Dashboard.php b/CRM/Core/BAO/Dashboard.php index d64620e3f6..91e560c6c7 100644 --- a/CRM/Core/BAO/Dashboard.php +++ b/CRM/Core/BAO/Dashboard.php @@ -100,7 +100,7 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { * array of dashlets */ public static function getContactDashlets($contactID = NULL) { - $contactID = $contactID ? $contactID : CRM_Core_Session::singleton()->getLoggedInContactID(); + $contactID = $contactID ? $contactID : CRM_Core_Session::getLoggedInContactID(); $dashlets = array(); // Get contact dashboard dashlets. @@ -184,7 +184,7 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { 'domain_id' => CRM_Core_Config::domainID(), 'option.limit' => 0, )); - $contactID = CRM_Core_Session::singleton()->getLoggedInContactID(); + $contactID = CRM_Core_Session::getLoggedInContactID(); $allDashlets = CRM_Utils_Array::index(array('name'), $getDashlets['values']); $defaultDashlets = array(); $defaults = array('blog' => 1, 'getting-started' => '0'); diff --git a/CRM/Core/Session.php b/CRM/Core/Session.php index 0cc4155290..56e6eee152 100644 --- a/CRM/Core/Session.php +++ b/CRM/Core/Session.php @@ -554,7 +554,7 @@ class CRM_Core_Session { * @throws CiviCRM_API3_Exception */ public function getLoggedInContactDisplayName() { - $userContactID = CRM_Core_Session::singleton()->getLoggedInContactID(); + $userContactID = CRM_Core_Session::getLoggedInContactID(); if (!$userContactID) { return ''; } diff --git a/CRM/Dedupe/Finder.php b/CRM/Dedupe/Finder.php index d020bb1480..b99d9b8396 100644 --- a/CRM/Dedupe/Finder.php +++ b/CRM/Dedupe/Finder.php @@ -379,7 +379,7 @@ class CRM_Dedupe_Finder { $displayNames[$dao->id] = $dao->display_name; } - $userId = CRM_Core_Session::singleton()->getLoggedInContactID(); + $userId = CRM_Core_Session::getLoggedInContactID(); foreach ($foundDupes as $dupes) { $srcID = $dupes[1]; $dstID = $dupes[0]; diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 7fc34e205a..c955de51bf 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -146,8 +146,7 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event { return $event; } - $session = CRM_Core_Session::singleton(); - $contactId = $session->get('userID'); + $contactId = CRM_Core_Session::getLoggedInContactID(); if (!$contactId) { $contactId = CRM_Utils_Array::value('contact_id', $params); } diff --git a/CRM/Mailing/Page/View.php b/CRM/Mailing/Page/View.php index 7fb43dd984..499907e5cb 100644 --- a/CRM/Mailing/Page/View.php +++ b/CRM/Mailing/Page/View.php @@ -97,7 +97,7 @@ class CRM_Mailing_Page_View extends CRM_Core_Page { $this->_contactID = $contactID; } else { - $this->_contactID = CRM_Core_Session::singleton()->getLoggedInContactID(); + $this->_contactID = CRM_Core_Session::getLoggedInContactID(); } // mailing key check diff --git a/CRM/Report/Form/Instance.php b/CRM/Report/Form/Instance.php index b726dfaf3c..3d76c10641 100644 --- a/CRM/Report/Form/Instance.php +++ b/CRM/Report/Form/Instance.php @@ -368,7 +368,7 @@ class CRM_Report_Form_Instance { // CRM-17310 my reports functionality - we should set owner if the checkbox is 1, // it seems to be not set at all if unchecked. if (!empty($formValues['add_to_my_reports'])) { - $params['owner_id'] = CRM_Core_Session::singleton()->getLoggedInContactID(); + $params['owner_id'] = CRM_Core_Session::getLoggedInContactID(); } else { $params['owner_id'] = 'null'; -- 2.25.1