@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * Returns true if valid, of not it returns a String with information about the reason |
| 153 | 153 | * |
| 154 | 154 | * @param string $username |
| 155 | - * @return boolean string |
|
| 155 | + * @return string|boolean string |
|
| 156 | 156 | */ |
| 157 | 157 | private function isUsernameValid($username) { |
| 158 | 158 | if (strlen ( $username ) <= 2) |
@@ -167,7 +167,6 @@ discard block |
||
| 167 | 167 | /** |
| 168 | 168 | * Returns true if valid, of not it returns a String with information about the reason |
| 169 | 169 | * |
| 170 | - * @param string $username |
|
| 171 | 170 | * @return boolean string |
| 172 | 171 | */ |
| 173 | 172 | private function isPasswordValid($password) { |
@@ -21,130 +21,130 @@ discard block |
||
| 21 | 21 | * @see \Zend\Mvc\Controller\AbstractActionController::onDispatch() |
| 22 | 22 | */ |
| 23 | 23 | public function onDispatch(\Zend\Mvc\MvcEvent $e) { |
| 24 | - $username = $this->getUserService ()->getCurrentUser (); |
|
| 24 | + $username = $this->getUserService()->getCurrentUser(); |
|
| 25 | 25 | |
| 26 | - if (false === $this->getUserService ()->isUserAllowedToManageUsers ( $username )) { |
|
| 27 | - $this->getResponse ()->setStatusCode ( 401 ); |
|
| 26 | + if (false === $this->getUserService()->isUserAllowedToManageUsers($username)) { |
|
| 27 | + $this->getResponse()->setStatusCode(401); |
|
| 28 | 28 | return; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - return parent::onDispatch ( $e ); |
|
| 31 | + return parent::onDispatch($e); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function indexAction() { |
| 35 | - $htpasswdService = $this->getHtpasswdService (); |
|
| 36 | - $userList = $htpasswdService->getUserList (); |
|
| 35 | + $htpasswdService = $this->getHtpasswdService(); |
|
| 36 | + $userList = $htpasswdService->getUserList(); |
|
| 37 | 37 | |
| 38 | 38 | $result = array(); |
| 39 | - foreach ( $userList as $username => $pass ) { |
|
| 39 | + foreach ($userList as $username => $pass) { |
|
| 40 | 40 | |
| 41 | - $result [] = array( |
|
| 41 | + $result [ ] = array( |
|
| 42 | 42 | 'username' => $username, |
| 43 | 43 | 'paswd' => $pass, |
| 44 | - 'isAdmin' => $this->getUserService ()->isUserAllowedToManageUsers ( $username ), |
|
| 45 | - 'isDeletable' => $this->getUserService ()->isUserDeleteable ( $username ) |
|
| 44 | + 'isAdmin' => $this->getUserService()->isUserAllowedToManageUsers($username), |
|
| 45 | + 'isDeletable' => $this->getUserService()->isUserDeleteable($username) |
|
| 46 | 46 | ); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $userService = $this->getServiceLocator ()->get ( 'HtpasswdManager\Service\UserService' ); |
|
| 49 | + $userService = $this->getServiceLocator()->get('HtpasswdManager\Service\UserService'); |
|
| 50 | 50 | |
| 51 | - $model = new ViewModel ( array( |
|
| 51 | + $model = new ViewModel(array( |
|
| 52 | 52 | 'userList' => $result, |
| 53 | - 'currentUser' => $userService->getCurrentUser () |
|
| 54 | - ) ); |
|
| 53 | + 'currentUser' => $userService->getCurrentUser() |
|
| 54 | + )); |
|
| 55 | 55 | |
| 56 | 56 | return $model; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function deleteAction() { |
| 60 | - $user = $this->params ( 'user' ); |
|
| 60 | + $user = $this->params('user'); |
|
| 61 | 61 | $messages = array(); |
| 62 | 62 | |
| 63 | - if (true === $this->getUserService ()->isUserDeleteable ( $user )) { |
|
| 64 | - $this->getHtpasswdService ()->deleteUser ( $user ); |
|
| 65 | - $messages [] = "Der Benutzer '{$user}' wurde gelöscht."; |
|
| 63 | + if (true === $this->getUserService()->isUserDeleteable($user)) { |
|
| 64 | + $this->getHtpasswdService()->deleteUser($user); |
|
| 65 | + $messages [ ] = "Der Benutzer '{$user}' wurde gelöscht."; |
|
| 66 | 66 | } else { |
| 67 | - $messages [] = "Der Benutzer '{$user}' steht auf einer Sperrliste und kann nicht gelöscht werden."; |
|
| 67 | + $messages [ ] = "Der Benutzer '{$user}' steht auf einer Sperrliste und kann nicht gelöscht werden."; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $model = $this->indexAction (); |
|
| 71 | - $model->setTemplate ( 'htpasswd-manager/user/index' ); |
|
| 72 | - $model->setVariable ( 'messages', $messages ); |
|
| 70 | + $model = $this->indexAction(); |
|
| 71 | + $model->setTemplate('htpasswd-manager/user/index'); |
|
| 72 | + $model->setVariable('messages', $messages); |
|
| 73 | 73 | |
| 74 | 74 | return $model; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public function editAction() { |
| 78 | - $user = $this->params ( 'user' ); |
|
| 78 | + $user = $this->params('user'); |
|
| 79 | 79 | $messages = array(); |
| 80 | - $htpasswd = $this->getHtpasswdService (); |
|
| 80 | + $htpasswd = $this->getHtpasswdService(); |
|
| 81 | 81 | |
| 82 | - $model = new ViewModel (); |
|
| 83 | - $model->setVariable ( 'user', $user ); |
|
| 82 | + $model = new ViewModel(); |
|
| 83 | + $model->setVariable('user', $user); |
|
| 84 | 84 | |
| 85 | - $post = $this->getRequest ()->getPost (); |
|
| 86 | - if (! isset ( $post ['password'] )) { |
|
| 85 | + $post = $this->getRequest()->getPost(); |
|
| 86 | + if (!isset ($post [ 'password' ])) { |
|
| 87 | 87 | // Formular initialisieren |
| 88 | - if (false === $htpasswd->userExists ( $user )) { |
|
| 89 | - $this->redirect ()->toRoute ( 'htpasswdmanager', array( |
|
| 88 | + if (false === $htpasswd->userExists($user)) { |
|
| 89 | + $this->redirect()->toRoute('htpasswdmanager', array( |
|
| 90 | 90 | 'action' => 'index' |
| 91 | - ) ); |
|
| 91 | + )); |
|
| 92 | 92 | } |
| 93 | 93 | } else { |
| 94 | 94 | // Formular speichern |
| 95 | - $password = $post ['password']; |
|
| 96 | - $htpasswd->updateUser ( $user, $password ); |
|
| 97 | - $messages [] = "Passwort für '{$user}' wurde aktualisiert."; |
|
| 95 | + $password = $post [ 'password' ]; |
|
| 96 | + $htpasswd->updateUser($user, $password); |
|
| 97 | + $messages [ ] = "Passwort für '{$user}' wurde aktualisiert."; |
|
| 98 | 98 | |
| 99 | - $model = $this->indexAction (); |
|
| 100 | - $model->setTemplate ( 'htpasswd-manager/user/index' ); |
|
| 99 | + $model = $this->indexAction(); |
|
| 100 | + $model->setTemplate('htpasswd-manager/user/index'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $model->setVariable ( 'messages', $messages ); |
|
| 103 | + $model->setVariable('messages', $messages); |
|
| 104 | 104 | return $model; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function addAction() { |
| 108 | - $username = $post = $this->getRequest ()->getPost ( 'username', '' ); |
|
| 109 | - $password = $post = $this->getRequest ()->getPost ( 'password', '' ); |
|
| 108 | + $username = $post = $this->getRequest()->getPost('username', ''); |
|
| 109 | + $password = $post = $this->getRequest()->getPost('password', ''); |
|
| 110 | 110 | $messages = array(); |
| 111 | - $model = new ViewModel (); |
|
| 111 | + $model = new ViewModel(); |
|
| 112 | 112 | |
| 113 | - $post = $this->getRequest ()->getPost (); |
|
| 114 | - if (! isset ( $post ['username'] )) { |
|
| 115 | - return new ViewModel ( array( |
|
| 113 | + $post = $this->getRequest()->getPost(); |
|
| 114 | + if (!isset ($post [ 'username' ])) { |
|
| 115 | + return new ViewModel(array( |
|
| 116 | 116 | 'username' => $username, |
| 117 | 117 | 'password' => $password, |
| 118 | 118 | 'messages' => $messages |
| 119 | - ) ); |
|
| 119 | + )); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $model->setVariable ( 'username', $username ); |
|
| 123 | - $uValid = $this->isUsernameValid ( $username ); |
|
| 122 | + $model->setVariable('username', $username); |
|
| 123 | + $uValid = $this->isUsernameValid($username); |
|
| 124 | 124 | if (true !== $uValid) { |
| 125 | - $messages [] = $uValid; |
|
| 125 | + $messages [ ] = $uValid; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $model->setVariable ( 'password', $password ); |
|
| 129 | - $pValid = $this->isPasswordValid ( $password ); |
|
| 128 | + $model->setVariable('password', $password); |
|
| 129 | + $pValid = $this->isPasswordValid($password); |
|
| 130 | 130 | if (true !== $pValid) { |
| 131 | - $messages [] = $pValid; |
|
| 131 | + $messages [ ] = $pValid; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | if (true === $uValid && true === $pValid) { |
| 135 | - if (true === $this->getHtpasswdService ()->userExists ( $username )) { |
|
| 136 | - $this->getHtpasswdService ()->updateUser ( $username, $password ); |
|
| 137 | - $messages [] = "Benutzer '{$username}' wurde aktualisiert."; |
|
| 135 | + if (true === $this->getHtpasswdService()->userExists($username)) { |
|
| 136 | + $this->getHtpasswdService()->updateUser($username, $password); |
|
| 137 | + $messages [ ] = "Benutzer '{$username}' wurde aktualisiert."; |
|
| 138 | 138 | } else { |
| 139 | - $this->getHtpasswdService ()->addUser ( $username, $password ); |
|
| 140 | - $messages [] = "Benutzer '{$username}' wurde hinzugefügt."; |
|
| 139 | + $this->getHtpasswdService()->addUser($username, $password); |
|
| 140 | + $messages [ ] = "Benutzer '{$username}' wurde hinzugefügt."; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $model = $this->indexAction (); |
|
| 144 | - $model->setTemplate ( 'htpasswd-manager/user/index' ); |
|
| 143 | + $model = $this->indexAction(); |
|
| 144 | + $model->setTemplate('htpasswd-manager/user/index'); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $model->setVariable ( 'messages', $messages ); |
|
| 147 | + $model->setVariable('messages', $messages); |
|
| 148 | 148 | return $model; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | * @return boolean string |
| 156 | 156 | */ |
| 157 | 157 | private function isUsernameValid($username) { |
| 158 | - if (strlen ( $username ) <= 2) |
|
| 158 | + if (strlen($username) <= 2) |
|
| 159 | 159 | return "Benutzername ist zu kurz."; |
| 160 | - else if (preg_match ( '~[a-zäöo][a-zäöu_0-9-]+~i', $username ) !== 1) |
|
| 160 | + else if (preg_match('~[a-zäöo][a-zäöu_0-9-]+~i', $username) !== 1) |
|
| 161 | 161 | return "Benutzername enthält ungültige Zeichen"; |
| 162 | - else if (strpos ( $username, ' ' ) !== false) |
|
| 162 | + else if (strpos($username, ' ') !== false) |
|
| 163 | 163 | return "Leerzeichen sind im Benutzernamen nicht erlaubt"; |
| 164 | 164 | return true; |
| 165 | 165 | } |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | private function getHtpasswdService() { |
| 178 | 178 | if ($this->htpasswdService === null) { |
| 179 | - $sl = $this->getServiceLocator (); |
|
| 180 | - $this->htpasswdService = $sl->get ( 'HtpasswdManager\Service\HtpasswdService' ); |
|
| 179 | + $sl = $this->getServiceLocator(); |
|
| 180 | + $this->htpasswdService = $sl->get('HtpasswdManager\Service\HtpasswdService'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return $this->htpasswdService; |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | private function getUserService() { |
| 187 | 187 | if ($this->userService === null) { |
| 188 | - $sl = $this->getServiceLocator (); |
|
| 189 | - $this->userService = $sl->get ( 'HtpasswdManager\Service\UserService' ); |
|
| 188 | + $sl = $this->getServiceLocator(); |
|
| 189 | + $this->userService = $sl->get('HtpasswdManager\Service\UserService'); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | return $this->userService; |
@@ -155,12 +155,13 @@ |
||
| 155 | 155 | * @return boolean string |
| 156 | 156 | */ |
| 157 | 157 | private function isUsernameValid($username) { |
| 158 | - if (strlen ( $username ) <= 2) |
|
| 159 | - return "Benutzername ist zu kurz."; |
|
| 160 | - else if (preg_match ( '~[a-zäöo][a-zäöu_0-9-]+~i', $username ) !== 1) |
|
| 161 | - return "Benutzername enthält ungültige Zeichen"; |
|
| 162 | - else if (strpos ( $username, ' ' ) !== false) |
|
| 163 | - return "Leerzeichen sind im Benutzernamen nicht erlaubt"; |
|
| 158 | + if (strlen ( $username ) <= 2) { |
|
| 159 | + return "Benutzername ist zu kurz."; |
|
| 160 | + } else if (preg_match ( '~[a-zäöo][a-zäöu_0-9-]+~i', $username ) !== 1) { |
|
| 161 | + return "Benutzername enthält ungültige Zeichen"; |
|
| 162 | + } else if (strpos ( $username, ' ' ) !== false) { |
|
| 163 | + return "Leerzeichen sind im Benutzernamen nicht erlaubt"; |
|
| 164 | + } |
|
| 164 | 165 | return true; |
| 165 | 166 | } |
| 166 | 167 | |
@@ -108,6 +108,9 @@ |
||
| 108 | 108 | return $usernameDeleted; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | + /** |
|
| 112 | + * @param string $newContent |
|
| 113 | + */ |
|
| 111 | 114 | private function replaceHtPasswdContent($newContent) { |
| 112 | 115 | // file_put_contents ( $this->filename, $newContent ); |
| 113 | 116 | $fp = fopen ( $this->filename, 'w' ); |
@@ -19,20 +19,20 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function __construct($htpasswd_filename) { |
| 21 | 21 | $this->filename = $htpasswd_filename; |
| 22 | - $this->createFileIfNotExistant (); |
|
| 22 | + $this->createFileIfNotExistant(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | private function createFileIfNotExistant() { |
| 26 | - if (true === file_exists ( $this->filename )) { |
|
| 26 | + if (true === file_exists($this->filename)) { |
|
| 27 | 27 | } else { |
| 28 | - touch ( $this->filename ); |
|
| 28 | + touch($this->filename); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | private function getHtpasswdContent() { |
| 33 | 33 | if ($this->htpasswdCache === null) { |
| 34 | 34 | |
| 35 | - $this->htpasswdCache = file_get_contents ( $this->filename ); |
|
| 35 | + $this->htpasswdCache = file_get_contents($this->filename); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return $this->htpasswdCache; |
@@ -41,18 +41,18 @@ discard block |
||
| 41 | 41 | private function updateHtpasswdContent() { |
| 42 | 42 | $this->htpasswdCache = null; |
| 43 | 43 | $this->userListCache = null; |
| 44 | - $this->getUserList (); |
|
| 44 | + $this->getUserList(); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function getUserList() { |
| 48 | 48 | if ($this->userListCache === null) { |
| 49 | 49 | $result = array(); |
| 50 | 50 | |
| 51 | - $content = $this->getHtpasswdContent (); |
|
| 51 | + $content = $this->getHtpasswdContent(); |
|
| 52 | 52 | |
| 53 | - if (preg_match_all ( $this::$REGULAR_USER_PASSWORD, $content, $matches, PREG_PATTERN_ORDER ) !== false) { |
|
| 54 | - foreach ( $matches [1] as $i => $user ) { |
|
| 55 | - $result [$user] = $matches [2] [$i]; |
|
| 53 | + if (preg_match_all($this::$REGULAR_USER_PASSWORD, $content, $matches, PREG_PATTERN_ORDER) !== false) { |
|
| 54 | + foreach ($matches [ 1 ] as $i => $user) { |
|
| 55 | + $result [ $user ] = $matches [ 2 ] [ $i ]; |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -63,45 +63,45 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | private function encodePassword($password) { |
| 66 | - return crypt ( $password, substr ( str_replace ( '+', '.', base64_encode ( pack ( 'N4', mt_rand (), mt_rand (), mt_rand (), mt_rand () ) ) ), 0, 22 ) ); |
|
| 66 | + return crypt($password, substr(str_replace('+', '.', base64_encode(pack('N4', mt_rand(), mt_rand(), mt_rand(), mt_rand()))), 0, 22)); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | private function getNewUserEncodedString($username, $password) { |
| 70 | - return $username . ':' . $this->encodePassword ( $password ) . "\n"; |
|
| 70 | + return $username . ':' . $this->encodePassword($password) . "\n"; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | public function addUser($username, $password) { |
| 74 | - $newContent = $this->getHtpasswdContent (); |
|
| 75 | - $newContent .= $this->getNewUserEncodedString ( $username, $password ); |
|
| 74 | + $newContent = $this->getHtpasswdContent(); |
|
| 75 | + $newContent .= $this->getNewUserEncodedString($username, $password); |
|
| 76 | 76 | |
| 77 | - $this->replaceHtPasswdContent ( $newContent ); |
|
| 77 | + $this->replaceHtPasswdContent($newContent); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function updateUser($username, $password) { |
| 81 | - if ($this->userExists ( $username )) { |
|
| 82 | - $this->deleteUser ( $username ); |
|
| 81 | + if ($this->userExists($username)) { |
|
| 82 | + $this->deleteUser($username); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - $this->addUser ( $username, $password ); |
|
| 85 | + $this->addUser($username, $password); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public function deleteUser($username) { |
| 89 | - $content = $this->getHtpasswdContent (); |
|
| 89 | + $content = $this->getHtpasswdContent(); |
|
| 90 | 90 | |
| 91 | 91 | $newContent = ''; |
| 92 | 92 | $usernameDeleted = false; |
| 93 | 93 | |
| 94 | - if (preg_match_all ( $this::$REGULAR_USER_PASSWORD, $this->getHtpasswdContent (), $match ) > 0) { |
|
| 95 | - foreach ( $match [1] as $i => $user ) { |
|
| 94 | + if (preg_match_all($this::$REGULAR_USER_PASSWORD, $this->getHtpasswdContent(), $match) > 0) { |
|
| 95 | + foreach ($match [ 1 ] as $i => $user) { |
|
| 96 | 96 | if ($user == $username) { |
| 97 | 97 | $usernameDeleted = true; |
| 98 | 98 | } else { |
| 99 | - $newContent .= $match [0] [$i] . "\n"; |
|
| 99 | + $newContent .= $match [ 0 ] [ $i ] . "\n"; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | if (true === $usernameDeleted) { |
| 104 | - $this->replaceHtPasswdContent ( $newContent ); |
|
| 104 | + $this->replaceHtPasswdContent($newContent); |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
@@ -110,17 +110,17 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | private function replaceHtPasswdContent($newContent) { |
| 112 | 112 | // file_put_contents ( $this->filename, $newContent ); |
| 113 | - $fp = fopen ( $this->filename, 'w' ); |
|
| 114 | - fwrite ( $fp, $newContent ); |
|
| 115 | - fclose ( $fp ); |
|
| 113 | + $fp = fopen($this->filename, 'w'); |
|
| 114 | + fwrite($fp, $newContent); |
|
| 115 | + fclose($fp); |
|
| 116 | 116 | |
| 117 | - $this->updateHtpasswdContent (); |
|
| 117 | + $this->updateHtpasswdContent(); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public function userExists($username) { |
| 121 | - $userList = $this->getUserList (); |
|
| 121 | + $userList = $this->getUserList(); |
|
| 122 | 122 | |
| 123 | - if (isset ( $userList [$username] )) |
|
| 123 | + if (isset ($userList [ $username ])) |
|
| 124 | 124 | return true; |
| 125 | 125 | |
| 126 | 126 | return false; |
@@ -120,8 +120,9 @@ |
||
| 120 | 120 | public function userExists($username) { |
| 121 | 121 | $userList = $this->getUserList (); |
| 122 | 122 | |
| 123 | - if (isset ( $userList [$username] )) |
|
| 124 | - return true; |
|
| 123 | + if (isset ( $userList [$username] )) { |
|
| 124 | + return true; |
|
| 125 | + } |
|
| 125 | 126 | |
| 126 | 127 | return false; |
| 127 | 128 | } |
@@ -140,6 +140,9 @@ |
||
| 140 | 140 | $this->assertFalse($service->userExists('not Existant'), "User 'not Existant' should not exist"); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | + /** |
|
| 144 | + * @param string $filename |
|
| 145 | + */ |
|
| 143 | 146 | protected function getNumberOfLines($filename) { |
| 144 | 147 | $cont = file_get_contents($filename); |
| 145 | 148 | $lines = explode("\n", $cont); |
@@ -5,153 +5,153 @@ |
||
| 5 | 5 | |
| 6 | 6 | class HtpasswdServiceTest extends \PHPUnit_Framework_TestCase { |
| 7 | 7 | |
| 8 | - protected $testDataDir; |
|
| 8 | + protected $testDataDir; |
|
| 9 | 9 | |
| 10 | - public function setUp() { |
|
| 11 | - $this->testDataDir = __DIR__ . '/TestData'; |
|
| 10 | + public function setUp() { |
|
| 11 | + $this->testDataDir = __DIR__ . '/TestData'; |
|
| 12 | 12 | |
| 13 | - parent::setUp(); |
|
| 14 | - } |
|
| 13 | + parent::setUp(); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | - public function testCreateFileIfNotExistant() { |
|
| 18 | - $testFile = $this->testDataDir . '/notExistant'; |
|
| 17 | + public function testCreateFileIfNotExistant() { |
|
| 18 | + $testFile = $this->testDataDir . '/notExistant'; |
|
| 19 | 19 | |
| 20 | - if (true === file_exists($testFile)) { |
|
| 21 | - unlink($testFile); |
|
| 22 | - } |
|
| 20 | + if (true === file_exists($testFile)) { |
|
| 21 | + unlink($testFile); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - $this->assertFileNotExists($testFile); |
|
| 24 | + $this->assertFileNotExists($testFile); |
|
| 25 | 25 | |
| 26 | - $service = new HtpasswdService($testFile); |
|
| 27 | - $this->assertFileExists($testFile); |
|
| 26 | + $service = new HtpasswdService($testFile); |
|
| 27 | + $this->assertFileExists($testFile); |
|
| 28 | 28 | |
| 29 | - // Cleanup |
|
| 30 | - unlink($testFile); |
|
| 31 | - } |
|
| 29 | + // Cleanup |
|
| 30 | + unlink($testFile); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public function testGetUserList_Empty() { |
|
| 34 | - $testFile = $this->testDataDir . '/htaccess_UserServiceTest_empty'; |
|
| 33 | + public function testGetUserList_Empty() { |
|
| 34 | + $testFile = $this->testDataDir . '/htaccess_UserServiceTest_empty'; |
|
| 35 | 35 | |
| 36 | - if (true === file_exists($testFile)) { |
|
| 37 | - unlink($testFile); |
|
| 38 | - } |
|
| 39 | - $this->assertFileNotExists($testFile); |
|
| 40 | - touch($testFile); |
|
| 41 | - $this->assertFileExists($testFile); |
|
| 36 | + if (true === file_exists($testFile)) { |
|
| 37 | + unlink($testFile); |
|
| 38 | + } |
|
| 39 | + $this->assertFileNotExists($testFile); |
|
| 40 | + touch($testFile); |
|
| 41 | + $this->assertFileExists($testFile); |
|
| 42 | 42 | |
| 43 | - $service = new HtpasswdService($testFile); |
|
| 43 | + $service = new HtpasswdService($testFile); |
|
| 44 | 44 | |
| 45 | - $userList = $service->getUserList(); |
|
| 46 | - $this->assertEquals($expected = [ ], $userList, "UserList"); |
|
| 45 | + $userList = $service->getUserList(); |
|
| 46 | + $this->assertEquals($expected = [ ], $userList, "UserList"); |
|
| 47 | 47 | |
| 48 | - // Cleanup |
|
| 49 | - unlink($testFile); |
|
| 50 | - } |
|
| 48 | + // Cleanup |
|
| 49 | + unlink($testFile); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public function testGetUserList_Filled() { |
|
| 53 | - $testFile = $this->testDataDir . '/htaccess_UserServiceTest'; |
|
| 54 | - $this->assertFileExists($testFile); |
|
| 52 | + public function testGetUserList_Filled() { |
|
| 53 | + $testFile = $this->testDataDir . '/htaccess_UserServiceTest'; |
|
| 54 | + $this->assertFileExists($testFile); |
|
| 55 | 55 | |
| 56 | - $service = new HtpasswdService($testFile); |
|
| 56 | + $service = new HtpasswdService($testFile); |
|
| 57 | 57 | |
| 58 | - $userList = $service->getUserList(); |
|
| 59 | - $this->assertEquals( |
|
| 60 | - $expected = [ 'steven' => '$apr1$UF1l/6iv$tT3IJUH.QL82HAraXetNo0', |
|
| 61 | - 'blub' => '$apr1$jVosh5nC$q6KJ5EZNU6thOPETMQw8O/' |
|
| 62 | - ], $userList, "UserList"); |
|
| 63 | - } |
|
| 58 | + $userList = $service->getUserList(); |
|
| 59 | + $this->assertEquals( |
|
| 60 | + $expected = [ 'steven' => '$apr1$UF1l/6iv$tT3IJUH.QL82HAraXetNo0', |
|
| 61 | + 'blub' => '$apr1$jVosh5nC$q6KJ5EZNU6thOPETMQw8O/' |
|
| 62 | + ], $userList, "UserList"); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - public function testAddUser() { |
|
| 66 | - $testFileTemplate = $this->testDataDir . '/htaccess_UserServiceTest'; |
|
| 67 | - $testFile = $this->testDataDir . '/htaccess_UserServiceTest_addUser'; |
|
| 68 | - $this->assertFileExists($testFileTemplate); |
|
| 65 | + public function testAddUser() { |
|
| 66 | + $testFileTemplate = $this->testDataDir . '/htaccess_UserServiceTest'; |
|
| 67 | + $testFile = $this->testDataDir . '/htaccess_UserServiceTest_addUser'; |
|
| 68 | + $this->assertFileExists($testFileTemplate); |
|
| 69 | 69 | |
| 70 | - if (true === file_exists($testFile)) { |
|
| 71 | - unlink($testFile); |
|
| 72 | - } |
|
| 73 | - $this->assertFileNotExists($testFile); |
|
| 70 | + if (true === file_exists($testFile)) { |
|
| 71 | + unlink($testFile); |
|
| 72 | + } |
|
| 73 | + $this->assertFileNotExists($testFile); |
|
| 74 | 74 | |
| 75 | - copy($testFileTemplate, $testFile); |
|
| 76 | - $this->assertFileExists($testFile); |
|
| 75 | + copy($testFileTemplate, $testFile); |
|
| 76 | + $this->assertFileExists($testFile); |
|
| 77 | 77 | |
| 78 | - $service = new HtpasswdService($testFile); |
|
| 79 | - $userList = $service->getUserList(); |
|
| 80 | - $this->assertCount(2, $userList); |
|
| 81 | - $this->assertEquals(2, $this->getNumberOfLines($testFile), "Number of Lines"); |
|
| 78 | + $service = new HtpasswdService($testFile); |
|
| 79 | + $userList = $service->getUserList(); |
|
| 80 | + $this->assertCount(2, $userList); |
|
| 81 | + $this->assertEquals(2, $this->getNumberOfLines($testFile), "Number of Lines"); |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | - $service->addUser('test', 'test'); |
|
| 84 | + $service->addUser('test', 'test'); |
|
| 85 | 85 | |
| 86 | - $userList = $service->getUserList(); |
|
| 87 | - $this->assertCount(3, $userList); |
|
| 88 | - $this->assertEquals($expected = [ 'steven', 'blub', 'test' ], |
|
| 89 | - array_keys($userList)); |
|
| 90 | - $this->assertEquals(3, $this->getNumberOfLines($testFile), "Number of Lines"); |
|
| 86 | + $userList = $service->getUserList(); |
|
| 87 | + $this->assertCount(3, $userList); |
|
| 88 | + $this->assertEquals($expected = [ 'steven', 'blub', 'test' ], |
|
| 89 | + array_keys($userList)); |
|
| 90 | + $this->assertEquals(3, $this->getNumberOfLines($testFile), "Number of Lines"); |
|
| 91 | 91 | |
| 92 | 92 | |
| 93 | - // Cleanup |
|
| 94 | - unlink($testFile); |
|
| 95 | - } |
|
| 93 | + // Cleanup |
|
| 94 | + unlink($testFile); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | - public function testdeleteUser() { |
|
| 99 | - $testFileTemplate = $this->testDataDir . '/htaccess_UserServiceTest'; |
|
| 100 | - $testFile = $this->testDataDir . '/htaccess_UserServiceTest_addUser'; |
|
| 101 | - $this->assertFileExists($testFileTemplate); |
|
| 98 | + public function testdeleteUser() { |
|
| 99 | + $testFileTemplate = $this->testDataDir . '/htaccess_UserServiceTest'; |
|
| 100 | + $testFile = $this->testDataDir . '/htaccess_UserServiceTest_addUser'; |
|
| 101 | + $this->assertFileExists($testFileTemplate); |
|
| 102 | 102 | |
| 103 | - if (true === file_exists($testFile)) { |
|
| 104 | - unlink($testFile); |
|
| 105 | - } |
|
| 106 | - $this->assertFileNotExists($testFile); |
|
| 103 | + if (true === file_exists($testFile)) { |
|
| 104 | + unlink($testFile); |
|
| 105 | + } |
|
| 106 | + $this->assertFileNotExists($testFile); |
|
| 107 | 107 | |
| 108 | - copy($testFileTemplate, $testFile); |
|
| 109 | - $this->assertFileExists($testFile); |
|
| 108 | + copy($testFileTemplate, $testFile); |
|
| 109 | + $this->assertFileExists($testFile); |
|
| 110 | 110 | |
| 111 | - $service = new HtpasswdService($testFile); |
|
| 112 | - $userList = $service->getUserList(); |
|
| 113 | - $this->assertCount(2, $userList); |
|
| 114 | - $this->assertEquals(2, $this->getNumberOfLines($testFile), "Number of Lines"); |
|
| 111 | + $service = new HtpasswdService($testFile); |
|
| 112 | + $userList = $service->getUserList(); |
|
| 113 | + $this->assertCount(2, $userList); |
|
| 114 | + $this->assertEquals(2, $this->getNumberOfLines($testFile), "Number of Lines"); |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | - $service->deleteUser('steven'); |
|
| 118 | - $userList = $service->getUserList(); |
|
| 119 | - $this->assertCount(1, $userList); |
|
| 120 | - $this->assertEquals($expected = [ 'blub' ], |
|
| 121 | - array_keys($userList)); |
|
| 122 | - $this->assertEquals(1, $this->getNumberOfLines($testFile), "Number of Lines"); |
|
| 117 | + $service->deleteUser('steven'); |
|
| 118 | + $userList = $service->getUserList(); |
|
| 119 | + $this->assertCount(1, $userList); |
|
| 120 | + $this->assertEquals($expected = [ 'blub' ], |
|
| 121 | + array_keys($userList)); |
|
| 122 | + $this->assertEquals(1, $this->getNumberOfLines($testFile), "Number of Lines"); |
|
| 123 | 123 | |
| 124 | 124 | |
| 125 | - // Cleanup |
|
| 126 | - unlink($testFile); |
|
| 127 | - } |
|
| 125 | + // Cleanup |
|
| 126 | + unlink($testFile); |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - public function testUserExists() { |
|
| 130 | - $testFile = $this->testDataDir . '/htaccess_UserServiceTest'; |
|
| 131 | - $this->assertFileExists($testFile); |
|
| 129 | + public function testUserExists() { |
|
| 130 | + $testFile = $this->testDataDir . '/htaccess_UserServiceTest'; |
|
| 131 | + $this->assertFileExists($testFile); |
|
| 132 | 132 | |
| 133 | - $service = new HtpasswdService($testFile); |
|
| 134 | - $userList = $service->getUserList(); |
|
| 133 | + $service = new HtpasswdService($testFile); |
|
| 134 | + $userList = $service->getUserList(); |
|
| 135 | 135 | |
| 136 | - $this->assertTrue($service->userExists('steven'), 'User should exist'); |
|
| 137 | - $this->assertTrue($service->userExists('blub'), 'User should exist'); |
|
| 138 | - $this->assertFalse($service->userExists(''), "User '' should not exist"); |
|
| 139 | - $this->assertFalse($service->userExists('notExistant'), "User 'notExistant' should not exist"); |
|
| 140 | - $this->assertFalse($service->userExists('not Existant'), "User 'not Existant' should not exist"); |
|
| 141 | - } |
|
| 136 | + $this->assertTrue($service->userExists('steven'), 'User should exist'); |
|
| 137 | + $this->assertTrue($service->userExists('blub'), 'User should exist'); |
|
| 138 | + $this->assertFalse($service->userExists(''), "User '' should not exist"); |
|
| 139 | + $this->assertFalse($service->userExists('notExistant'), "User 'notExistant' should not exist"); |
|
| 140 | + $this->assertFalse($service->userExists('not Existant'), "User 'not Existant' should not exist"); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - protected function getNumberOfLines($filename) { |
|
| 144 | - $cont = file_get_contents($filename); |
|
| 145 | - $lines = explode("\n", $cont); |
|
| 143 | + protected function getNumberOfLines($filename) { |
|
| 144 | + $cont = file_get_contents($filename); |
|
| 145 | + $lines = explode("\n", $cont); |
|
| 146 | 146 | |
| 147 | - // Remove emtpy lines |
|
| 148 | - foreach ($lines as $i => $line) { |
|
| 149 | - if (empty(trim($line))) { |
|
| 150 | - unset($lines[$i]); |
|
| 151 | - } |
|
| 152 | - } |
|
| 147 | + // Remove emtpy lines |
|
| 148 | + foreach ($lines as $i => $line) { |
|
| 149 | + if (empty(trim($line))) { |
|
| 150 | + unset($lines[$i]); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - return count($lines); |
|
| 155 | - } |
|
| 154 | + return count($lines); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | 157 | } |
| 158 | 158 | \ No newline at end of file |
@@ -147,7 +147,7 @@ |
||
| 147 | 147 | // Remove emtpy lines |
| 148 | 148 | foreach ($lines as $i => $line) { |
| 149 | 149 | if (empty(trim($line))) { |
| 150 | - unset($lines[$i]); |
|
| 150 | + unset($lines[ $i ]); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
@@ -12,48 +12,48 @@ |
||
| 12 | 12 | * Test bootstrap, for setting up autoloading |
| 13 | 13 | */ |
| 14 | 14 | class Bootstrap { |
| 15 | - protected static $serviceManager; |
|
| 16 | - |
|
| 17 | - public static function init() { |
|
| 18 | - static::initAutoloader(); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - protected static function initAutoloader() { |
|
| 22 | - $vendorPath = static::findParentPath('vendor'); |
|
| 23 | - |
|
| 24 | - if (file_exists($vendorPath . '/autoload.php')) { |
|
| 25 | - include $vendorPath . '/autoload.php'; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - if (!class_exists('Zend\Loader\AutoloaderFactory')) { |
|
| 29 | - throw new RuntimeException( |
|
| 30 | - 'Unable to load ZF2. Run `php composer.phar install`' |
|
| 31 | - ); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - AutoloaderFactory::factory(array( |
|
| 35 | - 'Zend\Loader\StandardAutoloader' => array( |
|
| 36 | - 'autoregister_zf' => true, |
|
| 37 | - 'namespaces' => array( |
|
| 38 | - __NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__, |
|
| 39 | - ), |
|
| 40 | - ), |
|
| 41 | - )); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - protected static function findParentPath($path) { |
|
| 45 | - $dir = __DIR__; |
|
| 46 | - $previousDir = '.'; |
|
| 47 | - while (!is_dir($dir . '/' . $path)) { |
|
| 48 | - $dir = dirname($dir); |
|
| 49 | - if ($previousDir === $dir) { |
|
| 50 | - return false; |
|
| 51 | - } |
|
| 52 | - $previousDir = $dir; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - return $dir . '/' . $path; |
|
| 56 | - } |
|
| 15 | + protected static $serviceManager; |
|
| 16 | + |
|
| 17 | + public static function init() { |
|
| 18 | + static::initAutoloader(); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + protected static function initAutoloader() { |
|
| 22 | + $vendorPath = static::findParentPath('vendor'); |
|
| 23 | + |
|
| 24 | + if (file_exists($vendorPath . '/autoload.php')) { |
|
| 25 | + include $vendorPath . '/autoload.php'; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + if (!class_exists('Zend\Loader\AutoloaderFactory')) { |
|
| 29 | + throw new RuntimeException( |
|
| 30 | + 'Unable to load ZF2. Run `php composer.phar install`' |
|
| 31 | + ); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + AutoloaderFactory::factory(array( |
|
| 35 | + 'Zend\Loader\StandardAutoloader' => array( |
|
| 36 | + 'autoregister_zf' => true, |
|
| 37 | + 'namespaces' => array( |
|
| 38 | + __NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__, |
|
| 39 | + ), |
|
| 40 | + ), |
|
| 41 | + )); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + protected static function findParentPath($path) { |
|
| 45 | + $dir = __DIR__; |
|
| 46 | + $previousDir = '.'; |
|
| 47 | + while (!is_dir($dir . '/' . $path)) { |
|
| 48 | + $dir = dirname($dir); |
|
| 49 | + if ($previousDir === $dir) { |
|
| 50 | + return false; |
|
| 51 | + } |
|
| 52 | + $previousDir = $dir; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + return $dir . '/' . $path; |
|
| 56 | + } |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | Bootstrap::init(); |
| 60 | 60 | \ No newline at end of file |
@@ -7,25 +7,25 @@ |
||
| 7 | 7 | class UserServiceFactory { |
| 8 | 8 | |
| 9 | 9 | public function __invoke($sm) { |
| 10 | - $config = $sm->get ( 'Config' ); |
|
| 10 | + $config = $sm->get('Config'); |
|
| 11 | 11 | |
| 12 | 12 | // Default |
| 13 | 13 | $not_deletable_users = array(); |
| 14 | - if (isset ( $config ['HtpasswdManager'] ['not_deletable_users'] ) && is_array ( $config ['HtpasswdManager'] ['not_deletable_users'] )) { |
|
| 15 | - $not_deletable_users = $config ['HtpasswdManager'] ['not_deletable_users']; |
|
| 14 | + if (isset ($config [ 'HtpasswdManager' ] [ 'not_deletable_users' ]) && is_array($config [ 'HtpasswdManager' ] [ 'not_deletable_users' ])) { |
|
| 15 | + $not_deletable_users = $config [ 'HtpasswdManager' ] [ 'not_deletable_users' ]; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // Default |
| 19 | 19 | $user_with_management_permission = true; |
| 20 | - if (isset ( $config ['HtpasswdManager'] ['usermanagement_users'] ) && is_array ( $config ['HtpasswdManager'] ['usermanagement_users'] )) { |
|
| 21 | - $user_with_management_permission = $config ['HtpasswdManager'] ['usermanagement_users']; |
|
| 22 | - } else if ($config ['HtpasswdManager'] ['usermanagement_users'] === false) { |
|
| 20 | + if (isset ($config [ 'HtpasswdManager' ] [ 'usermanagement_users' ]) && is_array($config [ 'HtpasswdManager' ] [ 'usermanagement_users' ])) { |
|
| 21 | + $user_with_management_permission = $config [ 'HtpasswdManager' ] [ 'usermanagement_users' ]; |
|
| 22 | + } else if ($config [ 'HtpasswdManager' ] [ 'usermanagement_users' ] === false) { |
|
| 23 | 23 | $user_with_management_permission = false; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $request = $sm->get ( 'Request' ); |
|
| 26 | + $request = $sm->get('Request'); |
|
| 27 | 27 | |
| 28 | - return new UserService ( $request, $not_deletable_users, $user_with_management_permission ); |
|
| 28 | + return new UserService($request, $not_deletable_users, $user_with_management_permission); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | } |
@@ -28,31 +28,31 @@ discard block |
||
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | 30 | public function getCurrentUser() { |
| 31 | - return $this->request->getServer ()->get ( 'REMOTE_USER', null ); |
|
| 31 | + return $this->request->getServer()->get('REMOTE_USER', null); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function isUserDeleteable($username) { |
| 35 | - $eResult = $this->getEventManager ()->trigger ( 'pre_' . __FUNCTION__, $this, array( |
|
| 35 | + $eResult = $this->getEventManager()->trigger('pre_' . __FUNCTION__, $this, array( |
|
| 36 | 36 | $username |
| 37 | - ) ); |
|
| 37 | + )); |
|
| 38 | 38 | |
| 39 | - if ($eResult->stopped ()) |
|
| 40 | - return $eResult->last (); |
|
| 39 | + if ($eResult->stopped()) |
|
| 40 | + return $eResult->last(); |
|
| 41 | 41 | |
| 42 | - return ! in_array ( $username, $this->not_deletable_users ); |
|
| 42 | + return !in_array($username, $this->not_deletable_users); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function isUserAllowedToManageUsers($username) { |
| 46 | - $eResult = $this->getEventManager ()->trigger ( 'pre_' . __FUNCTION__, $this, array( |
|
| 46 | + $eResult = $this->getEventManager()->trigger('pre_' . __FUNCTION__, $this, array( |
|
| 47 | 47 | 'user' => $username |
| 48 | - ) ); |
|
| 48 | + )); |
|
| 49 | 49 | |
| 50 | - if ($eResult->stopped ()) |
|
| 51 | - return $eResult->last (); |
|
| 50 | + if ($eResult->stopped()) |
|
| 51 | + return $eResult->last(); |
|
| 52 | 52 | |
| 53 | 53 | /* If parameter is an array => allow only users in list. IF parameter is boolean, return boolean value */ |
| 54 | - if (is_array ( $this->user_with_management_permission )) { |
|
| 55 | - $accessAllowed = in_array ( $username, $this->user_with_management_permission ); |
|
| 54 | + if (is_array($this->user_with_management_permission)) { |
|
| 55 | + $accessAllowed = in_array($username, $this->user_with_management_permission); |
|
| 56 | 56 | } else { |
| 57 | 57 | $accessAllowed = ($this->user_with_management_permission === true); |
| 58 | 58 | } |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | public function setEventManager(EventManagerInterface $eventManager) { |
| 64 | - $eventManager->setIdentifiers ( array( |
|
| 64 | + $eventManager->setIdentifiers(array( |
|
| 65 | 65 | __CLASS__, |
| 66 | - get_class ( $this ) |
|
| 67 | - ) ); |
|
| 66 | + get_class($this) |
|
| 67 | + )); |
|
| 68 | 68 | $this->eventManager = $eventManager; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -36,8 +36,9 @@ discard block |
||
| 36 | 36 | $username |
| 37 | 37 | ) ); |
| 38 | 38 | |
| 39 | - if ($eResult->stopped ()) |
|
| 40 | - return $eResult->last (); |
|
| 39 | + if ($eResult->stopped ()) { |
|
| 40 | + return $eResult->last (); |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | 43 | return ! in_array ( $username, $this->not_deletable_users ); |
| 43 | 44 | } |
@@ -47,8 +48,9 @@ discard block |
||
| 47 | 48 | 'user' => $username |
| 48 | 49 | ) ); |
| 49 | 50 | |
| 50 | - if ($eResult->stopped ()) |
|
| 51 | - return $eResult->last (); |
|
| 51 | + if ($eResult->stopped ()) { |
|
| 52 | + return $eResult->last (); |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | /* If parameter is an array => allow only users in list. IF parameter is boolean, return boolean value */ |
| 54 | 56 | if (is_array ( $this->user_with_management_permission )) { |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | 'Zend\Loader\StandardAutoloader' => array( |
| 22 | 22 | 'namespaces' => array( |
| 23 | 23 | // if we're in a namespace deeper than one level we need to fix the \ in the path |
| 24 | - __NAMESPACE__ => __DIR__ . '/src/' . str_replace ( '\\', '/', __NAMESPACE__ ) |
|
| 24 | + __NAMESPACE__ => __DIR__ . '/src/' . str_replace('\\', '/', __NAMESPACE__) |
|
| 25 | 25 | ) |
| 26 | 26 | ) |
| 27 | 27 | ); |
@@ -34,23 +34,23 @@ discard block |
||
| 34 | 34 | public function onBootstrap(MvcEvent $e) { |
| 35 | 35 | // You may not need to do this if you're doing it elsewhere in your |
| 36 | 36 | // application |
| 37 | - $eventManager = $e->getApplication ()->getEventManager (); |
|
| 38 | - $moduleRouteListener = new ModuleRouteListener (); |
|
| 39 | - $moduleRouteListener->attach ( $eventManager ); |
|
| 37 | + $eventManager = $e->getApplication()->getEventManager(); |
|
| 38 | + $moduleRouteListener = new ModuleRouteListener(); |
|
| 39 | + $moduleRouteListener->attach($eventManager); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function getServiceConfig() { |
| 43 | 43 | return array( |
| 44 | 44 | 'factories' => array( |
| 45 | - 'HtpasswdManager\Service\HtpasswdService' => function ($sm) { |
|
| 46 | - $config = $sm->get ( 'Config' ); |
|
| 45 | + 'HtpasswdManager\Service\HtpasswdService' => function($sm) { |
|
| 46 | + $config = $sm->get('Config'); |
|
| 47 | 47 | |
| 48 | - if (! isset ( $config ['HtpasswdManager'] ) || ! is_array ( $config ['HtpasswdManager'] ) || ! isset ( $config ['HtpasswdManager'] ['htpasswd'] ) || empty ( $config ['HtpasswdManager'] ['htpasswd'] )) { |
|
| 49 | - throw new \Exception ( 'HtpasswdManager Config not found' ); |
|
| 48 | + if (!isset ($config [ 'HtpasswdManager' ]) || !is_array($config [ 'HtpasswdManager' ]) || !isset ($config [ 'HtpasswdManager' ] [ 'htpasswd' ]) || empty ($config [ 'HtpasswdManager' ] [ 'htpasswd' ])) { |
|
| 49 | + throw new \Exception('HtpasswdManager Config not found'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - $htpasswd_filename = $config ['HtpasswdManager'] ['htpasswd']; |
|
| 53 | - $service = new HtpasswdService ( $htpasswd_filename ); |
|
| 52 | + $htpasswd_filename = $config [ 'HtpasswdManager' ] [ 'htpasswd' ]; |
|
| 53 | + $service = new HtpasswdService($htpasswd_filename); |
|
| 54 | 54 | |
| 55 | 55 | return $service; |
| 56 | 56 | } |