@@ -31,7 +31,6 @@ |
||
31 | 31 | /** |
32 | 32 | * Recursively builds parents path to passed resource |
33 | 33 | * |
34 | - * @param ACL_Resource|bool $page |
|
35 | 34 | * @param array $return |
36 | 35 | * @return array |
37 | 36 | */ |
@@ -3,61 +3,61 @@ |
||
3 | 3 | class ACL_Resources extends Records |
4 | 4 | { |
5 | 5 | |
6 | - protected $_sortOn = "name"; |
|
7 | - |
|
8 | - public function findAll() |
|
9 | - { |
|
10 | - if (!$this->getRegistry()->exists("all")) { |
|
11 | - $resources = parent::findAll(); |
|
12 | - $this->buildTree($resources); |
|
13 | - } |
|
14 | - |
|
15 | - return $this->getRegistry()->get('all'); |
|
16 | - } |
|
17 | - |
|
18 | - public function buildTree($resources = array()) |
|
19 | - { |
|
20 | - if ($resources) { |
|
21 | - /* @var $resource ACL_Resource */ |
|
22 | - foreach ($resources as $resource) { |
|
23 | - if ($resource->hasParent()) { |
|
24 | - $parent = $resources[$resource->id_parent]; |
|
25 | - $parent->addChild($resource); |
|
26 | - } |
|
27 | - } |
|
28 | - } |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * Recursively builds parents path to passed resource |
|
33 | - * |
|
34 | - * @param ACL_Resource|bool $page |
|
35 | - * @param array $return |
|
36 | - * @return array |
|
37 | - */ |
|
38 | - public function buildPath($resource, &$return = array()) |
|
39 | - { |
|
40 | - if (!($resource instanceof ACL_Resource)) { |
|
41 | - return array_reverse($return); |
|
42 | - } |
|
43 | - |
|
44 | - $return[] = $resource; |
|
45 | - |
|
46 | - return $this->buildPath($resource->getParent(), $return); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Singleton |
|
51 | - * |
|
52 | - * @return ACL_Resources |
|
53 | - */ |
|
54 | - public static function instance() |
|
55 | - { |
|
56 | - static $instance; |
|
57 | - if (!($instance instanceof self)) { |
|
58 | - $instance = new self(); |
|
59 | - } |
|
60 | - return $instance; |
|
61 | - } |
|
6 | + protected $_sortOn = "name"; |
|
7 | + |
|
8 | + public function findAll() |
|
9 | + { |
|
10 | + if (!$this->getRegistry()->exists("all")) { |
|
11 | + $resources = parent::findAll(); |
|
12 | + $this->buildTree($resources); |
|
13 | + } |
|
14 | + |
|
15 | + return $this->getRegistry()->get('all'); |
|
16 | + } |
|
17 | + |
|
18 | + public function buildTree($resources = array()) |
|
19 | + { |
|
20 | + if ($resources) { |
|
21 | + /* @var $resource ACL_Resource */ |
|
22 | + foreach ($resources as $resource) { |
|
23 | + if ($resource->hasParent()) { |
|
24 | + $parent = $resources[$resource->id_parent]; |
|
25 | + $parent->addChild($resource); |
|
26 | + } |
|
27 | + } |
|
28 | + } |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * Recursively builds parents path to passed resource |
|
33 | + * |
|
34 | + * @param ACL_Resource|bool $page |
|
35 | + * @param array $return |
|
36 | + * @return array |
|
37 | + */ |
|
38 | + public function buildPath($resource, &$return = array()) |
|
39 | + { |
|
40 | + if (!($resource instanceof ACL_Resource)) { |
|
41 | + return array_reverse($return); |
|
42 | + } |
|
43 | + |
|
44 | + $return[] = $resource; |
|
45 | + |
|
46 | + return $this->buildPath($resource->getParent(), $return); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Singleton |
|
51 | + * |
|
52 | + * @return ACL_Resources |
|
53 | + */ |
|
54 | + public static function instance() |
|
55 | + { |
|
56 | + static $instance; |
|
57 | + if (!($instance instanceof self)) { |
|
58 | + $instance = new self(); |
|
59 | + } |
|
60 | + return $instance; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | } |
64 | 64 | \ No newline at end of file |
@@ -37,6 +37,9 @@ |
||
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | + /** |
|
41 | + * @param boolean $value |
|
42 | + */ |
|
40 | 43 | public function authenticated($value = null) |
41 | 44 | { |
42 | 45 | if (!is_null($value)) { |
@@ -3,86 +3,86 @@ |
||
3 | 3 | class Nip_Auth extends Record |
4 | 4 | { |
5 | 5 | |
6 | - protected $_authenticated = false; |
|
6 | + protected $_authenticated = false; |
|
7 | 7 | |
8 | - public function authenticate($request = array()) |
|
9 | - { |
|
10 | - if ($request) { |
|
11 | - $this->email = clean($request['email']); |
|
12 | - $this->password = clean($request['password']); |
|
13 | - } |
|
8 | + public function authenticate($request = array()) |
|
9 | + { |
|
10 | + if ($request) { |
|
11 | + $this->email = clean($request['email']); |
|
12 | + $this->password = clean($request['password']); |
|
13 | + } |
|
14 | 14 | |
15 | - $query = $this->_getAuthenticateQuery(); |
|
16 | - $user = $this->getManager()->findOneByQuery($query); |
|
15 | + $query = $this->_getAuthenticateQuery(); |
|
16 | + $user = $this->getManager()->findOneByQuery($query); |
|
17 | 17 | |
18 | - if ($user) { |
|
19 | - $this->writeData($user->toArray()); |
|
18 | + if ($user) { |
|
19 | + $this->writeData($user->toArray()); |
|
20 | 20 | |
21 | - $this->id_session = session_id(); |
|
22 | - $this->last_login = date(DATE_DB); |
|
23 | - $this->save(); |
|
24 | - |
|
25 | - $this->authenticated(true); |
|
26 | - |
|
27 | - $_SESSION[$this->_getSessionVar()]['id'] = $this->id; |
|
28 | - } |
|
29 | - |
|
30 | - return $this->authenticated(); |
|
31 | - } |
|
32 | - |
|
33 | - public function deauthenticate() |
|
34 | - { |
|
35 | - unset($_SESSION[$this->_getSessionVar()]); |
|
36 | - $this->authenticated(false); |
|
37 | - return $this; |
|
38 | - } |
|
39 | - |
|
40 | - public function authenticated($value = null) |
|
41 | - { |
|
42 | - if (!is_null($value)) { |
|
43 | - $this->_authenticated = $value; |
|
44 | - } |
|
45 | - return $this->_authenticated; |
|
46 | - } |
|
47 | - |
|
48 | - public function updatePassword() |
|
49 | - { |
|
50 | - $this->password = Nip_Helper_Passwords::instance()->hash($this->new_password); |
|
51 | - $this->save(); |
|
52 | - return $this; |
|
53 | - } |
|
54 | - |
|
55 | - public function recoverPassword() |
|
56 | - { |
|
57 | - $user = $this->getManager()->findOneByEmail($this->email); |
|
58 | - $this->writeData($user->toArray()); |
|
59 | - |
|
60 | - $this->generatePassword()->updatePassword(); |
|
61 | - $this->sendRecoverPasswordMail(); |
|
62 | - } |
|
63 | - |
|
64 | - public function generatePassword() |
|
65 | - { |
|
66 | - $this->new_password = Nip_Helper_Passwords::instance()->generate(8, false, true, true, false); |
|
67 | - return $this; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @return Nip_DB_Query_Select |
|
72 | - */ |
|
73 | - protected function _getAuthenticateQuery() |
|
74 | - { |
|
75 | - $query = $this->getManager()->newQuery(); |
|
76 | - |
|
77 | - $query->where("email = ?", $this->email); |
|
78 | - $query->where("password = ?", Nip_Helper_Passwords::instance()->hash($this->password)); |
|
79 | - |
|
80 | - return $query; |
|
81 | - } |
|
82 | - |
|
83 | - protected function _getSessionVar() |
|
84 | - { |
|
85 | - return $this->getManager()->getModel(); |
|
86 | - } |
|
21 | + $this->id_session = session_id(); |
|
22 | + $this->last_login = date(DATE_DB); |
|
23 | + $this->save(); |
|
24 | + |
|
25 | + $this->authenticated(true); |
|
26 | + |
|
27 | + $_SESSION[$this->_getSessionVar()]['id'] = $this->id; |
|
28 | + } |
|
29 | + |
|
30 | + return $this->authenticated(); |
|
31 | + } |
|
32 | + |
|
33 | + public function deauthenticate() |
|
34 | + { |
|
35 | + unset($_SESSION[$this->_getSessionVar()]); |
|
36 | + $this->authenticated(false); |
|
37 | + return $this; |
|
38 | + } |
|
39 | + |
|
40 | + public function authenticated($value = null) |
|
41 | + { |
|
42 | + if (!is_null($value)) { |
|
43 | + $this->_authenticated = $value; |
|
44 | + } |
|
45 | + return $this->_authenticated; |
|
46 | + } |
|
47 | + |
|
48 | + public function updatePassword() |
|
49 | + { |
|
50 | + $this->password = Nip_Helper_Passwords::instance()->hash($this->new_password); |
|
51 | + $this->save(); |
|
52 | + return $this; |
|
53 | + } |
|
54 | + |
|
55 | + public function recoverPassword() |
|
56 | + { |
|
57 | + $user = $this->getManager()->findOneByEmail($this->email); |
|
58 | + $this->writeData($user->toArray()); |
|
59 | + |
|
60 | + $this->generatePassword()->updatePassword(); |
|
61 | + $this->sendRecoverPasswordMail(); |
|
62 | + } |
|
63 | + |
|
64 | + public function generatePassword() |
|
65 | + { |
|
66 | + $this->new_password = Nip_Helper_Passwords::instance()->generate(8, false, true, true, false); |
|
67 | + return $this; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @return Nip_DB_Query_Select |
|
72 | + */ |
|
73 | + protected function _getAuthenticateQuery() |
|
74 | + { |
|
75 | + $query = $this->getManager()->newQuery(); |
|
76 | + |
|
77 | + $query->where("email = ?", $this->email); |
|
78 | + $query->where("password = ?", Nip_Helper_Passwords::instance()->hash($this->password)); |
|
79 | + |
|
80 | + return $query; |
|
81 | + } |
|
82 | + |
|
83 | + protected function _getSessionVar() |
|
84 | + { |
|
85 | + return $this->getManager()->getModel(); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | } |
89 | 89 | \ No newline at end of file |
@@ -81,6 +81,9 @@ discard block |
||
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
84 | + /** |
|
85 | + * @return string |
|
86 | + */ |
|
84 | 87 | protected function getClassLocation($class, $retry = false) |
85 | 88 | { |
86 | 89 | if (in_array($class, array_keys($this->getMap()))) { |
@@ -133,6 +136,9 @@ discard block |
||
133 | 136 | return $this->_map; |
134 | 137 | } |
135 | 138 | |
139 | + /** |
|
140 | + * @param string $filePath |
|
141 | + */ |
|
136 | 142 | protected function readCacheFile($filePath) |
137 | 143 | { |
138 | 144 | if (file_exists($filePath)) { |
@@ -153,11 +159,17 @@ discard block |
||
153 | 159 | return str_replace(DS, '-', $dir).'.php'; |
154 | 160 | } |
155 | 161 | |
162 | + /** |
|
163 | + * @param boolean $retry |
|
164 | + */ |
|
156 | 165 | public function setRetry($retry) |
157 | 166 | { |
158 | 167 | $this->_retry = $retry; |
159 | 168 | } |
160 | 169 | |
170 | + /** |
|
171 | + * @param boolean $value |
|
172 | + */ |
|
161 | 173 | public function isFatal($value = null) |
162 | 174 | { |
163 | 175 | if (is_bool($value)) { |
@@ -170,7 +182,7 @@ discard block |
||
170 | 182 | /** |
171 | 183 | * Singleton |
172 | 184 | * |
173 | - * @return Nip_AutoLoader |
|
185 | + * @return AutoLoader |
|
174 | 186 | */ |
175 | 187 | static public function instance() |
176 | 188 | { |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | public function generateMapDir($dir) |
112 | 112 | { |
113 | 113 | $fileName = $this->getCacheName($dir); |
114 | - $filePath = $this->_cachePath.$fileName; |
|
114 | + $filePath = $this->_cachePath . $fileName; |
|
115 | 115 | $this->_mapGenerator->dump($dir, $filePath); |
116 | 116 | } |
117 | 117 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | if (!$this->_map) { |
121 | 121 | foreach ($this->_directories as $dir) { |
122 | 122 | $fileName = $this->getCacheName($dir); |
123 | - $filePath = $this->_cachePath.$fileName; |
|
123 | + $filePath = $this->_cachePath . $fileName; |
|
124 | 124 | |
125 | 125 | if (!$this->readCacheFile($filePath)) { |
126 | 126 | \Nip_Profiler::instance()->start('autoloader [readCache]'); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | if (defined('ROOT_PATH')) { |
151 | 151 | $dir = str_replace(ROOT_PATH, '', $dir); |
152 | 152 | } |
153 | - return str_replace(DS, '-', $dir).'.php'; |
|
153 | + return str_replace(DS, '-', $dir) . '.php'; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | public function setRetry($retry) |
@@ -194,6 +194,9 @@ |
||
194 | 194 | return $i18n; |
195 | 195 | } |
196 | 196 | |
197 | + /** |
|
198 | + * @param \Nip_I18n $translation |
|
199 | + */ |
|
197 | 200 | public function initLanguages($translation) |
198 | 201 | { |
199 | 202 | return $translation; |
@@ -28,6 +28,9 @@ discard block |
||
28 | 28 | return $this->_plugins; |
29 | 29 | } |
30 | 30 | |
31 | + /** |
|
32 | + * @param string $key |
|
33 | + */ |
|
31 | 34 | public function getPlugin($key) |
32 | 35 | { |
33 | 36 | return $this->_plugins[$key]; |
@@ -68,6 +71,9 @@ discard block |
||
68 | 71 | $_this->setEnabled(false); |
69 | 72 | } |
70 | 73 | |
74 | + /** |
|
75 | + * @param boolean $enabled |
|
76 | + */ |
|
71 | 77 | public function setEnabled($enabled) |
72 | 78 | { |
73 | 79 | $this->_enabled = $enabled; |
@@ -88,7 +94,7 @@ discard block |
||
88 | 94 | /** |
89 | 95 | * Singleton |
90 | 96 | * |
91 | - * @return Console |
|
97 | + * @return Nip_Console |
|
92 | 98 | */ |
93 | 99 | public static function instance() |
94 | 100 | { |
@@ -13,7 +13,7 @@ |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
16 | - * @return Logger_Adapter |
|
16 | + * @return Nip\Logger\Adapter\AdapterAbstract |
|
17 | 17 | */ |
18 | 18 | public function getLogger() |
19 | 19 | { |
@@ -159,6 +159,9 @@ |
||
159 | 159 | return true; |
160 | 160 | } |
161 | 161 | |
162 | + /** |
|
163 | + * @param string[] $action |
|
164 | + */ |
|
162 | 165 | protected function validAction($action) |
163 | 166 | { |
164 | 167 | return in_array($action, get_class_methods(get_class($this))); |
@@ -32,6 +32,9 @@ |
||
32 | 32 | return parent::cachePath() . '/db-metadata/'; |
33 | 33 | } |
34 | 34 | |
35 | + /** |
|
36 | + * @param Nip_Db_Metadata $metadata |
|
37 | + */ |
|
35 | 38 | public function setMetadata($metadata) { |
36 | 39 | $this->_metadata = $metadata; |
37 | 40 | return $this; |
@@ -16,6 +16,10 @@ |
||
16 | 16 | class Nip_DB_Profiler_Query extends Nip_Profile { |
17 | 17 | public $columns = array('time', 'type', 'memory', 'query', 'affectedRows', 'info'); |
18 | 18 | |
19 | + /** |
|
20 | + * @param boolean $query |
|
21 | + * @param string $queryType |
|
22 | + */ |
|
19 | 23 | public function __construct($query, $queryType) { |
20 | 24 | $this->query = $query; |
21 | 25 |
@@ -14,11 +14,11 @@ |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | class Nip_DB_Profiler_Query extends Nip_Profile { |
17 | - public $columns = array('time', 'type', 'memory', 'query', 'affectedRows', 'info'); |
|
17 | + public $columns = array('time', 'type', 'memory', 'query', 'affectedRows', 'info'); |
|
18 | 18 | |
19 | - public function __construct($query, $queryType) { |
|
20 | - $this->query = $query; |
|
19 | + public function __construct($query, $queryType) { |
|
20 | + $this->query = $query; |
|
21 | 21 | |
22 | - parent::__construct($queryType); |
|
23 | - } |
|
22 | + parent::__construct($queryType); |
|
23 | + } |
|
24 | 24 | } |
25 | 25 | \ No newline at end of file |
@@ -14,7 +14,7 @@ |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | class Nip_DB_Profiler_Query extends Nip_Profile { |
17 | - public $columns = array('time', 'type', 'memory', 'query', 'affectedRows', 'info'); |
|
17 | + public $columns = array('time', 'type', 'memory', 'query', 'affectedRows', 'info'); |
|
18 | 18 | |
19 | 19 | public function __construct($query, $queryType) { |
20 | 20 | $this->query = $query; |