[NFC] Extract getUserCheckSum function
[civicrm-core.git] / CRM / Contact / Page / View / UserDashBoard.php
index 2cc99577e1cc6af3dc2254fc33b2997aa464e4c1..a3fb8807de4d8a3e2927354e6035e6510c193979 100644 (file)
@@ -69,9 +69,9 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
     $session = CRM_Core_Session::singleton();
     $userID = $session->get('userID');
 
-    $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this);
+    $userChecksum = $this->getUserChecksum();
     $validUser = FALSE;
-    if (empty($userID) && $this->_contactId && $userChecksum) {
+    if ($userChecksum) {
       $this->assign('userChecksum', $userChecksum);
       $validUser = CRM_Contact_BAO_Contact_Utils::validChecksum($this->_contactId, $userChecksum);
       $this->_isChecksumUser = $validUser;
@@ -256,4 +256,17 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
     return self::$_links;
   }
 
+  /**
+   * Get the user checksum from the url to use in links.
+   *
+   * @return string
+   */
+  protected function getUserChecksum() {
+    $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this);
+    if (empty($userID) && $this->_contactId) {
+      return $userChecksum;
+    }
+    return FALSE;
+  }
+
 }