Файл: concrete5.7.5.6/concrete/controllers/single_page/dashboard/system/conversations/editor.php
Строк: 48
<?php
namespace ConcreteControllerSinglePageDashboardSystemConversations;
use ConcreteCorePageControllerDashboardPageController;
use Loader;
use ConcreteCoreRoutingRedirect;
class Editor extends DashboardPageController
{
public function view()
{
$db = Loader::db();
$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;
}
public function success()
{
$this->set('message', t('The active editor has been updated.'));
$this->view();
}
public function error()
{
$this->error->add(t('Invalid editor handle.'));
$this->view();
}
public function save()
{
$this->view();
$active = $this->post('activeEditor');
$db = Loader::db();
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));
$this->redirect('/dashboard/system/conversations/editor', 'success');
}
}