PluginProbe
User Access Manager / 2.1.9
User Access Manager v2.1.9
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
user-access-manager / src / Controller / Frontend / AdminOutputControllerTrait.php

AdminOutputControllerTrait.php in User Access Manager 2.1.9, at src/Controller/Frontend/AdminOutputControllerTrait.php

102 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * FrontendAdminOutputControllerTrait.php
4 *
5 * The FrontendTermController trait file.
6 *
7 * PHP versions 5
8 *
9 * @author Alexander Schneider <alexanderschneider85@gmail.com>
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 */
15 namespace UserAccessManager\Controller\Frontend;
16
17 use UserAccessManager\Config\MainConfig;
18 use UserAccessManager\Config\WordpressConfig;
19 use UserAccessManager\User\UserHandler;
20 use UserAccessManager\UserGroup\UserGroupHandler;
21 use UserAccessManager\Util\Util;
22 use UserAccessManager\Wrapper\Wordpress;
23
24 /**
25 * Trait FrontendAdminOutputControllerTrait
26 *
27 * @package UserAccessManager\Controller
28 */
29 trait AdminOutputControllerTrait
30 {
31 /**
32 * @return Wordpress
33 */
34 abstract protected function getWordpress();
35
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()
67 {
68 return $this->getWordpressConfig()->atAdminPanel() === false
69 && $this->getMainConfig()->blogAdminHint() === true;
70 }
71
72 /**
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
80 */
81 public function adminOutput($objectType, $objectId, $text = null)
82 {
83 $output = '';
84
85 if ($this->showAdminHint() === true) {
86 $hintText = $this->getMainConfig()->getBlogAdminHintText();
87
88 if ($text !== null && $this->getUtil()->endsWith($text, $hintText) === true) {
89 return $output;
90 }
91
92 if ($this->getUserHandler()->userIsAdmin($this->getWordpress()->getCurrentUser()->ID) === true
93 && count($this->getUserGroupHandler()->getUserGroupsForObject($objectType, $objectId)) > 0
94 ) {
95 $output .= $hintText;
96 }
97 }
98
99 return $output;
100 }
101 }
102