Completed
Pull Request — master (#10075)
by
unknown
27:10
created
lib/public/GroupInterface.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -40,84 +40,84 @@
 block discarded – undo
40 40
  */
41 41
 interface GroupInterface {
42 42
 
43
-	/**
44
-	 * actions that user backends can define
45
-	 */
46
-	const CREATE_GROUP		= 0x00000001;
47
-	const DELETE_GROUP		= 0x00000010;
48
-	const ADD_TO_GROUP		= 0x00000100;
49
-	const REMOVE_FROM_GOUP	= 0x00001000; // oops
50
-	const REMOVE_FROM_GROUP	= 0x00001000;
51
-	//OBSOLETE const GET_DISPLAYNAME	= 0x00010000;
52
-	const COUNT_USERS		= 0x00100000;
53
-	const GROUP_DETAILS		= 0x01000000;
54
-	/**
55
-	 * @since 13.0.0
56
-	 */
57
-	const IS_ADMIN  = 0x10000000;
43
+    /**
44
+     * actions that user backends can define
45
+     */
46
+    const CREATE_GROUP		= 0x00000001;
47
+    const DELETE_GROUP		= 0x00000010;
48
+    const ADD_TO_GROUP		= 0x00000100;
49
+    const REMOVE_FROM_GOUP	= 0x00001000; // oops
50
+    const REMOVE_FROM_GROUP	= 0x00001000;
51
+    //OBSOLETE const GET_DISPLAYNAME	= 0x00010000;
52
+    const COUNT_USERS		= 0x00100000;
53
+    const GROUP_DETAILS		= 0x01000000;
54
+    /**
55
+     * @since 13.0.0
56
+     */
57
+    const IS_ADMIN  = 0x10000000;
58 58
 
59
-	/**
60
-	 * Check if backend implements actions
61
-	 * @param int $actions bitwise-or'ed actions
62
-	 * @return boolean
63
-	 * @since 4.5.0
64
-	 *
65
-	 * Returns the supported actions as int to be
66
-	 * compared with \OC_Group_Backend::CREATE_GROUP etc.
67
-	 */
68
-	public function implementsActions($actions);
59
+    /**
60
+     * Check if backend implements actions
61
+     * @param int $actions bitwise-or'ed actions
62
+     * @return boolean
63
+     * @since 4.5.0
64
+     *
65
+     * Returns the supported actions as int to be
66
+     * compared with \OC_Group_Backend::CREATE_GROUP etc.
67
+     */
68
+    public function implementsActions($actions);
69 69
 
70
-	/**
71
-	 * is user in group?
72
-	 * @param string $uid uid of the user
73
-	 * @param string $gid gid of the group
74
-	 * @return bool
75
-	 * @since 4.5.0
76
-	 *
77
-	 * Checks whether the user is member of a group or not.
78
-	 */
79
-	public function inGroup($uid, $gid);
70
+    /**
71
+     * is user in group?
72
+     * @param string $uid uid of the user
73
+     * @param string $gid gid of the group
74
+     * @return bool
75
+     * @since 4.5.0
76
+     *
77
+     * Checks whether the user is member of a group or not.
78
+     */
79
+    public function inGroup($uid, $gid);
80 80
 
81
-	/**
82
-	 * Get all groups a user belongs to
83
-	 * @param string $uid Name of the user
84
-	 * @return array an array of group names
85
-	 * @since 4.5.0
86
-	 *
87
-	 * This function fetches all groups a user belongs to. It does not check
88
-	 * if the user exists at all.
89
-	 */
90
-	public function getUserGroups($uid);
81
+    /**
82
+     * Get all groups a user belongs to
83
+     * @param string $uid Name of the user
84
+     * @return array an array of group names
85
+     * @since 4.5.0
86
+     *
87
+     * This function fetches all groups a user belongs to. It does not check
88
+     * if the user exists at all.
89
+     */
90
+    public function getUserGroups($uid);
91 91
 
92
-	/**
93
-	 * get a list of all groups
94
-	 * @param string $search
95
-	 * @param int $limit
96
-	 * @param int $offset
97
-	 * @return array an array of group names
98
-	 * @since 4.5.0
99
-	 *
100
-	 * Returns a list with all groups
101
-	 */
102
-	public function getGroups($search = '', $limit = -1, $offset = 0);
92
+    /**
93
+     * get a list of all groups
94
+     * @param string $search
95
+     * @param int $limit
96
+     * @param int $offset
97
+     * @return array an array of group names
98
+     * @since 4.5.0
99
+     *
100
+     * Returns a list with all groups
101
+     */
102
+    public function getGroups($search = '', $limit = -1, $offset = 0);
103 103
 
104
-	/**
105
-	 * check if a group exists
106
-	 * @param string $gid
107
-	 * @return bool
108
-	 * @since 4.5.0
109
-	 */
110
-	public function groupExists($gid);
104
+    /**
105
+     * check if a group exists
106
+     * @param string $gid
107
+     * @return bool
108
+     * @since 4.5.0
109
+     */
110
+    public function groupExists($gid);
111 111
 
112
-	/**
113
-	 * get a list of all users in a group
114
-	 * @param string $gid
115
-	 * @param string $search
116
-	 * @param int $limit
117
-	 * @param int $offset
118
-	 * @return array an array of user ids
119
-	 * @since 4.5.0
120
-	 */
121
-	public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
112
+    /**
113
+     * get a list of all users in a group
114
+     * @param string $gid
115
+     * @param string $search
116
+     * @param int $limit
117
+     * @param int $offset
118
+     * @return array an array of user ids
119
+     * @since 4.5.0
120
+     */
121
+    public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
122 122
 
123 123
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,15 +46,15 @@
 block discarded – undo
46 46
 	const CREATE_GROUP		= 0x00000001;
47 47
 	const DELETE_GROUP		= 0x00000010;
48 48
 	const ADD_TO_GROUP		= 0x00000100;
49
-	const REMOVE_FROM_GOUP	= 0x00001000; // oops
50
-	const REMOVE_FROM_GROUP	= 0x00001000;
49
+	const REMOVE_FROM_GOUP = 0x00001000; // oops
50
+	const REMOVE_FROM_GROUP = 0x00001000;
51 51
 	//OBSOLETE const GET_DISPLAYNAME	= 0x00010000;
52
-	const COUNT_USERS		= 0x00100000;
53
-	const GROUP_DETAILS		= 0x01000000;
52
+	const COUNT_USERS = 0x00100000;
53
+	const GROUP_DETAILS = 0x01000000;
54 54
 	/**
55 55
 	 * @since 13.0.0
56 56
 	 */
57
-	const IS_ADMIN  = 0x10000000;
57
+	const IS_ADMIN = 0x10000000;
58 58
 
59 59
 	/**
60 60
 	 * Check if backend implements actions
Please login to merge, or discard this patch.
lib/public/Collaboration/Collaborators/ISearchPlugin.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@
 block discarded – undo
30 30
  * @since 13.0.0
31 31
  */
32 32
 interface ISearchPlugin {
33
-	/**
34
-	 * @param string $search
35
-	 * @param int $limit
36
-	 * @param int $offset
37
-	 * @param ISearchResult $searchResult
38
-	 * @return bool whether the plugin has more results
39
-	 * @since 13.0.0
40
-	 */
41
-	public function search($search, $limit, $offset, ISearchResult $searchResult);
33
+    /**
34
+     * @param string $search
35
+     * @param int $limit
36
+     * @param int $offset
37
+     * @param ISearchResult $searchResult
38
+     * @return bool whether the plugin has more results
39
+     * @since 13.0.0
40
+     */
41
+    public function search($search, $limit, $offset, ISearchResult $searchResult);
42 42
 }
Please login to merge, or discard this patch.
lib/private/Setup/OCI.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -32,81 +32,81 @@
 block discarded – undo
32 32
 namespace OC\Setup;
33 33
 
34 34
 class OCI extends AbstractDatabase {
35
-	public $dbprettyname = 'Oracle';
35
+    public $dbprettyname = 'Oracle';
36 36
 
37
-	protected $dbtablespace;
37
+    protected $dbtablespace;
38 38
 
39
-	public function initialize($config) {
40
-		parent::initialize($config);
41
-		if (array_key_exists('dbtablespace', $config)) {
42
-			$this->dbtablespace = $config['dbtablespace'];
43
-		} else {
44
-			$this->dbtablespace = 'USERS';
45
-		}
46
-		// allow empty hostname for oracle
47
-		$this->dbHost = $config['dbhost'];
39
+    public function initialize($config) {
40
+        parent::initialize($config);
41
+        if (array_key_exists('dbtablespace', $config)) {
42
+            $this->dbtablespace = $config['dbtablespace'];
43
+        } else {
44
+            $this->dbtablespace = 'USERS';
45
+        }
46
+        // allow empty hostname for oracle
47
+        $this->dbHost = $config['dbhost'];
48 48
 
49
-		$this->config->setValues([
50
-			'dbhost' => $this->dbHost,
51
-			'dbtablespace' => $this->dbtablespace,
52
-		]);
53
-	}
49
+        $this->config->setValues([
50
+            'dbhost' => $this->dbHost,
51
+            'dbtablespace' => $this->dbtablespace,
52
+        ]);
53
+    }
54 54
 
55
-	public function validate($config) {
56
-		$errors = array();
57
-		if (empty($config['dbuser']) && empty($config['dbname'])) {
58
-			$errors[] = $this->trans->t("%s enter the database username and name.", array($this->dbprettyname));
59
-		} else if (empty($config['dbuser'])) {
60
-			$errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname));
61
-		} else if (empty($config['dbname'])) {
62
-			$errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname));
63
-		}
64
-		return $errors;
65
-	}
55
+    public function validate($config) {
56
+        $errors = array();
57
+        if (empty($config['dbuser']) && empty($config['dbname'])) {
58
+            $errors[] = $this->trans->t("%s enter the database username and name.", array($this->dbprettyname));
59
+        } else if (empty($config['dbuser'])) {
60
+            $errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname));
61
+        } else if (empty($config['dbname'])) {
62
+            $errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname));
63
+        }
64
+        return $errors;
65
+    }
66 66
 
