INFRA-132 - CRM/Contact - phpcbf
[civicrm-core.git] / CRM / Contact / Page / View / UserDashBoard.php
index 93b4cce8abd7f09a84e3f7e5269c5031869dc81d..7c3db5361ba56ef2fecc7a1787d03d70c8a2e54c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
   public $_contactId = NULL;
 
-  /*
-     * always show public groups
-     */
-
+  /**
+   * Always show public groups
+   * @var bool
+   */
   public $_onlyPublicGroups = TRUE;
 
   public $_edit = TRUE;
@@ -60,14 +60,13 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
   /**
    * @throws Exception
    */
-  function __construct() {
+  public function __construct() {
     parent::__construct();
 
     $check = CRM_Core_Permission::check('access Contact Dashboard');
 
     if (!$check) {
       CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
-      break;
     }
 
     $this->_contactId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
@@ -80,7 +79,7 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
     }
     elseif ($this->_contactId != $userID) {
       if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::VIEW)) {
-        CRM_Core_Error::fatal(ts('You do not have permission to view this contact'));
+        CRM_Core_Error::fatal(ts('You do not have permission to access this contact.'));
       }
       if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
         $this->_edit = FALSE;
@@ -88,15 +87,13 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
     }
   }
 
-  /*
-     * Heart of the viewing process. The runner gets all the meta data for
-     * the contact and calls the appropriate type of page to view.
-     *
-     * @return void
-     * @access public
-     *
-     */
-  function preProcess() {
+  /**
+   * Heart of the viewing process. The runner gets all the meta data for
+   * the contact and calls the appropriate type of page to view.
+   *
+   * @return void
+   */
+  public function preProcess() {
     if (!$this->_contactId) {
       CRM_Core_Error::fatal(ts('You must be logged in to view this page.'));
     }
@@ -112,12 +109,11 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
   }
 
   /**
-   * Function to build user dashboard
+   * Build user dashboard
    *
    * @return void
-   * @access public
    */
-  function buildUserDashBoard() {
+  public function buildUserDashBoard() {
     //build component selectors
     $dashboardElements = array();
     $config = CRM_Core_Config::singleton();
@@ -188,6 +184,9 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
     usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc'));
     $this->assign('dashboardElements', $dashboardElements);
 
+    // return true when 'Invoices / Credit Notes' checkbox is checked
+    $this->assign('invoices', $this->_userOptions['Invoices / Credit Notes']);
+
     if (!empty($this->_userOptions['Groups'])) {
       $this->assign('showGroup', TRUE);
       //build group selector
@@ -200,13 +199,12 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
   }
 
   /**
-   * perform actions and display for user dashboard
+   * Perform actions and display for user dashboard
    *
    * @return void
    *
-   * @access public
    */
-  function run() {
+  public function run() {
     $this->preProcess();
     $this->buildUserDashBoard();
     return parent::run();
@@ -219,7 +217,7 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
    * @static
    */
   static
-  function &links() {
+  public function &links() {
     if (!(self::$_links)) {
       $disableExtra = ts('Are you sure you want to disable this relationship?');
 
@@ -233,12 +231,12 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
         CRM_Core_Action::VIEW => array(
           'name' => ts('Dashboard'),
           'url' => 'civicrm/user',
+          'class' => 'no-popup',
           'qs' => 'reset=1&id=%%cbid%%',
           'title' => ts('View Relationship'),
         ),
       );
 
-
       if (CRM_Core_Permission::check('access CiviCRM')) {
         self::$_links = array_merge(self::$_links, array(
           CRM_Core_Action::DISABLE => array(