]> git.mxchange.org Git - friendica-addons.git/blob - circle_text/group_text.php
Langfilter: Use two letter code for the language / Bluesky: Remove callstack
[friendica-addons.git] / circle_text / group_text.php
1 <?php
2 /**
3  * Name: Circle Text
4  * Description: Disable images in circle edit menu
5  * Version: 1.0
6  * Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
7  */
8
9 use Friendica\Core\Hook;
10 use Friendica\Core\Renderer;
11 use Friendica\DI;
12
13 function circle_text_install()
14 {
15         Hook::register('addon_settings', __FILE__, 'circle_text_settings');
16         Hook::register('addon_settings_post', __FILE__, 'circle_text_settings_post');
17 }
18
19 /**
20  *
21  * Callback from the settings post function.
22  * $post contains the $_POST array.
23  * We will make sure we've got a valid user account
24  * and if so set our configuration setting for this person.
25  *
26  */
27
28 function circle_text_settings_post(array $post)
29 {
30         if (!DI::userSession()->getLocalUserId() || empty($post['circle_text-submit'])) {
31                 return;
32         }
33
34         DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'circle_edit_image_limit', intval($post['circle_text']));
35 }
36
37
38 /**
39  *
40  * Called from the Addon Setting form.
41  * Add our own settings info to the page.
42  *
43  */
44
45 function circle_text_settings(array &$data)
46 {
47         if (!DI::userSession()->getLocalUserId()) {
48                 return;
49         }
50
51         $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'circle_edit_image_limit') ??
52                 DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'groupedit_image_limit');
53
54         $t    = Renderer::getMarkupTemplate('settings.tpl', 'addon/circle_text/');
55         $html = Renderer::replaceMacros($t, [
56                 '$enabled' => ['circle_text', DI::l10n()->t('Use a text only (non-image) circle selector in the "circle edit" menu'), $enabled],
57         ]);
58
59         $data = [
60                 'addon' => 'circle_text',
61                 'title' => DI::l10n()->t('Circle Text'),
62                 'html'  => $html,
63         ];
64 }