Merge pull request #15580 from jaapjansma/dev_1205
[civicrm-core.git] / CRM / Mailing / Task.php
index cd511c3d9b442f00316c00720867b28a45be1b47..32a4b0ff74ed48a188a995a5e822fd9d17362fca 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
  */
 
 /**
  * used by the search forms.
  *
  */
-class CRM_Mailing_Task {
-  /**
-   * The task array.
-   *
-   * @var array
-   */
-  static $_tasks = NULL;
+class CRM_Mailing_Task extends CRM_Core_Task {
 
-  /**
-   * The optional task array.
-   *
-   * @var array
-   */
-  static $_optionalTasks = NULL;
+  public static $objectType = 'mailing';
 
   /**
    * These tasks are the core set of tasks that the user can perform
@@ -58,46 +47,37 @@ class CRM_Mailing_Task {
    * @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::$_tasks = [
+        self::TASK_PRINT => [
           'title' => ts('Print Mailing Recipients'),
           'class' => 'CRM_Mailing_Form_Task_Print',
           'result' => FALSE,
-        ),
-      );
+        ],
+      ];
 
-      CRM_Utils_Hook::searchTasks('mailing', self::$_tasks);
-      asort(self::$_tasks);
+      parent::tasks();
     }
 
     return self::$_tasks;
   }
 
-  /**
-   * These tasks are the core set of task titles
-   * on mailing recipients.
-   *
-   * @return array
-   *   the set of task titles.
-   */
-  public static function &taskTitles() {
-    return array();
-  }
-
   /**
    * Show tasks selectively based on the permission level
    * 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) {
-    $task = array();
-    return $task;
+  public static function permissionedTaskTitles($permission, $params = []) {
+    $tasks = [];
+
+    $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params);
+    return $tasks;
   }
 
   /**
@@ -113,12 +93,13 @@ class CRM_Mailing_Task {
     self::tasks();
     if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) {
       // make the print task by default
-      $value = 1;
+      $value = self::TASK_PRINT;
     }
-    return array(
+
+    return [
       self::$_tasks[$value]['class'],
       self::$_tasks[$value]['result'],
-    );
+    ];
   }
 
 }