streams/mod/notes.php

35 lines
810 B
PHP
Raw Normal View History

2013-12-09 23:27:46 +00:00
<?php /** @file */
function notes_init(&$a) {
2014-06-05 04:02:57 +00:00
2015-01-29 04:56:04 +00:00
if(! local_channel())
2013-12-09 23:27:46 +00:00
return;
$ret = array('success' => true);
if(array_key_exists('note_text',$_REQUEST)) {
2013-12-09 23:27:46 +00:00
$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);
}
2015-01-29 04:56:04 +00:00
set_pconfig(local_channel(),'notes','text',$body);
2013-12-09 23:27:46 +00:00
}
// push updates to channel clones
if((argc() > 1) && (argv(1) === 'sync')) {
require_once('include/zot.php');
build_sync_packet();
}
2014-06-05 04:02:57 +00:00
logger('notes saved.', LOGGER_DEBUG);
2013-12-09 23:27:46 +00:00
json_return_and_die($ret);
2013-12-11 10:25:20 +00:00
}