@@ -1783,16 +1783,14 @@ public static function addActivity(
1783
1783
* particular component object.
1784
1784
*
1785
1785
* @return string
1786
+ * @throws \CRM_Core_Exception
1786
1787
*/
1787
1788
public static function getActivitySubject ($ entityObj ) {
1789
+ // @todo determine the subject on the appropriate entity rather than from the activity.
1788
1790
switch ($ entityObj ->__table ) {
1789
1791
case 'civicrm_membership ' :
1790
- $ membershipType = CRM_Member_PseudoConstant::membershipType ($ entityObj ->membership_type_id );
1791
- $ subject = $ membershipType ? $ membershipType : ts ('Membership ' );
1792
-
1793
- if (is_array ($ subject )) {
1794
- $ subject = implode (", " , $ subject );
1795
- }
1792
+ $ membershipType = CRM_Core_PseudoConstant::getLabel ('CRM_Member_BAO_Membership ' , 'membership_type_id ' , $ entityObj ->membership_type_id );
1793
+ $ subject = $ membershipType ?: ts ('Membership ' );
1796
1794
1797
1795
if (!CRM_Utils_System::isNull ($ entityObj ->source )) {
1798
1796
$ subject .= " - {$ entityObj ->source }" ;
@@ -1803,7 +1801,7 @@ public static function getActivitySubject($entityObj) {
1803
1801
$ subject .= sprintf (' (by %s) ' , $ displayName );
1804
1802
}
1805
1803
1806
- $ subject .= " - Status: " . CRM_Core_DAO:: getFieldValue ( ' CRM_Member_DAO_MembershipStatus ' , $ entityObj ->status_id , ' label ' );
1804
+ $ subject .= ' - Status: ' . CRM_Core_PseudoConstant:: getLabel ( ' CRM_Member_BAO_Membership ' , ' status_id ' , $ entityObj ->status_id );
1807
1805
return $ subject ;
1808
1806
1809
1807
case 'civicrm_participant ' :
@@ -2132,91 +2130,75 @@ public static function exportableFields($name = 'Activity') {
2132
2130
self ::$ _exportableFields [$ name ] = [];
2133
2131
2134
2132
// TODO: ideally we should retrieve all fields from xml, in this case since activity processing is done
2135
- // my case hence we have defined fields as case_*
2136
- if ($ name === 'Activity ' ) {
2137
- $ exportableFields = CRM_Activity_DAO_Activity::export ();
2138
- $ exportableFields ['source_contact_id ' ] = [
2139
- 'title ' => ts ('Source Contact ID ' ),
2140
- 'type ' => CRM_Utils_Type::T_INT ,
2141
- ];
2142
- $ exportableFields ['source_contact ' ] = [
2143
- 'title ' => ts ('Source Contact ' ),
2133
+ $ exportableFields = CRM_Activity_DAO_Activity::export ();
2134
+ $ exportableFields ['source_contact_id ' ] = [
2135
+ 'title ' => ts ('Source Contact ID ' ),
2136
+ 'type ' => CRM_Utils_Type::T_INT ,
2137
+ ];
2138
+ $ exportableFields ['source_contact ' ] = [
2139
+ 'title ' => ts ('Source Contact ' ),
2140
+ 'type ' => CRM_Utils_Type::T_STRING ,
2141
+ ];
2142
+
2143
+ // @todo - remove these - they are added by CRM_Core_DAO::appendPseudoConstantsToFields
2144
+ // below. That search label stuff is referenced in search builder but is likely just
2145
+ // a hack that duplicates, maybe differently, other functionality.
2146
+ $ activityFields = [
2147
+ 'activity_type ' => [
2148
+ 'title ' => ts ('Activity Type ' ),
2149
+ 'name ' => 'activity_type ' ,
2144
2150
'type ' => CRM_Utils_Type::T_STRING ,
2145
- ];
2151
+ 'searchByLabel ' => TRUE ,
2152
+ ],
2153
+ 'activity_status ' => [
2154
+ 'title ' => ts ('Activity Status ' ),
2155
+ 'name ' => 'activity_status ' ,
2156
+ 'type ' => CRM_Utils_Type::T_STRING ,
2157
+ 'searchByLabel ' => TRUE ,
2158
+ ],
2159
+ 'activity_priority ' => [
2160
+ 'title ' => ts ('Activity Priority ' ),
2161
+ 'name ' => 'activity_priority ' ,
2162
+ 'type ' => CRM_Utils_Type::T_STRING ,
2163
+ 'searchByLabel ' => TRUE ,
2164
+ ],
2165
+ ];
2166
+ $ fields = array_merge ($ activityFields , $ exportableFields );
2167
+ $ fields ['activity_type_id ' ]['title ' ] = ts ('Activity Type ID ' );
2168
+ $ fields ['activity_priority_id ' ] = $ fields ['priority_id ' ];
2146
2169
2147
- // @todo - remove these - they are added by CRM_Core_DAO::appendPseudoConstantsToFields
2148
- // below. That search label stuff is referenced in search builder but is likely just
2149
- // a hack that duplicates, maybe differently, other functionality.
2150
- $ Activityfields = [
2151
- 'activity_type ' => [
2152
- 'title ' => ts ('Activity Type ' ),
2153
- 'name ' => 'activity_type ' ,
2154
- 'type ' => CRM_Utils_Type::T_STRING ,
2155
- 'searchByLabel ' => TRUE ,
2156
- ],
2157
- 'activity_status ' => [
2158
- 'title ' => ts ('Activity Status ' ),
2159
- 'name ' => 'activity_status ' ,
2160
- 'type ' => CRM_Utils_Type::T_STRING ,
2161
- 'searchByLabel ' => TRUE ,
2162
- ],
2163
- 'activity_priority ' => [
2164
- 'title ' => ts ('Activity Priority ' ),
2165
- 'name ' => 'activity_priority ' ,
2166
- 'type ' => CRM_Utils_Type::T_STRING ,
2167
- 'searchByLabel ' => TRUE ,
2168
- ],
2169
- ];
2170
- $ fields = array_merge ($ Activityfields , $ exportableFields );
2171
- $ fields ['activity_type_id ' ]['title ' ] = ts ('Activity Type ID ' );
2172
- }
2173
- else {
2170
+ if ($ name === 'Case ' ) {
2171
+ // Now add "case_activity" fields
2174
2172
// Set title to activity fields.
2175
- $ fields = [
2176
- 'case_activity_subject ' => [
2177
- 'title ' => ts ('Activity Subject ' ),
2178
- 'type ' => CRM_Utils_Type::T_STRING ,
2179
- ],
2173
+ $ caseActivityFields = [
2180
2174
'case_source_contact_id ' => [
2181
2175
'title ' => ts ('Activity Reporter ' ),
2182
2176
'type ' => CRM_Utils_Type::T_STRING ,
2183
2177
],
2184
- 'case_recent_activity_date ' => [
2185
- 'title ' => ts ('Activity Actual Date ' ),
2178
+ 'case_activity_date_time ' => [
2179
+ 'title ' => ts ('Activity Date ' ),
2186
2180
'type ' => CRM_Utils_Type::T_DATE ,
2187
2181
],
2188
- 'case_scheduled_activity_date ' => [
2189
- 'title ' => ts ('Activity Scheduled Date ' ),
2190
- 'type ' => CRM_Utils_Type::T_DATE ,
2191
- ],
2192
- 'case_recent_activity_type ' => [
2182
+ 'case_activity_type ' => [
2193
2183
'title ' => ts ('Activity Type ' ),
2194
2184
'type ' => CRM_Utils_Type::T_STRING ,
2195
2185
],
2196
- 'case_activity_status ' => [
2197
- 'title ' => ts ('Activity Status ' ),
2198
- 'type ' => CRM_Utils_Type::T_STRING ,
2199
- ],
2200
- 'case_activity_duration ' => [
2201
- 'title ' => ts ('Activity Duration ' ),
2202
- 'type ' => CRM_Utils_Type::T_INT ,
2203
- ],
2204
2186
'case_activity_medium_id ' => [
2205
2187
'title ' => ts ('Activity Medium ' ),
2206
2188
'type ' => CRM_Utils_Type::T_INT ,
2207
2189
],
2208
- 'case_activity_details ' => [
2209
- 'title ' => ts ('Activity Details ' ),
2210
- 'type ' => CRM_Utils_Type::T_TEXT ,
2211
- ],
2212
2190
'case_activity_is_auto ' => [
2213
2191
'title ' => ts ('Activity Auto-generated? ' ),
2214
2192
'type ' => CRM_Utils_Type::T_BOOLEAN ,
2215
2193
],
2216
2194
];
2195
+ $ caseStandardFields = ['activity_subject ' , 'activity_status ' , 'activity_duration ' , 'activity_details ' ];
2196
+ foreach ($ caseStandardFields as $ key ) {
2197
+ $ caseActivityFields ['case_ ' . $ key ] = $ fields [$ key ];
2198
+ }
2199
+ $ fields = $ caseActivityFields ;
2217
2200
}
2218
-
2219
- // add custom data for case activities
2201
+ // Add custom data
2220
2202
$ fields = array_merge ($ fields , CRM_Core_BAO_CustomField::getFieldsForImport ('Activity ' ));
2221
2203
CRM_Core_DAO::appendPseudoConstantsToFields ($ fields );
2222
2204
self ::$ _exportableFields [$ name ] = $ fields ;
@@ -2455,6 +2437,7 @@ protected static function getPermittedActivityTypes() {
2455
2437
foreach ($ types as $ type ) {
2456
2438
$ permittedActivityTypes [$ type ['activity_type_id ' ]] = (int ) $ type ['activity_type_id ' ];
2457
2439
}
2440
+ asort ($ permittedActivityTypes );
2458
2441
Civi::$ statics [__CLASS__ ]['permitted_activity_types ' ][$ userID ] = $ permittedActivityTypes ;
2459
2442
}
2460
2443
return Civi::$ statics [__CLASS__ ]['permitted_activity_types ' ][$ userID ];
0 commit comments