diff --git a/README.md b/README.md index f142dcb..04f0fb4 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,12 @@ The ExpressionEngine Discussion Forum Module allows you to create and manage a f ## Changelog +### 5.1.3 + +- Fixed PHP deprecation issues. +- Fixed bug where Superadmin were not given full permissions in rare cases. +- Fixed Invalid reference to PATH_ADDONS ([#5](https://github.com/ExpressionEngine/Forum/issues/5)) + ### 5.1.2 - Fixed PHP deprecation issues. diff --git a/system/user/addons/forum/Model/Post.php b/system/user/addons/forum/Model/Post.php index 48c602d..a6fcf09 100644 --- a/system/user/addons/forum/Model/Post.php +++ b/system/user/addons/forum/Model/Post.php @@ -131,8 +131,13 @@ public static function onBeforeBulkDelete($delete_ids) public static function onAfterBulkDelete() { - require_once PATH_ADDONS . 'forum/mod.forum.php'; - require_once PATH_ADDONS . 'forum/mod.forum_core.php'; + foreach(['forum/mod.forum.php', 'forum/mod.forum_core.php'] as $file) { + if (file_exists(PATH_THIRD . $file)) { + require_once PATH_THIRD . $file; + } else { + require_once PATH_ADDONS . $file; + } + } $forum_core = new \Forum_Core(); diff --git a/system/user/addons/forum/Model/Topic.php b/system/user/addons/forum/Model/Topic.php index dc72498..74491d1 100644 --- a/system/user/addons/forum/Model/Topic.php +++ b/system/user/addons/forum/Model/Topic.php @@ -167,8 +167,13 @@ public static function onBeforeBulkDelete($delete_ids) public static function onAfterBulkDelete($delete_ids) { - require_once PATH_ADDONS . 'forum/mod.forum.php'; - require_once PATH_ADDONS . 'forum/mod.forum_core.php'; + foreach(['forum/mod.forum.php', 'forum/mod.forum_core.php'] as $file) { + if (file_exists(PATH_THIRD . $file)) { + require_once PATH_THIRD . $file; + } else { + require_once PATH_ADDONS . $file; + } + } $forum_core = new \Forum_Core(); diff --git a/system/user/addons/forum/addon.setup.php b/system/user/addons/forum/addon.setup.php index c0f69c5..620ba7b 100644 --- a/system/user/addons/forum/addon.setup.php +++ b/system/user/addons/forum/addon.setup.php @@ -5,7 +5,7 @@ 'author_url' => 'https://expressionengine.com/', 'name' => 'Forum', 'description' => 'Add a full-featured forum to your site', - 'version' => '5.1.2', + 'version' => '5.1.3', 'namespace' => 'ExpressionEngine\Addons\Forum', 'settings_exist' => true, diff --git a/system/user/addons/forum/mod.forum.php b/system/user/addons/forum/mod.forum.php index c326803..b8a6136 100644 --- a/system/user/addons/forum/mod.forum.php +++ b/system/user/addons/forum/mod.forum.php @@ -13,8 +13,8 @@ */ class Forum { - public $version = '5.1.2'; - public $build = '20251119'; + public $version = '5.1.3'; + public $build = '20260305'; public $use_site_profile = false; public $search_limit = 250; // Maximum number of search results (x2 since it can include this number of topics + this number of posts) public $return_data = ''; @@ -43,6 +43,7 @@ class Forum public $cur_thread_row = 0; public $thread_post_total = 0; // Used for new entry submission to determine redirect page number public $trigger_error_page = false; + public $trigger_login_page = false; public $is_table_open = false; public $preview_override = false; public $mbr_class_loaded = false; @@ -53,6 +54,7 @@ class Forum public $spellcheck_enabled = false; public $feeds_enabled = null; public $feed_ids = ''; + public $date_limit = ''; public $realm = "ExpressionEngine Forums"; public $auth_attempt = false; public $use_sess_id = 0; // Used in calls to ee()->functions->fetch_site_index() in certain URLs, like attachments @@ -271,12 +273,12 @@ public function display_forum($function = '') // Parse Snippets foreach (ee()->config->_global_vars as $key => $val) { - $this->return_data = str_replace(LD . $key . RD, $val, $this->return_data); + $this->return_data = str_replace(LD . $key . RD, ($val === null) ? '' : $val, $this->return_data); } // Parse Global Variables foreach (ee()->TMPL->global_vars as $key => $val) { - $this->return_data = str_replace(LD . $key . RD, $val, $this->return_data); + $this->return_data = str_replace(LD . $key . RD, ($val === null) ? '' : $val, $this->return_data); } $this->return_data = $this->_final_prep($this->return_data); @@ -938,7 +940,7 @@ public function var_swap($str, $data) } foreach ($data as $key => $val) { - $str = str_replace('{' . $key . '}', $val, $str); + $str = str_replace('{' . $key . '}', ($val === null) ? '' : $val, $str); } return $str; diff --git a/system/user/addons/forum/mod.forum_core.php b/system/user/addons/forum/mod.forum_core.php index 9a98f84..da1aeef 100644 --- a/system/user/addons/forum/mod.forum_core.php +++ b/system/user/addons/forum/mod.forum_core.php @@ -106,12 +106,12 @@ public function display_forum($function = '') // Parse Snippets foreach (ee()->config->_global_vars as $key => $val) { - $this->return_data = str_replace(LD . $key . RD, $val, $this->return_data); + $this->return_data = str_replace(LD . $key . RD, ($val === null) ? '' : $val, $this->return_data); } // Parse Global Variables foreach (ee()->TMPL->global_vars as $key => $val) { - $this->return_data = str_replace(LD . $key . RD, $val, $this->return_data); + $this->return_data = str_replace(LD . $key . RD, ($val === null) ? '' : $val, $this->return_data); } $this->return_data = $this->_final_prep($this->return_data); @@ -6180,7 +6180,8 @@ public function move_reply() } if (false !== (strpos($new_topic_id, "/"))) { - $new_topic_id = end(explode("/", $new_topic_id)); + $new_topic_id_parts = explode("/", $new_topic_id); + $new_topic_id = end($new_topic_id_parts); } if (! is_numeric($new_topic_id)) { @@ -6491,7 +6492,8 @@ public function do_merge() } if (false !== (strpos($merge_id, "/"))) { - $merge_id = end(explode("/", $merge_id)); + $merge_id_parts = explode("/", $merge_id); + $merge_id = end($merge_id_parts); } if (! is_numeric($merge_id)) { @@ -9523,7 +9525,7 @@ public function http_authentication_check_digest($allowed_groups = array()) } // make sure Super Admins are always allowed - if (! in_array($allowed_groups, 1)) { + if (! in_array(1, $allowed_groups)) { $allowed_groups[] = 1; } diff --git a/system/user/addons/forum/spam.forum.php b/system/user/addons/forum/spam.forum.php index 55ebedb..8d79bff 100644 --- a/system/user/addons/forum/spam.forum.php +++ b/system/user/addons/forum/spam.forum.php @@ -20,8 +20,13 @@ class Forum_spam implements SpamModerationInterface */ public function __construct() { - require_once PATH_ADDONS . 'forum/mod.forum.php'; - require_once PATH_ADDONS . 'forum/mod.forum_core.php'; + foreach(['forum/mod.forum.php', 'forum/mod.forum_core.php'] as $file) { + if (file_exists(PATH_THIRD . $file)) { + require_once PATH_THIRD . $file; + } else { + require_once PATH_ADDONS . $file; + } + } $this->fc = new \Forum_Core(); } diff --git a/system/user/addons/forum/tab.forum.php b/system/user/addons/forum/tab.forum.php index 7f60d86..8d3daff 100644 --- a/system/user/addons/forum/tab.forum.php +++ b/system/user/addons/forum/tab.forum.php @@ -317,8 +317,13 @@ public function save($entry, $values) // Update the forum stats if (! class_exists('Forum')) { - require PATH_ADDONS . 'forum/mod.forum.php'; - require PATH_ADDONS . 'forum/mod.forum_core.php'; + foreach(['forum/mod.forum.php', 'forum/mod.forum_core.php'] as $file) { + if (file_exists(PATH_THIRD . $file)) { + require_once PATH_THIRD . $file; + } else { + require_once PATH_ADDONS . $file; + } + } } $forum_core = new Forum_Core();