+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2017
+ * @copyright CiviCRM LLC (c) 2004-2018
* $Id$
*
*/
* used by the search forms
*
*/
-class CRM_Grant_Task {
- const DELETE_GRANTS = 1, PRINT_GRANTS = 2, EXPORT_GRANTS = 3, UPDATE_GRANTS = 4;
+class CRM_Grant_Task extends CRM_Core_Task {
- /**
- * The task array
- *
- * @var array
- */
- static $_tasks = NULL;
+ const
+ // Grant Tasks
+ UPDATE_GRANTS = 701;
- /**
- * The optional task array
- *
- * @var array
- */
- static $_optionalTasks = NULL;
+ static $objectType = 'grant';
/**
* These tasks are the core set of tasks that the user can perform
* @return array
* the set of tasks for a group of contacts
*/
- public static function &tasks() {
+ public static function tasks() {
if (!(self::$_tasks)) {
self::$_tasks = array(
- 1 => array(
+ self::TASK_DELETE => array(
'title' => ts('Delete grants'),
'class' => 'CRM_Grant_Form_Task_Delete',
'result' => FALSE,
),
- 2 => array(
+ self::TASK_PRINT => array(
'title' => ts('Print selected rows'),
'class' => 'CRM_Grant_Form_Task_Print',
'result' => FALSE,
),
- 3 => array(
+ self::TASK_EXPORT => array(
'title' => ts('Export grants'),
'class' => array(
'CRM_Export_Form_Select',
),
'result' => FALSE,
),
- 4 => array(
+ self::UPDATE_GRANTS => array(
'title' => ts('Update grants'),
'class' => 'CRM_Grant_Form_Task_Update',
'result' => FALSE,
),
);
- }
- if (!CRM_Core_Permission::check('delete in CiviGrant')) {
- unset(self::$_tasks[1]);
- }
- CRM_Utils_Hook::searchTasks('grant', self::$_tasks);
- asort(self::$_tasks);
- return self::$_tasks;
- }
- /**
- * These tasks are the core set of task titles
- *
- * @return array
- * the set of task titles
- */
- public static function &taskTitles() {
- self::tasks();
- $titles = array();
- foreach (self::$_tasks as $id => $value) {
- $titles[$id] = $value['title'];
+ if (!CRM_Core_Permission::check('delete in CiviGrant')) {
+ unset(self::$_tasks[self::TASK_DELETE]);
+ }
+
+ parent::tasks();
}
- return $titles;
+
+ return self::$_tasks;
}
/**
* of the user
*
* @param int $permission
+ * @param array $params
*
* @return array
* set of tasks that are valid for the user
*/
- public static function &permissionedTaskTitles($permission) {
- $tasks = array();
+ public static function permissionedTaskTitles($permission, $params = array()) {
if (($permission == CRM_Core_Permission::EDIT)
|| CRM_Core_Permission::check('edit grants')
) {
}
else {
$tasks = array(
- 3 => self::$_tasks[3]['title'],
+ self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'],
);
//CRM-4418,
if (CRM_Core_Permission::check('delete in CiviGrant')) {
- $tasks[1] = self::$_tasks[1]['title'];
+ $tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title'];
}
}
+
+ $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params);
return $tasks;
}
*/
public static function getTask($value) {
self::tasks();
- if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) {
- // make the print task by default
- $value = 2;
+
+ if (!CRM_Utils_Array::value($value, self::$_tasks)) {
+ // make it the print task by default
+ $value = self::TASK_PRINT;
}
- return array(
- self::$_tasks[$value]['class'],
- self::$_tasks[$value]['result'],
- );
+ return parent::getTask($value);
}
}