Merge pull request #5760 from sudhabisht/SMSissue
[civicrm-core.git] / CRM / Core / Controller.php
index 0e4ff0261137d08bb402fc60c3bfa3ee5fa6cd75..2173882c911031a7444e3466e7e6a4156405fef7 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  * This class acts as our base controller class and adds additional
@@ -38,7 +38,7 @@
  * for other useful tips and suggestions
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -52,28 +52,28 @@ require_once 'HTML/QuickForm/Action/Direct.php';
 class CRM_Core_Controller extends HTML_QuickForm_Controller {
 
   /**
-   * The title associated with this controller
+   * The title associated with this controller.
    *
    * @var string
    */
   protected $_title;
 
   /**
-   * The key associated with this controller
+   * The key associated with this controller.
    *
    * @var string
    */
   public $_key;
 
   /**
-   * The name of the session scope where values are stored
+   * The name of the session scope where values are stored.
    *
    * @var object
    */
   protected $_scope;
 
   /**
-   * The state machine associated with this controller
+   * The state machine associated with this controller.
    *
    * @var object
    */
@@ -116,35 +116,35 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   public $_generateQFKey = TRUE;
 
   /**
-   * QF response type
+   * QF response type.
    *
    * @var string
    */
   public $_QFResponseType = 'html';
 
   /**
-   * Cache the smarty template for efficiency reasons
+   * Cache the smarty template for efficiency reasons.
    *
    * @var CRM_Core_Smarty
    */
   static protected $_template;
 
   /**
-   * Cache the session for efficiency reasons
+   * Cache the session for efficiency reasons.
    *
    * @var CRM_Core_Session
    */
   static protected $_session;
 
   /**
-   * The parent of this form if embedded
+   * The parent of this form if embedded.
    *
    * @var object
    */
   protected $_parent = NULL;
 
   /**
-   * The destination if set will override the destination the code wants to send it to
+   * The destination if set will override the destination the code wants to send it to.
    *
    * @var string;
    */
@@ -172,10 +172,8 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
    *   Should we add a unique sequence number to the end of the key.
    * @param bool $ignoreKey
    *   Should we not set a qfKey for this controller (for standalone forms).
-   *
-   * @internal param bool $whether controller is modal
    */
-  function __construct(
+  public function __construct(
     $title = NULL,
     $modal = TRUE,
     $mode = NULL,
@@ -195,8 +193,8 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     // lets try to get it from the session and/or the request vars
     // we do this early on in case there is a fatal error in retrieving the
     // key and/or session
-    $this->_entryURL =
-      CRM_Utils_Request::retrieve('entryURL', 'String', $this);
+    $this->_entryURL
+      CRM_Utils_Request::retrieve('entryURL', 'String', $this);
 
     // add a unique validable key to the name
     $name = CRM_Utils_System::getClassName($this);
@@ -205,7 +203,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
       // definitely different for different forms
       $name = $scope;
     }
-    $name         = $name . '_' . $this->key($name, $addSequence, $ignoreKey);
+    $name = $name . '_' . $this->key($name, $addSequence, $ignoreKey);
     $this->_title = $title;
     if ($scope) {
       $this->_scope = $scope;
@@ -220,8 +218,8 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     if (!empty($this->_key)) {
       CRM_Core_Session::registerAndRetrieveSessionObjects(array(
         "_{$name}_container",
-          array('CiviCRM', $this->_scope),
-        ));
+        array('CiviCRM', $this->_scope),
+      ));
     }
 
     $this->HTML_QuickForm_Controller($name, $modal);
@@ -280,7 +278,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
 
   public function fini() {
     CRM_Core_BAO_Cache::storeSessionToCache(array(
-      "_{$this->_name}_container",
+        "_{$this->_name}_container",
         array('CiviCRM', $this->_scope),
       ),
       TRUE
@@ -381,12 +379,11 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
    * Helper function to add all the needed default actions. Note that the framework
    * redefines all of the default QFC actions
    *
-   * @param string directory to store all the uploaded files
-   * @param array names for the various upload buttons (note u can have more than 1 upload)
+   * @param string $uploadDirectory to store all the uploaded files
+   * @param array $uploadNames for the various upload buttons (note u can have more than 1 upload)
    *
    *
    * @return void
-   *
    */
   public function addActions($uploadDirectory = NULL, $uploadNames = NULL) {
     $names = array(
@@ -411,7 +408,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Getter method for stateMachine
+   * Getter method for stateMachine.
    *
    * @return CRM_Core_StateMachine
    */
@@ -420,7 +417,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Setter method for stateMachine
+   * Setter method for stateMachine.
    *
    * @param CRM_Core_StateMachine $stateMachine
    *
@@ -436,7 +433,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
    *
    * @param CRM_Core_StateMachine $stateMachine
    * @param \const|int $action the mode in which the state machine is operating
-   *                              typicaly this will be add/view/edit
+   *                              typically this will be add/view/edit
    *
    * @return void
    */
@@ -444,8 +441,8 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
     $pages = $stateMachine->getPages();
     foreach ($pages as $name => $value) {
       $className = CRM_Utils_Array::value('className', $value, $name);
-      $title     = CRM_Utils_Array::value('title', $value);
-      $options   = CRM_Utils_Array::value('options', $value);
+      $title = CRM_Utils_Array::value('title', $value);
+      $options = CRM_Utils_Array::value('options', $value);
       $stateName = CRM_Utils_String::getClassName($className);
       if (!empty($value['className'])) {
         $formName = $name;
@@ -486,7 +483,8 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
    * we have two submit buttons, we could have one displayed as a button and
    * the other as an image, both are of type 'submit'.
    *
-   * @return string the name of the button that has been pressed by the user
+   * @return string
+   *   the name of the button that has been pressed by the user
    */
   public function getButtonName() {
     $data = &$this->container();
@@ -517,7 +515,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Store the variable with the value in the form scope
+   * Store the variable with the value in the form scope.
    *
    * @param string|array $name name of the variable or an assoc array of name/value pairs
    * @param mixed $value
@@ -525,29 +523,26 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
    *
    *
    * @return void
-   *
    */
   public function set($name, $value = NULL) {
     self::$_session->set($name, $value, $this->_scope);
   }
 
   /**
-   * Get the variable from the form scope
+   * Get the variable from the form scope.
    *
    * @param string $name
-   *   name of the variable.
+   *   name of the variable.
    *
-
    *
    * @return mixed
-   *
    */
   public function get($name) {
     return self::$_session->get($name, $this->_scope);
   }
 
   /**
-   * Create the header for the wizard from the list of pages
+   * Create the header for the wizard from the list of pages.
    * Store the created header in smarty
    *
    * @param string $currentPageName
@@ -556,9 +551,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
    * @return array
    */
   public function wizardHeader($currentPageName) {
-    $wizard          = array();
+    $wizard = array();
     $wizard['steps'] = array();
-    $count           = 0;
+    $count = 0;
     foreach ($this->_pages as $name => $page) {
       $count++;
       $wizard['steps'][] = array(
@@ -604,7 +599,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Assign value to name in template
+   * Assign value to name in template.
    *
    * @param string $var
    * @param mixed $value
@@ -617,7 +612,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Assign value to name in template by reference
+   * Assign value to name in template by reference.
    *
    * @param string $var
    * @param mixed $value
@@ -630,7 +625,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Appends values to template variables
+   * Appends values to template variables.
    *
    * @param array|string $tpl_var the template variable name(s)
    * @param mixed $value
@@ -642,7 +637,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Returns an array containing template variables
+   * Returns an array containing template variables.
    *
    * @param string $name
    *
@@ -653,7 +648,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Setter for embedded
+   * Setter for embedded.
    *
    * @param bool $embedded
    *
@@ -664,16 +659,17 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Getter for embedded
+   * Getter for embedded.
    *
-   * @return boolean return the embedded value
+   * @return bool
+   *   return the embedded value
    */
   public function getEmbedded() {
     return $this->_embedded;
   }
 
   /**
-   * Setter for skipRedirection
+   * Setter for skipRedirection.
    *
    * @param bool $skipRedirection
    *
@@ -684,9 +680,10 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Getter for skipRedirection
+   * Getter for skipRedirection.
    *
-   * @return boolean return the skipRedirection value
+   * @return bool
+   *   return the skipRedirection value
    */
   public function getSkipRedirection() {
     return $this->_skipRedirection;
@@ -722,7 +719,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Setter for print
+   * Setter for print.
    *
    * @param bool $print
    *
@@ -739,9 +736,10 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
   }
 
   /**
-   * Getter for print
+   * Getter for print.
    *
-   * @return boolean return the print value
+   * @return bool
+   *   return the print value
    */
   public function getPrint() {
     return $this->_print;
@@ -851,14 +849,13 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
    * and present the user a better message and/or redirect to the same page with a reset url
    *
    * @return void
-   *
    */
   public function invalidKey() {
     self::invalidKeyCommon();
   }
 
   public function invalidKeyCommon() {
-    $msg = ts('We can\'t load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site adminstrator for assistance.') . '<br /><br />' . ts('Site Administrators: This error may indicate that users are accessing this page using a domain or URL other than the configured Base URL. EXAMPLE: Base URL is http://example.org, but some users are accessing the page via http://www.example.org or a domain alias like http://myotherexample.org.') . '<br /><br />' . ts('Error type: Could not find a valid session key.');
+    $msg = ts("We can't load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site administrator for assistance.") . '<br /><br />' . ts('Site Administrators: This error may indicate that users are accessing this page using a domain or URL other than the configured Base URL. EXAMPLE: Base URL is http://example.org, but some users are accessing the page via http://www.example.org or a domain alias like http://myotherexample.org.') . '<br /><br />' . ts('Error type: Could not find a valid session key.');
     CRM_Core_Error::fatal($msg);
   }