4 * Description: Disable images in group edit menu
6 * Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
8 use Friendica\Core\Addon;
9 use Friendica\Core\PConfig;
11 function group_text_install() {
13 Addon::registerHook('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings');
14 Addon::registerHook('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post');
16 logger("installed group_text");
20 function group_text_uninstall() {
22 Addon::unregisterHook('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings');
23 Addon::unregisterHook('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post');
26 logger("removed group_text");
33 * Callback from the settings post function.
34 * $post contains the $_POST array.
35 * We will make sure we've got a valid user account
36 * and if so set our configuration setting for this person.
40 function group_text_settings_post($a,$post) {
41 if(! local_user() || (! x($_POST,'group_text-submit')))
43 PConfig::set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text']));
45 info( t('Group Text settings updated.') . EOL);
51 * Called from the Addon Setting form.
52 * Add our own settings info to the page.
58 function group_text_settings(&$a,&$s) {
63 /* Add our stylesheet to the page so we can make our settings look nice */
65 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/group_text/group_text.css' . '" media="all" />' . "\r\n";
67 /* Get the current state of our config variable */
69 $enabled = PConfig::get(local_user(),'system','groupedit_image_limit');
70 $checked = (($enabled) ? ' checked="checked" ' : '');
72 /* Add some HTML to the existing form */
74 $s .= '<div class="settings-block">';
75 $s .= '<h3>' . t('Group Text') . '</h3>';
76 $s .= '<div id="group_text-enable-wrapper">';
77 $s .= '<label id="group_text-enable-label" for="group_text-checkbox">' . t('Use a text only (non-image) group selector in the "group edit" menu') . '</label>';
78 $s .= '<input id="group_text-checkbox" type="checkbox" name="group_text" value="1" ' . $checked . '/>';
79 $s .= '</div><div class="clear"></div>';
81 /* provide a submit button */
83 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="group_text-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';