Skip to content

Instantly share code, notes, and snippets.

@katzueno
Last active Jan 11, 2016
Embed
What would you like to do?
Quick fix for Dashboard - System and Settings - Conversation - Settings of concrete5.7.5.3

Quick fix of Conversation Setting page of Dashboard in 5.7.5.2 & 5.7.5.3

Read more at https://www.concrete5.org/developers/bugs/5-7-5-3/conversations-bug/

Where you need to change

You need to change the following file.

/concrete/controllers/single_page/dashboard/system/conversations/settings.php

What you need to change

Check it out this DIFF where you need to change.

  • Add use Database; on the first part of the
  • Replace Core::make('Concrete\Core\Database\Connection\Connection'); with Database::connection(); twice.

That's it.

Good luck.


By Katz Ueno (concrete5 Japan, Inc.) http://concrete5.co.jp/en/

<?php
namespace Concrete\Controller\SinglePage\Dashboard\System\Conversations;
use Concrete\Core\Conversation\Conversation;
use Concrete\Core\Page\Controller\DashboardPageController;
use Core;
use Database;
class Settings extends DashboardPageController
{
public function view()
{
$config = Core::make('config');
$helperFile = Core::make('helper/concrete/file');
$fileAccessFileTypes = $config->get('conversations.files.allowed_types');
//is nothing's been defined, display the constant value
if (!$fileAccessFileTypes) {
$fileAccessFileTypes = $helperFile->unserializeUploadFileExtensions($config->get('concrete.upload.extensions'));
} else {
$fileAccessFileTypes = $helperFile->unserializeUploadFileExtensions($fileAccessFileTypes);
}
$this->set('file_access_file_types', $fileAccessFileTypes);
$this->set('maxFileSizeGuest', $config->get('conversations.files.guest.max_size'));
$this->set('maxFileSizeRegistered', $config->get('conversations.files.registered.max_size'));
$this->set('maxFilesGuest', $config->get('conversations.files.guest.max'));
$this->set('maxFilesRegistered', $config->get('conversations.files.registered.max'));
$this->set('fileExtensions', implode(',', $fileAccessFileTypes));
$this->set('attachmentsEnabled', intval($config->get('conversations.attachments_enabled')));
$this->loadEditors();
$this->set('notificationUsers', Conversation::getDefaultSubscribedUsers());
$this->set('subscriptionEnabled', intval($config->get('conversations.subscription_enabled')));
}
protected function loadEditors()
{
$db = Database::connection();
$q = $db->executeQuery('SELECT * FROM ConversationEditors');
$editors = array();
$active = false;
while ($row = $q->fetch()) {
if ($row['cnvEditorIsActive'] == 1) {
$active = $row['cnvEditorHandle'];
}
$editors[$row['cnvEditorHandle']] = tc('ConversationEditorName', $row['cnvEditorName']);
}
$q->closeCursor();
if (!$active) {
$active = array_pop(array_reverse($editors));
}
$this->set('active', $active);
$this->set('editors', $editors);
$this->editors = $editors;
}
protected function saveEditors()
{
$this->loadEditors();
$active = $this->post('activeEditor');
$db = Database::connection();
if (!isset($this->editors[$active])) {
$this->redirect('/dashboard/system/conversations/editor/error');
return;
}
$db->executeQuery('UPDATE ConversationEditors SET cnvEditorIsActive=0');
$db->executeQuery('UPDATE ConversationEditors SET cnvEditorIsActive=1 WHERE cnvEditorHandle=?', array($active));
}
public function success()
{
$this->view();
$this->set('message', t('Updated conversations settings.'));
}
public function save()
{
$config = Core::make('config');
if (Core::make('token')->validate('conversations.settings.save')) {
$helper_file = Core::make('helper/concrete/file');
$config->save('conversations.files.guest.max_size', intval($this->post('maxFileSizeGuest')));
$config->save('conversations.files.registered.max_size', intval($this->post('maxFileSizeRegistered')));
$config->save('conversations.files.guest.max', intval($this->post('maxFilesGuest')));
$config->save('conversations.files.registered.max', intval($this->post('maxFilesRegistered')));
$config->save('conversations.attachments_enabled', !!$this->post('attachmentsEnabled'));
$config->save('conversations.subscription_enabled', !!$this->post('subscriptionEnabled'));
$users = array();
if (is_array($this->post('defaultUsers'))) {
foreach ($this->post('defaultUsers') as $uID) {
$ui = \UserInfo::getByID($uID);
if (is_object($ui)) {
$users[] = $ui;
}
}
}
Conversation::setDefaultSubscribedUsers($users);
if ($this->post('fileExtensions')) {
$types = preg_split('{,}', $this->post('fileExtensions'), null, PREG_SPLIT_NO_EMPTY);
$types = $helper_file->serializeUploadFileExtensions($types);
$config->save('conversations.files.allowed_types', $types);
}
$this->saveEditors();
$this->success();
} else {
$this->error->add('Invalid Token.');
$this->view();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment