Unneeded "info" messages removed
[friendica-addons.git/.git] / group_text / group_text.php
1 <?php
2 /**
3  * Name: Group Text
4  * Description: Disable images in group edit menu
5  * Version: 1.0
6  * Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
7  */
8 use Friendica\Core\Hook;
9 use Friendica\Core\Logger;
10 use Friendica\DI;
11
12 function group_text_install() {
13
14         Hook::register('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings');
15         Hook::register('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post');
16
17         Logger::log("installed group_text");
18 }
19
20
21 function group_text_uninstall() {
22
23         Hook::unregister('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings');
24         Hook::unregister('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post');
25
26
27         Logger::log("removed group_text");
28 }
29
30
31
32 /**
33  *
34  * Callback from the settings post function.
35  * $post contains the $_POST array.
36  * We will make sure we've got a valid user account
37  * and if so set our configuration setting for this person.
38  *
39  */
40
41 function group_text_settings_post($a,$post) {
42         if(! local_user() || empty($_POST['group_text-submit']))
43                 return;
44         DI::pConfig()->set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text']));
45 }
46
47
48 /**
49  *
50  * Called from the Addon Setting form. 
51  * Add our own settings info to the page.
52  *
53  */
54
55
56
57 function group_text_settings(&$a,&$s) {
58
59         if(! local_user())
60                 return;
61
62         /* Add our stylesheet to the page so we can make our settings look nice */
63
64         DI::page()['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . DI::baseUrl()->get() . '/addon/group_text/group_text.css' . '" media="all" />' . "\r\n";
65
66         /* Get the current state of our config variable */
67
68         $enabled = DI::pConfig()->get(local_user(),'system','groupedit_image_limit');
69         $checked = (($enabled) ? ' checked="checked" ' : '');
70
71         /* Add some HTML to the existing form */
72
73         $s .= '<div class="settings-block">';
74         $s .= '<h3>' . DI::l10n()->t('Group Text') . '</h3>';
75         $s .= '<div id="group_text-enable-wrapper">';
76         $s .= '<label id="group_text-enable-label" for="group_text-checkbox">' . DI::l10n()->t('Use a text only (non-image) group selector in the "group edit" menu') . '</label>';
77         $s .= '<input id="group_text-checkbox" type="checkbox" name="group_text" value="1" ' . $checked . '/>';
78         $s .= '</div><div class="clear"></div>';
79
80         /* provide a submit button */
81
82         $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="group_text-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';
83
84 }