worked on CRM-13203
authoryashodha <yashodha.chaku@webaccess.co.in>
Mon, 12 Aug 2013 12:58:49 +0000 (18:28 +0530)
committeryashodha <yashodha.chaku@webaccess.co.in>
Mon, 12 Aug 2013 12:58:49 +0000 (18:28 +0530)
CRM/Activity/Form/Activity.php

index 0c41a3affabf15832804df17700327194049270e..ca4f7dca9d0b1b44bdb3bb7c5aa0fad2be269535 100644 (file)
@@ -180,7 +180,8 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
         'type' => 'select',
         'label' => ts('Followup Activity'),
         'attributes' => array(
-          '' => '- ' . ts('select activity') . ' -') +
+          '' => '- ' . ts('select activity') . ' -'
+        ) +
         CRM_Core_PseudoConstant::ActivityType(FALSE)
       ),
       // Add optional 'Subject' field for the Follow-up Activiity, CRM-4491
@@ -275,7 +276,9 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
     //check for required permissions, CRM-6264
     if ($this->_activityId &&
       in_array($this->_action, array(
-        CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) &&
+        CRM_Core_Action::UPDATE,
+        CRM_Core_Action::VIEW
+      )) &&
       !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)
     ) {
       CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
@@ -304,8 +307,8 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
 
     // Assign pageTitle to be "Activity - "+ activity name
     if (isset($activityTName)) {
-    $pageTitle = 'Activity - ' . CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
-    $this->assign('pageTitle', $pageTitle);
+      $pageTitle = 'Activity - ' . CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
+      $this->assign('pageTitle', $pageTitle);
     }
 
     //check the mode when this form is called either single or as
@@ -383,7 +386,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
     }
 
     if ($this->_context == 'fulltext') {
-      $keyName   = '&qfKey';
+      $keyName = '&qfKey';
       $urlParams = 'force=1';
       $urlString = 'civicrm/contact/search/custom';
       if ($this->_action == CRM_Core_Action::UPDATE) {
@@ -397,7 +400,12 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       $this->assign('searchKey', $qfKey);
     }
     elseif (in_array($this->_context, array(
-      'standalone', 'home', 'dashlet', 'dashletFullscreen'))) {
+      'standalone',
+      'home',
+      'dashlet',
+      'dashletFullscreen'
+    ))
+    ) {
       $urlParams = 'reset=1';
       $urlString = 'civicrm/dashboard';
     }
@@ -408,14 +416,17 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       }
       $path = CRM_Utils_System::currentPath();
       if ($this->_compContext == 'advanced' ||
-        $path == 'civicrm/contact/search/advanced') {
+        $path == 'civicrm/contact/search/advanced'
+      ) {
         $urlString = 'civicrm/contact/search/advanced';
       }
-      else if ($path == 'civicrm/contact/search') {
-        $urlString = 'civicrm/contact/search';
-      }
       else {
-        $urlString = 'civicrm/activity/search';
+        if ($path == 'civicrm/contact/search') {
+          $urlString = 'civicrm/contact/search';
+        }
+        else {
+          $urlString = 'civicrm/activity/search';
+        }
       }
       $this->assign('searchKey', $qfKey);
     }
