Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with SMF 2.1 #2

Merged
merged 11 commits into from Apr 10, 2024
16 changes: 8 additions & 8 deletions Sources/AutoRespond/AutoRespond.php
Expand Up @@ -3,14 +3,14 @@
declare(strict_types=1);

/**
* Auto respond mod (SMF)
*
* @package AutoRespond
* @version 2.1
* @author Michel Mendiola <suki@missallsunday.com>
* @copyright Copyright (c) 2024 Michel Mendiola
* @license https://opensource.org/license/mit/
*/
* Auto respond mod (SMF)
*
* @package AutoRespond
* @version 2.1
* @author Michel Mendiola <suki@missallsunday.com>
* @copyright Copyright (c) 2024 Michel Mendiola
* @license https://opensource.org/license/mit/
*/

namespace AutoRespond;

Expand Down
18 changes: 9 additions & 9 deletions Sources/AutoRespond/AutoRespondAdmin.php
Expand Up @@ -3,14 +3,14 @@
declare(strict_types=1);

/**
* Auto respond mod (SMF)
*
* @package AutoRespond
* @version 2.1
* @author Michel Mendiola <suki@missallsunday.com>
* @copyright Copyright (c) 2024 Michel Mendiola
* @license https://opensource.org/license/mit/
*/
* Auto respond mod (SMF)
*
* @package AutoRespond
* @version 2.1
* @author Michel Mendiola <suki@missallsunday.com>
* @copyright Copyright (c) 2024 Michel Mendiola
* @license https://opensource.org/license/mit/
*/

namespace AutoRespond;

Expand Down Expand Up @@ -118,7 +118,7 @@ public function delete(): void
$message = 'AR_form_success_delete';
}

$this->redirect($message);
$this->redirect($message);
}

public function add(): void
Expand Down
80 changes: 80 additions & 0 deletions Sources/AutoRespond/AutoRespondEntity.php
@@ -0,0 +1,80 @@
<?php

namespace AutoRespond;

class AutoRespondEntity
{
public string $body = '';
public string $title = '';
public int $user_id = 1;
public int $id = 0;
public int $board_id = 0;

public function __construct(array $entry = [])
{
$this->setEntry($entry);
}

public function setEntry(array $entry): void
{
foreach ($entry as $key => $value) {
$setCall = 'set' . $this->snakeToCamel($key);
$this->{$setCall}($value);
}
}

public function getBoardId(): int
{
return $this->board_id;
}

public function setBoardId(int $boardId): void
{
$this->board_id = $boardId;
}

public function getBody(): string
{
return $this->body;
}

public function setBody(string $body): void
{
$this->body = $body;
}

public function getTitle(): string
{
return $this->title;
}

public function setTitle(string $title): void
{
$this->title = $title;
}

public function getUserId(): int
{
return $this->user_id;
}

public function setUserId(int $userId): void
{
$this->user_id = $userId;
}

public function getId(): int
{
return $this->id;
}

public function setId(int $id): void
{
$this->id = $id;
}

private function snakeToCamel($input): string
{
return \lcfirst(\str_replace('_', '', \ucwords($input, '_')));
}
}
22 changes: 11 additions & 11 deletions Sources/AutoRespond/AutoRespondService.php
Expand Up @@ -3,14 +3,14 @@
declare(strict_types=1);

/**
* Auto respond mod (SMF)
*
* @package AutoRespond
* @version 2.1
* @author Michel Mendiola <suki@missallsunday.com>
* @copyright Copyright (c) 2024 Michel Mendiola
* @license https://opensource.org/license/mit/
*/
* Auto respond mod (SMF)
*
* @package AutoRespond
* @version 2.1
* @author Michel Mendiola <suki@missallsunday.com>
* @copyright Copyright (c) 2024 Michel Mendiola
* @license https://opensource.org/license/mit/
*/

namespace AutoRespond;

Expand Down Expand Up @@ -142,9 +142,9 @@ public function getEntriesByBoard(int $boardId = 0): array
FROM {db_prefix}autorespond
WHERE find_in_set("{int:boardId}",board_id) <> 0
ORDER BY {raw:sort}', [
'sort' => 'id',
'boardId' => $boardId
]));
'sort' => 'id',
'boardId' => $boardId
]));
}

public function getBoards(): array
Expand Down
22 changes: 11 additions & 11 deletions Themes/default/AutoRespond.template.php
Expand Up @@ -12,7 +12,7 @@

