diff --git a/CRM/Contact/Page/View/UserDashBoard.php b/CRM/Contact/Page/View/UserDashBoard.php index 83d501720fb1..dcadcc71ef47 100644 --- a/CRM/Contact/Page/View/UserDashBoard.php +++ b/CRM/Contact/Page/View/UserDashBoard.php @@ -50,17 +50,12 @@ public function __construct() { $userID = CRM_Core_Session::getLoggedInContactID(); $userChecksum = $this->getUserChecksum(); - $validUser = FALSE; - if ($userChecksum) { - $this->assign('userChecksum', $userChecksum); - $validUser = CRM_Contact_BAO_Contact_Utils::validChecksum($this->_contactId, $userChecksum); - $this->_isChecksumUser = $validUser; - } + $this->assign('userChecksum', $userChecksum); if (!$this->_contactId) { $this->_contactId = $userID; } - elseif ($this->_contactId != $userID && !$validUser) { + elseif ($this->_contactId != $userID && !$userChecksum) { if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::VIEW)) { CRM_Core_Error::statusBounce(ts('You do not have permission to access this contact.')); } @@ -95,6 +90,8 @@ public function preProcess() { /** * Build user dashboard. + * + * @throws \CRM_Core_Exception */ public function buildUserDashBoard() { //build component selectors @@ -157,7 +154,7 @@ public function buildUserDashBoard() { $this->assign('pcpInfo', $pcpInfo); } - if (!empty($dashboardOptions['Assigned Activities']) && empty($this->_isChecksumUser)) { + if (!empty($dashboardOptions['Assigned Activities']) && !$this->getUserChecksum()) { // Assigned Activities section $dashboardElements[] = [ 'class' => 'crm-dashboard-assignedActivities', @@ -249,11 +246,12 @@ public static function &links() { /** * Get the user checksum from the url to use in links. * - * @return string + * @return string|false + * @throws \CRM_Core_Exception */ protected function getUserChecksum() { $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this); - if (empty($userID) && $this->_contactId) { + if ($this->_contactId && CRM_Contact_BAO_Contact_Utils::validChecksum($this->_contactId, $userChecksum)) { return $userChecksum; } return FALSE;