Skip to content
Snippets Groups Projects
Verified Commit d5ac3638 authored by Kevin Cristiano's avatar Kevin Cristiano :earth_americas:
Browse files

civicrm release

parent 547c3935
No related branches found
No related tags found
No related merge requests found
Showing
with 123 additions and 92 deletions
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* /*
Plugin Name: CiviCRM Plugin Name: CiviCRM
Description: CiviCRM - Growing and Sustaining Relationships Description: CiviCRM - Growing and Sustaining Relationships
Version: 5.25.0 Version: 5.26.0
Author: CiviCRM LLC Author: CiviCRM LLC
Author URI: https://civicrm.org/ Author URI: https://civicrm.org/
Plugin URI: https://docs.civicrm.org/sysadmin/en/latest/install/wordpress/ Plugin URI: https://docs.civicrm.org/sysadmin/en/latest/install/wordpress/
...@@ -54,7 +54,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; ...@@ -54,7 +54,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
// Set version here: when it changes, will force JS to reload // Set version here: when it changes, will force JS to reload
define( 'CIVICRM_PLUGIN_VERSION', '5.25.0' ); define( 'CIVICRM_PLUGIN_VERSION', '5.26.0' );
// Store reference to this file // Store reference to this file
if (!defined('CIVICRM_PLUGIN_FILE')) { if (!defined('CIVICRM_PLUGIN_FILE')) {
...@@ -419,8 +419,8 @@ class CiviCRM_For_WordPress { ...@@ -419,8 +419,8 @@ class CiviCRM_For_WordPress {
*/ */
public function civicrm_in_wordpress_set() { public function civicrm_in_wordpress_set() {
// Get identifying query var // Get identifying query var.
$page = get_query_var( 'page' ); $page = get_query_var( 'civiwp' );
// Store // Store
self::$in_wordpress = ( $page == 'CiviCRM' ) ? TRUE : FALSE; self::$in_wordpress = ( $page == 'CiviCRM' ) ? TRUE : FALSE;
...@@ -578,6 +578,12 @@ class CiviCRM_For_WordPress { ...@@ -578,6 +578,12 @@ class CiviCRM_For_WordPress {
// Go no further if CiviCRM not installed yet // Go no further if CiviCRM not installed yet
if ( ! CIVICRM_INSTALLED ) return; if ( ! CIVICRM_INSTALLED ) return;
// Attempt to replace 'page' query arg with 'civiwp'.
add_filter( 'request', array( $this, 'maybe_replace_page_query_var' ) );
// Add our query vars.
add_filter( 'query_vars', array( $this, 'query_vars' ) );
// Delay everything else until query has been parsed // Delay everything else until query has been parsed
add_action( 'parse_query', array( $this, 'register_hooks_front_end' ) ); add_action( 'parse_query', array( $this, 'register_hooks_front_end' ) );
...@@ -610,6 +616,14 @@ class CiviCRM_For_WordPress { ...@@ -610,6 +616,14 @@ class CiviCRM_For_WordPress {
} }
$alreadyRegistered = TRUE; $alreadyRegistered = TRUE;
// Redirect if old query var is present.
if ( 'CiviCRM' == get_query_var( 'page' ) && 'CiviCRM' != get_query_var( 'civiwp' ) ) {
$redirect_url = remove_query_arg( 'page', false );
$redirect_url = add_query_arg( 'civiwp', 'CiviCRM', $redirect_url );
wp_redirect( $redirect_url, 301 );
exit();
}
// Store context // Store context
$this->civicrm_in_wordpress_set(); $this->civicrm_in_wordpress_set();
...@@ -720,9 +734,6 @@ class CiviCRM_For_WordPress { ...@@ -720,9 +734,6 @@ class CiviCRM_For_WordPress {
} }
// Add our query vars.
add_filter( 'query_vars', array( $this, 'query_vars' ) );
} }
...@@ -813,7 +824,7 @@ class CiviCRM_For_WordPress { ...@@ -813,7 +824,7 @@ class CiviCRM_For_WordPress {
// Let's add rewrite rule when viewing the basepage // Let's add rewrite rule when viewing the basepage
add_rewrite_rule( add_rewrite_rule(
'^' . $config->wpBasePage . '/([^?]*)?', '^' . $config->wpBasePage . '/([^?]*)?',
'index.php?page_id=' . $basepage->ID . '&page=CiviCRM&q=civicrm%2F$matches[1]', 'index.php?page_id=' . $basepage->ID . '&civiwp=CiviCRM&q=civicrm%2F$matches[1]',
'top' 'top'
); );
...@@ -853,7 +864,7 @@ class CiviCRM_For_WordPress { ...@@ -853,7 +864,7 @@ class CiviCRM_For_WordPress {
// Build our query vars // Build our query vars
$civicrm_query_vars = array( $civicrm_query_vars = array(
'page', 'q', 'reset', 'id', 'html', 'snippet', // URL query vars 'civiwp', 'q', 'reset', 'id', 'html', 'snippet', // URL query vars
'action', 'mode', 'cid', 'gid', 'sid', 'cs', 'force', // Shortcode query vars 'action', 'mode', 'cid', 'gid', 'sid', 'cs', 'force', // Shortcode query vars
); );
...@@ -881,6 +892,36 @@ class CiviCRM_For_WordPress { ...@@ -881,6 +892,36 @@ class CiviCRM_For_WordPress {
} }
/**
* Filters the request right after WP's
* parsed it and replaces the 'page' query
* variable with 'civiwp' if applicable.
*
* Prevents old URLs like example.org/civicrm/?page=CiviCRM&q=what/ever/path&reset=1
* being redirected to example.org/civicrm/?civiwp=CiviCRM&q=what/ever/path&reset=1
*
* @see https://lab.civicrm.org/dev/wordpress/-/issues/49
*
* @since 5.26
*
* @param array $query_vars The existing query vars.
* @return array $query_vars The modified query vars.
*/
public function maybe_replace_page_query_var( $query_vars ) {
$civi_query_arg = array_search( 'CiviCRM', $query_vars );
// Bail if the query var is not 'page'.
if ( false === $civi_query_arg || $civi_query_arg !== 'page' ) return $query_vars;
unset( $query_vars['page'] );
$query_vars['civiwp'] = 'CiviCRM';
return $query_vars;
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// CiviCRM Initialisation // CiviCRM Initialisation
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -1537,7 +1578,7 @@ class CiviCRM_For_WordPress { ...@@ -1537,7 +1578,7 @@ class CiviCRM_For_WordPress {
$q = get_query_var( 'q' ); $q = get_query_var( 'q' );
if (!empty($q)) { if (!empty($q)) {
$page = get_query_var( 'page' ); $page = get_query_var( 'civiwp' );
$reset = get_query_var( 'reset' ); $reset = get_query_var( 'reset' );
$id = get_query_var( 'id' ); $id = get_query_var( 'id' );
$html = get_query_var( 'html' ); $html = get_query_var( 'html' );
...@@ -1552,7 +1593,7 @@ class CiviCRM_For_WordPress { ...@@ -1552,7 +1593,7 @@ class CiviCRM_For_WordPress {
$force = get_query_var( 'force' ); $force = get_query_var( 'force' );
$_REQUEST['q'] = $_GET['q'] = $q; $_REQUEST['q'] = $_GET['q'] = $q;
$_REQUEST['page'] = $_GET['page'] = 'CiviCRM'; $_REQUEST['civiwp'] = $_GET['civiwp'] = 'CiviCRM';
if (!empty($reset)) { $_REQUEST['reset'] = $_GET['reset'] = $reset; } if (!empty($reset)) { $_REQUEST['reset'] = $_GET['reset'] = $reset; }
if (!empty($id)) { $_REQUEST['id'] = $_GET['id'] = $id; } if (!empty($id)) { $_REQUEST['id'] = $_GET['id'] = $id; }
if (!empty($html)) { $_REQUEST['html'] = $_GET['html'] = $html; } if (!empty($html)) { $_REQUEST['html'] = $_GET['html'] = $html; }
......
The following people and organizations sponsored and/or contributed new and improved features to the project. As of CiviCRM 5.25, contributor recognition is viewable in the release notes of each individual version. This file represents an archive of recognition for people and organizations that have sponsored and/or contributed to the project prior to version 5.25.
************************************************ ************************************************
Code Contributors for 5.x Code Contributors for 5.x
......
...@@ -545,7 +545,7 @@ SELECT g.* ...@@ -545,7 +545,7 @@ SELECT g.*
} }
if ($allGroups == NULL) { if ($allGroups == NULL) {
$allGroups = CRM_Contact_BAO_Contact::buildOptions('group_id', NULL, ['onlyActive' => FALSE]); $allGroups = CRM_Contact_BAO_Contact::buildOptions('group_id', 'get');
} }
$acls = CRM_ACL_BAO_Cache::build($contactID); $acls = CRM_ACL_BAO_Cache::build($contactID);
......
...@@ -1677,7 +1677,7 @@ WHERE activity.id IN ($activityIds)"; ...@@ -1677,7 +1677,7 @@ WHERE activity.id IN ($activityIds)";
* Add activity for Membership/Event/Contribution. * Add activity for Membership/Event/Contribution.
* *
* @param object $activity * @param object $activity
* (reference) particular component object. * particular component object.
* @param string $activityType * @param string $activityType
* For Membership Signup or Renewal. * For Membership Signup or Renewal.
* @param int $targetContactID * @param int $targetContactID
...@@ -1687,7 +1687,7 @@ WHERE activity.id IN ($activityIds)"; ...@@ -1687,7 +1687,7 @@ WHERE activity.id IN ($activityIds)";
* @return bool|NULL * @return bool|NULL
*/ */
public static function addActivity( public static function addActivity(
&$activity, $activity,
$activityType = 'Membership Signup', $activityType = 'Membership Signup',
$targetContactID = NULL, $targetContactID = NULL,
$params = [] $params = []
...@@ -1706,7 +1706,11 @@ WHERE activity.id IN ($activityIds)"; ...@@ -1706,7 +1706,11 @@ WHERE activity.id IN ($activityIds)";
// create activity record only for Completed Contributions // create activity record only for Completed Contributions
$contributionCompletedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'); $contributionCompletedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
if ($activity->contribution_status_id != $contributionCompletedStatusId) { if ($activity->contribution_status_id != $contributionCompletedStatusId) {
return NULL; //For onbehalf payments, create a scheduled activity.
if (empty($params['on_behalf'])) {
return NULL;
}
$params['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Scheduled');
} }
$activityType = $component = 'Contribution'; $activityType = $component = 'Contribution';
......
...@@ -36,7 +36,7 @@ class CRM_Activity_BAO_ActivityContact extends CRM_Activity_DAO_ActivityContact ...@@ -36,7 +36,7 @@ class CRM_Activity_BAO_ActivityContact extends CRM_Activity_DAO_ActivityContact
* @return object * @return object
* activity_contact object * activity_contact object
*/ */
public static function create(&$params) { public static function create($params) {
$activityContact = new CRM_Activity_DAO_ActivityContact(); $activityContact = new CRM_Activity_DAO_ActivityContact();
$activityContact->copyValues($params); $activityContact->copyValues($params);
......
...@@ -21,25 +21,4 @@ ...@@ -21,25 +21,4 @@
class CRM_Activity_Form_Task_Email extends CRM_Activity_Form_Task { class CRM_Activity_Form_Task_Email extends CRM_Activity_Form_Task {
use CRM_Contact_Form_Task_EmailTrait; use CRM_Contact_Form_Task_EmailTrait;
/**
* Build all the data structures needed to build the form.
*
* @throws \CiviCRM_API3_Exception
*/
public function preProcess() {
CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
parent::preProcess();
$this->setContactIDs();
$this->assign('single', $this->_single);
}
/**
* List available tokens for this form.
*
* @return array
*/
public function listTokens() {
return CRM_Core_SelectValues::contactTokens();
}
} }
...@@ -45,7 +45,8 @@ class CRM_Activity_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLette ...@@ -45,7 +45,8 @@ class CRM_Activity_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLette
* @param array $activityIds array of activity ids * @param array $activityIds array of activity ids
* @param string $html_message message text with tokens * @param string $html_message message text with tokens
* @param array $formValues formValues from the form * @param array $formValues formValues from the form
* @return void *
* @return string
*/ */
public static function createDocument($activityIds, $html_message, $formValues) { public static function createDocument($activityIds, $html_message, $formValues) {
$tp = self::createTokenProcessor(); $tp = self::createTokenProcessor();
...@@ -61,13 +62,15 @@ class CRM_Activity_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLette ...@@ -61,13 +62,15 @@ class CRM_Activity_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLette
/** /**
* Create a token processor * Create a token processor
*
* @return \Civi\Token\TokenProcessor
*/ */
public static function createTokenProcessor() { public static function createTokenProcessor() {
return new TokenProcessor(\Civi::dispatcher(), array( return new TokenProcessor(\Civi::dispatcher(), [
'controller' => get_class(), 'controller' => get_class(),
'smarty' => FALSE, 'smarty' => FALSE,
'schema' => ['activityId'], 'schema' => ['activityId'],
)); ]);
} }
} }
...@@ -152,7 +152,7 @@ class CRM_Activity_Task extends CRM_Core_Task { ...@@ -152,7 +152,7 @@ class CRM_Activity_Task extends CRM_Core_Task {
*/ */
public static function getTask($value) { public static function getTask($value) {
self::tasks(); self::tasks();
if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) { if (!$value || empty(self::$_tasks[$value])) {
// make the print task by default // make the print task by default
$value = self::TASK_PRINT; $value = self::TASK_PRINT;
} }
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
+--------------------------------------------------------------------+ +--------------------------------------------------------------------+
*/ */
use Civi\Api4\MessageTemplate;
/** /**
* *
* @package CRM * @package CRM
...@@ -19,7 +21,7 @@ ...@@ -19,7 +21,7 @@
* This class generates form components for Message templates * This class generates form components for Message templates
* used by membership, contributions, event registrations, etc. * used by membership, contributions, event registrations, etc.
*/ */
class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form { class CRM_Admin_Form_MessageTemplates extends CRM_Core_Form {
/** /**
* which (and whether) mailing workflow this template belongs to * which (and whether) mailing workflow this template belongs to
* @var int * @var int
...@@ -28,20 +30,26 @@ class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form { ...@@ -28,20 +30,26 @@ class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form {
/** /**
* Is document file is already loaded as default value? * Is document file is already loaded as default value?
*
* @var bool * @var bool
*/ */
protected $_is_document = FALSE; protected $_is_document = FALSE;
/**
* PreProcess form - load existing values.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function preProcess() { public function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
$this, FALSE, 'add'
);
$this->assign('action', $this->_action); $this->assign('action', $this->_action);
$this->_values = [];
$this->_BAOName = 'CRM_Core_BAO_MessageTemplate'; if ($this->_id) {
$this->set('BAOName', $this->_BAOName); $this->_values = (array) MessageTemplate::get()->addWhere('id', '=', $this->_id)->setSelect(['*'])->execute()->first();
parent::preProcess(); }
} }
/** /**
...@@ -253,6 +261,10 @@ class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form { ...@@ -253,6 +261,10 @@ class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form {
/** /**
* Process the form submission. * Process the form submission.
*
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/ */
public function postProcess() { public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) { if ($this->_action & CRM_Core_Action::DELETE) {
...@@ -295,12 +307,12 @@ class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form { ...@@ -295,12 +307,12 @@ class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form {
$params['is_active'] = TRUE; $params['is_active'] = TRUE;
} }
$messageTemplate = CRM_Core_BAO_MessageTemplate::add($params); $messageTemplate = MessageTemplate::save()->setDefaults($params)->setRecords([['id' => $this->_id]])->execute()->first();
CRM_Core_Session::setStatus(ts('The Message Template \'%1\' has been saved.', [1 => $messageTemplate->msg_title]), ts('Saved'), 'success'); CRM_Core_Session::setStatus(ts('The Message Template \'%1\' has been saved.', [1 => $messageTemplate['msg_title']]), ts('Saved'), 'success');
if (isset($this->_submitValues['_qf_MessageTemplates_upload'])) { if (isset($this->_submitValues['_qf_MessageTemplates_upload'])) {
// Save button was pressed // Save button was pressed
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates/add', "action=update&id={$messageTemplate->id}&reset=1")); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/messageTemplates/add', "action=update&id={$messageTemplate['id']}&reset=1"));
} }
// Save and done button was pressed // Save and done button was pressed
if ($this->_workflow_id) { if ($this->_workflow_id) {
......
...@@ -92,7 +92,7 @@ class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences { ...@@ -92,7 +92,7 @@ class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences {
// check that locale supports address parsing // check that locale supports address parsing
if ( if (
CRM_Utils_Array::value($addressOptions['Street Address Parsing'], $this->_params['address_options']) && !empty($this->_params['address_options'][$addressOptions['Street Address Parsing']]) &&
!CRM_Core_BAO_Address::isSupportedParsingLocale() !CRM_Core_BAO_Address::isSupportedParsingLocale()
) { ) {
$config = CRM_Core_Config::singleton(); $config = CRM_Core_Config::singleton();
......
...@@ -39,13 +39,6 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { ...@@ -39,13 +39,6 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting {
'uiLanguages' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'uiLanguages' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME,
]; ];
public function preProcess() {
if (!CRM_Core_I18n::isMultiLingual()) {
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'templates/CRM/Admin/Form/Setting/Localization.js', 1, 'html-header');
}
}
/** /**
* Build the form object. * Build the form object.
*/ */
......
...@@ -56,9 +56,7 @@ class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting { ...@@ -56,9 +56,7 @@ class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting {
} }
} }
if ( if ($config->userSystem->viewsExists() &&
function_exists('module_exists') &&
module_exists('views') &&
( (
$config->dsn != $config->userFrameworkDSN || !empty($drupal_prefix) $config->dsn != $config->userFrameworkDSN || !empty($drupal_prefix)
) )
......
...@@ -164,7 +164,7 @@ trait CRM_Admin_Form_SettingTrait { ...@@ -164,7 +164,7 @@ trait CRM_Admin_Form_SettingTrait {
if (isset($quickFormType)) { if (isset($quickFormType)) {
$options = $props['options'] ?? NULL; $options = $props['options'] ?? NULL;
if ($options) { if ($options) {
if ($props['html_type'] === 'Select' && isset($props['is_required']) && $props['is_required'] === FALSE && !isset($options[''])) { if ($quickFormType === 'Select' && isset($props['is_required']) && $props['is_required'] === FALSE && !isset($options[''])) {
// If the spec specifies the field is not required add a null option. // If the spec specifies the field is not required add a null option.
// Why not if empty($props['is_required']) - basically this has been added to the spec & might not be set to TRUE // Why not if empty($props['is_required']) - basically this has been added to the spec & might not be set to TRUE
// when it is true. // when it is true.
......
...@@ -136,10 +136,8 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { ...@@ -136,10 +136,8 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic {
/** /**
* Browse all jobs. * Browse all jobs.
*
* @param null $action
*/ */
public function browse($action = NULL) { public function browse() {
// check if non-prod mode is enabled. // check if non-prod mode is enabled.
if (CRM_Core_Config::environment() != 'Production') { if (CRM_Core_Config::environment() != 'Production') {
CRM_Core_Session::setStatus(ts('Execution of scheduled jobs has been turned off by default since this is a non-production environment. You can override this for particular jobs by adding runInNonProductionEnvironment=TRUE as a parameter.'), ts("Non-production Environment"), "warning", array('expires' => 0)); CRM_Core_Session::setStatus(ts('Execution of scheduled jobs has been turned off by default since this is a non-production environment. You can override this for particular jobs by adding runInNonProductionEnvironment=TRUE as a parameter.'), ts("Non-production Environment"), "warning", array('expires' => 0));
......
...@@ -71,11 +71,8 @@ class CRM_Admin_Page_JobLog extends CRM_Core_Page_Basic { ...@@ -71,11 +71,8 @@ class CRM_Admin_Page_JobLog extends CRM_Core_Page_Basic {
/** /**
* Browse all jobs. * Browse all jobs.
*
* @param null $action
*/ */
public function browse($action = NULL) { public function browse() {
$jid = CRM_Utils_Request::retrieve('jid', 'Positive', $this); $jid = CRM_Utils_Request::retrieve('jid', 'Positive', $this);
$sj = new CRM_Core_JobManager(); $sj = new CRM_Core_JobManager();
......
...@@ -257,7 +257,7 @@ class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic { ...@@ -257,7 +257,7 @@ class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic {
// populate action links // populate action links
$this->action($messageTemplate, $action, $values[$messageTemplate->id], $links, CRM_Core_Permission::EDIT); $this->action($messageTemplate, $action, $values[$messageTemplate->id], $links, CRM_Core_Permission::EDIT);
if (!$messageTemplate->workflow_id) { if (!$messageTemplate->workflow_name) {
$userTemplates[$messageTemplate->id] = $values[$messageTemplate->id]; $userTemplates[$messageTemplate->id] = $values[$messageTemplate->id];
} }
elseif (!$messageTemplate->is_reserved) { elseif (!$messageTemplate->is_reserved) {
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
* *
* @package CRM * @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing * @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id$
*
*/ */
class CRM_Api4_Page_AJAX extends CRM_Core_Page { class CRM_Api4_Page_AJAX extends CRM_Core_Page {
......
...@@ -16,8 +16,6 @@ use Civi\Api4\Service\Schema\Joinable\Joinable; ...@@ -16,8 +16,6 @@ use Civi\Api4\Service\Schema\Joinable\Joinable;
* *
* @package CRM * @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing * @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id$
*
*/ */
class CRM_Api4_Page_Api4Explorer extends CRM_Core_Page { class CRM_Api4_Page_Api4Explorer extends CRM_Core_Page {
...@@ -37,6 +35,7 @@ class CRM_Api4_Page_Api4Explorer extends CRM_Core_Page { ...@@ -37,6 +35,7 @@ class CRM_Api4_Page_Api4Explorer extends CRM_Core_Page {
'schema' => (array) \Civi\Api4\Entity::get()->setChain(['fields' => ['$name', 'getFields']])->execute(), 'schema' => (array) \Civi\Api4\Entity::get()->setChain(['fields' => ['$name', 'getFields']])->execute(),
'links' => $entityLinks, 'links' => $entityLinks,
'docs' => \Civi\Api4\Utils\ReflectionUtils::parseDocBlock($apiDoc->getDocComment()), 'docs' => \Civi\Api4\Utils\ReflectionUtils::parseDocBlock($apiDoc->getDocComment()),
'functions' => self::getSqlFunctions(),
'groupOptions' => array_column((array) $groupOptions, 'options', 'name'), 'groupOptions' => array_column((array) $groupOptions, 'options', 'name'),
]; ];
Civi::resources() Civi::resources()
...@@ -58,4 +57,25 @@ class CRM_Api4_Page_Api4Explorer extends CRM_Core_Page { ...@@ -58,4 +57,25 @@ class CRM_Api4_Page_Api4Explorer extends CRM_Core_Page {
parent::run(); parent::run();
} }
/**
* Gets info about all available sql functions
* @return array
*/
public static function getSqlFunctions() {
$fns = [];
foreach (glob(Civi::paths()->getPath('[civicrm.root]/Civi/Api4/Query/SqlFunction*.php')) as $file) {
$matches = [];
if (preg_match('/(SqlFunction[A-Z_]+)\.php$/', $file, $matches)) {
$className = '\Civi\Api4\Query\\' . $matches[1];
if (is_subclass_of($className, '\Civi\Api4\Query\SqlFunction')) {
$fns[] = [
'name' => $className::getName(),
'params' => $className::getParams(),
];
}
}
}
return $fns;
}
} }
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
* *
* @package CRM * @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing * @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id$
*
*/ */
......
...@@ -20,20 +20,10 @@ class CRM_Batch_BAO_EntityBatch extends CRM_Batch_DAO_EntityBatch { ...@@ -20,20 +20,10 @@ class CRM_Batch_BAO_EntityBatch extends CRM_Batch_DAO_EntityBatch {
* Create entity batch entry. * Create entity batch entry.
* *
* @param array $params * @param array $params
* @return array * @return CRM_Batch_DAO_EntityBatch
*/ */
public static function create(&$params) { public static function create($params) {
$op = 'edit'; return self::writeRecord($params);
$entityId = $params['id'] ?? NULL;
if (!$entityId) {
$op = 'create';
}
CRM_Utils_Hook::pre($op, 'EntityBatch', $entityId, $params);
$entityBatch = new CRM_Batch_DAO_EntityBatch();
$entityBatch->copyValues($params);
$entityBatch->save();
CRM_Utils_Hook::post($op, 'EntityBatch', $entityBatch->id, $entityBatch);
return $entityBatch;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment