PluginProbe
User Access Manager / 2.1.6
User Access Manager v2.1.6
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 / LoginControllerTrait.php

LoginControllerTrait.php in User Access Manager 2.1.6, at src/Controller/Frontend/LoginControllerTrait.php

139 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * LoginControllerTrait.php
4 *
5 * The LoginControllerTrait 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\Controller\BaseControllerTrait;
18 use UserAccessManager\Wrapper\Wordpress;
19
20 /**
21 * Trait LoginControllerTrait
22 *
23 * @package UserAccessManager\Controller
24 */
25 trait LoginControllerTrait
26 {
27 /**
28 * @return Wordpress
29 */
30 abstract protected function getWordpress();
31
32 /**
33 * @return string
34 */
35 abstract public function getRequestUrl();
36
37 /**
38 * @param string $name
39 * @param mixed $default
40 *
41 * @return mixed
42 */
43 abstract public function getRequestParameter($name, $default = null);
44
45 /**
46 * Returns the user login name.
47 *
48 * @return string
49 */
50 public function getUserLogin()
51 {
52 $userLogin = $this->getRequestParameter('log');
53 return $this->getWordpress()->escHtml(stripslashes($userLogin));
54 }
55
56 /**
57 * Returns true if the user is logged in.
58 *
59 * @return bool
60 */
61 public function isUserLoggedIn()
62 {
63 return $this->getWordpress()->isUserLoggedIn();
64 }
65
66 /**
67 * Returns the user name of the current user
68 *
69 * @return string
70 */
71 public function getCurrentUserName()
72 {
73 return $this->getWordpress()->getCurrentUser()->display_name;
74 }
75
76 /**
77 * Returns the login url.
78 *
79 * @return string
80 */
81 public function getLoginUrl()
82 {
83 return $this->getWordpress()->wpLoginUrl($this->getRequestUrl());
84 }
85
86 /**
87 * Returns the logout url.
88 *
89 * @return string
90 */
91 public function getLogoutUrl()
92 {
93 return $this->getWordpress()->wpLogoutUrl($this->getRequestUrl());
94 }
95
96
97 /**
98 * Returns the registration url.
99 *
100 * @return string
101 */
102 public function getRegistrationUrl()
103 {
104 return $this->getWordpress()->wpRegistrationUrl();
105 }
106
107 /**
108 * Returns the lost password url.
109 *
110 * @return string
111 */
112 public function getLostPasswordUrl()
113 {
114 return $this->getWordpress()->wpLostPasswordUrl($this->getRequestUrl());
115 }
116
117 /**
118 * Checks if we allowed show the login form.
119 *
120 * @return bool
121 */
122 public function showLoginForm()
123 {
124 return $this->getWordpress()->isSingle() === true || $this->getWordpress()->isPage() === true;
125 }
126
127 /**
128 * Returns the login redirect url.
129 *
130 * @return mixed
131 */
132 public function getRedirectLoginUrl()
133 {
134 $loginUrl = $this->getWordpress()->getBlogInfo('wpurl')
135 .'/wp-login.php?redirect_to='.urlencode($_SERVER['REQUEST_URI']);
136 return $this->getWordpress()->applyFilters('uam_login_url', $loginUrl);
137 }
138 }
139