@@ -920,8 +920,7 @@ public static function deprecatedGetActivities($input) {
920
920
921
921
$ config = CRM_Core_Config::singleton ();
922
922
923
- $ randomNum = md5 (uniqid ());
924
- $ activityTempTable = "civicrm_temp_activity_details_ {$ randomNum }" ;
923
+ $ activityTempTable = CRM_Utils_SQL_TempTable::build ()->setCategory ('actdetail ' )->getName ();
925
924
926
925
$ tableFields = array (
927
926
'activity_id ' => 'int unsigned ' ,
@@ -1012,7 +1011,7 @@ public static function deprecatedGetActivities($input) {
1012
1011
1013
1012
// step 2: Get target and assignee contacts for above activities
1014
1013
// create temp table for target contacts
1015
- $ activityContactTempTable = " civicrm_temp_activity_contact_ { $ randomNum }" ;
1014
+ $ activityContactTempTable = CRM_Utils_SQL_TempTable:: build ()-> setCategory ( ' actcontact ' )-> getName () ;
1016
1015
$ query = "CREATE TEMPORARY TABLE {$ activityContactTempTable } (
1017
1016
activity_id int unsigned, contact_id int unsigned, record_type_id varchar(16),
1018
1017
contact_name varchar(255), is_deleted int unsigned, counter int unsigned, INDEX index_activity_id( activity_id ) )
@@ -1773,20 +1772,27 @@ public static function sendSMS(
1773
1772
$ smsProviderParams ['To ' ] = '' ;
1774
1773
}
1775
1774
1776
- $ sendResult = self ::sendSMSMessage (
1777
- $ contactId ,
1778
- $ tokenText ,
1779
- $ smsProviderParams ,
1780
- $ activityID ,
1781
- $ sourceContactId
1782
- );
1775
+ $ doNotSms = CRM_Utils_Array::value ('do_not_sms ' , $ contact , 0 );
1783
1776
1784
- if (PEAR ::isError ($ sendResult )) {
1785
- // Collect all of the PEAR_Error objects
1786
- $ errMsgs [] = $ sendResult ;
1777
+ if ($ doNotSms ) {
1778
+ $ errMsgs [] = PEAR ::raiseError ('Contact Does not accept SMS ' , NULL , PEAR_ERROR_RETURN );
1787
1779
}
1788
1780
else {
1789
- $ success ++;
1781
+ $ sendResult = self ::sendSMSMessage (
1782
+ $ contactId ,
1783
+ $ tokenText ,
1784
+ $ smsProviderParams ,
1785
+ $ activityID ,
1786
+ $ sourceContactId
1787
+ );
1788
+
1789
+ if (PEAR ::isError ($ sendResult )) {
1790
+ // Collect all of the PEAR_Error objects
1791
+ $ errMsgs [] = $ sendResult ;
1792
+ }
1793
+ else {
1794
+ $ success ++;
1795
+ }
1790
1796
}
1791
1797
}
1792
1798
@@ -1827,9 +1833,7 @@ public static function sendSMSMessage(
1827
1833
$ activityID ,
1828
1834
$ sourceContactID = NULL
1829
1835
) {
1830
- $ doNotSms = TRUE ;
1831
1836
$ toPhoneNumber = NULL ;
1832
-
1833
1837
if ($ smsProviderParams ['To ' ]) {
1834
1838
// If phone number is specified use it
1835
1839
$ toPhoneNumber = trim ($ smsProviderParams ['To ' ]);
@@ -1843,21 +1847,20 @@ public static function sendSMSMessage(
1843
1847
$ toPhoneNumberDetails = reset ($ toPhoneNumbers );
1844
1848
$ toPhoneNumber = CRM_Utils_Array::value ('phone ' , $ toPhoneNumberDetails );
1845
1849
// Contact allows to send sms
1846
- $ doNotSms = FALSE ;
1847
1850
}
1848
1851
}
1849
1852
1850
1853
// make sure both phone are valid
1851
1854
// and that the recipient wants to receive sms
1852
- if (empty ($ toPhoneNumber ) or $ doNotSms ) {
1855
+ if (empty ($ toPhoneNumber )) {
1853
1856
return PEAR ::raiseError (
1854
1857
'Recipient phone number is invalid or recipient does not want to receive SMS ' ,
1855
1858
NULL ,
1856
1859
PEAR_ERROR_RETURN
1857
1860
);
1858
1861
}
1859
1862
1860
- $ recipient = $ smsProviderParams [ ' To ' ] ;
1863
+ $ recipient = $ toPhoneNumber ;
1861
1864
$ smsProviderParams ['contact_id ' ] = $ toID ;
1862
1865
$ smsProviderParams ['parent_activity_id ' ] = $ activityID ;
1863
1866
@@ -2529,69 +2532,70 @@ public static function isOverdue($activity) {
2529
2532
* @return array
2530
2533
* array of exportable Fields
2531
2534
*/
2532
- public static function &exportableFields ($ name = 'Activity ' ) {
2533
- if (!isset (self ::$ _exportableFields [$ name ])) {
2534
- self ::$ _exportableFields [$ name ] = array ();
2535
-
2536
- // TODO: ideally we should retrieve all fields from xml, in this case since activity processing is done
2537
- // my case hence we have defined fields as case_*
2538
- if ($ name == 'Activity ' ) {
2539
- $ exportableFields = CRM_Activity_DAO_Activity::export ();
2540
- $ exportableFields ['source_contact_id ' ]['title ' ] = ts ('Source Contact ID ' );
2541
- $ exportableFields ['source_contact ' ] = array (
2542
- 'title ' => ts ('Source Contact ' ),
2543
- 'type ' => CRM_Utils_Type::T_STRING ,
2544
- );
2535
+ public static function exportableFields ($ name = 'Activity ' ) {
2536
+ self ::$ _exportableFields [$ name ] = array ();
2537
+
2538
+ // TODO: ideally we should retrieve all fields from xml, in this case since activity processing is done
2539
+ // my case hence we have defined fields as case_*
2540
+ if ($ name == 'Activity ' ) {
2541
+ $ exportableFields = CRM_Activity_DAO_Activity::export ();
2542
+ $ exportableFields ['source_contact_id ' ] = [
2543
+ 'title ' => ts ('Source Contact ID ' ),
2544
+ 'type ' => CRM_Utils_Type::T_INT ,
2545
+ ];
2546
+ $ exportableFields ['source_contact ' ] = array (
2547
+ 'title ' => ts ('Source Contact ' ),
2548
+ 'type ' => CRM_Utils_Type::T_STRING ,
2549
+ );
2545
2550
2546
- $ Activityfields = array (
2547
- 'activity_type ' => array (
2548
- 'title ' => ts ('Activity Type ' ),
2549
- 'name ' => 'activity_type ' ,
2550
- 'type ' => CRM_Utils_Type::T_STRING ,
2551
- 'searchByLabel ' => TRUE ,
2552
- ),
2553
- 'activity_status ' => array (
2554
- 'title ' => ts ('Activity Status ' ),
2555
- 'name ' => 'activity_status ' ,
2556
- 'type ' => CRM_Utils_Type::T_STRING ,
2557
- 'searchByLabel ' => TRUE ,
2558
- ),
2559
- 'activity_priority ' => array (
2560
- 'title ' => ts ('Activity Priority ' ),
2561
- 'name ' => 'activity_priority ' ,
2562
- 'type ' => CRM_Utils_Type::T_STRING ,
2563
- 'searchByLabel ' => TRUE ,
2564
- ),
2565
- );
2566
- $ fields = array_merge ($ Activityfields , $ exportableFields );
2567
- }
2568
- else {
2569
- // Set title to activity fields.
2570
- $ fields = array (
2571
- 'case_activity_subject ' => array ('title ' => ts ('Activity Subject ' ), 'type ' => CRM_Utils_Type::T_STRING ),
2572
- 'case_source_contact_id ' => array ('title ' => ts ('Activity Reporter ' ), 'type ' => CRM_Utils_Type::T_STRING ),
2573
- 'case_recent_activity_date ' => array ('title ' => ts ('Activity Actual Date ' ), 'type ' => CRM_Utils_Type::T_DATE ),
2574
- 'case_scheduled_activity_date ' => array (
2575
- 'title ' => ts ('Activity Scheduled Date ' ),
2576
- 'type ' => CRM_Utils_Type::T_DATE ,
2577
- ),
2578
- 'case_recent_activity_type ' => array ('title ' => ts ('Activity Type ' ), 'type ' => CRM_Utils_Type::T_STRING ),
2579
- 'case_activity_status ' => array ('title ' => ts ('Activity Status ' ), 'type ' => CRM_Utils_Type::T_STRING ),
2580
- 'case_activity_duration ' => array ('title ' => ts ('Activity Duration ' ), 'type ' => CRM_Utils_Type::T_INT ),
2581
- 'case_activity_medium_id ' => array ('title ' => ts ('Activity Medium ' ), 'type ' => CRM_Utils_Type::T_INT ),
2582
- 'case_activity_details ' => array ('title ' => ts ('Activity Details ' ), 'type ' => CRM_Utils_Type::T_TEXT ),
2583
- 'case_activity_is_auto ' => array (
2584
- 'title ' => ts ('Activity Auto-generated? ' ),
2585
- 'type ' => CRM_Utils_Type::T_BOOLEAN ,
2586
- ),
2587
- );
2588
- }
2551
+ $ Activityfields = array (
2552
+ 'activity_type ' => array (
2553
+ 'title ' => ts ('Activity Type ' ),
2554
+ 'name ' => 'activity_type ' ,
2555
+ 'type ' => CRM_Utils_Type::T_STRING ,
2556
+ 'searchByLabel ' => TRUE ,
2557
+ ),
2558
+ 'activity_status ' => array (
2559
+ 'title ' => ts ('Activity Status ' ),
2560
+ 'name ' => 'activity_status ' ,
2561
+ 'type ' => CRM_Utils_Type::T_STRING ,
2562
+ 'searchByLabel ' => TRUE ,
2563
+ ),
2564
+ 'activity_priority ' => array (
2565
+ 'title ' => ts ('Activity Priority ' ),
2566
+ 'name ' => 'activity_priority ' ,
2567
+ 'type ' => CRM_Utils_Type::T_STRING ,
2568
+ 'searchByLabel ' => TRUE ,
2569
+ ),
2570
+ );
2571
+ $ fields = array_merge ($ Activityfields , $ exportableFields );
2572
+ }
2573
+ else {
2574
+ // Set title to activity fields.
2575
+ $ fields = array (
2576
+ 'case_activity_subject ' => array ('title ' => ts ('Activity Subject ' ), 'type ' => CRM_Utils_Type::T_STRING ),
2577
+ 'case_source_contact_id ' => array ('title ' => ts ('Activity Reporter ' ), 'type ' => CRM_Utils_Type::T_STRING ),
2578
+ 'case_recent_activity_date ' => array ('title ' => ts ('Activity Actual Date ' ), 'type ' => CRM_Utils_Type::T_DATE ),
2579
+ 'case_scheduled_activity_date ' => array (
2580
+ 'title ' => ts ('Activity Scheduled Date ' ),
2581
+ 'type ' => CRM_Utils_Type::T_DATE ,
2582
+ ),
2583
+ 'case_recent_activity_type ' => array ('title ' => ts ('Activity Type ' ), 'type ' => CRM_Utils_Type::T_STRING ),
2584
+ 'case_activity_status ' => array ('title ' => ts ('Activity Status ' ), 'type ' => CRM_Utils_Type::T_STRING ),
2585
+ 'case_activity_duration ' => array ('title ' => ts ('Activity Duration ' ), 'type ' => CRM_Utils_Type::T_INT ),
2586
+ 'case_activity_medium_id ' => array ('title ' => ts ('Activity Medium ' ), 'type ' => CRM_Utils_Type::T_INT ),
2587
+ 'case_activity_details ' => array ('title ' => ts ('Activity Details ' ), 'type ' => CRM_Utils_Type::T_TEXT ),
2588
+ 'case_activity_is_auto ' => array (
2589
+ 'title ' => ts ('Activity Auto-generated? ' ),
2590
+ 'type ' => CRM_Utils_Type::T_BOOLEAN ,
2591
+ ),
2592
+ );
2593
+ }
2589
2594
2590
- // add custom data for case activities
2591
- $ fields = array_merge ($ fields , CRM_Core_BAO_CustomField::getFieldsForImport ('Activity ' ));
2595
+ // add custom data for case activities
2596
+ $ fields = array_merge ($ fields , CRM_Core_BAO_CustomField::getFieldsForImport ('Activity ' ));
2592
2597
2593
- self ::$ _exportableFields [$ name ] = $ fields ;
2594
- }
2598
+ self ::$ _exportableFields [$ name ] = $ fields ;
2595
2599
return self ::$ _exportableFields [$ name ];
2596
2600
}
2597
2601
@@ -2831,6 +2835,22 @@ public static function checkPermission($activityId, $action) {
2831
2835
return $ allow ;
2832
2836
}
2833
2837
2838
+ /**
2839
+ * Checks if user has permissions to edit inbound e-mails, either bsic info
2840
+ * or both basic information and content.
2841
+ *
2842
+ * @return bool
2843
+ */
2844
+ public function checkEditInboundEmailsPermissions () {
2845
+ if (CRM_Core_Permission::check ('edit inbound email basic information ' )
2846
+ || CRM_Core_Permission::check ('edit inbound email basic information and content ' )
2847
+ ) {
2848
+ return TRUE ;
2849
+ }
2850
+
2851
+ return FALSE ;
2852
+ }
2853
+
2834
2854
/**
2835
2855
* Wrapper for ajax activity selector.
2836
2856
*
0 commit comments