@@ -452,7 +463,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
     // figure out the file name for activity type, if any
     if ($this->_activityTypeId &&
       $this->_activityTypeFile =
-      CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, $this->_crmDir)
+        CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, $this->_crmDir)
     ) {
       $this->assign('activityTypeFile', $this->_activityTypeFile);
       $this->assign('crmDir', $this->_crmDir);
@@ -493,10 +504,10 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
 
     // if we're editing...
     if (isset($this->_activityId)) {
-      $defaults['source_contact_qid'] = CRM_Utils_Array::value( 'source_contact_id',
-        $defaults );
-      $defaults['source_contact_id']  = CRM_Utils_Array::value( 'source_contact',
-        $defaults );
+      $defaults['source_contact_qid'] = CRM_Utils_Array::value('source_contact_id',
+        $defaults);
+      $defaults['source_contact_id'] = CRM_Utils_Array::value('source_contact',
+        $defaults);
 
       if (!CRM_Utils_Array::crmIsEmptyArray($defaults['target_contact'])) {
         $target_contact_value = explode(';', trim($defaults['target_contact_value']));
@@ -530,7 +541,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
         $this->assign('current_activity_date_time', $defaults['activity_date_time']);
         list($defaults['activity_date_time'],
           $defaults['activity_date_time_time']
-        ) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
+          ) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
       }
 
       //set the assigneed contact count to template
@@ -637,17 +648,17 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
         $button = ts('Restore');
       }
       $this->addButtons(array(
-          array(
-            'type' => 'next',
-            'name' => $button,
-            'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
-            'isDefault' => TRUE
-          ),
-          array(
-            'type' => 'cancel',
-            'name' => ts('Cancel')
-          )
-        ));
+        array(
+          'type' => 'next',
+          'name' => $button,
+          'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
+          'isDefault' => TRUE
+        ),
+        array(
+          'type' => 'cancel',
+          'name' => ts('Cancel')
+        )
+      ));
       return;
     }
 
@@ -670,7 +681,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
     //enable form element (ActivityLinks sets this true)
     $this->assign('suppressForm', FALSE);
 
-    $element = &$this->add('select', 'activity_type_id', ts('Activity Type'),
+    $element = & $this->add('select', 'activity_type_id', ts('Activity Type'),
       $this->_fields['followup_activity_type_id']['attributes'],
       FALSE, array(
         'onchange' =>
@@ -779,14 +790,14 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
     $this->assign('tokenUrl', $tokenUrl);
 
     $admin = CRM_Core_Permission::check('administer CiviCRM');
-    //allow to edit sourcecontactfield field if context is civicase.
+    //allow to edit source contact field field if context is civicase.
     if ($this->_context == 'caseActivity') {
       $admin = TRUE;
     }
 
     $this->assign('admin', $admin);
 
-    $sourceContactField = &$this->add($this->_fields['source_contact_id']['type'],
+    $sourceContactField = & $this->add($this->_fields['source_contact_id']['type'],
       'source_contact_id',
       $this->_fields['source_contact_id']['label'],
       NULL,
@@ -854,7 +865,8 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       $this->addButtons($buttons);
     }
     else {
-      $message = array('completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'),
+      $message = array(
+        'completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'),
         'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.'),
       );
       $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");");
@@ -883,9 +895,9 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
     $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this);
 
     if (CRM_Core_BAO_Setting::getItem(
-        CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
-        'activity_assignee_notification'
-      )
+      CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
+      'activity_assignee_notification'
+    )
     ) {
       $this->assign('activityAssigneeNotification', TRUE);
     }
@@ -1052,7 +1064,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       !CRM_Utils_Array::crmIsEmptyArray($params['target_contact_id'])
     ) {
       $targetContacts = $params['target_contact_id'];
-      foreach($targetContacts as $targetContactId) {
+      foreach ($targetContacts as $targetContactId) {
         $params['target_contact_id'] = array($targetContactId);
         // save activity
         $activity[] = $this->processActivity($params);
@@ -1137,8 +1149,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       )
     ) {
       $mailToContacts = array();
-      //FIX ME : add more parameters to 'getNames' function
-      $assigneeContacts = CRM_Activity_BAO_ActivityContact::getNames($activity->id, $assigneeID, TRUE, FALSE);
+      $assigneeContacts = CRM_Activity_BAO_ActivityContact::getNames($activity->id, $assigneeID);
 
       //build an associative array with unique email addresses.
       foreach ($activityAssigned as $id => $dnc) {
@@ -1148,11 +1159,11 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       }
 
       if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
-        //include attachments while sendig a copy of activity.
+        //include attachments while sending a copy of activity.
         $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
 
-        $ics = new CRM_Activity_BAO_ICalendar( $activity );
-        $ics->addAttachment( $attachments, $mailToContacts );
+        $ics = new CRM_Activity_BAO_ICalendar($activity);
+        $ics->addAttachment($attachments, $mailToContacts);
 
         // CRM-8400 add param with _currentlyViewedContactId for URL link in mail
         CRM_Case_BAO_Case::sendActivityCopy(NULL, $activity->id, $mailToContacts, $attachments, NULL);