@@ -31,22 +31,22 @@ |
||
31 | 31 | |
32 | 32 | class Hooks { |
33 | 33 | |
34 | - /** |
|
35 | - * clean up user specific settings if user gets deleted |
|
36 | - * @param array $params array with uid |
|
37 | - * |
|
38 | - * This function is connected to the pre_deleteUser signal of OC_Users |
|
39 | - * to remove the used space for the trash bin stored in the database |
|
40 | - */ |
|
41 | - public static function deleteUser_hook($params) { |
|
42 | - $uid = $params['uid']; |
|
43 | - Trashbin::deleteUser($uid); |
|
44 | - } |
|
34 | + /** |
|
35 | + * clean up user specific settings if user gets deleted |
|
36 | + * @param array $params array with uid |
|
37 | + * |
|
38 | + * This function is connected to the pre_deleteUser signal of OC_Users |
|
39 | + * to remove the used space for the trash bin stored in the database |
|
40 | + */ |
|
41 | + public static function deleteUser_hook($params) { |
|
42 | + $uid = $params['uid']; |
|
43 | + Trashbin::deleteUser($uid); |
|
44 | + } |
|
45 | 45 | |
46 | - public static function post_write_hook($params) { |
|
47 | - $user = \OCP\User::getUser(); |
|
48 | - if (!empty($user)) { |
|
49 | - Trashbin::resizeTrash($user); |
|
50 | - } |
|
51 | - } |
|
46 | + public static function post_write_hook($params) { |
|
47 | + $user = \OCP\User::getUser(); |
|
48 | + if (!empty($user)) { |
|
49 | + Trashbin::resizeTrash($user); |
|
50 | + } |
|
51 | + } |
|
52 | 52 | } |
@@ -29,60 +29,60 @@ |
||
29 | 29 | |
30 | 30 | class SearchResult implements ISearchResult { |
31 | 31 | |
32 | - protected $result = [ |
|
33 | - 'exact' => [], |
|
34 | - ]; |
|
32 | + protected $result = [ |
|
33 | + 'exact' => [], |
|
34 | + ]; |
|
35 | 35 | |
36 | - protected $exactIdMatches = []; |
|
36 | + protected $exactIdMatches = []; |
|
37 | 37 | |
38 | - public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null) { |
|
39 | - $type = $type->getLabel(); |
|
40 | - if(!isset($this->result[$type])) { |
|
41 | - $this->result[$type] = []; |
|
42 | - $this->result['exact'][$type] = []; |
|
43 | - } |
|
38 | + public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null) { |
|
39 | + $type = $type->getLabel(); |
|
40 | + if(!isset($this->result[$type])) { |
|
41 | + $this->result[$type] = []; |
|
42 | + $this->result['exact'][$type] = []; |
|
43 | + } |
|
44 | 44 | |
45 | - $this->result[$type] = array_merge($this->result[$type], $matches); |
|
46 | - if(is_array($exactMatches)) { |
|
47 | - $this->result['exact'][$type] = array_merge($this->result['exact'][$type], $exactMatches); |
|
48 | - } |
|
49 | - } |
|
45 | + $this->result[$type] = array_merge($this->result[$type], $matches); |
|
46 | + if(is_array($exactMatches)) { |
|
47 | + $this->result['exact'][$type] = array_merge($this->result['exact'][$type], $exactMatches); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - public function markExactIdMatch(SearchResultType $type) { |
|
52 | - $this->exactIdMatches[$type->getLabel()] = 1; |
|
53 | - } |
|
51 | + public function markExactIdMatch(SearchResultType $type) { |
|
52 | + $this->exactIdMatches[$type->getLabel()] = 1; |
|
53 | + } |
|
54 | 54 | |
55 | - public function hasExactIdMatch(SearchResultType $type) { |
|
56 | - return isset($this->exactIdMatches[$type->getLabel()]); |
|
57 | - } |
|
55 | + public function hasExactIdMatch(SearchResultType $type) { |
|
56 | + return isset($this->exactIdMatches[$type->getLabel()]); |
|
57 | + } |
|
58 | 58 | |
59 | - public function hasResult(SearchResultType $type, $collaboratorId) { |
|
60 | - $type = $type->getLabel(); |
|
61 | - if(!isset($this->result[$type])) { |
|
62 | - return false; |
|
63 | - } |
|
59 | + public function hasResult(SearchResultType $type, $collaboratorId) { |
|
60 | + $type = $type->getLabel(); |
|
61 | + if(!isset($this->result[$type])) { |
|
62 | + return false; |
|
63 | + } |
|
64 | 64 | |
65 | - $resultArrays = [$this->result['exact'][$type], $this->result[$type]]; |
|
66 | - foreach($resultArrays as $resultArray) { |
|
67 | - foreach ($resultArray as $result) { |
|
68 | - if ($result['value']['shareWith'] === $collaboratorId) { |
|
69 | - return true; |
|
70 | - } |
|
71 | - } |
|
72 | - } |
|
65 | + $resultArrays = [$this->result['exact'][$type], $this->result[$type]]; |
|
66 | + foreach($resultArrays as $resultArray) { |
|
67 | + foreach ($resultArray as $result) { |
|
68 | + if ($result['value']['shareWith'] === $collaboratorId) { |
|
69 | + return true; |
|
70 | + } |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - return false; |
|
75 | - } |
|
74 | + return false; |
|
75 | + } |
|
76 | 76 | |
77 | - public function asArray() { |
|
78 | - return $this->result; |
|
79 | - } |
|
77 | + public function asArray() { |
|
78 | + return $this->result; |
|
79 | + } |
|
80 | 80 | |
81 | - public function unsetResult(SearchResultType $type) { |
|
82 | - $type = $type->getLabel(); |
|
83 | - $this->result[$type] = []; |
|
84 | - if(isset($this->result['exact'][$type])) { |
|
85 | - $this->result['exact'][$type] = []; |
|
86 | - } |
|
87 | - } |
|
81 | + public function unsetResult(SearchResultType $type) { |
|
82 | + $type = $type->getLabel(); |
|
83 | + $this->result[$type] = []; |
|
84 | + if(isset($this->result['exact'][$type])) { |
|
85 | + $this->result['exact'][$type] = []; |
|
86 | + } |
|
87 | + } |
|
88 | 88 | } |
@@ -34,15 +34,15 @@ discard block |
||
34 | 34 | $helper = new Helper(\OC::$server->getConfig()); |
35 | 35 | $ocConfig = \OC::$server->getConfig(); |
36 | 36 | $uBackend = new User_Proxy( |
37 | - $helper->getServerConfigurationPrefixes(true), |
|
38 | - new LDAP(), |
|
39 | - $ocConfig, |
|
40 | - \OC::$server->getNotificationManager(), |
|
41 | - \OC::$server->getUserSession(), |
|
42 | - \OC::$server->query('LDAPUserPluginManager') |
|
37 | + $helper->getServerConfigurationPrefixes(true), |
|
38 | + new LDAP(), |
|
39 | + $ocConfig, |
|
40 | + \OC::$server->getNotificationManager(), |
|
41 | + \OC::$server->getUserSession(), |
|
42 | + \OC::$server->query('LDAPUserPluginManager') |
|
43 | 43 | ); |
44 | 44 | $deletedUsersIndex = new DeletedUsersIndex( |
45 | - $ocConfig, $dbConnection, $userMapping |
|
45 | + $ocConfig, $dbConnection, $userMapping |
|
46 | 46 | ); |
47 | 47 | |
48 | 48 | $application->add(new OCA\User_LDAP\Command\ShowConfig($helper)); |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | $application->add(new OCA\User_LDAP\Command\DeleteConfig($helper)); |
53 | 53 | $application->add(new OCA\User_LDAP\Command\Search($ocConfig)); |
54 | 54 | $application->add(new OCA\User_LDAP\Command\ShowRemnants( |
55 | - $deletedUsersIndex, \OC::$server->getDateTimeFormatter()) |
|
55 | + $deletedUsersIndex, \OC::$server->getDateTimeFormatter()) |
|
56 | 56 | ); |
57 | 57 | $application->add(new OCA\User_LDAP\Command\CheckUser( |
58 | - $uBackend, $helper, $deletedUsersIndex, $userMapping) |
|
58 | + $uBackend, $helper, $deletedUsersIndex, $userMapping) |
|
59 | 59 | ); |
@@ -30,10 +30,10 @@ |
||
30 | 30 | use OCP\IConfig; |
31 | 31 | |
32 | 32 | class UUIDFixGroup extends UUIDFix { |
33 | - public function __construct(GroupMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) { |
|
34 | - $this->mapper = $mapper; |
|
35 | - $this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config, |
|
36 | - \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), |
|
37 | - \OC::$server->query('LDAPUserPluginManager')); |
|
38 | - } |
|
33 | + public function __construct(GroupMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) { |
|
34 | + $this->mapper = $mapper; |
|
35 | + $this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config, |
|
36 | + \OC::$server->getNotificationManager(), \OC::$server->getUserSession(), |
|
37 | + \OC::$server->query('LDAPUserPluginManager')); |
|
38 | + } |
|
39 | 39 | } |
@@ -28,54 +28,54 @@ |
||
28 | 28 | use OCP\IServerContainer; |
29 | 29 | |
30 | 30 | class Manager implements IManager { |
31 | - /** @var string[] */ |
|
32 | - protected $sorters =[]; |
|
31 | + /** @var string[] */ |
|
32 | + protected $sorters =[]; |
|
33 | 33 | |
34 | - /** @var ISorter[] */ |
|
35 | - protected $sorterInstances = []; |
|
36 | - /** @var IServerContainer */ |
|
37 | - private $c; |
|
34 | + /** @var ISorter[] */ |
|
35 | + protected $sorterInstances = []; |
|
36 | + /** @var IServerContainer */ |
|
37 | + private $c; |
|
38 | 38 | |
39 | - public function __construct(IServerContainer $container) { |
|
40 | - $this->c = $container; |
|
41 | - } |
|
39 | + public function __construct(IServerContainer $container) { |
|
40 | + $this->c = $container; |
|
41 | + } |
|
42 | 42 | |
43 | - public function runSorters(array $sorters, array &$sortArray, array $context) { |
|
44 | - $sorterInstances = $this->getSorters(); |
|
45 | - while($sorter = array_shift($sorters)) { |
|
46 | - if(isset($sorterInstances[$sorter])) { |
|
47 | - $sorterInstances[$sorter]->sort($sortArray, $context); |
|
48 | - } else { |
|
49 | - $this->c->getLogger()->warning('No sorter for ID "{id}", skipping', [ |
|
50 | - 'app' => 'core', 'id' => $sorter |
|
51 | - ]); |
|
52 | - } |
|
53 | - } |
|
54 | - } |
|
43 | + public function runSorters(array $sorters, array &$sortArray, array $context) { |
|
44 | + $sorterInstances = $this->getSorters(); |
|
45 | + while($sorter = array_shift($sorters)) { |
|
46 | + if(isset($sorterInstances[$sorter])) { |
|
47 | + $sorterInstances[$sorter]->sort($sortArray, $context); |
|
48 | + } else { |
|
49 | + $this->c->getLogger()->warning('No sorter for ID "{id}", skipping', [ |
|
50 | + 'app' => 'core', 'id' => $sorter |
|
51 | + ]); |
|
52 | + } |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | - public function registerSorter($className) { |
|
57 | - $this->sorters[] = $className; |
|
58 | - } |
|
56 | + public function registerSorter($className) { |
|
57 | + $this->sorters[] = $className; |
|
58 | + } |
|
59 | 59 | |
60 | - protected function getSorters() { |
|
61 | - if(count($this->sorterInstances) === 0) { |
|
62 | - foreach ($this->sorters as $sorter) { |
|
63 | - /** @var ISorter $instance */ |
|
64 | - $instance = $this->c->resolve($sorter); |
|
65 | - if(!$instance instanceof ISorter) { |
|
66 | - $this->c->getLogger()->notice('Skipping sorter which is not an instance of ISorter. Class name: {class}', |
|
67 | - ['app' => 'core', 'class' => $sorter]); |
|
68 | - continue; |
|
69 | - } |
|
70 | - $sorterId = trim($instance->getId()); |
|
71 | - if(trim($sorterId) === '') { |
|
72 | - $this->c->getLogger()->notice('Skipping sorter with empty ID. Class name: {class}', |
|
73 | - ['app' => 'core', 'class' => $sorter]); |
|
74 | - continue; |
|
75 | - } |
|
76 | - $this->sorterInstances[$sorterId] = $instance; |
|
77 | - } |
|
78 | - } |
|
79 | - return $this->sorterInstances; |
|
80 | - } |
|
60 | + protected function getSorters() { |
|
61 | + if(count($this->sorterInstances) === 0) { |
|
62 | + foreach ($this->sorters as $sorter) { |
|
63 | + /** @var ISorter $instance */ |
|
64 | + $instance = $this->c->resolve($sorter); |
|
65 | + if(!$instance instanceof ISorter) { |
|
66 | + $this->c->getLogger()->notice('Skipping sorter which is not an instance of ISorter. Class name: {class}', |
|
67 | + ['app' => 'core', 'class' => $sorter]); |
|
68 | + continue; |
|
69 | + } |
|
70 | + $sorterId = trim($instance->getId()); |
|
71 | + if(trim($sorterId) === '') { |
|
72 | + $this->c->getLogger()->notice('Skipping sorter with empty ID. Class name: {class}', |
|
73 | + ['app' => 'core', 'class' => $sorter]); |
|
74 | + continue; |
|
75 | + } |
|
76 | + $this->sorterInstances[$sorterId] = $instance; |
|
77 | + } |
|
78 | + } |
|
79 | + return $this->sorterInstances; |
|
80 | + } |
|
81 | 81 | } |
@@ -27,19 +27,19 @@ |
||
27 | 27 | use OCP\IServerContainer; |
28 | 28 | |
29 | 29 | class JSSettingsHelper { |
30 | - /** @var IServerContainer */ |
|
31 | - private $c; |
|
30 | + /** @var IServerContainer */ |
|
31 | + private $c; |
|
32 | 32 | |
33 | - public function __construct(IServerContainer $c) { |
|
34 | - $this->c = $c; |
|
35 | - } |
|
33 | + public function __construct(IServerContainer $c) { |
|
34 | + $this->c = $c; |
|
35 | + } |
|
36 | 36 | |
37 | - public function extend(array $settings) { |
|
38 | - $appConfig = json_decode($settings['array']['oc_appconfig'], true); |
|
37 | + public function extend(array $settings) { |
|
38 | + $appConfig = json_decode($settings['array']['oc_appconfig'], true); |
|
39 | 39 | |
40 | - $value = (int)$this->c->getConfig()->getAppValue('comments', 'maxAutoCompleteResults', 10); |
|
41 | - $appConfig['comments']['maxAutoCompleteResults'] = $value; |
|
40 | + $value = (int)$this->c->getConfig()->getAppValue('comments', 'maxAutoCompleteResults', 10); |
|
41 | + $appConfig['comments']['maxAutoCompleteResults'] = $value; |
|
42 | 42 | |
43 | - $settings['array']['oc_appconfig'] = json_encode($appConfig); |
|
44 | - } |
|
43 | + $settings['array']['oc_appconfig'] = json_encode($appConfig); |
|
44 | + } |
|
45 | 45 | } |
@@ -31,41 +31,41 @@ |
||
31 | 31 | */ |
32 | 32 | interface ICalendar { |
33 | 33 | |
34 | - /** |
|
35 | - * @return string defining the technical unique key |
|
36 | - * @since 13.0.0 |
|
37 | - */ |
|
38 | - public function getKey(); |
|
34 | + /** |
|
35 | + * @return string defining the technical unique key |
|
36 | + * @since 13.0.0 |
|
37 | + */ |
|
38 | + public function getKey(); |
|
39 | 39 | |
40 | - /** |
|
41 | - * In comparison to getKey() this function returns a human readable (maybe translated) name |
|
42 | - * @return null|string |
|
43 | - * @since 13.0.0 |
|
44 | - */ |
|
45 | - public function getDisplayName(); |
|
40 | + /** |
|
41 | + * In comparison to getKey() this function returns a human readable (maybe translated) name |
|
42 | + * @return null|string |
|
43 | + * @since 13.0.0 |
|
44 | + */ |
|
45 | + public function getDisplayName(); |
|
46 | 46 | |
47 | - /** |
|
48 | - * Calendar color |
|
49 | - * @return null|string |
|
50 | - * @since 13.0.0 |
|
51 | - */ |
|
52 | - public function getDisplayColor(); |
|
47 | + /** |
|
48 | + * Calendar color |
|
49 | + * @return null|string |
|
50 | + * @since 13.0.0 |
|
51 | + */ |
|
52 | + public function getDisplayColor(); |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param string $pattern which should match within the $searchProperties |
|
56 | - * @param array $searchProperties defines the properties within the query pattern should match |
|
57 | - * @param array $options - optional parameters: |
|
58 | - * ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]] |
|
59 | - * @param integer|null $limit - limit number of search results |
|
60 | - * @param integer|null $offset - offset for paging of search results |
|
61 | - * @return array an array of events/journals/todos which are arrays of key-value-pairs |
|
62 | - * @since 13.0.0 |
|
63 | - */ |
|
64 | - public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null); |
|
54 | + /** |
|
55 | + * @param string $pattern which should match within the $searchProperties |
|
56 | + * @param array $searchProperties defines the properties within the query pattern should match |
|
57 | + * @param array $options - optional parameters: |
|
58 | + * ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]] |
|
59 | + * @param integer|null $limit - limit number of search results |
|
60 | + * @param integer|null $offset - offset for paging of search results |
|
61 | + * @return array an array of events/journals/todos which are arrays of key-value-pairs |
|
62 | + * @since 13.0.0 |
|
63 | + */ |
|
64 | + public function search($pattern, array $searchProperties=[], array $options=[], $limit=null, $offset=null); |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return integer build up using \OCP\Constants |
|
68 | - * @since 13.0.0 |
|
69 | - */ |
|
70 | - public function getPermissions(); |
|
66 | + /** |
|
67 | + * @return integer build up using \OCP\Constants |
|
68 | + * @since 13.0.0 |
|
69 | + */ |
|
70 | + public function getPermissions(); |
|
71 | 71 | } |
@@ -37,136 +37,136 @@ |
||
37 | 37 | use OCP\IDBConnection; |
38 | 38 | |
39 | 39 | class MDB2SchemaManager { |
40 | - /** @var \OC\DB\Connection $conn */ |
|
41 | - protected $conn; |
|
40 | + /** @var \OC\DB\Connection $conn */ |
|
41 | + protected $conn; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param IDBConnection $conn |
|
45 | - */ |
|
46 | - public function __construct($conn) { |
|
47 | - $this->conn = $conn; |
|
48 | - } |
|
43 | + /** |
|
44 | + * @param IDBConnection $conn |
|
45 | + */ |
|
46 | + public function __construct($conn) { |
|
47 | + $this->conn = $conn; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * saves database scheme to xml file |
|
52 | - * @param string $file name of file |
|
53 | - * @return bool |
|
54 | - * |
|
55 | - * TODO: write more documentation |
|
56 | - */ |
|
57 | - public function getDbStructure($file) { |
|
58 | - return \OC\DB\MDB2SchemaWriter::saveSchemaToFile($file, $this->conn); |
|
59 | - } |
|
50 | + /** |
|
51 | + * saves database scheme to xml file |
|
52 | + * @param string $file name of file |
|
53 | + * @return bool |
|
54 | + * |
|
55 | + * TODO: write more documentation |
|
56 | + */ |
|
57 | + public function getDbStructure($file) { |
|
58 | + return \OC\DB\MDB2SchemaWriter::saveSchemaToFile($file, $this->conn); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Creates tables from XML file |
|
63 | - * @param string $file file to read structure from |
|
64 | - * @return bool |
|
65 | - * |
|
66 | - * TODO: write more documentation |
|
67 | - */ |
|
68 | - public function createDbFromStructure($file) { |
|
69 | - $schemaReader = new MDB2SchemaReader(\OC::$server->getConfig(), $this->conn->getDatabasePlatform()); |
|
70 | - $toSchema = new Schema([], [], $this->conn->getSchemaManager()->createSchemaConfig()); |
|
71 | - $toSchema = $schemaReader->loadSchemaFromFile($file, $toSchema); |
|
72 | - return $this->executeSchemaChange($toSchema); |
|
73 | - } |
|
61 | + /** |
|
62 | + * Creates tables from XML file |
|
63 | + * @param string $file file to read structure from |
|
64 | + * @return bool |
|
65 | + * |
|
66 | + * TODO: write more documentation |
|
67 | + */ |
|
68 | + public function createDbFromStructure($file) { |
|
69 | + $schemaReader = new MDB2SchemaReader(\OC::$server->getConfig(), $this->conn->getDatabasePlatform()); |
|
70 | + $toSchema = new Schema([], [], $this->conn->getSchemaManager()->createSchemaConfig()); |
|
71 | + $toSchema = $schemaReader->loadSchemaFromFile($file, $toSchema); |
|
72 | + return $this->executeSchemaChange($toSchema); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @return \OC\DB\Migrator |
|
77 | - */ |
|
78 | - public function getMigrator() { |
|
79 | - $random = \OC::$server->getSecureRandom(); |
|
80 | - $platform = $this->conn->getDatabasePlatform(); |
|
81 | - $config = \OC::$server->getConfig(); |
|
82 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
83 | - if ($platform instanceof SqlitePlatform) { |
|
84 | - return new SQLiteMigrator($this->conn, $random, $config, $dispatcher); |
|
85 | - } else if ($platform instanceof OraclePlatform) { |
|
86 | - return new OracleMigrator($this->conn, $random, $config, $dispatcher); |
|
87 | - } else if ($platform instanceof MySqlPlatform) { |
|
88 | - return new MySQLMigrator($this->conn, $random, $config, $dispatcher); |
|
89 | - } else if ($platform instanceof PostgreSqlPlatform) { |
|
90 | - return new PostgreSqlMigrator($this->conn, $random, $config, $dispatcher); |
|
91 | - } else { |
|
92 | - return new Migrator($this->conn, $random, $config, $dispatcher); |
|
93 | - } |
|
94 | - } |
|
75 | + /** |
|
76 | + * @return \OC\DB\Migrator |
|
77 | + */ |
|
78 | + public function getMigrator() { |
|
79 | + $random = \OC::$server->getSecureRandom(); |
|
80 | + $platform = $this->conn->getDatabasePlatform(); |
|
81 | + $config = \OC::$server->getConfig(); |
|
82 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
83 | + if ($platform instanceof SqlitePlatform) { |
|
84 | + return new SQLiteMigrator($this->conn, $random, $config, $dispatcher); |
|
85 | + } else if ($platform instanceof OraclePlatform) { |
|
86 | + return new OracleMigrator($this->conn, $random, $config, $dispatcher); |
|
87 | + } else if ($platform instanceof MySqlPlatform) { |
|
88 | + return new MySQLMigrator($this->conn, $random, $config, $dispatcher); |
|
89 | + } else if ($platform instanceof PostgreSqlPlatform) { |
|
90 | + return new PostgreSqlMigrator($this->conn, $random, $config, $dispatcher); |
|
91 | + } else { |
|
92 | + return new Migrator($this->conn, $random, $config, $dispatcher); |
|
93 | + } |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Reads database schema from file |
|
98 | - * |
|
99 | - * @param string $file file to read from |
|
100 | - * @return \Doctrine\DBAL\Schema\Schema |
|
101 | - */ |
|
102 | - private function readSchemaFromFile($file) { |
|
103 | - $platform = $this->conn->getDatabasePlatform(); |
|
104 | - $schemaReader = new MDB2SchemaReader(\OC::$server->getConfig(), $platform); |
|
105 | - $toSchema = new Schema([], [], $this->conn->getSchemaManager()->createSchemaConfig()); |
|
106 | - return $schemaReader->loadSchemaFromFile($file, $toSchema); |
|
107 | - } |
|
96 | + /** |
|
97 | + * Reads database schema from file |
|
98 | + * |
|
99 | + * @param string $file file to read from |
|
100 | + * @return \Doctrine\DBAL\Schema\Schema |
|
101 | + */ |
|
102 | + private function readSchemaFromFile($file) { |
|
103 | + $platform = $this->conn->getDatabasePlatform(); |
|
104 | + $schemaReader = new MDB2SchemaReader(\OC::$server->getConfig(), $platform); |
|
105 | + $toSchema = new Schema([], [], $this->conn->getSchemaManager()->createSchemaConfig()); |
|
106 | + return $schemaReader->loadSchemaFromFile($file, $toSchema); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * update the database scheme |
|
111 | - * @param string $file file to read structure from |
|
112 | - * @param bool $generateSql only return the sql needed for the upgrade |
|
113 | - * @return string|boolean |
|
114 | - */ |
|
115 | - public function updateDbFromStructure($file, $generateSql = false) { |
|
116 | - $toSchema = $this->readSchemaFromFile($file); |
|
117 | - $migrator = $this->getMigrator(); |
|
109 | + /** |
|
110 | + * update the database scheme |
|
111 | + * @param string $file file to read structure from |
|
112 | + * @param bool $generateSql only return the sql needed for the upgrade |
|
113 | + * @return string|boolean |
|
114 | + */ |
|
115 | + public function updateDbFromStructure($file, $generateSql = false) { |
|
116 | + $toSchema = $this->readSchemaFromFile($file); |
|
117 | + $migrator = $this->getMigrator(); |
|
118 | 118 | |
119 | - if ($generateSql) { |
|
120 | - return $migrator->generateChangeScript($toSchema); |
|
121 | - } else { |
|
122 | - $migrator->migrate($toSchema); |
|
123 | - return true; |
|
124 | - } |
|
125 | - } |
|
119 | + if ($generateSql) { |
|
120 | + return $migrator->generateChangeScript($toSchema); |
|
121 | + } else { |
|
122 | + $migrator->migrate($toSchema); |
|
123 | + return true; |
|
124 | + } |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * @param \Doctrine\DBAL\Schema\Schema $schema |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public function generateChangeScript($schema) { |
|
132 | - $migrator = $this->getMigrator(); |
|
133 | - return $migrator->generateChangeScript($schema); |
|
134 | - } |
|
127 | + /** |
|
128 | + * @param \Doctrine\DBAL\Schema\Schema $schema |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public function generateChangeScript($schema) { |
|
132 | + $migrator = $this->getMigrator(); |
|
133 | + return $migrator->generateChangeScript($schema); |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * remove all tables defined in a database structure xml file |
|
138 | - * |
|
139 | - * @param string $file the xml file describing the tables |
|
140 | - */ |
|
141 | - public function removeDBStructure($file) { |
|
142 | - $schemaReader = new MDB2SchemaReader(\OC::$server->getConfig(), $this->conn->getDatabasePlatform()); |
|
143 | - $toSchema = new Schema([], [], $this->conn->getSchemaManager()->createSchemaConfig()); |
|
144 | - $fromSchema = $schemaReader->loadSchemaFromFile($file, $toSchema); |
|
145 | - $toSchema = clone $fromSchema; |
|
146 | - /** @var $table \Doctrine\DBAL\Schema\Table */ |
|
147 | - foreach ($toSchema->getTables() as $table) { |
|
148 | - $toSchema->dropTable($table->getName()); |
|
149 | - } |
|
150 | - $comparator = new \Doctrine\DBAL\Schema\Comparator(); |
|
151 | - $schemaDiff = $comparator->compare($fromSchema, $toSchema); |
|
152 | - $this->executeSchemaChange($schemaDiff); |
|
153 | - } |
|
136 | + /** |
|
137 | + * remove all tables defined in a database structure xml file |
|
138 | + * |
|
139 | + * @param string $file the xml file describing the tables |
|
140 | + */ |
|
141 | + public function removeDBStructure($file) { |
|
142 | + $schemaReader = new MDB2SchemaReader(\OC::$server->getConfig(), $this->conn->getDatabasePlatform()); |
|
143 | + $toSchema = new Schema([], [], $this->conn->getSchemaManager()->createSchemaConfig()); |
|
144 | + $fromSchema = $schemaReader->loadSchemaFromFile($file, $toSchema); |
|
145 | + $toSchema = clone $fromSchema; |
|
146 | + /** @var $table \Doctrine\DBAL\Schema\Table */ |
|
147 | + foreach ($toSchema->getTables() as $table) { |
|
148 | + $toSchema->dropTable($table->getName()); |
|
149 | + } |
|
150 | + $comparator = new \Doctrine\DBAL\Schema\Comparator(); |
|
151 | + $schemaDiff = $comparator->compare($fromSchema, $toSchema); |
|
152 | + $this->executeSchemaChange($schemaDiff); |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * @param \Doctrine\DBAL\Schema\Schema|\Doctrine\DBAL\Schema\SchemaDiff $schema |
|
157 | - * @return bool |
|
158 | - */ |
|
159 | - private function executeSchemaChange($schema) { |
|
160 | - $this->conn->beginTransaction(); |
|
161 | - foreach ($schema->toSql($this->conn->getDatabasePlatform()) as $sql) { |
|
162 | - $this->conn->query($sql); |
|
163 | - } |
|
164 | - $this->conn->commit(); |
|
155 | + /** |
|
156 | + * @param \Doctrine\DBAL\Schema\Schema|\Doctrine\DBAL\Schema\SchemaDiff $schema |
|
157 | + * @return bool |
|
158 | + */ |
|
159 | + private function executeSchemaChange($schema) { |
|
160 | + $this->conn->beginTransaction(); |
|
161 | + foreach ($schema->toSql($this->conn->getDatabasePlatform()) as $sql) { |
|
162 | + $this->conn->query($sql); |
|
163 | + } |
|
164 | + $this->conn->commit(); |
|
165 | 165 | |
166 | - if ($this->conn->getDatabasePlatform() instanceof SqlitePlatform) { |
|
167 | - $this->conn->close(); |
|
168 | - $this->conn->connect(); |
|
169 | - } |
|
170 | - return true; |
|
171 | - } |
|
166 | + if ($this->conn->getDatabasePlatform() instanceof SqlitePlatform) { |
|
167 | + $this->conn->close(); |
|
168 | + $this->conn->connect(); |
|
169 | + } |
|
170 | + return true; |
|
171 | + } |
|
172 | 172 | } |
@@ -28,15 +28,15 @@ |
||
28 | 28 | |
29 | 29 | class WalledGardenController extends Controller { |
30 | 30 | |
31 | - /** |
|
32 | - * @PublicPage |
|
33 | - * @NoCSRFRequired |
|
34 | - * |
|
35 | - * @return Response |
|
36 | - */ |
|
37 | - function get() { |
|
38 | - $resp = new Response(); |
|
39 | - $resp->setStatus(Http::STATUS_NO_CONTENT); |
|
40 | - return $resp; |
|
41 | - } |
|
31 | + /** |
|
32 | + * @PublicPage |
|
33 | + * @NoCSRFRequired |
|
34 | + * |
|
35 | + * @return Response |
|
36 | + */ |
|
37 | + function get() { |
|
38 | + $resp = new Response(); |
|
39 | + $resp->setStatus(Http::STATUS_NO_CONTENT); |
|
40 | + return $resp; |
|
41 | + } |
|
42 | 42 | } |