Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-04-03-23-46-36
[civicrm-core.git] / CRM / Activity / Page / AJAX.php
index d762756be54b962d4d4fc12691aa2db5148e17e2..999b07ab0eb58ccbb2626d0cdf73a3f56627ba3a 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  *
  */
 
@@ -196,7 +196,7 @@ class CRM_Activity_Page_AJAX {
 
     foreach ($caseRelationships as $key => $value) {
       //calculate roles that don't have relationships
-      if (CRM_Utils_Array::value($value['relation_type'], $caseRoles)) {
+      if (!empty($caseRoles[$value['relation_type']])) {
         //keep naming from careRoles array
         $caseRelationships[$key]['relation'] = $caseRoles[$value['relation_type']];
         unset($caseRoles[$value['relation_type']]);
@@ -248,32 +248,40 @@ class CRM_Activity_Page_AJAX {
     // set user name, email and edit columns links
     // idx will count number of current row / needed by edit links
     $idx = 1;
-    foreach ($caseRelationships as $key => $row) {
+    foreach ($caseRelationships as &$row) {
+      // Get rid of the "<br />(Case Manager)" from label
+      list($typeLabel) = explode('<', $row['relation']);
       // view user links
-      if ($caseRelationships[$key]['cid']) {
-        $caseRelationships[$key]['name'] = '<a href='.CRM_Utils_System::url('civicrm/contact/view',
-          'action=view&reset=1&cid='.$caseRelationships[$key]['cid']).'>'.$caseRelationships[$key]['name'].'</a>';
+      if ($row['cid']) {
+        $row['name'] = '<a class="view-contact" title="'. ts('View Contact') .'" href='.CRM_Utils_System::url('civicrm/contact/view',
+          'action=view&reset=1&cid='.$row['cid']).'>'.$row['name'].'</a>';
       }
       // email column links/icon
-      if ($caseRelationships[$key]['email']) {
-        $caseRelationships[$key]['email'] = '<a href="'.CRM_Utils_System::url('civicrm/contact/view/activity', 'action=reset=1&action=add&atype=3&cid='.$caseRelationships[$key]['cid']).'" title="compose and send an email"><div class="icon email-icon" title="compose and send an email"></div>
-             </a>';
+      if ($row['email']) {
+        $row['email'] = '<a class="crm-hover-button crm-popup" href="'.CRM_Utils_System::url('civicrm/activity/email/add', 'reset=1&action=add&atype=3&cid='.$row['cid']).'&caseid='.$caseID.'" title="'. ts('Send an Email') . '"><span class="icon email-icon"></span></a>';
       }
       // edit links
       if ($hasAccessToAllCases) {
-        switch($caseRelationships[$key]['source']){
+        switch($row['source']){
         case 'caseRel':
-          $caseRelationships[$key]['actions'] =
-            '<a href="#" title="edit case role" onclick="createRelationship( '.$caseRelationships[$key]['relation_type'].', '.$caseRelationships[$key]['cid'].', '.$caseRelationships[$key]['rel_id'].', '.$idx.', \''.$caseRelationships[$key]['relation'].'\' );return false;"><div class="icon edit-icon" ></div></a>&nbsp;&nbsp;<a href="#" class="case-role-delete" case_id="'.$caseID.'" rel_type="'.$caseRelationships[$key]['relation_type'].'"><div class="icon delete-icon" title="remove contact from case role"></div></a>';
+          $row['actions'] =
+            '<a href="#editCaseRoleDialog" title="'. ts('Reassign %1', array(1 => $typeLabel)) .'" class="crm-hover-button case-miniform" data-rel_type="'. $row['relation_type'] .'" data-rel_id="'. $row['rel_id'] .'"data-key="'. CRM_Core_Key::get('civicrm/ajax/relation') .'">'.
+              '<span class="icon edit-icon"></span>'.
+            '</a>'.
+            '<a href="#deleteCaseRoleDialog" title="'. ts('Remove %1', array(1 => $typeLabel)) .'" class="crm-hover-button case-miniform" data-rel_type="'.$row['relation_type'].'" data-key="'. CRM_Core_Key::get('civicrm/ajax/delcaserole') .'">'.
+              '<span class="icon delete-icon"></span>'.
+            '</a>';
           break;
 
         case 'caseRoles':
-          $caseRelationships[$key]['actions'] =
-            '<a href="#" title="edit case role" onclick="createRelationship('.$caseRelationships[$key]['relation_type'].', null, null, '.$idx.',  \''.$caseRelationships[$key]['relation'].'\');return false;"><div class="icon edit-icon"></div></a>';
+          $row['actions'] =
+            '<a href="#editCaseRoleDialog" title="'. ts('Assign %1', array(1 => $typeLabel)) .'" class="crm-hover-button case-miniform" data-rel_type="'. $row['relation_type'] .'" data-key="'. CRM_Core_Key::get('civicrm/ajax/relation') .'">'.
+              '<span class="icon edit-icon"></span>'.
+            '</a>';
           break;
         }
       } else {
-        $caseRelationships[$key]['actions'] = '';
+        $row['actions'] = '';
       }
       $idx++;
     }
@@ -419,8 +427,9 @@ class CRM_Activity_Page_AJAX {
       1 => 'subject',
       2 => 'source_contact_name',
       3 => '',
-      4 => 'activity_date_time',
-      5 => 'status_id',
+      4 => '',
+      5 => 'activity_date_time',
+      6 => 'status_id',
     );
 
     $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');