X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=gnot%2Fgnot.php;h=8420ffe498e38addfd097ba5d1d84b9a8b61519b;hb=92cf2ce0699c11e1c5f1c3e8a20adebcd4ebb27b;hp=bbdf9d80ebae83e6db5a175e8f1d278986d2470b;hpb=be1342fe5dee55f30f4c83d2da5cdc4f5bc46b16;p=friendica-addons.git diff --git a/gnot/gnot.php b/gnot/gnot.php index bbdf9d80..8420ffe4 100644 --- a/gnot/gnot.php +++ b/gnot/gnot.php @@ -7,31 +7,21 @@ * * */ - -use Friendica\Core\PConfig; +use Friendica\Core\Hook; +use Friendica\Core\Logger; +use Friendica\Core\Renderer; +use Friendica\DI; +use Friendica\Model\Notify\Type; function gnot_install() { - register_hook('plugin_settings', 'addon/gnot/gnot.php', 'gnot_settings'); - register_hook('plugin_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post'); - register_hook('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail'); - - logger("installed gnot"); -} - - -function gnot_uninstall() { - - unregister_hook('plugin_settings', 'addon/gnot/gnot.php', 'gnot_settings'); - unregister_hook('plugin_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post'); - unregister_hook('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail'); - + Hook::register('addon_settings', 'addon/gnot/gnot.php', 'gnot_settings'); + Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post'); + Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail'); - logger("removed gnot"); + Logger::log("installed gnot"); } - - /** * * Callback from the settings post function. @@ -42,17 +32,16 @@ function gnot_uninstall() { */ function gnot_settings_post($a,$post) { - if(! local_user() || (! x($_POST,'gnot-submit'))) + if(! local_user() || empty($_POST['gnot-submit'])) return; - PConfig::set(local_user(),'gnot','enable',intval($_POST['gnot'])); - info( t('Gnot settings updated.') . EOL); + DI::pConfig()->set(local_user(),'gnot','enable',intval($_POST['gnot'])); } /** * - * Called from the Plugin Setting form. + * Called from the Addon Setting form. * Add our own settings info to the page. * */ @@ -66,35 +55,30 @@ function gnot_settings(&$a,&$s) { /* Add our stylesheet to the page so we can make our settings look nice */ - $a->page['htmlhead'] .= '' . "\r\n"; + DI::page()['htmlhead'] .= '' . "\r\n"; /* Get the current state of our config variable */ - $gnot = intval(PConfig::get(local_user(),'gnot','enable')); + $gnot = intval(DI::pConfig()->get(local_user(),'gnot','enable')); $gnot_checked = (($gnot) ? ' checked="checked" ' : '' ); + $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/gnot/'); /* Add some HTML to the existing form */ - $s .= '