streams/Zotlabs/Module/Notes.php

64 lines
1.4 KiB
PHP
Raw Normal View History

2016-04-19 03:38:38 +00:00
<?php
namespace Zotlabs\Module; /** @file */
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
2019-05-08 02:40:49 +00:00
class Notes extends Controller {
2016-04-19 03:38:38 +00:00
function init() {
if(! local_channel())
return;
$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');
if($old_text)
set_pconfig(local_channel(),'notes','text.bak',$old_text);
}
set_pconfig(local_channel(),'notes','text',$body);
2019-06-25 00:35:12 +00:00
2016-04-19 03:38:38 +00:00
2019-06-25 00:35:12 +00:00
// push updates to channel clones
2016-04-19 03:38:38 +00:00
2019-06-25 00:35:12 +00:00
if((argc() > 1) && (argv(1) === 'sync')) {
Libsync::build_sync_packet();
}
2016-04-19 03:38:38 +00:00
2019-06-25 00:35:12 +00:00
logger('notes saved.', LOGGER_DEBUG);
json_return_and_die($ret);
2016-04-19 03:38:38 +00:00
2019-06-25 00:35:12 +00:00
}
2016-04-19 03:38:38 +00:00
}
2019-06-25 00:35:12 +00:00
function get() {
$desc = t('This app allows you to create private notes for your personal use.');
$text = '<div class="section-content-info-wrapper">' . $desc . '</div>';
if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Notes'))) {
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
}