]> git.mxchange.org Git - friendica-addons.git/blob - group_text/group_text.php
Changes:
[friendica-addons.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  * Status: Unsupported
8  * Note: Please use Circle Text instead
9  */
10
11 use Friendica\App;
12 use Friendica\Core\Hook;
13 use Friendica\Core\Logger;
14 use Friendica\Core\Renderer;
15 use Friendica\DI;
16
17 function group_text_install()
18 {
19         Hook::register('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings');
20         Hook::register('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post');
21 }
22
23 /**
24  *
25  * Callback from the settings post function.
26  * $post contains the $_POST array.
27  * We will make sure we've got a valid user account
28  * and if so set our configuration setting for this person.
29  *
30  */
31
32 function group_text_settings_post(array $post)
33 {
34         if (!DI::userSession()->getLocalUserId() || empty($post['group_text-submit'])) {
35                 return;
36         }
37
38         DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'groupedit_image_limit', intval($post['group_text']));
39 }
40
41
42 /**
43  *
44  * Called from the Addon Setting form.
45  * Add our own settings info to the page.
46  *
47  */
48
49 function group_text_settings(array &$data)
50 {
51         if (!DI::userSession()->getLocalUserId()) {
52                 return;
53         }
54
55         $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'groupedit_image_limit');
56
57         $t    = Renderer::getMarkupTemplate('settings.tpl', 'addon/group_text/');
58         $html = Renderer::replaceMacros($t, [
59                 '$enabled' => ['group_text', DI::l10n()->t('Use a text only (non-image) group selector in the "group edit" menu'), $enabled],
60         ]);
61
62         $data = [
63                 'addon' => 'group_text',
64                 'title' => DI::l10n()->t('Group Text'),
65                 'html'  => $html,
66         ];
67 }