67
-	public function setupDatabase($username) {
68
-		try {
69
-			$this->connect();
70
-		} catch (\Exception $e) {
71
-			$errorMessage = $this->getLastError();
72
-			if ($errorMessage) {
73
-				throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
74
-					$errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
75
-					. ' ORACLE_SID=' . getenv('ORACLE_SID')
76
-					. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
77
-					. ' NLS_LANG=' . getenv('NLS_LANG')
78
-					. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
79
-			}
80
-			throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'),
81
-				'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
82
-				. ' ORACLE_SID=' . getenv('ORACLE_SID')
83
-				. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
84
-				. ' NLS_LANG=' . getenv('NLS_LANG')
85
-				. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
86
-		}
67
+    public function setupDatabase($username) {
68
+        try {
69
+            $this->connect();
70
+        } catch (\Exception $e) {
71
+            $errorMessage = $this->getLastError();
72
+            if ($errorMessage) {
73
+                throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
74
+                    $errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
75
+                    . ' ORACLE_SID=' . getenv('ORACLE_SID')
76
+                    . ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
77
+                    . ' NLS_LANG=' . getenv('NLS_LANG')
78
+                    . ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
79
+            }
80
+            throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'),
81
+                'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
82
+                . ' ORACLE_SID=' . getenv('ORACLE_SID')
83
+                . ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
84
+                . ' NLS_LANG=' . getenv('NLS_LANG')
85
+                . ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
86
+        }
87 87
 
88
-		$this->config->setValues([
89
-			'dbuser' => $this->dbUser,
90
-			'dbname' => $this->dbName,
91
-			'dbpassword' => $this->dbPassword,
92
-		]);
93
-	}
88
+        $this->config->setValues([
89
+            'dbuser' => $this->dbUser,
90
+            'dbname' => $this->dbName,
91
+            'dbpassword' => $this->dbPassword,
92
+        ]);
93
+    }
94 94
 
95
-	/**
96
-	 * @param resource $connection
97
-	 * @return string
98
-	 */
99
-	protected function getLastError($connection = null) {
100
-		if ($connection) {
101
-			$error = oci_error($connection);
102
-		} else {
103
-			$error = oci_error();
104
-		}
105
-		foreach (array('message', 'code') as $key) {
106
-			if (isset($error[$key])) {
107
-				return $error[$key];
108
-			}
109
-		}
110
-		return '';
111
-	}
95
+    /**
96
+     * @param resource $connection
97
+     * @return string
98
+     */
99
+    protected function getLastError($connection = null) {
100
+        if ($connection) {
101
+            $error = oci_error($connection);
102
+        } else {
103
+            $error = oci_error();
104
+        }
105
+        foreach (array('message', 'code') as $key) {
106
+            if (isset($error[$key])) {
107
+                return $error[$key];
108
+            }
109
+        }
110
+        return '';
111
+    }
112 112
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -71,18 +71,18 @@
 block discarded – undo
71 71
 			$errorMessage = $this->getLastError();
72 72
 			if ($errorMessage) {
73 73
 				throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
74
-					$errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
75
-					. ' ORACLE_SID=' . getenv('ORACLE_SID')
76
-					. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
77
-					. ' NLS_LANG=' . getenv('NLS_LANG')
78
-					. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
74
+					$errorMessage.' Check environment: ORACLE_HOME='.getenv('ORACLE_HOME')
75
+					. ' ORACLE_SID='.getenv('ORACLE_SID')
76
+					. ' LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH')
77
+					. ' NLS_LANG='.getenv('NLS_LANG')
78
+					. ' tnsnames.ora is '.(is_readable(getenv('ORACLE_HOME').'/network/admin/tnsnames.ora') ? '' : 'not ').'readable');
79 79
 			}
80 80
 			throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'),
81
-				'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
82
-				. ' ORACLE_SID=' . getenv('ORACLE_SID')
83
-				. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
84
-				. ' NLS_LANG=' . getenv('NLS_LANG')
85
-				. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
81
+				'Check environment: ORACLE_HOME='.getenv('ORACLE_HOME')
82
+				. ' ORACLE_SID='.getenv('ORACLE_SID')
83
+				. ' LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH')
84
+				. ' NLS_LANG='.getenv('NLS_LANG')
85
+				. ' tnsnames.ora is '.(is_readable(getenv('ORACLE_HOME').'/network/admin/tnsnames.ora') ? '' : 'not ').'readable');
86 86
 		}
87 87
 
