Fix for multiple role assignment between cases
[civicrm-core.git] / CRM / Contact / Task.php
index 6a9204ea0ba65370ec6dba2fa2284305135e0d96..764ef97ba852e0a8f7a4612d09d71a1768a17ded 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -70,7 +70,6 @@ class CRM_Contact_Task {
    * The task array
    *
    * @var array
-   * @static
    */
   static $_tasks = NULL;
 
@@ -78,7 +77,6 @@ class CRM_Contact_Task {
    * The optional task array
    *
    * @var array
-   * @static
    */
   static $_optionalTasks = NULL;
 
@@ -239,32 +237,45 @@ class CRM_Contact_Task {
         );
       }
 
-      if (CRM_Core_Permission::access('CiviMail')) {
-        self::$_tasks[self::CREATE_MAILING] = array(
-          'title' => ts('Schedule/Send a Mass Mailing'),
-          'class' => array(
-            'CRM_Mailing_Form_Group',
-            'CRM_Mailing_Form_Settings',
-            'CRM_Mailing_Form_Upload',
-            'CRM_Mailing_Form_Test',
-            'CRM_Mailing_Form_Schedule',
-          ),
-          'result' => FALSE,
-        );
+      if (defined('CIVICRM_CIVIMAIL_UI_LEGACY')) {
+        if (CRM_Core_Permission::access('CiviMail')) {
+          self::$_tasks[self::CREATE_MAILING] = array(
+            'title' => ts('Schedule/Send a Mass Mailing'),
+            'class' => array(
+              'CRM_Mailing_Form_Group',
+              'CRM_Mailing_Form_Settings',
+              'CRM_Mailing_Form_Upload',
+              'CRM_Mailing_Form_Test',
+              'CRM_Mailing_Form_Schedule',
+            ),
+            'result' => FALSE,
+          );
+        }
+        elseif (CRM_Mailing_Info::workflowEnabled() &&
+          CRM_Core_Permission::check('create mailings')
+        ) {
+          self::$_tasks[self::CREATE_MAILING] = array(
+            'title' => ts('Create a Mass Mailing'),
+            'class' => array(
+              'CRM_Mailing_Form_Group',
+              'CRM_Mailing_Form_Settings',
+              'CRM_Mailing_Form_Upload',
+              'CRM_Mailing_Form_Test',
+            ),
+            'result' => FALSE,
+          );
+        }
       }
-      elseif (CRM_Mailing_Info::workflowEnabled() &&
-        CRM_Core_Permission::check('create mailings')
-      ) {
-        self::$_tasks[self::CREATE_MAILING] = array(
-          'title' => ts('Create a Mass Mailing'),
-          'class' => array(
-            'CRM_Mailing_Form_Group',
-            'CRM_Mailing_Form_Settings',
-            'CRM_Mailing_Form_Upload',
-            'CRM_Mailing_Form_Test',
-          ),
-          'result' => FALSE,
-        );
+      else {
+        if (CRM_Core_Permission::access('CiviMail')
+          || (CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings'))
+        ) {
+          self::$_tasks[self::CREATE_MAILING] = array(
+            'title' => ts('Schedule/Send a Mass Mailing'),
+            'class' => 'CRM_Mailing_Form_Task_AdhocMailing',
+            'result' => FALSE,
+          );
+        }
       }
 
       self::$_tasks += CRM_Core_Component::taskList();
@@ -279,8 +290,8 @@ class CRM_Contact_Task {
    * These tasks are the core set of tasks that the user can perform
    * on a contact / group of contacts
    *
-   * @return array the set of tasks for a group of contacts
-   * @static
+   * @return array
+   *   the set of tasks for a group of contacts
    */
   public static function &taskTitles() {
     self::initTasks();
@@ -316,7 +327,8 @@ class CRM_Contact_Task {
    * @param bool $deletedContacts
    *   Are these tasks for operating on deleted contacts?.
    *
-   * @return array set of tasks that are valid for the user
+   * @return array
+   *   set of tasks that are valid for the user
    */
   public static function &permissionedTaskTitles($permission, $deletedContacts = FALSE) {
     self::initTasks();
@@ -355,10 +367,10 @@ class CRM_Contact_Task {
   }
 
   /**
-   * These tasks get added based on the context the user is in
+   * These tasks get added based on the context the user is in.
    *
-   * @return array the set of optional tasks for a group of contacts
-   * @static
+   * @return array
+   *   the set of optional tasks for a group of contacts
    */
   public static function &optionalTaskTitle() {
     $tasks = array(
@@ -384,4 +396,5 @@ class CRM_Contact_Task {
       CRM_Utils_Array::value('result', self::$_tasks[$value]),
     );
   }
+
 }