function template_ar_show_add()
{
global $context, $scripturl, $txt;
global $context, $scripturl, $txt;

$action = $context['data']['id'] ? 'edit' : 'add';
$id = $context['data']['id'] ? (';id='. $context['data']['id']) : '';
Expand Down Expand Up @@ -89,7 +89,7 @@ function template_ar_show_add()

function template_ar_show_list()
{
global $context, $txt, $scripturl;
global $context, $txt, $scripturl;

$session = ';'. $context['session_var'] .'='. $context['session_id'];

Expand All @@ -99,12 +99,12 @@ function template_ar_show_list()
unset($_SESSION['autorespond']);
}

if (empty($context['data']['entries'])) {
if (empty($context['data']['entries'])) {
echo '
<div class="noticebox">' . $txt['AR_empty_message_list'] . '</div>';
} else
{
echo '
{
echo '
<table class="table_grid">
<thead>
<tr class="title_bar">
Expand All @@ -119,8 +119,8 @@ function template_ar_show_list()
<tbody>';

/* AutoRespondEntity $entry */
foreach($context['data']['entries'] as $id => $entry)
echo '
foreach($context['data']['entries'] as $id => $entry)
echo '
<tr class="windowbg" style="text-align: center">
<td class="windowbg2">
'. $id .'
Expand All @@ -142,12 +142,12 @@ function template_ar_show_list()
</td>
</tr>';

echo '</tbody>
echo '</tbody>
</table><br />';
}
}

echo '
echo '
<div id="confirm_buttons">
<a class="button" href="'.$scripturl. '?'. \AutoRespond\AutoRespondAdmin::URL .';sa=add'. $session .'">'. $txt['AR_admin_add'] .'</a>
</div>';
}
}
4 changes: 2 additions & 2 deletions Themes/default/languages/AutoRespond.english.php
Expand Up @@ -55,12 +55,12 @@
$txt['AR_update_post_count_sub'] = 'If checked, it will increment the post account of the user who will post the reply.';
$txt['AR_lock_topic_after'] = 'Lock the topic after the response?';
$txt['AR_lock_topic_after_sub'] = 'If checked, the topic where the response will be posted will get locked automatically.';
$txt['AR_dummy_ip'] = 'Place a dummy IP (127.0.0.1) instead of the posters IP';
$txt['AR_dummy_ip'] = 'Place a dummy IP (127.0.0.1) instead of the posters IP';
$txt['AR_dummy_ip_sub'] = 'If this is checked, all the messages generated by this mod will have an IP 127.0.0.1 (localhost).';
$txt['AR_manage_desc'] = 'Here\'s a list of all your custom messages, from here you can add/edit/delete any message as well as add new ones';

/* Error strings */
$txt['AR_error_delete'] = 'The message could not be deleted.';
$txt['AR_no_message'] = 'The message does not exist.';
$txt['AR_empty_value'] = 'You need to fill out all the items in the form';
$txt['AR_empty_message_list'] = 'There are no messages yet';
$txt['AR_empty_message_list'] = 'There are no messages yet';
39 changes: 23 additions & 16 deletions composer.json
@@ -1,18 +1,25 @@
{
"name": "suki/auto-respond",
"description": "SMF modification for creating automatic responses",
"type": "smf-module",
"license": "MIT",
"authors": [
{
"name": "Michel Mendiola",
"email": "suki@missallsunday.com"
}
],
"autoload": {
"psr-4": {
"AutoRespond\\": "Sources/AutoRespond/"
}
},
"minimum-stability": "dev"
"name": "suki/auto-respond",
"description": "SMF modification for creating automatic responses",
"type": "smf-module",
"license": "MIT",
"authors": [
{
"name": "Michel Mendiola",
"email": "suki@missallsunday.com"
}
],
"autoload": {
"psr-4": {
"AutoRespond\\": "Sources/AutoRespond/"
}
},
"minimum-stability": "dev",
"require": {
"php": ">=7.4",
"ext-ctype": "*"
},
"require-dev": {
"phpstan/phpstan": "2.0.x-dev"
}
}
17 changes: 17 additions & 0 deletions phpstan.neon
@@ -0,0 +1,17 @@
parameters:
level: 5
paths:
- Sources
ignoreErrors:
- '#Function loadMemberContext not found.#'
- '#Function loadMemberData not found.#'
- '#Function getBoardTree not found.#'
- '#Function loadtemplate not found.#'
- '#Function loadLanguage not found.#'
- '#Function isAllowedTo not found.#'
- '#Function redirectexit not found.#'
- '#Function prepareDBSettingContext not found.#'
- '#Function saveDBSettings not found.#'
- '#Function checkSession not found.#'
- '#Function un_preparsecode not found.#'
- '#Function createPost not found.#'
40 changes: 0 additions & 40 deletions readme.txt

This file was deleted.

27 changes: 0 additions & 27 deletions uninstall.php

This file was deleted.