Skip to content

Commit

Permalink
Merge pull request #17196 from eileenmcnaughton/session
Browse files Browse the repository at this point in the history
[REF] Cleanup a few instances where we use old call to get loggedInUserID
  • Loading branch information
seamuslee001 authored May 1, 2020
2 parents 5386882 + f0c3f9b commit ca492fb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
11 changes: 5 additions & 6 deletions CRM/Case/BAO/Case.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public static function getCases($allCases = TRUE, $params = [], $context = 'dash
}

$type = CRM_Utils_Array::value('type', $params, 'upcoming');
$userID = CRM_Core_Session::singleton()->get('userID');
$userID = CRM_Core_Session::getLoggedInContactID();

// validate access for all cases.
if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) {
Expand Down Expand Up @@ -670,7 +670,7 @@ public static function getCasesSummary($allCases = TRUE) {
return $caseSummary;
}

$userID = CRM_Core_Session::singleton()->get('userID');
$userID = CRM_Core_Session::getLoggedInContactID();

//validate access for all cases.
if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) {
Expand Down Expand Up @@ -1269,9 +1269,9 @@ public static function sendActivityCopy($clientId, $activityId, $contacts, $atta
break;
}
}
$session = CRM_Core_Session::singleton();

// CRM-8926 If user is not logged in, use the activity creator as userID
if (!($userID = $session->get('userID'))) {
if (!($userID = CRM_Core_Session::getLoggedInContactID())) {
$userID = CRM_Activity_BAO_Activity::getSourceContactID($activityId);
}

Expand Down Expand Up @@ -1403,8 +1403,7 @@ public static function getCaseActivityCount($caseId, $activityTypeId) {
*
*/
public static function getNextScheduledActivity($cases, $type = 'upcoming') {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$userID = CRM_Core_Session::getLoggedInContactID();

$caseID = implode(',', $cases['case_id']);
$contactID = implode(',', $cases['contact_id']);
Expand Down
14 changes: 8 additions & 6 deletions CRM/Financial/Form/FinancialBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function preProcess() {
$this->set("context", $context);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
parent::preProcess();
$session = CRM_Core_Session::singleton();

if ($this->_id) {
$permissions = [
CRM_Core_Action::UPDATE => [
Expand All @@ -49,7 +49,7 @@ public function preProcess() {

$createdID = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $this->_id, 'created_id');
if (!empty($permissions[$this->_action])) {
$this->checkPermissions($this->_action, $permissions[$this->_action]['permission'], $createdID, $session->get('userID'), $permissions[$this->_action]['actionName']);
$this->checkPermissions($this->_action, $permissions[$this->_action]['permission'], $createdID, CRM_Core_Session::getLoggedInContactID(), $permissions[$this->_action]['actionName']);
}
}
}
Expand Down Expand Up @@ -169,6 +169,8 @@ public static function formRule($values, $files, $self) {

/**
* Process the form submission.
*
* @throws \CRM_Core_Exception
*/
public function postProcess() {
$session = CRM_Core_Session::singleton();
Expand All @@ -180,7 +182,7 @@ public function postProcess() {

// store the submitted values in an array
$params['modified_date'] = date('YmdHis');
$params['modified_id'] = $session->get('userID');
$params['modified_id'] = CRM_Core_Session::getLoggedInContactID();
if (!empty($params['created_date'])) {
$params['created_date'] = CRM_Utils_Date::processDate($params['created_date']);
}
Expand All @@ -190,7 +192,7 @@ public function postProcess() {
$params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Open');
$params['created_date'] = date('YmdHis');
if (empty($params['created_id'])) {
$params['created_id'] = $session->get('userID');
$params['created_id'] = CRM_Core_Session::getLoggedInContactID();
}
$details = "{$params['title']} batch has been created by this contact.";
$activityTypeName = 'Create Batch';
Expand Down Expand Up @@ -218,8 +220,8 @@ public function postProcess() {
'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_DAO_Activity', 'activity_status_id', 'Completed'),
'priority_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_DAO_Activity', 'priority_id', 'Normal'),
'activity_date_time' => date('YmdHis'),
'source_contact_id' => $session->get('userID'),
'source_contact_qid' => $session->get('userID'),
'source_contact_id' => CRM_Core_Session::getLoggedInContactID(),
'source_contact_qid' => CRM_Core_Session::getLoggedInContactID(),
'details' => $details,
];

Expand Down
2 changes: 1 addition & 1 deletion CRM/PCP/Form/PCPAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function preProcess() {
$contactID = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $this->_id, 'contact_id');
}

$this->_contactID = $contactID ?? $session->get('userID');
$this->_contactID = $contactID ?? CRM_Core_Session::getLoggedInContactID();
if (!$this->_pageId) {
if (!$this->_id) {
$msg = ts('We can\'t load the requested web page due to an incomplete link. This can be caused by using your browser\'s Back button or by using an incomplete or invalid link.');
Expand Down
8 changes: 4 additions & 4 deletions CRM/Report/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,7 @@ public function where($recordType = NULL) {
1
) {
// get current user
$session = CRM_Core_Session::singleton();
if ($contactID = $session->get('userID')) {
if ($contactID = CRM_Core_Session::getLoggedInContactID()) {
$clause = "{$this->_aliases['civicrm_activity_contact']}.activity_id IN
(SELECT activity_id FROM civicrm_activity_contact WHERE contact_id = {$contactID})";
}
Expand Down Expand Up @@ -609,6 +608,8 @@ public function groupBy() {
* Build ACL clause.
*
* @param string $tableAlias
*
* @throws \CRM_Core_Exception
*/
public function buildACLClause($tableAlias = 'contact_a') {
//override for ACL( Since Contact may be source
Expand All @@ -619,8 +620,7 @@ public function buildACLClause($tableAlias = 'contact_a') {
return;
}

$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
$contactID = CRM_Core_Session::getLoggedInContactID();
if (!$contactID) {
$contactID = 0;
}
Expand Down

0 comments on commit ca492fb

Please sign in to comment.