Skip to content

Commit

Permalink
Merge pull request #19132 from seamuslee001/master
Browse files Browse the repository at this point in the history
5.33
  • Loading branch information
eileenmcnaughton authored Dec 6, 2020
2 parents 0d8130f + 18cdd96 commit 7c9da56
Show file tree
Hide file tree
Showing 22 changed files with 270 additions and 106 deletions.
8 changes: 4 additions & 4 deletions CRM/Contact/DAO/RelationshipCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Contact/RelationshipCache.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:3bee16c8388728d3e391e9dd7c17abb8)
* (GenCodeChecksum:ba039fcadc13e48749f965343301ec1d)
*/

/**
Expand Down Expand Up @@ -129,7 +129,7 @@ public function __construct() {
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
return $plural ? ts('Relationship Caches') : ts('Relationship Cache');
return $plural ? ts('Related Contacts') : ts('Related Contact');
}

/**
Expand Down Expand Up @@ -237,7 +237,7 @@ public static function &fields() {
'near_relation' => [
'name' => 'near_relation',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Relationship Name (Near side)'),
'title' => ts('Relationship Name (to related contact)'),
'description' => ts('name for relationship of near_contact to far_contact.'),
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
Expand Down Expand Up @@ -271,7 +271,7 @@ public static function &fields() {
'far_relation' => [
'name' => 'far_relation',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Relationship Name (Near side)'),
'title' => ts('Relationship Name (from related contact)'),
'description' => ts('name for relationship of far_contact to near_contact.'),
'maxlength' => 64,
'size' => CRM_Utils_Type::BIG,
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static function add(&$params) {
CRM_Contribute_BAO_ContributionRecur::updateOnNewPayment(
(!empty($params['contribution_recur_id']) ? $params['contribution_recur_id'] : $params['prevContribution']->contribution_recur_id),
$contributionStatus,
$params['receive_date'] ?? NULL
$params['receive_date'] ?? 'now'
);
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/BAO/ContributionRecur.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ public static function getRecurringFields() {
*
* @throws \CiviCRM_API3_Exception
*/
public static function updateOnNewPayment($recurringContributionID, $paymentStatus, $effectiveDate) {
public static function updateOnNewPayment($recurringContributionID, $paymentStatus, string $effectiveDate = 'now') {

if (!in_array($paymentStatus, ['Completed', 'Failed'])) {
return;
Expand Down
3 changes: 1 addition & 2 deletions CRM/Core/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,7 @@ public function sequenceKey() {
* Returns list of FK relationships.
*
*
* @return array
* Array of CRM_Core_Reference_Interface
* @return CRM_Core_Reference_Basic[]
*/
public static function getReferenceColumns() {
return [];
Expand Down
2 changes: 1 addition & 1 deletion CRM/Export/BAO/ExportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ public function runQuery($params, $order) {
list($select, $from, $where, $having) = $query->query();
$this->setQueryFields($query->_fields);
$whereClauses = ['trash_clause' => "contact_a.is_deleted != 1"];
if ($this->getRequestedFields() && ($this->getComponentTable())) {
if ($this->getRequestedFields() && $this->getComponentTable() && $this->getComponentTable() !== 'civicrm_contact') {
$from .= " INNER JOIN " . $this->getComponentTable() . " ctTable ON ctTable.contact_id = contact_a.id ";
}
elseif ($this->getComponentClause()) {
Expand Down
4 changes: 4 additions & 0 deletions CRM/Upgrade/Incremental/sql/5.33.beta2.mysql.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{* file to handle db changes in 5.33.beta2 during upgrade *}

{* dev/core#2188, dev/core#337 (redux) - Ranges aren't support on these widgets. Note: This same change ran previously in 5.9.beta and contemporaneously in 5.32.1, and that's OK. *}
UPDATE civicrm_custom_field SET is_search_range = 0 WHERE html_type IN ('Radio', 'Select') AND data_type IN ('Money', 'Float', 'Int');
5 changes: 5 additions & 0 deletions Civi/Api4/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public static function getFields($checkPermissions = TRUE) {
'data_type' => 'Array',
'description' => 'Any @see annotations from docblock',
],
[
'name' => 'bridge',
'data_type' => 'Array',
'description' => 'Connecting fields for EntityBridge types',
],
];
}))->setCheckPermissions($checkPermissions);
}
Expand Down
11 changes: 10 additions & 1 deletion Civi/Api4/Generic/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ protected static function getEntityName() {
* @return string
*/
protected static function getEntityTitle($plural = FALSE) {
return static::getEntityName();
$name = static::getEntityName();
$dao = \CRM_Core_DAO_AllCoreTables::getFullName($name);
return $dao ? $dao::getEntityTitle($plural) : ($plural ? \CRM_Utils_String::pluralize($name) : $name);
}

/**
Expand Down Expand Up @@ -136,6 +138,13 @@ public static function getInfo() {
'type' => [self::stripNamespace(get_parent_class(static::class))],
'paths' => static::getEntityPaths(),
];
// Add info for entities with a corresponding DAO
$dao = \CRM_Core_DAO_AllCoreTables::getFullName($info['name']);
if ($dao) {
$info['paths'] = $dao::getEntityPaths();
$info['icon'] = $dao::$_icon;
$info['dao'] = $dao;
}
foreach (ReflectionUtils::getTraits(static::class) as $trait) {
$info['type'][] = self::stripNamespace($trait);
}
Expand Down
25 changes: 0 additions & 25 deletions Civi/Api4/Generic/DAOEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,4 @@ public static function replace($checkPermissions = TRUE) {
->setCheckPermissions($checkPermissions);
}

/**
* @param bool $plural
* Whether to return a plural title.
* @return string
*/
protected static function getEntityTitle($plural = FALSE) {
$name = static::getEntityName();
$dao = \CRM_Core_DAO_AllCoreTables::getFullName($name);
return $dao ? $dao::getEntityTitle($plural) : $name;
}

/**
* @return array
*/
public static function getInfo() {
$info = parent::getInfo();
$dao = \CRM_Core_DAO_AllCoreTables::getFullName($info['name']);
if ($dao) {
$info['paths'] = $dao::getEntityPaths();
$info['icon'] = $dao::$_icon;
$info['dao'] = $dao;
}
return $info;
}

}
20 changes: 20 additions & 0 deletions Civi/Api4/Generic/Traits/EntityBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,24 @@
*/
trait EntityBridge {

/**
* Adds "bridge" info, which should specify an array of two field names from this entity
*
* This automatic function can be overridden by annotating the APIv4 entity like
* `@bridge contact_id group_id`
*
* @return array
*/
public static function getInfo() {
$info = parent::getInfo();
if (!empty($info['dao']) && empty($info['bridge'])) {
foreach (($info['dao'])::fields() as $field) {
if (!empty($field['FKClassName']) || $field['name'] === 'entity_id') {
$info['bridge'][] = $field['name'];
}
}
}
return $info;
}

}
3 changes: 2 additions & 1 deletion Civi/Api4/GroupContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
* A contact can either be "Added" "Removed" or "Pending" in a group.
* CiviCRM only considers them to be "in" a group if their status is "Added".
*
* @bridge group_id contact_id
* @see \Civi\Api4\Group
*
* @searchable false
* @package Civi\Api4
*/
class GroupContact extends Generic\DAOEntity {
Expand Down
2 changes: 1 addition & 1 deletion Civi/Api4/RelationshipCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* RelationshipCache - readonly table to facilitate joining and finding contacts by relationship.
*
* @see \Civi\Api4\Relationship
*
* @bridge near_contact_id far_contact_id
* @package Civi\Api4
*/
class RelationshipCache extends Generic\AbstractEntity {
Expand Down
3 changes: 3 additions & 0 deletions Civi/Api4/Utils/ReflectionUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public static function parseDocBlock($comment) {
elseif ($key == 'searchable') {
$info[$key] = strtolower($words[0]) !== 'false';
}
elseif ($key == 'bridge') {
$info[$key] = $words;
}
elseif ($key == 'param' && $words) {
$type = $words[0][0] !== '$' ? explode('|', array_shift($words)) : NULL;
$param = rtrim(array_shift($words), '-:()/');
Expand Down
9 changes: 3 additions & 6 deletions ext/oauth-client/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@
</urls>
<releaseDate>2020-10-23</releaseDate>
<version>1.0</version>
<tags>
<tag>mgmt:hidden</tag>
</tags>
<develStage>alpha</develStage>
<develStage>stable</develStage>
<compatibility>
<ver>5.0</ver>
<ver>5.33</ver>
</compatibility>
<requires>
<ext version="~4.5">org.civicrm.afform</ext>
</requires>
<comments>This is a new, undeveloped module</comments>
<comments>This extension provides a framework for oauth support</comments>
<classloader>
<psr4 prefix="Civi\" path="Civi"/>
</classloader>
Expand Down
17 changes: 0 additions & 17 deletions ext/search/CRM/Search/Page/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@ public function run() {
];
CRM_Utils_System::appendBreadCrumb([$breadCrumb]);

$schema = \Civi\Search\Admin::getSchema();

// If user does not have permission to search any entity, bye bye.
if (!$schema) {
CRM_Utils_System::permissionDenied();
}

// Add client-side vars for the search UI
$vars = [
'schema' => $schema,
'links' => \Civi\Search\Admin::getLinks(array_column($schema, 'name')),
];

Civi::resources()
->addBundle('bootstrap3')
->addVars('search', $vars);

// Load angular module
$loader = new Civi\Angular\AngularLoader();
$loader->setPageName('civicrm/admin/search');
Expand Down
Loading

0 comments on commit 7c9da56

Please sign in to comment.