myaac/system/pages/admin/notepad.php
slawkens 6c9e09ea73 * moved template menus to database, they're now dynamically loaded
* you can edit them in Admin Panel under 'Menus' option.
* you can also add custom links, like http://google.pl
* removed videos pages, as it can be easily added using custom Menus and Pages with insert Media
* removed bug_report configurable, its now enabled by default
2017-10-24 14:42:23 +02:00

57 lines
1.4 KiB
PHP

<?php
/**
* Notepad
*
* @package MyAAC
* @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC
* @version 0.6.6
* @link http://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Notepad';
$notepad_content = Notepad::get($account_logged->getId());
if(isset($_POST['content']))
{
$_content = html_entity_decode(stripslashes($_POST['content']));
if(!$notepad_content)
Notepad::create($account_logged->getId(), $_content);
else
Notepad::update($account_logged->getId(), $_content);
echo '<div class="success" style="text-align: center;">Saved at ' . date('H:i') . '</div>';
}
else
{
if($notepad_content !== false)
$_content = $notepad_content;
}
echo $twig->render('admin.notepad.html.twig', array('content' => isset($_content) ? $_content : null));
class Notepad
{
static public function get($account_id)
{
global $db;
$query = $db->select(TABLE_PREFIX . 'notepad', array('account_id' => $account_id));
if($query !== false)
return $query['content'];
return false;
}
static public function create($account_id, $content = '')
{
global $db;
$db->insert(TABLE_PREFIX . 'notepad', array('account_id' => $account_id, 'content' => $content));
}
static public function update($account_id, $content = '')
{
global $db;
$db->update(TABLE_PREFIX . 'notepad', array('content' => $content), array('account_id' => $account_id));
}
}