PluginProbe
User Access Manager / 2.1.4
User Access Manager v2.1.4
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.4, at src/Controller/Frontend/AdminOutputControllerTrait.php

101 lines 2.4 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\Access\AccessHandler;
18 use UserAccessManager\Config\MainConfig;
19 use UserAccessManager\Config\WordpressConfig;
20 use UserAccessManager\User\UserHandler;
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 * @var Wordpress
33 */
34 protected $wordpress;
35
36 /**
37 * @var WordpressConfig
38 */
39 protected $wordpressConfig;
40
41 /**
42 * @var MainConfig
43 */
44 protected $mainConfig;
45
46 /**
47 * @var Util
48 */
49 protected $util;
50
51 /**
52 * @var UserHandler
53 */
54 protected $userHandler;
55
56 /**
57 * @var AccessHandler
58 */
59 protected $accessHandler;
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->wordpressConfig->atAdminPanel() === false && $this->mainConfig->blogAdminHint() === true;
69 }
70
71 /**
72 * Returns the admin hint.
73 *
74 * @param string $objectType The object type.
75 * @param integer $objectId The object id we want to check.
76 * @param string $text The text on which we want to append the hint.
77 *
78 * @return string
79 */
80 public function adminOutput($objectType, $objectId, $text = null)
81 {
82 $output = '';
83
84 if ($this->showAdminHint() === true) {
85 $hintText = $this->mainConfig->getBlogAdminHintText();
86
87 if ($text !== null && $this->util->endsWith($text, $hintText) === true) {
88 return $output;
89 }
90
91 if ($this->userHandler->userIsAdmin($this->wordpress->getCurrentUser()->ID) === true
92 && count($this->accessHandler->getUserGroupsForObject($objectType, $objectId)) > 0
93 ) {
94 $output .= $hintText;
95 }
96 }
97
98 return $output;
99 }
100 }
101