@@ -28,74 +28,74 @@ |
||
28 | 28 | use OCP\ILogger; |
29 | 29 | |
30 | 30 | class ErrorHandler { |
31 | - /** @var ILogger */ |
|
32 | - private static $logger; |
|
31 | + /** @var ILogger */ |
|
32 | + private static $logger; |
|
33 | 33 | |
34 | - /** |
|
35 | - * remove password in URLs |
|
36 | - * @param string $msg |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - protected static function removePassword($msg) { |
|
40 | - return preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $msg); |
|
41 | - } |
|
34 | + /** |
|
35 | + * remove password in URLs |
|
36 | + * @param string $msg |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + protected static function removePassword($msg) { |
|
40 | + return preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $msg); |
|
41 | + } |
|
42 | 42 | |
43 | - public static function register($debug=false) { |
|
44 | - $handler = new ErrorHandler(); |
|
43 | + public static function register($debug=false) { |
|
44 | + $handler = new ErrorHandler(); |
|
45 | 45 | |
46 | - if ($debug) { |
|
47 | - set_error_handler(array($handler, 'onAll'), E_ALL); |
|
48 | - if (\OC::$CLI) { |
|
49 | - set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); |
|
50 | - } |
|
51 | - } else { |
|
52 | - set_error_handler(array($handler, 'onError')); |
|
53 | - } |
|
54 | - register_shutdown_function(array($handler, 'onShutdown')); |
|
55 | - set_exception_handler(array($handler, 'onException')); |
|
56 | - } |
|
46 | + if ($debug) { |
|
47 | + set_error_handler(array($handler, 'onAll'), E_ALL); |
|
48 | + if (\OC::$CLI) { |
|
49 | + set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); |
|
50 | + } |
|
51 | + } else { |
|
52 | + set_error_handler(array($handler, 'onError')); |
|
53 | + } |
|
54 | + register_shutdown_function(array($handler, 'onShutdown')); |
|
55 | + set_exception_handler(array($handler, 'onException')); |
|
56 | + } |
|
57 | 57 | |
58 | - public static function setLogger(ILogger $logger) { |
|
59 | - self::$logger = $logger; |
|
60 | - } |
|
58 | + public static function setLogger(ILogger $logger) { |
|
59 | + self::$logger = $logger; |
|
60 | + } |
|
61 | 61 | |
62 | - //Fatal errors handler |
|
63 | - public static function onShutdown() { |
|
64 | - $error = error_get_last(); |
|
65 | - if($error && self::$logger) { |
|
66 | - //ob_end_clean(); |
|
67 | - $msg = $error['message'] . ' at ' . $error['file'] . '#' . $error['line']; |
|
68 | - self::$logger->critical(self::removePassword($msg), array('app' => 'PHP')); |
|
69 | - } |
|
70 | - } |
|
62 | + //Fatal errors handler |
|
63 | + public static function onShutdown() { |
|
64 | + $error = error_get_last(); |
|
65 | + if($error && self::$logger) { |
|
66 | + //ob_end_clean(); |
|
67 | + $msg = $error['message'] . ' at ' . $error['file'] . '#' . $error['line']; |
|
68 | + self::$logger->critical(self::removePassword($msg), array('app' => 'PHP')); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Uncaught exception handler |
|
74 | - * |
|
75 | - * @param \Exception $exception |
|
76 | - */ |
|
77 | - public static function onException($exception) { |
|
78 | - $class = get_class($exception); |
|
79 | - $msg = $exception->getMessage(); |
|
80 | - $msg = "$class: $msg at " . $exception->getFile() . '#' . $exception->getLine(); |
|
81 | - self::$logger->critical(self::removePassword($msg), ['app' => 'PHP']); |
|
82 | - } |
|
72 | + /** |
|
73 | + * Uncaught exception handler |
|
74 | + * |
|
75 | + * @param \Exception $exception |
|
76 | + */ |
|
77 | + public static function onException($exception) { |
|
78 | + $class = get_class($exception); |
|
79 | + $msg = $exception->getMessage(); |
|
80 | + $msg = "$class: $msg at " . $exception->getFile() . '#' . $exception->getLine(); |
|
81 | + self::$logger->critical(self::removePassword($msg), ['app' => 'PHP']); |
|
82 | + } |
|
83 | 83 | |
84 | - //Recoverable errors handler |
|
85 | - public static function onError($number, $message, $file, $line) { |
|
86 | - if (error_reporting() === 0) { |
|
87 | - return; |
|
88 | - } |
|
89 | - $msg = $message . ' at ' . $file . '#' . $line; |
|
90 | - self::$logger->error(self::removePassword($msg), array('app' => 'PHP')); |
|
84 | + //Recoverable errors handler |
|
85 | + public static function onError($number, $message, $file, $line) { |
|
86 | + if (error_reporting() === 0) { |
|
87 | + return; |
|
88 | + } |
|
89 | + $msg = $message . ' at ' . $file . '#' . $line; |
|
90 | + self::$logger->error(self::removePassword($msg), array('app' => 'PHP')); |
|
91 | 91 | |
92 | - } |
|
92 | + } |
|
93 | 93 | |
94 | - //Recoverable handler which catch all errors, warnings and notices |
|
95 | - public static function onAll($number, $message, $file, $line) { |
|
96 | - $msg = $message . ' at ' . $file . '#' . $line; |
|
97 | - self::$logger->debug(self::removePassword($msg), array('app' => 'PHP')); |
|
94 | + //Recoverable handler which catch all errors, warnings and notices |
|
95 | + public static function onAll($number, $message, $file, $line) { |
|
96 | + $msg = $message . ' at ' . $file . '#' . $line; |
|
97 | + self::$logger->debug(self::removePassword($msg), array('app' => 'PHP')); |
|
98 | 98 | |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | } |
@@ -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 | } |
@@ -37,54 +37,54 @@ |
||
37 | 37 | */ |
38 | 38 | class Tag extends Entity { |
39 | 39 | |
40 | - protected $owner; |
|
41 | - protected $type; |
|
42 | - protected $name; |
|
40 | + protected $owner; |
|
41 | + protected $type; |
|
42 | + protected $name; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Constructor. |
|
46 | - * |
|
47 | - * @param string $owner The tag's owner |
|
48 | - * @param string $type The type of item this tag is used for |
|
49 | - * @param string $name The tag's name |
|
50 | - */ |
|
51 | - public function __construct($owner = null, $type = null, $name = null) { |
|
52 | - $this->setOwner($owner); |
|
53 | - $this->setType($type); |
|
54 | - $this->setName($name); |
|
55 | - } |
|
44 | + /** |
|
45 | + * Constructor. |
|
46 | + * |
|
47 | + * @param string $owner The tag's owner |
|
48 | + * @param string $type The type of item this tag is used for |
|
49 | + * @param string $name The tag's name |
|
50 | + */ |
|
51 | + public function __construct($owner = null, $type = null, $name = null) { |
|
52 | + $this->setOwner($owner); |
|
53 | + $this->setType($type); |
|
54 | + $this->setName($name); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Transform a database columnname to a property |
|
59 | - * |
|
60 | - * @param string $columnName the name of the column |
|
61 | - * @return string the property name |
|
62 | - * @todo migrate existing database columns to the correct names |
|
63 | - * to be able to drop this direct mapping |
|
64 | - */ |
|
65 | - public function columnToProperty($columnName){ |
|
66 | - if ($columnName === 'category') { |
|
67 | - return 'name'; |
|
68 | - } elseif ($columnName === 'uid') { |
|
69 | - return 'owner'; |
|
70 | - } else { |
|
71 | - return parent::columnToProperty($columnName); |
|
72 | - } |
|
73 | - } |
|
57 | + /** |
|
58 | + * Transform a database columnname to a property |
|
59 | + * |
|
60 | + * @param string $columnName the name of the column |
|
61 | + * @return string the property name |
|
62 | + * @todo migrate existing database columns to the correct names |
|
63 | + * to be able to drop this direct mapping |
|
64 | + */ |
|
65 | + public function columnToProperty($columnName){ |
|
66 | + if ($columnName === 'category') { |
|
67 | + return 'name'; |
|
68 | + } elseif ($columnName === 'uid') { |
|
69 | + return 'owner'; |
|
70 | + } else { |
|
71 | + return parent::columnToProperty($columnName); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Transform a property to a database column name |
|
77 | - * |
|
78 | - * @param string $property the name of the property |
|
79 | - * @return string the column name |
|
80 | - */ |
|
81 | - public function propertyToColumn($property){ |
|
82 | - if ($property === 'name') { |
|
83 | - return 'category'; |
|
84 | - } elseif ($property === 'owner') { |
|
85 | - return 'uid'; |
|
86 | - } else { |
|
87 | - return parent::propertyToColumn($property); |
|
88 | - } |
|
89 | - } |
|
75 | + /** |
|
76 | + * Transform a property to a database column name |
|
77 | + * |
|
78 | + * @param string $property the name of the property |
|
79 | + * @return string the column name |
|
80 | + */ |
|
81 | + public function propertyToColumn($property){ |
|
82 | + if ($property === 'name') { |
|
83 | + return 'category'; |
|
84 | + } elseif ($property === 'owner') { |
|
85 | + return 'uid'; |
|
86 | + } else { |
|
87 | + return parent::propertyToColumn($property); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | } |
@@ -40,53 +40,53 @@ |
||
40 | 40 | |
41 | 41 | class TagManager implements \OCP\ITagManager { |
42 | 42 | |
43 | - /** |
|
44 | - * User session |
|
45 | - * |
|
46 | - * @var \OCP\IUserSession |
|
47 | - */ |
|
48 | - private $userSession; |
|
43 | + /** |
|
44 | + * User session |
|
45 | + * |
|
46 | + * @var \OCP\IUserSession |
|
47 | + */ |
|
48 | + private $userSession; |
|
49 | 49 | |
50 | - /** |
|
51 | - * TagMapper |
|
52 | - * |
|
53 | - * @var TagMapper |
|
54 | - */ |
|
55 | - private $mapper; |
|
50 | + /** |
|
51 | + * TagMapper |
|
52 | + * |
|
53 | + * @var TagMapper |
|
54 | + */ |
|
55 | + private $mapper; |
|
56 | 56 | |
57 | - /** |
|
58 | - * Constructor. |
|
59 | - * |
|
60 | - * @param TagMapper $mapper Instance of the TagMapper abstraction layer. |
|
61 | - * @param \OCP\IUserSession $userSession the user session |
|
62 | - */ |
|
63 | - public function __construct(TagMapper $mapper, \OCP\IUserSession $userSession) { |
|
64 | - $this->mapper = $mapper; |
|
65 | - $this->userSession = $userSession; |
|
57 | + /** |
|
58 | + * Constructor. |
|
59 | + * |
|
60 | + * @param TagMapper $mapper Instance of the TagMapper abstraction layer. |
|
61 | + * @param \OCP\IUserSession $userSession the user session |
|
62 | + */ |
|
63 | + public function __construct(TagMapper $mapper, \OCP\IUserSession $userSession) { |
|
64 | + $this->mapper = $mapper; |
|
65 | + $this->userSession = $userSession; |
|
66 | 66 | |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Create a new \OCP\ITags instance and load tags from db. |
|
71 | - * |
|
72 | - * @see \OCP\ITags |
|
73 | - * @param string $type The type identifier e.g. 'contact' or 'event'. |
|
74 | - * @param array $defaultTags An array of default tags to be used if none are stored. |
|
75 | - * @param boolean $includeShared Whether to include tags for items shared with this user by others. |
|
76 | - * @param string $userId user for which to retrieve the tags, defaults to the currently |
|
77 | - * logged in user |
|
78 | - * @return \OCP\ITags |
|
79 | - */ |
|
80 | - public function load($type, $defaultTags = array(), $includeShared = false, $userId = null) { |
|
81 | - if (is_null($userId)) { |
|
82 | - $user = $this->userSession->getUser(); |
|
83 | - if ($user === null) { |
|
84 | - // nothing we can do without a user |
|
85 | - return null; |
|
86 | - } |
|
87 | - $userId = $this->userSession->getUser()->getUId(); |
|
88 | - } |
|
89 | - return new Tags($this->mapper, $userId, $type, $defaultTags, $includeShared); |
|
90 | - } |
|
69 | + /** |
|
70 | + * Create a new \OCP\ITags instance and load tags from db. |
|
71 | + * |
|
72 | + * @see \OCP\ITags |
|
73 | + * @param string $type The type identifier e.g. 'contact' or 'event'. |
|
74 | + * @param array $defaultTags An array of default tags to be used if none are stored. |
|
75 | + * @param boolean $includeShared Whether to include tags for items shared with this user by others. |
|
76 | + * @param string $userId user for which to retrieve the tags, defaults to the currently |
|
77 | + * logged in user |
|
78 | + * @return \OCP\ITags |
|
79 | + */ |
|
80 | + public function load($type, $defaultTags = array(), $includeShared = false, $userId = null) { |
|
81 | + if (is_null($userId)) { |
|
82 | + $user = $this->userSession->getUser(); |
|
83 | + if ($user === null) { |
|
84 | + // nothing we can do without a user |
|
85 | + return null; |
|
86 | + } |
|
87 | + $userId = $this->userSession->getUser()->getUId(); |
|
88 | + } |
|
89 | + return new Tags($this->mapper, $userId, $type, $defaultTags, $includeShared); |
|
90 | + } |
|
91 | 91 | |
92 | 92 | } |
@@ -25,14 +25,14 @@ |
||
25 | 25 | namespace OC; |
26 | 26 | |
27 | 27 | class NaturalSort_DefaultCollator { |
28 | - public function compare($a, $b) { |
|
29 | - $result = strcasecmp($a, $b); |
|
30 | - if ($result === 0) { |
|
31 | - if ($a === $b) { |
|
32 | - return 0; |
|
33 | - } |
|
34 | - return ($a > $b) ? -1 : 1; |
|
35 | - } |
|
36 | - return ($result < 0) ? -1 : 1; |
|
37 | - } |
|
28 | + public function compare($a, $b) { |
|
29 | + $result = strcasecmp($a, $b); |
|
30 | + if ($result === 0) { |
|
31 | + if ($a === $b) { |
|
32 | + return 0; |
|
33 | + } |
|
34 | + return ($a > $b) ? -1 : 1; |
|
35 | + } |
|
36 | + return ($result < 0) ? -1 : 1; |
|
37 | + } |
|
38 | 38 | } |
@@ -25,12 +25,12 @@ |
||
25 | 25 | use OC\BackgroundJob\QueuedJob; |
26 | 26 | |
27 | 27 | class CallableJob extends QueuedJob { |
28 | - protected function run($serializedCallable) { |
|
29 | - $callable = unserialize($serializedCallable); |
|
30 | - if (is_callable($callable)) { |
|
31 | - $callable(); |
|
32 | - } else { |
|
33 | - throw new \InvalidArgumentException('Invalid serialized callable'); |
|
34 | - } |
|
35 | - } |
|
28 | + protected function run($serializedCallable) { |
|
29 | + $callable = unserialize($serializedCallable); |
|
30 | + if (is_callable($callable)) { |
|
31 | + $callable(); |
|
32 | + } else { |
|
33 | + throw new \InvalidArgumentException('Invalid serialized callable'); |
|
34 | + } |
|
35 | + } |
|
36 | 36 | } |
@@ -26,13 +26,13 @@ |
||
26 | 26 | use SuperClosure\Serializer; |
27 | 27 | |
28 | 28 | class ClosureJob extends QueuedJob { |
29 | - protected function run($serializedCallable) { |
|
30 | - $serializer = new Serializer(); |
|
31 | - $callable = $serializer->unserialize($serializedCallable); |
|
32 | - if (is_callable($callable)) { |
|
33 | - $callable(); |
|
34 | - } else { |
|
35 | - throw new \InvalidArgumentException('Invalid serialized callable'); |
|
36 | - } |
|
37 | - } |
|
29 | + protected function run($serializedCallable) { |
|
30 | + $serializer = new Serializer(); |
|
31 | + $callable = $serializer->unserialize($serializedCallable); |
|
32 | + if (is_callable($callable)) { |
|
33 | + $callable(); |
|
34 | + } else { |
|
35 | + throw new \InvalidArgumentException('Invalid serialized callable'); |
|
36 | + } |
|
37 | + } |
|
38 | 38 | } |