From e8f1483104bee719c5522febf6d4add7a9e888be Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Mon, 16 Sep 2013 17:58:26 +0530 Subject: [PATCH] CRM-10128 --- CRM/Contact/BAO/Contact/Permission.php | 6 +++--- CRM/Core/BAO/UFMatch.php | 6 ------ CRM/Core/Config.php | 14 ++++++++++++++ CRM/Core/Permission.php | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CRM/Contact/BAO/Contact/Permission.php b/CRM/Contact/BAO/Contact/Permission.php index 94b43b350f..0f80d5208f 100644 --- a/CRM/Contact/BAO/Contact/Permission.php +++ b/CRM/Contact/BAO/Contact/Permission.php @@ -344,7 +344,7 @@ WHERE (( contact_id_a = %1 AND contact_id_b = %2 AND is_permission_a_b = 1 ) OR } // set appropriate AUTH source - self::toggleChecksumAuthSrc(TRUE); + self::initChecksumAuthSrc(TRUE, $form); // so here the contact is posing as $contactID, lets set the logging contact ID variable // CRM-8965 @@ -355,9 +355,9 @@ WHERE (( contact_id_a = %1 AND contact_id_b = %2 AND is_permission_a_b = 1 ) OR return TRUE; } - static function toggleChecksumAuthSrc($checkSumValidationResult = FALSE) { + static function initChecksumAuthSrc($checkSumValidationResult = FALSE, $form = NULL) { $session = CRM_Core_Session::singleton(); - if ($checkSumValidationResult && CRM_Utils_Request::retrieve('cs', 'String', $form, FALSE)) { + if ($checkSumValidationResult && $form && CRM_Utils_Request::retrieve('cs', 'String', $form, FALSE)) { // if result is already validated, and url has cs, set the flag. $session->set('authSrc', CRM_Core_Permission::AUTH_SRC_CHECKSUM); } else if (($session->get('authSrc') & CRM_Core_Permission::AUTH_SRC_CHECKSUM) == CRM_Core_Permission::AUTH_SRC_CHECKSUM) { diff --git a/CRM/Core/BAO/UFMatch.php b/CRM/Core/BAO/UFMatch.php index 2b3433de9a..18fe4dfdab 100644 --- a/CRM/Core/BAO/UFMatch.php +++ b/CRM/Core/BAO/UFMatch.php @@ -124,9 +124,6 @@ class CRM_Core_BAO_UFMatch extends CRM_Core_DAO_UFMatch { $session->set('ufID', CRM_Utils_Array::value('uf_id', $userIds, '')); $session->set('userID', CRM_Utils_Array::value('contact_id', $userIds, '')); $session->set('ufUniqID', CRM_Utils_Array::value('uf_name', $userIds, '')); - if (CRM_Utils_Array::value('contact_id', $userIds, FALSE)) { - $session->set('authSrc', CRM_Core_Permission::AUTH_SRC_LOGIN); - } } } @@ -163,9 +160,6 @@ class CRM_Core_BAO_UFMatch extends CRM_Core_DAO_UFMatch { $session->set('ufID', $ufID); $session->set('userID', $userID); $session->set('ufUniqID', $ufUniqID); - if ($userID) { - $session->set('authSrc', CRM_Core_Permission::AUTH_SRC_LOGIN); - } // add current contact to recently viewed if ($ufmatch->contact_id) { diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index 459faf8370..377cec0afe 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -242,6 +242,9 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { array(1 => array($userID, 'Integer')) ); } + + // initialize authentication source + self::$_singleton->initAuthSrc(); } return self::$_singleton; } @@ -652,6 +655,17 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { CRM_Core_DAO::executeQuery($query); } + // This method should initialize auth sources + function initAuthSrc() { + $session = CRM_Core_Session::singleton(); + if ($session->get('userID') && !$session->get('authSrc')) { + $session->set('authSrc', CRM_Core_Permission::AUTH_SRC_LOGIN); + } + + // checksum source + CRM_Contact_BAO_Contact_Permission::initChecksumAuthSrc(); + } + /** * one function to get domain ID */ diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index a20517476a..78a47d87f4 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -68,7 +68,7 @@ class CRM_Core_Permission { * * @var int */ - CONST AUTH_SRC_UNKNOWN = 1, AUTH_SRC_CHECKSUM = 2, AUTH_SRC_SITEKEY = 4, AUTH_SRC_LOGIN = 8; + CONST AUTH_SRC_UNKNOWN = 0, AUTH_SRC_CHECKSUM = 1, AUTH_SRC_SITEKEY = 2, AUTH_SRC_LOGIN = 4; /** * get the current permission of this user -- 2.25.1