88 88
 		$this->config->setValues([
Please login to merge, or discard this patch.
lib/public/Collaboration/Collaborators/ISearch.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -30,21 +30,21 @@
 block discarded – undo
30 30
  * @since 13.0.0
31 31
  */
32 32
 interface ISearch {
33
-	/**
34
-	 * @param string $search
35
-	 * @param array $shareTypes
36
-	 * @param bool $lookup
37
-	 * @param int $limit
38
-	 * @param int $offset
39
-	 * @return array with two elements, 1st ISearchResult as array, 2nd a bool indicating whether more result are available
40
-	 * @since 13.0.0
41
-	 */
42
-	public function search($search, array $shareTypes, $lookup, $limit, $offset);
33
+    /**
34
+     * @param string $search
35
+     * @param array $shareTypes
36
+     * @param bool $lookup
37
+     * @param int $limit
38
+     * @param int $offset
39
+     * @return array with two elements, 1st ISearchResult as array, 2nd a bool indicating whether more result are available
40
+     * @since 13.0.0
41
+     */
42
+    public function search($search, array $shareTypes, $lookup, $limit, $offset);
43 43
 
44
-	/**
45
-	 * @param array $pluginInfo with keys 'shareType' containing the name of a corresponding constant in \OCP\Share and
46
-	 * 	'class' with the class name of the plugin
47
-	 * @since 13.0.0
48
-	 */
49
-	public function registerPlugin(array $pluginInfo);
44
+    /**
45
+     * @param array $pluginInfo with keys 'shareType' containing the name of a corresponding constant in \OCP\Share and
46
+     * 	'class' with the class name of the plugin
47
+     * @since 13.0.0
48
+     */
49
+    public function registerPlugin(array $pluginInfo);
50 50
 }
Please login to merge, or discard this patch.
lib/public/Collaboration/Collaborators/ISearchResult.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -30,44 +30,44 @@
 block discarded – undo
30 30
  * @since 13.0.0
31 31
  */
32 32
 interface ISearchResult {
33
-	/**
34
-	 * @param SearchResultType $type
35
-	 * @param array $matches
36
-	 * @param array|null $exactMatches
37
-	 * @since 13.0.0
38
-	 */
39
-	public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null);
33
+    /**
34
+     * @param SearchResultType $type
35
+     * @param array $matches
36
+     * @param array|null $exactMatches
37
+     * @since 13.0.0
38
+     */
39
+    public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null);
40 40
 
41
-	/**
42
-	 * @param SearchResultType $type
43
-	 * @param string $collaboratorId
44
-	 * @return bool
45
-	 * @since 13.0.0
46
-	 */
47
-	public function hasResult(SearchResultType $type, $collaboratorId);
41
+    /**
42
+     * @param SearchResultType $type
43
+     * @param string $collaboratorId
44
+     * @return bool
45
+     * @since 13.0.0
46
+     */
47
+    public function hasResult(SearchResultType $type, $collaboratorId);
48 48
 
49
-	/**
50
-	 * @param SearchResultType $type
51
-	 * @since 13.0.0
52
-	 */
53
-	public function unsetResult(SearchResultType $type);
49
+    /**
50
+     * @param SearchResultType $type
51
+     * @since 13.0.0
52
+     */
53
+    public function unsetResult(SearchResultType $type);
54 54
 
55
-	/**
56
-	 * @param SearchResultType $type
57
-	 * @since 13.0.0
58
-	 */
59
-	public function markExactIdMatch(SearchResultType $type);
55
+    /**
56
+     * @param SearchResultType $type
57
+     * @since 13.0.0
58
+     */
59
+    public function markExactIdMatch(SearchResultType $type);
60 60
 
61
-	/**
62
-	 * @param SearchResultType $type
63
-	 * @return bool
64
-	 * @since 13.0.0
65
-	 */
66
-	public function hasExactIdMatch(SearchResultType $type);
61
+    /**
62
+     * @param SearchResultType $type
63
+     * @return bool
64
+     * @since 13.0.0
65
+     */
66
+    public function hasExactIdMatch(SearchResultType $type);
67 67
 
68
-	/**
69
-	 * @return array
70
-	 * @since 13.0.0
71
-	 */
72
-	public function asArray();
68
+    /**
69
+     * @return array
70
+     * @since 13.0.0
71
+     */
72
+    public function asArray();
73 73
 }
Please login to merge, or discard this patch.
lib/private/Repair/Owncloud/SaveAccountsTableData.php 2 patches
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -38,137 +38,137 @@
 block discarded – undo
38 38
  */
39 39
 class SaveAccountsTableData implements IRepairStep {
40 40
 
41
-	const BATCH_SIZE = 75;
42
-
43
-	/** @var IDBConnection */
44
-	protected $db;
45
-
46
-	/** @var IConfig */
47
-	protected $config;
48
-
49
-	/**
50
-	 * @param IDBConnection $db
51
-	 * @param IConfig $config
52
-	 */
53
-	public function __construct(IDBConnection $db, IConfig $config) {
54
-		$this->db = $db;
55
-		$this->config = $config;
56
-	}
57
-
58
-	/**
59
-	 * @return string
60
-	 */
61
-	public function getName() {
62
-		return 'Copy data from accounts table when migrating from ownCloud';
63
-	}
64
-
65
-	/**
66
-	 * @param IOutput $output
67
-	 */
68
-	public function run(IOutput $output) {
69
-		if (!$this->shouldRun()) {
70
-			return;
71
-		}
72
-
73
-		$offset = 0;
74
-		$numUsers = $this->runStep($offset);
75
-
76
-		while ($numUsers === self::BATCH_SIZE) {
77
-			$offset += $numUsers;
78
-			$numUsers = $this->runStep($offset);
79
-		}
80
-
81
-		// Remove the table
82
-		$this->db->dropTable('accounts');
83
-	}
84
-
85
-	/**
86
-	 * @return bool
87
-	 */
88
-	protected function shouldRun() {
89
-		$schema = $this->db->createSchema();
90
-
91
-		$tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'accounts';
92
-		if (!$schema->hasTable($tableName)) {
93
-			return false;
94
-		}
95
-
96
-		$table = $schema->getTable($tableName);
97
-		return $table->hasColumn('user_id');
98
-	}
99
-
100
-	/**
101
-	 * @param int $offset
102
-	 * @return int Number of copied users
103
-	 */
104
-	protected function runStep($offset) {
105
-		$query = $this->db->getQueryBuilder();
106
-		$query->select('*')
107
-			->from('accounts')
108
-			->orderBy('id')
109
-			->setMaxResults(self::BATCH_SIZE);
110
-
111
-		if ($offset > 0) {
112
-			$query->setFirstResult($offset);
113
-		}
114
-
115
-		$result = $query->execute();
116
-
117
-		$update = $this->db->getQueryBuilder();
118
-		$update->update('users')
119
-			->set('displayname', $update->createParameter('displayname'))
120
-			->where($update->expr()->eq('uid', $update->createParameter('userid')));
121
-
122
-		$updatedUsers = 0;
123
-		while ($row = $result->fetch()) {
124
-			try {
125
-				$this->migrateUserInfo($update, $row);
126
-			} catch (PreConditionNotMetException $e) {
127
-				// Ignore and continue
128
-			} catch (\UnexpectedValueException $e) {
129
-				// Ignore and continue
130
-			}
131
-			$updatedUsers++;
132
-		}
133
-		$result->closeCursor();
134
-
135
-		return $updatedUsers;
136
-	}
137
-
138
-	/**
139
-	 * @param IQueryBuilder $update
140
-	 * @param array $userdata
141
-	 * @throws PreConditionNotMetException
142
-	 * @throws \UnexpectedValueException
143
-	 */
144
-	protected function migrateUserInfo(IQueryBuilder $update, $userdata) {
145
-		$state = (int) $userdata['state'];
146
-		if ($state === 3) {
147
-			// Deleted user, ignore
148
-			return;
149
-		}
150
-
151
-		if ($userdata['email'] !== null) {
152
-			$this->config->setUserValue($userdata['user_id'], 'settings', 'email', $userdata['email']);
153
-		}
154
-		if ($userdata['quota'] !== null) {
155
-			$this->config->setUserValue($userdata['user_id'], 'files', 'quota', $userdata['quota']);
156
-		}
157
-		if ($userdata['last_login'] !== null) {
158
-			$this->config->setUserValue($userdata['user_id'], 'login', 'lastLogin', $userdata['last_login']);
159
-		}
160
-		if ($state === 1) {
161
-			$this->config->setUserValue($userdata['user_id'], 'core', 'enabled', 'true');
162
-		} else if ($state === 2) {
163
-			$this->config->setUserValue($userdata['user_id'], 'core', 'enabled', 'false');
164
-		}
165
-
166
-		if ($userdata['display_name'] !== null) {
167
-			$update->setParameter('displayname', $userdata['display_name'])
168
-				->setParameter('userid', $userdata['user_id']);
169
-			$update->execute();
170
-		}
171
-
172
-	}
41
+    const BATCH_SIZE = 75;
42
+
43
+    /** @var IDBConnection */
44
+    protected $db;
45
+
46
+    /** @var IConfig */
47
+    protected $config;
48
+
49
+    /**
50
+     * @param IDBConnection $db
51
+     * @param IConfig $config
52
+     */
53
+    public function __construct(IDBConnection $db, IConfig $config) {
54
+        $this->db = $db;
55
+        $this->config = $config;
56
+    }
57
+
58
+    /**
59
+     * @return string
60
+     */
61
+    public function getName() {
62
+        return 'Copy data from accounts table when migrating from ownCloud';
63
+    }
64
+
65
+    /**
66
+     * @param IOutput $output
67
+     */
68
+    public function run(IOutput $output) {
69
+        if (!$this->shouldRun()) {
70
+            return;
71
+        }
72
+
73
+        $offset = 0;
74
+        $numUsers = $this->runStep($offset);
75
+
76
+        while ($numUsers === self::BATCH_SIZE) {
77
+            $offset += $numUsers;
78
+            $numUsers = $this->runStep($offset);
79
+        }
80
+
81
+        // Remove the table
82
+        $this->db->dropTable('accounts');
83
+    }
84
+
85
+    /**
86
+     * @return bool
87
+     */
88
+    protected function shouldRun() {
89
+        $schema = $this->db->createSchema();
90
+
91
+        $tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'accounts';
92
+        if (!$schema->hasTable($tableName)) {
93
+            return false;
94
+        }
95
+
96
+        $table = $schema->getTable($tableName);
97
+        return $table->hasColumn('user_id');
98
+    }
99
+
100
+    /**
101
+     * @param int $offset
102
+     * @return int Number of copied users
103
+     */
104
+    protected function runStep($offset) {
105
+        $query = $this->db->getQueryBuilder();
106
+        $query->select('*')
107
+            ->from('accounts')
108
+            ->orderBy('id')
109
+            ->setMaxResults(self::BATCH_SIZE);
110
+
111
+        if ($offset > 0) {
112
+            $query->setFirstResult($offset);
113
+        }
114
+
115
+        $result = $query->execute();
116
+
117
+        $update = $this->db->getQueryBuilder();
118
+        $update->update('users')
119
+            ->set('displayname', $update->createParameter('displayname'))
120
+            ->where($update->expr()->eq('uid', $update->createParameter('userid')));
121
+
122
+        $updatedUsers = 0;
123
+        while ($row = $result->fetch()) {
124
+            try {
125
+                $this->migrateUserInfo($update, $row);
126
+            } catch (PreConditionNotMetException $e) {
127
+                // Ignore and continue
128
+            } catch (\UnexpectedValueException $e) {
129
+                // Ignore and continue
130
+            }
131
+            $updatedUsers++;
132
+        }
133
+        $result->closeCursor();
134
+
135
+        return $updatedUsers;
136
+    }
137
+
138
+    /**
139
+     * @param IQueryBuilder $update
140
+     * @param array $userdata
141
+     * @throws PreConditionNotMetException
142
+     * @throws \UnexpectedValueException
143
+     */
144
+    protected function migrateUserInfo(IQueryBuilder $update, $userdata) {
145
+        $state = (int) $userdata['state'];
146
+        if ($state === 3) {
147
+            // Deleted user, ignore
148
+            return;
149
+        }
150
+
151
+        if ($userdata['email'] !== null) {
152
+            $this->config->setUserValue($userdata['user_id'], 'settings', 'email', $userdata['email']);
153
+        }
154
+        if ($userdata['quota'] !== null) {
155
+            $this->config->setUserValue($userdata['user_id'], 'files', 'quota', $userdata['quota']);
156
+        }
157
+        if ($userdata['last_login'] !== null) {
158
+            $this->config->setUserValue($userdata['user_id'], 'login', 'lastLogin', $userdata['last_login']);
159
+        }
160
+        if ($state === 1) {
161
+            $this->config->setUserValue($userdata['user_id'], 'core', 'enabled', 'true');
162
+        } else if ($state === 2) {
163
+            $this->config->setUserValue($userdata['user_id'], 'core', 'enabled', 'false');
164
+        }
165
+
166
+        if ($userdata['display_name'] !== null) {
167
+            $update->setParameter('displayname', $userdata['display_name'])
168
+                ->setParameter('userid', $userdata['user_id']);
169
+            $update->execute();
170
+        }
171
+
172
+    }
173 173
 }
