Skip to content

Commit

Permalink
Merge pull request #79 from paul999/33x2
Browse files Browse the repository at this point in the history
Preparing for new release
  • Loading branch information
paul999 authored Apr 18, 2023
2 parents 951adcf + 7936892 commit 1d98678
Show file tree
Hide file tree
Showing 51 changed files with 2,063 additions and 1,933 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Copy the extension to phpBB/ext/paul999/mention

Go to "ACP" > "Customise" > "Extensions" and enable the "phpBB mentions" extension.

**Please note that this extension requires phpBB 3.2!**
**Please note that this extension requires phpBB 3.3 and at least php 7.1!
The extension has only been tested with PHP7.1, 7.2, 7.3 7,4 and 8.0.
If you use phpBB 3.2, you should use 1.0.x instead.**

## Tests and Continuous Integration

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Mention a user by using @USERNAME",
"homepage": "https://www.phpbbextensions.io",
"version": "2.0.0",
"time": "2019-06-10",
"time": "2023-03-04",
"license": "GPL-2.0-only",
"authors": [
{
Expand All @@ -15,7 +15,7 @@
}
],
"require": {
"php": "~7.1"
"php": "~7.1 || ~8.0"
},
"extra": {
"display-name": "Simple mentions",
Expand Down
10 changes: 7 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 44 additions & 5 deletions controller/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public function __construct(user $user, driver_interface $db, auth $auth, reques
* get a list of users matching on a username (Minimal 3 chars)
*
*
* @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
* @return JsonResponse A Symfony Response object
*/
public function handle()
public function handle() : JsonResponse
{
if ($this->user->data['user_id'] == ANONYMOUS || $this->user->data['is_bot'] || !$this->auth->acl_get('u_can_mention'))
{
Expand All @@ -89,18 +89,57 @@ public function handle()
FROM ' . USERS_TABLE . '
WHERE user_id <> ' . ANONYMOUS . '
AND ' . $this->db->sql_in_set('user_type', [USER_NORMAL, USER_FOUNDER]) . '
AND username_clean ' . $this->db->sql_like_expression($name . $this->db->get_any_char());
$result = $this->db->sql_query($sql);
AND username_clean ' . $this->db->sql_like_expression($this->db->get_any_char() . $name . $this->db->get_any_char());
$result = $this->db->sql_query_limit($sql, max(5, (int) $this->config['simple_mention_maxresults']), 0);
$return = [];

while ($row = $this->db->sql_fetchrow($result))
{
$return[] = [
'key' =>$row['username'],
'key' => $row['username'],
'value' => $row['username'],
'user_id' => $row['user_id'],
'type' => 'user',
];
}
$this->db->sql_freeresult($result);

if ($this->auth->acl_get('u_can_mention_groups'))
{
// We can mention groups. So also add that to the list.

$sql = 'SELECT COUNT(ug.user_id) as cnt, g.group_name, g.group_id, g.group_type
FROM '. USER_GROUP_TABLE . ' ug, ' . GROUPS_TABLE . ' g
WHERE
g.group_id = ug.group_id
AND g.group_type <> ' . GROUP_HIDDEN . '
AND ' . $this->db->sql_in_set('g.group_name', ['GUESTS', 'BOTS'], true) . '
AND (
LOWER(g.group_name) ' . $this->db->sql_like_expression($this->db->get_any_char() . strtolower($name) . $this->db->get_any_char()) . '
OR g.group_type = ' . GROUP_SPECIAL . '
)
GROUP BY ug.group_id';

$result = $this->db->sql_query_limit($sql, max(5, (int) $this->config['simple_mention_maxresults']), 0);

while ($row = $this->db->sql_fetchrow($result))
{
if ($row['cnt'] > $this->config['simple_mention_large_groups'] && !$this->auth->acl_get('u_can_mention_large_groups'))
{
// User can't send mentions to large groups.
continue;
}
$return[] = [
'key' => $row['group_type'] == GROUP_SPECIAL ? $this->user->lang('G_' . $row['group_name']) : $row['group_name'],
'value' => $row['group_type'] == GROUP_SPECIAL ? $this->user->lang('G_' . $row['group_name']) : $row['group_name'],
'group_id' => $row['group_id'],
'cnt' => $row['cnt'],
'type' => 'group',
];
}
$this->db->sql_freeresult($result);
}

return new JsonResponse($return);
}
}
210 changes: 0 additions & 210 deletions core/bbcodes_installer.php

This file was deleted.

Loading

0 comments on commit 1d98678

Please sign in to comment.