From e159a5e0a2ea4f4ea041213339a7d2ba1d35e362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jer=C3=B4me=20Bakker?= Date: Tue, 26 Jul 2022 16:37:03 +0200 Subject: [PATCH] changed: updated for Elgg 4.3 --- README.md | 2 +- classes/ColdTrick/OpenSearch/Export.php | 18 +++++++++++++----- classes/ColdTrick/OpenSearch/Menus/Page.php | 2 +- classes/ColdTrick/OpenSearch/SearchParams.php | 2 +- composer.json | 2 +- composer.lock | 12 ++++++------ views/default/opensearch/search/suggest.php | 2 +- views/default/opensearch/stats/indices.php | 2 +- 8 files changed, 25 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4189871..58ec040 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # opensearch -![Elgg 4.2](https://img.shields.io/badge/Elgg-4.2-green.svg) +![Elgg 4.3](https://img.shields.io/badge/Elgg-4.3-green.svg) ![OpenSearch 1.1](https://img.shields.io/badge/OpenSearch-1.1-green.svg) [![Build Status](https://scrutinizer-ci.com/g/ColdTrick/opensearch/badges/build.png?b=master)](https://scrutinizer-ci.com/g/ColdTrick/opensearch/build-status/master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ColdTrick/opensearch/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ColdTrick/opensearch/?branch=master) diff --git a/classes/ColdTrick/OpenSearch/Export.php b/classes/ColdTrick/OpenSearch/Export.php index 701890e..e2c2006 100644 --- a/classes/ColdTrick/OpenSearch/Export.php +++ b/classes/ColdTrick/OpenSearch/Export.php @@ -2,6 +2,8 @@ namespace ColdTrick\OpenSearch; +use Elgg\Database\QueryBuilder; + class Export { /** @@ -247,11 +249,13 @@ public static function entityRelationshipsToObject(\Elgg\Hook $hook) { return; } - $relationships = get_entity_relationships($entity->guid); - if (empty($relationships)) { - return; - } - + $relationships = elgg_get_relationships([ + 'batch' => true, + 'wheres' => function(QueryBuilder $qb, $main_alias) use ($entity) { + return $qb->compare("{$main_alias}.guid_one", '=', $entity->guid, ELGG_VALUE_GUID); + } + ]); + $result = []; /* @var $relationship \ElggRelationship */ foreach ($relationships as $relationship) { @@ -264,6 +268,10 @@ public static function entityRelationshipsToObject(\Elgg\Hook $hook) { ]; } + if (empty($result)) { + return; + } + $return = $hook->getValue(); if (!isset($return->relationships)) { diff --git a/classes/ColdTrick/OpenSearch/Menus/Page.php b/classes/ColdTrick/OpenSearch/Menus/Page.php index 13a795d..8a2126b 100644 --- a/classes/ColdTrick/OpenSearch/Menus/Page.php +++ b/classes/ColdTrick/OpenSearch/Menus/Page.php @@ -19,7 +19,7 @@ public static function admin(\Elgg\Hook $hook) { return; } - $current_path = parse_url(current_page_url(), PHP_URL_PATH); + $current_path = parse_url(elgg_get_current_url(), PHP_URL_PATH); $site_path = parse_url(elgg_get_site_url(), PHP_URL_PATH); $parsed_path = substr($current_path, strlen($site_path)); diff --git a/classes/ColdTrick/OpenSearch/SearchParams.php b/classes/ColdTrick/OpenSearch/SearchParams.php index 21cf4e4..6e39a5b 100644 --- a/classes/ColdTrick/OpenSearch/SearchParams.php +++ b/classes/ColdTrick/OpenSearch/SearchParams.php @@ -445,7 +445,7 @@ public function addEntityAccessFilter(int $user_guid = 0) { } // add acl filter - $access_array = get_access_array($user_guid); + $access_array = elgg_get_access_array($user_guid); if (!empty($access_array)) { $access_filter[]['terms']['access_id'] = $access_array; } diff --git a/composer.json b/composer.json index 28e0961..2e6e708 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "coldtrick/sniffs": "dev-master" }, "conflict": { - "elgg/elgg": "<4.2" + "elgg/elgg": "<4.3" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index 7762ce8..54350b5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8d0f228cce6989577d855ca2e9ffc418", + "content-hash": "39654424a5c195c6830737ca088e7087", "packages": [ { "name": "composer/installers", @@ -502,16 +502,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.6.2", + "version": "3.7.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", - "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", "shasum": "" }, "require": { @@ -554,7 +554,7 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2021-12-12T21:44:58+00:00" + "time": "2022-06-18T07:21:10+00:00" } ], "aliases": [], diff --git a/views/default/opensearch/search/suggest.php b/views/default/opensearch/search/suggest.php index 31a534a..f091caf 100644 --- a/views/default/opensearch/search/suggest.php +++ b/views/default/opensearch/search/suggest.php @@ -40,7 +40,7 @@ $url = elgg_view('output/url', [ 'text' => elgg_format_element('strong', [], $suggestion), - 'href' => elgg_http_add_url_query_elements(current_page_url(), ['q' => $suggestion]), + 'href' => elgg_http_add_url_query_elements(elgg_get_current_url(), ['q' => $suggestion]), ]); $query = elgg_format_element('i', [], $query); diff --git a/views/default/opensearch/stats/indices.php b/views/default/opensearch/stats/indices.php index bfee794..262dae2 100644 --- a/views/default/opensearch/stats/indices.php +++ b/views/default/opensearch/stats/indices.php @@ -54,7 +54,7 @@ $title = elgg_view('output/url', [ 'text' => elgg_echo('opensearch:stats:index:index', [$index]), 'href' => "#index_{$index}", - 'rel' => 'toggle', + 'class' => 'elgg-toggle', ]); echo elgg_view_module('info', $title, $content);