PluginProbe
User Access Manager / 2.1.11
User Access Manager v2.1.11
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Controller/Frontend/AdminOutputControllerTrait.php +66 -16 2.3.17 → 2.1.11 View file →
@@ -1,8 +1,18 @@
1 1 <?php
2 -
3 -declare(strict_types=1);
4 -
2 +/**
3 + * FrontendAdminOutputControllerTrait.php
4 + *
5 + * The FrontendTermController trait file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <[email protected]>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
5 15 namespace UserAccessManager\Controller\Frontend;
6 16
7 17 use UserAccessManager\Config\MainConfig;
8 18 use UserAccessManager\Config\WordpressConfig;
@@ -7,22 +17,54 @@
7 17 use UserAccessManager\Config\MainConfig;
8 18 use UserAccessManager\Config\WordpressConfig;
9 19 use UserAccessManager\User\UserHandler;
10 20 use UserAccessManager\UserGroup\UserGroupHandler;
11 -use UserAccessManager\UserGroup\UserGroupTypeException;
12 21 use UserAccessManager\Util\Util;
13 22 use UserAccessManager\Wrapper\Wordpress;
14 23
24 +/**
25 + * Trait FrontendAdminOutputControllerTrait
26 + *
27 + * @package UserAccessManager\Controller
28 + */
15 29 trait AdminOutputControllerTrait
16 30 {
17 - abstract protected function getWordpress(): Wordpress;
18 - abstract protected function getWordpressConfig(): WordpressConfig;
19 - abstract protected function getMainConfig(): MainConfig;
20 - abstract protected function getUtil(): Util;
21 - abstract protected function getUserHandler(): UserHandler;
22 - abstract protected function getUserGroupHandler(): UserGroupHandler;
31 + /**
32 + * @return Wordpress
33 + */
34 + abstract protected function getWordpress();
23 35
24 - private function showAdminHint(): bool
36 + /**
37 + * @return WordpressConfig
38 + */
39 + abstract protected function getWordpressConfig();
40 +
41 + /**
42 + * @return MainConfig
43 + */
44 + abstract protected function getMainConfig();
45 +
46 + /**
47 + * @return Util
48 + */
49 + abstract protected function getUtil();
50 +
51 + /**
52 + * @return UserHandler
53 + */
54 + abstract protected function getUserHandler();
55 +
56 + /**
57 + * @return UserGroupHandler
58 + */
59 + abstract protected function getUserGroupHandler();
60 +
61 + /**
62 + * Returns true if the hint text should be shown.
63 + *
64 + * @return bool
65 + */
66 + private function showAdminHint()
25 67 {
26 68 return $this->getWordpressConfig()->atAdminPanel() === false
27 69 && $this->getMainConfig()->blogAdminHint() === true;
28 70 }
@@ -27,25 +69,33 @@
27 69 && $this->getMainConfig()->blogAdminHint() === true;
28 70 }
29 71
30 72 /**
31 - * @throws UserGroupTypeException
73 + * Returns the admin hint.
74 + *
75 + * @param string $objectType The object type.
76 + * @param integer $objectId The object id we want to check.
77 + * @param string $text The text on which we want to append the hint.
78 + *
79 + * @return string
32 80 */
33 - public function adminOutput(string $objectType, int|string|null $objectId, $text = null): string
81 + public function adminOutput($objectType, $objectId, $text = null)
34 82 {
83 + $output = '';
84 +
35 85 if ($this->showAdminHint() === true) {
36 86 $hintText = $this->getMainConfig()->getBlogAdminHintText();
37 87
38 88 if ($text !== null && $this->getUtil()->endsWith($text, $hintText) === true) {
39 - return '';
89 + return $output;
40 90 }
41 91
42 92 if ($this->getUserHandler()->userIsAdmin($this->getWordpress()->getCurrentUser()->ID) === true
43 93 && count($this->getUserGroupHandler()->getUserGroupsForObject($objectType, $objectId)) > 0
44 94 ) {
45 - return $hintText;
95 + $output .= $hintText;
46 96 }
47 97 }
48 98
49 - return '';
99 + return $output;
50 100 }
51 101 }