Merge pull request #3342 from systopia/CRM-14741
[civicrm-core.git] / CRM / Member / Page / DashBoard.php
index 13b8e1d218849411b3aa2a18452ba6aed77e0621..ab55f088a075422e51247c9cc21bf7a83bf0ed3a 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -47,6 +47,16 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
    *
    */
   function preProcess() {
+
+    //CRM-13901 don't show dashboard to contacts with limited view writes & it does not relect
+    //what they have access to
+    //@todo implement acls on dashboard querys (preferably via api to enhance that at the same time)
+    if(!CRM_Core_Permission::check(array('view all contacts', 'edit all contacts'))) {
+      $this->showMembershipSummary = FALSE;
+      $this->assign('membershipSummary', FALSE);
+      return;
+    }
+    $this->assign('membershipSummary', TRUE);
     CRM_Utils_System::setTitle(ts('CiviMember'));
     $membershipSummary = array();
     $preMonth = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, 01, date("Y")));
@@ -60,7 +70,7 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
 
     // You can force the dashboard to display based upon a certain date
     $ym = CRM_Utils_Array::value('date', $_GET);
-    
+
     if ($ym) {
       if (preg_match('/^\d{6}$/', $ym) == 0 ||
         !checkdate(substr($ym, 4, 2), 1, substr($ym, 0, 4)) ||
@@ -165,10 +175,10 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
     $status = implode(',', $status);
 
     /* Disabled for lack of appropriate search
-       
+
        The Membership search isn't able to properly filter by join or renewal events.
        Until that works properly, the subtotals shouldn't get links.
+
     foreach ($membershipSummary as $typeID => $details) {
       foreach ($details as $key => $value) {
         switch ($key) {
@@ -238,9 +248,9 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
       }
     }
     */
-    
+
     // Temporary replacement for current totals column
-    
+
     foreach ($membershipSummary as $typeID => $details) {
       if (!$isCurrentMonth) {
         $membershipSummary[$typeID]['total']['total']['url'] = CRM_Utils_System::url('civicrm/member/search',
@@ -288,65 +298,65 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
 
     $totalCount['premonth']['new'] = array(
       'count' => $newCountPreMonth,
-      'url' => CRM_Utils_System::url('civicrm/activity/search',
-        "reset=1&force=1&signupType=1&dateLow=$preMonth&dateHigh=$preMonthEnd"
-      ),
+      //'url' => CRM_Utils_System::url('civicrm/activity/search',
+      //  "reset=1&force=1&signupType=1&dateLow=$preMonth&dateHigh=$preMonthEnd"
+      //),
     );
 
     $totalCount['premonth']['renew'] = array(
       'count' => $renewCountPreMonth,
-      'url' => CRM_Utils_System::url('civicrm/activity/search',
-        "reset=1&force=1&signupType=2&dateLow=$preMonth&dateHigh=$preMonthEnd"
-      ),
+      //'url' => CRM_Utils_System::url('civicrm/activity/search',
+      //  "reset=1&force=1&signupType=2&dateLow=$preMonth&dateHigh=$preMonthEnd"
+      //),
     );
 
     $totalCount['premonth']['total'] = array(
       'count' => $totalCountPreMonth,
-      'url' => CRM_Utils_System::url('civicrm/activity/search',
-        "reset=1&force=1&signupType=3&dateLow=$preMonth&dateHigh=$preMonthEnd"
-      ),
+      //'url' => CRM_Utils_System::url('civicrm/activity/search',
+      //  "reset=1&force=1&signupType=3&dateLow=$preMonth&dateHigh=$preMonthEnd"
+      //),
     );
 
     $totalCount['month']['new'] = array(
       'count' => $newCountMonth,
-      'url' => CRM_Utils_System::url('civicrm/activity/search',
-        "reset=1&force=1&signupType=1&dateLow=$monthStart&dateHigh=$ymd"
-      ),
+      //'url' => CRM_Utils_System::url('civicrm/activity/search',
+      //  "reset=1&force=1&signupType=1&dateLow=$monthStart&dateHigh=$ymd"
+      //),
     );
 
     $totalCount['month']['renew'] = array(
       'count' => $renewCountMonth,
-      'url' => CRM_Utils_System::url('civicrm/activity/search',
-        "reset=1&force=1&signupType=2&dateLow=$monthStart&dateHigh=$ymd"
-      ),
+      //'url' => CRM_Utils_System::url('civicrm/activity/search',
+      //  "reset=1&force=1&signupType=2&dateLow=$monthStart&dateHigh=$ymd"
+      //),
     );
 
     $totalCount['month']['total'] = array(
       'count' => $totalCountMonth,
-      'url' => CRM_Utils_System::url('civicrm/activity/search',
-        "reset=1&force=1&signupType=3&dateLow=$monthStart&dateHigh=$ymd"
-      ),
+      //'url' => CRM_Utils_System::url('civicrm/activity/search',
+      //  "reset=1&force=1&signupType=3&dateLow=$monthStart&dateHigh=$ymd"
+      //),
     );
 
     $totalCount['year']['new'] = array(
       'count' => $newCountYear,
-      'url' => CRM_Utils_System::url('civicrm/activity/search',
-        "reset=1&force=1&signupType=1&dateLow=$yearStart&dateHigh=$ymd"
-      ),
+      //'url' => CRM_Utils_System::url('civicrm/activity/search',
+      //  "reset=1&force=1&signupType=1&dateLow=$yearStart&dateHigh=$ymd"
+      //),
     );
 
     $totalCount['year']['renew'] = array(
       'count' => $renewCountYear,
-      'url' => CRM_Utils_System::url('civicrm/activity/search',
-        "reset=1&force=1&signupType=2&dateLow=$yearStart&dateHigh=$ymd"
-      ),
+      //'url' => CRM_Utils_System::url('civicrm/activity/search',
+      //  "reset=1&force=1&signupType=2&dateLow=$yearStart&dateHigh=$ymd"
+      //),
     );
 
     $totalCount['year']['total'] = array(
       'count' => $totalCountYear,
-      'url' => CRM_Utils_System::url('civicrm/activity/search',
-        "reset=1&force=1&signupType=3&dateLow=$yearStart&dateHigh=$ymd"
-      ),
+      //'url' => CRM_Utils_System::url('civicrm/activity/search',
+      //  "reset=1&force=1&signupType=3&dateLow=$yearStart&dateHigh=$ymd"
+      //),
     );
 
     $totalCount['current']['total'] = array(
@@ -377,7 +387,7 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
     //LCD add owner values
     $totalCount['premonth_owner']['premonth_owner'] = array(
       'count' => $totalCountPreMonth_owner,
-      'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&start=$preMonth&end=$preMonthEnd&owner=1"),
+    //  'url' => CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&start=$preMonth&end=$preMonthEnd&owner=1"),
     );
 
     $totalCount['month_owner']['month_owner'] = array(
@@ -412,7 +422,7 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
     $this->assign('totalCount', $totalCount);
     $this->assign('month', date('F', $monthStartTs));
     $this->assign('year', date('Y', $monthStartTs));
-    $this->assign('premonth', date('F', $preMonthYear));
+    $this->assign('premonth', date('F', strtotime($preMonth)));
     $this->assign('currentMonth', date('F'));
     $this->assign('currentYear', date('Y'));
     $this->assign('isCurrent', $isCurrentMonth);