@@ -91,20 +91,20 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function addFolder($path) { |
93 | 93 | $tmpBase = \OC::$server->getTempManager()->getTemporaryFolder(); |
94 | - $path = rtrim($path, '/') . '/'; |
|
94 | + $path = rtrim($path, '/').'/'; |
|
95 | 95 | if ($this->fileExists($path)) { |
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | $parts = explode('/', $path); |
99 | 99 | $folder = $tmpBase; |
100 | 100 | foreach ($parts as $part) { |
101 | - $folder .= '/' . $part; |
|
101 | + $folder .= '/'.$part; |
|
102 | 102 | if (!is_dir($folder)) { |
103 | 103 | mkdir($folder); |
104 | 104 | } |
105 | 105 | } |
106 | - $result = $this->tar->addModify(array($tmpBase . $path), '', $tmpBase); |
|
107 | - rmdir($tmpBase . $path); |
|
106 | + $result = $this->tar->addModify(array($tmpBase.$path), '', $tmpBase); |
|
107 | + rmdir($tmpBase.$path); |
|
108 | 108 | $this->fileList = false; |
109 | 109 | $this->cachedHeaders = false; |
110 | 110 | return $result; |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | //no proper way to delete, rename entire archive, rename file and remake archive |
142 | 142 | $tmp = \OC::$server->getTempManager()->getTemporaryFolder(); |
143 | 143 | $this->tar->extract($tmp); |
144 | - rename($tmp . $source, $tmp . $dest); |
|
144 | + rename($tmp.$source, $tmp.$dest); |
|
145 | 145 | $this->tar = null; |
146 | 146 | unlink($this->path); |
147 | 147 | $types = array(null, 'gz', 'bz'); |
148 | 148 | $this->tar = new \Archive_Tar($this->path, $types[self::getTarType($this->path)]); |
149 | - $this->tar->createModify(array($tmp), '', $tmp . '/'); |
|
149 | + $this->tar->createModify(array($tmp), '', $tmp.'/'); |
|
150 | 150 | $this->fileList = false; |
151 | 151 | $this->cachedHeaders = false; |
152 | 152 | return true; |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | } |
162 | 162 | foreach ($this->cachedHeaders as $header) { |
163 | 163 | if ($file == $header['filename'] |
164 | - or $file . '/' == $header['filename'] |
|
165 | - or '/' . $file . '/' == $header['filename'] |
|
166 | - or '/' . $file == $header['filename'] |
|
164 | + or $file.'/' == $header['filename'] |
|
165 | + or '/'.$file.'/' == $header['filename'] |
|
166 | + or '/'.$file == $header['filename'] |
|
167 | 167 | ) { |
168 | 168 | return $header; |
169 | 169 | } |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | if (!$this->fileExists($path)) { |
263 | 263 | return false; |
264 | 264 | } |
265 | - if ($this->fileExists('/' . $path)) { |
|
266 | - $success = $this->tar->extractList(array('/' . $path), $tmp); |
|
265 | + if ($this->fileExists('/'.$path)) { |
|
266 | + $success = $this->tar->extractList(array('/'.$path), $tmp); |
|
267 | 267 | } else { |
268 | 268 | $success = $this->tar->extractList(array($path), $tmp); |
269 | 269 | } |
270 | 270 | if ($success) { |
271 | - rename($tmp . $path, $dest); |
|
271 | + rename($tmp.$path, $dest); |
|
272 | 272 | } |
273 | 273 | \OCP\Files::rmdirr($tmp); |
274 | 274 | return $success; |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function fileExists($path) { |
294 | 294 | $files = $this->getFiles(); |
295 | - if ((array_search($path, $files) !== false) or (array_search($path . '/', $files) !== false)) { |
|
295 | + if ((array_search($path, $files) !== false) or (array_search($path.'/', $files) !== false)) { |
|
296 | 296 | return true; |
297 | 297 | } else { |
298 | - $folderPath = rtrim($path, '/') . '/'; |
|
298 | + $folderPath = rtrim($path, '/').'/'; |
|
299 | 299 | $pathLength = strlen($folderPath); |
300 | 300 | foreach ($files as $file) { |
301 | 301 | if (strlen($file) > $pathLength and substr($file, 0, $pathLength) == $folderPath) { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | } |
306 | 306 | if ($path[0] != '/') { //not all programs agree on the use of a leading / |
307 | - return $this->fileExists('/' . $path); |
|
307 | + return $this->fileExists('/'.$path); |
|
308 | 308 | } else { |
309 | 309 | return false; |
310 | 310 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | //no proper way to delete, extract entire archive, delete file and remake archive |
326 | 326 | $tmp = \OC::$server->getTempManager()->getTemporaryFolder(); |
327 | 327 | $this->tar->extract($tmp); |
328 | - \OCP\Files::rmdirr($tmp . $path); |
|
328 | + \OCP\Files::rmdirr($tmp.$path); |
|
329 | 329 | $this->tar = null; |
330 | 330 | unlink($this->path); |
331 | 331 | $this->reopen(); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | return fopen($tmpFile, $mode); |
357 | 357 | } else { |
358 | 358 | $handle = fopen($tmpFile, $mode); |
359 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
359 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
360 | 360 | $this->writeBack($tmpFile, $path); |
361 | 361 | }); |
362 | 362 | } |
@@ -37,28 +37,28 @@ discard block |
||
37 | 37 | use Icewind\Streams\CallbackWrapper; |
38 | 38 | use Icewind\Streams\RetryWrapper; |
39 | 39 | |
40 | -class FTP extends StreamWrapper{ |
|
40 | +class FTP extends StreamWrapper { |
|
41 | 41 | private $password; |
42 | 42 | private $user; |
43 | 43 | private $host; |
44 | 44 | private $secure; |
45 | 45 | private $root; |
46 | 46 | |
47 | - private static $tempFiles=array(); |
|
47 | + private static $tempFiles = array(); |
|
48 | 48 | |
49 | 49 | public function __construct($params) { |
50 | 50 | if (isset($params['host']) && isset($params['user']) && isset($params['password'])) { |
51 | - $this->host=$params['host']; |
|
52 | - $this->user=$params['user']; |
|
53 | - $this->password=$params['password']; |
|
51 | + $this->host = $params['host']; |
|
52 | + $this->user = $params['user']; |
|
53 | + $this->password = $params['password']; |
|
54 | 54 | if (isset($params['secure'])) { |
55 | 55 | $this->secure = $params['secure']; |
56 | 56 | } else { |
57 | 57 | $this->secure = false; |
58 | 58 | } |
59 | - $this->root=isset($params['root'])?$params['root']:'/'; |
|
60 | - if ( ! $this->root || $this->root[0]!=='/') { |
|
61 | - $this->root='/'.$this->root; |
|
59 | + $this->root = isset($params['root']) ? $params['root'] : '/'; |
|
60 | + if (!$this->root || $this->root[0] !== '/') { |
|
61 | + $this->root = '/'.$this->root; |
|
62 | 62 | } |
63 | 63 | if (substr($this->root, -1) !== '/') { |
64 | 64 | $this->root .= '/'; |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - public function getId(){ |
|
73 | - return 'ftp::' . $this->user . '@' . $this->host . '/' . $this->root; |
|
72 | + public function getId() { |
|
73 | + return 'ftp::'.$this->user.'@'.$this->host.'/'.$this->root; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | */ |
81 | 81 | public function constructUrl($path) { |
82 | - $url='ftp'; |
|
82 | + $url = 'ftp'; |
|
83 | 83 | if ($this->secure) { |
84 | - $url.='s'; |
|
84 | + $url .= 's'; |
|
85 | 85 | } |
86 | - $url.='://'.urlencode($this->user).':'.urlencode($this->password).'@'.$this->host.$this->root.$path; |
|
86 | + $url .= '://'.urlencode($this->user).':'.urlencode($this->password).'@'.$this->host.$this->root.$path; |
|
87 | 87 | return $url; |
88 | 88 | } |
89 | 89 | |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | return $result; |
103 | 103 | } |
104 | 104 | } |
105 | - public function fopen($path,$mode) { |
|
106 | - switch($mode) { |
|
105 | + public function fopen($path, $mode) { |
|
106 | + switch ($mode) { |
|
107 | 107 | case 'r': |
108 | 108 | case 'rb': |
109 | 109 | case 'w': |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | case 'c': |
124 | 124 | case 'c+': |
125 | 125 | //emulate these |
126 | - if (strrpos($path, '.')!==false) { |
|
127 | - $ext=substr($path, strrpos($path, '.')); |
|
126 | + if (strrpos($path, '.') !== false) { |
|
127 | + $ext = substr($path, strrpos($path, '.')); |
|
128 | 128 | } else { |
129 | - $ext=''; |
|
129 | + $ext = ''; |
|
130 | 130 | } |
131 | 131 | $tmpFile = \OC::$server->getTempManager()->getTemporaryFile(); |
132 | 132 | if ($this->file_exists($path)) { |
133 | 133 | $this->getFile($path, $tmpFile); |
134 | 134 | } |
135 | 135 | $handle = fopen($tmpFile, $mode); |
136 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
136 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
137 | 137 | $this->writeBack($tmpFile, $path); |
138 | 138 | }); |
139 | 139 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | 'post_createUser', |
78 | 78 | $this, |
79 | 79 | 'postCreateUser'); |
80 | - \OC::$server->getUserManager()->listen('\OC\User', 'assignedUserId', function ($uid) { |
|
80 | + \OC::$server->getUserManager()->listen('\OC\User', 'assignedUserId', function($uid) { |
|
81 | 81 | $this->postCreateUser(['uid' => $uid]); |
82 | 82 | }); |
83 | 83 | Util::connectHook('OC_User', |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | 'post_deleteUser', |
90 | 90 | $this, |
91 | 91 | 'postDeleteUser'); |
92 | - \OC::$server->getUserManager()->listen('\OC\User', 'postUnassignedUserId', function ($uid) { |
|
92 | + \OC::$server->getUserManager()->listen('\OC\User', 'postUnassignedUserId', function($uid) { |
|
93 | 93 | $this->postDeleteUser(['uid' => $uid]); |
94 | 94 | }); |
95 | 95 | \OC::$server->getUserManager()->listen('\OC\User', 'postUnassignedUserId', [$this, 'postUnassignedUserId']); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | public function preDeleteUser($params) { |
108 | 108 | $uid = $params['uid']; |
109 | 109 | $this->usersToDelete[$uid] = $this->userManager->get($uid); |
110 | - $this->calendarsToDelete = $this->calDav->getUsersOwnCalendars('principals/users/' . $uid); |
|
111 | - $this->addressBooksToDelete = $this->cardDav->getUsersOwnAddressBooks('principals/users/' . $uid); |
|
110 | + $this->calendarsToDelete = $this->calDav->getUsersOwnCalendars('principals/users/'.$uid); |
|
111 | + $this->addressBooksToDelete = $this->cardDav->getUsersOwnAddressBooks('principals/users/'.$uid); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | public function preUnassignedUserId($uid) { |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | |
118 | 118 | public function postDeleteUser($params) { |
119 | 119 | $uid = $params['uid']; |
120 | - if (isset($this->usersToDelete[$uid])){ |
|
120 | + if (isset($this->usersToDelete[$uid])) { |
|
121 | 121 | $this->syncService->deleteUser($this->usersToDelete[$uid]); |
122 | 122 | } |
123 | 123 | |
124 | 124 | foreach ($this->calendarsToDelete as $calendar) { |
125 | 125 | $this->calDav->deleteCalendar($calendar['id']); |
126 | 126 | } |
127 | - $this->calDav->deleteAllSharesByUser('principals/users/' . $uid); |
|
127 | + $this->calDav->deleteAllSharesByUser('principals/users/'.$uid); |
|
128 | 128 | |
129 | 129 | foreach ($this->addressBooksToDelete as $addressBook) { |
130 | 130 | $this->cardDav->deleteAddressBook($addressBook['id']); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | public function postUnassignedUserId($uid) { |
135 | - if (isset($this->usersToDelete[$uid])){ |
|
135 | + if (isset($this->usersToDelete[$uid])) { |
|
136 | 136 | $this->syncService->deleteUser($this->usersToDelete[$uid]); |
137 | 137 | } |
138 | 138 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | public function firstLogin(IUser $user = null) { |
146 | 146 | if (!is_null($user)) { |
147 | - $principal = 'principals/users/' . $user->getUID(); |
|
147 | + $principal = 'principals/users/'.$user->getUID(); |
|
148 | 148 | if ($this->calDav->getCalendarsForUserCount($principal) === 0) { |
149 | 149 | try { |
150 | 150 | $this->calDav->createCalendar($principal, CalDavBackend::PERSONAL_CALENDAR_URI, [ |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | * @since 5.0.0 |
54 | 54 | * @deprecated 14.0.0 |
55 | 55 | */ |
56 | - static public function rmdirr( $dir ) { |
|
57 | - return \OC_Helper::rmdirr( $dir ); |
|
56 | + static public function rmdirr($dir) { |
|
57 | + return \OC_Helper::rmdirr($dir); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @since 5.0.0 |
66 | 66 | * @deprecated 14.0.0 |
67 | 67 | */ |
68 | - static public function getMimeType( $path ) { |
|
68 | + static public function getMimeType($path) { |
|
69 | 69 | return \OC::$server->getMimeTypeDetector()->detect($path); |
70 | 70 | } |
71 | 71 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | * @since 5.0.0 |
89 | 89 | * @deprecated 14.0.0 |
90 | 90 | */ |
91 | - public static function streamCopy( $source, $target ) { |
|
92 | - list($count, ) = \OC_Helper::streamCopy( $source, $target ); |
|
91 | + public static function streamCopy($source, $target) { |
|
92 | + list($count,) = \OC_Helper::streamCopy($source, $target); |
|
93 | 93 | return $count; |
94 | 94 | } |
95 | 95 | |
@@ -114,6 +114,6 @@ discard block |
||
114 | 114 | * @deprecated 14.0.0 use IAppData instead |
115 | 115 | */ |
116 | 116 | public static function getStorage($app) { |
117 | - return \OC_App::getStorage( $app ); |
|
117 | + return \OC_App::getStorage($app); |
|
118 | 118 | } |
119 | 119 | } |
@@ -31,9 +31,9 @@ |
||
31 | 31 | \OC_JSON::checkAppEnabled('user_ldap'); |
32 | 32 | \OC_JSON::callCheck(); |
33 | 33 | |
34 | -$prefix = (string)$_POST['ldap_serverconfig_chooser']; |
|
34 | +$prefix = (string) $_POST['ldap_serverconfig_chooser']; |
|
35 | 35 | $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig()); |
36 | -if($helper->deleteServerConfiguration($prefix)) { |
|
36 | +if ($helper->deleteServerConfiguration($prefix)) { |
|
37 | 37 | \OC_JSON::success(); |
38 | 38 | } else { |
39 | 39 | $l = \OC::$server->getL10N('user_ldap'); |
@@ -68,7 +68,7 @@ |
||
68 | 68 | try { |
69 | 69 | $ldapWrapper->read($connection->getConnectionResource(), '', 'objectClass=*', array('dn')); |
70 | 70 | } catch (\Exception $e) { |
71 | - if($e->getCode() === 1) { |
|
71 | + if ($e->getCode() === 1) { |
|
72 | 72 | \OC_JSON::error(array('message' => $l->t('Invalid configuration: Anonymous binding is not allowed.'))); |
73 | 73 | exit; |
74 | 74 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | \OC_JSON::checkAppEnabled('user_ldap'); |
30 | 30 | \OC_JSON::callCheck(); |
31 | 31 | |
32 | -$prefix = (string)$_POST['ldap_serverconfig_chooser']; |
|
32 | +$prefix = (string) $_POST['ldap_serverconfig_chooser']; |
|
33 | 33 | $ldapWrapper = new OCA\User_LDAP\LDAP(); |
34 | 34 | $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); |
35 | 35 | $configuration = $connection->getConfiguration(); |
@@ -30,15 +30,15 @@ |
||
30 | 30 | \OC_JSON::checkAppEnabled('user_ldap'); |
31 | 31 | \OC_JSON::callCheck(); |
32 | 32 | |
33 | -$prefix = (string)$_POST['ldap_serverconfig_chooser']; |
|
33 | +$prefix = (string) $_POST['ldap_serverconfig_chooser']; |
|
34 | 34 | |
35 | 35 | // Checkboxes are not submitted, when they are unchecked. Set them manually. |
36 | 36 | // only legacy checkboxes (Advanced and Expert tab) need to be handled here, |
37 | 37 | // the Wizard-like tabs handle it on their own |
38 | 38 | $chkboxes = array('ldap_configuration_active', 'ldap_override_main_server', |
39 | 39 | 'ldap_turn_off_cert_check'); |
40 | -foreach($chkboxes as $boxid) { |
|
41 | - if(!isset($_POST[$boxid])) { |
|
40 | +foreach ($chkboxes as $boxid) { |
|
41 | + if (!isset($_POST[$boxid])) { |
|
42 | 42 | $_POST[$boxid] = 0; |
43 | 43 | } |
44 | 44 | } |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | |
36 | 36 | $l = \OC::$server->getL10N('user_ldap'); |
37 | 37 | |
38 | -if(!isset($_POST['action'])) { |
|
38 | +if (!isset($_POST['action'])) { |
|
39 | 39 | \OC_JSON::error(array('message' => $l->t('No action specified'))); |
40 | 40 | } |
41 | -$action = (string)$_POST['action']; |
|
41 | +$action = (string) $_POST['action']; |
|
42 | 42 | |
43 | 43 | |
44 | -if(!isset($_POST['ldap_serverconfig_chooser'])) { |
|
44 | +if (!isset($_POST['ldap_serverconfig_chooser'])) { |
|
45 | 45 | \OC_JSON::error(array('message' => $l->t('No configuration specified'))); |
46 | 46 | } |
47 | -$prefix = (string)$_POST['ldap_serverconfig_chooser']; |
|
47 | +$prefix = (string) $_POST['ldap_serverconfig_chooser']; |
|
48 | 48 | |
49 | 49 | $ldapWrapper = new \OCA\User_LDAP\LDAP(); |
50 | 50 | $configuration = new \OCA\User_LDAP\Configuration($prefix); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | $wizard = new \OCA\User_LDAP\Wizard($configuration, $ldapWrapper, $access); |
76 | 76 | |
77 | -switch($action) { |
|
77 | +switch ($action) { |
|
78 | 78 | case 'guessPortAndTLS': |
79 | 79 | case 'guessBaseDN': |
80 | 80 | case 'detectEmailAttribute': |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | case 'countInBaseDN': |
94 | 94 | try { |
95 | 95 | $result = $wizard->$action(); |
96 | - if($result !== false) { |
|
96 | + if ($result !== false) { |
|
97 | 97 | \OC_JSON::success($result->getResultArray()); |
98 | 98 | exit; |
99 | 99 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | try { |
110 | 110 | $loginName = $_POST['ldap_test_loginname']; |
111 | 111 | $result = $wizard->$action($loginName); |
112 | - if($result !== false) { |
|
112 | + if ($result !== false) { |
|
113 | 113 | \OC_JSON::success($result->getResultArray()); |
114 | 114 | exit; |
115 | 115 | } |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | case 'save': |
126 | 126 | $key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false; |
127 | 127 | $val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null; |
128 | - if($key === false || is_null($val)) { |
|
128 | + if ($key === false || is_null($val)) { |
|
129 | 129 | \OC_JSON::error(array('message' => $l->t('No data specified'))); |
130 | 130 | exit; |
131 | 131 | } |
132 | 132 | $cfg = array($key => $val); |
133 | 133 | $setParameters = array(); |
134 | 134 | $configuration->setConfiguration($cfg, $setParameters); |
135 | - if(!in_array($key, $setParameters)) { |
|
135 | + if (!in_array($key, $setParameters)) { |
|
136 | 136 | \OC_JSON::error(array('message' => $l->t($key. |
137 | 137 | ' Could not set configuration %s', $setParameters[0]))); |
138 | 138 | exit; |