@@ -24,45 +24,45 @@ |
||
24 | 24 | namespace OC\IntegrityCheck\Iterator; |
25 | 25 | |
26 | 26 | class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator { |
27 | - private $excludedFolders = []; |
|
27 | + private $excludedFolders = []; |
|
28 | 28 | |
29 | - public function __construct(\RecursiveIterator $iterator, $root = '') { |
|
30 | - parent::__construct($iterator); |
|
29 | + public function __construct(\RecursiveIterator $iterator, $root = '') { |
|
30 | + parent::__construct($iterator); |
|
31 | 31 | |
32 | - $appFolders = \OC::$APPSROOTS; |
|
33 | - foreach($appFolders as $key => $appFolder) { |
|
34 | - $appFolders[$key] = rtrim($appFolder['path'], '/'); |
|
35 | - } |
|
32 | + $appFolders = \OC::$APPSROOTS; |
|
33 | + foreach($appFolders as $key => $appFolder) { |
|
34 | + $appFolders[$key] = rtrim($appFolder['path'], '/'); |
|
35 | + } |
|
36 | 36 | |
37 | - $excludedFolders = [ |
|
38 | - rtrim($root . '/data', '/'), |
|
39 | - rtrim($root . '/themes', '/'), |
|
40 | - rtrim($root . '/config', '/'), |
|
41 | - rtrim($root . '/apps', '/'), |
|
42 | - rtrim($root . '/assets', '/'), |
|
43 | - rtrim($root . '/lost+found', '/'), |
|
44 | - // Ignore folders generated by updater since the updater is replaced |
|
45 | - // after the integrity check is run. |
|
46 | - // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846 |
|
47 | - rtrim($root . '/updater', '/'), |
|
48 | - rtrim($root . '/_oc_upgrade', '/'), |
|
49 | - ]; |
|
50 | - $customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', ''); |
|
51 | - if($customDataDir !== '') { |
|
52 | - $excludedFolders[] = rtrim($customDataDir, '/'); |
|
53 | - } |
|
37 | + $excludedFolders = [ |
|
38 | + rtrim($root . '/data', '/'), |
|
39 | + rtrim($root . '/themes', '/'), |
|
40 | + rtrim($root . '/config', '/'), |
|
41 | + rtrim($root . '/apps', '/'), |
|
42 | + rtrim($root . '/assets', '/'), |
|
43 | + rtrim($root . '/lost+found', '/'), |
|
44 | + // Ignore folders generated by updater since the updater is replaced |
|
45 | + // after the integrity check is run. |
|
46 | + // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846 |
|
47 | + rtrim($root . '/updater', '/'), |
|
48 | + rtrim($root . '/_oc_upgrade', '/'), |
|
49 | + ]; |
|
50 | + $customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', ''); |
|
51 | + if($customDataDir !== '') { |
|
52 | + $excludedFolders[] = rtrim($customDataDir, '/'); |
|
53 | + } |
|
54 | 54 | |
55 | - $this->excludedFolders = array_merge($excludedFolders, $appFolders); |
|
56 | - } |
|
55 | + $this->excludedFolders = array_merge($excludedFolders, $appFolders); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function accept() { |
|
62 | - return !in_array( |
|
63 | - $this->current()->getPathName(), |
|
64 | - $this->excludedFolders, |
|
65 | - true |
|
66 | - ); |
|
67 | - } |
|
58 | + /** |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function accept() { |
|
62 | + return !in_array( |
|
63 | + $this->current()->getPathName(), |
|
64 | + $this->excludedFolders, |
|
65 | + true |
|
66 | + ); |
|
67 | + } |
|
68 | 68 | } |
@@ -29,21 +29,21 @@ |
||
29 | 29 | * @package OC\IntegrityCheck\Helpers |
30 | 30 | */ |
31 | 31 | class EnvironmentHelper { |
32 | - /** |
|
33 | - * Provides \OC::$SERVERROOT |
|
34 | - * |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function getServerRoot() { |
|
38 | - return rtrim(\OC::$SERVERROOT, '/'); |
|
39 | - } |
|
32 | + /** |
|
33 | + * Provides \OC::$SERVERROOT |
|
34 | + * |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function getServerRoot() { |
|
38 | + return rtrim(\OC::$SERVERROOT, '/'); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Provides \OC_Util::getChannel() |
|
43 | - * |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function getChannel() { |
|
47 | - return \OC_Util::getChannel(); |
|
48 | - } |
|
41 | + /** |
|
42 | + * Provides \OC_Util::getChannel() |
|
43 | + * |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function getChannel() { |
|
47 | + return \OC_Util::getChannel(); |
|
48 | + } |
|
49 | 49 | } |
@@ -29,57 +29,57 @@ |
||
29 | 29 | * @package OC\IntegrityCheck\Helpers |
30 | 30 | */ |
31 | 31 | class FileAccessHelper { |
32 | - /** |
|
33 | - * Wrapper around file_get_contents($filename, $data) |
|
34 | - * |
|
35 | - * @param string $filename |
|
36 | - * @return string|false |
|
37 | - */ |
|
38 | - public function file_get_contents($filename) { |
|
39 | - return file_get_contents($filename); |
|
40 | - } |
|
32 | + /** |
|
33 | + * Wrapper around file_get_contents($filename, $data) |
|
34 | + * |
|
35 | + * @param string $filename |
|
36 | + * @return string|false |
|
37 | + */ |
|
38 | + public function file_get_contents($filename) { |
|
39 | + return file_get_contents($filename); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Wrapper around file_exists($filename) |
|
44 | - * |
|
45 | - * @param string $filename |
|
46 | - * @return bool |
|
47 | - */ |
|
48 | - public function file_exists($filename) { |
|
49 | - return file_exists($filename); |
|
50 | - } |
|
42 | + /** |
|
43 | + * Wrapper around file_exists($filename) |
|
44 | + * |
|
45 | + * @param string $filename |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | + public function file_exists($filename) { |
|
49 | + return file_exists($filename); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Wrapper around file_put_contents($filename, $data) |
|
54 | - * |
|
55 | - * @param string $filename |
|
56 | - * @param string $data |
|
57 | - * @return int |
|
58 | - * @throws \Exception |
|
59 | - */ |
|
60 | - public function file_put_contents($filename, $data) { |
|
61 | - $bytesWritten = @file_put_contents($filename, $data); |
|
62 | - if ($bytesWritten === false || $bytesWritten !== strlen($data)){ |
|
63 | - throw new \Exception('Failed to write into ' . $filename); |
|
64 | - } |
|
65 | - return $bytesWritten; |
|
66 | - } |
|
52 | + /** |
|
53 | + * Wrapper around file_put_contents($filename, $data) |
|
54 | + * |
|
55 | + * @param string $filename |
|
56 | + * @param string $data |
|
57 | + * @return int |
|
58 | + * @throws \Exception |
|
59 | + */ |
|
60 | + public function file_put_contents($filename, $data) { |
|
61 | + $bytesWritten = @file_put_contents($filename, $data); |
|
62 | + if ($bytesWritten === false || $bytesWritten !== strlen($data)){ |
|
63 | + throw new \Exception('Failed to write into ' . $filename); |
|
64 | + } |
|
65 | + return $bytesWritten; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param string $path |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - public function is_writable($path) { |
|
73 | - return is_writable($path); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @param string $path |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + public function is_writable($path) { |
|
73 | + return is_writable($path); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string $path |
|
78 | - * @throws \Exception |
|
79 | - */ |
|
80 | - public function assertDirectoryExists($path) { |
|
81 | - if (!is_dir($path)) { |
|
82 | - throw new \Exception('Directory ' . $path . ' does not exist.'); |
|
83 | - } |
|
84 | - } |
|
76 | + /** |
|
77 | + * @param string $path |
|
78 | + * @throws \Exception |
|
79 | + */ |
|
80 | + public function assertDirectoryExists($path) { |
|
81 | + if (!is_dir($path)) { |
|
82 | + throw new \Exception('Directory ' . $path . ' does not exist.'); |
|
83 | + } |
|
84 | + } |
|
85 | 85 | } |
@@ -30,28 +30,28 @@ |
||
30 | 30 | * @package OC\IntegrityCheck\Helpers |
31 | 31 | */ |
32 | 32 | class AppLocator { |
33 | - /** |
|
34 | - * Provides \OC_App::getAppPath($appId) |
|
35 | - * |
|
36 | - * @param string $appId |
|
37 | - * @return string |
|
38 | - * @throws \Exception If the app cannot be found |
|
39 | - */ |
|
40 | - public function getAppPath($appId) { |
|
41 | - $path = \OC_App::getAppPath($appId); |
|
42 | - if($path === false) { |
|
33 | + /** |
|
34 | + * Provides \OC_App::getAppPath($appId) |
|
35 | + * |
|
36 | + * @param string $appId |
|
37 | + * @return string |
|
38 | + * @throws \Exception If the app cannot be found |
|
39 | + */ |
|
40 | + public function getAppPath($appId) { |
|
41 | + $path = \OC_App::getAppPath($appId); |
|
42 | + if($path === false) { |
|
43 | 43 | |
44 | - throw new \Exception('App not found'); |
|
45 | - } |
|
46 | - return $path; |
|
47 | - } |
|
44 | + throw new \Exception('App not found'); |
|
45 | + } |
|
46 | + return $path; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Providers \OC_App::getAllApps() |
|
51 | - * |
|
52 | - * @return array |
|
53 | - */ |
|
54 | - public function getAllApps() { |
|
55 | - return \OC_App::getAllApps(); |
|
56 | - } |
|
49 | + /** |
|
50 | + * Providers \OC_App::getAllApps() |
|
51 | + * |
|
52 | + * @return array |
|
53 | + */ |
|
54 | + public function getAllApps() { |
|
55 | + return \OC_App::getAllApps(); |
|
56 | + } |
|
57 | 57 | } |
@@ -35,46 +35,46 @@ |
||
35 | 35 | */ |
36 | 36 | class HintException extends \Exception { |
37 | 37 | |
38 | - private $hint; |
|
38 | + private $hint; |
|
39 | 39 | |
40 | - /** |
|
41 | - * HintException constructor. |
|
42 | - * |
|
43 | - * @param string $message The error message. It will be not revealed to the |
|
44 | - * the user (unless the hint is empty) and thus |
|
45 | - * should be not translated. |
|
46 | - * @param string $hint A useful message that is presented to the end |
|
47 | - * user. It should be translated, but must not |
|
48 | - * contain sensitive data. |
|
49 | - * @param int $code |
|
50 | - * @param \Exception|null $previous |
|
51 | - */ |
|
52 | - public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) { |
|
53 | - $this->hint = $hint; |
|
54 | - parent::__construct($message, $code, $previous); |
|
55 | - } |
|
40 | + /** |
|
41 | + * HintException constructor. |
|
42 | + * |
|
43 | + * @param string $message The error message. It will be not revealed to the |
|
44 | + * the user (unless the hint is empty) and thus |
|
45 | + * should be not translated. |
|
46 | + * @param string $hint A useful message that is presented to the end |
|
47 | + * user. It should be translated, but must not |
|
48 | + * contain sensitive data. |
|
49 | + * @param int $code |
|
50 | + * @param \Exception|null $previous |
|
51 | + */ |
|
52 | + public function __construct($message, $hint = '', $code = 0, \Exception $previous = null) { |
|
53 | + $this->hint = $hint; |
|
54 | + parent::__construct($message, $code, $previous); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Returns a string representation of this Exception that includes the error |
|
59 | - * code, the message and the hint. |
|
60 | - * |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - public function __toString() { |
|
64 | - return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n"; |
|
65 | - } |
|
57 | + /** |
|
58 | + * Returns a string representation of this Exception that includes the error |
|
59 | + * code, the message and the hint. |
|
60 | + * |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + public function __toString() { |
|
64 | + return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n"; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Returns the hint with the intention to be presented to the end user. If |
|
69 | - * an empty hint was specified upon instatiation, the message is returned |
|
70 | - * instead. |
|
71 | - * |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function getHint() { |
|
75 | - if (empty($this->hint)) { |
|
76 | - return $this->message; |
|
77 | - } |
|
78 | - return $this->hint; |
|
79 | - } |
|
67 | + /** |
|
68 | + * Returns the hint with the intention to be presented to the end user. If |
|
69 | + * an empty hint was specified upon instatiation, the message is returned |
|
70 | + * instead. |
|
71 | + * |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function getHint() { |
|
75 | + if (empty($this->hint)) { |
|
76 | + return $this->message; |
|
77 | + } |
|
78 | + return $this->hint; |
|
79 | + } |
|
80 | 80 | } |
@@ -29,136 +29,136 @@ |
||
29 | 29 | * capabilities. |
30 | 30 | */ |
31 | 31 | abstract class Backend implements UserInterface { |
32 | - /** |
|
33 | - * error code for functions not provided by the user backend |
|
34 | - */ |
|
35 | - const NOT_IMPLEMENTED = -501; |
|
32 | + /** |
|
33 | + * error code for functions not provided by the user backend |
|
34 | + */ |
|
35 | + const NOT_IMPLEMENTED = -501; |
|
36 | 36 | |
37 | - /** |
|
38 | - * actions that user backends can define |
|
39 | - */ |
|
40 | - const CREATE_USER = 1; // 1 << 0 |
|
41 | - const SET_PASSWORD = 16; // 1 << 4 |
|
42 | - const CHECK_PASSWORD = 256; // 1 << 8 |
|
43 | - const GET_HOME = 4096; // 1 << 12 |
|
44 | - const GET_DISPLAYNAME = 65536; // 1 << 16 |
|
45 | - const SET_DISPLAYNAME = 1048576; // 1 << 20 |
|
46 | - const PROVIDE_AVATAR = 16777216; // 1 << 24 |
|
47 | - const COUNT_USERS = 268435456; // 1 << 28 |
|
37 | + /** |
|
38 | + * actions that user backends can define |
|
39 | + */ |
|
40 | + const CREATE_USER = 1; // 1 << 0 |
|
41 | + const SET_PASSWORD = 16; // 1 << 4 |
|
42 | + const CHECK_PASSWORD = 256; // 1 << 8 |
|
43 | + const GET_HOME = 4096; // 1 << 12 |
|
44 | + const GET_DISPLAYNAME = 65536; // 1 << 16 |
|
45 | + const SET_DISPLAYNAME = 1048576; // 1 << 20 |
|
46 | + const PROVIDE_AVATAR = 16777216; // 1 << 24 |
|
47 | + const COUNT_USERS = 268435456; // 1 << 28 |
|
48 | 48 | |
49 | - protected $possibleActions = array( |
|
50 | - self::CREATE_USER => 'createUser', |
|
51 | - self::SET_PASSWORD => 'setPassword', |
|
52 | - self::CHECK_PASSWORD => 'checkPassword', |
|
53 | - self::GET_HOME => 'getHome', |
|
54 | - self::GET_DISPLAYNAME => 'getDisplayName', |
|
55 | - self::SET_DISPLAYNAME => 'setDisplayName', |
|
56 | - self::PROVIDE_AVATAR => 'canChangeAvatar', |
|
57 | - self::COUNT_USERS => 'countUsers', |
|
58 | - ); |
|
49 | + protected $possibleActions = array( |
|
50 | + self::CREATE_USER => 'createUser', |
|
51 | + self::SET_PASSWORD => 'setPassword', |
|
52 | + self::CHECK_PASSWORD => 'checkPassword', |
|
53 | + self::GET_HOME => 'getHome', |
|
54 | + self::GET_DISPLAYNAME => 'getDisplayName', |
|
55 | + self::SET_DISPLAYNAME => 'setDisplayName', |
|
56 | + self::PROVIDE_AVATAR => 'canChangeAvatar', |
|
57 | + self::COUNT_USERS => 'countUsers', |
|
58 | + ); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Get all supported actions |
|
62 | - * @return int bitwise-or'ed actions |
|
63 | - * |
|
64 | - * Returns the supported actions as int to be |
|
65 | - * compared with self::CREATE_USER etc. |
|
66 | - */ |
|
67 | - public function getSupportedActions() { |
|
68 | - $actions = 0; |
|
69 | - foreach($this->possibleActions AS $action => $methodName) { |
|
70 | - if(method_exists($this, $methodName)) { |
|
71 | - $actions |= $action; |
|
72 | - } |
|
73 | - } |
|
60 | + /** |
|
61 | + * Get all supported actions |
|
62 | + * @return int bitwise-or'ed actions |
|
63 | + * |
|
64 | + * Returns the supported actions as int to be |
|
65 | + * compared with self::CREATE_USER etc. |
|
66 | + */ |
|
67 | + public function getSupportedActions() { |
|
68 | + $actions = 0; |
|
69 | + foreach($this->possibleActions AS $action => $methodName) { |
|
70 | + if(method_exists($this, $methodName)) { |
|
71 | + $actions |= $action; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - return $actions; |
|
76 | - } |
|
75 | + return $actions; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Check if backend implements actions |
|
80 | - * @param int $actions bitwise-or'ed actions |
|
81 | - * @return boolean |
|
82 | - * |
|
83 | - * Returns the supported actions as int to be |
|
84 | - * compared with self::CREATE_USER etc. |
|
85 | - */ |
|
86 | - public function implementsActions($actions) { |
|
87 | - return (bool)($this->getSupportedActions() & $actions); |
|
88 | - } |
|
78 | + /** |
|
79 | + * Check if backend implements actions |
|
80 | + * @param int $actions bitwise-or'ed actions |
|
81 | + * @return boolean |
|
82 | + * |
|
83 | + * Returns the supported actions as int to be |
|
84 | + * compared with self::CREATE_USER etc. |
|
85 | + */ |
|
86 | + public function implementsActions($actions) { |
|
87 | + return (bool)($this->getSupportedActions() & $actions); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * delete a user |
|
92 | - * @param string $uid The username of the user to delete |
|
93 | - * @return bool |
|
94 | - * |
|
95 | - * Deletes a user |
|
96 | - */ |
|
97 | - public function deleteUser( $uid ) { |
|
98 | - return false; |
|
99 | - } |
|
90 | + /** |
|
91 | + * delete a user |
|
92 | + * @param string $uid The username of the user to delete |
|
93 | + * @return bool |
|
94 | + * |
|
95 | + * Deletes a user |
|
96 | + */ |
|
97 | + public function deleteUser( $uid ) { |
|
98 | + return false; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Get a list of all users |
|
103 | - * |
|
104 | - * @param string $search |
|
105 | - * @param null|int $limit |
|
106 | - * @param null|int $offset |
|
107 | - * @return string[] an array of all uids |
|
108 | - */ |
|
109 | - public function getUsers($search = '', $limit = null, $offset = null) { |
|
110 | - return array(); |
|
111 | - } |
|
101 | + /** |
|
102 | + * Get a list of all users |
|
103 | + * |
|
104 | + * @param string $search |
|
105 | + * @param null|int $limit |
|
106 | + * @param null|int $offset |
|
107 | + * @return string[] an array of all uids |
|
108 | + */ |
|
109 | + public function getUsers($search = '', $limit = null, $offset = null) { |
|
110 | + return array(); |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * check if a user exists |
|
115 | - * @param string $uid the username |
|
116 | - * @return boolean |
|
117 | - */ |
|
118 | - public function userExists($uid) { |
|
119 | - return false; |
|
120 | - } |
|
113 | + /** |
|
114 | + * check if a user exists |
|
115 | + * @param string $uid the username |
|
116 | + * @return boolean |
|
117 | + */ |
|
118 | + public function userExists($uid) { |
|
119 | + return false; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * get the user's home directory |
|
124 | - * @param string $uid the username |
|
125 | - * @return boolean |
|
126 | - */ |
|
127 | - public function getHome($uid) { |
|
128 | - return false; |
|
129 | - } |
|
122 | + /** |
|
123 | + * get the user's home directory |
|
124 | + * @param string $uid the username |
|
125 | + * @return boolean |
|
126 | + */ |
|
127 | + public function getHome($uid) { |
|
128 | + return false; |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * get display name of the user |
|
133 | - * @param string $uid user ID of the user |
|
134 | - * @return string display name |
|
135 | - */ |
|
136 | - public function getDisplayName($uid) { |
|
137 | - return $uid; |
|
138 | - } |
|
131 | + /** |
|
132 | + * get display name of the user |
|
133 | + * @param string $uid user ID of the user |
|
134 | + * @return string display name |
|
135 | + */ |
|
136 | + public function getDisplayName($uid) { |
|
137 | + return $uid; |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * Get a list of all display names and user ids. |
|
142 | - * |
|
143 | - * @param string $search |
|
144 | - * @param string|null $limit |
|
145 | - * @param string|null $offset |
|
146 | - * @return array an array of all displayNames (value) and the corresponding uids (key) |
|
147 | - */ |
|
148 | - public function getDisplayNames($search = '', $limit = null, $offset = null) { |
|
149 | - $displayNames = array(); |
|
150 | - $users = $this->getUsers($search, $limit, $offset); |
|
151 | - foreach ( $users as $user) { |
|
152 | - $displayNames[$user] = $user; |
|
153 | - } |
|
154 | - return $displayNames; |
|
155 | - } |
|
140 | + /** |
|
141 | + * Get a list of all display names and user ids. |
|
142 | + * |
|
143 | + * @param string $search |
|
144 | + * @param string|null $limit |
|
145 | + * @param string|null $offset |
|
146 | + * @return array an array of all displayNames (value) and the corresponding uids (key) |
|
147 | + */ |
|
148 | + public function getDisplayNames($search = '', $limit = null, $offset = null) { |
|
149 | + $displayNames = array(); |
|
150 | + $users = $this->getUsers($search, $limit, $offset); |
|
151 | + foreach ( $users as $user) { |
|
152 | + $displayNames[$user] = $user; |
|
153 | + } |
|
154 | + return $displayNames; |
|
155 | + } |
|
156 | 156 | |
157 | - /** |
|
158 | - * Check if a user list is available or not |
|
159 | - * @return boolean if users can be listed or not |
|
160 | - */ |
|
161 | - public function hasUserListings() { |
|
162 | - return false; |
|
163 | - } |
|
157 | + /** |
|
158 | + * Check if a user list is available or not |
|
159 | + * @return boolean if users can be listed or not |
|
160 | + */ |
|
161 | + public function hasUserListings() { |
|
162 | + return false; |
|
163 | + } |
|
164 | 164 | } |
@@ -26,79 +26,79 @@ |
||
26 | 26 | use OCP\Diagnostics\IEvent; |
27 | 27 | |
28 | 28 | class Event implements IEvent { |
29 | - /** |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - protected $id; |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + protected $id; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var float |
|
36 | - */ |
|
37 | - protected $start; |
|
34 | + /** |
|
35 | + * @var float |
|
36 | + */ |
|
37 | + protected $start; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var float |
|
41 | - */ |
|
42 | - protected $end; |
|
39 | + /** |
|
40 | + * @var float |
|
41 | + */ |
|
42 | + protected $end; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - protected $description; |
|
44 | + /** |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + protected $description; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param string $id |
|
51 | - * @param string $description |
|
52 | - * @param float $start |
|
53 | - */ |
|
54 | - public function __construct($id, $description, $start) { |
|
55 | - $this->id = $id; |
|
56 | - $this->description = $description; |
|
57 | - $this->start = $start; |
|
58 | - } |
|
49 | + /** |
|
50 | + * @param string $id |
|
51 | + * @param string $description |
|
52 | + * @param float $start |
|
53 | + */ |
|
54 | + public function __construct($id, $description, $start) { |
|
55 | + $this->id = $id; |
|
56 | + $this->description = $description; |
|
57 | + $this->start = $start; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param float $time |
|
62 | - */ |
|
63 | - public function end($time) { |
|
64 | - $this->end = $time; |
|
65 | - } |
|
60 | + /** |
|
61 | + * @param float $time |
|
62 | + */ |
|
63 | + public function end($time) { |
|
64 | + $this->end = $time; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @return float |
|
69 | - */ |
|
70 | - public function getStart() { |
|
71 | - return $this->start; |
|
72 | - } |
|
67 | + /** |
|
68 | + * @return float |
|
69 | + */ |
|
70 | + public function getStart() { |
|
71 | + return $this->start; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function getId() { |
|
78 | - return $this->id; |
|
79 | - } |
|
74 | + /** |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function getId() { |
|
78 | + return $this->id; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function getDescription() { |
|
85 | - return $this->description; |
|
86 | - } |
|
81 | + /** |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function getDescription() { |
|
85 | + return $this->description; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @return float |
|
90 | - */ |
|
91 | - public function getEnd() { |
|
92 | - return $this->end; |
|
93 | - } |
|
88 | + /** |
|
89 | + * @return float |
|
90 | + */ |
|
91 | + public function getEnd() { |
|
92 | + return $this->end; |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @return float |
|
97 | - */ |
|
98 | - public function getDuration() { |
|
99 | - if (!$this->end) { |
|
100 | - $this->end = microtime(true); |
|
101 | - } |
|
102 | - return $this->end - $this->start; |
|
103 | - } |
|
95 | + /** |
|
96 | + * @return float |
|
97 | + */ |
|
98 | + public function getDuration() { |
|
99 | + if (!$this->end) { |
|
100 | + $this->end = microtime(true); |
|
101 | + } |
|
102 | + return $this->end - $this->start; |
|
103 | + } |
|
104 | 104 | } |
@@ -29,100 +29,100 @@ |
||
29 | 29 | use OCP\ISession; |
30 | 30 | |
31 | 31 | class DateTimeZone implements IDateTimeZone { |
32 | - /** @var IConfig */ |
|
33 | - protected $config; |
|
32 | + /** @var IConfig */ |
|
33 | + protected $config; |
|
34 | 34 | |
35 | - /** @var ISession */ |
|
36 | - protected $session; |
|
35 | + /** @var ISession */ |
|
36 | + protected $session; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Constructor |
|
40 | - * |
|
41 | - * @param IConfig $config |
|
42 | - * @param ISession $session |
|
43 | - */ |
|
44 | - public function __construct(IConfig $config, ISession $session) { |
|
45 | - $this->config = $config; |
|
46 | - $this->session = $session; |
|
47 | - } |
|
38 | + /** |
|
39 | + * Constructor |
|
40 | + * |
|
41 | + * @param IConfig $config |
|
42 | + * @param ISession $session |
|
43 | + */ |
|
44 | + public function __construct(IConfig $config, ISession $session) { |
|
45 | + $this->config = $config; |
|
46 | + $this->session = $session; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Get the timezone of the current user, based on his session information and config data |
|
51 | - * |
|
52 | - * @param bool|int $timestamp |
|
53 | - * @return \DateTimeZone |
|
54 | - */ |
|
55 | - public function getTimeZone($timestamp = false) { |
|
56 | - $timeZone = $this->config->getUserValue($this->session->get('user_id'), 'core', 'timezone', null); |
|
57 | - if ($timeZone === null) { |
|
58 | - if ($this->session->exists('timezone')) { |
|
59 | - return $this->guessTimeZoneFromOffset($this->session->get('timezone'), $timestamp); |
|
60 | - } |
|
61 | - $timeZone = $this->getDefaultTimeZone(); |
|
62 | - } |
|
49 | + /** |
|
50 | + * Get the timezone of the current user, based on his session information and config data |
|
51 | + * |
|
52 | + * @param bool|int $timestamp |
|
53 | + * @return \DateTimeZone |
|
54 | + */ |
|
55 | + public function getTimeZone($timestamp = false) { |
|
56 | + $timeZone = $this->config->getUserValue($this->session->get('user_id'), 'core', 'timezone', null); |
|
57 | + if ($timeZone === null) { |
|
58 | + if ($this->session->exists('timezone')) { |
|
59 | + return $this->guessTimeZoneFromOffset($this->session->get('timezone'), $timestamp); |
|
60 | + } |
|
61 | + $timeZone = $this->getDefaultTimeZone(); |
|
62 | + } |
|
63 | 63 | |
64 | - try { |
|
65 | - return new \DateTimeZone($timeZone); |
|
66 | - } catch (\Exception $e) { |
|
67 | - \OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", \OCP\Util::DEBUG); |
|
68 | - return new \DateTimeZone($this->getDefaultTimeZone()); |
|
69 | - } |
|
70 | - } |
|
64 | + try { |
|
65 | + return new \DateTimeZone($timeZone); |
|
66 | + } catch (\Exception $e) { |
|
67 | + \OCP\Util::writeLog('datetimezone', 'Failed to created DateTimeZone "' . $timeZone . "'", \OCP\Util::DEBUG); |
|
68 | + return new \DateTimeZone($this->getDefaultTimeZone()); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Guess the DateTimeZone for a given offset |
|
74 | - * |
|
75 | - * We first try to find a Etc/GMT* timezone, if that does not exist, |
|
76 | - * we try to find it manually, before falling back to UTC. |
|
77 | - * |
|
78 | - * @param mixed $offset |
|
79 | - * @param bool|int $timestamp |
|
80 | - * @return \DateTimeZone |
|
81 | - */ |
|
82 | - protected function guessTimeZoneFromOffset($offset, $timestamp) { |
|
83 | - try { |
|
84 | - // Note: the timeZone name is the inverse to the offset, |
|
85 | - // so a positive offset means negative timeZone |
|
86 | - // and the other way around. |
|
87 | - if ($offset > 0) { |
|
88 | - $timeZone = 'Etc/GMT-' . $offset; |
|
89 | - } else { |
|
90 | - $timeZone = 'Etc/GMT+' . abs($offset); |
|
91 | - } |
|
72 | + /** |
|
73 | + * Guess the DateTimeZone for a given offset |
|
74 | + * |
|
75 | + * We first try to find a Etc/GMT* timezone, if that does not exist, |
|
76 | + * we try to find it manually, before falling back to UTC. |
|
77 | + * |
|
78 | + * @param mixed $offset |
|
79 | + * @param bool|int $timestamp |
|
80 | + * @return \DateTimeZone |
|
81 | + */ |
|
82 | + protected function guessTimeZoneFromOffset($offset, $timestamp) { |
|
83 | + try { |
|
84 | + // Note: the timeZone name is the inverse to the offset, |
|
85 | + // so a positive offset means negative timeZone |
|
86 | + // and the other way around. |
|
87 | + if ($offset > 0) { |
|
88 | + $timeZone = 'Etc/GMT-' . $offset; |
|
89 | + } else { |
|
90 | + $timeZone = 'Etc/GMT+' . abs($offset); |
|
91 | + } |
|
92 | 92 | |
93 | - return new \DateTimeZone($timeZone); |
|
94 | - } catch (\Exception $e) { |
|
95 | - // If the offset has no Etc/GMT* timezone, |
|
96 | - // we try to guess one timezone that has the same offset |
|
97 | - foreach (\DateTimeZone::listIdentifiers() as $timeZone) { |
|
98 | - $dtz = new \DateTimeZone($timeZone); |
|
99 | - $dateTime = new \DateTime(); |
|
93 | + return new \DateTimeZone($timeZone); |
|
94 | + } catch (\Exception $e) { |
|
95 | + // If the offset has no Etc/GMT* timezone, |
|
96 | + // we try to guess one timezone that has the same offset |
|
97 | + foreach (\DateTimeZone::listIdentifiers() as $timeZone) { |
|
98 | + $dtz = new \DateTimeZone($timeZone); |
|
99 | + $dateTime = new \DateTime(); |
|
100 | 100 | |
101 | - if ($timestamp !== false) { |
|
102 | - $dateTime->setTimestamp($timestamp); |
|
103 | - } |
|
101 | + if ($timestamp !== false) { |
|
102 | + $dateTime->setTimestamp($timestamp); |
|
103 | + } |
|
104 | 104 | |
105 | - $dtOffset = $dtz->getOffset($dateTime); |
|
106 | - if ($dtOffset == 3600 * $offset) { |
|
107 | - return $dtz; |
|
108 | - } |
|
109 | - } |
|
105 | + $dtOffset = $dtz->getOffset($dateTime); |
|
106 | + if ($dtOffset == 3600 * $offset) { |
|
107 | + return $dtz; |
|
108 | + } |
|
109 | + } |
|
110 | 110 | |
111 | - // No timezone found, fallback to UTC |
|
112 | - \OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "' . $offset . "'", \OCP\Util::DEBUG); |
|
113 | - return new \DateTimeZone($this->getDefaultTimeZone()); |
|
114 | - } |
|
115 | - } |
|
111 | + // No timezone found, fallback to UTC |
|
112 | + \OCP\Util::writeLog('datetimezone', 'Failed to find DateTimeZone for offset "' . $offset . "'", \OCP\Util::DEBUG); |
|
113 | + return new \DateTimeZone($this->getDefaultTimeZone()); |
|
114 | + } |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Get the default timezone of the server |
|
119 | - * |
|
120 | - * Falls back to UTC if it is not yet set. |
|
121 | - * |
|
122 | - * @return string |
|
123 | - */ |
|
124 | - protected function getDefaultTimeZone() { |
|
125 | - $serverTimeZone = date_default_timezone_get(); |
|
126 | - return $serverTimeZone ?: 'UTC'; |
|
127 | - } |
|
117 | + /** |
|
118 | + * Get the default timezone of the server |
|
119 | + * |
|
120 | + * Falls back to UTC if it is not yet set. |
|
121 | + * |
|
122 | + * @return string |
|
123 | + */ |
|
124 | + protected function getDefaultTimeZone() { |
|
125 | + $serverTimeZone = date_default_timezone_get(); |
|
126 | + return $serverTimeZone ?: 'UTC'; |
|
127 | + } |
|
128 | 128 | } |
@@ -33,47 +33,47 @@ |
||
33 | 33 | */ |
34 | 34 | class TagMapper extends Mapper { |
35 | 35 | |
36 | - /** |
|
37 | - * Constructor. |
|
38 | - * |
|
39 | - * @param IDBConnection $db Instance of the Db abstraction layer. |
|
40 | - */ |
|
41 | - public function __construct(IDBConnection $db) { |
|
42 | - parent::__construct($db, 'vcategory', 'OC\Tagging\Tag'); |
|
43 | - } |
|
36 | + /** |
|
37 | + * Constructor. |
|
38 | + * |
|
39 | + * @param IDBConnection $db Instance of the Db abstraction layer. |
|
40 | + */ |
|
41 | + public function __construct(IDBConnection $db) { |
|
42 | + parent::__construct($db, 'vcategory', 'OC\Tagging\Tag'); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Load tags from the database. |
|
47 | - * |
|
48 | - * @param array|string $owners The user(s) whose tags we are going to load. |
|
49 | - * @param string $type The type of item for which we are loading tags. |
|
50 | - * @return array An array of Tag objects. |
|
51 | - */ |
|
52 | - public function loadTags($owners, $type) { |
|
53 | - if(!is_array($owners)) { |
|
54 | - $owners = array($owners); |
|
55 | - } |
|
45 | + /** |
|
46 | + * Load tags from the database. |
|
47 | + * |
|
48 | + * @param array|string $owners The user(s) whose tags we are going to load. |
|
49 | + * @param string $type The type of item for which we are loading tags. |
|
50 | + * @return array An array of Tag objects. |
|
51 | + */ |
|
52 | + public function loadTags($owners, $type) { |
|
53 | + if(!is_array($owners)) { |
|
54 | + $owners = array($owners); |
|
55 | + } |
|
56 | 56 | |
57 | - $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` ' |
|
58 | - . 'WHERE `uid` IN (' . str_repeat('?,', count($owners)-1) . '?) AND `type` = ? ORDER BY `category`'; |
|
59 | - return $this->findEntities($sql, array_merge($owners, array($type))); |
|
60 | - } |
|
57 | + $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` ' |
|
58 | + . 'WHERE `uid` IN (' . str_repeat('?,', count($owners)-1) . '?) AND `type` = ? ORDER BY `category`'; |
|
59 | + return $this->findEntities($sql, array_merge($owners, array($type))); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Check if a given Tag object already exists in the database. |
|
64 | - * |
|
65 | - * @param Tag $tag The tag to look for in the database. |
|
66 | - * @return bool |
|
67 | - */ |
|
68 | - public function tagExists($tag) { |
|
69 | - $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` ' |
|
70 | - . 'WHERE `uid` = ? AND `type` = ? AND `category` = ?'; |
|
71 | - try { |
|
72 | - $this->findEntity($sql, array($tag->getOwner(), $tag->getType(), $tag->getName())); |
|
73 | - } catch (DoesNotExistException $e) { |
|
74 | - return false; |
|
75 | - } |
|
76 | - return true; |
|
77 | - } |
|
62 | + /** |
|
63 | + * Check if a given Tag object already exists in the database. |
|
64 | + * |
|
65 | + * @param Tag $tag The tag to look for in the database. |
|
66 | + * @return bool |
|
67 | + */ |
|
68 | + public function tagExists($tag) { |
|
69 | + $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` ' |
|
70 | + . 'WHERE `uid` = ? AND `type` = ? AND `category` = ?'; |
|
71 | + try { |
|
72 | + $this->findEntity($sql, array($tag->getOwner(), $tag->getType(), $tag->getName())); |
|
73 | + } catch (DoesNotExistException $e) { |
|
74 | + return false; |
|
75 | + } |
|
76 | + return true; |
|
77 | + } |
|
78 | 78 | } |
79 | 79 |