@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | $this->server = $server; |
| 114 | 114 | |
| 115 | 115 | $this->server->on('method:POST', [$this, 'httpPost']); |
| 116 | - $this->server->on('propFind', [$this, 'propFind']); |
|
| 116 | + $this->server->on('propFind', [$this, 'propFind']); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | public function propFind(PropFind $propFind, INode $node) { |
| 120 | 120 | if ($node instanceof Calendar) { |
| 121 | - $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node) { |
|
| 121 | + $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function() use ($node) { |
|
| 122 | 122 | if ($node->getPublishStatus()) { |
| 123 | 123 | // We return the publish-url only if the calendar is published. |
| 124 | 124 | $token = $node->getPublishStatus(); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | }); |
| 130 | 130 | |
| 131 | - $propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function () use ($node) { |
|
| 131 | + $propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function() use ($node) { |
|
| 132 | 132 | $canShare = (!$node->isSubscription() && $node->canWrite()); |
| 133 | 133 | $canPublish = (!$node->isSubscription() && $node->canWrite()); |
| 134 | 134 | |
@@ -41,216 +41,216 @@ |
||
| 41 | 41 | use Sabre\HTTP\ResponseInterface; |
| 42 | 42 | |
| 43 | 43 | class PublishPlugin extends ServerPlugin { |
| 44 | - public const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Reference to SabreDAV server object. |
|
| 48 | - * |
|
| 49 | - * @var \Sabre\DAV\Server |
|
| 50 | - */ |
|
| 51 | - protected $server; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Config instance to get instance secret. |
|
| 55 | - * |
|
| 56 | - * @var IConfig |
|
| 57 | - */ |
|
| 58 | - protected $config; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * URL Generator for absolute URLs. |
|
| 62 | - * |
|
| 63 | - * @var IURLGenerator |
|
| 64 | - */ |
|
| 65 | - protected $urlGenerator; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * PublishPlugin constructor. |
|
| 69 | - * |
|
| 70 | - * @param IConfig $config |
|
| 71 | - * @param IURLGenerator $urlGenerator |
|
| 72 | - */ |
|
| 73 | - public function __construct(IConfig $config, IURLGenerator $urlGenerator) { |
|
| 74 | - $this->config = $config; |
|
| 75 | - $this->urlGenerator = $urlGenerator; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * This method should return a list of server-features. |
|
| 80 | - * |
|
| 81 | - * This is for example 'versioning' and is added to the DAV: header |
|
| 82 | - * in an OPTIONS response. |
|
| 83 | - * |
|
| 84 | - * @return string[] |
|
| 85 | - */ |
|
| 86 | - public function getFeatures() { |
|
| 87 | - // May have to be changed to be detected |
|
| 88 | - return ['oc-calendar-publishing', 'calendarserver-sharing']; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Returns a plugin name. |
|
| 93 | - * |
|
| 94 | - * Using this name other plugins will be able to access other plugins |
|
| 95 | - * using Sabre\DAV\Server::getPlugin |
|
| 96 | - * |
|
| 97 | - * @return string |
|
| 98 | - */ |
|
| 99 | - public function getPluginName() { |
|
| 100 | - return 'oc-calendar-publishing'; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * This initializes the plugin. |
|
| 105 | - * |
|
| 106 | - * This function is called by Sabre\DAV\Server, after |
|
| 107 | - * addPlugin is called. |
|
| 108 | - * |
|
| 109 | - * This method should set up the required event subscriptions. |
|
| 110 | - * |
|
| 111 | - * @param Server $server |
|
| 112 | - */ |
|
| 113 | - public function initialize(Server $server) { |
|
| 114 | - $this->server = $server; |
|
| 115 | - |
|
| 116 | - $this->server->on('method:POST', [$this, 'httpPost']); |
|
| 117 | - $this->server->on('propFind', [$this, 'propFind']); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - public function propFind(PropFind $propFind, INode $node) { |
|
| 121 | - if ($node instanceof Calendar) { |
|
| 122 | - $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node) { |
|
| 123 | - if ($node->getPublishStatus()) { |
|
| 124 | - // We return the publish-url only if the calendar is published. |
|
| 125 | - $token = $node->getPublishStatus(); |
|
| 126 | - $publishUrl = $this->urlGenerator->getAbsoluteURL($this->server->getBaseUri().'public-calendars/').$token; |
|
| 127 | - |
|
| 128 | - return new Publisher($publishUrl, true); |
|
| 129 | - } |
|
| 130 | - }); |
|
| 131 | - |
|
| 132 | - $propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function () use ($node) { |
|
| 133 | - $canShare = (!$node->isSubscription() && $node->canWrite()); |
|
| 134 | - $canPublish = (!$node->isSubscription() && $node->canWrite()); |
|
| 135 | - |
|
| 136 | - if ($this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes') { |
|
| 137 | - $canShare &= ($node->getOwner() === $node->getPrincipalURI()); |
|
| 138 | - $canPublish &= ($node->getOwner() === $node->getPrincipalURI()); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - return new AllowedSharingModes($canShare, $canPublish); |
|
| 142 | - }); |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * We intercept this to handle POST requests on calendars. |
|
| 148 | - * |
|
| 149 | - * @param RequestInterface $request |
|
| 150 | - * @param ResponseInterface $response |
|
| 151 | - * |
|
| 152 | - * @return void|bool |
|
| 153 | - */ |
|
| 154 | - public function httpPost(RequestInterface $request, ResponseInterface $response) { |
|
| 155 | - $path = $request->getPath(); |
|
| 156 | - |
|
| 157 | - // Only handling xml |
|
| 158 | - $contentType = $request->getHeader('Content-Type'); |
|
| 159 | - if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) { |
|
| 160 | - return; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - // Making sure the node exists |
|
| 164 | - try { |
|
| 165 | - $node = $this->server->tree->getNodeForPath($path); |
|
| 166 | - } catch (NotFound $e) { |
|
| 167 | - return; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - $requestBody = $request->getBodyAsString(); |
|
| 171 | - |
|
| 172 | - // If this request handler could not deal with this POST request, it |
|
| 173 | - // will return 'null' and other plugins get a chance to handle the |
|
| 174 | - // request. |
|
| 175 | - // |
|
| 176 | - // However, we already requested the full body. This is a problem, |
|
| 177 | - // because a body can only be read once. This is why we preemptively |
|
| 178 | - // re-populated the request body with the existing data. |
|
| 179 | - $request->setBody($requestBody); |
|
| 180 | - |
|
| 181 | - $this->server->xml->parse($requestBody, $request->getUrl(), $documentType); |
|
| 182 | - |
|
| 183 | - switch ($documentType) { |
|
| 184 | - |
|
| 185 | - case '{'.self::NS_CALENDARSERVER.'}publish-calendar': |
|
| 186 | - |
|
| 187 | - // We can only deal with IShareableCalendar objects |
|
| 188 | - if (!$node instanceof Calendar) { |
|
| 189 | - return; |
|
| 190 | - } |
|
| 191 | - $this->server->transactionType = 'post-publish-calendar'; |
|
| 192 | - |
|
| 193 | - // Getting ACL info |
|
| 194 | - $acl = $this->server->getPlugin('acl'); |
|
| 195 | - |
|
| 196 | - // If there's no ACL support, we allow everything |
|
| 197 | - if ($acl) { |
|
| 198 | - /** @var \Sabre\DAVACL\Plugin $acl */ |
|
| 199 | - $acl->checkPrivileges($path, '{DAV:}write'); |
|
| 200 | - |
|
| 201 | - $limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; |
|
| 202 | - $isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); |
|
| 203 | - if ($limitSharingToOwner && !$isOwner) { |
|
| 204 | - return; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - $node->setPublishStatus(true); |
|
| 209 | - |
|
| 210 | - // iCloud sends back the 202, so we will too. |
|
| 211 | - $response->setStatus(202); |
|
| 212 | - |
|
| 213 | - // Adding this because sending a response body may cause issues, |
|
| 214 | - // and I wanted some type of indicator the response was handled. |
|
| 215 | - $response->setHeader('X-Sabre-Status', 'everything-went-well'); |
|
| 216 | - |
|
| 217 | - // Breaking the event chain |
|
| 218 | - return false; |
|
| 219 | - |
|
| 220 | - case '{'.self::NS_CALENDARSERVER.'}unpublish-calendar': |
|
| 221 | - |
|
| 222 | - // We can only deal with IShareableCalendar objects |
|
| 223 | - if (!$node instanceof Calendar) { |
|
| 224 | - return; |
|
| 225 | - } |
|
| 226 | - $this->server->transactionType = 'post-unpublish-calendar'; |
|
| 227 | - |
|
| 228 | - // Getting ACL info |
|
| 229 | - $acl = $this->server->getPlugin('acl'); |
|
| 230 | - |
|
| 231 | - // If there's no ACL support, we allow everything |
|
| 232 | - if ($acl) { |
|
| 233 | - /** @var \Sabre\DAVACL\Plugin $acl */ |
|
| 234 | - $acl->checkPrivileges($path, '{DAV:}write'); |
|
| 235 | - |
|
| 236 | - $limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; |
|
| 237 | - $isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); |
|
| 238 | - if ($limitSharingToOwner && !$isOwner) { |
|
| 239 | - return; |
|
| 240 | - } |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - $node->setPublishStatus(false); |
|
| 244 | - |
|
| 245 | - $response->setStatus(200); |
|
| 246 | - |
|
| 247 | - // Adding this because sending a response body may cause issues, |
|
| 248 | - // and I wanted some type of indicator the response was handled. |
|
| 249 | - $response->setHeader('X-Sabre-Status', 'everything-went-well'); |
|
| 250 | - |
|
| 251 | - // Breaking the event chain |
|
| 252 | - return false; |
|
| 44 | + public const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Reference to SabreDAV server object. |
|
| 48 | + * |
|
| 49 | + * @var \Sabre\DAV\Server |
|
| 50 | + */ |
|
| 51 | + protected $server; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Config instance to get instance secret. |
|
| 55 | + * |
|
| 56 | + * @var IConfig |
|
| 57 | + */ |
|
| 58 | + protected $config; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * URL Generator for absolute URLs. |
|
| 62 | + * |
|
| 63 | + * @var IURLGenerator |
|
| 64 | + */ |
|
| 65 | + protected $urlGenerator; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * PublishPlugin constructor. |
|
| 69 | + * |
|
| 70 | + * @param IConfig $config |
|
| 71 | + * @param IURLGenerator $urlGenerator |
|
| 72 | + */ |
|
| 73 | + public function __construct(IConfig $config, IURLGenerator $urlGenerator) { |
|
| 74 | + $this->config = $config; |
|
| 75 | + $this->urlGenerator = $urlGenerator; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * This method should return a list of server-features. |
|
| 80 | + * |
|
| 81 | + * This is for example 'versioning' and is added to the DAV: header |
|
| 82 | + * in an OPTIONS response. |
|
| 83 | + * |
|
| 84 | + * @return string[] |
|
| 85 | + */ |
|
| 86 | + public function getFeatures() { |
|
| 87 | + // May have to be changed to be detected |
|
| 88 | + return ['oc-calendar-publishing', 'calendarserver-sharing']; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Returns a plugin name. |
|
| 93 | + * |
|
| 94 | + * Using this name other plugins will be able to access other plugins |
|
| 95 | + * using Sabre\DAV\Server::getPlugin |
|
| 96 | + * |
|
| 97 | + * @return string |
|
| 98 | + */ |
|
| 99 | + public function getPluginName() { |
|
| 100 | + return 'oc-calendar-publishing'; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * This initializes the plugin. |
|
| 105 | + * |
|
| 106 | + * This function is called by Sabre\DAV\Server, after |
|
| 107 | + * addPlugin is called. |
|
| 108 | + * |
|
| 109 | + * This method should set up the required event subscriptions. |
|
| 110 | + * |
|
| 111 | + * @param Server $server |
|
| 112 | + */ |
|
| 113 | + public function initialize(Server $server) { |
|
| 114 | + $this->server = $server; |
|
| 115 | + |
|
| 116 | + $this->server->on('method:POST', [$this, 'httpPost']); |
|
| 117 | + $this->server->on('propFind', [$this, 'propFind']); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + public function propFind(PropFind $propFind, INode $node) { |
|
| 121 | + if ($node instanceof Calendar) { |
|
| 122 | + $propFind->handle('{'.self::NS_CALENDARSERVER.'}publish-url', function () use ($node) { |
|
| 123 | + if ($node->getPublishStatus()) { |
|
| 124 | + // We return the publish-url only if the calendar is published. |
|
| 125 | + $token = $node->getPublishStatus(); |
|
| 126 | + $publishUrl = $this->urlGenerator->getAbsoluteURL($this->server->getBaseUri().'public-calendars/').$token; |
|
| 127 | + |
|
| 128 | + return new Publisher($publishUrl, true); |
|
| 129 | + } |
|
| 130 | + }); |
|
| 131 | + |
|
| 132 | + $propFind->handle('{'.self::NS_CALENDARSERVER.'}allowed-sharing-modes', function () use ($node) { |
|
| 133 | + $canShare = (!$node->isSubscription() && $node->canWrite()); |
|
| 134 | + $canPublish = (!$node->isSubscription() && $node->canWrite()); |
|
| 135 | + |
|
| 136 | + if ($this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes') { |
|
| 137 | + $canShare &= ($node->getOwner() === $node->getPrincipalURI()); |
|
| 138 | + $canPublish &= ($node->getOwner() === $node->getPrincipalURI()); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + return new AllowedSharingModes($canShare, $canPublish); |
|
| 142 | + }); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * We intercept this to handle POST requests on calendars. |
|
| 148 | + * |
|
| 149 | + * @param RequestInterface $request |
|
| 150 | + * @param ResponseInterface $response |
|
| 151 | + * |
|
| 152 | + * @return void|bool |
|
| 153 | + */ |
|
| 154 | + public function httpPost(RequestInterface $request, ResponseInterface $response) { |
|
| 155 | + $path = $request->getPath(); |
|
| 156 | + |
|
| 157 | + // Only handling xml |
|
| 158 | + $contentType = $request->getHeader('Content-Type'); |
|
| 159 | + if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) { |
|
| 160 | + return; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // Making sure the node exists |
|
| 164 | + try { |
|
| 165 | + $node = $this->server->tree->getNodeForPath($path); |
|
| 166 | + } catch (NotFound $e) { |
|
| 167 | + return; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + $requestBody = $request->getBodyAsString(); |
|
| 171 | + |
|
| 172 | + // If this request handler could not deal with this POST request, it |
|
| 173 | + // will return 'null' and other plugins get a chance to handle the |
|
| 174 | + // request. |
|
| 175 | + // |
|
| 176 | + // However, we already requested the full body. This is a problem, |
|
| 177 | + // because a body can only be read once. This is why we preemptively |
|
| 178 | + // re-populated the request body with the existing data. |
|
| 179 | + $request->setBody($requestBody); |
|
| 180 | + |
|
| 181 | + $this->server->xml->parse($requestBody, $request->getUrl(), $documentType); |
|
| 182 | + |
|
| 183 | + switch ($documentType) { |
|
| 184 | + |
|
| 185 | + case '{'.self::NS_CALENDARSERVER.'}publish-calendar': |
|
| 186 | + |
|
| 187 | + // We can only deal with IShareableCalendar objects |
|
| 188 | + if (!$node instanceof Calendar) { |
|
| 189 | + return; |
|
| 190 | + } |
|
| 191 | + $this->server->transactionType = 'post-publish-calendar'; |
|
| 192 | + |
|
| 193 | + // Getting ACL info |
|
| 194 | + $acl = $this->server->getPlugin('acl'); |
|
| 195 | + |
|
| 196 | + // If there's no ACL support, we allow everything |
|
| 197 | + if ($acl) { |
|
| 198 | + /** @var \Sabre\DAVACL\Plugin $acl */ |
|
| 199 | + $acl->checkPrivileges($path, '{DAV:}write'); |
|
| 200 | + |
|
| 201 | + $limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; |
|
| 202 | + $isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); |
|
| 203 | + if ($limitSharingToOwner && !$isOwner) { |
|
| 204 | + return; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + $node->setPublishStatus(true); |
|
| 209 | + |
|
| 210 | + // iCloud sends back the 202, so we will too. |
|
| 211 | + $response->setStatus(202); |
|
| 212 | + |
|
| 213 | + // Adding this because sending a response body may cause issues, |
|
| 214 | + // and I wanted some type of indicator the response was handled. |
|
| 215 | + $response->setHeader('X-Sabre-Status', 'everything-went-well'); |
|
| 216 | + |
|
| 217 | + // Breaking the event chain |
|
| 218 | + return false; |
|
| 219 | + |
|
| 220 | + case '{'.self::NS_CALENDARSERVER.'}unpublish-calendar': |
|
| 221 | + |
|
| 222 | + // We can only deal with IShareableCalendar objects |
|
| 223 | + if (!$node instanceof Calendar) { |
|
| 224 | + return; |
|
| 225 | + } |
|
| 226 | + $this->server->transactionType = 'post-unpublish-calendar'; |
|
| 227 | + |
|
| 228 | + // Getting ACL info |
|
| 229 | + $acl = $this->server->getPlugin('acl'); |
|
| 230 | + |
|
| 231 | + // If there's no ACL support, we allow everything |
|
| 232 | + if ($acl) { |
|
| 233 | + /** @var \Sabre\DAVACL\Plugin $acl */ |
|
| 234 | + $acl->checkPrivileges($path, '{DAV:}write'); |
|
| 235 | + |
|
| 236 | + $limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes'; |
|
| 237 | + $isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner(); |
|
| 238 | + if ($limitSharingToOwner && !$isOwner) { |
|
| 239 | + return; |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + $node->setPublishStatus(false); |
|
| 244 | + |
|
| 245 | + $response->setStatus(200); |
|
| 246 | + |
|
| 247 | + // Adding this because sending a response body may cause issues, |
|
| 248 | + // and I wanted some type of indicator the response was handled. |
|
| 249 | + $response->setHeader('X-Sabre-Status', 'everything-went-well'); |
|
| 250 | + |
|
| 251 | + // Breaking the event chain |
|
| 252 | + return false; |
|
| 253 | 253 | |
| 254 | - } |
|
| 255 | - } |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | 256 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | use Symfony\Component\EventDispatcher\GenericEvent; |
| 37 | 37 | |
| 38 | 38 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
| 39 | - @set_time_limit(0); |
|
| 39 | + @set_time_limit(0); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | require_once '../../lib/base.php'; |
@@ -50,188 +50,188 @@ discard block |
||
| 50 | 50 | $eventSource->send('success', $l->t('Preparing update')); |
| 51 | 51 | |
| 52 | 52 | class FeedBackHandler { |
| 53 | - /** @var integer */ |
|
| 54 | - private $progressStateMax = 100; |
|
| 55 | - /** @var integer */ |
|
| 56 | - private $progressStateStep = 0; |
|
| 57 | - /** @var string */ |
|
| 58 | - private $currentStep; |
|
| 59 | - /** @var \OCP\IEventSource */ |
|
| 60 | - private $eventSource; |
|
| 61 | - /** @var \OCP\IL10N */ |
|
| 62 | - private $l10n; |
|
| 63 | - |
|
| 64 | - public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) { |
|
| 65 | - $this->eventSource = $eventSource; |
|
| 66 | - $this->l10n = $l10n; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - public function handleRepairFeedback($event) { |
|
| 70 | - if (!$event instanceof GenericEvent) { |
|
| 71 | - return; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - switch ($event->getSubject()) { |
|
| 75 | - case '\OC\Repair::startProgress': |
|
| 76 | - $this->progressStateMax = $event->getArgument(0); |
|
| 77 | - $this->progressStateStep = 0; |
|
| 78 | - $this->currentStep = $event->getArgument(1); |
|
| 79 | - break; |
|
| 80 | - case '\OC\Repair::advance': |
|
| 81 | - $this->progressStateStep += $event->getArgument(0); |
|
| 82 | - $desc = $event->getArgument(1); |
|
| 83 | - if (empty($desc)) { |
|
| 84 | - $desc = $this->currentStep; |
|
| 85 | - } |
|
| 86 | - $this->eventSource->send('success', $this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc])); |
|
| 87 | - break; |
|
| 88 | - case '\OC\Repair::finishProgress': |
|
| 89 | - $this->progressStateMax = $this->progressStateStep; |
|
| 90 | - $this->eventSource->send('success', $this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep])); |
|
| 91 | - break; |
|
| 92 | - case '\OC\Repair::step': |
|
| 93 | - $this->eventSource->send('success', $this->l10n->t('Repair step:') . ' ' . $event->getArgument(0)); |
|
| 94 | - break; |
|
| 95 | - case '\OC\Repair::info': |
|
| 96 | - $this->eventSource->send('success', $this->l10n->t('Repair info:') . ' ' . $event->getArgument(0)); |
|
| 97 | - break; |
|
| 98 | - case '\OC\Repair::warning': |
|
| 99 | - $this->eventSource->send('notice', $this->l10n->t('Repair warning:') . ' ' . $event->getArgument(0)); |
|
| 100 | - break; |
|
| 101 | - case '\OC\Repair::error': |
|
| 102 | - $this->eventSource->send('notice', $this->l10n->t('Repair error:') . ' ' . $event->getArgument(0)); |
|
| 103 | - break; |
|
| 104 | - } |
|
| 105 | - } |
|
| 53 | + /** @var integer */ |
|
| 54 | + private $progressStateMax = 100; |
|
| 55 | + /** @var integer */ |
|
| 56 | + private $progressStateStep = 0; |
|
| 57 | + /** @var string */ |
|
| 58 | + private $currentStep; |
|
| 59 | + /** @var \OCP\IEventSource */ |
|
| 60 | + private $eventSource; |
|
| 61 | + /** @var \OCP\IL10N */ |
|
| 62 | + private $l10n; |
|
| 63 | + |
|
| 64 | + public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) { |
|
| 65 | + $this->eventSource = $eventSource; |
|
| 66 | + $this->l10n = $l10n; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + public function handleRepairFeedback($event) { |
|
| 70 | + if (!$event instanceof GenericEvent) { |
|
| 71 | + return; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + switch ($event->getSubject()) { |
|
| 75 | + case '\OC\Repair::startProgress': |
|
| 76 | + $this->progressStateMax = $event->getArgument(0); |
|
| 77 | + $this->progressStateStep = 0; |
|
| 78 | + $this->currentStep = $event->getArgument(1); |
|
| 79 | + break; |
|
| 80 | + case '\OC\Repair::advance': |
|
| 81 | + $this->progressStateStep += $event->getArgument(0); |
|
| 82 | + $desc = $event->getArgument(1); |
|
| 83 | + if (empty($desc)) { |
|
| 84 | + $desc = $this->currentStep; |
|
| 85 | + } |
|
| 86 | + $this->eventSource->send('success', $this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc])); |
|
| 87 | + break; |
|
| 88 | + case '\OC\Repair::finishProgress': |
|
| 89 | + $this->progressStateMax = $this->progressStateStep; |
|
| 90 | + $this->eventSource->send('success', $this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep])); |
|
| 91 | + break; |
|
| 92 | + case '\OC\Repair::step': |
|
| 93 | + $this->eventSource->send('success', $this->l10n->t('Repair step:') . ' ' . $event->getArgument(0)); |
|
| 94 | + break; |
|
| 95 | + case '\OC\Repair::info': |
|
| 96 | + $this->eventSource->send('success', $this->l10n->t('Repair info:') . ' ' . $event->getArgument(0)); |
|
| 97 | + break; |
|
| 98 | + case '\OC\Repair::warning': |
|
| 99 | + $this->eventSource->send('notice', $this->l10n->t('Repair warning:') . ' ' . $event->getArgument(0)); |
|
| 100 | + break; |
|
| 101 | + case '\OC\Repair::error': |
|
| 102 | + $this->eventSource->send('notice', $this->l10n->t('Repair error:') . ' ' . $event->getArgument(0)); |
|
| 103 | + break; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | if (\OCP\Util::needUpgrade()) { |
| 109 | - $config = \OC::$server->getSystemConfig(); |
|
| 110 | - if ($config->getValue('upgrade.disable-web', false)) { |
|
| 111 | - $eventSource->send('failure', $l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
| 112 | - $eventSource->close(); |
|
| 113 | - exit(); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - // if a user is currently logged in, their session must be ignored to |
|
| 117 | - // avoid side effects |
|
| 118 | - \OC_User::setIncognitoMode(true); |
|
| 119 | - |
|
| 120 | - $logger = \OC::$server->getLogger(); |
|
| 121 | - $config = \OC::$server->getConfig(); |
|
| 122 | - $updater = new \OC\Updater( |
|
| 123 | - $config, |
|
| 124 | - \OC::$server->getIntegrityCodeChecker(), |
|
| 125 | - $logger, |
|
| 126 | - \OC::$server->query(\OC\Installer::class) |
|
| 127 | - ); |
|
| 128 | - $incompatibleApps = []; |
|
| 129 | - |
|
| 130 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 131 | - $dispatcher->addListener('\OC\DB\Migrator::executeSql', function ($event) use ($eventSource, $l) { |
|
| 132 | - if ($event instanceof GenericEvent) { |
|
| 133 | - $eventSource->send('success', $l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 134 | - } |
|
| 135 | - }); |
|
| 136 | - $dispatcher->addListener('\OC\DB\Migrator::checkTable', function ($event) use ($eventSource, $l) { |
|
| 137 | - if ($event instanceof GenericEvent) { |
|
| 138 | - $eventSource->send('success', $l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 139 | - } |
|
| 140 | - }); |
|
| 141 | - $feedBack = new FeedBackHandler($eventSource, $l); |
|
| 142 | - $dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']); |
|
| 143 | - $dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']); |
|
| 144 | - $dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']); |
|
| 145 | - $dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']); |
|
| 146 | - $dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']); |
|
| 147 | - $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']); |
|
| 148 | - $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']); |
|
| 149 | - |
|
| 150 | - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) { |
|
| 151 | - $eventSource->send('success', $l->t('Turned on maintenance mode')); |
|
| 152 | - }); |
|
| 153 | - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) { |
|
| 154 | - $eventSource->send('success', $l->t('Turned off maintenance mode')); |
|
| 155 | - }); |
|
| 156 | - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { |
|
| 157 | - $eventSource->send('success', $l->t('Maintenance mode is kept active')); |
|
| 158 | - }); |
|
| 159 | - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($eventSource, $l) { |
|
| 160 | - $eventSource->send('success', $l->t('Updating database schema')); |
|
| 161 | - }); |
|
| 162 | - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { |
|
| 163 | - $eventSource->send('success', $l->t('Updated database')); |
|
| 164 | - }); |
|
| 165 | - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($eventSource, $l) { |
|
| 166 | - $eventSource->send('success', $l->t('Checking whether the database schema can be updated (this can take a long time depending on the database size)')); |
|
| 167 | - }); |
|
| 168 | - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) { |
|
| 169 | - $eventSource->send('success', $l->t('Checked database schema update')); |
|
| 170 | - }); |
|
| 171 | - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) { |
|
| 172 | - $eventSource->send('success', $l->t('Checking updates of apps')); |
|
| 173 | - }); |
|
| 174 | - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) { |
|
| 175 | - $eventSource->send('success', $l->t('Checking for update of app "%s" in appstore', [$app])); |
|
| 176 | - }); |
|
| 177 | - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 178 | - $eventSource->send('success', $l->t('Update app "%s" from appstore', [$app])); |
|
| 179 | - }); |
|
| 180 | - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 181 | - $eventSource->send('success', $l->t('Checked for update of app "%s" in appstore', [$app])); |
|
| 182 | - }); |
|
| 183 | - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { |
|
| 184 | - $eventSource->send('success', $l->t('Checking whether the database schema for %s can be updated (this can take a long time depending on the database size)', [$app])); |
|
| 185 | - }); |
|
| 186 | - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) { |
|
| 187 | - $eventSource->send('success', $l->t('Checked database schema update for apps')); |
|
| 188 | - }); |
|
| 189 | - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { |
|
| 190 | - $eventSource->send('success', $l->t('Updated "%1$s" to %2$s', [$app, $version])); |
|
| 191 | - }); |
|
| 192 | - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) { |
|
| 193 | - $incompatibleApps[] = $app; |
|
| 194 | - }); |
|
| 195 | - $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { |
|
| 196 | - $eventSource->send('failure', $message); |
|
| 197 | - $eventSource->close(); |
|
| 198 | - $config->setSystemValue('maintenance', false); |
|
| 199 | - }); |
|
| 200 | - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) { |
|
| 201 | - $eventSource->send('success', $l->t('Set log level to debug')); |
|
| 202 | - }); |
|
| 203 | - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) { |
|
| 204 | - $eventSource->send('success', $l->t('Reset log level')); |
|
| 205 | - }); |
|
| 206 | - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($eventSource, $l) { |
|
| 207 | - $eventSource->send('success', $l->t('Starting code integrity check')); |
|
| 208 | - }); |
|
| 209 | - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($eventSource, $l) { |
|
| 210 | - $eventSource->send('success', $l->t('Finished code integrity check')); |
|
| 211 | - }); |
|
| 212 | - |
|
| 213 | - try { |
|
| 214 | - $updater->upgrade(); |
|
| 215 | - } catch (\Exception $e) { |
|
| 216 | - \OC::$server->getLogger()->logException($e, [ |
|
| 217 | - 'level' => ILogger::ERROR, |
|
| 218 | - 'app' => 'update', |
|
| 219 | - ]); |
|
| 220 | - $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); |
|
| 221 | - $eventSource->close(); |
|
| 222 | - exit(); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - $disabledApps = []; |
|
| 226 | - foreach ($incompatibleApps as $app) { |
|
| 227 | - $disabledApps[$app] = $l->t('%s (incompatible)', [$app]); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - if (!empty($disabledApps)) { |
|
| 231 | - $eventSource->send('notice', $l->t('The following apps have been disabled: %s', [implode(', ', $disabledApps)])); |
|
| 232 | - } |
|
| 109 | + $config = \OC::$server->getSystemConfig(); |
|
| 110 | + if ($config->getValue('upgrade.disable-web', false)) { |
|
| 111 | + $eventSource->send('failure', $l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); |
|
| 112 | + $eventSource->close(); |
|
| 113 | + exit(); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + // if a user is currently logged in, their session must be ignored to |
|
| 117 | + // avoid side effects |
|
| 118 | + \OC_User::setIncognitoMode(true); |
|
| 119 | + |
|
| 120 | + $logger = \OC::$server->getLogger(); |
|
| 121 | + $config = \OC::$server->getConfig(); |
|
| 122 | + $updater = new \OC\Updater( |
|
| 123 | + $config, |
|
| 124 | + \OC::$server->getIntegrityCodeChecker(), |
|
| 125 | + $logger, |
|
| 126 | + \OC::$server->query(\OC\Installer::class) |
|
| 127 | + ); |
|
| 128 | + $incompatibleApps = []; |
|
| 129 | + |
|
| 130 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 131 | + $dispatcher->addListener('\OC\DB\Migrator::executeSql', function ($event) use ($eventSource, $l) { |
|
| 132 | + if ($event instanceof GenericEvent) { |
|
| 133 | + $eventSource->send('success', $l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 134 | + } |
|
| 135 | + }); |
|
| 136 | + $dispatcher->addListener('\OC\DB\Migrator::checkTable', function ($event) use ($eventSource, $l) { |
|
| 137 | + if ($event instanceof GenericEvent) { |
|
| 138 | + $eventSource->send('success', $l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()])); |
|
| 139 | + } |
|
| 140 | + }); |
|
| 141 | + $feedBack = new FeedBackHandler($eventSource, $l); |
|
| 142 | + $dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']); |
|
| 143 | + $dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']); |
|
| 144 | + $dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']); |
|
| 145 | + $dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']); |
|
| 146 | + $dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']); |
|
| 147 | + $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']); |
|
| 148 | + $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']); |
|
| 149 | + |
|
| 150 | + $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) { |
|
| 151 | + $eventSource->send('success', $l->t('Turned on maintenance mode')); |
|
| 152 | + }); |
|
| 153 | + $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) { |
|
| 154 | + $eventSource->send('success', $l->t('Turned off maintenance mode')); |
|
| 155 | + }); |
|
| 156 | + $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { |
|
| 157 | + $eventSource->send('success', $l->t('Maintenance mode is kept active')); |
|
| 158 | + }); |
|
| 159 | + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($eventSource, $l) { |
|
| 160 | + $eventSource->send('success', $l->t('Updating database schema')); |
|
| 161 | + }); |
|
| 162 | + $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { |
|
| 163 | + $eventSource->send('success', $l->t('Updated database')); |
|
| 164 | + }); |
|
| 165 | + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($eventSource, $l) { |
|
| 166 | + $eventSource->send('success', $l->t('Checking whether the database schema can be updated (this can take a long time depending on the database size)')); |
|
| 167 | + }); |
|
| 168 | + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) { |
|
| 169 | + $eventSource->send('success', $l->t('Checked database schema update')); |
|
| 170 | + }); |
|
| 171 | + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) { |
|
| 172 | + $eventSource->send('success', $l->t('Checking updates of apps')); |
|
| 173 | + }); |
|
| 174 | + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) { |
|
| 175 | + $eventSource->send('success', $l->t('Checking for update of app "%s" in appstore', [$app])); |
|
| 176 | + }); |
|
| 177 | + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 178 | + $eventSource->send('success', $l->t('Update app "%s" from appstore', [$app])); |
|
| 179 | + }); |
|
| 180 | + $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 181 | + $eventSource->send('success', $l->t('Checked for update of app "%s" in appstore', [$app])); |
|
| 182 | + }); |
|
| 183 | + $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { |
|
| 184 | + $eventSource->send('success', $l->t('Checking whether the database schema for %s can be updated (this can take a long time depending on the database size)', [$app])); |
|
| 185 | + }); |
|
| 186 | + $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) { |
|
| 187 | + $eventSource->send('success', $l->t('Checked database schema update for apps')); |
|
| 188 | + }); |
|
| 189 | + $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { |
|
| 190 | + $eventSource->send('success', $l->t('Updated "%1$s" to %2$s', [$app, $version])); |
|
| 191 | + }); |
|
| 192 | + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) { |
|
| 193 | + $incompatibleApps[] = $app; |
|
| 194 | + }); |
|
| 195 | + $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { |
|
| 196 | + $eventSource->send('failure', $message); |
|
| 197 | + $eventSource->close(); |
|
| 198 | + $config->setSystemValue('maintenance', false); |
|
| 199 | + }); |
|
| 200 | + $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) { |
|
| 201 | + $eventSource->send('success', $l->t('Set log level to debug')); |
|
| 202 | + }); |
|
| 203 | + $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) { |
|
| 204 | + $eventSource->send('success', $l->t('Reset log level')); |
|
| 205 | + }); |
|
| 206 | + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($eventSource, $l) { |
|
| 207 | + $eventSource->send('success', $l->t('Starting code integrity check')); |
|
| 208 | + }); |
|
| 209 | + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($eventSource, $l) { |
|
| 210 | + $eventSource->send('success', $l->t('Finished code integrity check')); |
|
| 211 | + }); |
|
| 212 | + |
|
| 213 | + try { |
|
| 214 | + $updater->upgrade(); |
|
| 215 | + } catch (\Exception $e) { |
|
| 216 | + \OC::$server->getLogger()->logException($e, [ |
|
| 217 | + 'level' => ILogger::ERROR, |
|
| 218 | + 'app' => 'update', |
|
| 219 | + ]); |
|
| 220 | + $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); |
|
| 221 | + $eventSource->close(); |
|
| 222 | + exit(); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + $disabledApps = []; |
|
| 226 | + foreach ($incompatibleApps as $app) { |
|
| 227 | + $disabledApps[$app] = $l->t('%s (incompatible)', [$app]); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + if (!empty($disabledApps)) { |
|
| 231 | + $eventSource->send('notice', $l->t('The following apps have been disabled: %s', [implode(', ', $disabledApps)])); |
|
| 232 | + } |
|
| 233 | 233 | } else { |
| 234 | - $eventSource->send('notice', $l->t('Already up to date')); |
|
| 234 | + $eventSource->send('notice', $l->t('Already up to date')); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $eventSource->send('done', ''); |
@@ -90,16 +90,16 @@ discard block |
||
| 90 | 90 | $this->eventSource->send('success', $this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep])); |
| 91 | 91 | break; |
| 92 | 92 | case '\OC\Repair::step': |
| 93 | - $this->eventSource->send('success', $this->l10n->t('Repair step:') . ' ' . $event->getArgument(0)); |
|
| 93 | + $this->eventSource->send('success', $this->l10n->t('Repair step:').' '.$event->getArgument(0)); |
|
| 94 | 94 | break; |
| 95 | 95 | case '\OC\Repair::info': |
| 96 | - $this->eventSource->send('success', $this->l10n->t('Repair info:') . ' ' . $event->getArgument(0)); |
|
| 96 | + $this->eventSource->send('success', $this->l10n->t('Repair info:').' '.$event->getArgument(0)); |
|
| 97 | 97 | break; |
| 98 | 98 | case '\OC\Repair::warning': |
| 99 | - $this->eventSource->send('notice', $this->l10n->t('Repair warning:') . ' ' . $event->getArgument(0)); |
|
| 99 | + $this->eventSource->send('notice', $this->l10n->t('Repair warning:').' '.$event->getArgument(0)); |
|
| 100 | 100 | break; |
| 101 | 101 | case '\OC\Repair::error': |
| 102 | - $this->eventSource->send('notice', $this->l10n->t('Repair error:') . ' ' . $event->getArgument(0)); |
|
| 102 | + $this->eventSource->send('notice', $this->l10n->t('Repair error:').' '.$event->getArgument(0)); |
|
| 103 | 103 | break; |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -128,12 +128,12 @@ discard block |
||
| 128 | 128 | $incompatibleApps = []; |
| 129 | 129 | |
| 130 | 130 | $dispatcher = \OC::$server->getEventDispatcher(); |
| 131 | - $dispatcher->addListener('\OC\DB\Migrator::executeSql', function ($event) use ($eventSource, $l) { |
|
| 131 | + $dispatcher->addListener('\OC\DB\Migrator::executeSql', function($event) use ($eventSource, $l) { |
|
| 132 | 132 | if ($event instanceof GenericEvent) { |
| 133 | 133 | $eventSource->send('success', $l->t('[%d / %d]: %s', [$event[0], $event[1], $event->getSubject()])); |
| 134 | 134 | } |
| 135 | 135 | }); |
| 136 | - $dispatcher->addListener('\OC\DB\Migrator::checkTable', function ($event) use ($eventSource, $l) { |
|
| 136 | + $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($eventSource, $l) { |
|
| 137 | 137 | if ($event instanceof GenericEvent) { |
| 138 | 138 | $eventSource->send('success', $l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()])); |
| 139 | 139 | } |
@@ -147,66 +147,66 @@ discard block |
||
| 147 | 147 | $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']); |
| 148 | 148 | $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']); |
| 149 | 149 | |
| 150 | - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) { |
|
| 150 | + $updater->listen('\OC\Updater', 'maintenanceEnabled', function() use ($eventSource, $l) { |
|
| 151 | 151 | $eventSource->send('success', $l->t('Turned on maintenance mode')); |
| 152 | 152 | }); |
| 153 | - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) { |
|
| 153 | + $updater->listen('\OC\Updater', 'maintenanceDisabled', function() use ($eventSource, $l) { |
|
| 154 | 154 | $eventSource->send('success', $l->t('Turned off maintenance mode')); |
| 155 | 155 | }); |
| 156 | - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { |
|
| 156 | + $updater->listen('\OC\Updater', 'maintenanceActive', function() use ($eventSource, $l) { |
|
| 157 | 157 | $eventSource->send('success', $l->t('Maintenance mode is kept active')); |
| 158 | 158 | }); |
| 159 | - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($eventSource, $l) { |
|
| 159 | + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function() use ($eventSource, $l) { |
|
| 160 | 160 | $eventSource->send('success', $l->t('Updating database schema')); |
| 161 | 161 | }); |
| 162 | - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { |
|
| 162 | + $updater->listen('\OC\Updater', 'dbUpgrade', function() use ($eventSource, $l) { |
|
| 163 | 163 | $eventSource->send('success', $l->t('Updated database')); |
| 164 | 164 | }); |
| 165 | - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($eventSource, $l) { |
|
| 165 | + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function() use ($eventSource, $l) { |
|
| 166 | 166 | $eventSource->send('success', $l->t('Checking whether the database schema can be updated (this can take a long time depending on the database size)')); |
| 167 | 167 | }); |
| 168 | - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) { |
|
| 168 | + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function() use ($eventSource, $l) { |
|
| 169 | 169 | $eventSource->send('success', $l->t('Checked database schema update')); |
| 170 | 170 | }); |
| 171 | - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) { |
|
| 171 | + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function() use ($eventSource, $l) { |
|
| 172 | 172 | $eventSource->send('success', $l->t('Checking updates of apps')); |
| 173 | 173 | }); |
| 174 | - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($eventSource, $l) { |
|
| 174 | + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function($app) use ($eventSource, $l) { |
|
| 175 | 175 | $eventSource->send('success', $l->t('Checking for update of app "%s" in appstore', [$app])); |
| 176 | 176 | }); |
| 177 | - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 177 | + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function($app) use ($eventSource, $l) { |
|
| 178 | 178 | $eventSource->send('success', $l->t('Update app "%s" from appstore', [$app])); |
| 179 | 179 | }); |
| 180 | - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($eventSource, $l) { |
|
| 180 | + $updater->listen('\OC\Updater', 'checkAppStoreApp', function($app) use ($eventSource, $l) { |
|
| 181 | 181 | $eventSource->send('success', $l->t('Checked for update of app "%s" in appstore', [$app])); |
| 182 | 182 | }); |
| 183 | - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { |
|
| 183 | + $updater->listen('\OC\Updater', 'appSimulateUpdate', function($app) use ($eventSource, $l) { |
|
| 184 | 184 | $eventSource->send('success', $l->t('Checking whether the database schema for %s can be updated (this can take a long time depending on the database size)', [$app])); |
| 185 | 185 | }); |
| 186 | - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) { |
|
| 186 | + $updater->listen('\OC\Updater', 'appUpgradeCheck', function() use ($eventSource, $l) { |
|
| 187 | 187 | $eventSource->send('success', $l->t('Checked database schema update for apps')); |
| 188 | 188 | }); |
| 189 | - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { |
|
| 189 | + $updater->listen('\OC\Updater', 'appUpgrade', function($app, $version) use ($eventSource, $l) { |
|
| 190 | 190 | $eventSource->send('success', $l->t('Updated "%1$s" to %2$s', [$app, $version])); |
| 191 | 191 | }); |
| 192 | - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) { |
|
| 192 | + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function($app) use (&$incompatibleApps) { |
|
| 193 | 193 | $incompatibleApps[] = $app; |
| 194 | 194 | }); |
| 195 | - $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { |
|
| 195 | + $updater->listen('\OC\Updater', 'failure', function($message) use ($eventSource, $config) { |
|
| 196 | 196 | $eventSource->send('failure', $message); |
| 197 | 197 | $eventSource->close(); |
| 198 | 198 | $config->setSystemValue('maintenance', false); |
| 199 | 199 | }); |
| 200 | - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) { |
|
| 200 | + $updater->listen('\OC\Updater', 'setDebugLogLevel', function($logLevel, $logLevelName) use ($eventSource, $l) { |
|
| 201 | 201 | $eventSource->send('success', $l->t('Set log level to debug')); |
| 202 | 202 | }); |
| 203 | - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) { |
|
| 203 | + $updater->listen('\OC\Updater', 'resetLogLevel', function($logLevel, $logLevelName) use ($eventSource, $l) { |
|
| 204 | 204 | $eventSource->send('success', $l->t('Reset log level')); |
| 205 | 205 | }); |
| 206 | - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($eventSource, $l) { |
|
| 206 | + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function() use ($eventSource, $l) { |
|
| 207 | 207 | $eventSource->send('success', $l->t('Starting code integrity check')); |
| 208 | 208 | }); |
| 209 | - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($eventSource, $l) { |
|
| 209 | + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function() use ($eventSource, $l) { |
|
| 210 | 210 | $eventSource->send('success', $l->t('Finished code integrity check')); |
| 211 | 211 | }); |
| 212 | 212 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | 'level' => ILogger::ERROR, |
| 218 | 218 | 'app' => 'update', |
| 219 | 219 | ]); |
| 220 | - $eventSource->send('failure', get_class($e) . ': ' . $e->getMessage()); |
|
| 220 | + $eventSource->send('failure', get_class($e).': '.$e->getMessage()); |
|
| 221 | 221 | $eventSource->close(); |
| 222 | 222 | exit(); |
| 223 | 223 | } |
@@ -38,850 +38,850 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | class Version13000Date20170718121200 extends SimpleMigrationStep { |
| 40 | 40 | |
| 41 | - /** @var IDBConnection */ |
|
| 42 | - private $connection; |
|
| 41 | + /** @var IDBConnection */ |
|
| 42 | + private $connection; |
|
| 43 | 43 | |
| 44 | - public function __construct(IDBConnection $connection) { |
|
| 45 | - $this->connection = $connection; |
|
| 46 | - } |
|
| 44 | + public function __construct(IDBConnection $connection) { |
|
| 45 | + $this->connection = $connection; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 49 | - /** @var ISchemaWrapper $schema */ |
|
| 50 | - $schema = $schemaClosure(); |
|
| 48 | + public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 49 | + /** @var ISchemaWrapper $schema */ |
|
| 50 | + $schema = $schemaClosure(); |
|
| 51 | 51 | |
| 52 | - if (!$schema->hasTable('properties')) { |
|
| 53 | - return; |
|
| 54 | - } |
|
| 55 | - // in case we have a properties table from oc we drop it since we will only migrate |
|
| 56 | - // the dav_properties values in the postSchemaChange step |
|
| 57 | - $table = $schema->getTable('properties'); |
|
| 58 | - if ($table->hasColumn('fileid')) { |
|
| 59 | - $qb = $this->connection->getQueryBuilder(); |
|
| 60 | - $qb->delete('properties'); |
|
| 61 | - $qb->execute(); |
|
| 62 | - } |
|
| 63 | - } |
|
| 52 | + if (!$schema->hasTable('properties')) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 55 | + // in case we have a properties table from oc we drop it since we will only migrate |
|
| 56 | + // the dav_properties values in the postSchemaChange step |
|
| 57 | + $table = $schema->getTable('properties'); |
|
| 58 | + if ($table->hasColumn('fileid')) { |
|
| 59 | + $qb = $this->connection->getQueryBuilder(); |
|
| 60 | + $qb->delete('properties'); |
|
| 61 | + $qb->execute(); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @param IOutput $output |
|
| 68 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 69 | - * @param array $options |
|
| 70 | - * @return null|ISchemaWrapper |
|
| 71 | - * @since 13.0.0 |
|
| 72 | - */ |
|
| 73 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 74 | - /** @var ISchemaWrapper $schema */ |
|
| 75 | - $schema = $schemaClosure(); |
|
| 66 | + /** |
|
| 67 | + * @param IOutput $output |
|
| 68 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 69 | + * @param array $options |
|
| 70 | + * @return null|ISchemaWrapper |
|
| 71 | + * @since 13.0.0 |
|
| 72 | + */ |
|
| 73 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 74 | + /** @var ISchemaWrapper $schema */ |
|
| 75 | + $schema = $schemaClosure(); |
|
| 76 | 76 | |
| 77 | - if (!$schema->hasTable('appconfig')) { |
|
| 78 | - $table = $schema->createTable('appconfig'); |
|
| 79 | - $table->addColumn('appid', 'string', [ |
|
| 80 | - 'notnull' => true, |
|
| 81 | - 'length' => 32, |
|
| 82 | - 'default' => '', |
|
| 83 | - ]); |
|
| 84 | - $table->addColumn('configkey', 'string', [ |
|
| 85 | - 'notnull' => true, |
|
| 86 | - 'length' => 64, |
|
| 87 | - 'default' => '', |
|
| 88 | - ]); |
|
| 89 | - $table->addColumn('configvalue', 'text', [ |
|
| 90 | - 'notnull' => false, |
|
| 91 | - ]); |
|
| 92 | - $table->setPrimaryKey(['appid', 'configkey']); |
|
| 93 | - $table->addIndex(['configkey'], 'appconfig_config_key_index'); |
|
| 94 | - $table->addIndex(['appid'], 'appconfig_appid_key'); |
|
| 95 | - } |
|
| 77 | + if (!$schema->hasTable('appconfig')) { |
|
| 78 | + $table = $schema->createTable('appconfig'); |
|
| 79 | + $table->addColumn('appid', 'string', [ |
|
| 80 | + 'notnull' => true, |
|
| 81 | + 'length' => 32, |
|
| 82 | + 'default' => '', |
|
| 83 | + ]); |
|
| 84 | + $table->addColumn('configkey', 'string', [ |
|
| 85 | + 'notnull' => true, |
|
| 86 | + 'length' => 64, |
|
| 87 | + 'default' => '', |
|
| 88 | + ]); |
|
| 89 | + $table->addColumn('configvalue', 'text', [ |
|
| 90 | + 'notnull' => false, |
|
| 91 | + ]); |
|
| 92 | + $table->setPrimaryKey(['appid', 'configkey']); |
|
| 93 | + $table->addIndex(['configkey'], 'appconfig_config_key_index'); |
|
| 94 | + $table->addIndex(['appid'], 'appconfig_appid_key'); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - if (!$schema->hasTable('storages')) { |
|
| 98 | - $table = $schema->createTable('storages'); |
|
| 99 | - $table->addColumn('id', 'string', [ |
|
| 100 | - 'notnull' => false, |
|
| 101 | - 'length' => 64, |
|
| 102 | - ]); |
|
| 103 | - $table->addColumn('numeric_id', Types::BIGINT, [ |
|
| 104 | - 'autoincrement' => true, |
|
| 105 | - 'notnull' => true, |
|
| 106 | - 'length' => 20, |
|
| 107 | - ]); |
|
| 108 | - $table->addColumn('available', 'integer', [ |
|
| 109 | - 'notnull' => true, |
|
| 110 | - 'default' => 1, |
|
| 111 | - ]); |
|
| 112 | - $table->addColumn('last_checked', 'integer', [ |
|
| 113 | - 'notnull' => false, |
|
| 114 | - ]); |
|
| 115 | - $table->setPrimaryKey(['numeric_id']); |
|
| 116 | - $table->addUniqueIndex(['id'], 'storages_id_index'); |
|
| 117 | - } |
|
| 97 | + if (!$schema->hasTable('storages')) { |
|
| 98 | + $table = $schema->createTable('storages'); |
|
| 99 | + $table->addColumn('id', 'string', [ |
|
| 100 | + 'notnull' => false, |
|
| 101 | + 'length' => 64, |
|
| 102 | + ]); |
|
| 103 | + $table->addColumn('numeric_id', Types::BIGINT, [ |
|
| 104 | + 'autoincrement' => true, |
|
| 105 | + 'notnull' => true, |
|
| 106 | + 'length' => 20, |
|
| 107 | + ]); |
|
| 108 | + $table->addColumn('available', 'integer', [ |
|
| 109 | + 'notnull' => true, |
|
| 110 | + 'default' => 1, |
|
| 111 | + ]); |
|
| 112 | + $table->addColumn('last_checked', 'integer', [ |
|
| 113 | + 'notnull' => false, |
|
| 114 | + ]); |
|
| 115 | + $table->setPrimaryKey(['numeric_id']); |
|
| 116 | + $table->addUniqueIndex(['id'], 'storages_id_index'); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - if (!$schema->hasTable('mounts')) { |
|
| 120 | - $table = $schema->createTable('mounts'); |
|
| 121 | - $table->addColumn('id', 'integer', [ |
|
| 122 | - 'autoincrement' => true, |
|
| 123 | - 'notnull' => true, |
|
| 124 | - 'length' => 4, |
|
| 125 | - ]); |
|
| 126 | - $table->addColumn('storage_id', Types::BIGINT, [ |
|
| 127 | - 'notnull' => true, |
|
| 128 | - 'length' => 20, |
|
| 129 | - ]); |
|
| 130 | - $table->addColumn('root_id', Types::BIGINT, [ |
|
| 131 | - 'notnull' => true, |
|
| 132 | - 'length' => 20, |
|
| 133 | - ]); |
|
| 134 | - $table->addColumn('user_id', 'string', [ |
|
| 135 | - 'notnull' => true, |
|
| 136 | - 'length' => 64, |
|
| 137 | - ]); |
|
| 138 | - $table->addColumn('mount_point', 'string', [ |
|
| 139 | - 'notnull' => true, |
|
| 140 | - 'length' => 4000, |
|
| 141 | - ]); |
|
| 142 | - $table->addColumn('mount_id', Types::BIGINT, [ |
|
| 143 | - 'notnull' => false, |
|
| 144 | - 'length' => 20, |
|
| 145 | - ]); |
|
| 146 | - $table->setPrimaryKey(['id']); |
|
| 147 | - $table->addIndex(['user_id'], 'mounts_user_index'); |
|
| 148 | - $table->addIndex(['storage_id'], 'mounts_storage_index'); |
|
| 149 | - $table->addIndex(['root_id'], 'mounts_root_index'); |
|
| 150 | - $table->addIndex(['mount_id'], 'mounts_mount_id_index'); |
|
| 151 | - $table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index'); |
|
| 152 | - } else { |
|
| 153 | - $table = $schema->getTable('mounts'); |
|
| 154 | - $table->addColumn('mount_id', Types::BIGINT, [ |
|
| 155 | - 'notnull' => false, |
|
| 156 | - 'length' => 20, |
|
| 157 | - ]); |
|
| 158 | - if (!$table->hasIndex('mounts_mount_id_index')) { |
|
| 159 | - $table->addIndex(['mount_id'], 'mounts_mount_id_index'); |
|
| 160 | - } |
|
| 161 | - } |
|
| 119 | + if (!$schema->hasTable('mounts')) { |
|
| 120 | + $table = $schema->createTable('mounts'); |
|
| 121 | + $table->addColumn('id', 'integer', [ |
|
| 122 | + 'autoincrement' => true, |
|
| 123 | + 'notnull' => true, |
|
| 124 | + 'length' => 4, |
|
| 125 | + ]); |
|
| 126 | + $table->addColumn('storage_id', Types::BIGINT, [ |
|
| 127 | + 'notnull' => true, |
|
| 128 | + 'length' => 20, |
|
| 129 | + ]); |
|
| 130 | + $table->addColumn('root_id', Types::BIGINT, [ |
|
| 131 | + 'notnull' => true, |
|
| 132 | + 'length' => 20, |
|
| 133 | + ]); |
|
| 134 | + $table->addColumn('user_id', 'string', [ |
|
| 135 | + 'notnull' => true, |
|
| 136 | + 'length' => 64, |
|
| 137 | + ]); |
|
| 138 | + $table->addColumn('mount_point', 'string', [ |
|
| 139 | + 'notnull' => true, |
|
| 140 | + 'length' => 4000, |
|
| 141 | + ]); |
|
| 142 | + $table->addColumn('mount_id', Types::BIGINT, [ |
|
| 143 | + 'notnull' => false, |
|
| 144 | + 'length' => 20, |
|
| 145 | + ]); |
|
| 146 | + $table->setPrimaryKey(['id']); |
|
| 147 | + $table->addIndex(['user_id'], 'mounts_user_index'); |
|
| 148 | + $table->addIndex(['storage_id'], 'mounts_storage_index'); |
|
| 149 | + $table->addIndex(['root_id'], 'mounts_root_index'); |
|
| 150 | + $table->addIndex(['mount_id'], 'mounts_mount_id_index'); |
|
| 151 | + $table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index'); |
|
| 152 | + } else { |
|
| 153 | + $table = $schema->getTable('mounts'); |
|
| 154 | + $table->addColumn('mount_id', Types::BIGINT, [ |
|
| 155 | + 'notnull' => false, |
|
| 156 | + 'length' => 20, |
|
| 157 | + ]); |
|
| 158 | + if (!$table->hasIndex('mounts_mount_id_index')) { |
|
| 159 | + $table->addIndex(['mount_id'], 'mounts_mount_id_index'); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - if (!$schema->hasTable('mimetypes')) { |
|
| 164 | - $table = $schema->createTable('mimetypes'); |
|
| 165 | - $table->addColumn('id', Types::BIGINT, [ |
|
| 166 | - 'autoincrement' => true, |
|
| 167 | - 'notnull' => true, |
|
| 168 | - 'length' => 20, |
|
| 169 | - ]); |
|
| 170 | - $table->addColumn('mimetype', 'string', [ |
|
| 171 | - 'notnull' => true, |
|
| 172 | - 'length' => 255, |
|
| 173 | - 'default' => '', |
|
| 174 | - ]); |
|
| 175 | - $table->setPrimaryKey(['id']); |
|
| 176 | - $table->addUniqueIndex(['mimetype'], 'mimetype_id_index'); |
|
| 177 | - } |
|
| 163 | + if (!$schema->hasTable('mimetypes')) { |
|
| 164 | + $table = $schema->createTable('mimetypes'); |
|
| 165 | + $table->addColumn('id', Types::BIGINT, [ |
|
| 166 | + 'autoincrement' => true, |
|
| 167 | + 'notnull' => true, |
|
| 168 | + 'length' => 20, |
|
| 169 | + ]); |
|
| 170 | + $table->addColumn('mimetype', 'string', [ |
|
| 171 | + 'notnull' => true, |
|
| 172 | + 'length' => 255, |
|
| 173 | + 'default' => '', |
|
| 174 | + ]); |
|
| 175 | + $table->setPrimaryKey(['id']); |
|
| 176 | + $table->addUniqueIndex(['mimetype'], 'mimetype_id_index'); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - if (!$schema->hasTable('filecache')) { |
|
| 180 | - $table = $schema->createTable('filecache'); |
|
| 181 | - $table->addColumn('fileid', Types::BIGINT, [ |
|
| 182 | - 'autoincrement' => true, |
|
| 183 | - 'notnull' => true, |
|
| 184 | - 'length' => 20, |
|
| 185 | - ]); |
|
| 186 | - $table->addColumn('storage', Types::BIGINT, [ |
|
| 187 | - 'notnull' => true, |
|
| 188 | - 'length' => 20, |
|
| 189 | - 'default' => 0, |
|
| 190 | - ]); |
|
| 191 | - $table->addColumn('path', 'string', [ |
|
| 192 | - 'notnull' => false, |
|
| 193 | - 'length' => 4000, |
|
| 194 | - ]); |
|
| 195 | - $table->addColumn('path_hash', 'string', [ |
|
| 196 | - 'notnull' => true, |
|
| 197 | - 'length' => 32, |
|
| 198 | - 'default' => '', |
|
| 199 | - ]); |
|
| 200 | - $table->addColumn('parent', Types::BIGINT, [ |
|
| 201 | - 'notnull' => true, |
|
| 202 | - 'length' => 20, |
|
| 203 | - 'default' => 0, |
|
| 204 | - ]); |
|
| 205 | - $table->addColumn('name', 'string', [ |
|
| 206 | - 'notnull' => false, |
|
| 207 | - 'length' => 250, |
|
| 208 | - ]); |
|
| 209 | - $table->addColumn('mimetype', Types::BIGINT, [ |
|
| 210 | - 'notnull' => true, |
|
| 211 | - 'length' => 20, |
|
| 212 | - 'default' => 0, |
|
| 213 | - ]); |
|
| 214 | - $table->addColumn('mimepart', Types::BIGINT, [ |
|
| 215 | - 'notnull' => true, |
|
| 216 | - 'length' => 20, |
|
| 217 | - 'default' => 0, |
|
| 218 | - ]); |
|
| 219 | - $table->addColumn('size', 'bigint', [ |
|
| 220 | - 'notnull' => true, |
|
| 221 | - 'length' => 8, |
|
| 222 | - 'default' => 0, |
|
| 223 | - ]); |
|
| 224 | - $table->addColumn('mtime', Types::BIGINT, [ |
|
| 225 | - 'notnull' => true, |
|
| 226 | - 'length' => 20, |
|
| 227 | - 'default' => 0, |
|
| 228 | - ]); |
|
| 229 | - $table->addColumn('storage_mtime', Types::BIGINT, [ |
|
| 230 | - 'notnull' => true, |
|
| 231 | - 'length' => 20, |
|
| 232 | - 'default' => 0, |
|
| 233 | - ]); |
|
| 234 | - $table->addColumn('encrypted', 'integer', [ |
|
| 235 | - 'notnull' => true, |
|
| 236 | - 'length' => 4, |
|
| 237 | - 'default' => 0, |
|
| 238 | - ]); |
|
| 239 | - $table->addColumn('unencrypted_size', 'bigint', [ |
|
| 240 | - 'notnull' => true, |
|
| 241 | - 'length' => 8, |
|
| 242 | - 'default' => 0, |
|
| 243 | - ]); |
|
| 244 | - $table->addColumn('etag', 'string', [ |
|
| 245 | - 'notnull' => false, |
|
| 246 | - 'length' => 40, |
|
| 247 | - ]); |
|
| 248 | - $table->addColumn('permissions', 'integer', [ |
|
| 249 | - 'notnull' => false, |
|
| 250 | - 'length' => 4, |
|
| 251 | - 'default' => 0, |
|
| 252 | - ]); |
|
| 253 | - $table->addColumn('checksum', 'string', [ |
|
| 254 | - 'notnull' => false, |
|
| 255 | - 'length' => 255, |
|
| 256 | - ]); |
|
| 257 | - $table->setPrimaryKey(['fileid']); |
|
| 258 | - $table->addUniqueIndex(['storage', 'path_hash'], 'fs_storage_path_hash'); |
|
| 259 | - $table->addIndex(['parent', 'name'], 'fs_parent_name_hash'); |
|
| 260 | - $table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype'); |
|
| 261 | - $table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart'); |
|
| 262 | - $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size'); |
|
| 263 | - $table->addIndex(['mtime'], 'fs_mtime'); |
|
| 264 | - $table->addIndex(['size'], 'fs_size'); |
|
| 265 | - } |
|
| 179 | + if (!$schema->hasTable('filecache')) { |
|
| 180 | + $table = $schema->createTable('filecache'); |
|
| 181 | + $table->addColumn('fileid', Types::BIGINT, [ |
|
| 182 | + 'autoincrement' => true, |
|
| 183 | + 'notnull' => true, |
|
| 184 | + 'length' => 20, |
|
| 185 | + ]); |
|
| 186 | + $table->addColumn('storage', Types::BIGINT, [ |
|
| 187 | + 'notnull' => true, |
|
| 188 | + 'length' => 20, |
|
| 189 | + 'default' => 0, |
|
| 190 | + ]); |
|
| 191 | + $table->addColumn('path', 'string', [ |
|
| 192 | + 'notnull' => false, |
|
| 193 | + 'length' => 4000, |
|
| 194 | + ]); |
|
| 195 | + $table->addColumn('path_hash', 'string', [ |
|
| 196 | + 'notnull' => true, |
|
| 197 | + 'length' => 32, |
|
| 198 | + 'default' => '', |
|
| 199 | + ]); |
|
| 200 | + $table->addColumn('parent', Types::BIGINT, [ |
|
| 201 | + 'notnull' => true, |
|
| 202 | + 'length' => 20, |
|
| 203 | + 'default' => 0, |
|
| 204 | + ]); |
|
| 205 | + $table->addColumn('name', 'string', [ |
|
| 206 | + 'notnull' => false, |
|
| 207 | + 'length' => 250, |
|
| 208 | + ]); |
|
| 209 | + $table->addColumn('mimetype', Types::BIGINT, [ |
|
| 210 | + 'notnull' => true, |
|
| 211 | + 'length' => 20, |
|
| 212 | + 'default' => 0, |
|
| 213 | + ]); |
|
| 214 | + $table->addColumn('mimepart', Types::BIGINT, [ |
|
| 215 | + 'notnull' => true, |
|
| 216 | + 'length' => 20, |
|
| 217 | + 'default' => 0, |
|
| 218 | + ]); |
|
| 219 | + $table->addColumn('size', 'bigint', [ |
|
| 220 | + 'notnull' => true, |
|
| 221 | + 'length' => 8, |
|
| 222 | + 'default' => 0, |
|
| 223 | + ]); |
|
| 224 | + $table->addColumn('mtime', Types::BIGINT, [ |
|
| 225 | + 'notnull' => true, |
|
| 226 | + 'length' => 20, |
|
| 227 | + 'default' => 0, |
|
| 228 | + ]); |
|
| 229 | + $table->addColumn('storage_mtime', Types::BIGINT, [ |
|
| 230 | + 'notnull' => true, |
|
| 231 | + 'length' => 20, |
|
| 232 | + 'default' => 0, |
|
| 233 | + ]); |
|
| 234 | + $table->addColumn('encrypted', 'integer', [ |
|
| 235 | + 'notnull' => true, |
|
| 236 | + 'length' => 4, |
|
| 237 | + 'default' => 0, |
|
| 238 | + ]); |
|
| 239 | + $table->addColumn('unencrypted_size', 'bigint', [ |
|
| 240 | + 'notnull' => true, |
|
| 241 | + 'length' => 8, |
|
| 242 | + 'default' => 0, |
|
| 243 | + ]); |
|
| 244 | + $table->addColumn('etag', 'string', [ |
|
| 245 | + 'notnull' => false, |
|
| 246 | + 'length' => 40, |
|
| 247 | + ]); |
|
| 248 | + $table->addColumn('permissions', 'integer', [ |
|
| 249 | + 'notnull' => false, |
|
| 250 | + 'length' => 4, |
|
| 251 | + 'default' => 0, |
|
| 252 | + ]); |
|
| 253 | + $table->addColumn('checksum', 'string', [ |
|
| 254 | + 'notnull' => false, |
|
| 255 | + 'length' => 255, |
|
| 256 | + ]); |
|
| 257 | + $table->setPrimaryKey(['fileid']); |
|
| 258 | + $table->addUniqueIndex(['storage', 'path_hash'], 'fs_storage_path_hash'); |
|
| 259 | + $table->addIndex(['parent', 'name'], 'fs_parent_name_hash'); |
|
| 260 | + $table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype'); |
|
| 261 | + $table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart'); |
|
| 262 | + $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size'); |
|
| 263 | + $table->addIndex(['mtime'], 'fs_mtime'); |
|
| 264 | + $table->addIndex(['size'], 'fs_size'); |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - if (!$schema->hasTable('group_user')) { |
|
| 268 | - $table = $schema->createTable('group_user'); |
|
| 269 | - $table->addColumn('gid', 'string', [ |
|
| 270 | - 'notnull' => true, |
|
| 271 | - 'length' => 64, |
|
| 272 | - 'default' => '', |
|
| 273 | - ]); |
|
| 274 | - $table->addColumn('uid', 'string', [ |
|
| 275 | - 'notnull' => true, |
|
| 276 | - 'length' => 64, |
|
| 277 | - 'default' => '', |
|
| 278 | - ]); |
|
| 279 | - $table->setPrimaryKey(['gid', 'uid']); |
|
| 280 | - $table->addIndex(['uid'], 'gu_uid_index'); |
|
| 281 | - } |
|
| 267 | + if (!$schema->hasTable('group_user')) { |
|
| 268 | + $table = $schema->createTable('group_user'); |
|
| 269 | + $table->addColumn('gid', 'string', [ |
|
| 270 | + 'notnull' => true, |
|
| 271 | + 'length' => 64, |
|
| 272 | + 'default' => '', |
|
| 273 | + ]); |
|
| 274 | + $table->addColumn('uid', 'string', [ |
|
| 275 | + 'notnull' => true, |
|
| 276 | + 'length' => 64, |
|
| 277 | + 'default' => '', |
|
| 278 | + ]); |
|
| 279 | + $table->setPrimaryKey(['gid', 'uid']); |
|
| 280 | + $table->addIndex(['uid'], 'gu_uid_index'); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - if (!$schema->hasTable('group_admin')) { |
|
| 284 | - $table = $schema->createTable('group_admin'); |
|
| 285 | - $table->addColumn('gid', 'string', [ |
|
| 286 | - 'notnull' => true, |
|
| 287 | - 'length' => 64, |
|
| 288 | - 'default' => '', |
|
| 289 | - ]); |
|
| 290 | - $table->addColumn('uid', 'string', [ |
|
| 291 | - 'notnull' => true, |
|
| 292 | - 'length' => 64, |
|
| 293 | - 'default' => '', |
|
| 294 | - ]); |
|
| 295 | - $table->setPrimaryKey(['gid', 'uid']); |
|
| 296 | - $table->addIndex(['uid'], 'group_admin_uid'); |
|
| 297 | - } |
|
| 283 | + if (!$schema->hasTable('group_admin')) { |
|
| 284 | + $table = $schema->createTable('group_admin'); |
|
| 285 | + $table->addColumn('gid', 'string', [ |
|
| 286 | + 'notnull' => true, |
|
| 287 | + 'length' => 64, |
|
| 288 | + 'default' => '', |
|
| 289 | + ]); |
|
| 290 | + $table->addColumn('uid', 'string', [ |
|
| 291 | + 'notnull' => true, |
|
| 292 | + 'length' => 64, |
|
| 293 | + 'default' => '', |
|
| 294 | + ]); |
|
| 295 | + $table->setPrimaryKey(['gid', 'uid']); |
|
| 296 | + $table->addIndex(['uid'], 'group_admin_uid'); |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - if (!$schema->hasTable('groups')) { |
|
| 300 | - $table = $schema->createTable('groups'); |
|
| 301 | - $table->addColumn('gid', 'string', [ |
|
| 302 | - 'notnull' => true, |
|
| 303 | - 'length' => 64, |
|
| 304 | - 'default' => '', |
|
| 305 | - ]); |
|
| 306 | - $table->setPrimaryKey(['gid']); |
|
| 307 | - } |
|
| 299 | + if (!$schema->hasTable('groups')) { |
|
| 300 | + $table = $schema->createTable('groups'); |
|
| 301 | + $table->addColumn('gid', 'string', [ |
|
| 302 | + 'notnull' => true, |
|
| 303 | + 'length' => 64, |
|
| 304 | + 'default' => '', |
|
| 305 | + ]); |
|
| 306 | + $table->setPrimaryKey(['gid']); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - if (!$schema->hasTable('preferences')) { |
|
| 310 | - $table = $schema->createTable('preferences'); |
|
| 311 | - $table->addColumn('userid', 'string', [ |
|
| 312 | - 'notnull' => true, |
|
| 313 | - 'length' => 64, |
|
| 314 | - 'default' => '', |
|
| 315 | - ]); |
|
| 316 | - $table->addColumn('appid', 'string', [ |
|
| 317 | - 'notnull' => true, |
|
| 318 | - 'length' => 32, |
|
| 319 | - 'default' => '', |
|
| 320 | - ]); |
|
| 321 | - $table->addColumn('configkey', 'string', [ |
|
| 322 | - 'notnull' => true, |
|
| 323 | - 'length' => 64, |
|
| 324 | - 'default' => '', |
|
| 325 | - ]); |
|
| 326 | - $table->addColumn('configvalue', 'text', [ |
|
| 327 | - 'notnull' => false, |
|
| 328 | - ]); |
|
| 329 | - $table->setPrimaryKey(['userid', 'appid', 'configkey']); |
|
| 330 | - } |
|
| 309 | + if (!$schema->hasTable('preferences')) { |
|
| 310 | + $table = $schema->createTable('preferences'); |
|
| 311 | + $table->addColumn('userid', 'string', [ |
|
| 312 | + 'notnull' => true, |
|
| 313 | + 'length' => 64, |
|
| 314 | + 'default' => '', |
|
| 315 | + ]); |
|
| 316 | + $table->addColumn('appid', 'string', [ |
|
| 317 | + 'notnull' => true, |
|
| 318 | + 'length' => 32, |
|
| 319 | + 'default' => '', |
|
| 320 | + ]); |
|
| 321 | + $table->addColumn('configkey', 'string', [ |
|
| 322 | + 'notnull' => true, |
|
| 323 | + 'length' => 64, |
|
| 324 | + 'default' => '', |
|
| 325 | + ]); |
|
| 326 | + $table->addColumn('configvalue', 'text', [ |
|
| 327 | + 'notnull' => false, |
|
| 328 | + ]); |
|
| 329 | + $table->setPrimaryKey(['userid', 'appid', 'configkey']); |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - if (!$schema->hasTable('properties')) { |
|
| 333 | - $table = $schema->createTable('properties'); |
|
| 334 | - $table->addColumn('id', 'integer', [ |
|
| 335 | - 'autoincrement' => true, |
|
| 336 | - 'notnull' => true, |
|
| 337 | - 'length' => 4, |
|
| 338 | - ]); |
|
| 339 | - $table->addColumn('userid', 'string', [ |
|
| 340 | - 'notnull' => true, |
|
| 341 | - 'length' => 64, |
|
| 342 | - 'default' => '', |
|
| 343 | - ]); |
|
| 344 | - $table->addColumn('propertypath', 'string', [ |
|
| 345 | - 'notnull' => true, |
|
| 346 | - 'length' => 255, |
|
| 347 | - 'default' => '', |
|
| 348 | - ]); |
|
| 349 | - $table->addColumn('propertyname', 'string', [ |
|
| 350 | - 'notnull' => true, |
|
| 351 | - 'length' => 255, |
|
| 352 | - 'default' => '', |
|
| 353 | - ]); |
|
| 354 | - $table->addColumn('propertyvalue', 'text', [ |
|
| 355 | - 'notnull' => true, |
|
| 356 | - ]); |
|
| 357 | - $table->setPrimaryKey(['id']); |
|
| 358 | - $table->addIndex(['userid'], 'property_index'); |
|
| 359 | - $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); |
|
| 360 | - } else { |
|
| 361 | - $table = $schema->getTable('properties'); |
|
| 362 | - if ($table->hasColumn('propertytype')) { |
|
| 363 | - $table->dropColumn('propertytype'); |
|
| 364 | - } |
|
| 365 | - if ($table->hasColumn('fileid')) { |
|
| 366 | - $table->dropColumn('fileid'); |
|
| 367 | - } |
|
| 368 | - if (!$table->hasColumn('propertypath')) { |
|
| 369 | - $table->addColumn('propertypath', 'string', [ |
|
| 370 | - 'notnull' => true, |
|
| 371 | - 'length' => 255, |
|
| 372 | - ]); |
|
| 373 | - } |
|
| 374 | - if (!$table->hasColumn('userid')) { |
|
| 375 | - $table->addColumn('userid', 'string', [ |
|
| 376 | - 'notnull' => false, |
|
| 377 | - 'length' => 64, |
|
| 378 | - 'default' => '', |
|
| 379 | - ]); |
|
| 380 | - } |
|
| 381 | - } |
|
| 332 | + if (!$schema->hasTable('properties')) { |
|
| 333 | + $table = $schema->createTable('properties'); |
|
| 334 | + $table->addColumn('id', 'integer', [ |
|
| 335 | + 'autoincrement' => true, |
|
| 336 | + 'notnull' => true, |
|
| 337 | + 'length' => 4, |
|
| 338 | + ]); |
|
| 339 | + $table->addColumn('userid', 'string', [ |
|
| 340 | + 'notnull' => true, |
|
| 341 | + 'length' => 64, |
|
| 342 | + 'default' => '', |
|
| 343 | + ]); |
|
| 344 | + $table->addColumn('propertypath', 'string', [ |
|
| 345 | + 'notnull' => true, |
|
| 346 | + 'length' => 255, |
|
| 347 | + 'default' => '', |
|
| 348 | + ]); |
|
| 349 | + $table->addColumn('propertyname', 'string', [ |
|
| 350 | + 'notnull' => true, |
|
| 351 | + 'length' => 255, |
|
| 352 | + 'default' => '', |
|
| 353 | + ]); |
|
| 354 | + $table->addColumn('propertyvalue', 'text', [ |
|
| 355 | + 'notnull' => true, |
|
| 356 | + ]); |
|
| 357 | + $table->setPrimaryKey(['id']); |
|
| 358 | + $table->addIndex(['userid'], 'property_index'); |
|
| 359 | + $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); |
|
| 360 | + } else { |
|
| 361 | + $table = $schema->getTable('properties'); |
|
| 362 | + if ($table->hasColumn('propertytype')) { |
|
| 363 | + $table->dropColumn('propertytype'); |
|
| 364 | + } |
|
| 365 | + if ($table->hasColumn('fileid')) { |
|
| 366 | + $table->dropColumn('fileid'); |
|
| 367 | + } |
|
| 368 | + if (!$table->hasColumn('propertypath')) { |
|
| 369 | + $table->addColumn('propertypath', 'string', [ |
|
| 370 | + 'notnull' => true, |
|
| 371 | + 'length' => 255, |
|
| 372 | + ]); |
|
| 373 | + } |
|
| 374 | + if (!$table->hasColumn('userid')) { |
|
| 375 | + $table->addColumn('userid', 'string', [ |
|
| 376 | + 'notnull' => false, |
|
| 377 | + 'length' => 64, |
|
| 378 | + 'default' => '', |
|
| 379 | + ]); |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - if (!$schema->hasTable('share')) { |
|
| 384 | - $table = $schema->createTable('share'); |
|
| 385 | - $table->addColumn('id', 'integer', [ |
|
| 386 | - 'autoincrement' => true, |
|
| 387 | - 'notnull' => true, |
|
| 388 | - 'length' => 4, |
|
| 389 | - ]); |
|
| 390 | - $table->addColumn('share_type', 'smallint', [ |
|
| 391 | - 'notnull' => true, |
|
| 392 | - 'length' => 1, |
|
| 393 | - 'default' => 0, |
|
| 394 | - ]); |
|
| 395 | - $table->addColumn('share_with', 'string', [ |
|
| 396 | - 'notnull' => false, |
|
| 397 | - 'length' => 255, |
|
| 398 | - ]); |
|
| 399 | - $table->addColumn('password', 'string', [ |
|
| 400 | - 'notnull' => false, |
|
| 401 | - 'length' => 255, |
|
| 402 | - ]); |
|
| 403 | - $table->addColumn('uid_owner', 'string', [ |
|
| 404 | - 'notnull' => true, |
|
| 405 | - 'length' => 64, |
|
| 406 | - 'default' => '', |
|
| 407 | - ]); |
|
| 408 | - $table->addColumn('uid_initiator', 'string', [ |
|
| 409 | - 'notnull' => false, |
|
| 410 | - 'length' => 64, |
|
| 411 | - ]); |
|
| 412 | - $table->addColumn('parent', 'integer', [ |
|
| 413 | - 'notnull' => false, |
|
| 414 | - 'length' => 4, |
|
| 415 | - ]); |
|
| 416 | - $table->addColumn('item_type', 'string', [ |
|
| 417 | - 'notnull' => true, |
|
| 418 | - 'length' => 64, |
|
| 419 | - 'default' => '', |
|
| 420 | - ]); |
|
| 421 | - $table->addColumn('item_source', 'string', [ |
|
| 422 | - 'notnull' => false, |
|
| 423 | - 'length' => 255, |
|
| 424 | - ]); |
|
| 425 | - $table->addColumn('item_target', 'string', [ |
|
| 426 | - 'notnull' => false, |
|
| 427 | - 'length' => 255, |
|
| 428 | - ]); |
|
| 429 | - $table->addColumn('file_source', 'integer', [ |
|
| 430 | - 'notnull' => false, |
|
| 431 | - 'length' => 4, |
|
| 432 | - ]); |
|
| 433 | - $table->addColumn('file_target', 'string', [ |
|
| 434 | - 'notnull' => false, |
|
| 435 | - 'length' => 512, |
|
| 436 | - ]); |
|
| 437 | - $table->addColumn('permissions', 'smallint', [ |
|
| 438 | - 'notnull' => true, |
|
| 439 | - 'length' => 1, |
|
| 440 | - 'default' => 0, |
|
| 441 | - ]); |
|
| 442 | - $table->addColumn('stime', 'bigint', [ |
|
| 443 | - 'notnull' => true, |
|
| 444 | - 'length' => 8, |
|
| 445 | - 'default' => 0, |
|
| 446 | - ]); |
|
| 447 | - $table->addColumn('accepted', 'smallint', [ |
|
| 448 | - 'notnull' => true, |
|
| 449 | - 'length' => 1, |
|
| 450 | - 'default' => 0, |
|
| 451 | - ]); |
|
| 452 | - $table->addColumn('expiration', 'datetime', [ |
|
| 453 | - 'notnull' => false, |
|
| 454 | - ]); |
|
| 455 | - $table->addColumn('token', 'string', [ |
|
| 456 | - 'notnull' => false, |
|
| 457 | - 'length' => 32, |
|
| 458 | - ]); |
|
| 459 | - $table->addColumn('mail_send', 'smallint', [ |
|
| 460 | - 'notnull' => true, |
|
| 461 | - 'length' => 1, |
|
| 462 | - 'default' => 0, |
|
| 463 | - ]); |
|
| 464 | - $table->addColumn('share_name', 'string', [ |
|
| 465 | - 'notnull' => false, |
|
| 466 | - 'length' => 64, |
|
| 467 | - ]); |
|
| 468 | - $table->setPrimaryKey(['id']); |
|
| 469 | - $table->addIndex(['item_type', 'share_type'], 'item_share_type_index'); |
|
| 470 | - $table->addIndex(['file_source'], 'file_source_index'); |
|
| 471 | - $table->addIndex(['token'], 'token_index'); |
|
| 472 | - $table->addIndex(['share_with'], 'share_with_index'); |
|
| 473 | - $table->addIndex(['parent'], 'parent_index'); |
|
| 474 | - $table->addIndex(['uid_owner'], 'owner_index'); |
|
| 475 | - $table->addIndex(['uid_initiator'], 'initiator_index'); |
|
| 476 | - } else { |
|
| 477 | - $table = $schema->getTable('share'); |
|
| 478 | - if (!$table->hasColumn('password')) { |
|
| 479 | - $table->addColumn('password', 'string', [ |
|
| 480 | - 'notnull' => false, |
|
| 481 | - 'length' => 255, |
|
| 482 | - ]); |
|
| 483 | - } |
|
| 484 | - } |
|
| 383 | + if (!$schema->hasTable('share')) { |
|
| 384 | + $table = $schema->createTable('share'); |
|
| 385 | + $table->addColumn('id', 'integer', [ |
|
| 386 | + 'autoincrement' => true, |
|
| 387 | + 'notnull' => true, |
|
| 388 | + 'length' => 4, |
|
| 389 | + ]); |
|
| 390 | + $table->addColumn('share_type', 'smallint', [ |
|
| 391 | + 'notnull' => true, |
|
| 392 | + 'length' => 1, |
|
| 393 | + 'default' => 0, |
|
| 394 | + ]); |
|
| 395 | + $table->addColumn('share_with', 'string', [ |
|
| 396 | + 'notnull' => false, |
|
| 397 | + 'length' => 255, |
|
| 398 | + ]); |
|
| 399 | + $table->addColumn('password', 'string', [ |
|
| 400 | + 'notnull' => false, |
|
| 401 | + 'length' => 255, |
|
| 402 | + ]); |
|
| 403 | + $table->addColumn('uid_owner', 'string', [ |
|
| 404 | + 'notnull' => true, |
|
| 405 | + 'length' => 64, |
|
| 406 | + 'default' => '', |
|
| 407 | + ]); |
|
| 408 | + $table->addColumn('uid_initiator', 'string', [ |
|
| 409 | + 'notnull' => false, |
|
| 410 | + 'length' => 64, |
|
| 411 | + ]); |
|
| 412 | + $table->addColumn('parent', 'integer', [ |
|
| 413 | + 'notnull' => false, |
|
| 414 | + 'length' => 4, |
|
| 415 | + ]); |
|
| 416 | + $table->addColumn('item_type', 'string', [ |
|
| 417 | + 'notnull' => true, |
|
| 418 | + 'length' => 64, |
|
| 419 | + 'default' => '', |
|
| 420 | + ]); |
|
| 421 | + $table->addColumn('item_source', 'string', [ |
|
| 422 | + 'notnull' => false, |
|
| 423 | + 'length' => 255, |
|
| 424 | + ]); |
|
| 425 | + $table->addColumn('item_target', 'string', [ |
|
| 426 | + 'notnull' => false, |
|
| 427 | + 'length' => 255, |
|
| 428 | + ]); |
|
| 429 | + $table->addColumn('file_source', 'integer', [ |
|
| 430 | + 'notnull' => false, |
|
| 431 | + 'length' => 4, |
|
| 432 | + ]); |
|
| 433 | + $table->addColumn('file_target', 'string', [ |
|
| 434 | + 'notnull' => false, |
|
| 435 | + 'length' => 512, |
|
| 436 | + ]); |
|
| 437 | + $table->addColumn('permissions', 'smallint', [ |
|
| 438 | + 'notnull' => true, |
|
| 439 | + 'length' => 1, |
|
| 440 | + 'default' => 0, |
|
| 441 | + ]); |
|
| 442 | + $table->addColumn('stime', 'bigint', [ |
|
| 443 | + 'notnull' => true, |
|
| 444 | + 'length' => 8, |
|
| 445 | + 'default' => 0, |
|
| 446 | + ]); |
|
| 447 | + $table->addColumn('accepted', 'smallint', [ |
|
| 448 | + 'notnull' => true, |
|
| 449 | + 'length' => 1, |
|
| 450 | + 'default' => 0, |
|
| 451 | + ]); |
|
| 452 | + $table->addColumn('expiration', 'datetime', [ |
|
| 453 | + 'notnull' => false, |
|
| 454 | + ]); |
|
| 455 | + $table->addColumn('token', 'string', [ |
|
| 456 | + 'notnull' => false, |
|
| 457 | + 'length' => 32, |
|
| 458 | + ]); |
|
| 459 | + $table->addColumn('mail_send', 'smallint', [ |
|
| 460 | + 'notnull' => true, |
|
| 461 | + 'length' => 1, |
|
| 462 | + 'default' => 0, |
|
| 463 | + ]); |
|
| 464 | + $table->addColumn('share_name', 'string', [ |
|
| 465 | + 'notnull' => false, |
|
| 466 | + 'length' => 64, |
|
| 467 | + ]); |
|
| 468 | + $table->setPrimaryKey(['id']); |
|
| 469 | + $table->addIndex(['item_type', 'share_type'], 'item_share_type_index'); |
|
| 470 | + $table->addIndex(['file_source'], 'file_source_index'); |
|
| 471 | + $table->addIndex(['token'], 'token_index'); |
|
| 472 | + $table->addIndex(['share_with'], 'share_with_index'); |
|
| 473 | + $table->addIndex(['parent'], 'parent_index'); |
|
| 474 | + $table->addIndex(['uid_owner'], 'owner_index'); |
|
| 475 | + $table->addIndex(['uid_initiator'], 'initiator_index'); |
|
| 476 | + } else { |
|
| 477 | + $table = $schema->getTable('share'); |
|
| 478 | + if (!$table->hasColumn('password')) { |
|
| 479 | + $table->addColumn('password', 'string', [ |
|
| 480 | + 'notnull' => false, |
|
| 481 | + 'length' => 255, |
|
| 482 | + ]); |
|
| 483 | + } |
|
| 484 | + } |
|
| 485 | 485 | |
| 486 | - if (!$schema->hasTable('jobs')) { |
|
| 487 | - $table = $schema->createTable('jobs'); |
|
| 488 | - $table->addColumn('id', 'integer', [ |
|
| 489 | - 'autoincrement' => true, |
|
| 490 | - 'notnull' => true, |
|
| 491 | - 'length' => 4, |
|
| 492 | - 'unsigned' => true, |
|
| 493 | - ]); |
|
| 494 | - $table->addColumn('class', 'string', [ |
|
| 495 | - 'notnull' => true, |
|
| 496 | - 'length' => 255, |
|
| 497 | - 'default' => '', |
|
| 498 | - ]); |
|
| 499 | - $table->addColumn('argument', 'string', [ |
|
| 500 | - 'notnull' => true, |
|
| 501 | - 'length' => 4000, |
|
| 502 | - 'default' => '', |
|
| 503 | - ]); |
|
| 504 | - $table->addColumn('last_run', 'integer', [ |
|
| 505 | - 'notnull' => false, |
|
| 506 | - 'default' => 0, |
|
| 507 | - ]); |
|
| 508 | - $table->addColumn('last_checked', 'integer', [ |
|
| 509 | - 'notnull' => false, |
|
| 510 | - 'default' => 0, |
|
| 511 | - ]); |
|
| 512 | - $table->addColumn('reserved_at', 'integer', [ |
|
| 513 | - 'notnull' => false, |
|
| 514 | - 'default' => 0, |
|
| 515 | - ]); |
|
| 516 | - $table->addColumn('execution_duration', 'integer', [ |
|
| 517 | - 'notnull' => true, |
|
| 518 | - 'default' => 0, |
|
| 519 | - ]); |
|
| 520 | - $table->setPrimaryKey(['id']); |
|
| 521 | - $table->addIndex(['class'], 'job_class_index'); |
|
| 522 | - } |
|
| 486 | + if (!$schema->hasTable('jobs')) { |
|
| 487 | + $table = $schema->createTable('jobs'); |
|
| 488 | + $table->addColumn('id', 'integer', [ |
|
| 489 | + 'autoincrement' => true, |
|
| 490 | + 'notnull' => true, |
|
| 491 | + 'length' => 4, |
|
| 492 | + 'unsigned' => true, |
|
| 493 | + ]); |
|
| 494 | + $table->addColumn('class', 'string', [ |
|
| 495 | + 'notnull' => true, |
|
| 496 | + 'length' => 255, |
|
| 497 | + 'default' => '', |
|
| 498 | + ]); |
|
| 499 | + $table->addColumn('argument', 'string', [ |
|
| 500 | + 'notnull' => true, |
|
| 501 | + 'length' => 4000, |
|
| 502 | + 'default' => '', |
|
| 503 | + ]); |
|
| 504 | + $table->addColumn('last_run', 'integer', [ |
|
| 505 | + 'notnull' => false, |
|
| 506 | + 'default' => 0, |
|
| 507 | + ]); |
|
| 508 | + $table->addColumn('last_checked', 'integer', [ |
|
| 509 | + 'notnull' => false, |
|
| 510 | + 'default' => 0, |
|
| 511 | + ]); |
|
| 512 | + $table->addColumn('reserved_at', 'integer', [ |
|
| 513 | + 'notnull' => false, |
|
| 514 | + 'default' => 0, |
|
| 515 | + ]); |
|
| 516 | + $table->addColumn('execution_duration', 'integer', [ |
|
| 517 | + 'notnull' => true, |
|
| 518 | + 'default' => 0, |
|
| 519 | + ]); |
|
| 520 | + $table->setPrimaryKey(['id']); |
|
| 521 | + $table->addIndex(['class'], 'job_class_index'); |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | - if (!$schema->hasTable('users')) { |
|
| 525 | - $table = $schema->createTable('users'); |
|
| 526 | - $table->addColumn('uid', 'string', [ |
|
| 527 | - 'notnull' => true, |
|
| 528 | - 'length' => 64, |
|
| 529 | - 'default' => '', |
|
| 530 | - ]); |
|
| 531 | - $table->addColumn('displayname', 'string', [ |
|
| 532 | - 'notnull' => false, |
|
| 533 | - 'length' => 64, |
|
| 534 | - ]); |
|
| 535 | - $table->addColumn('password', 'string', [ |
|
| 536 | - 'notnull' => true, |
|
| 537 | - 'length' => 255, |
|
| 538 | - 'default' => '', |
|
| 539 | - ]); |
|
| 540 | - $table->setPrimaryKey(['uid']); |
|
| 541 | - } |
|
| 524 | + if (!$schema->hasTable('users')) { |
|
| 525 | + $table = $schema->createTable('users'); |
|
| 526 | + $table->addColumn('uid', 'string', [ |
|
| 527 | + 'notnull' => true, |
|
| 528 | + 'length' => 64, |
|
| 529 | + 'default' => '', |
|
| 530 | + ]); |
|
| 531 | + $table->addColumn('displayname', 'string', [ |
|
| 532 | + 'notnull' => false, |
|
| 533 | + 'length' => 64, |
|
| 534 | + ]); |
|
| 535 | + $table->addColumn('password', 'string', [ |
|
| 536 | + 'notnull' => true, |
|
| 537 | + 'length' => 255, |
|
| 538 | + 'default' => '', |
|
| 539 | + ]); |
|
| 540 | + $table->setPrimaryKey(['uid']); |
|
| 541 | + } |
|
| 542 | 542 | |
| 543 | - if (!$schema->hasTable('authtoken')) { |
|
| 544 | - $table = $schema->createTable('authtoken'); |
|
| 545 | - $table->addColumn('id', 'integer', [ |
|
| 546 | - 'autoincrement' => true, |
|
| 547 | - 'notnull' => true, |
|
| 548 | - 'length' => 4, |
|
| 549 | - 'unsigned' => true, |
|
| 550 | - ]); |
|
| 551 | - $table->addColumn('uid', 'string', [ |
|
| 552 | - 'notnull' => true, |
|
| 553 | - 'length' => 64, |
|
| 554 | - 'default' => '', |
|
| 555 | - ]); |
|
| 556 | - $table->addColumn('login_name', 'string', [ |
|
| 557 | - 'notnull' => true, |
|
| 558 | - 'length' => 64, |
|
| 559 | - 'default' => '', |
|
| 560 | - ]); |
|
| 561 | - $table->addColumn('password', 'text', [ |
|
| 562 | - 'notnull' => false, |
|
| 563 | - ]); |
|
| 564 | - $table->addColumn('name', 'text', [ |
|
| 565 | - 'notnull' => true, |
|
| 566 | - 'default' => '', |
|
| 567 | - ]); |
|
| 568 | - $table->addColumn('token', 'string', [ |
|
| 569 | - 'notnull' => true, |
|
| 570 | - 'length' => 200, |
|
| 571 | - 'default' => '', |
|
| 572 | - ]); |
|
| 573 | - $table->addColumn('type', 'smallint', [ |
|
| 574 | - 'notnull' => false, |
|
| 575 | - 'length' => 2, |
|
| 576 | - 'default' => 0, |
|
| 577 | - 'unsigned' => true, |
|
| 578 | - ]); |
|
| 579 | - $table->addColumn('remember', 'smallint', [ |
|
| 580 | - 'notnull' => false, |
|
| 581 | - 'length' => 1, |
|
| 582 | - 'default' => 0, |
|
| 583 | - 'unsigned' => true, |
|
| 584 | - ]); |
|
| 585 | - $table->addColumn('last_activity', 'integer', [ |
|
| 586 | - 'notnull' => false, |
|
| 587 | - 'length' => 4, |
|
| 588 | - 'default' => 0, |
|
| 589 | - 'unsigned' => true, |
|
| 590 | - ]); |
|
| 591 | - $table->addColumn('last_check', 'integer', [ |
|
| 592 | - 'notnull' => false, |
|
| 593 | - 'length' => 4, |
|
| 594 | - 'default' => 0, |
|
| 595 | - 'unsigned' => true, |
|
| 596 | - ]); |
|
| 597 | - $table->addColumn('scope', 'text', [ |
|
| 598 | - 'notnull' => false, |
|
| 599 | - ]); |
|
| 600 | - $table->setPrimaryKey(['id']); |
|
| 601 | - $table->addUniqueIndex(['token'], 'authtoken_token_index'); |
|
| 602 | - $table->addIndex(['last_activity'], 'authtoken_last_activity_idx'); |
|
| 603 | - } else { |
|
| 604 | - $table = $schema->getTable('authtoken'); |
|
| 605 | - $table->addColumn('scope', 'text', [ |
|
| 606 | - 'notnull' => false, |
|
| 607 | - ]); |
|
| 608 | - } |
|
| 543 | + if (!$schema->hasTable('authtoken')) { |
|
| 544 | + $table = $schema->createTable('authtoken'); |
|
| 545 | + $table->addColumn('id', 'integer', [ |
|
| 546 | + 'autoincrement' => true, |
|
| 547 | + 'notnull' => true, |
|
| 548 | + 'length' => 4, |
|
| 549 | + 'unsigned' => true, |
|
| 550 | + ]); |
|
| 551 | + $table->addColumn('uid', 'string', [ |
|
| 552 | + 'notnull' => true, |
|
| 553 | + 'length' => 64, |
|
| 554 | + 'default' => '', |
|
| 555 | + ]); |
|
| 556 | + $table->addColumn('login_name', 'string', [ |
|
| 557 | + 'notnull' => true, |
|
| 558 | + 'length' => 64, |
|
| 559 | + 'default' => '', |
|
| 560 | + ]); |
|
| 561 | + $table->addColumn('password', 'text', [ |
|
| 562 | + 'notnull' => false, |
|
| 563 | + ]); |
|
| 564 | + $table->addColumn('name', 'text', [ |
|
| 565 | + 'notnull' => true, |
|
| 566 | + 'default' => '', |
|
| 567 | + ]); |
|
| 568 | + $table->addColumn('token', 'string', [ |
|
| 569 | + 'notnull' => true, |
|
| 570 | + 'length' => 200, |
|
| 571 | + 'default' => '', |
|
| 572 | + ]); |
|
| 573 | + $table->addColumn('type', 'smallint', [ |
|
| 574 | + 'notnull' => false, |
|
| 575 | + 'length' => 2, |
|
| 576 | + 'default' => 0, |
|
| 577 | + 'unsigned' => true, |
|
| 578 | + ]); |
|
| 579 | + $table->addColumn('remember', 'smallint', [ |
|
| 580 | + 'notnull' => false, |
|
| 581 | + 'length' => 1, |
|
| 582 | + 'default' => 0, |
|
| 583 | + 'unsigned' => true, |
|
| 584 | + ]); |
|
| 585 | + $table->addColumn('last_activity', 'integer', [ |
|
| 586 | + 'notnull' => false, |
|
| 587 | + 'length' => 4, |
|
| 588 | + 'default' => 0, |
|
| 589 | + 'unsigned' => true, |
|
| 590 | + ]); |
|
| 591 | + $table->addColumn('last_check', 'integer', [ |
|
| 592 | + 'notnull' => false, |
|
| 593 | + 'length' => 4, |
|
| 594 | + 'default' => 0, |
|
| 595 | + 'unsigned' => true, |
|
| 596 | + ]); |
|
| 597 | + $table->addColumn('scope', 'text', [ |
|
| 598 | + 'notnull' => false, |
|
| 599 | + ]); |
|
| 600 | + $table->setPrimaryKey(['id']); |
|
| 601 | + $table->addUniqueIndex(['token'], 'authtoken_token_index'); |
|
| 602 | + $table->addIndex(['last_activity'], 'authtoken_last_activity_idx'); |
|
| 603 | + } else { |
|
| 604 | + $table = $schema->getTable('authtoken'); |
|
| 605 | + $table->addColumn('scope', 'text', [ |
|
| 606 | + 'notnull' => false, |
|
| 607 | + ]); |
|
| 608 | + } |
|
| 609 | 609 | |
| 610 | - if (!$schema->hasTable('bruteforce_attempts')) { |
|
| 611 | - $table = $schema->createTable('bruteforce_attempts'); |
|
| 612 | - $table->addColumn('id', 'integer', [ |
|
| 613 | - 'autoincrement' => true, |
|
| 614 | - 'notnull' => true, |
|
| 615 | - 'length' => 4, |
|
| 616 | - 'unsigned' => true, |
|
| 617 | - ]); |
|
| 618 | - $table->addColumn('action', 'string', [ |
|
| 619 | - 'notnull' => true, |
|
| 620 | - 'length' => 64, |
|
| 621 | - 'default' => '', |
|
| 622 | - ]); |
|
| 623 | - $table->addColumn('occurred', 'integer', [ |
|
| 624 | - 'notnull' => true, |
|
| 625 | - 'length' => 4, |
|
| 626 | - 'default' => 0, |
|
| 627 | - 'unsigned' => true, |
|
| 628 | - ]); |
|
| 629 | - $table->addColumn('ip', 'string', [ |
|
| 630 | - 'notnull' => true, |
|
| 631 | - 'length' => 255, |
|
| 632 | - 'default' => '', |
|
| 633 | - ]); |
|
| 634 | - $table->addColumn('subnet', 'string', [ |
|
| 635 | - 'notnull' => true, |
|
| 636 | - 'length' => 255, |
|
| 637 | - 'default' => '', |
|
| 638 | - ]); |
|
| 639 | - $table->addColumn('metadata', 'string', [ |
|
| 640 | - 'notnull' => true, |
|
| 641 | - 'length' => 255, |
|
| 642 | - 'default' => '', |
|
| 643 | - ]); |
|
| 644 | - $table->setPrimaryKey(['id']); |
|
| 645 | - $table->addIndex(['ip'], 'bruteforce_attempts_ip'); |
|
| 646 | - $table->addIndex(['subnet'], 'bruteforce_attempts_subnet'); |
|
| 647 | - } |
|
| 610 | + if (!$schema->hasTable('bruteforce_attempts')) { |
|
| 611 | + $table = $schema->createTable('bruteforce_attempts'); |
|
| 612 | + $table->addColumn('id', 'integer', [ |
|
| 613 | + 'autoincrement' => true, |
|
| 614 | + 'notnull' => true, |
|
| 615 | + 'length' => 4, |
|
| 616 | + 'unsigned' => true, |
|
| 617 | + ]); |
|
| 618 | + $table->addColumn('action', 'string', [ |
|
| 619 | + 'notnull' => true, |
|
| 620 | + 'length' => 64, |
|
| 621 | + 'default' => '', |
|
| 622 | + ]); |
|
| 623 | + $table->addColumn('occurred', 'integer', [ |
|
| 624 | + 'notnull' => true, |
|
| 625 | + 'length' => 4, |
|
| 626 | + 'default' => 0, |
|
| 627 | + 'unsigned' => true, |
|
| 628 | + ]); |
|
| 629 | + $table->addColumn('ip', 'string', [ |
|
| 630 | + 'notnull' => true, |
|
| 631 | + 'length' => 255, |
|
| 632 | + 'default' => '', |
|
| 633 | + ]); |
|
| 634 | + $table->addColumn('subnet', 'string', [ |
|
| 635 | + 'notnull' => true, |
|
| 636 | + 'length' => 255, |
|
| 637 | + 'default' => '', |
|
| 638 | + ]); |
|
| 639 | + $table->addColumn('metadata', 'string', [ |
|
| 640 | + 'notnull' => true, |
|
| 641 | + 'length' => 255, |
|
| 642 | + 'default' => '', |
|
| 643 | + ]); |
|
| 644 | + $table->setPrimaryKey(['id']); |
|
| 645 | + $table->addIndex(['ip'], 'bruteforce_attempts_ip'); |
|
| 646 | + $table->addIndex(['subnet'], 'bruteforce_attempts_subnet'); |
|
| 647 | + } |
|
| 648 | 648 | |
| 649 | - if (!$schema->hasTable('vcategory')) { |
|
| 650 | - $table = $schema->createTable('vcategory'); |
|
| 651 | - $table->addColumn('id', 'integer', [ |
|
| 652 | - 'autoincrement' => true, |
|
| 653 | - 'notnull' => true, |
|
| 654 | - 'length' => 4, |
|
| 655 | - 'unsigned' => true, |
|
| 656 | - ]); |
|
| 657 | - $table->addColumn('uid', 'string', [ |
|
| 658 | - 'notnull' => true, |
|
| 659 | - 'length' => 64, |
|
| 660 | - 'default' => '', |
|
| 661 | - ]); |
|
| 662 | - $table->addColumn('type', 'string', [ |
|
| 663 | - 'notnull' => true, |
|
| 664 | - 'length' => 64, |
|
| 665 | - 'default' => '', |
|
| 666 | - ]); |
|
| 667 | - $table->addColumn('category', 'string', [ |
|
| 668 | - 'notnull' => true, |
|
| 669 | - 'length' => 255, |
|
| 670 | - 'default' => '', |
|
| 671 | - ]); |
|
| 672 | - $table->setPrimaryKey(['id']); |
|
| 673 | - $table->addIndex(['uid'], 'uid_index'); |
|
| 674 | - $table->addIndex(['type'], 'type_index'); |
|
| 675 | - $table->addIndex(['category'], 'category_index'); |
|
| 676 | - } |
|
| 649 | + if (!$schema->hasTable('vcategory')) { |
|
| 650 | + $table = $schema->createTable('vcategory'); |
|
| 651 | + $table->addColumn('id', 'integer', [ |
|
| 652 | + 'autoincrement' => true, |
|
| 653 | + 'notnull' => true, |
|
| 654 | + 'length' => 4, |
|
| 655 | + 'unsigned' => true, |
|
| 656 | + ]); |
|
| 657 | + $table->addColumn('uid', 'string', [ |
|
| 658 | + 'notnull' => true, |
|
| 659 | + 'length' => 64, |
|
| 660 | + 'default' => '', |
|
| 661 | + ]); |
|
| 662 | + $table->addColumn('type', 'string', [ |
|
| 663 | + 'notnull' => true, |
|
| 664 | + 'length' => 64, |
|
| 665 | + 'default' => '', |
|
| 666 | + ]); |
|
| 667 | + $table->addColumn('category', 'string', [ |
|
| 668 | + 'notnull' => true, |
|
| 669 | + 'length' => 255, |
|
| 670 | + 'default' => '', |
|
| 671 | + ]); |
|
| 672 | + $table->setPrimaryKey(['id']); |
|
| 673 | + $table->addIndex(['uid'], 'uid_index'); |
|
| 674 | + $table->addIndex(['type'], 'type_index'); |
|
| 675 | + $table->addIndex(['category'], 'category_index'); |
|
| 676 | + } |
|
| 677 | 677 | |
| 678 | - if (!$schema->hasTable('vcategory_to_object')) { |
|
| 679 | - $table = $schema->createTable('vcategory_to_object'); |
|
| 680 | - $table->addColumn('objid', 'integer', [ |
|
| 681 | - 'notnull' => true, |
|
| 682 | - 'length' => 4, |
|
| 683 | - 'default' => 0, |
|
| 684 | - 'unsigned' => true, |
|
| 685 | - ]); |
|
| 686 | - $table->addColumn('categoryid', 'integer', [ |
|
| 687 | - 'notnull' => true, |
|
| 688 | - 'length' => 4, |
|
| 689 | - 'default' => 0, |
|
| 690 | - 'unsigned' => true, |
|
| 691 | - ]); |
|
| 692 | - $table->addColumn('type', 'string', [ |
|
| 693 | - 'notnull' => true, |
|
| 694 | - 'length' => 64, |
|
| 695 | - 'default' => '', |
|
| 696 | - ]); |
|
| 697 | - $table->setPrimaryKey(['categoryid', 'objid', 'type']); |
|
| 698 | - $table->addIndex(['objid', 'type'], 'vcategory_objectd_index'); |
|
| 699 | - } |
|
| 678 | + if (!$schema->hasTable('vcategory_to_object')) { |
|
| 679 | + $table = $schema->createTable('vcategory_to_object'); |
|
| 680 | + $table->addColumn('objid', 'integer', [ |
|
| 681 | + 'notnull' => true, |
|
| 682 | + 'length' => 4, |
|
| 683 | + 'default' => 0, |
|
| 684 | + 'unsigned' => true, |
|
| 685 | + ]); |
|
| 686 | + $table->addColumn('categoryid', 'integer', [ |
|
| 687 | + 'notnull' => true, |
|
| 688 | + 'length' => 4, |
|
| 689 | + 'default' => 0, |
|
| 690 | + 'unsigned' => true, |
|
| 691 | + ]); |
|
| 692 | + $table->addColumn('type', 'string', [ |
|
| 693 | + 'notnull' => true, |
|
| 694 | + 'length' => 64, |
|
| 695 | + 'default' => '', |
|
| 696 | + ]); |
|
| 697 | + $table->setPrimaryKey(['categoryid', 'objid', 'type']); |
|
| 698 | + $table->addIndex(['objid', 'type'], 'vcategory_objectd_index'); |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | - if (!$schema->hasTable('systemtag')) { |
|
| 702 | - $table = $schema->createTable('systemtag'); |
|
| 703 | - $table->addColumn('id', 'integer', [ |
|
| 704 | - 'autoincrement' => true, |
|
| 705 | - 'notnull' => true, |
|
| 706 | - 'length' => 4, |
|
| 707 | - 'unsigned' => true, |
|
| 708 | - ]); |
|
| 709 | - $table->addColumn('name', 'string', [ |
|
| 710 | - 'notnull' => true, |
|
| 711 | - 'length' => 64, |
|
| 712 | - 'default' => '', |
|
| 713 | - ]); |
|
| 714 | - $table->addColumn('visibility', 'smallint', [ |
|
| 715 | - 'notnull' => true, |
|
| 716 | - 'length' => 1, |
|
| 717 | - 'default' => 1, |
|
| 718 | - ]); |
|
| 719 | - $table->addColumn('editable', 'smallint', [ |
|
| 720 | - 'notnull' => true, |
|
| 721 | - 'length' => 1, |
|
| 722 | - 'default' => 1, |
|
| 723 | - ]); |
|
| 724 | - $table->setPrimaryKey(['id']); |
|
| 725 | - $table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident'); |
|
| 726 | - } |
|
| 701 | + if (!$schema->hasTable('systemtag')) { |
|
| 702 | + $table = $schema->createTable('systemtag'); |
|
| 703 | + $table->addColumn('id', 'integer', [ |
|
| 704 | + 'autoincrement' => true, |
|
| 705 | + 'notnull' => true, |
|
| 706 | + 'length' => 4, |
|
| 707 | + 'unsigned' => true, |
|
| 708 | + ]); |
|
| 709 | + $table->addColumn('name', 'string', [ |
|
| 710 | + 'notnull' => true, |
|
| 711 | + 'length' => 64, |
|
| 712 | + 'default' => '', |
|
| 713 | + ]); |
|
| 714 | + $table->addColumn('visibility', 'smallint', [ |
|
| 715 | + 'notnull' => true, |
|
| 716 | + 'length' => 1, |
|
| 717 | + 'default' => 1, |
|
| 718 | + ]); |
|
| 719 | + $table->addColumn('editable', 'smallint', [ |
|
| 720 | + 'notnull' => true, |
|
| 721 | + 'length' => 1, |
|
| 722 | + 'default' => 1, |
|
| 723 | + ]); |
|
| 724 | + $table->setPrimaryKey(['id']); |
|
| 725 | + $table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident'); |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | - if (!$schema->hasTable('systemtag_object_mapping')) { |
|
| 729 | - $table = $schema->createTable('systemtag_object_mapping'); |
|
| 730 | - $table->addColumn('objectid', 'string', [ |
|
| 731 | - 'notnull' => true, |
|
| 732 | - 'length' => 64, |
|
| 733 | - 'default' => '', |
|
| 734 | - ]); |
|
| 735 | - $table->addColumn('objecttype', 'string', [ |
|
| 736 | - 'notnull' => true, |
|
| 737 | - 'length' => 64, |
|
| 738 | - 'default' => '', |
|
| 739 | - ]); |
|
| 740 | - $table->addColumn('systemtagid', 'integer', [ |
|
| 741 | - 'notnull' => true, |
|
| 742 | - 'length' => 4, |
|
| 743 | - 'default' => 0, |
|
| 744 | - 'unsigned' => true, |
|
| 745 | - ]); |
|
| 746 | - $table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk'); |
|
| 728 | + if (!$schema->hasTable('systemtag_object_mapping')) { |
|
| 729 | + $table = $schema->createTable('systemtag_object_mapping'); |
|
| 730 | + $table->addColumn('objectid', 'string', [ |
|
| 731 | + 'notnull' => true, |
|
| 732 | + 'length' => 64, |
|
| 733 | + 'default' => '', |
|
| 734 | + ]); |
|
| 735 | + $table->addColumn('objecttype', 'string', [ |
|
| 736 | + 'notnull' => true, |
|
| 737 | + 'length' => 64, |
|
| 738 | + 'default' => '', |
|
| 739 | + ]); |
|
| 740 | + $table->addColumn('systemtagid', 'integer', [ |
|
| 741 | + 'notnull' => true, |
|
| 742 | + 'length' => 4, |
|
| 743 | + 'default' => 0, |
|
| 744 | + 'unsigned' => true, |
|
| 745 | + ]); |
|
| 746 | + $table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk'); |
|
| 747 | 747 | // $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping'); |
| 748 | - } |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | - if (!$schema->hasTable('systemtag_group')) { |
|
| 751 | - $table = $schema->createTable('systemtag_group'); |
|
| 752 | - $table->addColumn('systemtagid', 'integer', [ |
|
| 753 | - 'notnull' => true, |
|
| 754 | - 'length' => 4, |
|
| 755 | - 'default' => 0, |
|
| 756 | - 'unsigned' => true, |
|
| 757 | - ]); |
|
| 758 | - $table->addColumn('gid', 'string', [ |
|
| 759 | - 'notnull' => true, |
|
| 760 | - ]); |
|
| 761 | - $table->setPrimaryKey(['gid', 'systemtagid']); |
|
| 762 | - } |
|
| 750 | + if (!$schema->hasTable('systemtag_group')) { |
|
| 751 | + $table = $schema->createTable('systemtag_group'); |
|
| 752 | + $table->addColumn('systemtagid', 'integer', [ |
|
| 753 | + 'notnull' => true, |
|
| 754 | + 'length' => 4, |
|
| 755 | + 'default' => 0, |
|
| 756 | + 'unsigned' => true, |
|
| 757 | + ]); |
|
| 758 | + $table->addColumn('gid', 'string', [ |
|
| 759 | + 'notnull' => true, |
|
| 760 | + ]); |
|
| 761 | + $table->setPrimaryKey(['gid', 'systemtagid']); |
|
| 762 | + } |
|
| 763 | 763 | |
| 764 | - if (!$schema->hasTable('file_locks')) { |
|
| 765 | - $table = $schema->createTable('file_locks'); |
|
| 766 | - $table->addColumn('id', 'integer', [ |
|
| 767 | - 'autoincrement' => true, |
|
| 768 | - 'notnull' => true, |
|
| 769 | - 'length' => 4, |
|
| 770 | - 'unsigned' => true, |
|
| 771 | - ]); |
|
| 772 | - $table->addColumn('lock', 'integer', [ |
|
| 773 | - 'notnull' => true, |
|
| 774 | - 'length' => 4, |
|
| 775 | - 'default' => 0, |
|
| 776 | - ]); |
|
| 777 | - $table->addColumn('key', 'string', [ |
|
| 778 | - 'notnull' => true, |
|
| 779 | - 'length' => 64, |
|
| 780 | - ]); |
|
| 781 | - $table->addColumn('ttl', 'integer', [ |
|
| 782 | - 'notnull' => true, |
|
| 783 | - 'length' => 4, |
|
| 784 | - 'default' => -1, |
|
| 785 | - ]); |
|
| 786 | - $table->setPrimaryKey(['id']); |
|
| 787 | - $table->addUniqueIndex(['key'], 'lock_key_index'); |
|
| 788 | - $table->addIndex(['ttl'], 'lock_ttl_index'); |
|
| 789 | - } |
|
| 764 | + if (!$schema->hasTable('file_locks')) { |
|
| 765 | + $table = $schema->createTable('file_locks'); |
|
| 766 | + $table->addColumn('id', 'integer', [ |
|
| 767 | + 'autoincrement' => true, |
|
| 768 | + 'notnull' => true, |
|
| 769 | + 'length' => 4, |
|
| 770 | + 'unsigned' => true, |
|
| 771 | + ]); |
|
| 772 | + $table->addColumn('lock', 'integer', [ |
|
| 773 | + 'notnull' => true, |
|
| 774 | + 'length' => 4, |
|
| 775 | + 'default' => 0, |
|
| 776 | + ]); |
|
| 777 | + $table->addColumn('key', 'string', [ |
|
| 778 | + 'notnull' => true, |
|
| 779 | + 'length' => 64, |
|
| 780 | + ]); |
|
| 781 | + $table->addColumn('ttl', 'integer', [ |
|
| 782 | + 'notnull' => true, |
|
| 783 | + 'length' => 4, |
|
| 784 | + 'default' => -1, |
|
| 785 | + ]); |
|
| 786 | + $table->setPrimaryKey(['id']); |
|
| 787 | + $table->addUniqueIndex(['key'], 'lock_key_index'); |
|
| 788 | + $table->addIndex(['ttl'], 'lock_ttl_index'); |
|
| 789 | + } |
|
| 790 | 790 | |
| 791 | - if (!$schema->hasTable('comments')) { |
|
| 792 | - $table = $schema->createTable('comments'); |
|
| 793 | - $table->addColumn('id', 'integer', [ |
|
| 794 | - 'autoincrement' => true, |
|
| 795 | - 'notnull' => true, |
|
| 796 | - 'length' => 4, |
|
| 797 | - 'unsigned' => true, |
|
| 798 | - ]); |
|
| 799 | - $table->addColumn('parent_id', 'integer', [ |
|
| 800 | - 'notnull' => true, |
|
| 801 | - 'length' => 4, |
|
| 802 | - 'default' => 0, |
|
| 803 | - 'unsigned' => true, |
|
| 804 | - ]); |
|
| 805 | - $table->addColumn('topmost_parent_id', 'integer', [ |
|
| 806 | - 'notnull' => true, |
|
| 807 | - 'length' => 4, |
|
| 808 | - 'default' => 0, |
|
| 809 | - 'unsigned' => true, |
|
| 810 | - ]); |
|
| 811 | - $table->addColumn('children_count', 'integer', [ |
|
| 812 | - 'notnull' => true, |
|
| 813 | - 'length' => 4, |
|
| 814 | - 'default' => 0, |
|
| 815 | - 'unsigned' => true, |
|
| 816 | - ]); |
|
| 817 | - $table->addColumn('actor_type', 'string', [ |
|
| 818 | - 'notnull' => true, |
|
| 819 | - 'length' => 64, |
|
| 820 | - 'default' => '', |
|
| 821 | - ]); |
|
| 822 | - $table->addColumn('actor_id', 'string', [ |
|
| 823 | - 'notnull' => true, |
|
| 824 | - 'length' => 64, |
|
| 825 | - 'default' => '', |
|
| 826 | - ]); |
|
| 827 | - $table->addColumn('message', 'text', [ |
|
| 828 | - 'notnull' => false, |
|
| 829 | - ]); |
|
| 830 | - $table->addColumn('verb', 'string', [ |
|
| 831 | - 'notnull' => false, |
|
| 832 | - 'length' => 64, |
|
| 833 | - ]); |
|
| 834 | - $table->addColumn('creation_timestamp', 'datetime', [ |
|
| 835 | - 'notnull' => false, |
|
| 836 | - ]); |
|
| 837 | - $table->addColumn('latest_child_timestamp', 'datetime', [ |
|
| 838 | - 'notnull' => false, |
|
| 839 | - ]); |
|
| 840 | - $table->addColumn('object_type', 'string', [ |
|
| 841 | - 'notnull' => true, |
|
| 842 | - 'length' => 64, |
|
| 843 | - 'default' => '', |
|
| 844 | - ]); |
|
| 845 | - $table->addColumn('object_id', 'string', [ |
|
| 846 | - 'notnull' => true, |
|
| 847 | - 'length' => 64, |
|
| 848 | - 'default' => '', |
|
| 849 | - ]); |
|
| 850 | - $table->addColumn('reference_id', 'string', [ |
|
| 851 | - 'notnull' => false, |
|
| 852 | - 'length' => 64, |
|
| 853 | - ]); |
|
| 854 | - $table->setPrimaryKey(['id']); |
|
| 855 | - $table->addIndex(['parent_id'], 'comments_parent_id_index'); |
|
| 856 | - $table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx'); |
|
| 857 | - $table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index'); |
|
| 858 | - $table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index'); |
|
| 859 | - } |
|
| 791 | + if (!$schema->hasTable('comments')) { |
|
| 792 | + $table = $schema->createTable('comments'); |
|
| 793 | + $table->addColumn('id', 'integer', [ |
|
| 794 | + 'autoincrement' => true, |
|
| 795 | + 'notnull' => true, |
|
| 796 | + 'length' => 4, |
|
| 797 | + 'unsigned' => true, |
|
| 798 | + ]); |
|
| 799 | + $table->addColumn('parent_id', 'integer', [ |
|
| 800 | + 'notnull' => true, |
|
| 801 | + 'length' => 4, |
|
| 802 | + 'default' => 0, |
|
| 803 | + 'unsigned' => true, |
|
| 804 | + ]); |
|
| 805 | + $table->addColumn('topmost_parent_id', 'integer', [ |
|
| 806 | + 'notnull' => true, |
|
| 807 | + 'length' => 4, |
|
| 808 | + 'default' => 0, |
|
| 809 | + 'unsigned' => true, |
|
| 810 | + ]); |
|
| 811 | + $table->addColumn('children_count', 'integer', [ |
|
| 812 | + 'notnull' => true, |
|
| 813 | + 'length' => 4, |
|
| 814 | + 'default' => 0, |
|
| 815 | + 'unsigned' => true, |
|
| 816 | + ]); |
|
| 817 | + $table->addColumn('actor_type', 'string', [ |
|
| 818 | + 'notnull' => true, |
|
| 819 | + 'length' => 64, |
|
| 820 | + 'default' => '', |
|
| 821 | + ]); |
|
| 822 | + $table->addColumn('actor_id', 'string', [ |
|
| 823 | + 'notnull' => true, |
|
| 824 | + 'length' => 64, |
|
| 825 | + 'default' => '', |
|
| 826 | + ]); |
|
| 827 | + $table->addColumn('message', 'text', [ |
|
| 828 | + 'notnull' => false, |
|
| 829 | + ]); |
|
| 830 | + $table->addColumn('verb', 'string', [ |
|
| 831 | + 'notnull' => false, |
|
| 832 | + 'length' => 64, |
|
| 833 | + ]); |
|
| 834 | + $table->addColumn('creation_timestamp', 'datetime', [ |
|
| 835 | + 'notnull' => false, |
|
| 836 | + ]); |
|
| 837 | + $table->addColumn('latest_child_timestamp', 'datetime', [ |
|
| 838 | + 'notnull' => false, |
|
| 839 | + ]); |
|
| 840 | + $table->addColumn('object_type', 'string', [ |
|
| 841 | + 'notnull' => true, |
|
| 842 | + 'length' => 64, |
|
| 843 | + 'default' => '', |
|
| 844 | + ]); |
|
| 845 | + $table->addColumn('object_id', 'string', [ |
|
| 846 | + 'notnull' => true, |
|
| 847 | + 'length' => 64, |
|
| 848 | + 'default' => '', |
|
| 849 | + ]); |
|
| 850 | + $table->addColumn('reference_id', 'string', [ |
|
| 851 | + 'notnull' => false, |
|
| 852 | + 'length' => 64, |
|
| 853 | + ]); |
|
| 854 | + $table->setPrimaryKey(['id']); |
|
| 855 | + $table->addIndex(['parent_id'], 'comments_parent_id_index'); |
|
| 856 | + $table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx'); |
|
| 857 | + $table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index'); |
|
| 858 | + $table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index'); |
|
| 859 | + } |
|
| 860 | 860 | |
| 861 | - if (!$schema->hasTable('comments_read_markers')) { |
|
| 862 | - $table = $schema->createTable('comments_read_markers'); |
|
| 863 | - $table->addColumn('user_id', 'string', [ |
|
| 864 | - 'notnull' => true, |
|
| 865 | - 'length' => 64, |
|
| 866 | - 'default' => '', |
|
| 867 | - ]); |
|
| 868 | - $table->addColumn('marker_datetime', 'datetime', [ |
|
| 869 | - 'notnull' => false, |
|
| 870 | - ]); |
|
| 871 | - $table->addColumn('object_type', 'string', [ |
|
| 872 | - 'notnull' => true, |
|
| 873 | - 'length' => 64, |
|
| 874 | - 'default' => '', |
|
| 875 | - ]); |
|
| 876 | - $table->addColumn('object_id', 'string', [ |
|
| 877 | - 'notnull' => true, |
|
| 878 | - 'length' => 64, |
|
| 879 | - 'default' => '', |
|
| 880 | - ]); |
|
| 881 | - $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index'); |
|
| 882 | - $table->setPrimaryKey(['user_id', 'object_type', 'object_id'], 'crm_pk'); |
|
| 861 | + if (!$schema->hasTable('comments_read_markers')) { |
|
| 862 | + $table = $schema->createTable('comments_read_markers'); |
|
| 863 | + $table->addColumn('user_id', 'string', [ |
|
| 864 | + 'notnull' => true, |
|
| 865 | + 'length' => 64, |
|
| 866 | + 'default' => '', |
|
| 867 | + ]); |
|
| 868 | + $table->addColumn('marker_datetime', 'datetime', [ |
|
| 869 | + 'notnull' => false, |
|
| 870 | + ]); |
|
| 871 | + $table->addColumn('object_type', 'string', [ |
|
| 872 | + 'notnull' => true, |
|
| 873 | + 'length' => 64, |
|
| 874 | + 'default' => '', |
|
| 875 | + ]); |
|
| 876 | + $table->addColumn('object_id', 'string', [ |
|
| 877 | + 'notnull' => true, |
|
| 878 | + 'length' => 64, |
|
| 879 | + 'default' => '', |
|
| 880 | + ]); |
|
| 881 | + $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index'); |
|
| 882 | + $table->setPrimaryKey(['user_id', 'object_type', 'object_id'], 'crm_pk'); |
|
| 883 | 883 | // $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index'); |
| 884 | - } |
|
| 884 | + } |
|
| 885 | 885 | |
| 886 | 886 | // if (!$schema->hasTable('credentials')) { |
| 887 | 887 | // $table = $schema->createTable('credentials'); |
@@ -900,139 +900,139 @@ discard block |
||
| 900 | 900 | // $table->addIndex(['user'], 'credentials_user'); |
| 901 | 901 | // } |
| 902 | 902 | |
| 903 | - if (!$schema->hasTable('admin_sections')) { |
|
| 904 | - $table = $schema->createTable('admin_sections'); |
|
| 905 | - $table->addColumn('id', 'string', [ |
|
| 906 | - 'notnull' => true, |
|
| 907 | - 'length' => 64, |
|
| 908 | - ]); |
|
| 909 | - $table->addColumn('class', 'string', [ |
|
| 910 | - 'notnull' => true, |
|
| 911 | - 'length' => 255, |
|
| 912 | - 'default' => '', |
|
| 913 | - ]); |
|
| 914 | - $table->addColumn('priority', 'smallint', [ |
|
| 915 | - 'notnull' => true, |
|
| 916 | - 'length' => 1, |
|
| 917 | - 'default' => 0, |
|
| 918 | - ]); |
|
| 919 | - $table->setPrimaryKey(['id']); |
|
| 920 | - $table->addUniqueIndex(['class'], 'admin_sections_class'); |
|
| 921 | - } |
|
| 903 | + if (!$schema->hasTable('admin_sections')) { |
|
| 904 | + $table = $schema->createTable('admin_sections'); |
|
| 905 | + $table->addColumn('id', 'string', [ |
|
| 906 | + 'notnull' => true, |
|
| 907 | + 'length' => 64, |
|
| 908 | + ]); |
|
| 909 | + $table->addColumn('class', 'string', [ |
|
| 910 | + 'notnull' => true, |
|
| 911 | + 'length' => 255, |
|
| 912 | + 'default' => '', |
|
| 913 | + ]); |
|
| 914 | + $table->addColumn('priority', 'smallint', [ |
|
| 915 | + 'notnull' => true, |
|
| 916 | + 'length' => 1, |
|
| 917 | + 'default' => 0, |
|
| 918 | + ]); |
|
| 919 | + $table->setPrimaryKey(['id']); |
|
| 920 | + $table->addUniqueIndex(['class'], 'admin_sections_class'); |
|
| 921 | + } |
|
| 922 | 922 | |
| 923 | - if (!$schema->hasTable('admin_settings')) { |
|
| 924 | - $table = $schema->createTable('admin_settings'); |
|
| 925 | - $table->addColumn('id', 'integer', [ |
|
| 926 | - 'autoincrement' => true, |
|
| 927 | - 'notnull' => true, |
|
| 928 | - 'length' => 4, |
|
| 929 | - ]); |
|
| 930 | - $table->addColumn('class', 'string', [ |
|
| 931 | - 'notnull' => true, |
|
| 932 | - 'length' => 255, |
|
| 933 | - 'default' => '', |
|
| 934 | - ]); |
|
| 935 | - $table->addColumn('section', 'string', [ |
|
| 936 | - 'notnull' => false, |
|
| 937 | - 'length' => 64, |
|
| 938 | - ]); |
|
| 939 | - $table->addColumn('priority', 'smallint', [ |
|
| 940 | - 'notnull' => true, |
|
| 941 | - 'length' => 1, |
|
| 942 | - 'default' => 0, |
|
| 943 | - ]); |
|
| 944 | - $table->setPrimaryKey(['id']); |
|
| 945 | - $table->addUniqueIndex(['class'], 'admin_settings_class'); |
|
| 946 | - $table->addIndex(['section'], 'admin_settings_section'); |
|
| 947 | - } |
|
| 923 | + if (!$schema->hasTable('admin_settings')) { |
|
| 924 | + $table = $schema->createTable('admin_settings'); |
|
| 925 | + $table->addColumn('id', 'integer', [ |
|
| 926 | + 'autoincrement' => true, |
|
| 927 | + 'notnull' => true, |
|
| 928 | + 'length' => 4, |
|
| 929 | + ]); |
|
| 930 | + $table->addColumn('class', 'string', [ |
|
| 931 | + 'notnull' => true, |
|
| 932 | + 'length' => 255, |
|
| 933 | + 'default' => '', |
|
| 934 | + ]); |
|
| 935 | + $table->addColumn('section', 'string', [ |
|
| 936 | + 'notnull' => false, |
|
| 937 | + 'length' => 64, |
|
| 938 | + ]); |
|
| 939 | + $table->addColumn('priority', 'smallint', [ |
|
| 940 | + 'notnull' => true, |
|
| 941 | + 'length' => 1, |
|
| 942 | + 'default' => 0, |
|
| 943 | + ]); |
|
| 944 | + $table->setPrimaryKey(['id']); |
|
| 945 | + $table->addUniqueIndex(['class'], 'admin_settings_class'); |
|
| 946 | + $table->addIndex(['section'], 'admin_settings_section'); |
|
| 947 | + } |
|
| 948 | 948 | |
| 949 | - if (!$schema->hasTable('personal_sections')) { |
|
| 950 | - $table = $schema->createTable('personal_sections'); |
|
| 951 | - $table->addColumn('id', 'string', [ |
|
| 952 | - 'notnull' => true, |
|
| 953 | - 'length' => 64, |
|
| 954 | - ]); |
|
| 955 | - $table->addColumn('class', 'string', [ |
|
| 956 | - 'notnull' => true, |
|
| 957 | - 'length' => 255, |
|
| 958 | - 'default' => '', |
|
| 959 | - ]); |
|
| 960 | - $table->addColumn('priority', 'smallint', [ |
|
| 961 | - 'notnull' => true, |
|
| 962 | - 'length' => 1, |
|
| 963 | - 'default' => 0, |
|
| 964 | - ]); |
|
| 965 | - $table->setPrimaryKey(['id']); |
|
| 966 | - $table->addUniqueIndex(['class'], 'personal_sections_class'); |
|
| 967 | - } |
|
| 949 | + if (!$schema->hasTable('personal_sections')) { |
|
| 950 | + $table = $schema->createTable('personal_sections'); |
|
| 951 | + $table->addColumn('id', 'string', [ |
|
| 952 | + 'notnull' => true, |
|
| 953 | + 'length' => 64, |
|
| 954 | + ]); |
|
| 955 | + $table->addColumn('class', 'string', [ |
|
| 956 | + 'notnull' => true, |
|
| 957 | + 'length' => 255, |
|
| 958 | + 'default' => '', |
|
| 959 | + ]); |
|
| 960 | + $table->addColumn('priority', 'smallint', [ |
|
| 961 | + 'notnull' => true, |
|
| 962 | + 'length' => 1, |
|
| 963 | + 'default' => 0, |
|
| 964 | + ]); |
|
| 965 | + $table->setPrimaryKey(['id']); |
|
| 966 | + $table->addUniqueIndex(['class'], 'personal_sections_class'); |
|
| 967 | + } |
|
| 968 | 968 | |
| 969 | - if (!$schema->hasTable('personal_settings')) { |
|
| 970 | - $table = $schema->createTable('personal_settings'); |
|
| 971 | - $table->addColumn('id', 'integer', [ |
|
| 972 | - 'autoincrement' => true, |
|
| 973 | - 'notnull' => true, |
|
| 974 | - 'length' => 4, |
|
| 975 | - ]); |
|
| 976 | - $table->addColumn('class', 'string', [ |
|
| 977 | - 'notnull' => true, |
|
| 978 | - 'length' => 255, |
|
| 979 | - 'default' => '', |
|
| 980 | - ]); |
|
| 981 | - $table->addColumn('section', 'string', [ |
|
| 982 | - 'notnull' => false, |
|
| 983 | - 'length' => 64, |
|
| 984 | - ]); |
|
| 985 | - $table->addColumn('priority', 'smallint', [ |
|
| 986 | - 'notnull' => true, |
|
| 987 | - 'length' => 1, |
|
| 988 | - 'default' => 0, |
|
| 989 | - ]); |
|
| 990 | - $table->setPrimaryKey(['id']); |
|
| 991 | - $table->addUniqueIndex(['class'], 'personal_settings_class'); |
|
| 992 | - $table->addIndex(['section'], 'personal_settings_section'); |
|
| 993 | - } |
|
| 969 | + if (!$schema->hasTable('personal_settings')) { |
|
| 970 | + $table = $schema->createTable('personal_settings'); |
|
| 971 | + $table->addColumn('id', 'integer', [ |
|
| 972 | + 'autoincrement' => true, |
|
| 973 | + 'notnull' => true, |
|
| 974 | + 'length' => 4, |
|
| 975 | + ]); |
|
| 976 | + $table->addColumn('class', 'string', [ |
|
| 977 | + 'notnull' => true, |
|
| 978 | + 'length' => 255, |
|
| 979 | + 'default' => '', |
|
| 980 | + ]); |
|
| 981 | + $table->addColumn('section', 'string', [ |
|
| 982 | + 'notnull' => false, |
|
| 983 | + 'length' => 64, |
|
| 984 | + ]); |
|
| 985 | + $table->addColumn('priority', 'smallint', [ |
|
| 986 | + 'notnull' => true, |
|
| 987 | + 'length' => 1, |
|
| 988 | + 'default' => 0, |
|
| 989 | + ]); |
|
| 990 | + $table->setPrimaryKey(['id']); |
|
| 991 | + $table->addUniqueIndex(['class'], 'personal_settings_class'); |
|
| 992 | + $table->addIndex(['section'], 'personal_settings_section'); |
|
| 993 | + } |
|
| 994 | 994 | |
| 995 | - if (!$schema->hasTable('accounts')) { |
|
| 996 | - $table = $schema->createTable('accounts'); |
|
| 997 | - $table->addColumn('uid', 'string', [ |
|
| 998 | - 'notnull' => true, |
|
| 999 | - 'length' => 64, |
|
| 1000 | - 'default' => '', |
|
| 1001 | - ]); |
|
| 1002 | - $table->addColumn('data', 'text', [ |
|
| 1003 | - 'notnull' => true, |
|
| 1004 | - 'default' => '', |
|
| 1005 | - ]); |
|
| 1006 | - $table->setPrimaryKey(['uid']); |
|
| 1007 | - } |
|
| 1008 | - return $schema; |
|
| 1009 | - } |
|
| 995 | + if (!$schema->hasTable('accounts')) { |
|
| 996 | + $table = $schema->createTable('accounts'); |
|
| 997 | + $table->addColumn('uid', 'string', [ |
|
| 998 | + 'notnull' => true, |
|
| 999 | + 'length' => 64, |
|
| 1000 | + 'default' => '', |
|
| 1001 | + ]); |
|
| 1002 | + $table->addColumn('data', 'text', [ |
|
| 1003 | + 'notnull' => true, |
|
| 1004 | + 'default' => '', |
|
| 1005 | + ]); |
|
| 1006 | + $table->setPrimaryKey(['uid']); |
|
| 1007 | + } |
|
| 1008 | + return $schema; |
|
| 1009 | + } |
|
| 1010 | 1010 | |
| 1011 | - public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 1012 | - /** @var ISchemaWrapper $schema */ |
|
| 1013 | - $schema = $schemaClosure(); |
|
| 1014 | - if (!$schema->hasTable('dav_properties')) { |
|
| 1015 | - return; |
|
| 1016 | - } |
|
| 1017 | - $query = $this->connection->getQueryBuilder(); |
|
| 1018 | - $query->select('*') |
|
| 1019 | - ->from('dav_properties'); |
|
| 1011 | + public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 1012 | + /** @var ISchemaWrapper $schema */ |
|
| 1013 | + $schema = $schemaClosure(); |
|
| 1014 | + if (!$schema->hasTable('dav_properties')) { |
|
| 1015 | + return; |
|
| 1016 | + } |
|
| 1017 | + $query = $this->connection->getQueryBuilder(); |
|
| 1018 | + $query->select('*') |
|
| 1019 | + ->from('dav_properties'); |
|
| 1020 | 1020 | |
| 1021 | - $insert = $this->connection->getQueryBuilder(); |
|
| 1022 | - $insert->insert('properties') |
|
| 1023 | - ->setValue('propertypath', $insert->createParameter('propertypath')) |
|
| 1024 | - ->setValue('propertyname', $insert->createParameter('propertyname')) |
|
| 1025 | - ->setValue('propertyvalue', $insert->createParameter('propertyvalue')) |
|
| 1026 | - ->setValue('userid', $insert->createParameter('userid')); |
|
| 1021 | + $insert = $this->connection->getQueryBuilder(); |
|
| 1022 | + $insert->insert('properties') |
|
| 1023 | + ->setValue('propertypath', $insert->createParameter('propertypath')) |
|
| 1024 | + ->setValue('propertyname', $insert->createParameter('propertyname')) |
|
| 1025 | + ->setValue('propertyvalue', $insert->createParameter('propertyvalue')) |
|
| 1026 | + ->setValue('userid', $insert->createParameter('userid')); |
|
| 1027 | 1027 | |
| 1028 | - $result = $query->execute(); |
|
| 1029 | - while ($row = $result->fetch()) { |
|
| 1030 | - preg_match('/(calendar)\/([A-z0-9-@_]+)\//', $row['propertypath'], $match); |
|
| 1031 | - $insert->setParameter('propertypath', (string) $row['propertypath']) |
|
| 1032 | - ->setParameter('propertyname', (string) $row['propertyname']) |
|
| 1033 | - ->setParameter('propertyvalue', (string) $row['propertyvalue']) |
|
| 1034 | - ->setParameter('userid', ($match[2] ?? '')); |
|
| 1035 | - $insert->execute(); |
|
| 1036 | - } |
|
| 1037 | - } |
|
| 1028 | + $result = $query->execute(); |
|
| 1029 | + while ($row = $result->fetch()) { |
|
| 1030 | + preg_match('/(calendar)\/([A-z0-9-@_]+)\//', $row['propertypath'], $match); |
|
| 1031 | + $insert->setParameter('propertypath', (string) $row['propertypath']) |
|
| 1032 | + ->setParameter('propertyname', (string) $row['propertyname']) |
|
| 1033 | + ->setParameter('propertyvalue', (string) $row['propertyvalue']) |
|
| 1034 | + ->setParameter('userid', ($match[2] ?? '')); |
|
| 1035 | + $insert->execute(); |
|
| 1036 | + } |
|
| 1037 | + } |
|
| 1038 | 1038 | } |
@@ -37,85 +37,85 @@ |
||
| 37 | 37 | * @package OC\Security\Normalizer |
| 38 | 38 | */ |
| 39 | 39 | class IpAddress { |
| 40 | - /** @var string */ |
|
| 41 | - private $ip; |
|
| 40 | + /** @var string */ |
|
| 41 | + private $ip; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param string $ip IP to normalized |
|
| 45 | - */ |
|
| 46 | - public function __construct(string $ip) { |
|
| 47 | - $this->ip = $ip; |
|
| 48 | - } |
|
| 43 | + /** |
|
| 44 | + * @param string $ip IP to normalized |
|
| 45 | + */ |
|
| 46 | + public function __construct(string $ip) { |
|
| 47 | + $this->ip = $ip; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Return the given subnet for an IPv4 address and mask bits |
|
| 52 | - * |
|
| 53 | - * @param string $ip |
|
| 54 | - * @param int $maskBits |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - private function getIPv4Subnet(string $ip, int $maskBits = 32): string { |
|
| 58 | - $binary = \inet_pton($ip); |
|
| 59 | - for ($i = 32; $i > $maskBits; $i -= 8) { |
|
| 60 | - $j = \intdiv($i, 8) - 1; |
|
| 61 | - $k = \min(8, $i - $maskBits); |
|
| 62 | - $mask = (0xff - ((2 ** $k) - 1)); |
|
| 63 | - $int = \unpack('C', $binary[$j]); |
|
| 64 | - $binary[$j] = \pack('C', $int[1] & $mask); |
|
| 65 | - } |
|
| 66 | - return \inet_ntop($binary).'/'.$maskBits; |
|
| 67 | - } |
|
| 50 | + /** |
|
| 51 | + * Return the given subnet for an IPv4 address and mask bits |
|
| 52 | + * |
|
| 53 | + * @param string $ip |
|
| 54 | + * @param int $maskBits |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + private function getIPv4Subnet(string $ip, int $maskBits = 32): string { |
|
| 58 | + $binary = \inet_pton($ip); |
|
| 59 | + for ($i = 32; $i > $maskBits; $i -= 8) { |
|
| 60 | + $j = \intdiv($i, 8) - 1; |
|
| 61 | + $k = \min(8, $i - $maskBits); |
|
| 62 | + $mask = (0xff - ((2 ** $k) - 1)); |
|
| 63 | + $int = \unpack('C', $binary[$j]); |
|
| 64 | + $binary[$j] = \pack('C', $int[1] & $mask); |
|
| 65 | + } |
|
| 66 | + return \inet_ntop($binary).'/'.$maskBits; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Return the given subnet for an IPv6 address and mask bits |
|
| 71 | - * |
|
| 72 | - * @param string $ip |
|
| 73 | - * @param int $maskBits |
|
| 74 | - * @return string |
|
| 75 | - */ |
|
| 76 | - private function getIPv6Subnet(string $ip, int $maskBits = 48): string { |
|
| 77 | - if ($ip[0] === '[' && $ip[-1] === ']') { // If IP is with brackets, for example [::1] |
|
| 78 | - $ip = substr($ip, 1, strlen($ip) - 2); |
|
| 79 | - } |
|
| 80 | - $pos = strpos($ip, '%'); // if there is an explicit interface added to the IP, e.g. fe80::ae2d:d1e7:fe1e:9a8d%enp2s0 |
|
| 81 | - if ($pos !== false) { |
|
| 82 | - $ip = substr($ip, 0, $pos - 1); |
|
| 83 | - } |
|
| 84 | - $binary = \inet_pton($ip); |
|
| 85 | - for ($i = 128; $i > $maskBits; $i -= 8) { |
|
| 86 | - $j = \intdiv($i, 8) - 1; |
|
| 87 | - $k = \min(8, $i - $maskBits); |
|
| 88 | - $mask = (0xff - ((2 ** $k) - 1)); |
|
| 89 | - $int = \unpack('C', $binary[$j]); |
|
| 90 | - $binary[$j] = \pack('C', $int[1] & $mask); |
|
| 91 | - } |
|
| 92 | - return \inet_ntop($binary).'/'.$maskBits; |
|
| 93 | - } |
|
| 69 | + /** |
|
| 70 | + * Return the given subnet for an IPv6 address and mask bits |
|
| 71 | + * |
|
| 72 | + * @param string $ip |
|
| 73 | + * @param int $maskBits |
|
| 74 | + * @return string |
|
| 75 | + */ |
|
| 76 | + private function getIPv6Subnet(string $ip, int $maskBits = 48): string { |
|
| 77 | + if ($ip[0] === '[' && $ip[-1] === ']') { // If IP is with brackets, for example [::1] |
|
| 78 | + $ip = substr($ip, 1, strlen($ip) - 2); |
|
| 79 | + } |
|
| 80 | + $pos = strpos($ip, '%'); // if there is an explicit interface added to the IP, e.g. fe80::ae2d:d1e7:fe1e:9a8d%enp2s0 |
|
| 81 | + if ($pos !== false) { |
|
| 82 | + $ip = substr($ip, 0, $pos - 1); |
|
| 83 | + } |
|
| 84 | + $binary = \inet_pton($ip); |
|
| 85 | + for ($i = 128; $i > $maskBits; $i -= 8) { |
|
| 86 | + $j = \intdiv($i, 8) - 1; |
|
| 87 | + $k = \min(8, $i - $maskBits); |
|
| 88 | + $mask = (0xff - ((2 ** $k) - 1)); |
|
| 89 | + $int = \unpack('C', $binary[$j]); |
|
| 90 | + $binary[$j] = \pack('C', $int[1] & $mask); |
|
| 91 | + } |
|
| 92 | + return \inet_ntop($binary).'/'.$maskBits; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Gets either the /32 (IPv4) or the /128 (IPv6) subnet of an IP address |
|
| 97 | - * |
|
| 98 | - * @return string |
|
| 99 | - */ |
|
| 100 | - public function getSubnet(): string { |
|
| 101 | - if (\preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $this->ip)) { |
|
| 102 | - return $this->getIPv4Subnet( |
|
| 103 | - $this->ip, |
|
| 104 | - 32 |
|
| 105 | - ); |
|
| 106 | - } |
|
| 107 | - return $this->getIPv6Subnet( |
|
| 108 | - $this->ip, |
|
| 109 | - 128 |
|
| 110 | - ); |
|
| 111 | - } |
|
| 95 | + /** |
|
| 96 | + * Gets either the /32 (IPv4) or the /128 (IPv6) subnet of an IP address |
|
| 97 | + * |
|
| 98 | + * @return string |
|
| 99 | + */ |
|
| 100 | + public function getSubnet(): string { |
|
| 101 | + if (\preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $this->ip)) { |
|
| 102 | + return $this->getIPv4Subnet( |
|
| 103 | + $this->ip, |
|
| 104 | + 32 |
|
| 105 | + ); |
|
| 106 | + } |
|
| 107 | + return $this->getIPv6Subnet( |
|
| 108 | + $this->ip, |
|
| 109 | + 128 |
|
| 110 | + ); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Returns the specified IP address |
|
| 115 | - * |
|
| 116 | - * @return string |
|
| 117 | - */ |
|
| 118 | - public function __toString(): string { |
|
| 119 | - return $this->ip; |
|
| 120 | - } |
|
| 113 | + /** |
|
| 114 | + * Returns the specified IP address |
|
| 115 | + * |
|
| 116 | + * @return string |
|
| 117 | + */ |
|
| 118 | + public function __toString(): string { |
|
| 119 | + return $this->ip; |
|
| 120 | + } |
|
| 121 | 121 | } |
@@ -36,371 +36,371 @@ |
||
| 36 | 36 | |
| 37 | 37 | class DependencyAnalyzer { |
| 38 | 38 | |
| 39 | - /** @var Platform */ |
|
| 40 | - private $platform; |
|
| 41 | - /** @var \OCP\IL10N */ |
|
| 42 | - private $l; |
|
| 43 | - /** @var array */ |
|
| 44 | - private $appInfo; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @param Platform $platform |
|
| 48 | - * @param \OCP\IL10N $l |
|
| 49 | - */ |
|
| 50 | - public function __construct(Platform $platform, IL10N $l) { |
|
| 51 | - $this->platform = $platform; |
|
| 52 | - $this->l = $l; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @param array $app |
|
| 57 | - * @returns array of missing dependencies |
|
| 58 | - */ |
|
| 59 | - public function analyze(array $app, bool $ignoreMax = false) { |
|
| 60 | - $this->appInfo = $app; |
|
| 61 | - if (isset($app['dependencies'])) { |
|
| 62 | - $dependencies = $app['dependencies']; |
|
| 63 | - } else { |
|
| 64 | - $dependencies = []; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - return array_merge( |
|
| 68 | - $this->analyzeArchitecture($dependencies), |
|
| 69 | - $this->analyzePhpVersion($dependencies), |
|
| 70 | - $this->analyzeDatabases($dependencies), |
|
| 71 | - $this->analyzeCommands($dependencies), |
|
| 72 | - $this->analyzeLibraries($dependencies), |
|
| 73 | - $this->analyzeOS($dependencies), |
|
| 74 | - $this->analyzeOC($dependencies, $app, $ignoreMax) |
|
| 75 | - ); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - public function isMarkedCompatible(array $app): bool { |
|
| 79 | - if (isset($app['dependencies'])) { |
|
| 80 | - $dependencies = $app['dependencies']; |
|
| 81 | - } else { |
|
| 82 | - $dependencies = []; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - $maxVersion = $this->getMaxVersion($dependencies, $app); |
|
| 86 | - if ($maxVersion === null) { |
|
| 87 | - return true; |
|
| 88 | - } |
|
| 89 | - return !$this->compareBigger($this->platform->getOcVersion(), $maxVersion); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Truncates both versions to the lowest common version, e.g. |
|
| 94 | - * 5.1.2.3 and 5.1 will be turned into 5.1 and 5.1, |
|
| 95 | - * 5.2.6.5 and 5.1 will be turned into 5.2 and 5.1 |
|
| 96 | - * @param string $first |
|
| 97 | - * @param string $second |
|
| 98 | - * @return string[] first element is the first version, second element is the |
|
| 99 | - * second version |
|
| 100 | - */ |
|
| 101 | - private function normalizeVersions($first, $second) { |
|
| 102 | - $first = explode('.', $first); |
|
| 103 | - $second = explode('.', $second); |
|
| 104 | - |
|
| 105 | - // get both arrays to the same minimum size |
|
| 106 | - $length = min(count($second), count($first)); |
|
| 107 | - $first = array_slice($first, 0, $length); |
|
| 108 | - $second = array_slice($second, 0, $length); |
|
| 109 | - |
|
| 110 | - return [implode('.', $first), implode('.', $second)]; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Parameters will be normalized and then passed into version_compare |
|
| 115 | - * in the same order they are specified in the method header |
|
| 116 | - * @param string $first |
|
| 117 | - * @param string $second |
|
| 118 | - * @param string $operator |
|
| 119 | - * @return bool result similar to version_compare |
|
| 120 | - */ |
|
| 121 | - private function compare($first, $second, $operator) { |
|
| 122 | - // we can't normalize versions if one of the given parameters is not a |
|
| 123 | - // version string but null. In case one parameter is null normalization |
|
| 124 | - // will therefore be skipped |
|
| 125 | - if ($first !== null && $second !== null) { |
|
| 126 | - list($first, $second) = $this->normalizeVersions($first, $second); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - return version_compare($first, $second, $operator); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Checks if a version is bigger than another version |
|
| 134 | - * @param string $first |
|
| 135 | - * @param string $second |
|
| 136 | - * @return bool true if the first version is bigger than the second |
|
| 137 | - */ |
|
| 138 | - private function compareBigger($first, $second) { |
|
| 139 | - return $this->compare($first, $second, '>'); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Checks if a version is smaller than another version |
|
| 144 | - * @param string $first |
|
| 145 | - * @param string $second |
|
| 146 | - * @return bool true if the first version is smaller than the second |
|
| 147 | - */ |
|
| 148 | - private function compareSmaller($first, $second) { |
|
| 149 | - return $this->compare($first, $second, '<'); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * @param array $dependencies |
|
| 154 | - * @return array |
|
| 155 | - */ |
|
| 156 | - private function analyzePhpVersion(array $dependencies) { |
|
| 157 | - $missing = []; |
|
| 158 | - if (isset($dependencies['php']['@attributes']['min-version'])) { |
|
| 159 | - $minVersion = $dependencies['php']['@attributes']['min-version']; |
|
| 160 | - if ($this->compareSmaller($this->platform->getPhpVersion(), $minVersion)) { |
|
| 161 | - $missing[] = $this->l->t('PHP %s or higher is required.', [$minVersion]); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - if (isset($dependencies['php']['@attributes']['max-version'])) { |
|
| 165 | - $maxVersion = $dependencies['php']['@attributes']['max-version']; |
|
| 166 | - if ($this->compareBigger($this->platform->getPhpVersion(), $maxVersion)) { |
|
| 167 | - $missing[] = $this->l->t('PHP with a version lower than %s is required.', [$maxVersion]); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - if (isset($dependencies['php']['@attributes']['min-int-size'])) { |
|
| 171 | - $intSize = $dependencies['php']['@attributes']['min-int-size']; |
|
| 172 | - if ($intSize > $this->platform->getIntSize() * 8) { |
|
| 173 | - $missing[] = $this->l->t('%sbit or higher PHP required.', [$intSize]); |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - return $missing; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - private function analyzeArchitecture(array $dependencies) { |
|
| 180 | - $missing = []; |
|
| 181 | - if (!isset($dependencies['architecture'])) { |
|
| 182 | - return $missing; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - $supportedArchitectures = $dependencies['architecture']; |
|
| 186 | - if (empty($supportedArchitectures)) { |
|
| 187 | - return $missing; |
|
| 188 | - } |
|
| 189 | - if (!is_array($supportedArchitectures)) { |
|
| 190 | - $supportedArchitectures = [$supportedArchitectures]; |
|
| 191 | - } |
|
| 192 | - $supportedArchitectures = array_map(function ($architecture) { |
|
| 193 | - return $this->getValue($architecture); |
|
| 194 | - }, $supportedArchitectures); |
|
| 195 | - $currentArchitecture = $this->platform->getArchitecture(); |
|
| 196 | - if (!in_array($currentArchitecture, $supportedArchitectures, true)) { |
|
| 197 | - $missing[] = $this->l->t('The following architectures are supported: %s', [implode(', ', $supportedArchitectures)]); |
|
| 198 | - } |
|
| 199 | - return $missing; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * @param array $dependencies |
|
| 204 | - * @return array |
|
| 205 | - */ |
|
| 206 | - private function analyzeDatabases(array $dependencies) { |
|
| 207 | - $missing = []; |
|
| 208 | - if (!isset($dependencies['database'])) { |
|
| 209 | - return $missing; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - $supportedDatabases = $dependencies['database']; |
|
| 213 | - if (empty($supportedDatabases)) { |
|
| 214 | - return $missing; |
|
| 215 | - } |
|
| 216 | - if (!is_array($supportedDatabases)) { |
|
| 217 | - $supportedDatabases = [$supportedDatabases]; |
|
| 218 | - } |
|
| 219 | - $supportedDatabases = array_map(function ($db) { |
|
| 220 | - return $this->getValue($db); |
|
| 221 | - }, $supportedDatabases); |
|
| 222 | - $currentDatabase = $this->platform->getDatabase(); |
|
| 223 | - if (!in_array($currentDatabase, $supportedDatabases)) { |
|
| 224 | - $missing[] = $this->l->t('The following databases are supported: %s', [implode(', ', $supportedDatabases)]); |
|
| 225 | - } |
|
| 226 | - return $missing; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * @param array $dependencies |
|
| 231 | - * @return array |
|
| 232 | - */ |
|
| 233 | - private function analyzeCommands(array $dependencies) { |
|
| 234 | - $missing = []; |
|
| 235 | - if (!isset($dependencies['command'])) { |
|
| 236 | - return $missing; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - $commands = $dependencies['command']; |
|
| 240 | - if (!is_array($commands)) { |
|
| 241 | - $commands = [$commands]; |
|
| 242 | - } |
|
| 243 | - if (isset($commands['@value'])) { |
|
| 244 | - $commands = [$commands]; |
|
| 245 | - } |
|
| 246 | - $os = $this->platform->getOS(); |
|
| 247 | - foreach ($commands as $command) { |
|
| 248 | - if (isset($command['@attributes']['os']) && $command['@attributes']['os'] !== $os) { |
|
| 249 | - continue; |
|
| 250 | - } |
|
| 251 | - $commandName = $this->getValue($command); |
|
| 252 | - if (!$this->platform->isCommandKnown($commandName)) { |
|
| 253 | - $missing[] = $this->l->t('The command line tool %s could not be found', [$commandName]); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - return $missing; |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * @param array $dependencies |
|
| 261 | - * @return array |
|
| 262 | - */ |
|
| 263 | - private function analyzeLibraries(array $dependencies) { |
|
| 264 | - $missing = []; |
|
| 265 | - if (!isset($dependencies['lib'])) { |
|
| 266 | - return $missing; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - $libs = $dependencies['lib']; |
|
| 270 | - if (!is_array($libs)) { |
|
| 271 | - $libs = [$libs]; |
|
| 272 | - } |
|
| 273 | - if (isset($libs['@value'])) { |
|
| 274 | - $libs = [$libs]; |
|
| 275 | - } |
|
| 276 | - foreach ($libs as $lib) { |
|
| 277 | - $libName = $this->getValue($lib); |
|
| 278 | - $libVersion = $this->platform->getLibraryVersion($libName); |
|
| 279 | - if (is_null($libVersion)) { |
|
| 280 | - $missing[] = $this->l->t('The library %s is not available.', [$libName]); |
|
| 281 | - continue; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - if (is_array($lib)) { |
|
| 285 | - if (isset($lib['@attributes']['min-version'])) { |
|
| 286 | - $minVersion = $lib['@attributes']['min-version']; |
|
| 287 | - if ($this->compareSmaller($libVersion, $minVersion)) { |
|
| 288 | - $missing[] = $this->l->t('Library %1$s with a version higher than %2$s is required - available version %3$s.', |
|
| 289 | - [$libName, $minVersion, $libVersion]); |
|
| 290 | - } |
|
| 291 | - } |
|
| 292 | - if (isset($lib['@attributes']['max-version'])) { |
|
| 293 | - $maxVersion = $lib['@attributes']['max-version']; |
|
| 294 | - if ($this->compareBigger($libVersion, $maxVersion)) { |
|
| 295 | - $missing[] = $this->l->t('Library %1$s with a version lower than %2$s is required - available version %3$s.', |
|
| 296 | - [$libName, $maxVersion, $libVersion]); |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - return $missing; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * @param array $dependencies |
|
| 306 | - * @return array |
|
| 307 | - */ |
|
| 308 | - private function analyzeOS(array $dependencies) { |
|
| 309 | - $missing = []; |
|
| 310 | - if (!isset($dependencies['os'])) { |
|
| 311 | - return $missing; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - $oss = $dependencies['os']; |
|
| 315 | - if (empty($oss)) { |
|
| 316 | - return $missing; |
|
| 317 | - } |
|
| 318 | - if (is_array($oss)) { |
|
| 319 | - $oss = array_map(function ($os) { |
|
| 320 | - return $this->getValue($os); |
|
| 321 | - }, $oss); |
|
| 322 | - } else { |
|
| 323 | - $oss = [$oss]; |
|
| 324 | - } |
|
| 325 | - $currentOS = $this->platform->getOS(); |
|
| 326 | - if (!in_array($currentOS, $oss)) { |
|
| 327 | - $missing[] = $this->l->t('The following platforms are supported: %s', [implode(', ', $oss)]); |
|
| 328 | - } |
|
| 329 | - return $missing; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * @param array $dependencies |
|
| 334 | - * @param array $appInfo |
|
| 335 | - * @return array |
|
| 336 | - */ |
|
| 337 | - private function analyzeOC(array $dependencies, array $appInfo, bool $ignoreMax) { |
|
| 338 | - $missing = []; |
|
| 339 | - $minVersion = null; |
|
| 340 | - if (isset($dependencies['nextcloud']['@attributes']['min-version'])) { |
|
| 341 | - $minVersion = $dependencies['nextcloud']['@attributes']['min-version']; |
|
| 342 | - } elseif (isset($dependencies['owncloud']['@attributes']['min-version'])) { |
|
| 343 | - $minVersion = $dependencies['owncloud']['@attributes']['min-version']; |
|
| 344 | - } elseif (isset($appInfo['requiremin'])) { |
|
| 345 | - $minVersion = $appInfo['requiremin']; |
|
| 346 | - } elseif (isset($appInfo['require'])) { |
|
| 347 | - $minVersion = $appInfo['require']; |
|
| 348 | - } |
|
| 349 | - $maxVersion = $this->getMaxVersion($dependencies, $appInfo); |
|
| 350 | - |
|
| 351 | - if (!is_null($minVersion)) { |
|
| 352 | - if ($this->compareSmaller($this->platform->getOcVersion(), $minVersion)) { |
|
| 353 | - $missing[] = $this->l->t('Server version %s or higher is required.', [$this->toVisibleVersion($minVersion)]); |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - if (!$ignoreMax && !is_null($maxVersion)) { |
|
| 357 | - if ($this->compareBigger($this->platform->getOcVersion(), $maxVersion)) { |
|
| 358 | - $missing[] = $this->l->t('Server version %s or lower is required.', [$this->toVisibleVersion($maxVersion)]); |
|
| 359 | - } |
|
| 360 | - } |
|
| 361 | - return $missing; |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - private function getMaxVersion(array $dependencies, array $appInfo): ?string { |
|
| 365 | - if (isset($dependencies['nextcloud']['@attributes']['max-version'])) { |
|
| 366 | - return $dependencies['nextcloud']['@attributes']['max-version']; |
|
| 367 | - } |
|
| 368 | - if (isset($dependencies['owncloud']['@attributes']['max-version'])) { |
|
| 369 | - return $dependencies['owncloud']['@attributes']['max-version']; |
|
| 370 | - } |
|
| 371 | - if (isset($appInfo['requiremax'])) { |
|
| 372 | - return $appInfo['requiremax']; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - return null; |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * Map the internal version number to the Nextcloud version |
|
| 380 | - * |
|
| 381 | - * @param string $version |
|
| 382 | - * @return string |
|
| 383 | - */ |
|
| 384 | - protected function toVisibleVersion($version) { |
|
| 385 | - switch ($version) { |
|
| 386 | - case '9.1': |
|
| 387 | - return '10'; |
|
| 388 | - default: |
|
| 389 | - if (strpos($version, '9.1.') === 0) { |
|
| 390 | - $version = '10.0.' . substr($version, 4); |
|
| 391 | - } |
|
| 392 | - return $version; |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * @param $element |
|
| 398 | - * @return mixed |
|
| 399 | - */ |
|
| 400 | - private function getValue($element) { |
|
| 401 | - if (isset($element['@value'])) { |
|
| 402 | - return $element['@value']; |
|
| 403 | - } |
|
| 404 | - return (string)$element; |
|
| 405 | - } |
|
| 39 | + /** @var Platform */ |
|
| 40 | + private $platform; |
|
| 41 | + /** @var \OCP\IL10N */ |
|
| 42 | + private $l; |
|
| 43 | + /** @var array */ |
|
| 44 | + private $appInfo; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @param Platform $platform |
|
| 48 | + * @param \OCP\IL10N $l |
|
| 49 | + */ |
|
| 50 | + public function __construct(Platform $platform, IL10N $l) { |
|
| 51 | + $this->platform = $platform; |
|
| 52 | + $this->l = $l; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @param array $app |
|
| 57 | + * @returns array of missing dependencies |
|
| 58 | + */ |
|
| 59 | + public function analyze(array $app, bool $ignoreMax = false) { |
|
| 60 | + $this->appInfo = $app; |
|
| 61 | + if (isset($app['dependencies'])) { |
|
| 62 | + $dependencies = $app['dependencies']; |
|
| 63 | + } else { |
|
| 64 | + $dependencies = []; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + return array_merge( |
|
| 68 | + $this->analyzeArchitecture($dependencies), |
|
| 69 | + $this->analyzePhpVersion($dependencies), |
|
| 70 | + $this->analyzeDatabases($dependencies), |
|
| 71 | + $this->analyzeCommands($dependencies), |
|
| 72 | + $this->analyzeLibraries($dependencies), |
|
| 73 | + $this->analyzeOS($dependencies), |
|
| 74 | + $this->analyzeOC($dependencies, $app, $ignoreMax) |
|
| 75 | + ); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + public function isMarkedCompatible(array $app): bool { |
|
| 79 | + if (isset($app['dependencies'])) { |
|
| 80 | + $dependencies = $app['dependencies']; |
|
| 81 | + } else { |
|
| 82 | + $dependencies = []; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + $maxVersion = $this->getMaxVersion($dependencies, $app); |
|
| 86 | + if ($maxVersion === null) { |
|
| 87 | + return true; |
|
| 88 | + } |
|
| 89 | + return !$this->compareBigger($this->platform->getOcVersion(), $maxVersion); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Truncates both versions to the lowest common version, e.g. |
|
| 94 | + * 5.1.2.3 and 5.1 will be turned into 5.1 and 5.1, |
|
| 95 | + * 5.2.6.5 and 5.1 will be turned into 5.2 and 5.1 |
|
| 96 | + * @param string $first |
|
| 97 | + * @param string $second |
|
| 98 | + * @return string[] first element is the first version, second element is the |
|
| 99 | + * second version |
|
| 100 | + */ |
|
| 101 | + private function normalizeVersions($first, $second) { |
|
| 102 | + $first = explode('.', $first); |
|
| 103 | + $second = explode('.', $second); |
|
| 104 | + |
|
| 105 | + // get both arrays to the same minimum size |
|
| 106 | + $length = min(count($second), count($first)); |
|
| 107 | + $first = array_slice($first, 0, $length); |
|
| 108 | + $second = array_slice($second, 0, $length); |
|
| 109 | + |
|
| 110 | + return [implode('.', $first), implode('.', $second)]; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Parameters will be normalized and then passed into version_compare |
|
| 115 | + * in the same order they are specified in the method header |
|
| 116 | + * @param string $first |
|
| 117 | + * @param string $second |
|
| 118 | + * @param string $operator |
|
| 119 | + * @return bool result similar to version_compare |
|
| 120 | + */ |
|
| 121 | + private function compare($first, $second, $operator) { |
|
| 122 | + // we can't normalize versions if one of the given parameters is not a |
|
| 123 | + // version string but null. In case one parameter is null normalization |
|
| 124 | + // will therefore be skipped |
|
| 125 | + if ($first !== null && $second !== null) { |
|
| 126 | + list($first, $second) = $this->normalizeVersions($first, $second); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + return version_compare($first, $second, $operator); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Checks if a version is bigger than another version |
|
| 134 | + * @param string $first |
|
| 135 | + * @param string $second |
|
| 136 | + * @return bool true if the first version is bigger than the second |
|
| 137 | + */ |
|
| 138 | + private function compareBigger($first, $second) { |
|
| 139 | + return $this->compare($first, $second, '>'); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Checks if a version is smaller than another version |
|
| 144 | + * @param string $first |
|
| 145 | + * @param string $second |
|
| 146 | + * @return bool true if the first version is smaller than the second |
|
| 147 | + */ |
|
| 148 | + private function compareSmaller($first, $second) { |
|
| 149 | + return $this->compare($first, $second, '<'); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * @param array $dependencies |
|
| 154 | + * @return array |
|
| 155 | + */ |
|
| 156 | + private function analyzePhpVersion(array $dependencies) { |
|
| 157 | + $missing = []; |
|
| 158 | + if (isset($dependencies['php']['@attributes']['min-version'])) { |
|
| 159 | + $minVersion = $dependencies['php']['@attributes']['min-version']; |
|
| 160 | + if ($this->compareSmaller($this->platform->getPhpVersion(), $minVersion)) { |
|
| 161 | + $missing[] = $this->l->t('PHP %s or higher is required.', [$minVersion]); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + if (isset($dependencies['php']['@attributes']['max-version'])) { |
|
| 165 | + $maxVersion = $dependencies['php']['@attributes']['max-version']; |
|
| 166 | + if ($this->compareBigger($this->platform->getPhpVersion(), $maxVersion)) { |
|
| 167 | + $missing[] = $this->l->t('PHP with a version lower than %s is required.', [$maxVersion]); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + if (isset($dependencies['php']['@attributes']['min-int-size'])) { |
|
| 171 | + $intSize = $dependencies['php']['@attributes']['min-int-size']; |
|
| 172 | + if ($intSize > $this->platform->getIntSize() * 8) { |
|
| 173 | + $missing[] = $this->l->t('%sbit or higher PHP required.', [$intSize]); |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + return $missing; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + private function analyzeArchitecture(array $dependencies) { |
|
| 180 | + $missing = []; |
|
| 181 | + if (!isset($dependencies['architecture'])) { |
|
| 182 | + return $missing; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + $supportedArchitectures = $dependencies['architecture']; |
|
| 186 | + if (empty($supportedArchitectures)) { |
|
| 187 | + return $missing; |
|
| 188 | + } |
|
| 189 | + if (!is_array($supportedArchitectures)) { |
|
| 190 | + $supportedArchitectures = [$supportedArchitectures]; |
|
| 191 | + } |
|
| 192 | + $supportedArchitectures = array_map(function ($architecture) { |
|
| 193 | + return $this->getValue($architecture); |
|
| 194 | + }, $supportedArchitectures); |
|
| 195 | + $currentArchitecture = $this->platform->getArchitecture(); |
|
| 196 | + if (!in_array($currentArchitecture, $supportedArchitectures, true)) { |
|
| 197 | + $missing[] = $this->l->t('The following architectures are supported: %s', [implode(', ', $supportedArchitectures)]); |
|
| 198 | + } |
|
| 199 | + return $missing; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * @param array $dependencies |
|
| 204 | + * @return array |
|
| 205 | + */ |
|
| 206 | + private function analyzeDatabases(array $dependencies) { |
|
| 207 | + $missing = []; |
|
| 208 | + if (!isset($dependencies['database'])) { |
|
| 209 | + return $missing; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + $supportedDatabases = $dependencies['database']; |
|
| 213 | + if (empty($supportedDatabases)) { |
|
| 214 | + return $missing; |
|
| 215 | + } |
|
| 216 | + if (!is_array($supportedDatabases)) { |
|
| 217 | + $supportedDatabases = [$supportedDatabases]; |
|
| 218 | + } |
|
| 219 | + $supportedDatabases = array_map(function ($db) { |
|
| 220 | + return $this->getValue($db); |
|
| 221 | + }, $supportedDatabases); |
|
| 222 | + $currentDatabase = $this->platform->getDatabase(); |
|
| 223 | + if (!in_array($currentDatabase, $supportedDatabases)) { |
|
| 224 | + $missing[] = $this->l->t('The following databases are supported: %s', [implode(', ', $supportedDatabases)]); |
|
| 225 | + } |
|
| 226 | + return $missing; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * @param array $dependencies |
|
| 231 | + * @return array |
|
| 232 | + */ |
|
| 233 | + private function analyzeCommands(array $dependencies) { |
|
| 234 | + $missing = []; |
|
| 235 | + if (!isset($dependencies['command'])) { |
|
| 236 | + return $missing; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + $commands = $dependencies['command']; |
|
| 240 | + if (!is_array($commands)) { |
|
| 241 | + $commands = [$commands]; |
|
| 242 | + } |
|
| 243 | + if (isset($commands['@value'])) { |
|
| 244 | + $commands = [$commands]; |
|
| 245 | + } |
|
| 246 | + $os = $this->platform->getOS(); |
|
| 247 | + foreach ($commands as $command) { |
|
| 248 | + if (isset($command['@attributes']['os']) && $command['@attributes']['os'] !== $os) { |
|
| 249 | + continue; |
|
| 250 | + } |
|
| 251 | + $commandName = $this->getValue($command); |
|
| 252 | + if (!$this->platform->isCommandKnown($commandName)) { |
|
| 253 | + $missing[] = $this->l->t('The command line tool %s could not be found', [$commandName]); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + return $missing; |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * @param array $dependencies |
|
| 261 | + * @return array |
|
| 262 | + */ |
|
| 263 | + private function analyzeLibraries(array $dependencies) { |
|
| 264 | + $missing = []; |
|
| 265 | + if (!isset($dependencies['lib'])) { |
|
| 266 | + return $missing; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + $libs = $dependencies['lib']; |
|
| 270 | + if (!is_array($libs)) { |
|
| 271 | + $libs = [$libs]; |
|
| 272 | + } |
|
| 273 | + if (isset($libs['@value'])) { |
|
| 274 | + $libs = [$libs]; |
|
| 275 | + } |
|
| 276 | + foreach ($libs as $lib) { |
|
| 277 | + $libName = $this->getValue($lib); |
|
| 278 | + $libVersion = $this->platform->getLibraryVersion($libName); |
|
| 279 | + if (is_null($libVersion)) { |
|
| 280 | + $missing[] = $this->l->t('The library %s is not available.', [$libName]); |
|
| 281 | + continue; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + if (is_array($lib)) { |
|
| 285 | + if (isset($lib['@attributes']['min-version'])) { |
|
| 286 | + $minVersion = $lib['@attributes']['min-version']; |
|
| 287 | + if ($this->compareSmaller($libVersion, $minVersion)) { |
|
| 288 | + $missing[] = $this->l->t('Library %1$s with a version higher than %2$s is required - available version %3$s.', |
|
| 289 | + [$libName, $minVersion, $libVersion]); |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + if (isset($lib['@attributes']['max-version'])) { |
|
| 293 | + $maxVersion = $lib['@attributes']['max-version']; |
|
| 294 | + if ($this->compareBigger($libVersion, $maxVersion)) { |
|
| 295 | + $missing[] = $this->l->t('Library %1$s with a version lower than %2$s is required - available version %3$s.', |
|
| 296 | + [$libName, $maxVersion, $libVersion]); |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + return $missing; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * @param array $dependencies |
|
| 306 | + * @return array |
|
| 307 | + */ |
|
| 308 | + private function analyzeOS(array $dependencies) { |
|
| 309 | + $missing = []; |
|
| 310 | + if (!isset($dependencies['os'])) { |
|
| 311 | + return $missing; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + $oss = $dependencies['os']; |
|
| 315 | + if (empty($oss)) { |
|
| 316 | + return $missing; |
|
| 317 | + } |
|
| 318 | + if (is_array($oss)) { |
|
| 319 | + $oss = array_map(function ($os) { |
|
| 320 | + return $this->getValue($os); |
|
| 321 | + }, $oss); |
|
| 322 | + } else { |
|
| 323 | + $oss = [$oss]; |
|
| 324 | + } |
|
| 325 | + $currentOS = $this->platform->getOS(); |
|
| 326 | + if (!in_array($currentOS, $oss)) { |
|
| 327 | + $missing[] = $this->l->t('The following platforms are supported: %s', [implode(', ', $oss)]); |
|
| 328 | + } |
|
| 329 | + return $missing; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * @param array $dependencies |
|
| 334 | + * @param array $appInfo |
|
| 335 | + * @return array |
|
| 336 | + */ |
|
| 337 | + private function analyzeOC(array $dependencies, array $appInfo, bool $ignoreMax) { |
|
| 338 | + $missing = []; |
|
| 339 | + $minVersion = null; |
|
| 340 | + if (isset($dependencies['nextcloud']['@attributes']['min-version'])) { |
|
| 341 | + $minVersion = $dependencies['nextcloud']['@attributes']['min-version']; |
|
| 342 | + } elseif (isset($dependencies['owncloud']['@attributes']['min-version'])) { |
|
| 343 | + $minVersion = $dependencies['owncloud']['@attributes']['min-version']; |
|
| 344 | + } elseif (isset($appInfo['requiremin'])) { |
|
| 345 | + $minVersion = $appInfo['requiremin']; |
|
| 346 | + } elseif (isset($appInfo['require'])) { |
|
| 347 | + $minVersion = $appInfo['require']; |
|
| 348 | + } |
|
| 349 | + $maxVersion = $this->getMaxVersion($dependencies, $appInfo); |
|
| 350 | + |
|
| 351 | + if (!is_null($minVersion)) { |
|
| 352 | + if ($this->compareSmaller($this->platform->getOcVersion(), $minVersion)) { |
|
| 353 | + $missing[] = $this->l->t('Server version %s or higher is required.', [$this->toVisibleVersion($minVersion)]); |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + if (!$ignoreMax && !is_null($maxVersion)) { |
|
| 357 | + if ($this->compareBigger($this->platform->getOcVersion(), $maxVersion)) { |
|
| 358 | + $missing[] = $this->l->t('Server version %s or lower is required.', [$this->toVisibleVersion($maxVersion)]); |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + return $missing; |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + private function getMaxVersion(array $dependencies, array $appInfo): ?string { |
|
| 365 | + if (isset($dependencies['nextcloud']['@attributes']['max-version'])) { |
|
| 366 | + return $dependencies['nextcloud']['@attributes']['max-version']; |
|
| 367 | + } |
|
| 368 | + if (isset($dependencies['owncloud']['@attributes']['max-version'])) { |
|
| 369 | + return $dependencies['owncloud']['@attributes']['max-version']; |
|
| 370 | + } |
|
| 371 | + if (isset($appInfo['requiremax'])) { |
|
| 372 | + return $appInfo['requiremax']; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + return null; |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * Map the internal version number to the Nextcloud version |
|
| 380 | + * |
|
| 381 | + * @param string $version |
|
| 382 | + * @return string |
|
| 383 | + */ |
|
| 384 | + protected function toVisibleVersion($version) { |
|
| 385 | + switch ($version) { |
|
| 386 | + case '9.1': |
|
| 387 | + return '10'; |
|
| 388 | + default: |
|
| 389 | + if (strpos($version, '9.1.') === 0) { |
|
| 390 | + $version = '10.0.' . substr($version, 4); |
|
| 391 | + } |
|
| 392 | + return $version; |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * @param $element |
|
| 398 | + * @return mixed |
|
| 399 | + */ |
|
| 400 | + private function getValue($element) { |
|
| 401 | + if (isset($element['@value'])) { |
|
| 402 | + return $element['@value']; |
|
| 403 | + } |
|
| 404 | + return (string)$element; |
|
| 405 | + } |
|
| 406 | 406 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | if (!is_array($supportedArchitectures)) { |
| 190 | 190 | $supportedArchitectures = [$supportedArchitectures]; |
| 191 | 191 | } |
| 192 | - $supportedArchitectures = array_map(function ($architecture) { |
|
| 192 | + $supportedArchitectures = array_map(function($architecture) { |
|
| 193 | 193 | return $this->getValue($architecture); |
| 194 | 194 | }, $supportedArchitectures); |
| 195 | 195 | $currentArchitecture = $this->platform->getArchitecture(); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | if (!is_array($supportedDatabases)) { |
| 217 | 217 | $supportedDatabases = [$supportedDatabases]; |
| 218 | 218 | } |
| 219 | - $supportedDatabases = array_map(function ($db) { |
|
| 219 | + $supportedDatabases = array_map(function($db) { |
|
| 220 | 220 | return $this->getValue($db); |
| 221 | 221 | }, $supportedDatabases); |
| 222 | 222 | $currentDatabase = $this->platform->getDatabase(); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | return $missing; |
| 317 | 317 | } |
| 318 | 318 | if (is_array($oss)) { |
| 319 | - $oss = array_map(function ($os) { |
|
| 319 | + $oss = array_map(function($os) { |
|
| 320 | 320 | return $this->getValue($os); |
| 321 | 321 | }, $oss); |
| 322 | 322 | } else { |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | return '10'; |
| 388 | 388 | default: |
| 389 | 389 | if (strpos($version, '9.1.') === 0) { |
| 390 | - $version = '10.0.' . substr($version, 4); |
|
| 390 | + $version = '10.0.'.substr($version, 4); |
|
| 391 | 391 | } |
| 392 | 392 | return $version; |
| 393 | 393 | } |
@@ -401,6 +401,6 @@ discard block |
||
| 401 | 401 | if (isset($element['@value'])) { |
| 402 | 402 | return $element['@value']; |
| 403 | 403 | } |
| 404 | - return (string)$element; |
|
| 404 | + return (string) $element; |
|
| 405 | 405 | } |
| 406 | 406 | } |
@@ -25,24 +25,24 @@ |
||
| 25 | 25 | |
| 26 | 26 | class EducationBundle extends Bundle { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritDoc} |
|
| 30 | - */ |
|
| 31 | - public function getName() { |
|
| 32 | - return $this->l10n->t('Education Edition'); |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritDoc} |
|
| 30 | + */ |
|
| 31 | + public function getName() { |
|
| 32 | + return $this->l10n->t('Education Edition'); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * {@inheritDoc} |
|
| 37 | - */ |
|
| 38 | - public function getAppIdentifiers() { |
|
| 39 | - return [ |
|
| 40 | - 'dashboard', |
|
| 41 | - 'circles', |
|
| 42 | - 'groupfolders', |
|
| 43 | - 'announcementcenter', |
|
| 44 | - 'quota_warning', |
|
| 45 | - 'user_saml', |
|
| 46 | - ]; |
|
| 47 | - } |
|
| 35 | + /** |
|
| 36 | + * {@inheritDoc} |
|
| 37 | + */ |
|
| 38 | + public function getAppIdentifiers() { |
|
| 39 | + return [ |
|
| 40 | + 'dashboard', |
|
| 41 | + 'circles', |
|
| 42 | + 'groupfolders', |
|
| 43 | + 'announcementcenter', |
|
| 44 | + 'quota_warning', |
|
| 45 | + 'user_saml', |
|
| 46 | + ]; |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -26,22 +26,22 @@ |
||
| 26 | 26 | |
| 27 | 27 | class GroupwareBundle extends Bundle { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * {@inheritDoc} |
|
| 31 | - */ |
|
| 32 | - public function getName() { |
|
| 33 | - return $this->l10n->t('Groupware bundle'); |
|
| 34 | - } |
|
| 29 | + /** |
|
| 30 | + * {@inheritDoc} |
|
| 31 | + */ |
|
| 32 | + public function getName() { |
|
| 33 | + return $this->l10n->t('Groupware bundle'); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * {@inheritDoc} |
|
| 38 | - */ |
|
| 39 | - public function getAppIdentifiers() { |
|
| 40 | - return [ |
|
| 41 | - 'calendar', |
|
| 42 | - 'contacts', |
|
| 43 | - 'deck', |
|
| 44 | - 'mail' |
|
| 45 | - ]; |
|
| 46 | - } |
|
| 36 | + /** |
|
| 37 | + * {@inheritDoc} |
|
| 38 | + */ |
|
| 39 | + public function getAppIdentifiers() { |
|
| 40 | + return [ |
|
| 41 | + 'calendar', |
|
| 42 | + 'contacts', |
|
| 43 | + 'deck', |
|
| 44 | + 'mail' |
|
| 45 | + ]; |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -25,22 +25,22 @@ |
||
| 25 | 25 | |
| 26 | 26 | class SocialSharingBundle extends Bundle { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritDoc} |
|
| 30 | - */ |
|
| 31 | - public function getName() { |
|
| 32 | - return $this->l10n->t('Social sharing bundle'); |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritDoc} |
|
| 30 | + */ |
|
| 31 | + public function getName() { |
|
| 32 | + return $this->l10n->t('Social sharing bundle'); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * {@inheritDoc} |
|
| 37 | - */ |
|
| 38 | - public function getAppIdentifiers() { |
|
| 39 | - return [ |
|
| 40 | - 'socialsharing_twitter', |
|
| 41 | - 'socialsharing_facebook', |
|
| 42 | - 'socialsharing_email', |
|
| 43 | - 'socialsharing_diaspora', |
|
| 44 | - ]; |
|
| 45 | - } |
|
| 35 | + /** |
|
| 36 | + * {@inheritDoc} |
|
| 37 | + */ |
|
| 38 | + public function getAppIdentifiers() { |
|
| 39 | + return [ |
|
| 40 | + 'socialsharing_twitter', |
|
| 41 | + 'socialsharing_facebook', |
|
| 42 | + 'socialsharing_email', |
|
| 43 | + 'socialsharing_diaspora', |
|
| 44 | + ]; |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -35,74 +35,74 @@ |
||
| 35 | 35 | use OCP\IImage; |
| 36 | 36 | |
| 37 | 37 | class TXT extends ProviderV2 { |
| 38 | - /** |
|
| 39 | - * {@inheritDoc} |
|
| 40 | - */ |
|
| 41 | - public function getMimeType(): string { |
|
| 42 | - return '/text\/plain/'; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * {@inheritDoc} |
|
| 47 | - */ |
|
| 48 | - public function isAvailable(FileInfo $file): bool { |
|
| 49 | - return $file->getSize() > 0; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * {@inheritDoc} |
|
| 54 | - */ |
|
| 55 | - public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
| 56 | - $content = $file->fopen('r'); |
|
| 57 | - |
|
| 58 | - if ($content === false) { |
|
| 59 | - return null; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - $content = stream_get_contents($content,3000); |
|
| 63 | - |
|
| 64 | - //don't create previews of empty text files |
|
| 65 | - if (trim($content) === '') { |
|
| 66 | - return null; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $lines = preg_split("/\r\n|\n|\r/", $content); |
|
| 70 | - |
|
| 71 | - // Define text size of text file preview |
|
| 72 | - $fontSize = $maxX ? (int) ((1 / 32) * $maxX) : 5; //5px |
|
| 73 | - $lineSize = ceil($fontSize * 1.5); |
|
| 74 | - |
|
| 75 | - $image = imagecreate($maxX, $maxY); |
|
| 76 | - imagecolorallocate($image, 255, 255, 255); |
|
| 77 | - $textColor = imagecolorallocate($image, 0, 0, 0); |
|
| 78 | - |
|
| 79 | - $fontFile = __DIR__; |
|
| 80 | - $fontFile .= '/../../../core'; |
|
| 81 | - $fontFile .= '/fonts/NotoSans-Regular.ttf'; |
|
| 82 | - |
|
| 83 | - $canUseTTF = function_exists('imagettftext'); |
|
| 84 | - |
|
| 85 | - foreach ($lines as $index => $line) { |
|
| 86 | - $index = $index + 1; |
|
| 87 | - |
|
| 88 | - $x = 1; |
|
| 89 | - $y = (int) ($index * $lineSize); |
|
| 90 | - |
|
| 91 | - if ($canUseTTF === true) { |
|
| 92 | - imagettftext($image, $fontSize, 0, $x, $y, $textColor, $fontFile, $line); |
|
| 93 | - } else { |
|
| 94 | - $y -= $fontSize; |
|
| 95 | - imagestring($image, 1, $x, $y, $line, $textColor); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - if (($index * $lineSize) >= $maxY) { |
|
| 99 | - break; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - $imageObject = new \OC_Image(); |
|
| 104 | - $imageObject->setResource($image); |
|
| 105 | - |
|
| 106 | - return $imageObject->valid() ? $imageObject : null; |
|
| 107 | - } |
|
| 38 | + /** |
|
| 39 | + * {@inheritDoc} |
|
| 40 | + */ |
|
| 41 | + public function getMimeType(): string { |
|
| 42 | + return '/text\/plain/'; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * {@inheritDoc} |
|
| 47 | + */ |
|
| 48 | + public function isAvailable(FileInfo $file): bool { |
|
| 49 | + return $file->getSize() > 0; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * {@inheritDoc} |
|
| 54 | + */ |
|
| 55 | + public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
| 56 | + $content = $file->fopen('r'); |
|
| 57 | + |
|
| 58 | + if ($content === false) { |
|
| 59 | + return null; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + $content = stream_get_contents($content,3000); |
|
| 63 | + |
|
| 64 | + //don't create previews of empty text files |
|
| 65 | + if (trim($content) === '') { |
|
| 66 | + return null; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $lines = preg_split("/\r\n|\n|\r/", $content); |
|
| 70 | + |
|
| 71 | + // Define text size of text file preview |
|
| 72 | + $fontSize = $maxX ? (int) ((1 / 32) * $maxX) : 5; //5px |
|
| 73 | + $lineSize = ceil($fontSize * 1.5); |
|
| 74 | + |
|
| 75 | + $image = imagecreate($maxX, $maxY); |
|
| 76 | + imagecolorallocate($image, 255, 255, 255); |
|
| 77 | + $textColor = imagecolorallocate($image, 0, 0, 0); |
|
| 78 | + |
|
| 79 | + $fontFile = __DIR__; |
|
| 80 | + $fontFile .= '/../../../core'; |
|
| 81 | + $fontFile .= '/fonts/NotoSans-Regular.ttf'; |
|
| 82 | + |
|
| 83 | + $canUseTTF = function_exists('imagettftext'); |
|
| 84 | + |
|
| 85 | + foreach ($lines as $index => $line) { |
|
| 86 | + $index = $index + 1; |
|
| 87 | + |
|
| 88 | + $x = 1; |
|
| 89 | + $y = (int) ($index * $lineSize); |
|
| 90 | + |
|
| 91 | + if ($canUseTTF === true) { |
|
| 92 | + imagettftext($image, $fontSize, 0, $x, $y, $textColor, $fontFile, $line); |
|
| 93 | + } else { |
|
| 94 | + $y -= $fontSize; |
|
| 95 | + imagestring($image, 1, $x, $y, $line, $textColor); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + if (($index * $lineSize) >= $maxY) { |
|
| 99 | + break; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + $imageObject = new \OC_Image(); |
|
| 104 | + $imageObject->setResource($image); |
|
| 105 | + |
|
| 106 | + return $imageObject->valid() ? $imageObject : null; |
|
| 107 | + } |
|
| 108 | 108 | } |