2016-04-19 03:38:38 +00:00
|
|
|
<?php
|
2021-12-03 03:01:39 +00:00
|
|
|
|
|
|
|
namespace Zotlabs\Module;
|
|
|
|
|
|
|
|
/** @file */
|
2016-04-19 03:38:38 +00:00
|
|
|
|
2018-06-05 01:40:11 +00:00
|
|
|
use Zotlabs\Lib\Libsync;
|
2019-05-08 02:40:49 +00:00
|
|
|
use Zotlabs\Web\Controller;
|
2019-06-25 00:35:12 +00:00
|
|
|
use Zotlabs\Lib\Apps;
|
2016-04-19 03:38:38 +00:00
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
class Notes extends Controller
|
|
|
|
{
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
if (!local_channel()) {
|
2021-12-02 23:02:31 +00:00
|
|
|
return;
|
2021-12-03 03:01:39 +00:00
|
|
|
}
|
2021-12-02 23:02:31 +00:00
|
|
|
|
|
|
|
$ret = array('success' => true);
|
|
|
|
if (array_key_exists('note_text', $_REQUEST)) {
|
|
|
|
$body = escape_tags($_REQUEST['note_text']);
|
|
|
|
|
|
|
|
// I've had my notes vanish into thin air twice in four years.
|
|
|
|
// Provide a backup copy if there were contents previously
|
|
|
|
// and there are none being saved now.
|
|
|
|
|
|
|
|
if (!$body) {
|
|
|
|
$old_text = get_pconfig(local_channel(), 'notes', 'text');
|
2021-12-03 03:01:39 +00:00
|
|
|
if ($old_text) {
|
2021-12-02 23:02:31 +00:00
|
|
|
set_pconfig(local_channel(), 'notes', 'text.bak', $old_text);
|
2021-12-03 03:01:39 +00:00
|
|
|
}
|
2021-12-02 23:02:31 +00:00
|
|
|
}
|
|
|
|
set_pconfig(local_channel(), 'notes', 'text', $body);
|
|
|
|
|
|
|
|
|
|
|
|
// push updates to channel clones
|
|
|
|
|
|
|
|
if ((argc() > 1) && (argv(1) === 'sync')) {
|
|
|
|
Libsync::build_sync_packet();
|
|
|
|
}
|
|
|
|
|
|
|
|
logger('notes saved.', LOGGER_DEBUG);
|
|
|
|
json_return_and_die($ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function get()
|
|
|
|
{
|
2019-06-25 00:35:12 +00:00
|
|
|
|
|
|
|
$desc = t('This app allows you to create private notes for your personal use.');
|
|
|
|
|
|
|
|
$text = '<div class="section-content-info-wrapper">' . $desc . '</div>';
|
|
|
|
|
2021-12-02 23:02:31 +00:00
|
|
|
if (!(local_channel() && Apps::system_app_installed(local_channel(), 'Notes'))) {
|
2019-06-25 00:35:12 +00:00
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
2020-02-13 05:36:21 +00:00
|
|
|
$desc = t('This app is installed. The Notes tool can be found on your stream page.');
|
2019-06-25 00:35:12 +00:00
|
|
|
|
|
|
|
$text = '<div class="section-content-info-wrapper">' . $desc . '</div>';
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
}
|
2016-04-19 03:38:38 +00:00
|
|
|
}
|