]> git.mxchange.org Git - friendica-addons.git/blob - group_text/group_text.php
twitter addon FR translation updated THX kalon33
[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  */
8
9 use Friendica\App;
10 use Friendica\Core\Hook;
11 use Friendica\Core\Logger;
12 use Friendica\Core\Renderer;
13 use Friendica\DI;
14
15 function group_text_install() {
16
17         Hook::register('addon_settings', 'addon/group_text/group_text.php', 'group_text_settings');
18         Hook::register('addon_settings_post', 'addon/group_text/group_text.php', 'group_text_settings_post');
19
20         Logger::notice("installed group_text");
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($a,$post) {
33         if(! local_user() || empty($_POST['group_text-submit']))
34                 return;
35         DI::pConfig()->set(local_user(),'system','groupedit_image_limit',intval($_POST['group_text']));
36 }
37
38
39 /**
40  *
41  * Called from the Addon Setting form. 
42  * Add our own settings info to the page.
43  *
44  */
45
46
47
48 function group_text_settings(App &$a, array &$data)
49 {
50         if (!local_user()) {
51                 return;
52         }
53
54         $enabled = DI::pConfig()->get(local_user(),'system','groupedit_image_limit');
55
56         $t    = Renderer::getMarkupTemplate('settings.tpl', 'addon/group_text/');
57         $html = Renderer::replaceMacros($t, [
58                 '$enabled' => ['group_text', DI::l10n()->t('Use a text only (non-image) group selector in the "group edit" menu'), $enabled],
59         ]);
60
61         $data = [
62                 'addon' => 'group_text',
63                 'title' => DI::l10n()->t('Group Text'),
64                 'html'  => $html,
65         ];
66 }