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 / LoginControllerTrait.php

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

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