From 3733a80c1de0e3bf69b91f1dc7ee217fd3e29fe5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 22 Sep 2024 17:24:28 +0200 Subject: notes: make sure we set App::$profile_uid in the module - issue #1865 and minor code cleanup --- Zotlabs/Module/Notes.php | 30 ++++++++++++++++++------------ Zotlabs/Widget/Notes.php | 9 ++++++--- 2 files changed, 24 insertions(+), 15 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Notes.php b/Zotlabs/Module/Notes.php index 2fd719f25..ba693e4f2 100644 --- a/Zotlabs/Module/Notes.php +++ b/Zotlabs/Module/Notes.php @@ -13,31 +13,34 @@ class Notes extends Controller { function post() { - if(! local_channel()) - return EMPTY_STR; + if(!local_channel()) { + return; + } - if(! Apps::system_app_installed(local_channel(), 'Notes')) - return EMPTY_STR; + if(!Apps::system_app_installed(local_channel(), 'Notes')) { + return; + } $ret = [ 'success' => false, 'html' => '' ]; - - if(array_key_exists('note_text',$_REQUEST)) { + 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); + 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); + + set_pconfig(local_channel(), 'notes', 'text', $body); $ret['html'] = bbcode($body, ['tryoembed' => false]); $ret['success'] = true; @@ -55,8 +58,9 @@ class Notes extends Controller { } function get() { - if(! local_channel()) + if(!local_channel()) { return EMPTY_STR; + } if(! Apps::system_app_installed(local_channel(), 'Notes')) { //Do not display any associated widgets at this point @@ -65,6 +69,8 @@ class Notes extends Controller { return Apps::app_render($papp, 'module'); } + App::$profile_uid = local_channel(); + $w = new \Zotlabs\Widget\Notes; $arr = ['app' => true]; diff --git a/Zotlabs/Widget/Notes.php b/Zotlabs/Widget/Notes.php index 836159edd..be4ec64a6 100644 --- a/Zotlabs/Widget/Notes.php +++ b/Zotlabs/Widget/Notes.php @@ -16,14 +16,17 @@ use Zotlabs\Lib\Apps; class Notes { function widget($arr) { - if(! local_channel()) + if(!local_channel()) { return EMPTY_STR; + } - if(App::$profile_uid !== local_channel()) + if (App::$profile_uid !== local_channel()) { return EMPTY_STR; + } - if(! Apps::system_app_installed(local_channel(), 'Notes')) + if(!Apps::system_app_installed(local_channel(), 'Notes')) { return EMPTY_STR; + } $text = get_pconfig(local_channel(),'notes','text'); -- cgit v1.2.3