Commit 25979aeb authored by Michael McAndrew's avatar Michael McAndrew
Browse files

upgrade to 4.3.4 (security release)

parent e15f65c0
......@@ -153,27 +153,16 @@ class CRM_Activity_BAO_Query {
* @access public
*/
static function where(&$query) {
$grouping = $testCondition = NULL;
$grouping = NULL;
foreach (array_keys($query->_params) as $id) {
if (substr($query->_params[$id][0], 0, 9) == 'activity_') {
if ($query->_mode == CRM_Contact_BAO_QUERY::MODE_CONTACTS) {
$query->_useDistinct = TRUE;
}
if ($query->_params[$id][0] == 'activity_test') {
$testCondition = $id;
continue;
}
$grouping = $query->_params[$id][3];
self::whereClauseSingle($query->_params[$id], $query);
}
}
// Only add test condition if other fields are selected
if ($grouping !== NULL && $testCondition &&
// we dont want to include all tests for sql OR CRM-7827
$query->getOperator() != 'OR'
) {
self::whereClauseSingle($query->_params[$testCondition], $query);
}
}
/**
......@@ -306,9 +295,12 @@ class CRM_Activity_BAO_Query {
break;
case 'activity_test':
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.is_test", $op, $value, "Boolean");
if ($value) {
$query->_qill[$grouping][] = ts('Activity is a Test');
// We dont want to include all tests for sql OR CRM-7827
if (!$value || $query->getOperator() != 'OR') {
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.is_test", $op, $value, "Boolean");
if ($value) {
$query->_qill[$grouping][] = ts('Activity is a Test');
}
}
break;
......@@ -525,8 +517,8 @@ class CRM_Activity_BAO_Query {
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, FALSE, TRUE);
$surveys = CRM_Campaign_BAO_Survey::getSurveys();
if ($surveys) $form->add('select', 'activity_survey_id', ts('Survey'),
$surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE);
if ($surveys) $form->add('select', 'activity_survey_id', ts('Survey / Petition'),
array(
'' => ts('- none -')) + $surveys, FALSE
);
......
......@@ -50,6 +50,13 @@ class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO
* @static
*/
static $_fields = null;
/**
* static instance to hold the keys used in $_fields for each field.
*
* @var array
* @static
*/
static $_fieldKeys = null;
/**
* static instance to hold the FK relationships
*
......@@ -177,6 +184,25 @@ class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO
}
return self::$_fields;
}
/**
* Returns an array containing, for each field, the arary key used for that
* field in self::$_fields.
*
* @access public
* @return array
*/
static function &fieldKeys()
{
if (!(self::$_fieldKeys)) {
self::$_fieldKeys = array(
'id' => 'id',
'activity_id' => 'activity_id',
'contact_id' => 'contact_id',
'record_type_id' => 'record_type_id',
);
}
return self::$_fieldKeys;
}
/**
* returns the names of this table
*
......
......@@ -255,8 +255,6 @@ class CRM_Activity_Form_Search extends CRM_Core_Form {
}
}
$total = $cancel = 0;
$permission = CRM_Core_Permission::getPermission();
$tasks = array('' => ts('- actions -')) + CRM_Activity_Task::permissionedTaskTitles($permission);
......@@ -328,17 +326,12 @@ class CRM_Activity_Form_Search extends CRM_Core_Form {
// if we are editing / running a saved search and the form has not been posted
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
}
if (CRM_Utils_Array::value('activity_survey_id', $this->_formValues)) {
// if the user has choosen a survey but not any activity type, we force the activity type
$sid = CRM_Utils_Array::value('activity_survey_id', $this->_formValues);
$activity_type_id = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $sid, 'activity_type_id');
$this->_formValues['activity_type_id'][$activity_type_id] = 1;
}
if (!CRM_Utils_Array::value('activity_test', $this->_formValues)) {
// We don't show test records in summaries or dashboards
if (empty($this->_formValues['activity_test']) && $this->_force) {
$this->_formValues["activity_test"] = 0;
}
if (!CRM_Utils_Array::value('activity_contact_name', $this->_formValues) && !CRM_Utils_Array::value('contact_id', $this->_formValues)) {
$this->_formValues['activity_role'] = NULL;
}
......@@ -399,51 +392,6 @@ class CRM_Activity_Form_Search extends CRM_Core_Form {
$controller->run();
}
/**
* This function is used to add the rules (mainly global rules) for form.
* All local rules are added near the element
*
* @return None
* @access public
* @see valid_date
*/
function addRules() {
$this->addFormRule(array('CRM_Activity_Form_Search', 'formRule'));
}
/**
* global validation rules for the form
*
* @param array $fields posted values of the form
* @param array $errors list of errors to be posted back to the form
*
* @return void
* @static
* @access public
*/
static function formRule($fields) {
$errors = array();
if (!empty($errors)) {
return $errors;
}
return TRUE;
}
/**
* Set the default form values
*
* @access protected
*
* @return array the default array reference
*/
function setDefaultValues() { // TODO test?
$defaults = array();
$defaults = $this->_formValues;
return $defaults;
}
function fixFormValues() {
if (!$this->_force) {
return;
......@@ -454,11 +402,15 @@ class CRM_Activity_Form_Search extends CRM_Core_Form {
$this->_defaults['activity_status'] = $status;
}
$survey = CRM_Utils_Request::retrieve('survey', 'Positive',
CRM_Core_DAO::$_nullObject
);
$survey = CRM_Utils_Request::retrieve('survey', 'Positive', CRM_Core_DAO::$_nullObject);
if ($survey) {
$this->_formValues['activity_survey_id'] = $survey;
$this->_formValues['activity_survey_id'] = $this->_defaults['activity_survey_id'] = $survey;
$sid = CRM_Utils_Array::value('activity_survey_id', $this->_formValues);
$activity_type_id = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $sid, 'activity_type_id');
$this->_formValues['activity_type_id'][$activity_type_id] = 1;
$this->_defaults['activity_type_id'][$activity_type_id] = 1;
}
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
......@@ -473,13 +425,17 @@ class CRM_Activity_Form_Search extends CRM_Core_Form {
$this->_formValues['activity_role'] = $activity_role;
}
else {
list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid);
$this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
}
// also assign individual mode to the template
$this->_single = TRUE;
}
}
if (!empty($this->_defaults)) {
$this->setDefaults($this->_defaults);
}
}
function getFormValues() {
......
......@@ -426,14 +426,14 @@ abstract class CRM_Activity_Import_Parser {
}
}
/*function setActiveFieldLocationTypes( $elements )
/*function setActiveFieldLocationTypes( $elements )
{
for ($i = 0; $i < count( $elements ); $i++) {
$this->_activeFields[$i]->_hasLocationType = $elements[$i];
}
}
function setActiveFieldPhoneTypes( $elements )
function setActiveFieldPhoneTypes( $elements )
{
for ($i = 0; $i < count( $elements ); $i++) {
$this->_activeFields[$i]->_phoneType = $elements[$i];
......@@ -634,7 +634,7 @@ abstract class CRM_Activity_Import_Parser {
}
foreach ($values as $k => $v) {
$values[$k] = preg_replace("/^$enclosure(.*) $enclosure$/", '$1', $v);
$values[$k] = preg_replace("/^$enclosure(.*)$enclosure$/", '$1', $v);
}
}
......
......@@ -209,11 +209,13 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
elseif ($activityTypeName == 'Print PDF Letter') {
$updateUrl = 'civicrm/activity/pdf/add';
}
$actionLinks += array(CRM_Core_Action::UPDATE => array('name' => ts('Edit'),
'url' => $updateUrl,
'qs' => $qsUpdate,
'title' => ts('Update Activity'),
));
if ( CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::UPDATE) ) {
$actionLinks += array(CRM_Core_Action::UPDATE => array('name' => ts('Edit'),
'url' => $updateUrl,
'qs' => $qsUpdate,
'title' => ts('Update Activity'),
));
}
}
if (
......
......@@ -110,10 +110,13 @@ class CRM_Activity_Task {
$config = CRM_Core_Config::singleton();
if (in_array('CiviCase', $config->enableComponents)) {
self::$_tasks[6] = array('title' => ts('File on Case'),
'class' => 'CRM_Activity_Form_Task_FileOnCase',
'result' => FALSE,
);
if ( CRM_Core_Permission::check('access all cases and activities') ||
CRM_Core_Permission::check('access my cases and activities') ) {
self::$_tasks[6] = array('title' => ts('File on Case'),
'class' => 'CRM_Activity_Form_Task_FileOnCase',
'result' => FALSE,
);
}
}
//CRM-4418, check for delete
......
......@@ -37,7 +37,9 @@
*
*/
class CRM_Admin_Form_Job extends CRM_Admin_Form {
protected $_id = NULL; function preProcess() {
protected $_id = NULL;
function preProcess() {
parent::preProcess();
......
......@@ -40,7 +40,9 @@
*/
class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form {
// which (and whether) mailing workflow this template belongs to
protected $_workflow_id = NULL; function preProcess() {
protected $_workflow_id = NULL;
function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String',
$this, FALSE, 'add'
......
......@@ -163,17 +163,16 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
break;
case 'textarea':
$this->addElement('textarea',
case 'checkbox':
$this->add($fieldValue['html_type'],
$fieldName,
$fieldValue['title']
);
break;
case 'checkbox':
$this->addElement('checkbox',
$fieldName,
$fieldValue['title']
);
case 'radio':
$options = CRM_Core_OptionGroup::values($fieldName, FALSE, FALSE, TRUE);
$this->addRadio($fieldName, $fieldValue['title'], $options, NULL, '&nbsp;&nbsp;');
break;
case 'checkboxes':
......@@ -264,6 +263,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
case 'text':
case 'select':
case 'radio':
$this->_config->$settingName = CRM_Utils_Array::value($settingName, $this->_params);
break;
......
......@@ -42,7 +42,9 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
CRM_Utils_System::setTitle(ts('Settings - Display Preferences'));
if (defined('CIVICRM_ACTIVITY_ASSIGNEE_MAIL') && CIVICRM_ACTIVITY_ASSIGNEE_MAIL) {
CRM_Core_Session::setStatus(ts('Your civicrm.settings.php file contains CIVICRM_ACTIVITY_ASSIGNEE_MAIL but this constant is no longer used. Please remove this from your config file and set your "Notify Activity Assignees" preference below.'), ts("Deprecated Constant"), "alert");
CRM_Core_Session::setStatus(ts('Your civicrm.settings.php file contains CIVICRM_ACTIVITY_ASSIGNEE_MAIL but this
constant is no longer used. Please remove this from your config file and set your "Notify Activity Assignees"
preference below.'), ts("Deprecated Constant"), "alert");
}
$this->_varNames = array(
......@@ -53,15 +55,20 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
'title' => ts('Viewing Contacts'),
'weight' => 1,
),
'contact_smart_group_display' => array(
'html_type' => 'radio',
'title' => ts('Viewing Smart Groups'),
'weight' => 2,
),
'contact_edit_options' => array(
'html_type' => 'checkboxes',
'title' => ts('Editing Contacts'),
'weight' => 2,
'weight' => 3,
),
'advanced_search_options' => array(
'html_type' => 'checkboxes',
'title' => ts('Contact Search'),
'weight' => 3,
'weight' => 4,
),
'activity_assignee_notification' => array(
'html_type' => 'checkbox',
......@@ -71,36 +78,35 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
'activity_assignee_notification_ics' => array(
'html_type' => 'checkbox',
'title' => ts('Include ICal Invite to Activity Assignees'),
'weight' => 5,
'weight' => 6,
),
'contact_ajax_check_similar' => array(
'html_type' => 'checkbox',
'title' => ts('Check for Similar Contacts'),
'weight' => 5,
'weight' => 7,
),
'user_dashboard_options' => array(
'html_type' => 'checkboxes',
'title' => ts('Contact Dashboard'),
'weight' => 6,
'weight' => 8,
),
'display_name_format' => array(
'html_type' => 'textarea',
'title' => ts('Individual Display Name Format'),
'weight' => 7,
'weight' => 9,
),
'sort_name_format' => array(
'html_type' => 'textarea',
'title' => ts('Individual Sort Name Format'),
'weight' => 8,
'weight' => 10,
),
'editor_id' => array(
'html_type' => NULL,
'weight' => 9,
'weight' => 11,
),
),
);
parent::preProcess();
}
......@@ -112,7 +118,8 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
$defaults['editor_id'] = $this->_config->editor_id;
}
if (empty($this->_config->display_name_format)) {
$defaults['display_name_format'] = "{contact.individual_prefix}{ }{contact.first_name}{ }{contact.last_name}{ }{contact.individual_suffix}";
$defaults['display_name_format'] =
"{contact.individual_prefix}{ }{contact.first_name}{ }{contact.last_name}{ }{contact.individual_suffix}";
}
else {
$defaults['display_name_format'] = $this->_config->display_name_format;
......@@ -126,9 +133,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
}
$config = CRM_Core_Config::singleton();
if ($config->userSystem->is_drupal == '1' &&
module_exists("wysiwyg")
) {
if ($config->userSystem->is_drupal == '1' && module_exists("wysiwyg")) {
$defaults['wysiwyg_input_format'] = variable_get('civicrm_wysiwyg_input_format', 0);
}
......@@ -142,7 +147,6 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
* @access public
*/
public function buildQuickForm() {
$drupal_wysiwyg = FALSE;
$wysiwyg_options = array('' => ts('Textarea')) + CRM_Core_PseudoConstant::wysiwygEditor();
$config = CRM_Core_Config::singleton();
......@@ -154,13 +158,17 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
}
$drupal_wysiwyg = FALSE;
if (!$config->userSystem->is_drupal ||
!module_exists("wysiwyg")
) {
if (!$config->userSystem->is_drupal || !module_exists("wysiwyg")) {
unset($wysiwyg_options[4]);
}
else {
$extra['onchange'] = 'if (this.value==4) { cj("#crm-preferences-display-form-block-wysiwyg_input_format").show(); } else { cj("#crm-preferences-display-form-block-wysiwyg_input_format").hide() }';
$extra['onchange'] = '
if (this.value==4) {
cj("#crm-preferences-display-form-block-wysiwyg_input_format").show();
}
else {
cj("#crm-preferences-display-form-block-wysiwyg_input_format").hide()
}';
$formats = filter_formats();
$format_options = array();
......@@ -174,6 +182,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
if ($drupal_wysiwyg) {
$this->addElement('select', 'wysiwyg_input_format', ts('Input Format'), $format_options, NULL);
}
$editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
$this->assign('editOptions', $editOptions);
......@@ -211,9 +220,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
}
$config = CRM_Core_Config::singleton();
if ($config->userSystem->is_drupal == '1' &&
module_exists("wysiwyg")
) {
if ($config->userSystem->is_drupal == '1' && module_exists("wysiwyg")) {
variable_set('civicrm_wysiwyg_input_format', $this->_params['wysiwyg_input_format']);
}
......
......@@ -175,7 +175,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
);
}
$this->add('select', 'recipient', ts('Recipient(s)'), $sel5[$recipient],
$this->add('select', 'recipient', ts('Limit Recipients'), $sel5[$recipient],
FALSE, array('onClick' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);")
);
......
......@@ -50,7 +50,7 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
*
* @return None
*/
function setDefaultValues() {
function setDefaultValues() {
if (!$this->_defaults) {
$this->_defaults = array();
$formArray = array('Component', 'Localization');
......
......@@ -76,7 +76,7 @@ class CRM_Admin_Form_Setting_Component extends CRM_Admin_Form_Setting {
* @access public
* @static
*/
static function formRule($fields) {
static function formRule($fields, $files, $options) {
$errors = array();
if (is_array($fields['enableComponents'])) {
......
......@@ -42,6 +42,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
protected $_settings = array(
'max_attachments' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'contact_undelete' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'versionAlert' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'versionCheck' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'maxFileSize' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'doNotAttachPDFReceipt' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
......@@ -56,53 +57,90 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting {
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Settings - Undelete, Logging and ReCAPTCHA'));
// also check if we can enable triggers
$validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(FALSE);
// FIXME: for now, disable logging for multilingual sites OR if triggers are not permittted
$domain = new CRM_Core_DAO_Domain;
$domain->find(TRUE);
$attribs = $domain->locales || !$validTriggerPermission ? array(
'disabled' => 'disabled') : NULL;
$attribs = $domain->locales || !$validTriggerPermission ?
array('disabled' => 'disabled') : NULL;
$this->assign('validTriggerPermission', $validTriggerPermission);
$this->addYesNo('logging', ts('Logging'), NULL, NULL, $attribs);
$this->addElement('text', 'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'),
$this->addElement(
'text',
'wkhtmltopdfPath', ts('Path to wkhtmltopdf executable'),
array('size' => 64, 'maxlength' => 256)
);
$this->addElement('text', 'recaptchaPublicKey', ts('Public Key'),
$this->addElement(
'text', 'recaptchaPublicKey', ts('Public Key'),
array('size' => 64, 'maxlength' => 64)
);
$this->addElement('text', 'recaptchaPrivateKey', ts('Private Key'),
$this->addElement(
'text', 'recaptchaPrivateKey', ts('Private Key'),
array('size' => 64, 'maxlength' => 64)
);
$this->addElement('text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'),
$this->addElement(
'text', 'dashboardCacheTimeout', ts('Dashboard cache timeout'),
array('size' => 3, 'maxlength' => 5)
);
$this->addElement('text', 'checksumTimeout', ts('CheckSum Lifespan'),
$this->addElement(
'text', 'checksumTimeout', ts('CheckSum Lifespan'),
array('size' => 2, 'maxlength' => 8)
);
$this->addElement('text', 'recaptchaOptions', ts('Recaptcha Options'),
$this->addElement(
'text', 'recaptchaOptions', ts('Recaptcha Options'),
array('size' => 64, 'maxlength' => 64)
);
$this->addRule('checksumTimeout', ts('Value should be a positive number'), 'positiveInteger');
$this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this);
parent::buildQuickForm();
}