174 174
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@
 block discarded – undo
88 88
 	protected function shouldRun() {
89 89
 		$schema = $this->db->createSchema();
90 90
 
91
-		$tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'accounts';
91
+		$tableName = $this->config->getSystemValue('dbtableprefix', 'oc_').'accounts';
92 92
 		if (!$schema->hasTable($tableName)) {
93 93
 			return false;
94 94
 		}
Please login to merge, or discard this patch.
lib/public/Share/IManager.php 1 patch
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -35,313 +35,313 @@
 block discarded – undo
35 35
  */
36 36
 interface IManager {
37 37
 
38
-	/**
39
-	 * Create a Share
40
-	 *
41
-	 * @param IShare $share
42
-	 * @return IShare The share object
43
-	 * @throws \Exception
44
-	 * @since 9.0.0
45
-	 */
46
-	public function createShare(IShare $share);
47
-
48
-	/**
49
-	 * Update a share.
50
-	 * The target of the share can't be changed this way: use moveShare
51
-	 * The share can't be removed this way (permission 0): use deleteShare
52
-	 *
53
-	 * @param IShare $share
54
-	 * @return IShare The share object
55
-	 * @throws \InvalidArgumentException
56
-	 * @since 9.0.0
57
-	 */
58
-	public function updateShare(IShare $share);
59
-
60
-	/**
61
-	 * Delete a share
62
-	 *
63
-	 * @param IShare $share
64
-	 * @throws ShareNotFound
65
-	 * @throws \InvalidArgumentException
66
-	 * @since 9.0.0
67
-	 */
68
-	public function deleteShare(IShare $share);
69
-
70
-	/**
71
-	 * Unshare a file as the recipient.
72
-	 * This can be different from a regular delete for example when one of
73
-	 * the users in a groups deletes that share. But the provider should
74
-	 * handle this.
75
-	 *
76
-	 * @param IShare $share
77
-	 * @param string $recipientId
78
-	 * @since 9.0.0
79
-	 */
80
-	public function deleteFromSelf(IShare $share, $recipientId);
81
-
82
-	/**
83
-	 * Move the share as a recipient of the share.
84
-	 * This is updating the share target. So where the recipient has the share mounted.
85
-	 *
86
-	 * @param IShare $share
87
-	 * @param string $recipientId
88
-	 * @return IShare
89
-	 * @throws \InvalidArgumentException If $share is a link share or the $recipient does not match
90
-	 * @since 9.0.0
91
-	 */
92
-	public function moveShare(IShare $share, $recipientId);
93
-
94
-	/**
95
-	 * Get all shares shared by (initiated) by the provided user in a folder.
96
-	 *
97
-	 * @param string $userId
98
-	 * @param Folder $node
99
-	 * @param bool $reshares
100
-	 * @return IShare[][] [$fileId => IShare[], ...]
101
-	 * @since 11.0.0
102
-	 */
103
-	public function getSharesInFolder($userId, Folder $node, $reshares = false);
104
-
105
-	/**
106
-	 * Get shares shared by (initiated) by the provided user.
107
-	 *
108
-	 * @param string $userId
109
-	 * @param int $shareType
110
-	 * @param Node|null $path
111
-	 * @param bool $reshares
112
-	 * @param int $limit The maximum number of returned results, -1 for all results
113
-	 * @param int $offset
114
-	 * @return IShare[]
115
-	 * @since 9.0.0
116
-	 */
117
-	public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
118
-
119
-	/**
120
-	 * Get shares shared with $user.
121
-	 * Filter by $node if provided
122
-	 *
123
-	 * @param string $userId
124
-	 * @param int $shareType
125
-	 * @param Node|null $node
126
-	 * @param int $limit The maximum number of shares returned, -1 for all
127
-	 * @param int $offset
128
-	 * @return IShare[]
129
-	 * @since 9.0.0
130
-	 */
131
-	public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
132
-
133
-	/**
134
-	 * Retrieve a share by the share id.
135
-	 * If the recipient is set make sure to retrieve the file for that user.
136
-	 * This makes sure that if a user has moved/deleted a group share this
137
-	 * is reflected.
138
-	 *
139
-	 * @param string $id
140
-	 * @param string|null $recipient userID of the recipient
141
-	 * @return IShare
142
-	 * @throws ShareNotFound
143
-	 * @since 9.0.0
144
-	 */
145
-	public function getShareById($id, $recipient = null);
146
-
147
-	/**
148
-	 * Get the share by token possible with password
149
-	 *
150
-	 * @param string $token
151
-	 * @return IShare
152
-	 * @throws ShareNotFound
153
-	 * @since 9.0.0
154
-	 */
155
-	public function getShareByToken($token);
156
-
157
-	/**
158
-	 * Verify the password of a public share
159
-	 *
160
-	 * @param IShare $share
161
-	 * @param string $password
162
-	 * @return bool
163
-	 * @since 9.0.0
164
-	 */
165
-	public function checkPassword(IShare $share, $password);
166
-
167
-	/**
168
-	 * The user with UID is deleted.
169
-	 * All share providers have to cleanup the shares with this user as well
170
-	 * as shares owned by this user.
171
-	 * Shares only initiated by this user are fine.
172
-	 *
173
-	 * @param string $uid
174
-	 * @since 9.1.0
175
-	 */
176
-	public function userDeleted($uid);
177
-
178
-	/**
179
-	 * The group with $gid is deleted
180
-	 * We need to clear up all shares to this group
181
-	 *
182
-	 * @param string $gid
183
-	 * @since 9.1.0
184
-	 */
185
-	public function groupDeleted($gid);
186
-
187
-	/**
188
-	 * The user $uid is deleted from the group $gid
189
-	 * All user specific group shares have to be removed
190
-	 *
191
-	 * @param string $uid
192
-	 * @param string $gid
193
-	 * @since 9.1.0
194
-	 */
195
-	public function userDeletedFromGroup($uid, $gid);
196
-
197
-	/**
198
-	 * Get access list to a path. This means
199
-	 * all the users that can access a given path.
200
-	 *
201
-	 * Consider:
202
-	 * -root
203
-	 * |-folder1 (23)
204
-	 *  |-folder2 (32)
205
-	 *   |-fileA (42)
206
-	 *
207
-	 * fileA is shared with user1 and user1@server1
208
-	 * folder2 is shared with group2 (user4 is a member of group2)
209
-	 * folder1 is shared with user2 (renamed to "folder (1)") and user2@server2
210
-	 *
211
-	 * Then the access list to '/folder1/folder2/fileA' with $currentAccess is:
212
-	 * [
213
-	 *  users  => [
214
-	 *      'user1' => ['node_id' => 42, 'node_path' => '/fileA'],
215
-	 *      'user4' => ['node_id' => 32, 'node_path' => '/folder2'],
216
-	 *      'user2' => ['node_id' => 23, 'node_path' => '/folder (1)'],
217
-	 *  ],
218
-	 *  remote => [
219
-	 *      'user1@server1' => ['node_id' => 42, 'token' => 'SeCr3t'],
220
-	 *      'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'],
221
-	 *  ],
222
-	 *  public => bool
223
-	 *  mail => bool
224
-	 * ]
225
-	 *
226
-	 * The access list to '/folder1/folder2/fileA' **without** $currentAccess is:
227
-	 * [
228
-	 *  users  => ['user1', 'user2', 'user4'],
229
-	 *  remote => bool,
230
-	 *  public => bool
231
-	 *  mail => bool
232
-	 * ]
233
-	 *
234
-	 * This is required for encryption/activity
235
-	 *
236
-	 * @param \OCP\Files\Node $path
237
-	 * @param bool $recursive Should we check all parent folders as well
238
-	 * @param bool $currentAccess Should the user have currently access to the file
239
-	 * @return array
240
-	 * @since 12
241
-	 */
242
-	public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false);
243
-
244
-	/**
245
-	 * Instantiates a new share object. This is to be passed to
246
-	 * createShare.
247
-	 *
248
-	 * @return IShare
249
-	 * @since 9.0.0
250
-	 */
251
-	public function newShare();
252
-
253
-	/**
254
-	 * Is the share API enabled
255
-	 *
256
-	 * @return bool
257
-	 * @since 9.0.0
258
-	 */
259
-	public function shareApiEnabled();
260
-
261
-	/**
262
-	 * Is public link sharing enabled
263
-	 *
264
-	 * @return bool
265
-	 * @since 9.0.0
266
-	 */
267
-	public function shareApiAllowLinks();
268
-
269
-	/**
270
-	 * Is password on public link requires
271
-	 *
272
-	 * @return bool
273
-	 * @since 9.0.0
274
-	 */
275
-	public function shareApiLinkEnforcePassword();
276
-
277
-	/**
278
-	 * Is default expire date enabled
279
-	 *
280
-	 * @return bool
281
-	 * @since 9.0.0
282
-	 */
283
-	public function shareApiLinkDefaultExpireDate();
284
-
285
-	/**
286
-	 * Is default expire date enforced
287
-	 *`
288
-	 * @return bool
289
-	 * @since 9.0.0
290
-	 */
291
-	public function shareApiLinkDefaultExpireDateEnforced();
292
-
293
-	/**
294
-	 * Number of default expire days
295
-	 *
296
-	 * @return int
297
-	 * @since 9.0.0
298
-	 */
299
-	public function shareApiLinkDefaultExpireDays();
300
-
301
-	/**
302
-	 * Allow public upload on link shares
303
-	 *
304
-	 * @return bool
305
-	 * @since 9.0.0
306
-	 */
307
-	public function shareApiLinkAllowPublicUpload();
308
-
309
-	/**
310
-	 * check if user can only share with group members
311
-	 * @return bool
312
-	 * @since 9.0.0
313
-	 */
314
-	public function shareWithGroupMembersOnly();
315
-
316
-	/**
317
-	 * Check if users can share with groups
318
-	 * @return bool
319
-	 * @since 9.0.1
320
-	 */
321
-	public function allowGroupSharing();
322
-
323
-	/**
324
-	 * Check if sharing is disabled for the given user
325
-	 *
326
-	 * @param string $userId
327
-	 * @return bool
328
-	 * @since 9.0.0
329
-	 */
330
-	public function sharingDisabledForUser($userId);
331
-
332
-	/**
333
-	 * Check if outgoing server2server shares are allowed
334
-	 * @return bool
335
-	 * @since 9.0.0
336
-	 */
337
-	public function outgoingServer2ServerSharesAllowed();
338
-
339
-	/**
340
-	 * Check if a given share provider exists
341
-	 * @param int $shareType
342
-	 * @return bool
343
-	 * @since 11.0.0
344
-	 */
345
-	public function shareProviderExists($shareType);
38
+    /**
39
+     * Create a Share
40
+     *
41
+     * @param IShare $share
42
+     * @return IShare The share object
43
+     * @throws \Exception
44
+     * @since 9.0.0
45
+     */
46
+    public function createShare(IShare $share);
47
+
48
+    /**
49
+     * Update a share.
50
+     * The target of the share can't be changed this way: use moveShare
51
+     * The share can't be removed this way (permission 0): use deleteShare
52
+     *
53
+     * @param IShare $share
54
+     * @return IShare The share object
55
+     * @throws \InvalidArgumentException
56
+     * @since 9.0.0
57
+     */
58
+    public function updateShare(IShare $share);
59
+
60
+    /**
61
+     * Delete a share
62
+     *
63
+     * @param IShare $share
64
+     * @throws ShareNotFound
65
+     * @throws \InvalidArgumentException
66
+     * @since 9.0.0
67
+     */
68
+    public function deleteShare(IShare $share);
69
+
70
+    /**
71
+     * Unshare a file as the recipient.
72
+     * This can be different from a regular delete for example when one of
73
+     * the users in a groups deletes that share. But the provider should
74
+     * handle this.
75
+     *
76
+     * @param IShare $share
77
+     * @param string $recipientId
78
+     * @since 9.0.0
79
+     */
80
+    public function deleteFromSelf(IShare $share, $recipientId);
81
+
82
+    /**
83
+     * Move the share as a recipient of the share.
84
+     * This is updating the share target. So where the recipient has the share mounted.
85
+     *
86
+     * @param IShare $share
87
+     * @param string $recipientId
88
+     * @return IShare
89
+     * @throws \InvalidArgumentException If $share is a link share or the $recipient does not match
90
+     * @since 9.0.0
91
+     */
92
+    public function moveShare(IShare $share, $recipientId);
93
+
94
+    /**
95
+     * Get all shares shared by (initiated) by the provided user in a folder.
96
+     *
97
+     * @param string $userId
98
+     * @param Folder $node
99
+     * @param bool $reshares
100
+     * @return IShare[][] [$fileId => IShare[], ...]
101
+     * @since 11.0.0
102
+     */
103
+    public function getSharesInFolder($userId, Folder $node, $reshares = false);
104
+
105
+    /**
106
+     * Get shares shared by (initiated) by the provided user.
107
+     *
108
+     * @param string $userId
109
+     * @param int $shareType
110
+     * @param Node|null $path
111
+     * @param bool $reshares
112
+     * @param int $limit The maximum number of returned results, -1 for all results
113
+     * @param int $offset
114
+     * @return IShare[]
115
+     * @since 9.0.0
116
+     */
117
+    public function getSharesBy($userId, $shareType, $path = null, $reshares = false, $limit = 50, $offset = 0);
118
+
119
+    /**
120
+     * Get shares shared with $user.
121
+     * Filter by $node if provided
122
+     *
123
+     * @param string $userId
124
+     * @param int $shareType
125
+     * @param Node|null $node
126
+     * @param int $limit The maximum number of shares returned, -1 for all
127
+     * @param int $offset
128
+     * @return IShare[]
129
+     * @since 9.0.0
130
+     */
131
+    public function getSharedWith($userId, $shareType, $node = null, $limit = 50, $offset = 0);
132
+
133
+    /**
134
+     * Retrieve a share by the share id.
135
+     * If the recipient is set make sure to retrieve the file for that user.
136
+     * This makes sure that if a user has moved/deleted a group share this
137
+     * is reflected.
138
+     *
139
+     * @param string $id
140
+     * @param string|null $recipient userID of the recipient
141
+     * @return IShare
142
+     * @throws ShareNotFound
143
+     * @since 9.0.0
144
+     */
145
+    public function getShareById($id, $recipient = null);
146
+
147
+    /**
148
+     * Get the share by token possible with password
149
+     *
150
+     * @param string $token
151
+     * @return IShare
152
+     * @throws ShareNotFound
153
+     * @since 9.0.0
154
+     */
155
+    public function getShareByToken($token);
156
+
157
+    /**
158
+     * Verify the password of a public share
159
+     *
160
+     * @param IShare $share
161
+     * @param string $password
162
+     * @return bool
163
+     * @since 9.0.0
164
+     */
165
+    public function checkPassword(IShare $share, $password);
166
+
167
+    /**
168
+     * The user with UID is deleted.
169
+     * All share providers have to cleanup the shares with this user as well
170
+     * as shares owned by this user.
171
+     * Shares only initiated by this user are fine.
172
+     *
173
+     * @param string $uid
174
+     * @since 9.1.0
175
+     */
176
+    public function userDeleted($uid);
177
+
178
+    /**
179
+     * The group with $gid is deleted
180
+     * We need to clear up all shares to this group
181
+     *
182
+     * @param string $gid
183
+     * @since 9.1.0
184
+     */
185
+    public function groupDeleted($gid);
186
+
187
+    /**
188
+     * The user $uid is deleted from the group $gid
189
+     * All user specific group shares have to be removed
190
+     *
191
+     * @param string $uid
192
+     * @param string $gid
193
+     * @since 9.1.0
194
+     */
195
+    public function userDeletedFromGroup($uid, $gid);
196
+
197
+    /**
198
+     * Get access list to a path. This means
199
+     * all the users that can access a given path.
200
+     *
201
+     * Consider:
202
+     * -root
203
+     * |-folder1 (23)
204
+     *  |-folder2 (32)
205
+     *   |-fileA (42)
206
+     *
207
+     * fileA is shared with user1 and user1@server1
208
+     * folder2 is shared with group2 (user4 is a member of group2)
209
+     * folder1 is shared with user2 (renamed to "folder (1)") and user2@server2
210
+     *
211
+     * Then the access list to '/folder1/folder2/fileA' with $currentAccess is:
212
+     * [
213
+     *  users  => [
214
+     *      'user1' => ['node_id' => 42, 'node_path' => '/fileA'],
215
+     *      'user4' => ['node_id' => 32, 'node_path' => '/folder2'],
216
+     *      'user2' => ['node_id' => 23, 'node_path' => '/folder (1)'],
217
+     *  ],
218
+     *  remote => [
219
+     *      'user1@server1' => ['node_id' => 42, 'token' => 'SeCr3t'],
220
+     *      'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'],
221
+     *  ],
222
+     *  public => bool
223
+     *  mail => bool
224
+     * ]
225
+     *
226
+     * The access list to '/folder1/folder2/fileA' **without** $currentAccess is:
227
+     * [
228
+     *  users  => ['user1', 'user2', 'user4'],
229
+     *  remote => bool,
230
+     *  public => bool
231
+     *  mail => bool
232
+     * ]
233
+     *
234
+     * This is required for encryption/activity
235
+     *
236
+     * @param \OCP\Files\Node $path
237
+     * @param bool $recursive Should we check all parent folders as well
238
+     * @param bool $currentAccess Should the user have currently access to the file
239
+     * @return array
240
+     * @since 12
241
+     */
242
+    public function getAccessList(\OCP\Files\Node $path, $recursive = true, $currentAccess = false);
243
+
244
+    /**
245
+     * Instantiates a new share object. This is to be passed to
246
+     * createShare.
247
+     *
248
+     * @return IShare
249
+     * @since 9.0.0
250
+     */
251
+    public function newShare();
252
+
253
+    /**
254
+     * Is the share API enabled
255
+     *
256
+     * @return bool
257
+     * @since 9.0.0
258
+     */
259
+    public function shareApiEnabled();
260
+
261
+    /**
262
+     * Is public link sharing enabled
263
+     *
264
+     * @return bool
265
+     * @since 9.0.0
266
+     */
267
+    public function shareApiAllowLinks();
268
+
269
+    /**
270
+     * Is password on public link requires
271
+     *
272
+     * @return bool
273
+     * @since 9.0.0
274
+     */
275
+    public function shareApiLinkEnforcePassword();
276
+
277
+    /**
278
+     * Is default expire date enabled
279
+     *
280
+     * @return bool
281
+     * @since 9.0.0
282
+     */
283
+    public function shareApiLinkDefaultExpireDate();
284
+
285
+    /**
286
+     * Is default expire date enforced
287
+     *`
288
+     * @return bool
289
+     * @since 9.0.0
290
+     */
291
+    public function shareApiLinkDefaultExpireDateEnforced();
292
+
293
+    /**
294
+     * Number of default expire days
295
+     *
296
+     * @return int
297
+     * @since 9.0.0
298
+     */
299
+    public function shareApiLinkDefaultExpireDays();
300
+
301
+    /**
302
+     * Allow public upload on link shares
303
+     *
304
+     * @return bool
305
+     * @since 9.0.0
306
+     */
307
+    public function shareApiLinkAllowPublicUpload();
308
+
309
+    /**
310
+     * check if user can only share with group members
311
+     * @return bool
312
+     * @since 9.0.0
313
+     */
314
+    public function shareWithGroupMembersOnly();
315
+
316
+    /**
317
+     * Check if users can share with groups
318
+     * @return bool
319
+     * @since 9.0.1
320
+     */
321
+    public function allowGroupSharing();
322
+
323
+    /**
324
+     * Check if sharing is disabled for the given user
325
+     *
326
+     * @param string $userId
327
+     * @return bool
328
+     * @since 9.0.0
329
+     */
330
+    public function sharingDisabledForUser($userId);
331
+
332
+    /**
333
+     * Check if outgoing server2server shares are allowed
334
+     * @return bool
335
+     * @since 9.0.0
336
+     */
337
+    public function outgoingServer2ServerSharesAllowed();
338
+
339
+    /**
340
+     * Check if a given share provider exists
341
+     * @param int $shareType
342
+     * @return bool
343
+     * @since 11.0.0
344
+     */
345
+    public function shareProviderExists($shareType);
346 346
 
347 347
 }
