diff --git a/common.php b/common.php index dde03773..6358f8c8 100644 --- a/common.php +++ b/common.php @@ -27,7 +27,7 @@ session_start(); define('MYAAC', true); define('MYAAC_VERSION', '0.8-dev'); -define('DATABASE_VERSION', 28); +define('DATABASE_VERSION', 29); define('TABLE_PREFIX', 'myaac_'); define('START_TIME', microtime(true)); define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); diff --git a/install/includes/schema.sql b/install/includes/schema.sql index 710c18c1..8c18c624 100644 --- a/install/includes/schema.sql +++ b/install/includes/schema.sql @@ -285,6 +285,7 @@ CREATE TABLE `myaac_pages` `date` INT(11) NOT NULL DEFAULT 0, `player_id` INT(11) NOT NULL DEFAULT 0, `php` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '0 - plain html, 1 - php', + `enable_tinymce` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '1 - enabled, 0 - disabled', `access` TINYINT(2) NOT NULL DEFAULT 0, `hidden` TINYINT(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), diff --git a/system/migrations/29.php b/system/migrations/29.php new file mode 100644 index 00000000..79e3d81d --- /dev/null +++ b/system/migrations/29.php @@ -0,0 +1,5 @@ +hasColumn(TABLE_PREFIX . 'pages', 'enable_tinymce')) { + $db->exec('ALTER TABLE `' . TABLE_PREFIX . 'pages` ADD `enable_tinymce` TINYINT(1) NOT NULL DEFAULT 1 COMMENT \'1 - enabled, 0 - disabled\' AFTER `php`;'); +} diff --git a/system/pages/admin/pages.php b/system/pages/admin/pages.php index 6bb1ae6b..50ae59f4 100644 --- a/system/pages/admin/pages.php +++ b/system/pages/admin/pages.php @@ -21,6 +21,7 @@ $name = $p_title = ''; $groups = new OTS_Groups_List(); $php = false; +$enable_tinymce = true; $access = 0; if (!empty($action)) { @@ -34,6 +35,7 @@ if (!empty($action)) { $p_title = $_REQUEST['title']; $php = isset($_REQUEST['php']) && $_REQUEST['php'] == 1; + $enable_tinymce = isset($_REQUEST['enable_tinymce']) && $_REQUEST['enable_tinymce'] == 1; if ($php) $body = $_REQUEST['body']; else if (isset($_REQUEST['body'])) { @@ -48,10 +50,11 @@ if (!empty($action)) { $player_id = 1; if ($action == 'add') { - if (Pages::add($name, $p_title, $body, $player_id, $php, $access, $errors)) { + if (Pages::add($name, $p_title, $body, $player_id, $php, $enable_tinymce, $access, $errors)) { $name = $p_title = $body = ''; $player_id = $access = 0; $php = false; + $enable_tinymce = true; } } else if ($action == 'delete') { if (Pages::delete($id, $errors)) @@ -63,13 +66,15 @@ if (!empty($action)) { $p_title = $_page['title']; $body = $_page['body']; $php = $_page['php'] == '1'; + $enable_tinymce = $_page['enable_tinymce'] == '1'; $access = $_page['access']; } else { - Pages::update($id, $name, $p_title, $body, $player_id, $php, $access); + Pages::update($id, $name, $p_title, $body, $player_id, $php, $enable_tinymce, $access); $action = $name = $p_title = $body = ''; $player_id = 1; $access = 0; $php = false; + $enable_tinymce = true; } } else if ($action == 'hide') { Pages::toggleHidden($id, $errors); @@ -99,6 +104,7 @@ $twig->display('admin.pages.form.html.twig', array( 'name' => $name, 'title' => $p_title, 'php' => $php, + 'enable_tinymce' => $enable_tinymce, 'body' => isset($body) ? htmlentities($body, ENT_COMPAT, 'UTF-8') : '', 'groups' => $groups->getGroups(), 'access' => $access @@ -120,13 +126,23 @@ class Pages return false; } - static public function add($name, $title, $body, $player_id, $php, $access, &$errors) + static public function add($name, $title, $body, $player_id, $php, $enable_tinymce, $access, &$errors) { global $db; if (isset($name[0]) && isset($title[0]) && isset($body[0]) && $player_id != 0) { $query = $db->select(TABLE_PREFIX . 'pages', array('name' => $name)); if ($query === false) - $db->insert(TABLE_PREFIX . 'pages', array('name' => $name, 'title' => $title, 'body' => $body, 'player_id' => $player_id, 'php' => $php ? '1' : '0', 'access' => $access)); + $db->insert(TABLE_PREFIX . 'pages', + array( + 'name' => $name, + 'title' => $title, + 'body' => $body, + 'player_id' => $player_id, + 'php' => $php ? '1' : '0', + 'enable_tinymce' => $enable_tinymce ? '1' : '0', + 'access' => $access + ) + ); else $errors[] = 'Page with this link already exists.'; } else @@ -135,10 +151,20 @@ class Pages return !count($errors); } - static public function update($id, $name, $title, $body, $player_id, $php, $access) + static public function update($id, $name, $title, $body, $player_id, $php, $enable_tinymce, $access) { global $db; - $db->update(TABLE_PREFIX . 'pages', array('name' => $name, 'title' => $title, 'body' => $body, 'player_id' => $player_id, 'php' => $php ? '1' : '0', 'access' => $access), array('id' => $id)); + $db->update(TABLE_PREFIX . 'pages', + array( + 'name' => $name, + 'title' => $title, + 'body' => $body, + 'player_id' => $player_id, + 'php' => $php ? '1' : '0', + 'enable_tinymce' => $enable_tinymce ? '1' : '0', + 'access' => $access + ), + array('id' => $id)); } static public function delete($id, &$errors) @@ -171,4 +197,4 @@ class Pages } } -?> \ No newline at end of file +?> diff --git a/system/templates/admin.pages.form.html.twig b/system/templates/admin.pages.form.html.twig index 6e54b061..e5b30707 100644 --- a/system/templates/admin.pages.form.html.twig +++ b/system/templates/admin.pages.form.html.twig @@ -33,12 +33,25 @@