(generalised the links in tpl to use hooks)CRM-12864
authoryashodha <yashodha.chaku@webaccess.co.in>
Mon, 24 Jun 2013 12:48:00 +0000 (18:18 +0530)
committeryashodha <yashodha.chaku@webaccess.co.in>
Mon, 24 Jun 2013 12:48:00 +0000 (18:18 +0530)
CRM/Event/BAO/Event.php
CRM/Event/Page/DashBoard.php
CRM/Event/Page/ManageEvent.php
templates/CRM/Event/Page/DashBoard.tpl
templates/CRM/Event/Page/ManageEvent.tpl

index 151f3b1dc970a019d3a07299aaa9fb94593fd92b..5f852a9dbc9bd6570ae59ab41d6865295370de8b 100644 (file)
@@ -339,8 +339,8 @@ WHERE      civicrm_event.is_active = 1 AND
     }
 
     //get the participant status type values.
-    $query        = 'SELECT id, name, class FROM civicrm_participant_status_type';
-    $status       = CRM_Core_DAO::executeQuery($query);
+    $query = 'SELECT id, name, class FROM civicrm_participant_status_type';
+    $status = CRM_Core_DAO::executeQuery($query);
     $statusValues = array();
     while ($status->fetch()) {
       $statusValues[$status->id]['id'] = $status->id;
@@ -380,10 +380,15 @@ LIMIT      0, 10
     $eventParticipant = array();
 
     $properties = array(
-      'eventTitle' => 'event_title', 'isPublic' => 'is_public',
-      'maxParticipants' => 'max_participants', 'startDate' => 'start_date',
-      'endDate' => 'end_date', 'eventType' => 'event_type',
-      'isMap' => 'is_map', 'participants' => 'participants',
+      'id' => 'id',
+      'eventTitle' => 'event_title',
+      'isPublic' => 'is_public',
+      'maxParticipants' => 'max_participants',
+      'startDate' => 'start_date',
+      'endDate' => 'end_date',
+      'eventType' => 'event_type',
+      'isMap' => 'is_map',
+      'participants' => 'participants',
       'notCountedDueToRole' => 'notCountedDueToRole',
       'notCountedDueToStatus' => 'notCountedDueToStatus',
       'notCountedParticipants' => 'notCountedParticipants',
@@ -408,9 +413,9 @@ LIMIT      0, 10
 
           case 'is_map':
             if ($dao->$name && $config->mapAPIKey) {
-              $values             = array();
-              $ids                = array();
-              $params             = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event');
+              $values = array();
+              $ids = array();
+              $params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event');
               $values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
               if (is_numeric(CRM_Utils_Array::value('geo_code_1', $values['location']['address'][1])) ||
                 ($config->mapGeoCoding &&
@@ -514,9 +519,9 @@ LIMIT      0, 10
       }
     }
 
-    $countedRoles     = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1');
-    $nonCountedRoles  = CRM_Event_PseudoConstant::participantRole(NULL, '( filter = 0 OR filter IS NULL )');
-    $countedStatus    = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
+    $countedRoles = CRM_Event_PseudoConstant::participantRole(NULL, 'filter = 1');
+    $nonCountedRoles = CRM_Event_PseudoConstant::participantRole(NULL, '( filter = 0 OR filter IS NULL )');
+    $countedStatus = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
     $nonCountedStatus = CRM_Event_PseudoConstant::participantStatus(NULL, '( is_counted = 0 OR is_counted IS NULL )');
 
     $countedStatusANDRoles = array_merge($countedStatus, $countedRoles);
index 71c6258ded23643de01020ce9811b98651a18ec4..53e949a9565913cb13bc451ae93f17981f1855cc 100644 (file)
@@ -50,6 +50,10 @@ class CRM_Event_Page_DashBoard extends CRM_Core_Page {
     CRM_Utils_System::setTitle(ts('CiviEvent'));
 
     $eventSummary = CRM_Event_BAO_Event::getEventSummary();
+    $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME,
+      'enable_cart'
+    );
+    $eventSummary['tab'] = CRM_Event_Page_ManageEvent::tabs($enableCart);
 
     $actionColumn = FALSE;
     if (!empty($eventSummary) &&
index 95ad8a2334d22088b0ba4737951cd5c91c51dc83..51fb063208cb3c38ae36cc5e63fff960d0cd982d 100644 (file)
@@ -48,6 +48,8 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page {
 
   static $_links = NULL;
 
+  static $_tabLinks = NULL;
+
   protected $_pager = NULL;
 
   protected $_sortByCharacter;
@@ -97,6 +99,65 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page {
     return self::$_actionLinks;
   }
 
+  /**
+   * Get tab  Links for events
+   *
+   * @return array (reference) of tab links
+   */
+  function &tabs($enableCart) {
+    if (!(self::$_tabLinks)) {
+      self::$_tabLinks = array(
+        'settings' => array(
+          'title' => ts('Info and Settings'),
+          'url' => 'civicrm/event/manage/settings',
+          'field' => 'id'
+        ),
+        'location' => array(
+          'title' => ts('Location'),
+          'url' => 'civicrm/event/manage/location',
+          'field' => 'is_show_location',
+        ),
+        'fee' => array(
+          'title' => ts('Fees'),
+          'url' => 'civicrm/event/manage/fee',
+          'field' => 'is_monetary',
+        ),
+        'registration' => array(
+          'title' => ts('Online Registration'),
+          'url' => 'civicrm/event/manage/registration',
+          'field' => 'is_online_registration',
+        ),
+        'reminder' => array(
+          'title' => ts('Schedule Reminders'),
+          'url' => 'civicrm/event/manage/reminder',
+          'field' => 'reminder',
+        ),
+        'conference' => array(
+          'title' => ts('Conference Slots'),
+          'url' => 'civicrm/event/manage/conference',
+          'field' => 'slot_label_id',
+        ),
+        'friend' => array(
+          'title' => ts('Tell a Friend'),
+          'url' => 'civicrm/event/manage/friend',
+          'field' => 'friend',
+        ),
+        'pcp' => array(
+          'title' => ts('Personal Campaign Pages'),
+          'url' => 'civicrm/event/manage/pcp',
+          'field' => 'is_pcp_enabled',
+        ),
+      );
+    }
+
+    if (!$enableCart) {
+      unset(self::$_tabLinks['conference']);
+    }
+
+    CRM_Utils_Hook::tabset('civicrm/event/manage', self::$_tabLinks, array());
+    return self::$_tabLinks;
+  }
+
   /**
    * Run the page.
    *
@@ -181,8 +242,6 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page {
 
     $this->search();
 
-    $config = CRM_Core_Config::singleton();
-
     $params = array();
     $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean',
       $this, FALSE
@@ -227,6 +286,12 @@ ORDER BY start_date desc
     while ($pcpDao->fetch()) {
       $eventPCPS[$pcpDao->entity_id] = $pcpDao->entity_id;
     }
+    // check if we're in shopping cart mode for events
+    $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME,
+      'enable_cart'
+    );
+    $this->assign('eventCartEnabled', $enableCart);
+    $mappingID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', 'civicrm_event', 'id', 'entity_value');
 
     while ($dao->fetch()) {
       if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) {
@@ -276,11 +341,11 @@ ORDER BY start_date desc
 
         //show campaigns on selector.
         $manageEvent[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
-        $manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, 3);
-
+        $manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mappingID);
         $manageEvent[$dao->id]['is_pcp_enabled'] = CRM_Utils_Array::value($dao->id, $eventPCPS);
       }
     }
+    $manageEvent['tab'] = self::tabs($enableCart);
     $this->assign('rows', $manageEvent);
 
     $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
@@ -288,12 +353,6 @@ ORDER BY start_date desc
     $findParticipants['statusCounted'] = implode(', ', array_values($statusTypes));
     $findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending));
     $this->assign('findParticipants', $findParticipants);
-
-    // check if we're in shopping cart mode for events
-    $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME,
-      'enable_cart'
-    );
-    $this->assign('eventCartEnabled', $enableCart);
   }
 
   /**
@@ -409,7 +468,7 @@ ORDER BY start_date desc
       $clauses[] = '( campaign_id IN ( ' . implode(' , ', array_values($campainIds)) . ' ) )';
     }
 
-    // dont do a the below assignment when doing a
+    // don't do a the below assignment when doing a
     // AtoZ pager clause
     if ($sortBy) {
       if (count($clauses) > 1 || $eventsByDates) {
index fc46f647cf8c82ac98a32036c375cc552a3fff93..18fcf3168382c5997e67f34ca6bd4cc699cbf80b 100644 (file)
             {/foreach}
             {if $values.maxParticipants}{ts 1=$values.maxParticipants}(max %1){/ts}{/if}
         </td>
-  {if $actionColumn}
+      {if $actionColumn}
         <td class="crm-event-isMap">
-            {if $values.isMap}
-                <a href="{$values.isMap}" title="{ts}Map event location{/ts}">&raquo;&nbsp;{ts}Map{/ts}</a>&nbsp;|&nbsp;
-            {/if}
-            {if $values.configure}
-              <div class="crm-configure-actions">
+          {if $values.isMap}
+            <a href="{$values.isMap}" title="{ts}Map event location{/ts}">&raquo;&nbsp;{ts}Map{/ts}</a>
+            &nbsp;|&nbsp;
+          {/if}
+          {if $values.configure}
+            <div class="crm-configure-actions">
                 <span id="{$id}" class="btn-slide">{ts}Configure{/ts}
-                <ul class="panel" id="panel_info_{$id}">
-                <li><a title="Info and Settings" class="action-item-wrap" href="{crmURL p='civicrm/event/manage/settings' q="reset=1&action=update&id=`$id`"}">{ts}Info and Settings{/ts}</a></li>
-                <li><a title="Location" class="action-item-wrap {if NOT $values.is_show_location} disabled{/if}" href="{crmURL p='civicrm/event/manage/location' q="reset=1&action=update&id=`$id`"}">{ts}Location{/ts}</a></li>
-                <li><a title="Fees" class="action-item {if NOT $values.is_monetary} disabled{/if}" href="{crmURL p='civicrm/event/manage/fee' q="reset=1&action=update&id=`$id`"}">{ts}Fees{/ts}</a></li>
-                <li><a title="Online Registration" class="action-item-wrap {if NOT $values.is_online_registration} disabled{/if}" href="{crmURL p='civicrm/event/manage/registration' q="reset=1&action=update&id=`$id`"}">{ts}Online Registration{/ts}</a></li>
-          <li><a title="Schedule Reminders" class="action-item-wrap {if NOT $values.reminder} disabled{/if}" href="{crmURL p='civicrm/event/manage/reminder' q="reset=1&action=update&id=`$id`"}">{ts}Schedule Reminders{/ts}</a></li>
-                <li><a title="Conference Slots" class="action-item-wrap {if NOT $values.is_subevent} disabled{/if}" href="{crmURL p='civicrm/event/manage/conference' q="reset=1&action=update&id=`$id`"}">{ts}Conference Slots{/ts}</a></li>
-                <li><a title="Tell a Friend" class="action-item-wrap {if NOT $values.friend} disabled{/if}" href="{crmURL p='civicrm/event/manage/friend' q="reset=1&action=update&id=`$id`"}">{ts}Tell a Friend{/ts}</a></li>
-          <li><a title="{ts}Personal Campaign Pages{/ts}" class="action-item-wrap {if NOT $values.is_pcp_enabled} disabled{/if}" href="{crmURL p='civicrm/event/manage/pcp' q="reset=1&action=update&id=`$id`"}">{ts}Personal Campaign Pages{/ts}</a></li>
+                  <ul class="panel" id="panel_info_{$id}">
+                    {foreach from=$eventSummary.tab key=k item=v}
+                      {assign var="fld" value=$v.field}
+                      {if NOT $values.$fld}{assign var="status" value="disabled"}{else}{assign var="status" value="enabled"}{/if}
+                      <li><a title="{$v.title}" class="action-item-wrap {$status}"
+                             href="{crmURL p="`$v.url`" q="reset=1&action=update&id=`$id`"}">{$v.title}</a></li>
+                    {/foreach}
+                  </ul>
                 </span>
-              </div>
-            {/if}
+            </div>
+          {/if}
         </td>
-  {/if}
+      {/if}
     </tr>
     {/foreach}
 
index f44ec0ed184653131454dd1d59b08dcd77c53bab..3f5ca8fe9cb45b14e7766b651bc48f8b5b9db6e9 100644 (file)
@@ -80,8 +80,9 @@
         <th class="hiddenElement"></th>
       </tr>
       </thead>
-      {foreach from=$rows item=row}
-        <tr id="row_{$row.id}" class="{if NOT $row.is_active} disabled{/if}">
+      {foreach from=$rows key=keys item=row}
+        {if $keys neq 'tab'}
+          <tr id="row_{$row.id}" class="{if NOT $row.is_active} disabled{/if}">
           <td class="crm-event_{$row.id}">
             <a href="{crmURL p='civicrm/event/info' q="id=`$row.id`&reset=1"}"
                title="{ts}View event info page{/ts}" class="bold">{$row.title}</a>&nbsp;&nbsp;({ts}ID:{/ts} {$row.id})
             <div class="crm-configure-actions">
               <span id="event-configure-{$row.id}" class="btn-slide">{ts}Configure{/ts}
                 <ul class="panel" id="panel_info_{$row.id}">
-                  <li>
-                    <a title="{ts}Info and Settings{/ts}" class="action-item-wrap"
-                       href="{crmURL p='civicrm/event/manage/settings'
-                       q="reset=1&action=update&id=`$row.id`"}">{ts}Info and Settings{/ts}
-                    </a>
-                  </li>
-                  <li>
-                    <a title="{ts}Location{/ts}" class="action-item-wrap {if NOT $row.is_show_location} disabled{/if}"
-                       href="{crmURL p='civicrm/event/manage/location'
-                       q="reset=1&action=update&id=`$row.id`"}">{ts}Location{/ts}
-                    </a>
-                  </li>
-                  <li>
-                    <a title="{ts}Fees{/ts}" class="action-item {if NOT $row.is_monetary} disabled{/if}"
-                       href="{crmURL p='civicrm/event/manage/fee' q="reset=1&action=update&id=`$row.id`"}">{ts}Fees{/ts}
-                    </a>
-                  </li>
-                  <li>
-                    <a title="{ts}Online Registration{/ts}" class="action-item-wrap
-                    {if NOT $row.is_online_registration} disabled{/if}" href="{crmURL
-                    p='civicrm/event/manage/registration' q="reset=1&action=update&id=`$row.id`"}">
-                      {ts}Online Registration{/ts}
-                    </a>
-                  </li>
-                  <li>
-                    <a title="{ts}Schedule Reminders{/ts}" class="action-item-wrap
-                    {if NOT $row.reminder} disabled{/if}" href="{crmURL p='civicrm/event/manage/reminder'
-                    q="reset=1&action=update&id=`$row.id`"}">{ts}Schedule Reminders{/ts}
-                    </a>
-                  </li>
-                  {if $eventCartEnabled}
-                    <li>
-                      <a title="{ts}Conference Slots{/ts}" class="action-item-wrap
-                      {if NOT $row.slot_label_id} disabled{/if}" href="{crmURL p='civicrm/event/manage/conference'
-                      q="reset=1&action=update&id=`$row.id`"}">{ts}Conference Slots{/ts}
-                      </a>
-                    </li>
-                  {/if}
-                  <li>
-                    <a title="{ts}Tell a Friend{/ts}" class="action-item-wrap {if NOT $row.friend} disabled{/if}"
-                       href="{crmURL p='civicrm/event/manage/friend'
-                       q="reset=1&action=update&id=`$row.id`"}">{ts}Tell a Friend{/ts}
-                    </a>
-                  </li>
-                  <li>
-                    <a title="{ts}Personal Campaign Pages{/ts}" class="action-item-wrap
-                    {if NOT $row.is_pcp_enabled} disabled{/if}" href="{crmURL p='civicrm/event/manage/pcp'
-                    q="reset=1&action=update&id=`$row.id`"}">{ts}Personal Campaign Pages{/ts}
-                    </a>
-                  </li>
+                  {foreach from=$rows.tab key=k item=v}
+                    {assign var="fld" value=$v.field}
+                    {if NOT $row.$fld}{assign var="status" value="disabled"}{else}{assign var="status" value="enabled"}{/if}
+                    <li><a title="{$v.title}" class="action-item-wrap {$status}"
+                           href="{crmURL p="`$v.url`" q="reset=1&action=update&id=`$row.id`"}">{$v.title}</a></li>
+                  {/foreach}
                 </ul>
               </span>
             </div>
           <td class="crm-event-start_date hiddenElement">{$row.start_date|crmDate}</td>
           <td class="crm-event-end_date hiddenElement">{$row.end_date|crmDate}</td>
         </tr>
+        {/if}
       {/foreach}
     </table>
   {include file="CRM/common/pager.tpl" location="bottom"}