Please login to merge, or discard this patch.
lib/private/Collaboration/Collaborators/RemotePlugin.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 							$searchResult->markExactIdMatch($resultType);
80 80
 						}
81 81
 						$result['exact'][] = [
82
-							'label' => $contact['FN'] . " ($cloudId)",
82
+							'label' => $contact['FN']." ($cloudId)",
83 83
 							'value' => [
84 84
 								'shareType' => Share::SHARE_TYPE_REMOTE,
85 85
 								'shareWith' => $cloudId,
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 						];
89 89
 					} else {
90 90
 						$result['wide'][] = [
91
-							'label' => $contact['FN'] . " ($cloudId)",
91
+							'label' => $contact['FN']." ($cloudId)",
92 92
 							'value' => [
93 93
 								'shareType' => Share::SHARE_TYPE_REMOTE,
94 94
 								'shareWith' => $cloudId,
Please login to merge, or discard this patch.
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -33,107 +33,107 @@
 block discarded – undo
33 33
 use OCP\Share;
34 34
 
35 35
 class RemotePlugin implements ISearchPlugin {
36
-	protected $shareeEnumeration;
36
+    protected $shareeEnumeration;
37 37
 
38
-	/** @var IManager */
39
-	private $contactsManager;
40
-	/** @var ICloudIdManager */
41
-	private $cloudIdManager;
42
-	/** @var IConfig */
43
-	private $config;
38
+    /** @var IManager */
39
+    private $contactsManager;
40
+    /** @var ICloudIdManager */
41
+    private $cloudIdManager;
42
+    /** @var IConfig */
43
+    private $config;
44 44
 
45
-	public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config) {
46
-		$this->contactsManager = $contactsManager;
47
-		$this->cloudIdManager = $cloudIdManager;
48
-		$this->config = $config;
45
+    public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config) {
46
+        $this->contactsManager = $contactsManager;
47
+        $this->cloudIdManager = $cloudIdManager;
48
+        $this->config = $config;
49 49
 
50
-		$this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
51
-	}
50
+        $this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
51
+    }
52 52
 
53
-	public function search($search, $limit, $offset, ISearchResult $searchResult) {
54
-		$result = ['wide' => [], 'exact' => []];
55
-		$resultType = new SearchResultType('remotes');
53
+    public function search($search, $limit, $offset, ISearchResult $searchResult) {
54
+        $result = ['wide' => [], 'exact' => []];
55
+        $resultType = new SearchResultType('remotes');
56 56
 
57
-		// Search in contacts
58
-		//@todo Pagination missing
59
-		$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN']);
60
-		foreach ($addressBookContacts as $contact) {
61
-			if (isset($contact['isLocalSystemBook'])) {
62
-				continue;
63
-			}
64
-			if (isset($contact['CLOUD'])) {
65
-				$cloudIds = $contact['CLOUD'];
66
-				if (!is_array($cloudIds)) {
67
-					$cloudIds = [$cloudIds];
68
-				}
69
-				$lowerSearch = strtolower($search);
70
-				foreach ($cloudIds as $cloudId) {
71
-					try {
72
-						list(, $serverUrl) = $this->splitUserRemote($cloudId);
73
-					} catch (\InvalidArgumentException $e) {
74
-						continue;
75
-					}
57
+        // Search in contacts
58
+        //@todo Pagination missing
59
+        $addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN']);
60
+        foreach ($addressBookContacts as $contact) {
61
+            if (isset($contact['isLocalSystemBook'])) {
62
+                continue;
63
+            }
64
+            if (isset($contact['CLOUD'])) {
65
+                $cloudIds = $contact['CLOUD'];
66
+                if (!is_array($cloudIds)) {
67
+                    $cloudIds = [$cloudIds];
68
+                }
69
+                $lowerSearch = strtolower($search);
70
+                foreach ($cloudIds as $cloudId) {
71
+                    try {
72
+                        list(, $serverUrl) = $this->splitUserRemote($cloudId);
73
+                    } catch (\InvalidArgumentException $e) {
74
+                        continue;
75
+                    }
76 76
 
77
-					if (strtolower($contact['FN']) === $lowerSearch || strtolower($cloudId) === $lowerSearch) {
78
-						if (strtolower($cloudId) === $lowerSearch) {
79
-							$searchResult->markExactIdMatch($resultType);
80
-						}
81
-						$result['exact'][] = [
82
-							'label' => $contact['FN'] . " ($cloudId)",
83
-							'value' => [
84
-								'shareType' => Share::SHARE_TYPE_REMOTE,
85
-								'shareWith' => $cloudId,
86
-								'server' => $serverUrl,
87
-							],
88
-						];
89
-					} else {
90
-						$result['wide'][] = [
91
-							'label' => $contact['FN'] . " ($cloudId)",
92
-							'value' => [
93
-								'shareType' => Share::SHARE_TYPE_REMOTE,
94
-								'shareWith' => $cloudId,
95
-								'server' => $serverUrl,
96
-							],
97
-						];
98
-					}
99
-				}
100
-			}
101
-		}
77
+                    if (strtolower($contact['FN']) === $lowerSearch || strtolower($cloudId) === $lowerSearch) {
78
+                        if (strtolower($cloudId) === $lowerSearch) {
79
+                            $searchResult->markExactIdMatch($resultType);
80
+                        }
81
+                        $result['exact'][] = [
82
+                            'label' => $contact['FN'] . " ($cloudId)",
83
+                            'value' => [
84
+                                'shareType' => Share::SHARE_TYPE_REMOTE,
85
+                                'shareWith' => $cloudId,
86
+                                'server' => $serverUrl,
87
+                            ],
88
+                        ];
89
+                    } else {
90
+                        $result['wide'][] = [
91
+                            'label' => $contact['FN'] . " ($cloudId)",
92
+                            'value' => [
93
+                                'shareType' => Share::SHARE_TYPE_REMOTE,
94
+                                'shareWith' => $cloudId,
95
+                                'server' => $serverUrl,
96
+                            ],
97
+                        ];
98
+                    }
99
+                }
100
+            }
101
+        }
102 102
 
103
-		if (!$this->shareeEnumeration) {
104
-			$result['wide'] = [];
105
-		} else {
106
-			$result['wide'] = array_slice($result['wide'], $offset, $limit);
107
-		}
103
+        if (!$this->shareeEnumeration) {
104
+            $result['wide'] = [];
105
+        } else {
106
+            $result['wide'] = array_slice($result['wide'], $offset, $limit);
107
+        }
108 108
 
109
-		if (!$searchResult->hasExactIdMatch($resultType) && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) {
110
-			$result['exact'][] = [
111
-				'label' => $search,
112
-				'value' => [
113
-					'shareType' => Share::SHARE_TYPE_REMOTE,
114
-					'shareWith' => $search,
115
-				],
116
-			];
117
-		}
109
+        if (!$searchResult->hasExactIdMatch($resultType) && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) {
110
+            $result['exact'][] = [
111
+                'label' => $search,
112
+                'value' => [
113
+                    'shareType' => Share::SHARE_TYPE_REMOTE,
114
+                    'shareWith' => $search,
115
+                ],
116
+            ];
117
+        }
118 118
 
119
-		$searchResult->addResultSet($resultType, $result['wide'], $result['exact']);
119
+        $searchResult->addResultSet($resultType, $result['wide'], $result['exact']);
120 120
 
121
-		return true;
122
-	}
121
+        return true;
122
+    }
123 123
 
124
-	/**
125
-	 * split user and remote from federated cloud id
126
-	 *
127
-	 * @param string $address federated share address
128
-	 * @return array [user, remoteURL]
129
-	 * @throws \InvalidArgumentException
130
-	 */
131
-	public function splitUserRemote($address) {
132
-		try {
133
-			$cloudId = $this->cloudIdManager->resolveCloudId($address);
134
-			return [$cloudId->getUser(), $cloudId->getRemote()];
135
-		} catch (\InvalidArgumentException $e) {
136
-			throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e);
137
-		}
138
-	}
124
+    /**
125
+     * split user and remote from federated cloud id
126
+     *
127
+     * @param string $address federated share address
128
+     * @return array [user, remoteURL]
129
+     * @throws \InvalidArgumentException
130
+     */
131
+    public function splitUserRemote($address) {
132
+        try {
133
+            $cloudId = $this->cloudIdManager->resolveCloudId($address);
134
+            return [$cloudId->getUser(), $cloudId->getRemote()];
135
+        } catch (\InvalidArgumentException $e) {
136
+            throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e);
137
+        }
138
+    }
139 139
 }
