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

[K6.4] fix and cleanup kunena config usage #9727

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
defined('_JEXEC') or die();

use Joomla\CMS\Language\Text;
use Kunena\Forum\Libraries\Factory\KunenaFactory;
use Kunena\Forum\Libraries\Config\KunenaConfig;

// Kunena 5.2.0: Convert all configuration options to the news ones in K6.0
/**
Expand All @@ -22,7 +22,7 @@
* @since Kunena 5.2.4
*/
function kunena_5215_2021_07_24_update_configuration($parent) {
$config = KunenaFactory::getConfig();
$config = KunenaConfig::getInstance();

$config->boardTitle = $config->board_title;

Expand Down
2 changes: 1 addition & 1 deletion src/admin/src/Model/ConfigModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ public function getConfigLists(): array
// Added new options into Kunena 3.0.0
$lists ['autoLink'] = HTMLHelper::_('select.genericlist', $yesno, 'cfg_autoLink', 'class="inputbox form-select"size="1"', 'value', 'text', $config->autoLink);
$lists ['accessComponent'] = HTMLHelper::_('select.genericlist', $yesno, 'cfg_accessComponent', 'class="inputbox form-select"size="1"', 'value', 'text', $config->accessComponent);
$lists ['componentUrl'] = preg_replace('|/+|', '/', Uri::root() . ($config->get('sef_rewrite') ? '' : 'index.php') . ($config->get('sef') ? '/component/kunena' : '?option=com_kunena'));
$lists ['componentUrl'] = preg_replace('|/+|', '/', Uri::root() . 'index.php' . ($config->sef ? '/component/kunena' : '?option=com_kunena'));
$lists['attachmentProtection'] = HTMLHelper::_('select.genericlist', $yesno, 'cfg_attachmentProtection', 'class="inputbox form-select"size="1"', 'value', 'text', $config->attachmentProtection);

// Option to select if the stats link need to be showed for all users or only for registered users
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/kunena/src/Email/KunenaEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function send($mail, array $receivers)
$emailRecipientCount = 1;
}

$emailRecipientPrivacy = $config->get('emailRecipientPrivacy', 'bcc');
$emailRecipientPrivacy = $config->emailRecipientPrivacy ?: 'bcc';

