Skip to content

Commit 9c2b620

Browse files
committed
Update to CiviCRM 5.3.1. This release includes important securty fixes, a number of bug fixes and improvements, including database changes.
Make sure you backup using Pantheon's database backup tool first. Then either go to http://<your_drupal_home>/civicrm/upgrade?reset=1 or use terminus drush site.env civicrm-upgrade-db Fully test on a dev environment before upgrading on live. Don't merge this code yet if you've got other updates which are urgent. If you have questions contact http://civicrmstarterkit.org/contact. We provide some basic general support for the public. If you require help with your specific website there will likely be a cost.
1 parent 542eaff commit 9c2b620

File tree

1,747 files changed

+27789
-23072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,747 files changed

+27789
-23072
lines changed

profiles/civicrm_starterkit/civicrm_starterkit.make

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ projects[drupal][version] = "7.51"
1313
; ====== CIVICRM RELATED =========
1414

1515
libraries[civicrm][download][type] = get
16-
libraries[civicrm][download][url] = "https://download.civicrm.org/civicrm-5.2.1-drupal.tar.gz"
16+
libraries[civicrm][download][url] = "https://download.civicrm.org/civicrm-5.3.1-drupal.tar.gz"
1717
libraries[civicrm][destination] = modules
1818
libraries[civicrm][directory_name] = civicrm
1919

profiles/civicrm_starterkit/modules/civicrm/CRM/Activity/BAO/Activity.php

