filter / disable certain task actions for soft credit search
authorDeepak Srivastava <deepak.srivastava.0303@gmail.com>
Fri, 14 Mar 2014 07:07:45 +0000 (12:37 +0530)
committerDeepak Srivastava <deepak.srivastava.0303@gmail.com>
Fri, 14 Mar 2014 07:07:45 +0000 (12:37 +0530)
CRM/Contribute/Form/Search.php
CRM/Contribute/Task.php

index 93e281a640e46e0c5b41f03831ca5fe043aa0e00..99d3543d587aa6d23baac45adc82e526fe340135 100644 (file)
@@ -284,7 +284,12 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form {
 
       $permission = CRM_Core_Permission::getPermission();
 
-      $tasks = array('' => ts('- actions -')) + CRM_Contribute_Task::permissionedTaskTitles($permission);
+      $queryParams = $this->get('queryParams');
+      $softCreditFiltering = FALSE;
+      if (!empty($queryParams)) {
+        $softCreditFiltering = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($queryParams);
+      }
+      $tasks = array('' => ts('- actions -')) + CRM_Contribute_Task::permissionedTaskTitles($permission, $softCreditFiltering);
       $this->add('select', 'task', ts('Actions:') . ' ', $tasks);
       $this->add('submit', $this->_actionButtonName, ts('Go'),
         array(
index 57526b738f9231b62f8bc47a9929b761ba263dbb..a3b05064917c3d8c98b1ea9ba2a394f641753d9b 100644 (file)
@@ -154,7 +154,7 @@ class CRM_Contribute_Task {
    * @return array set of tasks that are valid for the user
    * @access public
    */
-  static function &permissionedTaskTitles($permission) {
+  static function &permissionedTaskTitles($permission, $softCreditFiltering = FALSE) {
     $tasks = array();
     if (($permission == CRM_Core_Permission::EDIT)
       || CRM_Core_Permission::check('edit contributions')
@@ -173,6 +173,9 @@ class CRM_Contribute_Task {
         $tasks[1] = self::$_tasks[1]['title'];
       }
     }
+    if ($softCreditFiltering) {
+      unset($tasks[4], $tasks[7]);
+    }
     return $tasks;
   }