// If we hide email addresses from other users, we need to add TO address to prevent email from becoming spam.
if (
Expand Down
4 changes: 1 addition & 3 deletions src/libraries/kunena/src/Factory/KunenaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ public static function loadLanguage($file = 'com_kunena', $client = 'site'): boo

$english = false;

if (
self::getConfig()->get('fallbackEnglish')
) {
if (KunenaConfig::getInstance()->fallbackEnglish) {
$lang->load($file, $lookup2, 'en-GB', true, false);
$english = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/kunena/src/Layout/KunenaBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function __construct(string $name, array $paths = null)
// Setup dependencies.
$this->_name = $name;
$this->includePaths = isset($paths) ? $paths : $this->loadPaths();
$this->debug = JDEBUG || KunenaConfig::getInstance()->get('debug');
$this->debug = JDEBUG || KunenaConfig::getInstance()->debug;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/kunena/src/User/KunenaUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ public function getMessageOrdering(): string
static $default;

if (\is_null($default)) {
$default = KunenaFactory::getConfig()->get('defaultSort') == 'desc' ? 'desc' : 'asc';
$default = KunenaConfig::getInstance()->defaultSort == 'desc' ? 'desc' : 'asc';
}

if ($this->exists()) {
Expand Down
3 changes: 1 addition & 2 deletions src/site/src/Layout/Category/CategoryItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,8 @@ public function getCategoryActions()
// Is user allowed to post new topic?
$url = $category->getNewTopicUrl();
$this->ktemplate = KunenaFactory::getTemplate();
$config = KunenaConfig::getInstance();

if ($config->readOnly) {
if (KunenaConfig::getInstance()->readOnly) {
return false;
}

Expand Down
3 changes: 1 addition & 2 deletions src/site/src/Layout/Widget/WidgetEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ public function getAllowedtoUseLinksImages()
{
$this->ktemplate = KunenaFactory::getTemplate();
$templatesettings = $this->ktemplate->params;
$config = KunenaConfig::getInstance();
$me = KunenaUserHelper::getMyself();

if ($me->checkUserAllowedLinksImages()) {
$this->addScriptOptions('com_kunena.ckeditor_remove_buttons_url_image', $config->new_users_prevent_post_url_images);
$this->addScriptOptions('com_kunena.ckeditor_remove_buttons_url_image', KunenaConfig::getInstance()->new_users_prevent_post_url_images);
$editorbuttons = $templatesettings->get('editorButtons');

if (empty($editorbuttons)) {
Expand Down
5 changes: 1 addition & 4 deletions src/site/template/aurelia/layouts/attachment/item/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
\defined('_JEXEC') or die();

use Kunena\Forum\Libraries\Config\KunenaConfig;
use Kunena\Forum\Libraries\Factory\KunenaFactory;

$attachment = $this->attachment;

Expand All @@ -26,14 +25,12 @@
return;
}

$config = KunenaFactory::getConfig();
$config = KunenaConfig::getInstance();

// Load FancyBox library if enabled in configuration
if ($config->lightbox == 1) {
echo $this->subLayout('Widget/Lightbox');

$config = KunenaConfig::getInstance();

$attributesLink = $config->lightbox ? ' data-fancybox="gallery"' : '';
$attributesImg = ' style="max-height:' . (int) $config->imageHeight . 'px;"';

Expand Down
4 changes: 2 additions & 2 deletions src/site/template/aurelia/layouts/topic/row/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
$topic = $this->topic;
$category = $topic->getCategory();
$userTopic = $topic->getUserTopic();
$topicPages = $topic->getPagination(null, KunenaConfig::getInstance()->messagesPerPage, 3);
$config = KunenaConfig::getInstance();
$topicPages = $topic->getPagination(null, $config->messagesPerPage, 3);
$author = $topic->getLastPostAuthor();
$this->ktemplate = KunenaFactory::getTemplate();
$avatar = $author->getAvatarImage($this->ktemplate->params->get('avatarType'), 'thumb');
$config = KunenaConfig::getInstance();
$txt = '';

if ($this->topic->ordering) {
Expand Down
4 changes: 2 additions & 2 deletions src/site/template/aurelia/layouts/topic/row/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

$topic = $this->topic;
$userTopic = $topic->getUserTopic();
$topicPages = $topic->getPagination(null, KunenaConfig::getInstance()->messagesPerPage, 3);
$config = KunenaConfig::getInstance();
$topicPages = $topic->getPagination(null, $config->messagesPerPage, 3);
$author = $topic->getLastPostAuthor();
$this->ktemplate = KunenaFactory::getTemplate();
$avatar = $author->getAvatarImage($this->ktemplate->params->get('avatarType'), 'thumb');
$category = $this->topic->getCategory();
$category = $this->topic->getCategory();
$config = KunenaConfig::getInstance();
$txt = '';

if ($this->topic->ordering) {
Expand Down
4 changes: 2 additions & 2 deletions src/site/template/aurelia/layouts/topic/row/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
use Kunena\Forum\Libraries\Template\KunenaTemplate;

$topic = $this->topic;
$topicPages = $topic->getPagination(null, KunenaConfig::getInstance()->messagesPerPage, 3);
$config = KunenaConfig::getInstance();
$topicPages = $topic->getPagination(null, $config->messagesPerPage, 3);
$userTopic = $topic->getUserTopic();
$author = $topic->getLastPostAuthor();
$this->ktemplate = KunenaFactory::getTemplate();
$avatar = $author->getAvatarImage($this->ktemplate->params->get('avatarType'), 'thumb');
$category = $this->topic->getCategory();
$config = KunenaConfig::getInstance();
$txt = '';

if ($this->topic->ordering) {
Expand Down
Loading