Please login to merge, or discard this patch.
lib/private/Collaboration/Collaborators/Search.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$searchResult = $this->c->resolve(SearchResult::class);
48 48
 
49 49
 		foreach ($shareTypes as $type) {
50
-			if(!isset($this->pluginList[$type])) {
50
+			if (!isset($this->pluginList[$type])) {
51 51
 				continue;
52 52
 			}
53 53
 			foreach ($this->pluginList[$type] as $plugin) {
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
 		// that the exact same email address and federated cloud id exists
71 71
 		$emailType = new SearchResultType('emails');
72 72
 		$remoteType = new SearchResultType('remotes');
73
-		if($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) {
73
+		if ($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) {
74 74
 			$searchResult->unsetResult($remoteType);
75 75
 		} elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) {
76 76
 			$searchResult->unsetResult($emailType);
77 77
 		}
78 78
 
79
-		return [$searchResult->asArray(), (bool)$hasMoreResults];
79
+		return [$searchResult->asArray(), (bool) $hasMoreResults];
80 80
 	}
81 81
 
82 82
 	public function registerPlugin(array $pluginInfo) {
83
-		$shareType = constant(Share::class . '::' . $pluginInfo['shareType']);
84
-		if($shareType === null) {
83
+		$shareType = constant(Share::class.'::'.$pluginInfo['shareType']);
84
+		if ($shareType === null) {
85 85
 			throw new \InvalidArgumentException('Provided ShareType is invalid');
86 86
 		}
87 87
 		$this->pluginList[$shareType][] = $pluginInfo['class'];
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -31,68 +31,68 @@
 block discarded – undo
31 31
 use OCP\Share;
32 32
 
33 33
 class Search implements ISearch {
34
-	/** @var IContainer */
35
-	private $c;
34
+    /** @var IContainer */
35
+    private $c;
36 36
 
37
-	protected $pluginList = [];
37
+    protected $pluginList = [];
38 38
 
39
-	public function __construct(IContainer $c) {
40
-		$this->c = $c;
41
-	}
39
+    public function __construct(IContainer $c) {
40
+        $this->c = $c;
41
+    }
42 42
 
43
-	/**
44
-	 * @param string $search
45
-	 * @param array $shareTypes
46
-	 * @param bool $lookup
47
-	 * @param int|null $limit
48
-	 * @param int|null $offset
49
-	 * @return array
50
-	 * @throws \OCP\AppFramework\QueryException
51
-	 */
52
-	public function search($search, array $shareTypes, $lookup, $limit, $offset) {
53
-		$hasMoreResults = false;
43
+    /**
44
+     * @param string $search
45
+     * @param array $shareTypes
46
+     * @param bool $lookup
47
+     * @param int|null $limit
48
+     * @param int|null $offset
49
+     * @return array
50
+     * @throws \OCP\AppFramework\QueryException
51
+     */
52
+    public function search($search, array $shareTypes, $lookup, $limit, $offset) {
53
+        $hasMoreResults = false;
54 54
 
55
-		/** @var ISearchResult $searchResult */
56
-		$searchResult = $this->c->resolve(SearchResult::class);
55
+        /** @var ISearchResult $searchResult */
56
+        $searchResult = $this->c->resolve(SearchResult::class);
57 57
 
58
-		foreach ($shareTypes as $type) {
59
-			if(!isset($this->pluginList[$type])) {
60
-				continue;
61
-			}
62
-			foreach ($this->pluginList[$type] as $plugin) {
63
-				/** @var ISearchPlugin $searchPlugin */
64
-				$searchPlugin = $this->c->resolve($plugin);
65
-				$hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
66
-			}
67
-		}
58
+        foreach ($shareTypes as $type) {
59
+            if(!isset($this->pluginList[$type])) {
60
+                continue;
61
+            }
62
+            foreach ($this->pluginList[$type] as $plugin) {
63
+                /** @var ISearchPlugin $searchPlugin */
64
+                $searchPlugin = $this->c->resolve($plugin);
65
+                $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
66
+            }
67
+        }
68 68
 
69
-		// Get from lookup server, not a separate share type
70
-		if ($lookup) {
71
-			$searchPlugin = $this->c->resolve(LookupPlugin::class);
72
-			$hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
73
-		}
69
+        // Get from lookup server, not a separate share type
70
+        if ($lookup) {
71
+            $searchPlugin = $this->c->resolve(LookupPlugin::class);
72
+            $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
73
+        }
74 74
 
75
-		// sanitizing, could go into the plugins as well
75
+        // sanitizing, could go into the plugins as well
76 76
 
77
-		// if we have a exact match, either for the federated cloud id or for the
78
-		// email address we only return the exact match. It is highly unlikely
79
-		// that the exact same email address and federated cloud id exists
80
-		$emailType = new SearchResultType('emails');
81
-		$remoteType = new SearchResultType('remotes');
82
-		if($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) {
83
-			$searchResult->unsetResult($remoteType);
84
-		} elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) {
85
-			$searchResult->unsetResult($emailType);
86
-		}
77
+        // if we have a exact match, either for the federated cloud id or for the
78
+        // email address we only return the exact match. It is highly unlikely
79
+        // that the exact same email address and federated cloud id exists
80
+        $emailType = new SearchResultType('emails');
81
+        $remoteType = new SearchResultType('remotes');
82
+        if($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) {
83
+            $searchResult->unsetResult($remoteType);
84
+        } elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) {
85
+            $searchResult->unsetResult($emailType);
86
+        }
87 87
 
88
-		return [$searchResult->asArray(), (bool)$hasMoreResults];
89
-	}
88
+        return [$searchResult->asArray(), (bool)$hasMoreResults];
89
+    }
90 90
 
91
-	public function registerPlugin(array $pluginInfo) {
92
-		$shareType = constant(Share::class . '::' . $pluginInfo['shareType']);
93
-		if($shareType === null) {
94
-			throw new \InvalidArgumentException('Provided ShareType is invalid');
95
-		}
96
-		$this->pluginList[$shareType][] = $pluginInfo['class'];
97
-	}
91
+    public function registerPlugin(array $pluginInfo) {
92
+        $shareType = constant(Share::class . '::' . $pluginInfo['shareType']);
93
+        if($shareType === null) {
94
+            throw new \InvalidArgumentException('Provided ShareType is invalid');
95
+        }
96
+        $this->pluginList[$shareType][] = $pluginInfo['class'];
97
+    }
98 98
 }
Please login to merge, or discard this patch.