+68-44
Original file line numberDiff line numberDiff line change
@@ -676,13 +676,11 @@ public static function logActivityAction($activity, $logMessage = NULL) {
676676
*
677677
* @return array|int
678678
* Relevant data object values of open activities
679+
* @throws \CiviCRM_API3_Exception
679680
*/
680681
public static function getActivities($params, $getCount = FALSE) {
681682
$activities = array();
682683

683-
// fetch all active activity types
684-
$activityTypes = CRM_Core_OptionGroup::values('activity_type');
685-
686684
// Activity.Get API params
687685
$activityParams = array(
688686
'is_deleted' => 0,
@@ -711,37 +709,11 @@ public static function getActivities($params, $getCount = FALSE) {
711709
),
712710
);
713711

714-
// activity type ID clause
715-
if (!empty($params['activity_type_id'])) {
716-
if (is_array($params['activity_type_id'])) {
717-
foreach ($params['activity_type_id'] as $idx => $value) {
718-
$params['activity_type_id'][$idx] = CRM_Utils_Type::escape($value, 'Positive');
719-
}
720-
$activityParams['activity_type_id'] = array('IN' => $params['activity_type_id']);
721-
}
722-
else {
723-
$activityParams['activity_type_id'] = CRM_Utils_Type::escape($params['activity_type_id'], 'Positive');
724-
}
725-
}
726-
elseif (!empty($activityTypes) && count($activityTypes)) {
727-
$activityParams['activity_type_id'] = array('IN' => array_keys($activityTypes));
728-
}
729-
730712
if (!empty($params['activity_status_id'])) {
731713
$activityParams['activity_status_id'] = array('IN' => explode(',', $params['activity_status_id']));
732714
}
733715

734-
$excludeActivityIDs = array();
735-
if (!empty($params['activity_type_exclude_id'])) {
736-
if (is_array($params['activity_type_exclude_id'])) {
737-
foreach ($params['activity_type_exclude_id'] as $idx => $value) {
738-
$excludeActivityIDs[$idx] = CRM_Utils_Type::escape($value, 'Positive');
739-
}
740-
}
741-
else {
742-
$excludeActivityIDs[] = CRM_Utils_Type::escape($params['activity_type_exclude_id'], 'Positive');
743-
}
744-
}
716+
$activityParams['activity_type_id'] = self::filterActivityTypes($params);
745717

746718
if (!empty($params['rowCount']) &&
747719
$params['rowCount'] > 0
@@ -771,8 +743,8 @@ public static function getActivities($params, $getCount = FALSE) {
771743
$result = civicrm_api3('Activity', 'Get', $activityParams);
772744

773745
$enabledComponents = self::activityComponents();
746+
$bulkActivityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Bulk Email');
774747
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
775-
$bulkActivityTypeID = CRM_Core_PseudoConstant::getKey(__CLASS__, 'activity_type_id', 'Bulk Email');
776748

777749
// CRM-3553, need to check user has access to target groups.
778750
$mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs();
@@ -797,9 +769,7 @@ public static function getActivities($params, $getCount = FALSE) {
797769

798770
foreach ($result['values'] as $id => $activity) {
799771
// skip case activities if CiviCase is not enabled OR those actvities which are
800-
if ((!empty($activity['case_id']) && !in_array('CiviCase', $enabledComponents)) ||
801-
(count($excludeActivityIDs) && in_array($activity['activity_type_id'], $excludeActivityIDs))
802-
) {
772+
if (!empty($activity['case_id']) && !in_array('CiviCase', $enabledComponents)) {
803773
continue;
804774
}
805775

@@ -840,7 +810,7 @@ public static function getActivities($params, $getCount = FALSE) {
840810
else {
841811
$activities[$id][$expectedName] = CRM_Utils_Array::value($apiKey, $activity);
842812
if ($apiKey == 'activity_type_id') {
843-
$activities[$id]['activity_type'] = CRM_Utils_Array::value($activities[$id][$expectedName], $activityTypes);
813+
$activities[$id]['activity_type'] = CRM_Core_PseudoConstant::getName('CRM_Activity_BAO_Activity', 'activity_type_id', $activities[$id][$expectedName]);
844814
}
845815
elseif ($apiKey == 'campaign_id') {
846816
$activities[$id]['campaign'] = CRM_Utils_Array::value($activities[$id][$expectedName], $allCampaigns);
@@ -859,6 +829,60 @@ public static function getActivities($params, $getCount = FALSE) {
859829
return $getCount ? count($activities) : $activities;
860830
}
861831

832+
/**
833+
* Filter the activity types to only return the ones we actually asked for
834+
* Uses params['activity_type_id'] and params['activity_type_exclude_id']
835+
*
836+
* @param $params
837+
* @return array|null (Use in Activity.get API activity_type_id)
838+
*/
839+
public static function filterActivityTypes($params) {
840+
$activityTypes = array();
841+
842+
// If no activity types are specified, get all the active ones
843+
if (empty($params['activity_type_id'])) {
844+
$activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'get');
845+
}
846+
847+
// If no activity types are specified or excluded, return the list of all active ones
848+
if (empty($params['activity_type_id']) && empty($params['activity_type_exclude_id'])) {
849+
if (!empty($activityTypes)) {
850+
return array('IN' => array_keys($activityTypes));
851+
}
852+
return NULL;
853+
}
854+
855+
// If we have specified activity types, build a list to return, excluding the ones we don't want.
856+
if (!empty($params['activity_type_id'])) {
857+
if (!is_array($params['activity_type_id'])) {
858+
// Turn it into array if only one specified, so we don't duplicate processing below
859+
$params['activity_type_id'] = array($params['activity_type_id'] => $params['activity_type_id']);
860+
}
861+
foreach ($params['activity_type_id'] as $value) {
862+
// Add each activity type that was specified to list
863+
$value = CRM_Utils_Type::escape($value, 'Positive');
864+
$activityTypes[$value] = $value;
865+
}
866+
}
867+
868+
// Build the list of activity types to exclude (from $params['activity_type_exclude_id'])
869+
if (!empty($params['activity_type_exclude_id'])) {
870+
if (!is_array($params['activity_type_exclude_id'])) {
871+
// Turn it into array if only one specified, so we don't duplicate processing below
872+
$params['activity_type_exclude_id'] = array($params['activity_type_exclude_id'] => $params['activity_type_exclude_id']);
873+
}
874+
foreach ($params['activity_type_exclude_id'] as $value) {
875+
// Remove each activity type from list if it should be excluded
876+
$value = CRM_Utils_Type::escape($value, 'Positive');
877+
if (array_key_exists($value, $activityTypes)) {
878+
unset($activityTypes[$value]);
879+
}
880+
}
881+
}
882+
883+
return array('IN' => array_keys($activityTypes));
884+
}
885+
862886
/**
863887
* Get the list Activities.
864888
*
@@ -1181,6 +1205,8 @@ public static function getActivitiesCount($input) {
11811205
/**
11821206
* Get the activity Count.
11831207
*
1208+
* @deprecated
1209+
*
11841210
* @param array $input
11851211
* Array of parameters.
11861212
* Keys include
@@ -1216,6 +1242,8 @@ public static function deprecatedGetActivitiesCount($input) {
12161242
/**
12171243
* Get the activity sql clause to pick activities.
12181244
*
1245+
* @deprecated
1246+
*
12191247
* @param array $input
12201248
* Array of parameters.
12211249
* Keys include
@@ -1476,9 +1504,7 @@ public static function sendEmail(
14761504
}
14771505

14781506
//create the meta level record first ( email activity )
1479-
$activityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id',
1480-
'Email'
1481-
);
1507+
$activityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Email');
14821508

14831509
// CRM-6265: save both text and HTML parts in details (if present)
14841510
if ($html and $text) {
@@ -1496,7 +1522,7 @@ public static function sendEmail(
14961522
'subject' => $subject,
14971523
'details' => $details,
14981524
// FIXME: check for name Completed and get ID from that lookup
1499-
'status_id' => 2,
1525+
'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Completed'),
15001526
'campaign_id' => $campaignId,
15011527
);
15021528

@@ -2095,7 +2121,8 @@ public static function addActivity(
20952121
}
20962122
elseif ($activity->__table == 'civicrm_contribution') {
20972123
// create activity record only for Completed Contributions
2098-
if ($activity->contribution_status_id != 1) {
2124+
$contributionCompletedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
2125+
if ($activity->contribution_status_id != $contributionCompletedStatusId) {
20992126
return NULL;
21002127
}
21012128
$activityType = $component = 'Contribution';
@@ -2383,10 +2410,7 @@ public static function createFollowupActivity($activityId, $params) {
23832410
$followupParams = array();
23842411
$followupParams['parent_id'] = $activityId;
23852412
$followupParams['source_contact_id'] = CRM_Core_Session::getLoggedInContactID();
2386-
$followupParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity',
2387-
'activity_status_id',
2388-
'Scheduled'
2389-
);
2413+
$followupParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Scheduled');
23902414

23912415
$followupParams['activity_type_id'] = $params['followup_activity_type_id'];
23922416
// Get Subject of Follow-up Activiity, CRM-4491

profiles/civicrm_starterkit/modules/civicrm/CRM/Activity/BAO/Query.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ public static function whereClauseSingle(&$values, &$query) {
318318

319319
case 'activity_result':
320320
if (is_array($value)) {
321-
$safe = NULL;
322-
while (list(, $k) = each($value)) {
321+
$safe = [];
322+
foreach ($values as $id => $k) {
323323
$safe[] = "'" . CRM_Utils_Type::escape($k, 'String') . "'";
324324
}
325325
$query->_where[$grouping][] = "civicrm_activity.result IN (" . implode(',', $safe) . ")";
@@ -505,7 +505,7 @@ public static function buildSearchForm(&$form) {
505505
if ($name) {
506506
$value = CRM_Core_OptionGroup::values($name);
507507
if (!empty($value)) {
508-
while (list($k, $v) = each($value)) {
508+
foreach ($value as $k => $v) {
509509
$resultOptions[$v] = $v;
510510
}
511511
}

profiles/civicrm_starterkit/modules/civicrm/CRM/Activity/Form/Activity.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function preProcess() {
255255

256256
// Give the context.
257257
if (!isset($this->_context)) {
258-
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
258+
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
259259
if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
260260
$this->_context = 'search';
261261
}

profiles/civicrm_starterkit/modules/civicrm/CRM/Activity/Form/ActivityView.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CRM_Activity_Form_ActivityView extends CRM_Core_Form {
4242
public function preProcess() {
4343
// Get the activity values.
4444
$activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
45-
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
45+
$context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
4646
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
4747

4848
// Check for required permissions, CRM-6264.

profiles/civicrm_starterkit/modules/civicrm/CRM/Activity/Form/Search.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function preProcess() {
8787
$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean');
8888
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
8989
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
90-
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'search');
90+
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'search');
9191

9292
$this->assign("context", $this->_context);
9393

profiles/civicrm_starterkit/modules/civicrm/CRM/Activity/Page/Tab.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function browse() {
6363
*/
6464
public function edit() {
6565
// used for ajax tabs
66-
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
66+
$context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
6767
$this->assign('context', $context);
6868

6969
$this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this);
@@ -159,7 +159,7 @@ public function delete() {
159159
* Perform actions and display for activities.
160160
*/
161161
public function run() {
162-
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
162+
$context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
163163
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
164164
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
165165
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);

profiles/civicrm_starterkit/modules/civicrm/CRM/Admin/Form/MessageTemplates.php

+21
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function buildQuickForm() {
106106
}
107107
else {
108108
$this->_workflow_id = CRM_Utils_Array::value('workflow_id', $this->_values);
109+
$this->checkUserPermission($this->_workflow_id);
109110
$this->assign('workflow_id', $this->_workflow_id);
110111

111112
if ($this->_workflow_id) {
@@ -214,6 +215,26 @@ public function buildQuickForm() {
214215
}
215216
}
216217

218+
/**
219+
* Restrict users access based on permission
220+
*
221+
* @param int $workflowId
222+
*/
223+
private function checkUserPermission($workflowId) {
224+
if (isset($workflowId)) {
225+
$canView = CRM_Core_Permission::check('edit system workflow message templates');
226+
}
227+
else {
228+
$canView = CRM_Core_Permission::check('edit user-driven message templates');
229+
}
230+
231+
if (!$canView && !CRM_Core_Permission::check('edit message templates')) {
232+
CRM_Core_Session::setStatus(ts('You do not have permission to view requested page.'), ts('Access Denied'));
233+
$url = CRM_Utils_System::url('civicrm/admin/messageTemplates', "reset=1");
234+
CRM_Utils_System::redirect($url);
235+
}
236+
}
237+
217238
/**
218239
* Global form rule.
219240
*

profiles/civicrm_starterkit/modules/civicrm/CRM/Admin/Form/Options.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function setDefaultValues() {
129129
}
130130
}
131131

132-
//setDefault of contact types for email greeting, postal greeting, addressee, CRM-4575
132+
// setDefault of contact types for email greeting, postal greeting, addressee, CRM-4575
133133
if (in_array($this->_gName, array(
134134
'email_greeting',
135135
'postal_greeting',
@@ -302,7 +302,7 @@ public function buildQuickForm() {
302302
$enabled->freeze();
303303
}
304304

305-
//fix for CRM-3552, CRM-4575
305+
// fix for CRM-3552, CRM-4575
306306
$showIsDefaultGroups = array(
307307
'email_greeting',
308308
'postal_greeting',
@@ -322,7 +322,7 @@ public function buildQuickForm() {
322322
$this->add('checkbox', 'is_default', ts('Default Option?'));
323323
}
324324

325-
//get contact type for which user want to create a new greeting/addressee type, CRM-4575
325+
// get contact type for which user want to create a new greeting/addressee type, CRM-4575
326326
if (in_array($this->_gName, array(
327327
'email_greeting',
328328
'postal_greeting',
@@ -341,7 +341,7 @@ public function buildQuickForm() {
341341

342342
if ($this->_gName == 'participant_status') {
343343
// For Participant Status options, expose the 'filter' field to track which statuses are "Counted", and the Visibility field
344-
$element = $this->add('checkbox', 'filter', ts('Counted?'));
344+
$this->add('checkbox', 'filter', ts('Counted?'));
345345
$this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility());
346346
}
347347
if ($this->_gName == 'participant_role') {
@@ -364,6 +364,7 @@ public function buildQuickForm() {
364364
*
365365
* @return array
366366
* array of errors / empty array.
367+
* @throws \CRM_Core_Exception
367368
*/
368369
public static function formRule($fields, $files, $self) {
369370
$errors = array();
@@ -406,7 +407,7 @@ public static function formRule($fields, $files, $self) {
406407
$dataType = self::getOptionGroupDataType($self->_gName);
407408
if ($dataType && $self->_gName !== 'activity_type') {
408409
$validate = CRM_Utils_Type::validate($fields['value'], $dataType, FALSE);
409-
if (!$validate) {
410+
if ($validate === FALSE) {
410411
CRM_Core_Session::setStatus(
411412
ts('Data Type of the value field for this option value does not match ' . $dataType),
412413
ts('Value field Data Type mismatch'));
@@ -435,7 +436,7 @@ public static function getOptionGroupDataType($optionGroupName) {
435436
public function postProcess() {
436437
if ($this->_action & CRM_Core_Action::DELETE) {
437438
$fieldValues = array('option_group_id' => $this->_gid);
438-
$wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
439+
CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
439440

440441
if (CRM_Core_BAO_OptionValue::del($this->_id)) {
441442
if ($this->_gName == 'phone_type') {
@@ -450,7 +451,6 @@ public function postProcess() {
450451
}
451452
}
452453
else {
453-
$ids = array();
454454
$params = $this->exportValues();
455455

456456
// allow multiple defaults within group.

0 commit comments

Comments
 (0)