X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=newmemberwidget%2Fnewmemberwidget.php;h=90f0c38da462b5e9a694288da048ec7ff42d0c4f;hb=76ecff195f99c428d437de826c05034e5b53fd1f;hp=04ca86ccf84ff6ad4955e06f5db55bd60f903bac;hpb=2275f7e32797949265104e1aec1913a377dd8e37;p=friendica-addons.git diff --git a/newmemberwidget/newmemberwidget.php b/newmemberwidget/newmemberwidget.php index 04ca86cc..90f0c38d 100644 --- a/newmemberwidget/newmemberwidget.php +++ b/newmemberwidget/newmemberwidget.php @@ -1,58 +1,71 @@ ***/ -require_once('include/bbcode.php'); +use Friendica\Content\Text\BBCode; +use Friendica\Core\Hook; +use Friendica\Core\Logger; +use Friendica\Core\Renderer; +use Friendica\DI; +use Friendica\Util\Strings; -function newmemberwidget_install () { - register_hook( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init'); - logger('newmemberwidget installed'); -} -function newmemberwidget_uninstall () { - unregister_hook( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init'); +function newmemberwidget_install() +{ + Hook::register( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init'); + Logger::log('newmemberwidget installed'); } -function newmemberwidget_network_mod_init ( $a, $b) { - if (x($_SESSION['new_member'])) { +function newmemberwidget_network_mod_init ($a, $b) +{ + if (empty($_SESSION['new_member'])) { + return; + } + $t = '
'; - $a->page['aside'] = $t . $a->page['aside']; - } + DI::page()['aside'] = $t . DI::page()['aside']; } -function newmemberwidget_plugin_admin_post( &$a ) { - $ft = ((x($_POST, 'freetext')) ? trim($_POST['freetext']) : ""); - $lsn = ((x($_POST, 'localsupportname')) ? notags(trim($_POST['localsupportname'])) : ""); - $gs = intval($_POST['linkglobalsupport']); - $ls = intval($_POST['linklocalsupport']); - set_config ( 'newmemberwidget', 'freetext', trim($ft)); - set_config ( 'newmemberwidget', 'linkglobalsupport', $gs); - set_config ( 'newmemberwidget', 'linklocalsupport', $ls); - set_config ( 'newmemberwidget', 'localsupport', trim($lsn)); +function newmemberwidget_addon_admin_post(&$a) +{ + $ft = (!empty($_POST['freetext']) ? trim($_POST['freetext']) : ""); + $lsn = (!empty($_POST['localsupportname']) ? Strings::escapeTags(trim($_POST['localsupportname'])) : ""); + $gs = intval($_POST['linkglobalsupport']); + $ls = intval($_POST['linklocalsupport']); + DI::config()->set('newmemberwidget', 'freetext', trim($ft)); + DI::config()->set('newmemberwidget', 'linkglobalsupport', $gs); + DI::config()->set('newmemberwidget', 'linklocalsupport', $ls); + DI::config()->set('newmemberwidget', 'localsupport', trim($lsn)); } -function newmemberwidget_plugin_admin(&$a, &$o){ - $t = get_markup_template('admin.tpl','addon/newmemberwidget'); - $o = replace_macros($t, array( - '$submit' => t('Save Settings'), - '$freetext' => array( "freetext", t("Message"), get_config( "newmemberwidget", "freetext" ), t("Your message for new members. You can use bbcode here.")), - '$linkglobalsupport' => array( "linkglobalsupport", t('Add a link to global support forum'), get_config( 'newmemberwidget', 'linkglobalsupport'), t('Should a link to the global support forum be displayed?')." (@helpers)"), - '$linklocalsupport' => array( "linklocalsupport", t('Add a link to the local support forum'), get_config( 'newmemberwidget', 'linklocalsupport'), t('If you have a local support forum and wand to have a link displayed in the widget, check this box.')), - '$localsupportname' => array( "localsupportname", t('Name of the local support group'), get_config( 'newmemberwidget', 'localsupport'), t('If you checked the above, specify the nickname of the local support group here (i.e. helpers)')), - )); +function newmemberwidget_addon_admin(&$a, &$o) +{ + $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/newmemberwidget'); + $o = Renderer::replaceMacros($t, [ + '$submit' => DI::l10n()->t('Save Settings'), + '$freetext' => [ "freetext", DI::l10n()->t("Message"), DI::config()->get("newmemberwidget", "freetext"), DI::l10n()->t("Your message for new members. You can use bbcode here.")], + '$linkglobalsupport' => [ "linkglobalsupport", DI::l10n()->t('Add a link to global support forum'), DI::config()->get('newmemberwidget', 'linkglobalsupport'), DI::l10n()->t('Should a link to the global support forum be displayed?')." (@helpers)"], + '$linklocalsupport' => [ "linklocalsupport", DI::l10n()->t('Add a link to the local support forum'), DI::config()->get('newmemberwidget', 'linklocalsupport'), DI::l10n()->t('If you have a local support forum and want to have a link displayed in the widget, check this box.')], + '$localsupportname' => [ "localsupportname", DI::l10n()->t('Name of the local support group'), DI::config()->get('newmemberwidget', 'localsupport'), DI::l10n()->t('If you checked the above, specify the nickname of the local support group here (i.e. helpers)')], + ]); } -