4 * Description: Disable images in group edit menu
6 * Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
8 use Friendica\Core\Hook;
9 use Friendica\Core\L10n;
10 use Friendica\Core\Logger;
11 use Friendica\Core\PConfig;
14 function group_text_install() {
16 Hook::register('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings');
17 Hook::register('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post');
19 Logger::log("installed group_text");
23 function group_text_uninstall() {
25 Hook::unregister('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings');
26 Hook::unregister('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post');
29 Logger::log("removed group_text");
36 * Callback from the settings post function.
37 * $post contains the $_POST array.
38 * We will make sure we've got a valid user account
39 * and if so set our configuration setting for this person.
43 function group_text_settings_post($a,$post) {
44 if(! local_user() || empty($_POST['group_text-submit']))
46 PConfig::set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text']));
48 info(L10n::t('Group Text settings updated.') . EOL);
54 * Called from the Addon Setting form.
55 * Add our own settings info to the page.
61 function group_text_settings(&$a,&$s) {
66 /* Add our stylesheet to the page so we can make our settings look nice */
68 DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/group_text/group_text.css' . '" media="all" />' . "\r\n";
70 /* Get the current state of our config variable */
72 $enabled = DI::pConfig()->get(local_user(),'system','groupedit_image_limit');
73 $checked = (($enabled) ? ' checked="checked" ' : '');
75 /* Add some HTML to the existing form */
77 $s .= '<div class="settings-block">';
78 $s .= '<h3>' . L10n::t('Group Text') . '</h3>';
79 $s .= '<div id="group_text-enable-wrapper">';
80 $s .= '<label id="group_text-enable-label" for="group_text-checkbox">' . L10n::t('Use a text only (non-image) group selector in the "group edit" menu') . '</label>';
81 $s .= '<input id="group_text-checkbox" type="checkbox" name="group_text" value="1" ' . $checked . '/>';
82 $s .= '</div><div class="clear"></div>';
84 /* provide a submit button */
86 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="group_text-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';