4 * Name: New Member Widget
5 * 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.
7 * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
10 require_once('include/bbcode.php');
12 use Friendica\Core\Config;
14 function newmemberwidget_install () {
15 register_hook( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
16 logger('newmemberwidget installed');
18 function newmemberwidget_uninstall () {
19 unregister_hook( '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>'.t('New Member').'</h3>'.EOL;
26 $t .= '<a href="newmember" id="newmemberwidget-tips">' . 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">'.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">'.t('Local Support Forum').'</a><br />'.EOL;
31 $ft = Config::get('newmemberwidget','freetext');
33 $t .= '<p>'.bbcode(trim($ft)).'</p>';
34 $t .= '</div><div class="clear"></div>';
35 $a->page['aside'] = $t . $a->page['aside'];
39 function newmemberwidget_plugin_admin_post( &$a ) {
40 $ft = ((x($_POST, 'freetext')) ? trim($_POST['freetext']) : "");
41 $lsn = ((x($_POST, 'localsupportname')) ? notags(trim($_POST['localsupportname'])) : "");
42 $gs = intval($_POST['linkglobalsupport']);
43 $ls = intval($_POST['linklocalsupport']);
44 Config::set ( 'newmemberwidget', 'freetext', trim($ft));
45 Config::set ( 'newmemberwidget', 'linkglobalsupport', $gs);
46 Config::set ( 'newmemberwidget', 'linklocalsupport', $ls);
47 Config::set ( 'newmemberwidget', 'localsupport', trim($lsn));
50 function newmemberwidget_plugin_admin(&$a, &$o){
51 $t = get_markup_template('admin.tpl','addon/newmemberwidget');
52 $o = replace_macros($t, array(
53 '$submit' => t('Save Settings'),
54 '$freetext' => array( "freetext", t("Message"), Config::get( "newmemberwidget", "freetext" ), t("Your message for new members. You can use bbcode here.")),
55 '$linkglobalsupport' => array( "linkglobalsupport", t('Add a link to global support forum'), Config::get( 'newmemberwidget', 'linkglobalsupport'), t('Should a link to the global support forum be displayed?')." (<a href='https://forum.friendi.ca/profile/helpers'>@helpers</a>)"),
56 '$linklocalsupport' => array( "linklocalsupport", t('Add a link to the local support forum'), Config::get( 'newmemberwidget', 'linklocalsupport'), t('If you have a local support forum and want to have a link displayed in the widget, check this box.')),
57 '$localsupportname' => array( "localsupportname", t('Name of the local support group'), Config::get( 'newmemberwidget', 'localsupport'), t('If you checked the above, specify the <em>nickname</em> of the local support group here (i.e. helpers)')),