3 * Name: New Member Widget
4 * Description: Adds a widget for new members into the sidebar of the network page. The widget will be displayed for the 1st 14days of a account existance and contains a link to the new member page and a free-form text the admin can define.
6 * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
9 use Friendica\Content\Text\BBCode;
10 use Friendica\Core\Addon;
11 use Friendica\Core\Config;
12 use Friendica\Core\L10n;
14 function newmemberwidget_install () {
15 Addon::registerHook( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
16 logger('newmemberwidget installed');
18 function newmemberwidget_uninstall () {
19 Addon::unregisterHook( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
22 function newmemberwidget_network_mod_init ( $a, $b) {
23 if (x($_SESSION['new_member'])) {
24 $t = '<div id="newmember_widget" class="widget">'.EOL;
25 $t .= '<h3>'.L10n::t('New Member').'</h3>'.EOL;
26 $t .= '<a href="newmember" id="newmemberwidget-tips">' . L10n::t('Tips for New Members') . '</a><br />'.EOL;
27 if (Config::get('newmemberwidget','linkglobalsupport')==1)
28 $t .= '<a href="https://forum.friendi.ca/profile/helpers" target="_new">'.L10n::t('Global Support Forum').'</a><br />'.EOL;
29 if (Config::get('newmemberwidget','linklocalsupport')==1)
30 $t .= '<a href="'.$a->get_baseurl().'/profile/'.Config::get('newmemberwidget','localsupport').'" target="_new">'.L10n::t('Local Support Forum').'</a><br />'.EOL;
31 $ft = Config::get('newmemberwidget','freetext');
33 $t .= '<p>'.BBCode::convert(trim($ft)).'</p>';
34 $t .= '</div><div class="clear"></div>';
35 $a->page['aside'] = $t . $a->page['aside'];
39 function newmemberwidget_addon_admin_post(&$a)
41 $ft = ((x($_POST, 'freetext')) ? trim($_POST['freetext']) : "");
42 $lsn = ((x($_POST, 'localsupportname')) ? notags(trim($_POST['localsupportname'])) : "");
43 $gs = intval($_POST['linkglobalsupport']);
44 $ls = intval($_POST['linklocalsupport']);
45 Config::set('newmemberwidget', 'freetext', trim($ft));
46 Config::set('newmemberwidget', 'linkglobalsupport', $gs);
47 Config::set('newmemberwidget', 'linklocalsupport', $ls);
48 Config::set('newmemberwidget', 'localsupport', trim($lsn));
51 function newmemberwidget_addon_admin(&$a, &$o)
53 $t = get_markup_template('admin.tpl', 'addon/newmemberwidget');
54 $o = replace_macros($t, [
55 '$submit' => L10n::t('Save Settings'),
56 '$freetext' => [ "freetext", L10n::t("Message"), Config::get("newmemberwidget", "freetext"), L10n::t("Your message for new members. You can use bbcode here.")],
57 '$linkglobalsupport' => [ "linkglobalsupport", L10n::t('Add a link to global support forum'), Config::get('newmemberwidget', 'linkglobalsupport'), L10n::t('Should a link to the global support forum be displayed?')." (<a href='https://forum.friendi.ca/profile/helpers'>@helpers</a>)"],
58 '$linklocalsupport' => [ "linklocalsupport", L10n::t('Add a link to the local support forum'), Config::get('newmemberwidget', 'linklocalsupport'), L10n::t('If you have a local support forum and want to have a link displayed in the widget, check this box.')],
59 '$localsupportname' => [ "localsupportname", L10n::t('Name of the local support group'), Config::get('newmemberwidget', 'localsupport'), L10n::t('If you checked the above, specify the <em>nickname</em> of the local support group here (i.e. helpers)')],