CRM-15988 - Cleanup internal use of entity names
[civicrm-core.git] / CRM / Core / Key.php
index 8e430822e215cfaa3c357cc485c7a1430e85bc80..88b60d02d25a922edc5ba62133a88fd1b56a74d9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -38,13 +38,12 @@ class CRM_Core_Key {
   static $_sessionID = NULL;
 
   /**
-   * Generate a private key per session and store in session
+   * Generate a private key per session and store in session.
    *
-   * @return string private key for this session
-   * @static
-   * @access private
+   * @return string
+   *   private key for this session
    */
-  static function privateKey() {
+  public static function privateKey() {
     if (!self::$_key) {
       $session = CRM_Core_Session::singleton();
       self::$_key = $session->get('qfPrivateKey');
@@ -59,7 +58,7 @@ class CRM_Core_Key {
   /**
    * @return mixed|null|string
    */
-  static function sessionID() {
+  public static function sessionID() {
     if (!self::$_sessionID) {
       $session = CRM_Core_Session::singleton();
       self::$_sessionID = $session->get('qfSessionID');
@@ -76,16 +75,16 @@ class CRM_Core_Key {
    * and a private key. Modelled after drupal's form API
    *
    * @param string $name
-   * @param bool $addSequence should we add a unique sequence number to the end of the key
+   * @param bool $addSequence
+   *   Should we add a unique sequence number to the end of the key.
    *
-   * @return string       valid formID
-   * @static
-   * @access public
+   * @return string
+   *   valid formID
    */
-  static function get($name, $addSequence = FALSE) {
+  public static function get($name, $addSequence = FALSE) {
     $privateKey = self::privateKey();
-    $sessionID  = self::sessionID();
-    $key        = md5($sessionID . $name . $privateKey);
+    $sessionID = self::sessionID();
+    $key = md5($sessionID . $name . $privateKey);
 
     if ($addSequence) {
       // now generate a random number between 1 and 100K and add it to the key
@@ -96,17 +95,16 @@ class CRM_Core_Key {
   }
 
   /**
-   * Validate a form key based on the form name
+   * Validate a form key based on the form name.
    *
    * @param string $key
    * @param string $name
    * @param bool $addSequence
    *
-   * @return string $formKey if valid, else null
-   * @static
-   * @access public
+   * @return string
+   *   if valid, else null
    */
-  static function validate($key, $name, $addSequence = FALSE) {
+  public static function validate($key, $name, $addSequence = FALSE) {
     if (!is_string($key)) {
       return NULL;
     }
@@ -134,7 +132,7 @@ class CRM_Core_Key {
    *
    * @return bool
    */
-  static function valid($key) {
+  public static function valid($key) {
     // a valid key is a 32 digit hex number
     // followed by an optional _ and a number between 1 and 10000
     if (strpos('_', $key) !== FALSE) {
@@ -155,5 +153,5 @@ class CRM_Core_Key {
     // ensure that hash is a 32 digit hex number
     return preg_match('#[0-9a-f]{32}#i', $hash) ? TRUE : FALSE;
   }
-}
 
+}