}
}
- // first see if the contact has edit / view all contacts
- if (CRM_Core_Permission::check('edit all contacts') ||
- ($type == self::VIEW && CRM_Core_Permission::check('view all contacts'))
- ) {
- return $deleteClause;
- }
-
if (!$contactID) {
$contactID = CRM_Core_Session::getLoggedInContactID();
}
$contactID = (int) $contactID;
+ // first see if the contact has edit / view all permission
+ if (CRM_Core_Permission::check('edit all contacts', $contactID) ||
+ ($type == self::VIEW && CRM_Core_Permission::check('view all contacts', $contactID))
+ ) {
+ return $deleteClause;
+ }
+
$where = implode(' AND ',
array(
CRM_ACL_BAO_ACL::whereClause($type,
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
// note this also resets any ACL cache
$staticGroupIDs = array();
$cachedGroupIDs = array();
while ($dao->fetch()) {
- // currently operation is restrcited to VIEW/EDIT
+ // currently operation is restricted to VIEW/EDIT
if ($dao->where_clause) {
if ($dao->select_tables) {
$tmpTables = array();
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_ACL_DAO_EntityRole', $id, 'is_active', $is_active);
CRM_Core_Session::setStatus("", ts('Wordpress Access Control Updated'), "success");
- // rebuild the menus to comply with the new permisssions/capabilites
+ // rebuild the menus to comply with the new permissions/capabilites
CRM_Core_Invoke::rebuildMenuAndCaches();
CRM_Utils_System::redirect('admin.php?page=CiviCRM&q=civicrm/admin/access&reset=1');
continue;
}
- $isBulkActivity = (!$bulkActivityTypeID || ($bulkActivityTypeID != $activity['activity_type_id']));
+ $isBulkActivity = (!$bulkActivityTypeID || ($bulkActivityTypeID === $activity['activity_type_id']));
foreach ($mappingParams as $apiKey => $expectedName) {
if (in_array($apiKey, array('assignee_contact_name', 'target_contact_name'))) {
$activities[$id][$expectedName] = CRM_Utils_Array::value($apiKey, $activity, array());
}
// Get contact activities.
- $activities = CRM_Activity_BAO_Activity::deprecatedGetActivities($params);
+ $activities = CRM_Activity_BAO_Activity::getActivities($params);
// Add total.
$params['total'] = CRM_Activity_BAO_Activity::deprecatedGetActivitiesCount($params);
}
elseif (isset($values['target_contact_counter']) && $values['target_contact_counter']) {
$activity['target_contact_name'] = '';
- foreach ($values['target_contact_name'] as $tcID => $tcName) {
- $targetTypeImage = "";
- $targetLink = CRM_Utils_System::href($tcName, 'civicrm/contact/view', "reset=1&cid={$tcID}");
- if ($showContactOverlay) {
- $targetTypeImage = CRM_Contact_BAO_Contact_Utils::getImage(
- CRM_Contact_BAO_Contact::getContactType($tcID),
- FALSE,
- $tcID);
- $activity['target_contact_name'] .= "<div>$targetTypeImage $targetLink";
- }
- else {
- $activity['target_contact_name'] .= $targetLink;
- }
+ $firstTargetName = reset($values['target_contact_name']);
+ $firstTargetContactID = key($values['target_contact_name']);
+
+ $targetLink = CRM_Utils_System::href($firstTargetName, 'civicrm/contact/view', "reset=1&cid={$firstTargetContactID}");
+ if ($showContactOverlay) {
+ $targetTypeImage = CRM_Contact_BAO_Contact_Utils::getImage(
+ CRM_Contact_BAO_Contact::getContactType($firstTargetContactID),
+ FALSE,
+ $firstTargetContactID);
+ $activity['target_contact_name'] .= "<div>$targetTypeImage $targetLink";
+ }
+ else {
+ $activity['target_contact_name'] .= $targetLink;
}
if ($extraCount = $values['target_contact_counter'] - 1) {
$mainActivity->activity_date_time = $actDateTime;
// Make sure this is current revision.
$mainActivity->is_current_revision = TRUE;
- // Drop all relations.
- $mainActivity->parent_id = $mainActivity->original_id = NULL;
+ $mainActivity->original_id = $otherActivity->id;
+ $otherActivity->is_current_revision = FALSE;
$mainActivity->save();
$mainActivityId = $mainActivity->id;
1 => $params['caseID'],
)) . ' ' . $otherActivity->subject;
}
- $otherActivity->activity_date_time = $actDateTime;
$otherActivity->save();
$caseActivity->free();
'sort' => $sort,
);
$config = CRM_Core_Config::singleton();
- $rows = CRM_Activity_BAO_Activity::deprecatedGetActivities($params);
+ $rows = CRM_Activity_BAO_Activity::getActivities($params);
if (empty($rows)) {
return $rows;
*/
class CRM_Admin_Form_Setting extends CRM_Core_Form {
+ use CRM_Admin_Form_SettingTrait;
+
protected $_settings = array();
+ protected $includesReadOnlyFields;
+
/**
* Set default values for the form.
*
)
);
- $descriptions = array();
- $settingMetaData = $this->getSettingsMetaData();
- foreach ($settingMetaData as $setting => $props) {
- if (isset($props['quick_form_type'])) {
- if (isset($props['pseudoconstant'])) {
- $options = civicrm_api3('Setting', 'getoptions', array(
- 'field' => $setting,
- ));
- }
- else {
- $options = NULL;
- }
- //Load input as readonly whose values are overridden in civicrm.settings.php.
- if (Civi::settings()->getMandatory($setting)) {
- $props['html_attributes']['readonly'] = TRUE;
- $setStatus = TRUE;
- }
-
- $add = 'add' . $props['quick_form_type'];
- if ($add == 'addElement') {
- $this->$add(
- $props['html_type'],
- $setting,
- ts($props['title']),
- ($options !== NULL) ? $options['values'] : CRM_Utils_Array::value('html_attributes', $props, array()),
- ($options !== NULL) ? CRM_Utils_Array::value('html_attributes', $props, array()) : NULL
- );
- }
- elseif ($add == 'addSelect') {
- $this->addElement('select', $setting, ts($props['title']), $options['values'], CRM_Utils_Array::value('html_attributes', $props));
- }
- elseif ($add == 'addCheckBox') {
- $this->addCheckBox($setting, ts($props['title']), $options['values'], NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, array(' '));
- }
- elseif ($add == 'addChainSelect') {
- $this->addChainSelect($setting, array(
- 'label' => ts($props['title']),
- ));
- }
- elseif ($add == 'addMonthDay') {
- $this->add('date', $setting, ts($props['title']), CRM_Core_SelectValues::date(NULL, 'M d'));
- }
- else {
- $this->$add($setting, ts($props['title']));
- }
- // Migrate to using an array as easier in smart...
- $descriptions[$setting] = ts($props['description']);
- $this->assign("{$setting}_description", ts($props['description']));
- if ($setting == 'max_attachments') {
- //temp hack @todo fix to get from metadata
- $this->addRule('max_attachments', ts('Value should be a positive number'), 'positiveInteger');
- }
- if ($setting == 'maxFileSize') {
- //temp hack
- $this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger');
- }
+ $this->addFieldsDefinedInSettingsMetadata();
- }
- }
- if (!empty($setStatus)) {
+ if ($this->includesReadOnlyFields) {
CRM_Core_Session::setStatus(ts("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php."), '', 'info', array('expires' => 0));
}
- // setting_description should be deprecated - see Mail.tpl for metadata based tpl.
- $this->assign('setting_descriptions', $descriptions);
- $this->assign('settings_fields', $settingMetaData);
- }
-
- /**
- * Get default entity.
- *
- * @return string
- */
- public function getDefaultEntity() {
- return 'Setting';
}
/**
* @todo Document what I do.
*
* @param array $params
+ * @throws \CRM_Core_Exception
*/
public function commonProcess(&$params) {
unset($params[$name]);
}
}
- $settings = array_intersect_key($params, $this->_settings);
- $result = civicrm_api('setting', 'create', $settings + array('version' => 3));
- foreach ($settings as $setting => $settingGroup) {
- //@todo array_diff this
- unset($params[$setting]);
+ try {
+ $settings = $this->getSettingsToSetByMetadata($params);
+ civicrm_api3('setting', 'create', $settings);
}
- if (!empty($result['error_message'])) {
- CRM_Core_Session::setStatus($result['error_message'], ts('Save Failed'), 'error');
+ catch (CiviCRM_API3_Exception $e) {
+ CRM_Core_Session::setStatus($e->getMessage(), ts('Save Failed'), 'error');
}
- //CRM_Core_BAO_ConfigSetting::create($params);
+ $this->filterParamsSetByMetadata($params);
+
$params = CRM_Core_BAO_ConfigSetting::filterSkipVars($params);
if (!empty($params)) {
- CRM_Core_Error::fatal('Unrecognized setting. This may be a config field which has not been properly migrated to a setting. (' . implode(', ', array_keys($params)) . ')');
+ throw new CRM_Core_Exception('Unrecognized setting. This may be a config field which has not been properly migrated to a setting. (' . implode(', ', array_keys($params)) . ')');
}
CRM_Core_Config::clearDBCache();
) + $autoSearchFields;
}
- /**
- * Get the metadata relating to the settings on the form, ordered by the keys in $this->_settings.
- *
- * @return array
- */
- protected function getSettingsMetaData() {
- $allSettingMetaData = civicrm_api3('setting', 'getfields', array());
- $settingMetaData = array_intersect_key($allSettingMetaData['values'], $this->_settings);
- // This array_merge re-orders to the key order of $this->_settings.
- $settingMetaData = array_merge($this->_settings, $settingMetaData);
- return $settingMetaData;
- }
-
}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2018
+ */
+
+/**
+ * This trait allows us to consolidate Preferences & Settings forms.
+ *
+ * It is intended mostly as part of a refactoring process to get rid of having 2.
+ */
+trait CRM_Admin_Form_SettingTrait {
+
+ /**
+ * @var array
+ */
+ protected $settingsMetadata;
+
+ /**
+ * Get default entity.
+ *
+ * @return string
+ */
+ public function getDefaultEntity() {
+ return 'Setting';
+ }
+
+ /**
+ * Get the metadata relating to the settings on the form, ordered by the keys in $this->_settings.
+ *
+ * @return array
+ */
+ protected function getSettingsMetaData() {
+ if (empty($this->settingsMetadata)) {
+ $allSettingMetaData = civicrm_api3('setting', 'getfields', []);
+ $this->settingsMetadata = array_intersect_key($allSettingMetaData['values'], $this->_settings);
+ // This array_merge re-orders to the key order of $this->_settings.
+ $this->settingsMetadata = array_merge($this->_settings, $this->settingsMetadata);
+ }
+ return $this->settingsMetadata;
+ }
+
+ /**
+ * Get the settings which can be stored based on metadata.
+ *
+ * @param array $params
+ * @return array
+ */
+ protected function getSettingsToSetByMetadata($params) {
+ return array_intersect_key($params, $this->_settings);
+ }
+
+ /**
+ * @param $params
+ */
+ protected function filterParamsSetByMetadata(&$params) {
+ foreach ($this->getSettingsToSetByMetadata($params) as $setting => $settingGroup) {
+ //@todo array_diff this
+ unset($params[$setting]);
+ }
+ }
+
+ /**
+ * Add fields in the metadata to the template.
+ */
+ protected function addFieldsDefinedInSettingsMetadata() {
+ $settingMetaData = $this->getSettingsMetaData();
+ $descriptions = [];
+ foreach ($settingMetaData as $setting => $props) {
+ if (isset($props['quick_form_type'])) {
+ if (isset($props['pseudoconstant'])) {
+ $options = civicrm_api3('Setting', 'getoptions', [
+ 'field' => $setting,
+ ]);
+ }
+ else {
+ $options = NULL;
+ }
+ //Load input as readonly whose values are overridden in civicrm.settings.php.
+ if (Civi::settings()->getMandatory($setting)) {
+ $props['html_attributes']['readonly'] = TRUE;
+ $this->includesReadOnlyFields = TRUE;
+ }
+
+ $add = 'add' . $props['quick_form_type'];
+ if ($add == 'addElement') {
+ $this->$add(
+ $props['html_type'],
+ $setting,
+ ts($props['title']),
+ ($options !== NULL) ? $options['values'] : CRM_Utils_Array::value('html_attributes', $props, []),
+ ($options !== NULL) ? CRM_Utils_Array::value('html_attributes', $props, []) : NULL
+ );
+ }
+ elseif ($add == 'addSelect') {
+ $this->addElement('select', $setting, ts($props['title']), $options['values'], CRM_Utils_Array::value('html_attributes', $props));
+ }
+ elseif ($add == 'addCheckBox') {
+ $this->addCheckBox($setting, ts($props['title']), $options['values'], NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, [' ']);
+ }
+ elseif ($add == 'addChainSelect') {
+ $this->addChainSelect($setting, [
+ 'label' => ts($props['title']),
+ ]);
+ }
+ elseif ($add == 'addMonthDay') {
+ $this->add('date', $setting, ts($props['title']), CRM_Core_SelectValues::date(NULL, 'M d'));
+ }
+ else {
+ $this->$add($setting, ts($props['title']));
+ }
+ // Migrate to using an array as easier in smart...
+ $descriptions[$setting] = ts($props['description']);
+ $this->assign("{$setting}_description", ts($props['description']));
+ if ($setting == 'max_attachments') {
+ //temp hack @todo fix to get from metadata
+ $this->addRule('max_attachments', ts('Value should be a positive number'), 'positiveInteger');
+ }
+ if ($setting == 'maxFileSize') {
+ //temp hack
+ $this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger');
+ }
+
+ }
+ }
+ // setting_description should be deprecated - see Mail.tpl for metadata based tpl.
+ $this->assign('setting_descriptions', $descriptions);
+ $this->assign('settings_fields', $settingMetaData);
+ }
+
+}
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_PrintLabel', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return CRM_Campaign_DAO_Campaign|null
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Campaign_DAO_Campaign', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Campaign_DAO_Survey', $id, 'is_active', $is_active);
);
list($select, $from) = explode(' FROM ', $sql);
$selectSQL = "
- SELECT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name
+ SELECT '$cacheKey', contact_a.id, contact_a.display_name
FROM {$from}
";
$mask = CRM_Core_Action::mask($permissions);
$caseTypes = CRM_Case_PseudoConstant::caseType('name');
- foreach ($result->fetchAll() as $key => $case) {
+ foreach ($result->fetchAll() as $case) {
+ $key = $case['case_id'];
$casesList[$key] = array();
$casesList[$key]['DT_RowId'] = $case['case_id'];
$casesList[$key]['DT_RowAttr'] = array('data-entity' => 'case', 'data-id' => $case['case_id']);
*
* @param null $context
* @param int $userID
- * @param null $type
+ * @param null $type (deprecated)
*
* @return array
* Array of case activities
*
*/
public static function getCaseActivity($caseID, &$params, $contactID, $context = NULL, $userID = NULL, $type = NULL) {
- $values = array();
-
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
CRM_Activity_BAO_Activity::getStatusesByType(CRM_Activity_BAO_Activity::CANCELLED)
);
- $contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid=", FALSE, NULL, FALSE);
- $hasViewContact = CRM_Core_Permission::giveMeAllACLs();
-
if (!$userID) {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
continue;
}
- $caseActivity['DT_RowId'] = $caseActivityId;
+ $caseActivities[$caseActivityId]['DT_RowId'] = $caseActivityId;
//Add classes to the row, via DataTables syntax
- $caseActivity['DT_RowClass'] = "crm-entity status-id-$dao->status";
+ $caseActivities[$caseActivityId]['DT_RowClass'] = "crm-entity status-id-$dao->status";
if (CRM_Utils_Array::crmInArray($dao->status, $compStatusValues)) {
- $caseActivity['DT_RowClass'] .= " status-completed";
+ $caseActivities[$caseActivityId]['DT_RowClass'] .= " status-completed";
}
else {
if (CRM_Utils_Date::overdue($dao->display_date)) {
- $caseActivity['DT_RowClass'] .= " status-overdue";
+ $caseActivities[$caseActivityId]['DT_RowClass'] .= " status-overdue";
}
else {
- $caseActivity['DT_RowClass'] .= " status-scheduled";
+ $caseActivities[$caseActivityId]['DT_RowClass'] .= " status-scheduled";
}
}
if (!empty($dao->priority)) {
if ($dao->priority == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'priority_id', 'Urgent')) {
- $caseActivity['DT_RowClass'] .= " priority-urgent ";
+ $caseActivities[$caseActivityId]['DT_RowClass'] .= " priority-urgent ";
}
elseif ($dao->priority == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'priority_id', 'Low')) {
- $caseActivity['DT_RowClass'] .= " priority-low ";
+ $caseActivities[$caseActivityId]['DT_RowClass'] .= " priority-low ";
}
}
//Add data to the row for inline editing, via DataTable syntax
- $caseActivity['DT_RowAttr'] = array();
- $caseActivity['DT_RowAttr']['data-entity'] = 'activity';
- $caseActivity['DT_RowAttr']['data-id'] = $caseActivityId;
+ $caseActivities[$caseActivityId]['DT_RowAttr'] = array();
+ $caseActivities[$caseActivityId]['DT_RowAttr']['data-entity'] = 'activity';
+ $caseActivities[$caseActivityId]['DT_RowAttr']['data-id'] = $caseActivityId;
//Activity Date and Time
- $caseActivity['activity_date_time'] = CRM_Utils_Date::customFormat($dao->display_date);
+ $caseActivities[$caseActivityId]['activity_date_time'] = CRM_Utils_Date::customFormat($dao->display_date);
//Activity Subject
- $caseActivity['subject'] = $dao->subject;
+ $caseActivities[$caseActivityId]['subject'] = $dao->subject;
//Activity Type
- $caseActivity['type'] = (!empty($activityTypes[$dao->type]['icon']) ? '<span class="crm-i ' . $activityTypes[$dao->type]['icon'] . '"></span> ' : '')
+ $caseActivities[$caseActivityId]['type'] = (!empty($activityTypes[$dao->type]['icon']) ? '<span class="crm-i ' . $activityTypes[$dao->type]['icon'] . '"></span> ' : '')
. $activityTypes[$dao->type]['label'];
- //Activity Target (With)
- $targetContact = '';
- if (isset($dao->target_contact_id)) {
- $targetContact = $dao->target_contact_name;
- if ($hasViewContact) {
- $targetContact = '<a href="' . $contactViewUrl . $dao->target_contact_id . '">' . $dao->target_contact_name . '</a>';
+ // Activity Target (With Contact) (There can be more than one)
+ $targetContact = self::formatContactLink($dao->target_contact_id, $dao->target_contact_name);
+ if (empty($caseActivities[$caseActivityId]['target_contact_name'])) {
+ $caseActivities[$caseActivityId]['target_contact_name'] = $targetContact;
+ }
+ else {
+ if (strpos($caseActivities[$caseActivityId]['target_contact_name'], $targetContact) === FALSE) {
+ $caseActivities[$caseActivityId]['target_contact_name'] .= '; ' . $targetContact;
}
}
- $caseActivity['target_contact_name'] = $targetContact;
- //Activity Source Contact (Reporter)
- $sourceContact = $dao->source_contact_name;
- if ($hasViewContact) {
- $sourceContact = '<a href="' . $contactViewUrl . $dao->source_contact_id . '">' . $dao->source_contact_name . '</a>';
- }
- $caseActivity['source_contact_name'] = $sourceContact;
+ // Activity Source Contact (Reporter) (There can only be one)
+ $sourceContact = self::formatContactLink($dao->source_contact_id, $dao->source_contact_name);
+ $caseActivities[$caseActivityId]['source_contact_name'] = $sourceContact;
- //Activity Assignee. CRM-4485.
- $assigneeContact = '';
- if (isset($dao->assignee_contact_id)) {
- $assigneeContact = $dao->assignee_contact_name;
- if ($hasViewContact) {
- $assigneeContact = '<a href="' . $contactViewUrl . $dao->assignee_contact_id . '">' . $dao->assignee_contact_name . '</a>';
+ // Activity Assignee (There can be more than one)
+ $assigneeContact = self::formatContactLink($dao->assignee_contact_id, $dao->assignee_contact_name);
+ if (empty($caseActivities[$caseActivityId]['assignee_contact_name'])) {
+ $caseActivities[$caseActivityId]['assignee_contact_name'] = $assigneeContact;
+ }
+ else {
+ if (strpos($caseActivities[$caseActivityId]['assignee_contact_name'], $assigneeContact) === FALSE) {
+ $caseActivities[$caseActivityId]['assignee_contact_name'] .= '; ' . $assigneeContact;
}
}
- $caseActivity['assignee_contact_name'] = $assigneeContact;
//Activity Status
- $caseActivity['status_id'] = $activityStatuses[$dao->status];
+ $caseActivities[$caseActivityId]['status_id'] = $activityStatuses[$dao->status];
// FIXME: Why are we not using CRM_Core_Action for these links? This is too much manual work and likely to get out-of-sync with core markup.
$url = "";
}
elseif (!$caseDeleted) {
$url = ' <a ' . $css . ' href="' . $restoreUrl . $additionalUrl . '">' . ts('Restore') . '</a>';
- $caseActivity['status_id'] = $caseActivity['status_id'] . '<br /> (deleted)';
+ $caseActivities[$caseActivityId]['status_id'] = $caseActivities[$caseActivityId]['status_id'] . '<br /> (deleted)';
}
//check for operations.
// if there are file attachments we will return how many and, if only one, add a link to it
if (!empty($dao->attachment_ids)) {
$attachmentIDs = array_unique(explode(',', $dao->attachment_ids));
- $caseActivity['no_attachments'] = count($attachmentIDs);
+ $caseActivities[$caseActivityId]['no_attachments'] = count($attachmentIDs);
$url .= implode(' ', CRM_Core_BAO_File::paperIconAttachment('civicrm_activity', $caseActivityId));
}
- $caseActivity['links'] = $url;
-
- array_push($caseActivities, $caseActivity);
+ $caseActivities[$caseActivityId]['links'] = $url;
}
$dao->free();
$caseActivitiesDT = array();
- $caseActivitiesDT['data'] = $caseActivities;
+ $caseActivitiesDT['data'] = array_values($caseActivities);
$caseActivitiesDT['recordsTotal'] = $caseCount;
$caseActivitiesDT['recordsFiltered'] = $caseCount;
return $caseActivitiesDT;
}
+ /**
+ * Helper function to generate a formatted contact link/name for display in the Case activities tab
+ *
+ * @param $contactId
+ * @param $contactName
+ *
+ * @return string
+ */
+ private static function formatContactLink($contactId, $contactName) {
+ if (empty($contactId)) {
+ return NULL;
+ }
+
+ $hasViewContact = CRM_Contact_BAO_Contact_Permission::allow($contactId);
+
+ if ($hasViewContact) {
+ $contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid={$contactId}");
+ return "<a href=\"{$contactViewUrl}\">" . $contactName . "</a>";
+ }
+ else {
+ return $contactName;
+ }
+ }
+
/**
* Get Case Related Contacts.
*
$atArray,
$this->_currentUserId
);
- $activities = array_keys($activities);
- $activities = $activities[0];
+ $activityId = CRM_Utils_Array::first(array_keys($activities['data']));
$editUrl = CRM_Utils_System::url('civicrm/case/activity',
- "reset=1&cid={$this->_currentlyViewedContactId}&caseid={$caseId}&action=update&id={$activities}"
+ "reset=1&cid={$this->_currentlyViewedContactId}&caseid={$caseId}&action=update&id={$activityId}"
);
}
CRM_Core_Error::statusBounce(ts("You can not add another '%1' activity to this case. %2",
'recordsTotal' => $cases['total'],
);
unset($cases['total']);
- $casesDT['data'] = $cases;
+ $casesDT['data'] = array_values($cases);
CRM_Utils_JSON::output($casesDT);
}
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
$params = array('id' => $id);
* @param bool $isActive
* Value we want to set the is_active field.
*
- * @return CRM_Core_DAO|null
- * DAO object on success, NULL otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $isActive) {
return CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Group', $id, 'is_active', $isActive);
$this->_qill[$grouping][] = "$field[title] $op \"$value\"";
}
elseif ($name === 'email_greeting') {
+ CRM_Core_Error::deprecatedFunctionWarning('pass in email_greeting_id or email_greeting_display');
$filterCondition = array('greeting_type' => 'email_greeting');
$this->optionValueQuery(
$name, $op, $value, $grouping,
);
}
elseif ($name === 'postal_greeting') {
+ CRM_Core_Error::deprecatedFunctionWarning('pass in postal_greeting_id or postal_greeting_display');
$filterCondition = array('greeting_type' => 'postal_greeting');
$this->optionValueQuery(
$name, $op, $value, $grouping,
);
}
elseif ($name === 'addressee') {
+ CRM_Core_Error::deprecatedFunctionWarning('pass in addressee_id or addressee_display');
$filterCondition = array('greeting_type' => 'addressee');
$this->optionValueQuery(
$name, $op, $value, $grouping,
}
$sql = "
CREATE TEMPORARY TABLE {$relationshipTempTable}
+ (
+ `contact_id` int(10) unsigned NOT NULL DEFAULT '0',
+ `contact_id_alt` int(10) unsigned NOT NULL DEFAULT '0',
+ KEY `contact_id` (`contact_id`),
+ KEY `contact_id_alt` (`contact_id_alt`)
+ )
(SELECT contact_id_b as contact_id, contact_id_a as contact_id_alt, civicrm_relationship.id
FROM civicrm_relationship
INNER JOIN civicrm_contact c ON civicrm_relationship.contact_id_a = c.id
}
}
else {
- // LOWER roughly translates to 'hurt my database without deriving any benefit' See CRM-19811.
- $wc = self::caseImportant($op) ? "LOWER({$field['where']})" : "{$field['where']}";
+ CRM_Core_Error::deprecatedFunctionWarning('pass $ids to this method');
+ $wc = "{$field['where']}";
}
if (in_array($name, $pseudoFields)) {
if (!in_array($name, array('gender_id', 'prefix_id', 'suffix_id', 'communication_style_id'))) {
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_RelationshipType', $id, 'is_active', $is_active);
* @param array $formValues
*
*/
- public static function formatSavedSearchFields(&$formValues) {
+ public static function formatSavedSearchFields($formValues) {
$dateFields = array(
'start_date_1',
'end_date_1',
$formValues[$element] = date('Y-m-d', strtotime($value));
}
}
+
+ return $formValues;
}
}
if ((CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_all') ||
($form->_task == CRM_Contact_Task::SAVE_SEARCH)
) {
- $sortByCharacter = $form->get('sortByCharacter');
- $cacheKey = ($sortByCharacter && $sortByCharacter != 'all') ? "{$cacheKey}_alphabet" : $cacheKey;
-
// since we don't store all contacts in prevnextcache, when user selects "all" use query to retrieve contacts
// rather than prevnext cache table for most of the task actions except export where we rebuild query to fetch
// final result set
}
$form->_emails = $fromEmailValues;
+ $defaults = array();
$form->_fromEmails = $fromEmailValues;
+ if (!Civi::settings()->get('allow_mail_from_logged_in_contact')) {
+ $defaults['from_email_address'] = current(CRM_Core_BAO_Domain::getNameAndEmail(FALSE, TRUE));
+ }
if (is_numeric(key($form->_fromEmails))) {
// Add signature
$defaultEmail = civicrm_api3('email', 'getsingle', array('id' => key($form->_fromEmails)));
if (!empty($defaultEmail['signature_text'])) {
$defaults['text_message'] = "\n\n--\n" . $defaultEmail['signature_text'];
}
- $form->setDefaults($defaults);
}
+ $form->setDefaults($defaults);
}
/**
$countRow = Civi::service('prevnext')->getCount($cacheKey);
// $sortByCharacter triggers a refresh in the prevNext cache
if ($sortByCharacter && $sortByCharacter != 'all') {
- $cacheKey .= "_alphabet";
$this->fillupPrevNextCache($sort, $cacheKey, 0, max(self::CACHE_SIZE, $pageSize));
}
elseif (($firstRecord + $pageSize) >= $countRow) {
// the other alternative of running the FULL query will just be incredibly inefficient
// and slow things down way too much on large data sets / complex queries
- $selectSQL = "SELECT DISTINCT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.sort_name";
+ $selectSQL = "SELECT DISTINCT '$cacheKey', contact_a.id, contact_a.sort_name";
$sql = str_replace(array("SELECT contact_a.id as contact_id", "SELECT contact_a.id as id"), $selectSQL, $sql);
try {
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Premium', $id, 'premiums_active ', $is_active);
*
*/
class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task {
+
+ use CRM_Financial_Form_SalesTaxTrait;
+
public $_mode;
public $_action;
$defaults['total_amount'] = CRM_Utils_Money::format(abs($this->_refund), NULL, NULL, TRUE);
}
elseif ($this->_owed) {
- $defaults['total_amount'] = number_format($this->_owed, 2);
+ $defaults['total_amount'] = CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($this->_owed);
}
// Set $newCredit variable in template to control whether link to credit card mode is included
}
}
- $amountFields = array('non_deductible_amount', 'fee_amount', 'net_amount');
+ $amountFields = array('non_deductible_amount', 'fee_amount');
foreach ($amountFields as $amt) {
if (isset($defaults[$amt])) {
$defaults[$amt] = CRM_Utils_Money::format($defaults[$amt], NULL, '%a');
'invoice_id',
'non_deductible_amount',
'fee_amount',
- 'net_amount',
);
foreach ($additionalDetailFields as $key) {
if (!empty($defaults[$key])) {
$softErrors = CRM_Contribute_Form_SoftCredit::formRule($fields, $errors, $self);
- if (!empty($fields['total_amount']) && (!empty($fields['net_amount']) || !empty($fields['fee_amount']))) {
- $sum = CRM_Utils_Rule::cleanMoney($fields['net_amount']) + CRM_Utils_Rule::cleanMoney($fields['fee_amount']);
- if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != $sum) {
- $errors['total_amount'] = ts('The sum of fee amount and net amount must be equal to total amount');
- }
- }
-
//CRM-16285 - Function to handle validation errors on form, for recurring contribution field.
CRM_Contribute_BAO_ContributionRecur::validateRecurContribution($fields, $files, $self, $errors);
*
* Ie the membership block supports a separate transactions AND the contribution form has been configured for a
* contribution
- * transaction AND a membership transaction AND the payment processor supports double financial transactions (ie. NOT doTransferPayment style)
+ * transaction AND a membership transaction AND the payment processor supports double financial transactions (ie. NOT doTransferCheckout style)
*
* @param int $formID
* @param bool $amountBlockActiveOnForm
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_ActionSchedule', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
// reset the cache
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_Job', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_LocationType', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, NULL otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_MessageTemplate', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return CRM_Core_DAO_Navigation|NULL
- * DAO object on success, NULL otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_Navigation', $id, 'is_active', $is_active);
$config = CRM_Core_Config::singleton();
$makeLink = FALSE;
- if (isset($url) && $url) {
- if (substr($url, 0, 4) !== 'http') {
+ if (!empty($url)) {
+ // Skip processing fully-formed urls
+ if (substr($url, 0, 4) !== 'http' && $url[0] !== '/') {
//CRM-7656 --make sure to separate out url path from url params,
//as we'r going to validate url path across cross-site scripting.
$parsedUrl = parse_url($url);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_OptionGroup', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_OptionValue', $id, 'is_active', $is_active);
}
/**
- * Store multiple items in the setting table.
+ * Get multiple items from the setting table.
*
* @param array $params
* (required) An api formatted array of keys and values.
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
//check if custom data profile field is disabled
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * CRM_Core_DAO_UFGroup object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $id, 'is_active', $is_active);
}
$dao = new CRM_Core_DAO_UFMatch();
$dao->copyValues($params);
+ // Fixme: this function cannot update records
if (!$dao->find(TRUE)) {
$dao->save();
+ Civi::$statics[__CLASS__][$params['domain_id']][(int) $dao->contact_id] = (int) $dao->uf_id;
+ CRM_Utils_Hook::post($hook, 'UFMatch', $dao->id, $dao);
}
- CRM_Utils_Hook::post($hook, 'UFMatch', $dao->id, $dao);
return $dao;
}
$ufmatch = new CRM_Core_DAO_UFMatch();
$ufmatch->uf_id = $ufID;
- $ufmatch->domain_id = CRM_Core_Config::domainID();
+ $ufmatch->domain_id = $domainId = CRM_Core_Config::domainID();
$ufmatch->delete();
+
+ // Flush cache
+ Civi::$statics[__CLASS__][$domainId] = [];
}
/**
* @param int $ufID
* Id of UF for which related contact_id is required.
*
- * @return int
+ * @return int|NULL
* contact_id on success, null otherwise
*/
public static function getContactId($ufID) {
- if (!isset($ufID)) {
+ if (!$ufID) {
return NULL;
}
+ $domainId = CRM_Core_Config::domainID();
+ if (!isset(Civi::$statics[__CLASS__][$domainId])) {
+ Civi::$statics[__CLASS__][$domainId] = [];
+ }
+ $contactId = array_search($ufID, Civi::$statics[__CLASS__][$domainId]);
+ if ($contactId) {
+ return $contactId;
+ }
$ufmatch = new CRM_Core_DAO_UFMatch();
-
$ufmatch->uf_id = $ufID;
- $ufmatch->domain_id = CRM_Core_Config::domainID();
+ $ufmatch->domain_id = $domainId;
if ($ufmatch->find(TRUE)) {
- return (int ) $ufmatch->contact_id;
+ $contactId = (int) $ufmatch->contact_id;
+ Civi::$statics[__CLASS__][$domainId][$contactId] = (int) $ufID;
+ return $contactId;
}
return NULL;
}
* @param int $contactID
* ID of the contact for which related uf_id is required.
*
- * @return int
+ * @return int|NULL
* uf_id of the given contact_id on success, null otherwise
*/
public static function getUFId($contactID) {
- if (!isset($contactID)) {
+ if (!$contactID) {
return NULL;
}
- $domain = CRM_Core_BAO_Domain::getDomain();
- $ufmatch = new CRM_Core_DAO_UFMatch();
+ $domainId = CRM_Core_Config::domainID();
+ $contactID = (int) $contactID;
- $ufmatch->contact_id = $contactID;
- $ufmatch->domain_id = $domain->id;
- if ($ufmatch->find(TRUE)) {
- return $ufmatch->uf_id;
+ if (empty(Civi::$statics[__CLASS__][$domainId]) || !array_key_exists($contactID, Civi::$statics[__CLASS__][$domainId])) {
+ Civi::$statics[__CLASS__][$domainId][$contactID] = NULL;
+ $ufmatch = new CRM_Core_DAO_UFMatch();
+ $ufmatch->contact_id = $contactID;
+ $ufmatch->domain_id = $domainId;
+ if ($ufmatch->find(TRUE)) {
+ Civi::$statics[__CLASS__][$domainId][$contactID] = (int) $ufmatch->uf_id;
+ }
}
- return NULL;
+ return Civi::$statics[__CLASS__][$domainId][$contactID];
}
/**
/**
* Modify indices to account for localization options.
*
- * @param CRM_Core_DAO $class DAO class
+ * @param string $class DAO class
* @param array $originalIndices index definitions before localization
*
* @return array
*
* Generated from xml/schema/CRM/Core/CustomField.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:7f096c92af68ef9564675e3d708fbbe1)
+ * (GenCodeChecksum:73d7ccebba6055cae4fa0c9d797025c4)
*/
/**
if (!isset(Civi::$statics[__CLASS__]['links'])) {
Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id');
+ Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
}
return Civi::$statics[__CLASS__]['links'];
'entity' => 'CustomField',
'bao' => 'CRM_Core_BAO_CustomField',
'localizable' => 0,
+ 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
'pseudoconstant' => [
'table' => 'civicrm_option_group',
'keyColumn' => 'id',
*
* Generated from xml/schema/CRM/Core/OptionValue.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:8cf699b034cbd9d7b8fe0a69250a79ba)
+ * (GenCodeChecksum:c2177ac5574657232c71d57dbf7e0e55)
*/
/**
'entity' => 'OptionValue',
'bao' => 'CRM_Core_BAO_OptionValue',
'localizable' => 0,
+ 'pseudoconstant' => [
+ 'optionGroupName' => 'visibility',
+ 'optionEditPath' => 'civicrm/admin/options/visibility',
+ ]
],
'icon' => [
'name' => 'icon',
*
* Generated from xml/schema/CRM/Core/PrevNextCache.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:cfce4435348e53ba9941ce5ed223c05b)
+ * (GenCodeChecksum:5e4976ab94ea074a01a14e9eb0dde913)
*/
/**
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Prev Next Entity ID 2'),
'description' => 'FK to entity table specified in entity_table column.',
- 'required' => TRUE,
+ 'required' => FALSE,
'table_name' => 'civicrm_prevnext_cache',
'entity' => 'PrevNextCache',
'bao' => 'CRM_Core_BAO_PrevNextCache',
*
* Generated from xml/schema/CRM/Core/UFField.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:4777c5b97760d4bd4b7138468d18ded5)
+ * (GenCodeChecksum:20b17223454fb0b4a8e2801193ff253c)
*/
/**
'entity' => 'UFField',
'bao' => 'CRM_Core_BAO_UFField',
'localizable' => 0,
+ 'pseudoconstant' => [
+ 'optionGroupName' => 'phone_type',
+ 'optionEditPath' => 'civicrm/admin/options/phone_type',
+ ]
],
'website_type_id' => [
'name' => 'website_type_id',
'entity' => 'UFField',
'bao' => 'CRM_Core_BAO_UFField',
'localizable' => 0,
+ 'pseudoconstant' => [
+ 'optionGroupName' => 'website_type',
+ 'optionEditPath' => 'civicrm/admin/options/website_type',
+ ]
],
'label' => [
'name' => 'label',
$validUser = CRM_Contact_BAO_Contact_Utils::validChecksum($tempID, $userChecksum);
if ($validUser) {
CRM_Core_Resources::singleton()->addVars('coreForm', array('contact_id' => (int) $tempID));
- CRM_Core_Resources::singleton()->addVars('coreForm', array('checksum' => (int) $tempID));
+ CRM_Core_Resources::singleton()->addVars('coreForm', array('checksum' => $userChecksum));
return $tempID;
}
}
--- /dev/null
+<?php
+/*
++--------------------------------------------------------------------+
+| CiviCRM version 5 |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2018 |
++--------------------------------------------------------------------+
+| This file is a part of CiviCRM. |
+| |
+| CiviCRM is free software; you can copy, modify, and distribute it |
+| under the terms of the GNU Affero General Public License |
+| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+| |
+| CiviCRM is distributed in the hope that it will be useful, but |
+| WITHOUT ANY WARRANTY; without even the implied warranty of |
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+| See the GNU Affero General Public License for more details. |
+| |
+| You should have received a copy of the GNU Affero General Public |
+| License and the CiviCRM Licensing Exception along |
+| with this program; if not, contact CiviCRM LLC |
+| at info[AT]civicrm[DOT]org. If you have questions about the |
+| GNU Affero General Public License or the licensing of CiviCRM, |
+| see the CiviCRM license FAQ at http://civicrm.org/licensing |
++--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2018
+ *
+ * Generated from schema_structure.tpl
+ * DO NOT EDIT. Generated by CRM_Core_CodeGen
+ */
+class CRM_Core_I18n_SchemaStructure_5_4_alpha1 {
+
+ /**
+ * Get translatable columns.
+ *
+ * @return array
+ * A table-indexed array of translatable columns.
+ */
+ public static function columns() {
+ static $result = NULL;
+ if (!$result) {
+ $result = [
+ 'civicrm_location_type' => [
+ 'display_name' => "varchar(64)",
+ ],
+ 'civicrm_option_group' => [
+ 'title' => "varchar(255)",
+ 'description' => "varchar(255)",
+ ],
+ 'civicrm_relationship_type' => [
+ 'label_a_b' => "varchar(64)",
+ 'label_b_a' => "varchar(64)",
+ 'description' => "varchar(255)",
+ ],
+ 'civicrm_contact_type' => [
+ 'label' => "varchar(64)",
+ 'description' => "text",
+ ],
+ 'civicrm_batch' => [
+ 'title' => "varchar(255)",
+ 'description' => "text",
+ ],
+ 'civicrm_premiums' => [
+ 'premiums_intro_title' => "varchar(255)",
+ 'premiums_intro_text' => "text",
+ 'premiums_nothankyou_label' => "varchar(255)",
+ ],
+ 'civicrm_membership_status' => [
+ 'label' => "varchar(128)",
+ ],
+ 'civicrm_survey' => [
+ 'title' => "varchar(255)",
+ 'instructions' => "text",
+ 'thankyou_title' => "varchar(255)",
+ 'thankyou_text' => "text",
+ ],
+ 'civicrm_participant_status_type' => [
+ 'label' => "varchar(255)",
+ ],
+ 'civicrm_case_type' => [
+ 'title' => "varchar(64)",
+ 'description' => "varchar(255)",
+ ],
+ 'civicrm_tell_friend' => [
+ 'title' => "varchar(255)",
+ 'intro' => "text",
+ 'suggested_message' => "text",
+ 'thankyou_title' => "varchar(255)",
+ 'thankyou_text' => "text",
+ ],
+ 'civicrm_custom_group' => [
+ 'title' => "varchar(64)",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ ],
+ 'civicrm_custom_field' => [
+ 'label' => "varchar(255)",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ ],
+ 'civicrm_option_value' => [
+ 'label' => "varchar(512)",
+ 'description' => "text",
+ ],
+ 'civicrm_group' => [
+ 'title' => "varchar(64)",
+ ],
+ 'civicrm_contribution_page' => [
+ 'title' => "varchar(255)",
+ 'intro_text' => "text",
+ 'pay_later_text' => "text",
+ 'pay_later_receipt' => "text",
+ 'initial_amount_label' => "varchar(255)",
+ 'initial_amount_help_text' => "text",
+ 'thankyou_title' => "varchar(255)",
+ 'thankyou_text' => "text",
+ 'thankyou_footer' => "text",
+ 'receipt_from_name' => "varchar(255)",
+ 'receipt_text' => "text",
+ 'footer_text' => "text",
+ ],
+ 'civicrm_product' => [
+ 'name' => "varchar(255)",
+ 'description' => "text",
+ 'options' => "text",
+ ],
+ 'civicrm_membership_type' => [
+ 'name' => "varchar(128)",
+ 'description' => "varchar(255)",
+ ],
+ 'civicrm_membership_block' => [
+ 'new_title' => "varchar(255)",
+ 'new_text' => "text",
+ 'renewal_title' => "varchar(255)",
+ 'renewal_text' => "text",
+ ],
+ 'civicrm_price_set' => [
+ 'title' => "varchar(255)",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ ],
+ 'civicrm_dashboard' => [
+ 'label' => "varchar(255)",
+ ],
+ 'civicrm_uf_group' => [
+ 'title' => "varchar(64)",
+ 'frontend_title' => "varchar(64)",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ 'cancel_button_text' => "varchar(64)",
+ 'submit_button_text' => "varchar(64)",
+ ],
+ 'civicrm_uf_field' => [
+ 'help_post' => "text",
+ 'help_pre' => "text",
+ 'label' => "varchar(255)",
+ ],
+ 'civicrm_price_field' => [
+ 'label' => "varchar(255)",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ ],
+ 'civicrm_price_field_value' => [
+ 'label' => "varchar(255)",
+ 'description' => "text",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ ],
+ 'civicrm_pcp_block' => [
+ 'link_text' => "varchar(255)",
+ ],
+ 'civicrm_event' => [
+ 'title' => "varchar(255)",
+ 'summary' => "text",
+ 'description' => "text",
+ 'registration_link_text' => "varchar(255)",
+ 'event_full_text' => "text",
+ 'fee_label' => "varchar(255)",
+ 'intro_text' => "text",
+ 'footer_text' => "text",
+ 'confirm_title' => "varchar(255)",
+ 'confirm_text' => "text",
+ 'confirm_footer_text' => "text",
+ 'confirm_email_text' => "text",
+ 'confirm_from_name' => "varchar(255)",
+ 'thankyou_title' => "varchar(255)",
+ 'thankyou_text' => "text",
+ 'thankyou_footer_text' => "text",
+ 'pay_later_text' => "text",
+ 'pay_later_receipt' => "text",
+ 'initial_amount_label' => "varchar(255)",
+ 'initial_amount_help_text' => "text",
+ 'waitlist_text' => "text",
+ 'approval_req_text' => "text",
+ 'template_title' => "varchar(255)",
+ ],
+ ];
+ }
+ return $result;
+ }
+
+ /**
+ * Get a table indexed array of the indices for translatable fields.
+ *
+ * @return array
+ * Indices for translatable fields.
+ */
+ public static function indices() {
+ static $result = NULL;
+ if (!$result) {
+ $result = [
+ 'civicrm_custom_group' => [
+ 'UI_title_extends' => [
+ 'name' => 'UI_title_extends',
+ 'field' => [
+ 'title',
+ 'extends',
+ ],
+ 'unique' => 1,
+ ],
+ ],
+ 'civicrm_custom_field' => [
+ 'UI_label_custom_group_id' => [
+ 'name' => 'UI_label_custom_group_id',
+ 'field' => [
+ 'label',
+ 'custom_group_id',
+ ],
+ 'unique' => 1,
+ ],
+ ],
+ 'civicrm_group' => [
+ 'UI_title' => [
+ 'name' => 'UI_title',
+ 'field' => [
+ 'title',
+ ],
+ 'unique' => 1,
+ ],
+ ],
+ ];
+ }
+ return $result;
+ }
+
+ /**
+ * Get tables with translatable fields.
+ *
+ * @return array
+ * Array of names of tables with fields that can be translated.
+ */
+ public static function tables() {
+ static $result = NULL;
+ if (!$result) {
+ $result = array_keys(self::columns());
+ }
+ return $result;
+ }
+
+ /**
+ * Get a list of widgets for editing translatable fields.
+ *
+ * @return array
+ * Array of the widgets for editing translatable fields.
+ */
+ public static function widgets() {
+ static $result = NULL;
+ if (!$result) {
+ $result = [
+ 'civicrm_location_type' => [
+ 'display_name' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_option_group' => [
+ 'title' => [
+ 'type' => "Text",
+ ],
+ 'description' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_relationship_type' => [
+ 'label_a_b' => [
+ 'type' => "Text",
+ ],
+ 'label_b_a' => [
+ 'type' => "Text",
+ ],
+ 'description' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_contact_type' => [
+ 'label' => [
+ 'type' => "Text",
+ ],
+ 'description' => [
+ 'type' => "TextArea",
+ 'rows' => "2",
+ 'cols' => "60",
+ ],
+ ],
+ 'civicrm_batch' => [
+ 'title' => [
+ 'type' => "Text",
+ ],
+ 'description' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "80",
+ ],
+ ],
+ 'civicrm_premiums' => [
+ 'premiums_intro_title' => [
+ 'type' => "Text",
+ ],
+ 'premiums_intro_text' => [
+ 'type' => "Text",
+ ],
+ 'premiums_nothankyou_label' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_membership_status' => [
+ 'label' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_survey' => [
+ 'title' => [
+ 'type' => "Text",
+ 'required' => "true",
+ ],
+ 'instructions' => [
+ 'type' => "TextArea",
+ 'rows' => "20",
+ 'cols' => "80",
+ ],
+ 'thankyou_title' => [
+ 'type' => "Text",
+ ],
+ 'thankyou_text' => [
+ 'type' => "TextArea",
+ 'rows' => "8",
+ 'cols' => "60",
+ ],
+ ],
+ 'civicrm_participant_status_type' => [
+ 'label' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_case_type' => [
+ 'title' => [
+ 'type' => "Text",
+ 'required' => "true",
+ ],
+ 'description' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_tell_friend' => [
+ 'title' => [
+ 'type' => "Text",
+ ],
+ 'intro' => [
+ 'type' => "Text",
+ ],
+ 'suggested_message' => [
+ 'type' => "Text",
+ ],
+ 'thankyou_title' => [
+ 'type' => "Text",
+ ],
+ 'thankyou_text' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_custom_group' => [
+ 'title' => [
+ 'type' => "Text",
+ 'required' => "true",
+ ],
+ 'help_pre' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "80",
+ ],
+ 'help_post' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "80",
+ ],
+ ],
+ 'civicrm_custom_field' => [
+ 'label' => [
+ 'type' => "Text",
+ 'required' => "true",
+ ],
+ 'help_pre' => [
+ 'type' => "Text",
+ ],
+ 'help_post' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_option_value' => [
+ 'label' => [
+ 'type' => "Text",
+ 'required' => "true",
+ ],
+ 'description' => [
+ 'type' => "TextArea",
+ 'rows' => "8",
+ 'cols' => "60",
+ ],
+ ],
+ 'civicrm_group' => [
+ 'title' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_contribution_page' => [
+ 'title' => [
+ 'type' => "Text",
+ ],
+ 'intro_text' => [
+ 'type' => "RichTextEditor",
+ 'rows' => "6",
+ 'cols' => "50",
+ ],
+ 'pay_later_text' => [
+ 'type' => "Text",
+ ],
+ 'pay_later_receipt' => [
+ 'type' => "Text",
+ ],
+ 'initial_amount_label' => [
+ 'type' => "Text",
+ ],
+ 'initial_amount_help_text' => [
+ 'type' => "Text",
+ ],
+ 'thankyou_title' => [
+ 'type' => "Text",
+ ],
+ 'thankyou_text' => [
+ 'type' => "RichTextEditor",
+ 'rows' => "8",
+ 'cols' => "60",
+ ],
+ 'thankyou_footer' => [
+ 'type' => "RichTextEditor",
+ 'rows' => "8",
+ 'cols' => "60",
+ ],
+ 'receipt_from_name' => [
+ 'type' => "Text",
+ ],
+ 'receipt_text' => [
+ 'type' => "TextArea",
+ 'rows' => "6",
+ 'cols' => "50",
+ ],
+ 'footer_text' => [
+ 'type' => "RichTextEditor",
+ 'rows' => "6",
+ 'cols' => "50",
+ ],
+ ],
+ 'civicrm_product' => [
+ 'name' => [
+ 'type' => "Text",
+ 'required' => "true",
+ ],
+ 'description' => [
+ 'type' => "Text",
+ ],
+ 'options' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_membership_type' => [
+ 'name' => [
+ 'type' => "Text",
+ 'label' => "Name",
+ ],
+ 'description' => [
+ 'type' => "TextArea",
+ 'rows' => "6",
+ 'cols' => "50",
+ 'label' => "Description",
+ ],
+ ],
+ 'civicrm_membership_block' => [
+ 'new_title' => [
+ 'type' => "Text",
+ ],
+ 'new_text' => [
+ 'type' => "Text",
+ ],
+ 'renewal_title' => [
+ 'type' => "Text",
+ ],
+ 'renewal_text' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_price_set' => [
+ 'title' => [
+ 'type' => "Text",
+ 'required' => "true",
+ ],
+ 'help_pre' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "80",
+ ],
+ 'help_post' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "80",
+ ],
+ ],
+ 'civicrm_dashboard' => [
+ 'label' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_uf_group' => [
+ 'title' => [
+ 'type' => "Text",
+ 'required' => "true",
+ ],
+ 'frontend_title' => [
+ 'type' => "Text",
+ ],
+ 'help_pre' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "80",
+ ],
+ 'help_post' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "80",
+ ],
+ 'cancel_button_text' => [
+ 'type' => "Text",
+ ],
+ 'submit_button_text' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_uf_field' => [
+ 'help_post' => [
+ 'type' => "Text",
+ ],
+ 'help_pre' => [
+ 'type' => "Text",
+ ],
+ 'label' => [
+ 'type' => "Text",
+ 'required' => "true",
+ ],
+ ],
+ 'civicrm_price_field' => [
+ 'label' => [
+ 'type' => "Text",
+ 'required' => "true",
+ ],
+ 'help_pre' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "80",
+ ],
+ 'help_post' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "80",
+ ],
+ ],
+ 'civicrm_price_field_value' => [
+ 'label' => [
+ 'type' => "Text",
+ ],
+ 'description' => [
+ 'type' => "TextArea",
+ 'rows' => "2",
+ 'cols' => "60",
+ ],
+ 'help_pre' => [
+ 'type' => "TextArea",
+ 'rows' => "2",
+ 'cols' => "60",
+ ],
+ 'help_post' => [
+ 'type' => "TextArea",
+ 'rows' => "2",
+ 'cols' => "60",
+ ],
+ ],
+ 'civicrm_pcp_block' => [
+ 'link_text' => [
+ 'type' => "Text",
+ ],
+ ],
+ 'civicrm_event' => [
+ 'title' => [
+ 'type' => "Text",
+ ],
+ 'summary' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "60",
+ ],
+ 'description' => [
+ 'type' => "TextArea",
+ 'rows' => "8",
+ 'cols' => "60",
+ ],
+ 'registration_link_text' => [
+ 'type' => "Text",
+ ],
+ 'event_full_text' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "60",
+ ],
+ 'fee_label' => [
+ 'type' => "Text",
+ ],
+ 'intro_text' => [
+ 'type' => "TextArea",
+ 'rows' => "6",
+ 'cols' => "50",
+ ],
+ 'footer_text' => [
+ 'type' => "TextArea",
+ 'rows' => "6",
+ 'cols' => "50",
+ ],
+ 'confirm_title' => [
+ 'type' => "Text",
+ ],
+ 'confirm_text' => [
+ 'type' => "TextArea",
+ 'rows' => "6",
+ 'cols' => "50",
+ ],
+ 'confirm_footer_text' => [
+ 'type' => "TextArea",
+ 'rows' => "6",
+ 'cols' => "50",
+ ],
+ 'confirm_email_text' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "50",
+ ],
+ 'confirm_from_name' => [
+ 'type' => "Text",
+ ],
+ 'thankyou_title' => [
+ 'type' => "Text",
+ ],
+ 'thankyou_text' => [
+ 'type' => "TextArea",
+ 'rows' => "6",
+ 'cols' => "50",
+ ],
+ 'thankyou_footer_text' => [
+ 'type' => "TextArea",
+ 'rows' => "6",
+ 'cols' => "50",
+ ],
+ 'pay_later_text' => [
+ 'type' => "Text",
+ ],
+ 'pay_later_receipt' => [
+ 'type' => "Text",
+ ],
+ 'initial_amount_label' => [
+ 'type' => "Text",
+ ],
+ 'initial_amount_help_text' => [
+ 'type' => "Text",
+ ],
+ 'waitlist_text' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "60",
+ ],
+ 'approval_req_text' => [
+ 'type' => "TextArea",
+ 'rows' => "4",
+ 'cols' => "60",
+ ],
+ 'template_title' => [
+ 'type' => "Text",
+ ],
+ ],
+ ];
+ }
+ return $result;
+ }
+
+}
}
/**
- * Process payment - this function wraps around both doTransferPayment and doDirectPayment.
+ * Process payment - this function wraps around both doTransferCheckout and doDirectPayment.
*
* The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
* more agnostic.
}
/**
- * Process payment - this function wraps around both doTransferPayment and doDirectPayment.
+ * Process payment - this function wraps around both doTransferCheckout and doDirectPayment.
*
* The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
* more agnostic.
/**
* Given a permission string or array, check for access requirements
- * @param mixed $permissions
+ * @param string|array $permissions
* The permission to check as an array or string -see examples.
- * arrays
+ *
+ * @param int $contactId
+ * Contact id to check permissions for. Defaults to current logged-in user.
*
* Ex 1
*
* @return bool
* true if yes, else false
*/
- public static function check($permissions) {
+ public static function check($permissions, $contactId = NULL) {
$permissions = (array) $permissions;
+ $userId = NULL;
+ if ($contactId) {
+ $userId = CRM_Core_BAO_UFMatch::getUFId($contactId);
+ }
+ /** @var CRM_Core_Permission_Temp $tempPerm */
$tempPerm = CRM_Core_Config::singleton()->userPermissionTemp;
foreach ($permissions as $permission) {
if (is_array($permission)) {
foreach ($permission as $orPerm) {
- if (self::check($orPerm)) {
+ if (self::check($orPerm, $contactId)) {
//one of our 'or' permissions has succeeded - stop checking this permission
return TRUE;
}
}
else {
// This is an individual permission
- $granted = CRM_Core_Config::singleton()->userPermissionClass->check($permission);
+ $granted = CRM_Core_Config::singleton()->userPermissionClass->check($permission, $userId);
// Call the permission_check hook to permit dynamic escalation (CRM-19256)
- CRM_Utils_Hook::permission_check($permission, $granted);
+ CRM_Utils_Hook::permission_check($permission, $granted, $contactId);
if (
!$granted
&& !($tempPerm && $tempPerm->check($permission))
* @param string $str
* The permission to check.
*
- * @param int $contactID
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str, $contactID = NULL) {
+ public function check($str, $userId = NULL) {
$str = $this->translatePermission($str, 'Drupal', array(
'view user account' => 'access user profiles',
'administer users' => 'administer users',
return TRUE;
}
if (function_exists('user_access')) {
- return user_access($str) ? TRUE : FALSE;
+ $account = NULL;
+ if ($userId) {
+ $account = user_load($userId);
+ }
+ return user_access($str, $account);
}
return TRUE;
}
*
* @param string $str
* The permission to check.
+ * @param int $userId
*
*/
- public function check($str) {
+ public function check($str, $userId = NULL) {
//no default behaviour
}
* @param string $str
* The permission to check.
*
- * @param int $contactID
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str, $contactID = NULL) {
+ public function check($str, $userId = NULL) {
$str = $this->translatePermission($str, 'Drupal', array(
'view user account' => 'access user profiles',
'administer users' => 'administer users',
return TRUE;
}
if (function_exists('user_access')) {
- return user_access($str) ? TRUE : FALSE;
+ $account = NULL;
+ if ($userId) {
+ $account = user_load($userId);
+ }
+ return user_access($str, $account);
}
return TRUE;
}
* @param string $str
* The permission to check.
*
- * @param int $contactID
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str, $contactID = NULL) {
+ public function check($str, $userId = NULL) {
$str = $this->translatePermission($str, 'Drupal6', array(
'view user account' => 'access user profiles',
'administer users' => 'administer users',
return TRUE;
}
if (function_exists('user_access')) {
- return user_access($str) ? TRUE : FALSE;
+ $account = NULL;
+ if ($userId) {
+ $account = user_load($userId);
+ }
+ return user_access($str, $account);
}
return TRUE;
}
* @param string $str
* The permission to check.
*
- * @param null $contactID
+ * @param int $userId
*
* @return bool
*/
- public function check($str, $contactID = NULL) {
+ public function check($str, $userId = NULL) {
$str = $this->translatePermission($str, 'Drupal', array(
'view user account' => 'access user profiles',
));
if ($str == CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
return TRUE;
}
- return \Drupal::currentUser()->hasPermission($str);
+ $acct = $userId ? \Drupal\user\Entity\User::load($userId) : \Drupal::currentUser();
+ return $acct->hasPermission($str);
}
/**
*
* @param string $str
* The permission to check.
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str) {
+ public function check($str, $userId = NULL) {
$config = CRM_Core_Config::singleton();
+ // JFactory::getUser does strict type checking, so convert falesy values to NULL
+ if (!$userId) {
+ $userId = NULL;
+ }
$translated = $this->translateJoomlaPermission($str);
if ($translated === CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
// we've not yet figured out how to bootstrap joomla, so we should
// not execute hooks if joomla is not loaded
if (defined('_JEXEC')) {
- $user = JFactory::getUser();
+ $user = JFactory::getUser($userId);
$api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST');
// If we are coming from REST we don't have a user but we do have the api_key for a user.
*
* @param string $str
* The permission to check.
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str) {
+ public function check($str, $userId = NULL) {
return TRUE;
}
*
* @param string $str
* The permission to check.
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str) {
+ public function check($str, $userId = NULL) {
if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
return FALSE;
}
*
* @param string $str
* The permission to check.
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str) {
+ public function check($str, $userId = NULL) {
// Generic cms 'administer users' role tranlates to users with the 'edit_users' capability' in WordPress
$str = $this->translatePermission($str, 'WordPress', array(
'administer users' => 'edit_users',
return TRUE;
}
- if (current_user_can('super admin') || current_user_can('administrator')) {
+ $user = $userId ? get_userdata($userId) : wp_get_current_user();
+
+ if ($user->has_cap('super admin') || $user->has_cap('administrator')) {
return TRUE;
}
// Make string lowercase and convert spaces into underscore
$str = CRM_Utils_String::munge(strtolower($str));
- if (is_user_logged_in()) {
+ if ($user->exists()) {
// Check whether the logged in user has the capabilitity
- if (current_user_can($str)) {
+ if ($user->has_cap($str)) {
return TRUE;
}
}
* @param string $cacheKey
* @param string $sql
* A SQL query. The query *MUST* be a SELECT statement which yields
- * the following columns (in order): entity_table, entity_id1, entity_id2, cacheKey, data
+ * the following columns (in order): cacheKey, entity_id1, data
* @return bool
*/
public function fillWithSql($cacheKey, $sql);
* @param string $cacheKey
* @param array $rows
* A list of cache records. Each record should have keys:
- * - entity_table
* - entity_id1
- * - entity_id2
* - data
* @return bool
*/
*
* @param string $cacheKey
* @param int $id1
- * @param int $id2
*
* @return array
+ * List of neighbors.
+ * [
+ * 'foundEntry' => 1,
+ * 'prev' => ['id1' => 123, 'data'=>'foo'],
+ * 'next' => ['id1' => 456, 'data'=>'foo'],
+ * ]
*/
- public function getPositions($cacheKey, $id1, $id2);
+ public function getPositions($cacheKey, $id1);
/**
* Delete an item from the prevnext cache table based on the entity.
*
* @param int $id
* @param string $cacheKey
- * @param string $entityTable
*/
- public function deleteItem($id = NULL, $cacheKey = NULL, $entityTable = 'civicrm_contact');
+ public function deleteItem($id = NULL, $cacheKey = NULL);
/**
* Get count of matching rows.
*
* @param string $sql
* A SQL query. The query *MUST* be a SELECT statement which yields
- * the following columns (in order): entity_table, entity_id1, entity_id2, cacheKey, data
+ * the following columns (in order): cacheKey, entity_id1, data
* @return bool
* @throws CRM_Core_Exception
*/
public function fillWithSql($cacheKey, $sql) {
$insertSQL = "
-INSERT INTO civicrm_prevnext_cache ( entity_table, entity_id1, entity_id2, cacheKey, data )
+INSERT INTO civicrm_prevnext_cache (cacheKey, entity_id1, data)
";
$result = CRM_Core_DAO::executeQuery($insertSQL . $sql, [], FALSE, NULL, FALSE, TRUE, TRUE);
if (is_a($result, 'DB_Error')) {
$insert = CRM_Utils_SQL_Insert::into('civicrm_prevnext_cache')
->columns([
- 'entity_table',
'entity_id1',
- 'entity_id2',
'cacheKey',
'data'
]);
* To unselect all contact IDs, use NULL.
*/
public function markSelection($cacheKey, $action, $cIds = NULL) {
- $entity_table = 'civicrm_contact';
-
if (!$cacheKey) {
return;
}
$params = array();
- $entity_whereClause = " AND entity_table = '{$entity_table}'";
if ($cIds && $cacheKey && $action) {
if (is_array($cIds)) {
$cIdFilter = "(" . implode(',', $cIds) . ")";
$whereClause = "
-WHERE cacheKey LIKE %1
+WHERE cacheKey = %1
AND (entity_id1 IN {$cIdFilter} OR entity_id2 IN {$cIdFilter})
";
}
else {
$whereClause = "
-WHERE cacheKey LIKE %1
+WHERE cacheKey = %1
AND (entity_id1 = %2 OR entity_id2 = %2)
";
$params[2] = array("{$cIds}", 'Integer');
}
if ($action == 'select') {
$whereClause .= "AND is_selected = 0";
- $sql = "UPDATE civicrm_prevnext_cache SET is_selected = 1 {$whereClause} {$entity_whereClause}";
- $params[1] = array("{$cacheKey}%", 'String');
+ $sql = "UPDATE civicrm_prevnext_cache SET is_selected = 1 {$whereClause}";
+ $params[1] = array($cacheKey, 'String');
}
elseif ($action == 'unselect') {
$whereClause .= "AND is_selected = 1";
- $sql = "UPDATE civicrm_prevnext_cache SET is_selected = 0 {$whereClause} {$entity_whereClause}";
- $params[1] = array("%{$cacheKey}%", 'String');
+ $sql = "UPDATE civicrm_prevnext_cache SET is_selected = 0 {$whereClause}";
+ $params[1] = array($cacheKey, 'String');
}
// default action is reseting
}
$sql = "
UPDATE civicrm_prevnext_cache
SET is_selected = 0
-WHERE cacheKey LIKE %1 AND is_selected = 1
- {$entity_whereClause}
+WHERE cacheKey = %1 AND is_selected = 1
";
- $params[1] = array("{$cacheKey}%", 'String');
+ $params[1] = array($cacheKey, 'String');
}
CRM_Core_DAO::executeQuery($sql, $params);
}
* @return array|NULL
*/
public function getSelection($cacheKey, $action = 'get') {
- $entity_table = 'civicrm_contact';
-
if (!$cacheKey) {
return NULL;
}
$params = array();
- $entity_whereClause = " AND entity_table = '{$entity_table}'";
if ($cacheKey && ($action == 'get' || $action == 'getall')) {
$actionGet = ($action == "get") ? " AND is_selected = 1 " : "";
$sql = "
-SELECT entity_id1, entity_id2 FROM civicrm_prevnext_cache
-WHERE cacheKey LIKE %1
+SELECT entity_id1 FROM civicrm_prevnext_cache
+WHERE cacheKey = %1
$actionGet
- $entity_whereClause
ORDER BY id
";
- $params[1] = array("{$cacheKey}%", 'String');
+ $params[1] = array($cacheKey, 'String');
$contactIds = array($cacheKey => array());
$cIdDao = CRM_Core_DAO::executeQuery($sql, $params);
while ($cIdDao->fetch()) {
- if ($cIdDao->entity_id1 == $cIdDao->entity_id2) {
- $contactIds[$cacheKey][$cIdDao->entity_id1] = 1;
- }
+ $contactIds[$cacheKey][$cIdDao->entity_id1] = 1;
}
return $contactIds;
}
*
* @param string $cacheKey
* @param int $id1
- * @param int $id2
- *
- * NOTE: I don't really get why there are two ID columns, but we'll
- * keep passing them through as a matter of safe-refactoring.
*
* @return array
*/
- public function getPositions($cacheKey, $id1, $id2) {
- return CRM_Core_BAO_PrevNextCache::getPositions($cacheKey, $id1, $id2);
+ public function getPositions($cacheKey, $id1) {
+ $mergeId = CRM_Core_DAO::singleValueQuery(
+ "SELECT id FROM civicrm_prevnext_cache WHERE cacheKey = %2 AND entity_id1 = %1",
+ [
+ 1 => [$id1, 'Integer'],
+ 2 => [$cacheKey, 'String'],
+ ]
+ );
+
+ $pos = ['foundEntry' => 0];
+ if ($mergeId) {
+ $pos['foundEntry'] = 1;
+
+ $sql = "SELECT pn.id, pn.entity_id1, pn.entity_id2, pn.data FROM civicrm_prevnext_cache pn ";
+ $wherePrev = " WHERE pn.id < %1 AND pn.cacheKey = %2 ORDER BY ID DESC LIMIT 1";
+ $whereNext = " WHERE pn.id > %1 AND pn.cacheKey = %2 ORDER BY ID ASC LIMIT 1";
+ $p = [
+ 1 => [$mergeId, 'Integer'],
+ 2 => [$cacheKey, 'String'],
+ ];
+
+ $dao = CRM_Core_DAO::executeQuery($sql . $wherePrev, $p);
+ if ($dao->fetch()) {
+ $pos['prev']['id1'] = $dao->entity_id1;
+ $pos['prev']['mergeId'] = $dao->id;
+ $pos['prev']['data'] = $dao->data;
+ }
+
+ $dao = CRM_Core_DAO::executeQuery($sql . $whereNext, $p);
+ if ($dao->fetch()) {
+ $pos['next']['id1'] = $dao->entity_id1;
+ $pos['next']['mergeId'] = $dao->id;
+ $pos['next']['data'] = $dao->data;
+ }
+ }
+ return $pos;
+
}
/**
*
* @param int $id
* @param string $cacheKey
- * @param string $entityTable
*/
- public function deleteItem($id = NULL, $cacheKey = NULL, $entityTable = 'civicrm_contact') {
- CRM_Core_BAO_PrevNextCache::deleteItem($id, $cacheKey, $entityTable);
+ public function deleteItem($id = NULL, $cacheKey = NULL) {
+ $sql = "DELETE FROM civicrm_prevnext_cache WHERE (1)";
+ $params = array();
+
+ if (is_numeric($id)) {
+ $sql .= " AND ( entity_id1 = %2 OR entity_id2 = %2 )";
+ $params[2] = array($id, 'Integer');
+ }
+
+ if (isset($cacheKey)) {
+ $sql .= " AND cacheKey = %3";
+ $params[3] = array($cacheKey, 'String');
+ }
+ CRM_Core_DAO::executeQuery($sql, $params);
}
/**
* @return int
*/
public function getCount($cacheKey) {
- return CRM_Core_BAO_PrevNextCache::getCount($cacheKey, NULL, "entity_table = 'civicrm_contact'");
+ $query = "SELECT COUNT(*) FROM civicrm_prevnext_cache pn WHERE pn.cacheKey = %1";
+ $params = [1 => [$cacheKey, 'String']];
+ return (int) CRM_Core_DAO::singleValueQuery($query, $params, TRUE, FALSE);
}
}
"bower_components/datatables/media/css/jquery.dataTables.min.css",
"bower_components/jquery-validation/dist/jquery.validate.min.js",
"packages/jquery/plugins/jquery.ui.datepicker.validation.min.js",
+ "js/crm.datepicker.js",
"js/Common.js",
"js/crm.ajax.js",
"js/wysiwyg/crm.wysiwyg.js",
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Event', $id, 'is_active', $is_active);
$title = $groupTitles = array();
foreach ($additionalIDs as $pId => $cId) {
//get the params submitted by participant.
- $participantParams = CRM_Utils_Array::value($pId, $values['params'], array());
+ $participantParams = NULL;
+ if (isset($values['params'])) {
+ $participantParams = CRM_Utils_Array::value($pId, $values['params'], array());
+ }
list($profilePre, $groupTitles) = self::buildCustomDisplay($preProfileID,
'additionalCustomPre',
* the permission that the user has (or null)
*/
public static function checkPermission($eventId = NULL, $type = CRM_Core_Permission::VIEW) {
- static $permissions = NULL;
-
- if (empty($permissions)) {
+ if (!isset(Civi::$statics[__CLASS__]['permissions'])) {
$params = array(
'check_permissions' => 1,
'return' => 'title',
// Search again, but only events created by the user.
$params['created_id'] = 'user_contact_id';
$result = civicrm_api3('Event', 'get', $params);
- $createdEvents = CRM_Utils_Array::collect('title', $result['values']);
+ $createdEvents = array_keys($result['values']);
// Note: for a multisite setup, a user with edit all events, can edit all events
// including those from other sites
if (CRM_Core_Permission::check('edit all events')) {
- $permissions[CRM_Core_Permission::EDIT] = array_keys($allEvents);
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::EDIT] = array_keys($allEvents);
}
else {
- $permissions[CRM_Core_Permission::EDIT] = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_event', $allEvents, $createdEvents);
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::EDIT] = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_event', $allEvents, $createdEvents);
}
if (CRM_Core_Permission::check('edit all events')) {
- $permissions[CRM_Core_Permission::VIEW] = array_keys($allEvents);
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::VIEW] = array_keys($allEvents);
}
else {
if (CRM_Core_Permission::check('access CiviEvent') &&
// at the same time also allow any hook to override if needed.
$createdEvents = array_keys($allEvents);
}
- $permissions[CRM_Core_Permission::VIEW] = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_event', $allEvents, $createdEvents);
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::VIEW] = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_event', $allEvents, $createdEvents);
}
- $permissions[CRM_Core_Permission::DELETE] = array();
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::DELETE] = array();
if (CRM_Core_Permission::check('delete in CiviEvent')) {
// Note: we want to restrict the scope of delete permission to
// events that are editable/viewable (usecase multisite).
// We can remove array_intersect once we have ACL support for delete functionality.
- $permissions[CRM_Core_Permission::DELETE] = array_intersect($permissions[CRM_Core_Permission::EDIT],
- $permissions[CRM_Core_Permission::VIEW]
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::DELETE] = array_intersect(Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::EDIT],
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::VIEW]
);
}
}
if ($eventId) {
- return in_array($eventId, $permissions[$type]) ? TRUE : FALSE;
+ return in_array($eventId, Civi::$statics[__CLASS__]['permissions'][$type]) ? TRUE : FALSE;
}
- return $permissions;
+ return Civi::$statics[__CLASS__]['permissions'];
}
/**
$returnMessages = array();
- $participantRole = CRM_Event_PseudoConstant::participantRole();
$pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'");
$expiredStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
$waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
$expiredParticipantCount = $waitingConfirmCount = $waitingApprovalCount = 0;
//get all participant who's status in class pending and waiting
- $query = "SELECT * FROM civicrm_participant WHERE status_id IN {$statusIds} ORDER BY register_date";
-
$query = "
SELECT participant.id,
participant.contact_id,
}
/**
- * This function checks if there was any registraion for related event ids,
- * and returns array of ids with no regsitrations
+ * This function checks if there was any registration for related event ids,
+ * and returns array of ids with no registrations
*
* @param string or int or object... $eventID
*
}
}
$this->assign('totalTaxAmount', $totalTaxAmount);
- $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
+ $this->assign('taxTerm', $this->getSalesTaxTerm());
$this->assign('dataArray', $dataArray);
}
if (!empty($additionalParticipantDetails)) {
$displayOpt = CRM_Utils_Array::value('tax_display_settings', $invoiceSettings);
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
foreach ($fieldValues['options'] as $optionId => $optionVal) {
+ if (CRM_Utils_Array::value('visibility_id', $optionVal) != array_search('public', $visibility) &&
+ $adminFieldVisible == FALSE
+ ) {
+ continue;
+ }
+
$values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues);
if ($invoicing && isset($optionVal['tax_amount'])) {
$values['feeBlock']['value'][$fieldCnt] = CRM_Price_BAO_PriceField::getTaxLabel($optionVal, 'amount', $displayOpt, $taxTerm);
// CRM-7675
const EXPORT_ROW_COUNT = 100000;
- /**
- * Key representing the head of household in the relationship array.
- *
- * e.g. 8_a_b.
- *
- * @var string
- */
- protected static $headOfHouseholdRelationshipKey;
-
- /**
- * Key representing the head of household in the relationship array.
- *
- * e.g. 8_a_b.
- *
- * @var string
- */
- protected static $memberOfHouseholdRelationshipKey;
-
/**
* Key representing the head of household in the relationship array.
*
/**
* Get Query Group By Clause
- * @param int $exportMode
+ * @param \CRM_Export_BAO_ExportProcessor $processor
* Export Mode
- * @param string $queryMode
- * Query Mode
* @param array $returnProperties
* Return Properties
* @param object $query
* @return string $groupBy
* Group By Clause
*/
- public static function getGroupBy($exportMode, $queryMode, $returnProperties, $query) {
+ public static function getGroupBy($processor, $returnProperties, $query) {
$groupBy = '';
+ $exportMode = $processor->getExportMode();
+ $queryMode = $processor->getQueryMode();
if (!empty($returnProperties['tags']) || !empty($returnProperties['groups']) ||
CRM_Utils_Array::value('notes', $returnProperties) ||
// CRM-9552
$queryOperator = 'AND'
) {
- $processor = new CRM_Export_BAO_ExportProcessor($exportMode, $fields, $queryOperator);
+ $processor = new CRM_Export_BAO_ExportProcessor($exportMode, $fields, $queryOperator, $mergeSameHousehold);
$returnProperties = array();
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
// without manually testing the export of IM provider still works.
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
self::$relationshipTypes = $processor->getRelationshipTypes();
- //also merge Head of Household
- self::$memberOfHouseholdRelationshipKey = CRM_Utils_Array::key('Household Member of', self::$relationshipTypes);
- self::$headOfHouseholdRelationshipKey = CRM_Utils_Array::key('Head of Household for', self::$relationshipTypes);
$queryMode = $processor->getQueryMode();
foreach ($returnProperties as $key => $value) {
if (!$processor->isRelationshipTypeKey($key)) {
- $returnProperties[self::$memberOfHouseholdRelationshipKey][$key] = $value;
- $returnProperties[self::$headOfHouseholdRelationshipKey][$key] = $value;
+ foreach ($processor->getHouseholdRelationshipTypes() as $householdRelationshipType) {
+ if (!in_array($key, ['location_type', 'im_provider'])) {
+ $returnProperties[$householdRelationshipType][$key] = $value;
+ }
+ }
}
}
-
- unset($returnProperties[self::$memberOfHouseholdRelationshipKey]['location_type']);
- unset($returnProperties[self::$memberOfHouseholdRelationshipKey]['im_provider']);
- unset($returnProperties[self::$headOfHouseholdRelationshipKey]['location_type']);
- unset($returnProperties[self::$headOfHouseholdRelationshipKey]['im_provider']);
}
- list($relationQuery, $allRelContactArray) = self::buildRelatedContactArray($selectAll, $ids, $exportMode, $componentTable, $returnProperties, $queryMode);
+ list($relationQuery, $allRelContactArray) = self::buildRelatedContactArray($selectAll, $ids, $processor, $componentTable, $returnProperties);
// make sure the groups stuff is included only if specifically specified
// by the fields param (CRM-1969), else we limit the contacts outputted to only
$queryString = "$select $from $where $having";
- $groupBy = self::getGroupBy($exportMode, $queryMode, $returnProperties, $query);
+ $groupBy = self::getGroupBy($processor, $returnProperties, $query);
$queryString .= $groupBy;
// merge the records if they have corresponding households
if ($mergeSameHousehold) {
- self::mergeSameHousehold($exportTempTable, $headerRows, $sqlColumns, self::$memberOfHouseholdRelationshipKey);
- self::mergeSameHousehold($exportTempTable, $headerRows, $sqlColumns, self::$headOfHouseholdRelationshipKey);
+ foreach ($processor->getHouseholdRelationshipTypes() as $householdRelationshipType) {
+ self::mergeSameHousehold($exportTempTable, $sqlColumns, $householdRelationshipType);
+ }
}
// call export hook
self::writeCSVFromTable($exportTempTable, $headerRows, $sqlColumns, $exportMode);
}
else {
- // return tableName and sqlColumns in test context
+ // return tableName sqlColumns headerRows in test context
return array($exportTempTable, $sqlColumns, $headerRows);
}
*
* @param string $exportTempTable
* Temporary temp table that stores the records.
- * @param array $headerRows
- * Array of headers for the export file.
* @param array $sqlColumns
* Array of names of the table columns of the temp table.
* @param string $prefix
* Name of the relationship type that is prefixed to the table columns.
*/
- public static function mergeSameHousehold($exportTempTable, &$headerRows, &$sqlColumns, $prefix) {
+ public static function mergeSameHousehold($exportTempTable, &$sqlColumns, $prefix) {
$prefixColumn = $prefix . '_';
$allKeys = array_keys($sqlColumns);
$replaced = array();
- $headerRows = array_values($headerRows);
// name map of the non standard fields in header rows & sql columns
$mappingFields = array(
foreach ($replaced as $from => $to) {
$clause[] = "$from = $to ";
unset($sqlColumns[$to]);
- if ($key = CRM_Utils_Array::key($to, $allKeys)) {
- unset($headerRows[$key]);
- }
}
$query .= implode(",\n", $clause);
$query .= " WHERE {$replaced['civicrm_primary_id']} != ''";
* Columns to go in the temp table.
* @param \CRM_Export_BAO_ExportProcessor $processor
* @param array|string $value
- * @param array $phoneTypes
- * @param array $imProviders
*
* @return array
*/
- public static function setHeaderRows($field, $headerRows, $sqlColumns, $processor, $value, $phoneTypes, $imProviders) {
+ public static function setHeaderRows($field, $headerRows, $sqlColumns, $processor, $value) {
$queryFields = $processor->getQueryFields();
if (substr($field, -11) == 'campaign_id') {
// @todo - set this correctly in the xml rather than here.
$headerRows[] = ts('Campaign ID');
}
+ elseif ($processor->isMergeSameHousehold() && $field === 'id') {
+ $headerRows[] = ts('Household ID');
+ }
elseif (isset($queryFields[$field]['title'])) {
$headerRows[] = $queryFields[$field]['title'];
}
}
}
- $headerRows[] = $headerName;
+ if (!$processor->isHouseholdMergeRelationshipTypeKey($field)) {
+ // Do not add to header row if we are only generating for merge reasons.
+ $headerRows[] = $headerName;
+ }
self::sqlColumnDefn($processor, $sqlColumns, $headerName);
}
if (!empty($type[1])) {
if (CRM_Utils_Array::value(0, $type) == 'phone') {
- $hdr .= "-" . CRM_Utils_Array::value($type[1], $phoneTypes);
+ $hdr .= "-" . CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Phone', 'phone_type_id', $type[1]);
}
elseif (CRM_Utils_Array::value(0, $type) == 'im') {
- $hdr .= "-" . CRM_Utils_Array::value($type[1], $imProviders);
+ $hdr .= "-" . CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_IM', 'provider_id', $type[1]);
}
}
$headerName = $field . '-' . $hdr;
$metadata = $headerRows = $outputColumns = $sqlColumns = array();
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
-
$queryFields = $processor->getQueryFields();
foreach ($returnProperties as $key => $value) {
if ($key != 'location' || !is_array($value)) {
$outputColumns[$key] = $value;
- list($headerRows, $sqlColumns) = self::setHeaderRows($key, $headerRows, $sqlColumns, $processor, $value, $phoneTypes, $imProviders);
+ list($headerRows, $sqlColumns) = self::setHeaderRows($key, $headerRows, $sqlColumns, $processor, $value);
}
else {
foreach ($value as $locationType => $locationFields) {
$metadata[$daoFieldName]['pseudoconstant']['var'] = 'imProviders';
}
self::sqlColumnDefn($processor, $sqlColumns, $outputFieldName);
- list($headerRows, $sqlColumns) = self::setHeaderRows($outputFieldName, $headerRows, $sqlColumns, $processor, $value, $phoneTypes, $imProviders);
+ list($headerRows, $sqlColumns) = self::setHeaderRows($outputFieldName, $headerRows, $sqlColumns, $processor, $value);
if ($actualDBFieldName == 'country' || $actualDBFieldName == 'world_region') {
$metadata[$daoFieldName] = array('context' => 'country');
}
/**
* @param $selectAll
* @param $ids
- * @param $exportMode
+ * @param \CRM_Export_BAO_ExportProcessor $processor
* @param $componentTable
* @param $returnProperties
- * @param $queryMode
+ *
* @return array
*/
- protected static function buildRelatedContactArray($selectAll, $ids, $exportMode, $componentTable, $returnProperties, $queryMode) {
+ protected static function buildRelatedContactArray($selectAll, $ids, $processor, $componentTable, $returnProperties) {
$allRelContactArray = $relationQuery = array();
-
+ $queryMode = $processor->getQueryMode();
+ $exportMode = $processor->getExportMode();
foreach (self::$relationshipTypes as $rel => $dnt) {
if ($relationReturnProperties = CRM_Utils_Array::value($rel, $returnProperties)) {
$allRelContactArray[$rel] = array();
*/
protected $requestedFields;
+ /**
+ * Is the contact being merged into a single household.
+ *
+ * @var bool
+ */
+ protected $isMergeSameHousehold;
+
/**
* Key representing the head of household in the relationship array.
*
* @param int $exportMode
* @param array|NULL $requestedFields
* @param string $queryOperator
+ * @param bool $isMergeSameHousehold
*/
- public function __construct($exportMode, $requestedFields, $queryOperator) {
+ public function __construct($exportMode, $requestedFields, $queryOperator, $isMergeSameHousehold = FALSE) {
$this->setExportMode($exportMode);
$this->setQueryMode();
$this->setQueryOperator($queryOperator);
$this->setRequestedFields($requestedFields);
$this->setRelationshipTypes();
+ $this->setIsMergeSameHousehold($isMergeSameHousehold);
}
/**
);
}
+ /**
+ * @return bool
+ */
+ public function isMergeSameHousehold() {
+ return $this->isMergeSameHousehold;
+ }
+
+ /**
+ * @param bool $isMergeSameHousehold
+ */
+ public function setIsMergeSameHousehold($isMergeSameHousehold) {
+ $this->isMergeSameHousehold = $isMergeSameHousehold;
+ }
+
+ /**
+ * Return relationship types for household merge.
+ *
+ * @return mixed
+ */
+ public function getHouseholdRelationshipTypes() {
+ if (!$this->isMergeSameHousehold()) {
+ return [];
+ }
+ return [
+ CRM_Utils_Array::key('Household Member of', $this->getRelationshipTypes()),
+ CRM_Utils_Array::key('Head of Household for', $this->getRelationshipTypes()),
+ ];
+ }
/**
* @param $fieldName
return array_key_exists($fieldName, $this->relationshipTypes);
}
+
+ /**
+ * @param $fieldName
+ * @return bool
+ */
+ public function isHouseholdMergeRelationshipTypeKey($fieldName) {
+ return in_array($fieldName, $this->getHouseholdRelationshipTypes());
+ }
+
/**
* @return string
*/
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return CRM_Core_DAO|null
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_FinancialAccount', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return CRM_Financial_DAO_PaymentProcessor|null
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_PaymentProcessor', $id, 'is_active', $is_active);
*/
public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $isCurrentDomainOnly = TRUE) {
- $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . $mode . '_' . CRM_Core_Config::domainID();
+ $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . $mode . '_' . $isCurrentDomainOnly . '_' . CRM_Core_Config::domainID();
if (!$reset) {
$processors = CRM_Utils_Cache::singleton()->get($cacheKey);
if (!empty($processors)) {
public static function getPaymentProcessors($capabilities = array(), $ids = FALSE) {
$testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : array();
if (is_array($ids)) {
- $processors = self::getAllPaymentProcessors('all', TRUE, FALSE);
+ $processors = self::getAllPaymentProcessors('all', FALSE, FALSE);
}
else {
- $processors = self::getAllPaymentProcessors('all', TRUE);
+ $processors = self::getAllPaymentProcessors('all');
}
if (in_array('TestMode', $capabilities) && is_array($ids)) {
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_PaymentProcessorType', $id, 'is_active', $is_active);
* @return array
*/
public function setDefaultValues() {
- return $this->_values;
+ $defaults = $this->_values;
+ // Format money fields - localize for display
+ $moneyFields = ['total_amount', 'fee_amount', 'net_amount'];
+ foreach ($moneyFields as $field) {
+ $defaults[$field] = CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($this->_values[$field]);
+ }
+ return $defaults;
}
/**
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.7 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2018
+ */
+
+trait CRM_Financial_Form_SalesTaxTrait {
+
+ /**
+ * Assign the sales tax term to the template.
+ */
+ public function assignSalesTaxTermToTemplate() {
+ $this->assign('taxTerm', $this->getSalesTaxTerm());
+ }
+
+ /**
+ * Assign sales tax rates to the template.
+ */
+ public function assignSalesTaxRates() {
+ $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
+ }
+
+ /**
+ * Return the string to be assigned to the template for sales tax - e.g GST, VAT.
+ *
+ * @return string
+ */
+ public function getSalesTaxTerm() {
+ $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
+ $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
+ if (!$invoicing) {
+ return '';
+ }
+ return CRM_Utils_Array::value('tax_term', $invoiceSettings);
+ }
+
+ /**
+ * Assign information to the template required for sales tax purposes.
+ */
+ public function assignSalesTaxMetadataToTemplate() {
+ $this->assignSalesTaxRates();
+ $this->assignSalesTaxTermToTemplate();
+ }
+
+ /**
+ * Get sales tax rates.
+ *
+ * @return array
+ */
+ public function getTaxRatesForFinancialTypes() {
+ return CRM_Core_PseudoConstant::getTaxRates();
+ }
+
+ /**
+ * @param int $financialTypeID
+ *
+ * @return string
+ */
+ public function getTaxRateForFinancialType($financialTypeID) {
+ return CRM_Utils_Array::value($financialTypeID, $this->getTaxRatesForFinancialTypes());
+ }
+
+}
if ($pcomponent == 'event') {
$this->_entityTable = 'civicrm_event';
$isShare = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_entityId, 'is_share');
+ $this->_title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_entityId, 'title');
}
else {
$isShare = CRM_Utils_Array::value('is_share', $values);
$updateLogConn = TRUE;
}
if (!empty($alterSql)) {
- CRM_Core_DAO::executeQuery("ALTER TABLE {$this->db}.{$logTable} " . implode(', ', $alterSql));
+ CRM_Core_DAO::executeQuery("ALTER TABLE {$this->db}.{$logTable} " . implode(', ', $alterSql), [], TRUE, NULL, FALSE, FALSE);
}
}
if ($updateLogConn) {
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Component', $id, 'is_active', $is_active);
// Get recipients selected in prior mailings
if (!empty($priorMailingIDs['Include'])) {
CRM_Utils_SQL_Select::from('civicrm_mailing_recipients')
- ->select("contact_id, $entityColumn")
+ ->select("DISTINCT civicrm_mailing_recipients.contact_id, $entityColumn")
+ ->join('temp', " LEFT JOIN $excludeTempTablename temp ON civicrm_mailing_recipients.contact_id = temp.contact_id ")
->where('mailing_id IN (#mailings)')
+ ->where('temp.contact_id IS NULL')
->param('#mailings', $priorMailingIDs['Include'])
->insertIgnoreInto($includedTempTablename, array('contact_id', $entityColumn))
->execute();
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Member_DAO_MembershipStatus', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Member_DAO_MembershipType', $id, 'is_active', $is_active);
*
* @param int $membershipId
* @param $changeToday
+ * If provided, specify an alternative date to use as "today" for renewal
* @param int $membershipTypeID
* If provided, overrides the membership type of the $membershipID membership.
* @param int $numRenewTerms
return 'Membership';
}
+ /**
+ * @var array
+ */
+ protected $statusMessage = [];
+
+ /**
+ * Add to the status message.
+ *
+ * @param $message
+ */
+ protected function addStatusMessage($message) {
+ $this->statusMessage[] = $message;
+ }
+
+ /**
+ * Get the status message.
+ *
+ * @return string
+ */
+ protected function getStatusMessage() {
+ return implode(' ', $this->statusMessage);
+ }
+
/**
* Values submitted to the form, processed along the way.
*
* Build the form object.
*/
public function buildQuickForm() {
+ $this->assignSalesTaxMetadataToTemplate();
$this->addPaymentProcessorSelect(TRUE, FALSE, TRUE);
CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->getDefaultPaymentInstrumentId());
*/
public function buildQuickForm() {
- $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
-
$this->assign('currency', CRM_Core_Config::singleton()->defaultCurrencySymbol);
- $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
- $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
- if (isset($invoicing)) {
- $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
- }
+ $isUpdateToExistingRecurringMembership = $this->isUpdateToExistingRecurringMembership();
// build price set form.
$buildPriceSet = FALSE;
if ($this->_priceSetId || !empty($_POST['price_set_id'])) {
);
$sel->setOptions(array($selMemTypeOrg, $selOrgMemType));
- $elements = array();
- if ($sel) {
- $elements[] = $sel;
+ if ($isUpdateToExistingRecurringMembership) {
+ $sel->freeze();
}
$this->applyFilter('__ALL__', 'trim');
$this->addDate('join_date', ts('Member Since'), FALSE, array('formatType' => 'activityDate'));
$this->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'activityDate'));
$endDate = $this->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'activityDate'));
- if ($endDate) {
- $elements[] = $endDate;
+ if ($endDate && $isUpdateToExistingRecurringMembership) {
+ $endDate->freeze();
}
$this->add('text', 'source', ts('Source'),
$statusOverride = $this->addElement('select', 'is_override', ts('Status Override?'),
CRM_Member_StatusOverrideTypes::getSelectOptions()
);
- if ($statusOverride) {
- $elements[] = $statusOverride;
+ if ($statusOverride && $isUpdateToExistingRecurringMembership) {
+ $statusOverride->freeze();
}
$this->add('datepicker', 'status_override_end_date', ts('Status Override End Date'), '', FALSE, array('minDate' => time(), 'time' => FALSE));
$this->assign('displayName', $this->_memberDisplayName);
}
- $isRecur = FALSE;
- if ($this->_action & CRM_Core_Action::UPDATE) {
- $recurContributionId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id,
- 'contribution_recur_id'
+ if ($isUpdateToExistingRecurringMembership && CRM_Member_BAO_Membership::isCancelSubscriptionSupported($this->_id)) {
+ $this->assign('cancelAutoRenew',
+ CRM_Utils_System::url('civicrm/contribute/unsubscribe', "reset=1&mid={$this->_id}")
);
- if ($recurContributionId && !CRM_Member_BAO_Membership::isSubscriptionCancelled($this->_id)) {
- $isRecur = TRUE;
- if (CRM_Member_BAO_Membership::isCancelSubscriptionSupported($this->_id)) {
- $this->assign('cancelAutoRenew',
- CRM_Utils_System::url('civicrm/contribute/unsubscribe', "reset=1&mid={$this->_id}")
- );
- }
- foreach ($elements as $elem) {
- $elem->freeze();
- }
- }
}
- $this->assign('isRecur', $isRecur);
+
+ $this->assign('isRecur', $isUpdateToExistingRecurringMembership);
$this->addFormRule(array('CRM_Member_Form_Membership', 'formRule'), $this);
$mailingInfo = Civi::settings()->get('mailing_backend');
$formValues = $this->setPriceSetParameters($formValues);
$params = $softParams = $ids = array();
- $allMemberStatus = CRM_Member_PseudoConstant::membershipStatus();
- $allContributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$this->processBillingAddress();
if ($this->_id) {
$params['tax_amount'] = $formValues['tax_amount'];
}
$params['total_amount'] = CRM_Utils_Array::value('amount', $formValues);
- $submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues);
if (!empty($lineItem[$this->_priceSetId])) {
foreach ($lineItem[$this->_priceSetId] as &$li) {
if (!empty($li['membership_type_id'])) {
///CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//lineitems with the financial type selected in form
+ $submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues);
if ($isQuickConfig && $submittedFinancialType) {
$li['financial_type_id'] = $submittedFinancialType;
}
}
}
- // max related memberships - take from form or inherit from membership type
foreach ($this->_memTypeSelected as $memType) {
if (array_key_exists('max_related', $formValues)) {
+ // max related memberships - take from form or inherit from membership type
$membershipTypeValues[$memType]['max_related'] = CRM_Utils_Array::value('max_related', $formValues);
}
$membershipTypeValues[$memType]['custom'] = CRM_Core_BAO_CustomField::postProcess($formValues,
$softParams['contact_id'] = $this->_contactID;
}
}
+
+ $pendingMembershipStatusId = CRM_Core_PseudoConstant::getKey('CRM_Member_BAO_Membership', 'status_id', 'Pending');
+
if (!empty($formValues['record_contribution'])) {
$recordContribution = array(
'total_amount',
}
}
+ $completedContributionStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
if (empty($params['is_override']) &&
- CRM_Utils_Array::value('contribution_status_id', $params) != array_search('Completed', $allContributionStatus)
+ CRM_Utils_Array::value('contribution_status_id', $params) != $completedContributionStatusId
) {
- $params['status_id'] = array_search('Pending', $allMemberStatus);
+ $params['status_id'] = $pendingMembershipStatusId;
$params['skipStatusCal'] = TRUE;
$params['is_pay_later'] = 1;
$this->assign('is_pay_later', 1);
$ids['contribution'] = $contribution->id;
$params['contribution_recur_id'] = $paymentParams['contributionRecurID'];
}
+ $paymentStatus = NULL;
if ($params['total_amount'] > 0.0) {
$payment = $this->_paymentProcessor['object'];
try {
$result = $payment->doPayment($paymentParams);
$formValues = array_merge($formValues, $result);
+ $paymentStatus = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $formValues['payment_status_id']);
// Assign amount to template if payment was successful.
$this->assign('amount', $params['total_amount']);
}
}
}
- if ($formValues['payment_status_id'] != array_search('Completed', $allContributionStatus)) {
- $params['status_id'] = array_search('Pending', $allMemberStatus);
+ if ($paymentStatus !== 'Completed') {
+ $params['status_id'] = $pendingMembershipStatusId;
$params['skipStatusCal'] = TRUE;
// unset send-receipt option, since receipt will be sent when ipn is received.
unset($formValues['send_receipt'], $formValues['send_receipt']);
}
}
$now = date('YmdHis');
- $params['receive_date'] = $now;
+ $params['receive_date'] = date('YmdHis');
$params['invoice_id'] = $formValues['invoiceID'];
$params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)',
array(1 => $membershipType, 2 => $userName)
}
if ($taxAmount) {
$this->assign('totalTaxAmount', $totalTaxAmount);
- $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
+ // Not sure why would need this on Submit.... unless it's being used when sending mails in which case this is the wrong place
+ $this->assign('taxTerm', $this->getSalesTaxTerm());
}
$this->assign('dataArray', $dataArray);
}
*
* @param CRM_Member_BAO_Membership $membership
* @param string $endDate
- * @param bool $receiptSend
*
* @return string
*/
- protected function getStatusMessageForUpdate($membership, $endDate, $receiptSend) {
+ protected function getStatusMessageForUpdate($membership, $endDate) {
// End date can be modified by hooks, so if end date is set then use it.
$endDate = ($membership->end_date) ? $membership->end_date : $endDate;
$endDate = CRM_Utils_Date::customFormat($endDate);
$statusMsg .= ' ' . ts('The membership End Date is %1.', array(1 => $endDate));
}
-
- if ($receiptSend) {
- $statusMsg .= ' ' . ts('A confirmation and receipt has been sent to %1.', array(1 => $this->_contributorEmail));
- }
return $statusMsg;
}
* Get status message for create action.
*
* @param string $endDate
- * @param bool $receiptSend
* @param array $membershipTypes
* @param array $createdMemberships
* @param bool $isRecur
* @param array $calcDates
- * @param bool $mailSent
*
* @return array|string
*/
- protected function getStatusMessageForCreate($endDate, $receiptSend, $membershipTypes, $createdMemberships,
- $isRecur, $calcDates, $mailSent) {
+ protected function getStatusMessageForCreate($endDate, $membershipTypes, $createdMemberships,
+ $isRecur, $calcDates) {
// FIX ME: fix status messages
$statusMsg = array();
}
}
$statusMsg = implode('<br/>', $statusMsg);
- if ($receiptSend && !empty($mailSent)) {
- $statusMsg .= ' ' . ts('A membership confirmation and receipt has been sent to %1.', array(1 => $this->_contributorEmail));
- }
return $statusMsg;
}
* @param $createdMemberships
* @param $isRecur
* @param $calcDates
- * @param $mailSend
+ * @param $mailSent
*/
- protected function setStatusMessage($membership, $endDate, $receiptSend, $membershipTypes, $createdMemberships, $isRecur, $calcDates, $mailSend) {
- $statusMsg = '';
+ protected function setStatusMessage($membership, $endDate, $receiptSend, $membershipTypes, $createdMemberships, $isRecur, $calcDates, $mailSent) {
if (($this->_action & CRM_Core_Action::UPDATE)) {
- $statusMsg = $this->getStatusMessageForUpdate($membership, $endDate, $receiptSend);
+ $this->addStatusMessage($this->getStatusMessageForUpdate($membership, $endDate));
}
elseif (($this->_action & CRM_Core_Action::ADD)) {
- $statusMsg = $this->getStatusMessageForCreate($endDate, $receiptSend, $membershipTypes, $createdMemberships,
- $isRecur, $calcDates, $mailSend);
+ $this->addStatusMessage($this->getStatusMessageForCreate($endDate, $membershipTypes, $createdMemberships,
+ $isRecur, $calcDates));
+ }
+ if ($receiptSend && $mailSent) {
+ $this->addStatusMessage(ts('A membership confirmation and receipt has been sent to %1.', array(1 => $this->_contributorEmail)));
}
- CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
+ CRM_Core_Session::setStatus($this->getStatusMessage(), ts('Complete'), 'success');
//CRM-15187
// display message when membership type is changed
if (($this->_action & CRM_Core_Action::UPDATE) && $this->_id && !in_array($this->_memType, $this->_memTypeSelected)) {
}
}
+ /**
+ * @return bool
+ */
+ protected function isUpdateToExistingRecurringMembership() {
+ $isRecur = FALSE;
+ if ($this->_action & CRM_Core_Action::UPDATE
+ && CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_id,
+ 'contribution_recur_id')
+ && !CRM_Member_BAO_Membership::isSubscriptionCancelled($this->_id)) {
+
+ $isRecur = TRUE;
+ }
+ return $isRecur;
+ }
+
}
}
//CRM-16950
- $taxRates = CRM_Core_PseudoConstant::getTaxRates();
- $taxRate = CRM_Utils_Array::value($this->allMembershipTypeDetails[$defaults['membership_type_id']]['financial_type_id'], $taxRates);
-
- $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
+ $taxRate = $this->getTaxRateForFinancialType($this->allMembershipTypeDetails[$defaults['membership_type_id']]['financial_type_id']);
// auto renew options if enabled for the membership
$options = CRM_Core_SelectValues::memberAutoRenew();
//CRM-16950
$taxAmount = NULL;
$totalAmount = CRM_Utils_Array::value('minimum_fee', $values);
- if (CRM_Utils_Array::value($values['financial_type_id'], $taxRates)) {
+ // @todo - feels a bug - we use taxRate from the form default rather than from the specified type?!?
+ if ($this->getTaxRateForFinancialType($values['financial_type_id'])) {
$taxAmount = ($taxRate / 100) * CRM_Utils_Array::value('minimum_fee', $values);
$totalAmount = $totalAmount + $taxAmount;
}
'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values),
'total_amount' => CRM_Utils_Money::format($totalAmount, NULL, '%a'),
'total_amount_numeric' => $totalAmount,
- 'tax_message' => $taxAmount ? ts("Includes %1 amount of %2", array(1 => CRM_Utils_Array::value('tax_term', $invoiceSettings), 2 => CRM_Utils_Money::format($taxAmount))) : $taxAmount,
+ 'tax_message' => $taxAmount ? ts("Includes %1 amount of %2", array(1 => $this->getSalesTaxTerm(), 2 => CRM_Utils_Money::format($taxAmount))) : $taxAmount,
);
if (!empty($values['auto_renew'])) {
* Campaign page id.
*
* @param bool $is_active
- * @return null
+ *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setDisable($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_PCP_DAO_PCP', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise.
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceField', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceFieldValue', $id, 'is_active', $is_active);
* Id of the database record.
* @param $isActive
*
- * @internal param bool $is_active value we want to set the is_active field
- *
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $isActive) {
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $id, 'is_active', $isActive);
* @param bool $isQuickConfig we want to set the is_quick_config field.
* Value we want to set the is_quick_config field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsQuickConfig($id, $isQuickConfig) {
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $id, 'is_quick_config', $isQuickConfig);
* @return CRM_Report_DAO_ReportInstance
*/
public static function add(&$params) {
- $instance = new CRM_Report_DAO_ReportInstance();
if (empty($params)) {
return NULL;
}
$instance->save();
if ($instanceID) {
- CRM_Utils_Hook::pre('edit', 'ReportInstance', $instance->id, $instance);
+ CRM_Utils_Hook::post('edit', 'ReportInstance', $instance->id, $instance);
}
else {
- CRM_Utils_Hook::pre('create', 'ReportInstance', $instance->id, $instance);
+ CRM_Utils_Hook::post('create', 'ReportInstance', $instance->id, $instance);
}
return $instance;
}
if (!CRM_Core_Permission::check('view report sql')) {
return;
}
+ $ignored_output_modes = array('pdf', 'csv', 'print');
+ if (in_array($this->_outputMode, $ignored_output_modes)) {
+ return;
+ }
$this->tabs['Developer'] = array(
'title' => ts('Developer'),
'tpl' => 'Developer',
$this->sqlArray[] = $sql;
foreach ($this->sqlArray as $sql) {
foreach (array('LEFT JOIN') as $term) {
- $sql = str_replace($term, '<br>  ' . $term, $sql);
+ $sql = str_replace($term, '<br> ' . $term, $sql);
}
foreach (array('FROM', 'WHERE', 'GROUP BY', 'ORDER BY', 'LIMIT', ';') as $term) {
$sql = str_replace($term, '<br><br>' . $term, $sql);
$this->sqlFormattedArray[] = $sql;
$this->assign('sql', implode(';<br><br><br><br>', $this->sqlFormattedArray));
}
+ $this->assign('sqlModes', $sqlModes = CRM_Utils_SQL::getSqlModes());
+
}
/**
if (!empty($field['pseudofield'])) {
continue;
}
- $clause = NULL;
- if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
- if (CRM_Utils_Array::value('operatorType', $field) ==
- CRM_Report_Form::OP_MONTH
- ) {
- $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
- $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params);
- if (is_array($value) && !empty($value)) {
- $clause
- = "(month({$field['dbAlias']}) $op (" . implode(', ', $value) .
- '))';
- }
- }
- else {
- $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
- $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
- $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
- $fromTime = CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params);
- $toTime = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params);
- $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type'], $fromTime, $toTime);
- }
- }
- else {
- $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
- if ($op) {
- $clause = $this->whereClause($field,
- $op,
- CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
- CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
- CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
- );
- }
- }
+ $clause = $this->generateFilterClause($field, $fieldName);
if (!empty($clause)) {
if (!empty($field['having'])) {
* @param array $field
* @param string $table
*/
- private function setEntityRefDefaults(&$field, $table) {
+ public function setEntityRefDefaults(&$field, $table) {
$field['attributes'] = $field['attributes'] ? $field['attributes'] : array();
$field['attributes'] += array(
'entity' => CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($table)),
}
}
+ /**
+ * Generate clause for the selected filter.
+ *
+ * @param array $field
+ * Field specification
+ * @param string $fieldName
+ * Field name.
+ *
+ * @return string
+ * Relevant where clause.
+ */
+ protected function generateFilterClause($field, $fieldName) {
+ if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
+ if (CRM_Utils_Array::value('operatorType', $field) ==
+ CRM_Report_Form::OP_MONTH
+ ) {
+ $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
+ $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params);
+ if (is_array($value) && !empty($value)) {
+ return "(month({$field['dbAlias']}) $op (" . implode(', ', $value) .
+ '))';
+ }
+ }
+ else {
+ $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
+ $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
+ $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
+ $fromTime = CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params);
+ $toTime = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params);
+ return $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type'], $fromTime, $toTime);
+ }
+ }
+ else {
+ $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
+ if ($op) {
+ return $this->whereClause($field,
+ $op,
+ CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
+ CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
+ CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
+ );
+ }
+ }
+ return '';
+ }
+
}
),
),
),
- 'civicrm_group' => array(
- 'dao' => 'CRM_Contact_DAO_Group',
- 'alias' => 'cgroup',
- 'filters' => array(
- 'gid' => array(
- 'name' => 'group_id',
- 'title' => ts('Group'),
- 'type' => CRM_Utils_Type::T_INT,
- 'group' => TRUE,
- 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Core_PseudoConstant::staticGroup(),
- ),
- ),
- ),
);
+ $this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
parent::__construct();
}
// Handle ID to label conversion for contact fields
$entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'contact/currentEmployer', 'View Contact Detail') ? TRUE : $entryFound;
-
+ $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, NULL, NULL) ? TRUE : $entryFound;
// display birthday in the configured custom format
if (array_key_exists('civicrm_contact_birth_date', $row)) {
$birthDate = $row['civicrm_contact_birth_date'];
$entryFound = TRUE;
}
- // handle country
- if (array_key_exists('civicrm_address_country_id', $row)) {
- if ($value = $row['civicrm_address_country_id']) {
- $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, FALSE);
- }
- $entryFound = TRUE;
- }
-
- if (array_key_exists('civicrm_address_state_province_id', $row)) {
- if ($value = $row['civicrm_address_state_province_id']) {
- $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE);
- }
- $entryFound = TRUE;
- }
-
// skip looking further in rows, if first row itself doesn't
// have the column we need
if (!$entryFound) {
$entryFound = TRUE;
}
- if (array_key_exists('civicrm_address_state_province_id', $row)) {
- if ($value = $row['civicrm_address_state_province_id']) {
- $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE);
- }
- $entryFound = TRUE;
- }
+ $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, NULL, NULL) ? TRUE : $entryFound;
// skip looking further in rows, if first row itself doesn't
// have the column we need
$entryFound = TRUE;
}
- // Handle country
- // @todo use alterDisplayAddressFields function
- if (array_key_exists('civicrm_address_country_id', $row)) {
- if ($value = $row['civicrm_address_country_id']) {
- $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, FALSE);
- }
- $entryFound = TRUE;
- }
-
- // Handle state/province
- // @todo use alterDisplayAddressFields function
- if (array_key_exists('civicrm_address_state_province_id', $row)) {
- if ($value = $row['civicrm_address_state_province_id']) {
- $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE);
- }
- $entryFound = TRUE;
- }
+ $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, NULL, NULL) ? TRUE : $entryFound;
// Handle contact name A
// @todo refactor into separate function
SELECT civicrm_contact_id, civicrm_contact_sort_name, civicrm_contribution_total_amount, civicrm_contribution_currency
FROM civireport_contribution_detail_temp2
WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribution_id']}";
- $this->addToDeveloperTab($query);
$dao = CRM_Core_DAO::executeQuery($query);
$string = '';
$separator = ($this->_outputMode !== 'csv') ? "<br/>" : ' ';
SELECT civicrm_contact_id, civicrm_contact_sort_name
FROM civireport_contribution_detail_temp1
WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribution_id']}";
- $this->addToDeveloperTab($query);
$dao = CRM_Core_DAO::executeQuery($query);
$string = '';
while ($dao->fetch()) {
$entryFound = TRUE;
}
- if (array_key_exists('civicrm_address_state_province_id', $row)) {
- if ($value = $row['civicrm_address_state_province_id']) {
- $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvince($value, FALSE);
- }
- $entryFound = TRUE;
- }
-
- if (array_key_exists('civicrm_address_country_id', $row)) {
- if ($value = $row['civicrm_address_country_id']) {
- $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, FALSE);
- }
- $entryFound = TRUE;
- }
-
if (array_key_exists('civicrm_contact_sort_name', $row) &&
$rows[$rowNum]['civicrm_contact_sort_name'] &&
array_key_exists('civicrm_contact_id', $row)
'fields' => array('email' => NULL),
'grouping' => 'contact-fields',
),
- 'civicrm_group' => array(
- 'dao' => 'CRM_Contact_DAO_Group',
- 'alias' => 'cgroup',
- 'filters' => array(
- 'gid' => array(
- 'name' => 'group_id',
- 'title' => ts('Group'),
- 'type' => CRM_Utils_Type::T_INT,
- 'group' => TRUE,
- 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Core_PseudoConstant::staticGroup(),
- ),
- ),
- ),
);
// If we have a campaign, build out the relevant elements
);
}
+ $this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
$this->_currencyColumn = 'civicrm_pledge_currency';
parent::__construct();
/**
* The recommended PHP version.
*/
- const RECOMMENDED_PHP_VER = '7.0';
+ const RECOMMENDED_PHP_VER = '7.1';
/**
* The previous recommended PHP version.
*/
- const MIN_RECOMMENDED_PHP_VER = '5.6';
+ const MIN_RECOMMENDED_PHP_VER = '7.0';
/**
* The minimum PHP version required to install Civi.
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2017 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License along with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Upgrade logic for FiveSix */
+class CRM_Upgrade_Incremental_php_FiveSix extends CRM_Upgrade_Incremental_Base {
+
+ /**
+ * Compute any messages which should be displayed beforeupgrade.
+ *
+ * Note: This function is called iteratively for each upcoming
+ * revision to the database.
+ *
+ * @param string $preUpgradeMessage
+ * @param string $rev
+ * a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
+ * @param null $currentVer
+ */
+ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
+ // Example: Generate a pre-upgrade message.
+ // if ($rev == '5.12.34') {
+ // $preUpgradeMessage .= '<p>' . ts('A new permission has been added called %1 This Permission is now used to control access to the Manage Tags screen', array(1 => 'manage tags')) . '</p>';
+ // }
+ }
+
+ /**
+ * Compute any messages which should be displayed after upgrade.
+ *
+ * @param string $postUpgradeMessage
+ * alterable.
+ * @param string $rev
+ * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
+ */
+ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
+ // Example: Generate a post-upgrade message.
+ // if ($rev == '5.12.34') {
+ // $postUpgradeMessage .= '<br /><br />' . ts("By default, CiviCRM now disables the ability to import directly from SQL. To use this feature, you must explicitly grant permission 'import SQL datasource'.");
+ // }
+ }
+
+ /*
+ * Important! All upgrade functions MUST add a 'runSql' task.
+ * Uncomment and use the following template for a new upgrade version
+ * (change the x in the function name):
+ */
+
+ // /**
+ // * Upgrade function.
+ // *
+ // * @param string $rev
+ // */
+ // public function upgrade_5_0_x($rev) {
+ // $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
+ // $this->addTask('Do the foo change', 'taskFoo', ...);
+ // // Additional tasks here...
+ // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex.
+ // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable.
+ // }
+
+ // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) {
+ // return TRUE;
+ // }
+
+}
--- /dev/null
+{* file to handle db changes in 5.6.alpha1 during upgrade *}
+
+ALTER TABLE civicrm_prevnext_cache
+ CHANGE `entity_id2` `entity_id2` int unsigned NULL COMMENT 'FK to entity table specified in entity_table column.';
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'is_active', $is_active);
* @param bool $isActive
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $isActive) {
return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $id, 'is_active', $isActive);
* @param bool $isQuickConfig we want to set the is_quick_config field.
* Value we want to set the is_quick_config field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsQuickConfig($id, $isQuickConfig) {
return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $id, 'is_quick_config', $isQuickConfig);
elseif (version_compare($phpVersion, CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER) >= 0) {
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
- ts('This system uses PHP version %1. This meets the minimum requirements for CiviCRM to function but is not recommended. At least PHP version %2 is recommended; the preferrred version is %3.',
+ ts('This system uses PHP version %1. This meets the minimum requirements for CiviCRM to function but is not recommended. At least PHP version %2 is recommended; the preferred version is %3.',
array(
1 => $phpVersion,
2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
*/
public function checkPhpEcrypt() {
$messages = array();
+ $mailingBackend = Civi::settings()->get('mailing_backend');
+ if (!is_array($mailingBackend)
+ || !isset($mailingBackend['outBound_option'])
+ || $mailingBackend['outBound_option'] != CRM_Mailing_Config::OUTBOUND_OPTION_SMTP
+ || !CRM_Utils_Array::value('smtpAuth', $mailingBackend)
+ ) {
+ return $messages;
+ }
+
$test_pass = 'iAmARandomString';
$encrypted_test_pass = CRM_Utils_Crypt::encrypt($test_pass);
if ($encrypted_test_pass == base64_encode($test_pass)) {
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
- ts('Your PHP does not include the recommended encryption functions. Some passwords will not be stored encrypted, and if you have recently upgraded from a PHP that does include these functions, your encrypted passwords will not be decrypted correctly. If you are using PHP 7.0 or earlier, you probably want to include the "%1" extension.',
- array('1' => 'mcrypt')
+ ts('Your PHP does not include the mcrypt encryption functions. Your SMTP password will not be stored encrypted, and if you have recently upgraded from a PHP that stored it with encryption, it will not be decrypted correctly.'
),
ts('PHP Missing Extension "mcrypt"'),
\Psr\Log\LogLevel::WARNING,
}
elseif (!is_writable($basedir)) {
$messages[] = new CRM_Utils_Check_Message(
- __FUNCTION__,
+ __FUNCTION__ . 'Writable',
ts('Your extensions directory (%1) is read-only. If you would like to perform downloads or upgrades, then change the file permissions.',
array(1 => $basedir)),
ts('Read-Only Extensions'),
\Psr\Log\LogLevel::WARNING,
'fa-plug'
);
- return $messages;
}
if (empty($extensionSystem->getDefaultContainer()->baseUrl)) {
$messages[] = new CRM_Utils_Check_Message(
- __FUNCTION__,
+ __FUNCTION__ . 'URL',
ts('The extensions URL is not properly set. Please go to the <a href="%1">URL setting page</a> and correct it.',
array(1 => CRM_Utils_System::url('civicrm/admin/setting/url', 'reset=1'))),
ts('Extensions url missing'),
\Psr\Log\LogLevel::ERROR,
'fa-plug'
);
- return $messages;
}
if (!$extensionSystem->getBrowser()->isEnabled()) {
if ($errors) {
$messages[] = new CRM_Utils_Check_Message(
- __FUNCTION__,
+ __FUNCTION__ . 'Error',
'<ul><li>' . implode('</li><li>', $errors) . '</li></ul>',
ts('Extension Error'),
\Psr\Log\LogLevel::ERROR,
* The name of an atomic permission, ie. 'access deleted contacts'
* @param bool $granted
* Whether this permission is currently granted. The hook can change this value.
+ * @param int $contactId
+ * Contact whose permissions we are checking (if null, assume current user).
*
* @return null
* The return value is ignored
*/
- public static function permission_check($permission, &$granted) {
- return self::singleton()->invoke(array('permission', 'granted'), $permission, $granted,
- self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
+ public static function permission_check($permission, &$granted, $contactId) {
+ return self::singleton()->invoke(array('permission', 'granted', 'contactId'), $permission, $granted, $contactId,
+ self::$_nullObject, self::$_nullObject, self::$_nullObject,
'civicrm_permission_check'
);
}
if (!$currency) {
$currency = $config->defaultCurrency;
}
-
- // money_format() exists only in certain PHP install (CRM-650)
- // setlocale() affects native gettext (CRM-11054, CRM-9976)
- if (is_numeric($amount) && function_exists('money_format')) {
- $lc = setlocale(LC_MONETARY, 0);
- setlocale(LC_MONETARY, 'en_US.utf8', 'en_US', 'en_US.utf8', 'en_US', 'C');
- $amount = money_format($valueFormat, $amount);
- setlocale(LC_MONETARY, $lc);
- }
-
- $rep = array(
- ',' => $config->monetaryThousandSeparator,
- '.' => $config->monetaryDecimalPoint,
- );
-
+ $amount = self::formatNumericByFormat($amount, $valueFormat);
// If it contains tags, means that HTML was passed and the
// amount is already converted properly,
// so don't mess with it again.
+ // @todo deprecate handling for the html tags because .... WTF
if (strpos($amount, '<') === FALSE) {
- $amount = strtr($amount, $rep);
+ $amount = self::replaceCurrencySeparators($amount);
}
$replacements = array(
return TRUE;
}
+ /**
+ * Format money for display (just numeric part) according to the current locale.
+ *
+ * This calls the underlying system function but does not handle currency separators.
+ *
+ * It's not totally clear when it changes the $amount value but has historical usage.
+ *
+ * @param $amount
+ *
+ * @return string
+ */
+ protected static function formatLocaleNumeric($amount) {
+ return self::formatNumericByFormat($amount, CRM_Core_Config::singleton()->moneyvalueformat);
+ }
+
+ /**
+ * Format money for display (just numeric part) according to the current locale with rounding.
+ *
+ * At this stage this is conceived as an internal function with the currency wrapper
+ * functions determining the number of places.
+ *
+ * This calls the underlying system function but does not handle currency separators.
+ *
+ * It's not totally clear when it changes the $amount value but has historical usage.
+ *
+ * @param string $amount
+ * @param int $numberOfPlaces
+ *
+ * @return string
+ */
+ protected static function formatLocaleNumericRounded($amount, $numberOfPlaces) {
+ return self::formatLocaleNumeric(round($amount, $numberOfPlaces));
+ }
+
+ /**
+ * Format money for display (just numeric part) according to the current locale with rounding.
+ *
+ * This handles both rounding & replacement of the currency separators for the locale.
+ *
+ * @param string $amount
+ * @param string $currency
+ *
+ * @return string
+ * Formatted amount.
+ */
+ public static function formatLocaleNumericRoundedByCurrency($amount, $currency) {
+ $amount = self::formatLocaleNumericRounded($amount, self::getCurrencyPrecision($currency));
+ return self::replaceCurrencySeparators($amount);
+ }
+
+ /**
+ * Format money for display (just numeric part) according to the current locale with rounding based on the
+ * default currency for the site.
+ *
+ * @param $amount
+ * @return mixed
+ */
+ public static function formatLocaleNumericRoundedForDefaultCurrency($amount) {
+ return self::formatLocaleNumericRoundedByCurrency($amount, self::getCurrencyPrecision(CRM_Core_Config::singleton()->defaultCurrency));
+ }
+
+ /**
+ * Replace currency separators.
+ *
+ * @param string $amount
+ *
+ * @return string
+ */
+ protected static function replaceCurrencySeparators($amount) {
+ $config = CRM_Core_Config::singleton();
+ $rep = array(
+ ',' => $config->monetaryThousandSeparator,
+ '.' => $config->monetaryDecimalPoint,
+ );
+ return strtr($amount, $rep);
+ }
+
+ /**
+ * Format numeric part of currency by the passed in format.
+ *
+ * This is envisaged as an internal function, with wrapper functions defining valueFormat
+ * into easily understood functions / variables and handling separator conversions and
+ * rounding.
+ *
+ * @param string $amount
+ * @param string $valueFormat
+ *
+ * @return string
+ */
+ protected static function formatNumericByFormat($amount, $valueFormat) {
+ // money_format() exists only in certain PHP install (CRM-650)
+ // setlocale() affects native gettext (CRM-11054, CRM-9976)
+ if (is_numeric($amount) && function_exists('money_format')) {
+ $lc = setlocale(LC_MONETARY, 0);
+ setlocale(LC_MONETARY, 'en_US.utf8', 'en_US', 'en_US.utf8', 'en_US', 'C');
+ $amount = money_format($valueFormat, $amount);
+ setlocale(LC_MONETARY, $lc);
+ }
+ return $amount;
+ }
+
}
* @param string $text
*/
public function generateLabel($text) {
+ // paddingLeft is used for both left & right padding so needs to be
+ // subtracted twice from width to get the width that is available for text
$args = array(
- 'w' => $this->width,
+ 'w' => $this->width - 2 * $this->paddingLeft,
'h' => 0,
'txt' => $text,
'border' => 0,
// make sure item is not already present in list
for ($i = 0; $i < count(self::$_recent); $i++) {
- if (self::$_recent[$i]['type'] === $type && self::$_recent[$i]['id'] === $id) {
+ if (self::$_recent[$i]['type'] === $type && self::$_recent[$i]['id'] == $id) {
// delete item from array
array_splice(self::$_recent, $i, 1);
break;
}
}
+ CRM_Utils_Hook::recent(self::$_recent);
$session = CRM_Core_Session::singleton();
$session->set(self::STORE_NAME, self::$_recent);
}
self::$_recent[] = $tempRecent[$i];
}
+ CRM_Utils_Hook::recent(self::$_recent);
$session = CRM_Core_Session::singleton();
$session->set(self::STORE_NAME, self::$_recent);
}
/**
* Check if a provider is allowed to add stuff.
- * If correspondig setting is empty, all are allowed
+ * If corresponding setting is empty, all are allowed
*
* @param string $providerName
+ * @return bool
*/
public static function isProviderEnabled($providerName) {
/**
* Gets the list of available providers to civi's recent items stack
+ *
+ * @return array
*/
public static function getProviders() {
$providers = array(
}
}
+ /**
+ * Append Drupal7 js to coreResourcesList.
+ *
+ * @param array $list
+ */
+ public function appendCoreResources(&$list) {
+ $list[] = 'js/crm.drupal7.js';
+ }
+
}
return \Drupal::languageManager()->getCurrentLanguage()->getId();
}
+ /**
+ * Append Drupal8 js to coreResourcesList.
+ *
+ * @param array $list
+ */
+ public function appendCoreResources(&$list) {
+ $list[] = 'js/crm.drupal8.js';
+ }
+
}
_drupal_flush_css_js();
}
- /**
- * Append Drupal js to coreResourcesList.
- *
- * @param array $list
- */
- public function appendCoreResources(&$list) {
- $list[] = 'js/crm.drupal.js';
- }
-
/**
* @inheritDoc
*/
*/
public function getBasePath() {
global $civicrm_root;
- $joomlaPath = explode('/administrator', $civicrm_root);
+ $joomlaPath = explode(DIRECTORY_SEPARATOR . 'administrator', $civicrm_root);
$joomlaBase = $joomlaPath[0];
return $joomlaBase;
}
define('JDEBUG', FALSE);
}
+ // Set timezone for Joomla on Cron
+ $config = JFactory::getConfig();
+ $timezone = $config->get('offset');
+ if ($timezone) {
+ date_default_timezone_set($timezone);
+ CRM_Core_Config::singleton()->userSystem->setMySQLTimeZone();
+ }
+
// CRM-14281 Joomla wasn't available during bootstrap, so hook_civicrm_config never executes.
$config = CRM_Core_Config::singleton();
CRM_Utils_Hook::config($config);
// less randomly.
\CRM_Utils_Hook::tokenValues($contactArray,
(array) $contactId,
- empty($row->context['mailingJob']) ? NULL : $row->context['mailingJob']->id,
+ empty($row->context['mailingJobId']) ? NULL : $row->context['mailingJobId'],
$messageTokens,
$row->context['controller']
);
});
};
scope.doSend = function doSend(recipient) {
+ recipient = JSON.parse(JSON.stringify(recipient).replace(/\,\s/g, ','));
scope.$eval(attr.onSend, {
preview: {recipient: recipient}
});
// @param mailing Object (per APIv3)
// @return Promise an object with "subject", "body_text", "body_html"
preview: function preview(mailing) {
+ return this.getPreviewContent(qApi, mailing);
+ },
+
+ // @param backend
+ // @param mailing Object (per APIv3)
+ // @return preview content
+ getPreviewContent: function getPreviewContent(backend, mailing) {
if (CRM.crmMailing.workflowEnabled && !CRM.checkPerm('create mailings') && !CRM.checkPerm('access CiviMail')) {
- return qApi('Mailing', 'preview', {id: mailing.id}).then(function(result) {
+ return backend('Mailing', 'preview', {id: mailing.id}).then(function(result) {
return result.values;
});
}
else {
- // Protect against races in saving and previewing by chaining create+preview.
- var params = angular.extend({}, mailing, mailing.recipients, {
- id: mailing.id,
- 'api.Mailing.preview': {
- id: '$value.id'
- }
- });
- delete params.scheduled_date;
- delete params.recipients; // the content was merged in
- params._skip_evil_bao_auto_recipients_ = 1; // skip recipient rebuild on mail preview
- return qApi('Mailing', 'create', params).then(function(result) {
- mailing.modified_date = result.values[result.id].modified_date;
+ var params = angular.extend({}, mailing);
+ delete params.id;
+ return backend('Mailing', 'preview', params).then(function(result) {
// changes rolled back, so we don't care about updating mailing
- return result.values[result.id]['api.Mailing.preview'].values;
+ return result.values;
});
}
},
};
var result = null;
var p = crmMailingMgr
- .preview(mailing)
+ .getPreviewContent(CRM.api3, mailing)
.then(function (content) {
var options = CRM.utils.adjustDialogDefaults({
autoOpen: false,
);
$params['tag_id'] = array(
'title' => 'Tags',
- 'description' => 'Find activities with specified tags.',
+ 'description' => 'Find cases with specified tags.',
'type' => 1,
'FKClassName' => 'CRM_Core_DAO_Tag',
'FKApiName' => 'Tag',
* @throws \API_Exception
*/
function civicrm_api3_mailing_preview($params) {
- civicrm_api3_verify_mandatory($params,
- 'CRM_Mailing_DAO_Mailing',
- array('id'),
- FALSE
- );
-
$fromEmail = NULL;
if (!empty($params['from_email'])) {
$fromEmail = $params['from_email'];
}
- $session = CRM_Core_Session::singleton();
$mailing = new CRM_Mailing_BAO_Mailing();
- $mailing->id = $params['id'];
- $mailing->find(TRUE);
+ $mailingID = CRM_Utils_Array::value('id', $params);
+ if ($mailingID) {
+ $mailing->id = $mailingID;
+ $mailing->find(TRUE);
+ }
+ else {
+ $mailing->copyValues($params);
+ }
+
+ $session = CRM_Core_Session::singleton();
CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
$params['payment_processor_type_id']['api.required'] = 1;
$params['is_default']['api.default'] = 0;
$params['is_test']['api.default'] = 0;
+ $params['domain_id']['api.default'] = CRM_Core_Config::domainID();
}
/**
$params['class_name']['api.required'] = 1;
$params['is_active']['api.default'] = 1;
$params['is_recur']['api.default'] = FALSE;
- // FIXME bool support // $params['is_recur']['api.required'] = 1;
$params['name']['api.required'] = 1;
$params['title']['api.required'] = 1;
$params['payment_instrument_id']['api.default'] = 'Credit Card';
*/
function civicrm_api3_setting_get($params) {
$domains = _civicrm_api3_setting_getDomainArray($params);
- $result = $result = CRM_Core_BAO_Setting::getItems($params, $domains, CRM_Utils_Array::value('return', $params, array()));
+ $result = CRM_Core_BAO_Setting::getItems($params, $domains, CRM_Utils_Array::value('return', $params, array()));
return civicrm_api3_create_success($result, $params, 'Setting', 'get');
}
/**
"require": {
"dompdf/dompdf" : "0.8.*",
"electrolinux/phpquery": "^0.9.6",
- "symfony/config": "^2.6.13 || ~3.0",
- "symfony/dependency-injection": "^2.6.13 || ~3.0",
- "symfony/event-dispatcher": "^2.6.13 || ~3.0",
- "symfony/filesystem": "^2.6.13 || ~3.0",
- "symfony/process": "^2.6.13 || ~3.0",
+ "symfony/config": "^2.8.44 || ~3.0",
+ "symfony/polyfill-iconv": "~1.0",
+ "symfony/dependency-injection": "^2.8.44 || ~3.0",
+ "symfony/event-dispatcher": "^2.8.44 || ~3.0",
+ "symfony/filesystem": "^2.8.44 || ~3.0",
+ "symfony/process": "^2.8.44 || ~3.0",
"psr/log": "~1.0.0",
- "symfony/finder": "^2.6.13 || ~3.0",
+ "symfony/finder": "^2.8.44 || ~3.0",
"tecnickcom/tcpdf" : "6.2.*",
"totten/ca-config": "~17.05",
"zetacomponents/base": "1.7.*",
{
"_readme": [
"This file locks the dependencies of your project to a known state",
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "233f9c457d9e7d49a6d96c356e1035f1",
+ "content-hash": "38f5450ab72f881008f5cd10bb588b6f",
"packages": [
{
"name": "civicrm/civicrm-cxn-rpc",
"extra": {
"branch-alias": {
"dev-develop": "0.7-dev"
+ },
+ "patches_applied": {
+ "Fix Fatal error: Uncaught Dompdf Exception: No block-level parent found.": "tools/scripts/composer/patches/dompdf_no_block_level_parent_fix.patch"
}
},
"autoload": {
"pear/auth_sasl": "Install optionally via your project's composer.json"
},
"type": "library",
+ "extra": {
+ "patches_applied": {
+ "CRM-8744 Display CiviCRM Specific error message": "tools/scripts/composer/patches/net-smtp-patch.patch",
+ "Fix PHP7 Compliance": "tools/scripts/composer/patches/net-smtp-php7-patch.patch",
+ "Fix Pass by reference issues": "tools/scripts/composer/patches/net-smtp-ref-patch.patch",
+ "Fix TLS support issue in PHP5.6": "tools/scripts/composer/patches/net-smtp-tls-patch.patch"
+ }
+ },
"autoload": {
"psr-0": {
"Net": "./"
},
{
"name": "symfony/config",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/Config",
+ "version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
- "reference": "0ca496cbe208fc37c4cf3415ebb3056e0963115b"
+ "reference": "06c0be4cdd8363f3ec8d592c9a4d1b981d5052af"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/config/zipball/0ca496cbe208fc37c4cf3415ebb3056e0963115b",
- "reference": "0ca496cbe208fc37c4cf3415ebb3056e0963115b",
+ "url": "https://api.github.com/repos/symfony/config/zipball/06c0be4cdd8363f3ec8d592c9a4d1b981d5052af",
+ "reference": "06c0be4cdd8363f3ec8d592c9a4d1b981d5052af",
"shasum": ""
},
"require": {
- "php": ">=5.3.3",
- "symfony/filesystem": "~2.3"
+ "php": ">=5.3.9",
+ "symfony/filesystem": "~2.3|~3.0.0",
+ "symfony/polyfill-ctype": "~1.8"
},
"require-dev": {
- "symfony/phpunit-bridge": "~2.7"
+ "symfony/yaml": "~2.7|~3.0.0"
+ },
+ "suggest": {
+ "symfony/yaml": "To use the yaml reference dumper"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.8-dev"
}
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"Symfony\\Component\\Config\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
- "time": "2015-07-08T05:59:48+00:00"
+ "time": "2018-07-26T11:13:39+00:00"
},
{
"name": "symfony/dependency-injection",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/DependencyInjection",
+ "version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
- "reference": "d9fe6837d74aed11e5ee741cd6b6dfe45e0af78e"
+ "reference": "ad2446d39d11c3daaa7f147d957941a187e47357"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/d9fe6837d74aed11e5ee741cd6b6dfe45e0af78e",
- "reference": "d9fe6837d74aed11e5ee741cd6b6dfe45e0af78e",
+ "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/ad2446d39d11c3daaa7f147d957941a187e47357",
+ "reference": "ad2446d39d11c3daaa7f147d957941a187e47357",
"shasum": ""
},
"require": {
- "php": ">=5.3.3"
+ "php": ">=5.3.9"
},
"conflict": {
"symfony/expression-language": "<2.6"
},
"require-dev": {
- "symfony/config": "~2.2",
- "symfony/expression-language": "~2.6",
- "symfony/phpunit-bridge": "~2.7",
- "symfony/yaml": "~2.1"
+ "symfony/config": "~2.2|~3.0.0",
+ "symfony/expression-language": "~2.6|~3.0.0",
+ "symfony/yaml": "~2.3.42|~2.7.14|~2.8.7|~3.0.7"
},
"suggest": {
"symfony/config": "",
+ "symfony/expression-language": "For using expressions in service container configuration",
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
"symfony/yaml": ""
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.8-dev"
}
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"Symfony\\Component\\DependencyInjection\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
- "time": "2015-07-22T10:08:40+00:00"
+ "time": "2018-07-26T11:13:39+00:00"
},
{
"name": "symfony/event-dispatcher",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/EventDispatcher",
+ "version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02"
+ "reference": "84ae343f39947aa084426ed1138bb96bf94d1f12"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/672593bc4b0043a0acf91903bb75a1c82d8f2e02",
- "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/84ae343f39947aa084426ed1138bb96bf94d1f12",
+ "reference": "84ae343f39947aa084426ed1138bb96bf94d1f12",
"shasum": ""
},
"require": {
- "php": ">=5.3.3"
+ "php": ">=5.3.9"
},
"require-dev": {
"psr/log": "~1.0",
- "symfony/config": "~2.0,>=2.0.5",
- "symfony/dependency-injection": "~2.6",
- "symfony/expression-language": "~2.6",
- "symfony/phpunit-bridge": "~2.7",
- "symfony/stopwatch": "~2.3"
+ "symfony/config": "^2.0.5|~3.0.0",
+ "symfony/dependency-injection": "~2.6|~3.0.0",
+ "symfony/expression-language": "~2.6|~3.0.0",
+ "symfony/stopwatch": "~2.3|~3.0.0"
},
"suggest": {
"symfony/dependency-injection": "",
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.8-dev"
}
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"Symfony\\Component\\EventDispatcher\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
- "time": "2015-05-02T15:18:45+00:00"
+ "time": "2018-07-26T09:03:18+00:00"
},
{
"name": "symfony/filesystem",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/Filesystem",
+ "version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
- "reference": "823c035b1a5c13a4924e324d016eb07e70f94735"
+ "reference": "2d6a4deccdfa2e4e9f113138b93457b2d0886c15"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/filesystem/zipball/823c035b1a5c13a4924e324d016eb07e70f94735",
- "reference": "823c035b1a5c13a4924e324d016eb07e70f94735",
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/2d6a4deccdfa2e4e9f113138b93457b2d0886c15",
+ "reference": "2d6a4deccdfa2e4e9f113138b93457b2d0886c15",
"shasum": ""
},
"require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "symfony/phpunit-bridge": "~2.7"
+ "php": ">=5.3.9",
+ "symfony/polyfill-ctype": "~1.8"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.8-dev"
}
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"Symfony\\Component\\Filesystem\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
- "time": "2015-07-08T05:59:48+00:00"
+ "time": "2018-07-26T11:13:39+00:00"
},
{
"name": "symfony/finder",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/Finder",
+ "version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "203a10f928ae30176deeba33512999233181dd28"
+ "reference": "f0de0b51913eb2caab7dfed6413b87e14fca780e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/203a10f928ae30176deeba33512999233181dd28",
- "reference": "203a10f928ae30176deeba33512999233181dd28",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/f0de0b51913eb2caab7dfed6413b87e14fca780e",
+ "reference": "f0de0b51913eb2caab7dfed6413b87e14fca780e",
"shasum": ""
},
"require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "symfony/phpunit-bridge": "~2.7"
+ "php": ">=5.3.9"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.8-dev"
}
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"Symfony\\Component\\Finder\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
- "time": "2015-07-09T16:02:48+00:00"
+ "time": "2018-07-26T11:13:39+00:00"
},
{
- "name": "symfony/process",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/Process",
+ "name": "symfony/polyfill-ctype",
+ "version": "v1.8.0",
"source": {
"type": "git",
- "url": "https://github.com/symfony/process.git",
- "reference": "57f1e88bb5dafa449b83f9f265b11d52d517b3e9"
+ "url": "https://github.com/symfony/polyfill-ctype.git",
+ "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/57f1e88bb5dafa449b83f9f265b11d52d517b3e9",
- "reference": "57f1e88bb5dafa449b83f9f265b11d52d517b3e9",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
+ "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
- "require-dev": {
- "symfony/phpunit-bridge": "~2.7"
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Ctype\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ },
+ {
+ "name": "Gert de Pagter",
+ "email": "BackEndTea@gmail.com"
+ }
+ ],
+ "description": "Symfony polyfill for ctype functions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "ctype",
+ "polyfill",
+ "portable"
+ ],
+ "time": "2018-04-30T19:57:29+00:00"
+ },
+ {
+ "name": "symfony/polyfill-iconv",
+ "version": "v1.9.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-iconv.git",
+ "reference": "bcc0cd69185b8a5d8b4a5400c489ed3333bf9bb2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/bcc0cd69185b8a5d8b4a5400c489ed3333bf9bb2",
+ "reference": "bcc0cd69185b8a5d8b4a5400c489ed3333bf9bb2",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "suggest": {
+ "ext-iconv": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "1.9-dev"
}
},
"autoload": {
- "psr-0": {
- "Symfony\\Component\\Process\\": ""
+ "psr-4": {
+ "Symfony\\Polyfill\\Iconv\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
}
+ ],
+ "description": "Symfony polyfill for the Iconv extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "iconv",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "time": "2018-08-06T14:22:27+00:00"
+ },
+ {
+ "name": "symfony/process",
+ "version": "v2.8.44",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/process.git",
+ "reference": "cc83afdb5ac99147806b3bb65a3ff1227664f596"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/process/zipball/cc83afdb5ac99147806b3bb65a3ff1227664f596",
+ "reference": "cc83afdb5ac99147806b3bb65a3ff1227664f596",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Process\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
- "time": "2015-06-30T16:10:16+00:00"
+ "time": "2018-07-26T11:13:39+00:00"
},
{
"name": "tecnickcom/tcpdf",
text-align: right;
}
+.crm-container .crm-section .label label{
+ white-space: normal;
+}
+
.crm-container .label-left .label {
text-align: left;
}
}
#civicrm-menu {
- position:absolute;
+ position:fixed;
top:0;
left:0;
background:#1B1B1B repeat-x;
#crm-container div.crm-inline-edit.form {
cursor: default;
border: 2px dashed #6665BF;
- overflow: auto;
+ box-shadow: rgba(255, 255, 255, 0.3) 0 0 0 99999px;
+ background-color: white;
+ float: left;
+ z-index: 99;
+}
+
+#mainTabContainer:not(.narrowpage) .contactCardRight div.crm-inline-edit.form {
+ float: right;
}
#crm-container .crm-inline-edit.add-new {
border-bottom-left-radius: 1em;
}
-#crm-container .crm-inline-edit.add-new .crm-edit-help {
+#crm-container .crm-address-block+.crm-address-block .add-new .crm-edit-help {
display: block;
background-color: #EBEBEB;
}
-#crm-container .crm-edit-ready .crm-inline-edit:hover .crm-edit-help {
+#crm-container .crm-edit-ready .crm-summary-block .crm-inline-edit:hover .crm-edit-help {
display: block;
background-color: #DFE1FF;
}
display: none !important;
}
+#crm-container .crm-address-block+.crm-address-block .add-new .crm-summary-row {
+ display: none;
+}
+
#crm-container span.crm-custom-greeting {
font-size: 9px;
}
white-space: nowrap;
}
#crm-container table.crm-inline-edit-form td.crm-label,
-#crm-container div.crm-inline-edit-form .crm-label {
+#crm-container div.crm-inline-edit-form .crm-label,
+#crm-container div.crm-inline-edit-form .messages {
white-space: normal;
}
/* Moved from civicrm.css in v3.2 */
ul#civicrm-menu {
- z-index: 1;
position:relative;
- border: none;
- left:0px;
- height:0px;
- padding: 2px 0px 25px 2px !important;
- padding-bottom:25px !important; /*moz bottom */
- padding-bottom:2px; /*ie bottom */
}
div#toolbar-box div.m {
$.each(result.values, function (id, value) {
$.each(value, function (fieldname, fieldvalue) {
$('#' + fieldname).val(fieldvalue).change();
- $("[name=" + fieldname + "]").val([fieldvalue]);
+ $('[name="' + fieldname + '"]').val([fieldvalue]);
if ($.isArray(fieldvalue)) {
$.each(fieldvalue, function (index, val) {
$("#" + fieldname + "_" + val).prop('checked', true);
return combined;
}
- function copyAttributes($source, $target, attributes) {
+ CRM.utils.copyAttributes = function ($source, $target, attributes) {
_.each(attributes, function(name) {
if ($source.attr(name) !== undefined) {
$target.attr(name, $source.attr(name));
}
});
- }
-
- /**
- * @see http://wiki.civicrm.org/confluence/display/CRMDOC/crmDatepicker
- */
- $.fn.crmDatepicker = function(options) {
- return $(this).each(function() {
- if ($(this).is('.crm-form-date-wrapper .crm-hidden-date')) {
- // Already initialized - destroy
- $(this)
- .off('.crmDatepicker')
- .css('display', '')
- .removeClass('crm-hidden-date')
- .siblings().remove();
- $(this).unwrap();
- }
- if (options === 'destroy') {
- return;
- }
- var
- $dataField = $(this).wrap('<span class="crm-form-date-wrapper" />'),
- settings = _.cloneDeep(options || {}),
- $dateField = $(),
- $timeField = $(),
- $clearLink = $(),
- hasDatepicker = settings.date !== false && settings.date !== 'yy',
- type = hasDatepicker ? 'text' : 'number';
-
- if (settings.allowClear !== undefined ? settings.allowClear : !$dataField.is('.required, [required]')) {
- $clearLink = $('<a class="crm-hover-button crm-clear-link" title="'+ _.escape(ts('Clear')) +'"><i class="crm-i fa-times"></i></a>')
- .insertAfter($dataField);
- }
- if (settings.time !== false) {
- $timeField = $('<input>').insertAfter($dataField);
- copyAttributes($dataField, $timeField, ['class', 'disabled']);
- $timeField
- .addClass('crm-form-text crm-form-time')
- .attr('placeholder', $dataField.attr('time-placeholder') === undefined ? ts('Time') : $dataField.attr('time-placeholder'))
- .attr('aria-label', $dataField.attr('time-placeholder') === undefined ? ts('Time') : $dataField.attr('time-placeholder'))
- .change(updateDataField)
- .timeEntry({
- spinnerImage: '',
- show24Hours: settings.time === true || settings.time === undefined ? CRM.config.timeIs24Hr : settings.time == '24'
- });
- }
- if (settings.date !== false) {
- // Render "number" field for year-only format, calendar popup for all other formats
- $dateField = $('<input type="' + type + '">').insertAfter($dataField);
- copyAttributes($dataField, $dateField, ['placeholder', 'style', 'class', 'disabled', 'aria-label']);
- $dateField.addClass('crm-form-' + type);
- if (hasDatepicker) {
- settings.minDate = settings.minDate ? CRM.utils.makeDate(settings.minDate) : null;
- settings.maxDate = settings.maxDate ? CRM.utils.makeDate(settings.maxDate) : null;
- settings.dateFormat = typeof settings.date === 'string' ? settings.date : CRM.config.dateInputFormat;
- settings.changeMonth = _.includes(settings.dateFormat, 'm');
- settings.changeYear = _.includes(settings.dateFormat, 'y');
- if (!settings.yearRange && settings.minDate !== null && settings.maxDate !== null) {
- settings.yearRange = '' + CRM.utils.formatDate(settings.minDate, 'yy') + ':' + CRM.utils.formatDate(settings.maxDate, 'yy');
- }
- $dateField.addClass('crm-form-date').datepicker(settings);
- } else {
- $dateField.attr('min', settings.minDate ? CRM.utils.formatDate(settings.minDate, 'yy') : '1000');
- $dateField.attr('max', settings.maxDate ? CRM.utils.formatDate(settings.maxDate, 'yy') : '4000');
- }
- $dateField.change(updateDataField);
- }
- // Rudimentary validation. TODO: Roll into use of jQUery validate and ui.datepicker.validation
- function isValidDate() {
- // FIXME: parseDate doesn't work with incomplete date formats; skip validation if no month, day or year in format
- var lowerFormat = settings.dateFormat.toLowerCase();
- if (lowerFormat.indexOf('y') < 0 || lowerFormat.indexOf('m') < 0 || !dateHasDay()) {
- return true;
- }
- try {
- $.datepicker.parseDate(settings.dateFormat, $dateField.val());
- return true;
- } catch (e) {
- return false;
- }
- }
-
- /**
- * Does the date format contain the day.
- *
- * @returns {boolean}
- */
- function dateHasDay() {
- var lowerFormat = settings.dateFormat.toLowerCase();
- if (lowerFormat.indexOf('d') < 0) {
- return false;
- }
- return true;
- }
- function updateInputFields(e, context) {
- var val = $dataField.val(),
- time = null;
- if (context !== 'userInput' && context !== 'crmClear') {
- if (hasDatepicker) {
- $dateField.datepicker('setDate', _.includes(val, '-') ? $.datepicker.parseDate('yy-mm-dd', val) : null);
- } else if ($dateField.length) {
- $dateField.val(val.slice(0, 4));
- }
- if ($timeField.length) {
- if (val.length === 8) {
- time = val;
- } else if (val.length === 19) {
- time = val.split(' ')[1];
- }
- $timeField.timeEntry('setTime', time);
- }
- }
- $clearLink.css('visibility', val ? 'visible' : 'hidden');
- }
- function updateDataField(e, context) {
- // The crmClear event wipes all the field values anyway, so no need to respond
- if (context !== 'crmClear') {
- var val = '';
- if ($dateField.val()) {
- if (hasDatepicker && isValidDate() && dateHasDay()) {
- val = $.datepicker.formatDate('yy-mm-dd', $dateField.datepicker('getDate'));
- $dateField.removeClass('crm-error');
- } else if (!hasDatepicker) {
- val = $dateField.val() + '-01-01';
- }
- else if (!dateHasDay()) {
- // This would be a Year-month date (yyyy-mm)
- // it could be argued it should not use a datepicker....
- val = $dateField.val() + '-01';
- } else {
- $dateField.addClass('crm-error');
- }
- }
- if ($timeField.val()) {
- val += (val ? ' ' : '') + $timeField.timeEntry('getTime').toTimeString().substr(0, 8);
- }
- $dataField.val(val).trigger('change', ['userInput']);
- }
- }
- $dataField.hide().addClass('crm-hidden-date').on('change.crmDatepicker', updateInputFields);
- updateInputFields();
- });
};
CRM.utils.formatSelect2Result = function (row) {
return false;
}
// Compare arguments
- $.each(newUrl.split('?')[1].split('&'), function(k, v) {
+ $.each((newUrl.split('?')[1] || '').split('&'), function(k, v) {
var arg = v.split('=');
args[arg[0]] = arg[1];
});
- $.each(oldUrl.split('?')[1].split('&'), function(k, v) {
+ $.each((oldUrl.split('?')[1] || '').split('&'), function(k, v) {
var arg = v.split('=');
if (args[arg[0]] !== undefined && arg[1] !== args[arg[0]]) {
same = false;
--- /dev/null
+(function($, CRM, _) {
+ "use strict";
+
+ /**
+ * @see http://wiki.civicrm.org/confluence/display/CRMDOC/crmDatepicker
+ */
+ $.fn.crmDatepicker = function(options) {
+ return $(this).each(function() {
+ if ($(this).is('.crm-form-date-wrapper .crm-hidden-date')) {
+ // Already initialized - destroy
+ $(this)
+ .off('.crmDatepicker')
+ .css('display', '')
+ .removeClass('crm-hidden-date')
+ .siblings().remove();
+ $(this).unwrap();
+ }
+ if (options === 'destroy') {
+ return;
+ }
+ var
+ $dataField = $(this).wrap('<span class="crm-form-date-wrapper" />'),
+ settings = CRM._.cloneDeep(options || {}),
+ $dateField = $(),
+ $timeField = $(),
+ $clearLink = $(),
+ hasDatepicker = settings.date !== false && settings.date !== 'yy',
+ type = hasDatepicker ? 'text' : 'number';
+
+ if (settings.allowClear !== undefined ? settings.allowClear : !$dataField.is('.required, [required]')) {
+ $clearLink = $('<a class="crm-hover-button crm-clear-link" title="'+ CRM._.escape(ts('Clear')) +'"><i class="crm-i fa-times"></i></a>')
+ .insertAfter($dataField);
+ }
+ if (settings.time !== false) {
+ $timeField = $('<input>').insertAfter($dataField);
+ CRM.utils.copyAttributes($dataField, $timeField, ['class', 'disabled']);
+ $timeField
+ .addClass('crm-form-text crm-form-time')
+ .attr('placeholder', $dataField.attr('time-placeholder') === undefined ? ts('Time') : $dataField.attr('time-placeholder'))
+ .attr('aria-label', $dataField.attr('time-placeholder') === undefined ? ts('Time') : $dataField.attr('time-placeholder'))
+ .change(updateDataField)
+ .timeEntry({
+ spinnerImage: '',
+ show24Hours: settings.time === true || settings.time === undefined ? CRM.config.timeIs24Hr : settings.time == '24'
+ });
+ }
+ if (settings.date !== false) {
+ // Render "number" field for year-only format, calendar popup for all other formats
+ $dateField = $('<input type="' + type + '">').insertAfter($dataField);
+ CRM.utils.copyAttributes($dataField, $dateField, ['placeholder', 'style', 'class', 'disabled', 'aria-label']);
+ $dateField.addClass('crm-form-' + type);
+ if (hasDatepicker) {
+ settings.minDate = settings.minDate ? CRM.utils.makeDate(settings.minDate) : null;
+ settings.maxDate = settings.maxDate ? CRM.utils.makeDate(settings.maxDate) : null;
+ settings.dateFormat = typeof settings.date === 'string' ? settings.date : CRM.config.dateInputFormat;
+ settings.changeMonth = CRM._.includes(settings.dateFormat, 'm');
+ settings.changeYear = CRM._.includes(settings.dateFormat, 'y');
+ if (!settings.yearRange && settings.minDate !== null && settings.maxDate !== null) {
+ settings.yearRange = '' + CRM.utils.formatDate(settings.minDate, 'yy') + ':' + CRM.utils.formatDate(settings.maxDate, 'yy');
+ }
+ $dateField.addClass('crm-form-date').datepicker(settings);
+ } else {
+ $dateField.attr('min', settings.minDate ? CRM.utils.formatDate(settings.minDate, 'yy') : '1000');
+ $dateField.attr('max', settings.maxDate ? CRM.utils.formatDate(settings.maxDate, 'yy') : '4000');
+ }
+ $dateField.change(updateDataField);
+ }
+ // Rudimentary validation. TODO: Roll into use of jQUery validate and ui.datepicker.validation
+ function isValidDate() {
+ // FIXME: parseDate doesn't work with incomplete date formats; skip validation if no month, day or year in format
+ var lowerFormat = settings.dateFormat.toLowerCase();
+ if (lowerFormat.indexOf('y') < 0 || lowerFormat.indexOf('m') < 0 || !dateHasDay()) {
+ return true;
+ }
+ try {
+ $.datepicker.parseDate(settings.dateFormat, $dateField.val());
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
+
+ /**
+ * Does the date format contain the day.
+ *
+ * @returns {boolean}
+ */
+ function dateHasDay() {
+ var lowerFormat = settings.dateFormat.toLowerCase();
+ if (lowerFormat.indexOf('d') < 0) {
+ return false;
+ }
+ return true;
+ }
+ function updateInputFields(e, context) {
+ var val = $dataField.val(),
+ time = null;
+ if (context !== 'userInput' && context !== 'crmClear') {
+ if (hasDatepicker) {
+ $dateField.datepicker('setDate', CRM._.includes(val, '-') ? $.datepicker.parseDate('yy-mm-dd', val) : null);
+ } else if ($dateField.length) {
+ $dateField.val(val.slice(0, 4));
+ }
+ if ($timeField.length) {
+ if (val.length === 8) {
+ time = val;
+ } else if (val.length === 19) {
+ time = val.split(' ')[1];
+ }
+ $timeField.timeEntry('setTime', time);
+ }
+ }
+ $clearLink.css('visibility', val ? 'visible' : 'hidden');
+ }
+ function updateDataField(e, context) {
+ // The crmClear event wipes all the field values anyway, so no need to respond
+ if (context !== 'crmClear') {
+ var val = '';
+ if ($dateField.val()) {
+ if (hasDatepicker && isValidDate() && dateHasDay()) {
+ val = $.datepicker.formatDate('yy-mm-dd', $dateField.datepicker('getDate'));
+ $dateField.removeClass('crm-error');
+ } else if (!hasDatepicker) {
+ val = $dateField.val() + '-01-01';
+ }
+ else if (!dateHasDay()) {
+ // This would be a Year-month date (yyyy-mm)
+ // it could be argued it should not use a datepicker....
+ val = $dateField.val() + '-01';
+ } else {
+ $dateField.addClass('crm-error');
+ }
+ }
+ if ($timeField.val()) {
+ val += (val ? ' ' : '') + $timeField.timeEntry('getTime').toTimeString().substr(0, 8);
+ }
+ $dataField.val(val).trigger('change', ['userInput']);
+ }
+ }
+ $dataField.hide().addClass('crm-hidden-date').on('change.crmDatepicker', updateInputFields);
+ updateInputFields();
+ });
+ };
+})(jQuery, CRM, CRM._);
// D7 hack, restore toolbar position (CRM-15341)
$('#toolbar').css('z-index', '');
}
- })
- // d8 Hack to hide title when it should be (CRM-19960)
- .ready(function() {
- var pageTitle = $('.page-title');
- var title = $('.page-title').text();
- if ('<span id="crm-remove-title" style="display:none">CiviCRM</span>' == title) {
- pageTitle.hide();
- }
- });
+ });
+ $('#civicrm-menu').css({'width': '97%'});
});
--- /dev/null
+// http://civicrm.org/licensing
+CRM.$(function($) {
+ // d8 Hack to hide title when it should be (CRM-19960)
+ var pageTitle = $('.page-title');
+ if ('<span id="crm-remove-title" style="display:none">CiviCRM</span>' == pageTitle.text()) {
+ pageTitle.hide();
+ }
+
+ $('#toolbar-bar').hide();
+
+ $('.crm-hidemenu').click(function(e) {
+ $('#toolbar-bar').slideDown();
+ });
+ $('#crm-notification-container').on('click', '#crm-restore-menu', function() {
+ $('#toolbar-bar').slideUp();
+ });
+});
'bower_components/jquery-validation/dist/jquery.validate.min.js',
'packages/jquery/plugins/jquery.timeentry.js',
'js/Common.js',
+ 'js/crm.datepicker.js',
'bower_components/angular/angular.js',
'js/crm.angular.js',
angularTempFile,
LOCK TABLES `civicrm_domain` WRITE;
/*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
-INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.5.beta1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
+INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.6.alpha1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
/*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
UNLOCK TABLES;
<table id="scheduleReminders" class="display">
<thead>
<tr id="options" class="columnheader">
- <th class="sortable">{ts}Title{/ts}</th>
+ <th id="sortable">{ts}Title{/ts}</th>
<th >{ts}Reminder For{/ts}</th>
<th >{ts}When{/ts}</th>
<th >{ts}While{/ts}</th>
<table class="form-layout-compressed">
{foreach from=$caseRoles.client item=client}
<tr class="crm-case-caseview-display_name">
- <td class="label-left bold" style="padding: 0px; border: none;">{$client.display_name}</td>
+ <td class="label-left bold" style="padding: 0px; border: none;">
+ <a href="{crmURL p='civicrm/contact/view' q="action=view&reset=1&cid=`$client.contact_id`"}" title="{ts}View contact record{/ts}">{$client.display_name}</a>
+ </td>
</tr>
{if $client.phone}
<tr class="crm-case-caseview-phone">
<span class="crm-i fa-pencil"></span> {if $add}{ts}Edit address{/ts}{else}{ts}Add address{/ts}{/if}
</div>
{/if}
- {if $add }
+ {if !$add}
+ <div class="crm-summary-row">
+ <div class="crm-label">{ts}Address{/ts}</div>
+ <div class="crm-content"></div>
+ </div>
+ {else}
<div class="crm-summary-row {if $add.is_primary eq 1} primary{/if}">
<div class="crm-label">
{ts 1=$add.location_type}%1 Address{/ts}
o.animate({height: '+=50px'}, 200);
data.snippet = 6;
data.reset = 1;
- o.addClass('form');
+ var width = o.width();
$('.crm-edit-ready').removeClass('crm-edit-ready');
- o.block();
+ o.block().addClass('form').css('width', '' + width + 'px');
$.getJSON(CRM.url('civicrm/ajax/inline', data))
.fail(errorHandler)
.done(function(response) {
o.unblock();
o.css('overflow', 'hidden').wrapInner('<div class="inline-edit-hidden-content" style="display:none" />').append(response.content);
+ // Needed to accurately measure box width
+ $('.crm-container-snippet', o).css('display', 'inline-block');
// Smooth resizing
- var newHeight = $('.crm-container-snippet', o).height();
- var diff = newHeight - parseInt(o.css('height'), 10);
- if (diff < 0) {
- diff = 0 - diff;
+ var newHeight = $('.crm-container-snippet', o).height(),
+ speed = newHeight - parseInt(o.css('height'), 10),
+ animation = {height: '' + newHeight + 'px'};
+ // Animation speed is set relative to how much the box needs to grow
+ if (speed < 0) {
+ speed = 0 - speed;
}
- o.animate({height: '' + newHeight + 'px'}, diff * 2, function() {
- o.removeAttr('style');
+ // Horizontal growth
+ var newWidth = $('.crm-container-snippet', o).width();
+ if (newWidth > width) {
+ animation.width = '' + newWidth + 'px';
+ // Slow down animation if we have lots of horizontal growth to do
+ if (newWidth - width > speed) {
+ speed = newWidth - width;
+ }
+ } else {
+ newWidth = width;
+ }
+ $('.crm-container-snippet', o).css('display', '');
+ o.animate(animation, speed, function() {
+ o.css({height: '', width: '', minWidth: '' + newWidth + 'px'});
});
$('form', o).validate(CRM.validate.params);
ajaxFormParams.data = data;
$('form', o).ajaxFormUnbind();
if (response.status == 'success' || response.status == 'cancel') {
- o.trigger('crmFormSuccess', [response]);
+ o.trigger('crmFormSuccess', [response]).removeAttr('style');
$('.crm-inline-edit-container').addClass('crm-edit-ready');
var data = o.data('edit-params');
var dependent = $((o.data('dependent-fields') || []).join(','));
$('form', container).ajaxFormUnbind();
$('.inline-edit-hidden-content', container).nextAll().remove();
$('.inline-edit-hidden-content > *:first-child', container).unwrap();
- container.removeClass('form');
+ container.removeClass('form').removeAttr('style');
$('.crm-inline-edit-container').addClass('crm-edit-ready');
$('a.ui-notify-close', '#crm-notification-container').click();
return false;
CRM.api3('address', 'delete', {id: $block.data('edit-params').aid}, true)
.done(function(data) {
$('.crm-inline-edit-container').addClass('crm-edit-ready');
- $block.remove();
+ $block.closest('.crm-address-block').remove();
reloadBlock('.crm-inline-edit.address:not(.add-new)');
});
});
<span class="description">{ts}Non-deductible portion of this contribution.{/ts}</span></td></tr>
<tr class="crm-contribution-form-block-fee_amount"><td class="label">{$form.fee_amount.label}</td><td{$valueStyle}>{$form.fee_amount.html|crmMoney:$currency:'XXX':'YYY'}<br />
<span class="description">{ts}Processing fee for this transaction (if applicable).{/ts}</span></td></tr>
-
- <tr class="crm-contribution-form-block-net_amount"><td class="label">{$form.net_amount.label}</td><td{$valueStyle}>{$form.net_amount.html|crmMoney:$currency:'':1}<br />
<span class="description">{ts}Net value of the contribution (Total Amount minus Fee).{/ts}</span></td></tr>
<tr class="crm-contribution-form-block-invoice_id"><td class="label">{$form.invoice_id.label}</td><td{$valueStyle}>{$form.invoice_id.html}<br />
<span class="description">{ts}Unique internal reference ID for this contribution.{/ts}</span></td></tr>
{/if}
</div>
{/if}
-
+
<div class="crm-block crm-form-block crm-contribution-form-block">
{if !$email and $action neq 8 and $context neq 'standalone'}
<div class="icon inform-icon"></div> {ts}You will not be able to send an automatic email receipt for this contribution because there is no email address recorded for this contact. If you want a receipt to be sent when this contribution is recorded, click Cancel and then click Edit from the Summary tab to add an email address before recording the contribution.{/ts}
</div>
{/if}
-
+
{if $action eq 8}
<div class="messages status no-popup">
<div class="icon inform-icon"></div>
var thousandMarker = "{/literal}{$config->monetaryThousandSeparator}{literal}";
var separator = "{/literal}{$config->monetaryDecimalPoint}{literal}";
-cj('#fee_amount').change( function() {
- var totalAmount = cj('#total_amount').val().replace(thousandMarker,'').replace(separator,'.');
- var feeAmount = cj('#fee_amount').val().replace(thousandMarker,'').replace(separator,'.');
- var netAmount = totalAmount - feeAmount;
- if (totalAmount) {
- cj('#net_amount').val(CRM.formatMoney(netAmount, true));
- }
-});
-
cj("#financial_type_id").on("change",function(){
cj('#total_amount').trigger("change");
})
var fname = '#priceset';
if ( !priceSetId ) {
cj('#membership_type_id_1').val(0);
- CRM.buildCustomData(customDataType, 'null' );
+ CRM.buildCustomData(customDataType, null );
// hide price set fields.
cj( fname ).hide( );
subTypeNames = currentMembershipType.join(',');
if ( subTypeNames.length < 1 ) {
- subTypeNames = 'null';
+ subTypeNames = null;
}
CRM.buildCustomData( customDataType, subTypeNames );
</div>
</fieldset>
+ {include file="CRM/common/customDataBlock.tpl"}
+
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
{/if}
<div class="spacer"></div>
<div id="report-tab-set-developer" class="civireport-criteria">
- <p><b>{ts}Class used{/ts}: {$report_class}</b></p>
+ <p><b>{ts}Class used{/ts}: {$report_class|escape}</b></p>
+ <p>{ts}SQL Modes{/ts}:
+ {foreach from=$sqlModes item=sqlMode}
+ {$sqlMode|escape}
+ {/foreach}
+ </p>
<pre>{$sql|purify}</pre>
</div>
{/strip}{/capture}// <script> Generated {$smarty.now|date_format:'%d %b %Y %H:%M:%S'}
{literal}
(function($) {
- var menuMarkup = {/literal}{$menuMarkup|@json_encode};
-{if $config->userFramework neq 'Joomla'}{literal}
- $('body').append(menuMarkup);
-
- $('#civicrm-menu').css({position: "fixed", top: "0px"});
+ var menuMarkup = {/literal}{$menuMarkup|@json_encode}{literal};
//Track Scrolling
- $(window).scroll(function () {
- $('div.sticky-header').css({top: $('#civicrm-menu').height() + "px", position: "fixed"});
- });
-
- if ($('#edit-shortcuts').length > 0) {
- $('#civicrm-menu').css({'width': '97%'});
+ if ($('div.sticky-header').length) {
+ $(window).scroll(function () {
+ $('div.sticky-header').css({top: $('#civicrm-menu').height() + "px", position: "fixed"});
+ });
}
-{/literal}{else}{* Special menu hacks for Joomla *}{literal}
- // below div is present in older version of joomla 2.5.x
- var elementExists = $('div#toolbar-box div.m').length;
- if (elementExists > 0) {
+
+ if ($('div#toolbar-box div.m').length) {
$('div#toolbar-box div.m').html(menuMarkup);
}
- else {
+ else if ($("#crm-nav-menu-container").length) {
$("#crm-nav-menu-container").html(menuMarkup).css({'padding-bottom': '10px'});
}
-{/literal}{/if}{literal}
+ else {
+ $('body').append(menuMarkup);
+ }
+
// CRM-15493 get the current qfKey
$("input[name=qfKey]", "#quickSearch").val($('#civicrm-navigation-menu').data('qfkey'));
*/
public function testHardLocks() {
$hardLocks = array(
- 'symfony/config' => '/^v2\.6\./',
- 'symfony/dependency-injection' => '/^v2\.6\./',
- 'symfony/event-dispatcher' => '/^v2\.6\./',
- 'symfony/filesystem' => '/^v2\.6\./',
- 'symfony/finder' => '/^v2\.6\./',
- 'symfony/process' => '/^v2\.6\./',
+ 'symfony/config' => '/^v2\.8\./',
+ 'symfony/dependency-injection' => '/^v2\.8\./',
+ 'symfony/event-dispatcher' => '/^v2\.8\./',
+ 'symfony/filesystem' => '/^v2\.8\./',
+ 'symfony/finder' => '/^v2\.8\./',
+ 'symfony/process' => '/^v2\.8\./',
);
$lockFile = Civi::paths()->getPath('[civicrm.root]/composer.lock');
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Class CRM_Event_BAO_EventPermissionsTest
+ * @group headless
+ */
+class CRM_Event_BAO_EventPermissionsTest extends CiviUnitTestCase {
+
+ public function setUp() {
+ parent::setUp();
+ $this->_contactId = $this->createLoggedInUser();
+ $event = $this->eventCreate(array(
+ 'created_id' => $this->_contactId,
+ ));
+ $this->_eventId = $event['id'];
+ }
+
+ public function testEditOwnEvent() {
+ CRM_Core_Config::singleton()->userPermissionTemp = ['access civievent', 'access CiviCRM', 'view event info'];
+ unset(\Civi::$statics['CRM_Event_BAO_Event']['permissions']);
+ $permissions = CRM_Event_BAO_Event::checkPermission($this->_eventId, CRM_Core_Permission::EDIT);
+ $this->assertTrue($permissions);
+ }
+
+}
['Individual', 'city', ''],
['Individual', 'state_province', ''],
];
- list($tableName) = CRM_Export_BAO_Export::exportComponents(
+ list($tableName, $sqlColumns, $headerRows) = CRM_Export_BAO_Export::exportComponents(
FALSE,
$this->contactIDs,
[],
$this->assertEquals($householdID, $dao->civicrm_primary_id);
}
+ $this->assertEquals([
+ 0 => 'City',
+ 1 => 'State',
+ 2 => 'Household ID',
+ ], $headerRows);
+ $this->assertEquals(
+ [
+ 'city' => 'city varchar(64)',
+ 'state_province' => 'state_province varchar(64)',
+ 'civicrm_primary_id' => 'civicrm_primary_id varchar(16)',
+ ], $sqlColumns);
}
/**
$this->contactDelete($this->allowedContactId);
}
+ /**
+ * Test mailing receipients when using previous mailing as include and contact is in exclude as well
+ */
+ public function testMailingIncludePreviousMailingExcludeGroup() {
+ $groupName = 'Test static group ' . substr(sha1(rand()), 0, 7);
+ $groupName2 = 'Test static group 2' . substr(sha1(rand()), 0, 7);
+ $groupID = $this->groupCreate([
+ 'name' => $groupName,
+ 'title' => $groupName,
+ 'is_active' => 1,
+ ]);
+ $groupID2 = $this->groupCreate([
+ 'name' => $groupName2,
+ 'title' => $groupName2,
+ 'is_active' => 1,
+ ]);
+ $contactID = $this->individualCreate(array(), 0);
+ $contactID2 = $this->individualCreate(array(), 2);
+ $this->callAPISuccess('GroupContact', 'Create', array(
+ 'group_id' => $groupID,
+ 'contact_id' => $contactID,
+ ));
+ $this->callAPISuccess('GroupContact', 'Create', array(
+ 'group_id' => $groupID,
+ 'contact_id' => $contactID2,
+ ));
+ $this->callAPISuccess('GroupContact', 'Create', array(
+ 'group_id' => $groupID2,
+ 'contact_id' => $contactID2,
+ ));
+ // Create dummy mailing
+ $mailingID = $this->callAPISuccess('Mailing', 'create', array())['id'];
+ $this->createMailingGroup($mailingID, $groupID);
+ $expectedContactIDs = [$contactID, $contactID2];
+ $this->assertRecipientsCorrect($mailingID, $expectedContactIDs);
+ $mailingID2 = $this->callAPISuccess('Mailing', 'create', array())['id'];
+ $this->createMailingGroup($mailingID2, $groupID2, 'Exclude');
+ $this->callAPISuccess('MailingGroup', 'create', array(
+ 'mailing_id' => $mailingID2,
+ 'group_type' => 'Include',
+ 'entity_table' => CRM_Mailing_BAO_Mailing::getTableName(),
+ 'entity_id' => $mailingID,
+ ));
+ $expectedContactIDs = [$contactID];
+ $this->assertRecipientsCorrect($mailingID2, $expectedContactIDs);
+ $this->callAPISuccess('mailing', 'delete', ['id' => $mailingID2]);
+ $this->callAPISuccess('mailing', 'delete', ['id' => $mailingID]);
+ $this->callAPISuccess('group', 'delete', ['id' => $groupID]);
+ $this->callAPISuccess('group', 'delete', ['id' => $groupID2]);
+ $this->callAPISuccess('contact', 'delete', ['id' => $contactID, 'skip_undelete' => TRUE]);
+ $this->callAPISuccess('contact', 'delete', ['id' => $contactID2, 'skip_undelete' => TRUE]);
+ }
+
/**
* Test verify that a disabled mailing group doesn't prvent access to the mailing generated with the group.
*/
* @dataProvider getThousandSeparators
*/
public function testSubmit($thousandSeparator) {
+ CRM_Core_Session::singleton()->getStatus(TRUE);
$this->setCurrencySeparators($thousandSeparator);
$form = $this->getForm();
$form->preProcess();
$this->createLoggedInUser();
$params = array(
'cid' => $this->_individualId,
- 'join_date' => date('m/d/Y', time()),
+ 'join_date' => date('2/d/Y', time()),
'start_date' => '',
'end_date' => '',
// This format reflects the 23 being the organisation & the 25 being the type.
'Receipt text',
));
$this->mut->stop();
+ $this->assertEquals([
+ [
+ 'text' => 'AnnualFixed membership for Mr. Anthony Anderson II has been added. The new membership End Date is December 31st, ' . date('Y') . '. A membership confirmation and receipt has been sent to anthony_anderson@civicrm.org.',
+ 'title' => 'Complete',
+ 'type' => 'success',
+ 'options' => NULL,
+ ],
+ ], CRM_Core_Session::singleton()->getStatus());
}
/**
* Test the submit function of the membership form.
*/
public function testSubmitRecur() {
+ CRM_Core_Session::singleton()->getStatus(TRUE);
$pendingVal = $this->callAPISuccessGetValue('OptionValue', array(
'return' => "id",
'option_group_id' => "contribution_status",
'entity_table' => 'civicrm_membership',
'contribution_id' => $contribution['id'],
), 1);
+ $this->assertEquals([
+ [
+ 'text' => 'AnnualFixed membership for Mr. Anthony Anderson II has been added. The new membership End Date is ' . date('F jS, Y', strtotime('last day of this month')) . ' 12:00 AM.',
+ 'title' => 'Complete',
+ 'type' => 'success',
+ 'options' => NULL,
+ ],
+ ], CRM_Core_Session::singleton()->getStatus());
}
/**
}
/**
- * CRM-21656: Test the submit function of the membership form if Sale Tax is enabled.
- * Check that the tax rate isn't reapplied to line item's unit price and total amount
+ * CRM-21656: Test the submit function of the membership form if Sales Tax is enabled.
+ * This test simulates what happens when one hits Edit on a Contribution that has both LineItems and Sales Tax components
+ * Without making any Edits -> check that the LineItem data remain the same
+ * In addition (a data-integrity check) -> check that the LineItem data add up to the data at the Contribution level
*/
- public function testLineItemAmountOnSaleTax() {
+ public function testLineItemAmountOnSalesTax() {
$this->enableTaxAndInvoicing();
$this->relationForFinancialTypeWithFinancialAccount(2);
$form = $this->getForm();
$this->createLoggedInUser();
$priceSet = $this->callAPISuccess('PriceSet', 'Get', array("extends" => "CiviMember"));
$form->set('priceSetId', $priceSet['id']);
+ // we are simulating the creation of a Price Set in Administer -> CiviContribute -> Manage Price Sets so set is_quick_config = 0
+ $this->callAPISuccess('PriceSet', 'Create', array("id" => $priceSet['id'], 'is_quick_config' => 0));
// clean the price options static variable to repopulate the options, in order to fetch tax information
\Civi::$statics['CRM_Price_BAO_PriceField']['priceOptions'] = NULL;
CRM_Price_BAO_PriceSet::buildPriceSet($form);
),
CRM_Core_Action::UPDATE);
- // ensure that the line-item values got unaffected
+ // ensure that the LineItem data remain the same
$lineItem = $this->callAPISuccessGetSingle('LineItem', array('entity_id' => $membership['id'], 'entity_table' => 'civicrm_membership'));
$this->assertEquals(1, $lineItem['qty']);
- $this->assertEquals(5.00, $lineItem['tax_amount']); // ensure that tax amount is not changed
+ $this->assertEquals(50.00, $lineItem['unit_price']);
+ $this->assertEquals(50.00, $lineItem['line_total']);
+ $this->assertEquals(5.00, $lineItem['tax_amount']);
+
+ // ensure that the LineItem data add up to the data at the Contribution level
+ $contribution = $this->callAPISuccessGetSingle('Contribution',
+ array(
+ 'contribution_id' => 1,
+ 'return' => array('tax_amount', 'total_amount'),
+ )
+ );
+ $this->assertEquals($contribution['total_amount'], $lineItem['line_total'] + $lineItem['tax_amount']);
+ $this->assertEquals($contribution['tax_amount'], $lineItem['tax_amount']);
+
+ $financialItems = $this->callAPISuccess('FinancialItem', 'get', array());
+ $financialItems_sum = 0;
+ foreach ($financialItems['values'] as $financialItem) {
+ $financialItems_sum += $financialItem['amount'];
+ }
+ $this->assertEquals($contribution['total_amount'], $financialItems_sum);
// reset the price options static variable so not leave any dummy data, that might hamper other unit tests
\Civi::$statics['CRM_Price_BAO_PriceField']['priceOptions'] = NULL;
/**
* @dataProvider subtractCurrenciesDataProvider
- * @param $inputData
- * @param $expectedResult
+ * @param string $leftOp
+ * @param string $rightOp
+ * @param string $currency
+ * @param float $expectedResult
*/
public function testSubtractCurrencies($leftOp, $rightOp, $currency, $expectedResult) {
$this->assertEquals($expectedResult, CRM_Utils_Money::subtractCurrencies($leftOp, $rightOp, $currency));
);
}
+ /**
+ * Test rounded by currency function.
+ *
+ * In practice this only does rounding to 2 since rounding by any other amount is
+ * only place-holder supported.
+ */
+ public function testFormatLocaleNumericRoundedByCurrency() {
+ $result = CRM_Utils_Money::formatLocaleNumericRoundedByCurrency(8950.3678, 'NZD');
+ $this->assertEquals('8,950.37', $result);
+ }
+
+ /**
+ * Test rounded by currency function.
+ *
+ * This should be formatted according to European standards - . thousand separator
+ * and , for decimal. (The Europeans are wrong but they don't know that. We will forgive them
+ * because ... metric).
+ */
+ public function testFormatLocaleNumericRoundedByCurrencyEuroThousand() {
+ $this->setCurrencySeparators('.');
+ $result = CRM_Utils_Money::formatLocaleNumericRoundedByCurrency(8950.3678, 'NZD');
+ $this->assertEquals('8.950,37', $result);
+ $this->setCurrencySeparators(',');
+ }
+
}
--- /dev/null
+<?php
+
+namespace E2E\Core;
+
+/**
+ * Class PrevNextTest
+ *
+ * Check that the active prev-next service behaves as expected.
+ *
+ * @package E2E\Core
+ * @group e2e
+ */
+class PrevNextTest extends \CiviEndToEndTestCase {
+
+ /**
+ * @var string
+ */
+ protected $cacheKey, $cacheKeyB;
+
+ /**
+ * @var \CRM_Core_PrevNextCache_Interface
+ */
+ protected $prevNext;
+
+ protected function setUp() {
+ parent::setUp();
+ $this->prevNext = \Civi::service('prevnext');
+ $this->cacheKey = 'PrevNextTest_' . \CRM_Utils_String::createRandom(16, \CRM_Utils_String::ALPHANUMERIC);
+ $this->cacheKeyB = 'PrevNextTest_' . \CRM_Utils_String::createRandom(16, \CRM_Utils_String::ALPHANUMERIC);
+ $this->assertTrue(
+ \CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_contact') > 25,
+ 'The contact table must have at least 25 records.'
+ );
+ }
+
+ protected function tearDown() {
+ \Civi::service('prevnext')->deleteItem(NULL, $this->cacheKey);
+ }
+
+ public function testFillSql() {
+ $start = 0;
+ $prefillLimit = 25;
+ $sort = NULL;
+
+ $query = new \CRM_Contact_BAO_Query(array(), NULL, NULL, FALSE, FALSE, 1, FALSE, TRUE, FALSE, NULL, 'AND');
+ $sql = $query->searchQuery($start, $prefillLimit, $sort, FALSE, $query->_includeContactIds,
+ FALSE, TRUE, TRUE);
+ $selectSQL = "SELECT DISTINCT '$this->cacheKey', contact_a.id, contact_a.sort_name";
+ $sql = str_replace(array("SELECT contact_a.id as contact_id", "SELECT contact_a.id as id"), $selectSQL, $sql);
+
+ $this->assertTrue(
+ $this->prevNext->fillWithSql($this->cacheKey, $sql),
+ "fillWithSql should return TRUE on success"
+ );
+
+ $this->assertEquals(25, $this->prevNext->getCount($this->cacheKey));
+ $this->assertEquals(0, $this->prevNext->getCount('not-a-key-' . $this->cacheKey));
+
+ $all = $this->prevNext->getSelection($this->cacheKey, 'getall')[$this->cacheKey];
+ $this->assertCount($prefillLimit, $all);
+ $this->assertCount($prefillLimit, array_unique(array_keys($all)));
+ $this->assertEquals([1], array_unique(array_values($all)));
+
+ $this->assertSelections([]);
+ }
+
+ public function testFillArray() {
+ $rowSetA = [
+ ['entity_id1' => 100, 'data' => 'Alice'],
+ ['entity_id1' => 400, 'data' => 'Bob'],
+ ['entity_id1' => 200, 'data' => 'Carol'],
+ ];
+ $rowSetB = [
+ ['entity_id1' => 300, 'data' => 'Dave'],
+ ];
+
+ $this->assertTrue(
+ $this->prevNext->fillWithArray($this->cacheKey, $rowSetA),
+ "fillWithArray should return TRUE on success"
+ );
+ $this->assertTrue(
+ $this->prevNext->fillWithArray($this->cacheKey, $rowSetB),
+ "fillWithArray should return TRUE on success"
+ );
+
+ $this->assertEquals(4, $this->prevNext->getCount($this->cacheKey));
+ $this->assertEquals(0, $this->prevNext->getCount('not-a-key-' . $this->cacheKey));
+
+ $all = $this->prevNext->getSelection($this->cacheKey, 'getall')[$this->cacheKey];
+ $this->assertEquals([100, 400, 200, 300], array_keys($all));
+ $this->assertEquals([1], array_unique(array_values($all)));
+
+ $this->assertSelections([]);
+ }
+
+ public function getFillFunctions() {
+ return [
+ ['testFillSql'],
+ ['testFillArray'],
+ ];
+ }
+
+ /**
+ * Select and unselect one item.
+ *
+ * @dataProvider getFillFunctions
+ */
+ public function testMarkSelection_1($fillFunction) {
+ call_user_func([$this, $fillFunction]);
+
+ $all = $this->prevNext->getSelection($this->cacheKey, 'getall')[$this->cacheKey];
+ list ($id1, $id2) = array_keys($all);
+ $this->prevNext->markSelection($this->cacheKey, 'select', $id1);
+
+ $this->assertSelections([$id1]);
+
+ $this->prevNext->markSelection($this->cacheKey, 'unselect', $id1);
+ $this->assertSelections([]);
+ }
+
+ /**
+ * Select and unselect two items.
+ *
+ * @dataProvider getFillFunctions
+ */
+ public function testMarkSelection_2($fillFunction) {
+ call_user_func([$this, $fillFunction]);
+
+ $all = $this->prevNext->getSelection($this->cacheKey, 'getall')[$this->cacheKey];
+ list ($id1, $id2, $id3) = array_keys($all);
+
+ $this->prevNext->markSelection($this->cacheKey, 'select', [$id1, $id3]);
+ $this->assertSelections([$id1, $id3]);
+
+ $this->prevNext->markSelection($this->cacheKey, 'unselect', $id1);
+ $this->assertSelections([$id3]);
+
+ $this->prevNext->markSelection($this->cacheKey, 'select', $id2);
+ $this->assertSelections([$id2, $id3]);
+
+ $this->prevNext->markSelection($this->cacheKey, 'unselect');
+ $this->assertSelections([]);
+ }
+
+ /**
+ * Check the neighbors of the first item.
+ *
+ * @dataProvider getFillFunctions
+ */
+ public function testGetPosition_first($fillFunction) {
+ call_user_func([$this, $fillFunction]);
+
+ $all = $this->prevNext->getSelection($this->cacheKey, 'getall')[$this->cacheKey];
+ list ($id1, $id2, $id3) = array_keys($all);
+
+ $pos = $this->prevNext->getPositions($this->cacheKey, $id1);
+
+ $this->assertTrue((bool) $pos['foundEntry']);
+
+ $this->assertEquals($id2, $pos['next']['id1']);
+ $this->assertTrue(!empty($pos['next']['data']));
+
+ $this->assertTrue(!isset($pos['prev']));
+ }
+
+ /**
+ * Check the neighbors of a middle item.
+ *
+ * @dataProvider getFillFunctions
+ */
+ public function testGetPosition_middle($fillFunction) {
+ call_user_func([$this, $fillFunction]);
+
+ $all = $this->prevNext->getSelection($this->cacheKey, 'getall')[$this->cacheKey];
+ list ($id1, $id2, $id3) = array_keys($all);
+
+ $pos = $this->prevNext->getPositions($this->cacheKey, $id2);
+ $this->assertTrue((bool) $pos['foundEntry']);
+
+ $this->assertEquals($id3, $pos['next']['id1']);
+ $this->assertTrue(!empty($pos['next']['data']));
+
+ $this->assertEquals($id1, $pos['prev']['id1']);
+ $this->assertTrue(!empty($pos['prev']['data']));
+ }
+
+ /**
+ * Check the neighbors of the last item.
+ *
+ * @dataProvider getFillFunctions
+ */
+ public function testGetPosition_last($fillFunction) {
+ call_user_func([$this, $fillFunction]);
+
+ $all = $this->prevNext->getSelection($this->cacheKey, 'getall')[$this->cacheKey];
+ list ($idLast, $idPrev) = array_reverse(array_keys($all));
+
+ $pos = $this->prevNext->getPositions($this->cacheKey, $idLast);
+ $this->assertTrue((bool) $pos['foundEntry']);
+
+ $this->assertTrue(!isset($pos['next']));
+
+ $this->assertEquals($idPrev, $pos['prev']['id1']);
+ $this->assertTrue(!empty($pos['prev']['data']));
+ }
+
+ /**
+ * Check the neighbors of the last item.
+ *
+ * @dataProvider getFillFunctions
+ */
+ public function testGetPosition_invalid($fillFunction) {
+ call_user_func([$this, $fillFunction]);
+
+ $pos = $this->prevNext->getPositions($this->cacheKey, 99999999);
+ $this->assertFalse((bool) $pos['foundEntry']);
+ $this->assertTrue(!isset($pos['next']));
+ $this->assertTrue(!isset($pos['prev']));
+ }
+
+ public function testDeleteByCacheKey() {
+ // Add background data
+ $this->prevNext->fillWithArray($this->cacheKeyB, [
+ ['entity_id1' => 100, 'data' => 'Alice'],
+ ['entity_id1' => 150, 'data' => 'Dave'],
+ ]);
+ $this->prevNext->markSelection($this->cacheKeyB, 'select', 100);
+ $this->assertSelections([100], 'get', $this->cacheKeyB);
+ $this->assertSelections([100, 150], 'getall', $this->cacheKeyB);
+
+ // Add some data that we're actually working with.
+ $this->testFillArray();
+
+ $all = $this->prevNext->getSelection($this->cacheKey, 'getall')[$this->cacheKey];
+ $this->assertEquals([100, 400, 200, 300], array_keys($all));
+
+ list ($id1, $id2, $id3) = array_keys($all);
+ $this->prevNext->markSelection($this->cacheKey, 'select', [$id1, $id3]);
+ $this->assertSelections([$id1, $id3]);
+
+ $this->prevNext->deleteItem(NULL, $this->cacheKey);
+ $all = $this->prevNext->getSelection($this->cacheKey, 'getall')[$this->cacheKey];
+ $this->assertEquals([], array_keys($all));
+ $this->assertSelections([]);
+
+ // Ensure background data was untouched.
+ $this->assertSelections([100], 'get', $this->cacheKeyB);
+ $this->assertSelections([100, 150], 'getall', $this->cacheKeyB);
+ }
+
+ public function testDeleteByEntityId() {
+ // Fill two caches
+ $this->prevNext->fillWithArray($this->cacheKey, [
+ ['entity_id1' => 100, 'data' => 'Alice'],
+ ['entity_id1' => 150, 'data' => 'Dave'],
+ ]);
+ $this->prevNext->markSelection($this->cacheKey, 'select', 100);
+ $this->assertSelections([100], 'get', $this->cacheKey);
+ $this->assertSelections([100, 150], 'getall', $this->cacheKey);
+
+ $this->prevNext->fillWithArray($this->cacheKeyB, [
+ ['entity_id1' => 100, 'data' => 'Alice'],
+ ['entity_id1' => 400, 'data' => 'Bob'],
+ ]);
+ $this->prevNext->markSelection($this->cacheKeyB, 'select', [100, 400]);
+ $this->assertSelections([100, 400], 'get', $this->cacheKeyB);
+ $this->assertSelections([100, 400], 'getall', $this->cacheKeyB);
+
+ // Delete
+ $this->prevNext->deleteItem(100);
+ $this->assertSelections([], 'get', $this->cacheKey);
+ $this->assertSelections([150], 'getall', $this->cacheKey);
+ $this->assertSelections([400], 'get', $this->cacheKeyB);
+ $this->assertSelections([400], 'getall', $this->cacheKeyB);
+ }
+
+ public function testDeleteAll() {
+ // Fill two caches
+ $this->prevNext->fillWithArray($this->cacheKey, [
+ ['entity_id1' => 100, 'data' => 'Alice'],
+ ['entity_id1' => 150, 'data' => 'Dave'],
+ ]);
+ $this->prevNext->markSelection($this->cacheKey, 'select', 100);
+ $this->assertSelections([100], 'get', $this->cacheKey);
+ $this->assertSelections([100, 150], 'getall', $this->cacheKey);
+
+ $this->prevNext->fillWithArray($this->cacheKeyB, [
+ ['entity_id1' => 100, 'data' => 'Alice'],
+ ['entity_id1' => 400, 'data' => 'Bob'],
+ ]);
+ $this->prevNext->markSelection($this->cacheKeyB, 'select', [100, 400]);
+ $this->assertSelections([100, 400], 'get', $this->cacheKeyB);
+ $this->assertSelections([100, 400], 'getall', $this->cacheKeyB);
+
+ // Delete
+ $this->prevNext->deleteItem(NULL, NULL);
+ $this->assertSelections([], 'get', $this->cacheKey);
+ $this->assertSelections([], 'getall', $this->cacheKey);
+ $this->assertSelections([], 'get', $this->cacheKeyB);
+ $this->assertSelections([], 'getall', $this->cacheKeyB);
+ }
+
+
+ /**
+ * Assert that the current cacheKey has a list of selected contact IDs.
+ *
+ * @param array $ids
+ * Contact IDs that should be selected.
+ */
+ protected function assertSelections($ids, $action = 'get', $cacheKey = NULL) {
+ if ($cacheKey === NULL) {
+ $cacheKey = $this->cacheKey;
+ }
+ $selected = $this->prevNext->getSelection($cacheKey, $action)[$cacheKey];
+ $this->assertEquals($ids, array_keys($selected));
+ $this->assertCount(count($ids), $selected);
+ }
+
+}
<labelColumn>title</labelColumn>
</pseudoconstant>
</field>
+ <foreignKey>
+ <name>option_group_id</name>
+ <table>civicrm_option_group</table>
+ <key>id</key>
+ <add>5.6</add>
+ <onDelete>SET NULL</onDelete>
+ </foreignKey>
<field>
<name>filter</name>
<type>varchar</type>
<type>int unsigned</type>
<default>NULL</default>
<add>2.2</add>
+ <pseudoconstant>
+ <optionGroupName>visibility</optionGroupName>
+ </pseudoconstant>
</field>
<field>
<name>icon</name>
<name>entity_id2</name>
<title>Prev Next Entity ID 2</title>
<type>int unsigned</type>
- <required>true</required>
+ <required>false</required>
<comment>FK to entity table specified in entity_table column.</comment>
<add>3.4</add>
</field>
<type>int unsigned</type>
<comment>Phone Type Id, if required</comment>
<add>2.2</add>
+ <pseudoconstant>
+ <optionGroupName>phone_type</optionGroupName>
+ </pseudoconstant>
</field>
<field>
<name>website_type_id</name>
<type>int unsigned</type>
<comment>Website Type Id, if required</comment>
<add>4.5</add>
+ <pseudoconstant>
+ <optionGroupName>website_type</optionGroupName>
+ </pseudoconstant>
</field>
<field>
<name>label</name>
<?xml version="1.0" encoding="iso-8859-1" ?>
<version>
- <version_no>5.5.beta1</version_no>
+ <version_no>5.6.alpha1</version_no>
</version>