summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------3rdparty0
-rw-r--r--README.md4
-rw-r--r--apps/dav/appinfo/info.xml1
-rw-r--r--core/ajax/update.php15
-rw-r--r--core/js/js.js9
-rw-r--r--core/shipped.json1
-rw-r--r--lib/private/api.php18
-rw-r--r--lib/private/appframework/dependencyinjection/dicontainer.php4
-rw-r--r--lib/private/group/manager.php19
-rw-r--r--lib/private/legacy/subadmin.php172
-rw-r--r--lib/private/ocs/result.php4
-rw-r--r--lib/private/subadmin.php251
-rw-r--r--lib/private/updater.php3
-rw-r--r--settings/controller/checksetupcontroller.php4
-rw-r--r--settings/controller/userscontroller.php2
-rw-r--r--settings/js/apps.js4
-rw-r--r--tests/lib/api.php62
-rw-r--r--tests/lib/subadmin.php264
-rw-r--r--tests/settings/controller/userscontrollertest.php108
-rw-r--r--version.php2
20 files changed, 785 insertions, 162 deletions
diff --git a/3rdparty b/3rdparty
-Subproject 1914e923a4589e619b930e1ca587041d6fd3a1f
+Subproject f67a9ebe4362986ff31643d84d442fedce1d140
diff --git a/README.md b/README.md
index 1085d516263..7e1a9fbc78b 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ Dependencies:
[![Dependency Status](https://www.versioneye.com/user/projects/54d1f76f3ca0840b190000c0/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54d1f76f3ca0840b190000c0)
### Installation instructions
-https://doc.owncloud.org/server/8.2/developer_manual/app/index.html
+https://doc.owncloud.org/server/9.0/developer_manual/app/index.html
### Contribution Guidelines
https://owncloud.org/contribute/
@@ -35,4 +35,4 @@ https://www.transifex.com/projects/p/owncloud/
[![Transifex](https://www.transifex.com/projects/p/owncloud/resource/core/chart/image_png)](https://www.transifex.com/projects/p/owncloud/)
For more detailed information about translations:
-http://doc.owncloud.org/server/8.2/developer_manual/core/translation.html
+http://doc.owncloud.org/server/9.0/developer_manual/core/translation.html
diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml
index c80af15a29b..38878ec27f2 100644
--- a/apps/dav/appinfo/info.xml
+++ b/apps/dav/appinfo/info.xml
@@ -5,6 +5,7 @@
<description>ownCloud WebDAV endpoint</description>
<licence>AGPL</licence>
<author>owncloud.org</author>
+ <version>0.1</version>
<requiremin>9.0</requiremin>
<shipped>true</shipped>
<standalone/>
diff --git a/core/ajax/update.php b/core/ajax/update.php
index dfec64cd2cf..42f7f14bbdd 100644
--- a/core/ajax/update.php
+++ b/core/ajax/update.php
@@ -124,15 +124,18 @@ if (OC::checkUpgrade(false)) {
exit();
}
- if (!empty($incompatibleApps)) {
- $eventSource->send('notice',
- (string)$l->t('Following incompatible apps have been disabled: %s', implode(', ', $incompatibleApps)));
+ $disabledApps = [];
+ foreach ($disabledThirdPartyApps as $app) {
+ $disabledApps[$app] = (string) $l->t('%s (3rdparty)', [$app]);
}
- if (!empty($disabledThirdPartyApps)) {
- $eventSource->send('notice',
- (string)$l->t('Following apps have been disabled: %s', implode(', ', $disabledThirdPartyApps)));
+ foreach ($incompatibleApps as $app) {
+ $disabledApps[$app] = (string) $l->t('%s (incompatible)', [$app]);
}
+ if (!empty($disabledApps)) {
+ $eventSource->send('notice',
+ (string)$l->t('Following apps have been disabled: %s', implode(', ', $disabledApps)));
+ }
} else {
$eventSource->send('notice', (string)$l->t('Already up to date'));
}
diff --git a/core/js/js.js b/core/js/js.js
index 00a775b8027..3eafb3d9d6d 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1633,6 +1633,15 @@ OC.Util = {
},
/**
+ * Returns whether this is IE
+ *
+ * @return {bool} true if this is IE, false otherwise
+ */
+ isIE: function() {
+ return $('html').hasClass('ie');
+ },
+
+ /**
* Returns whether this is IE8
*
* @return {bool} true if this is IE8, false otherwise
diff --git a/core/shipped.json b/core/shipped.json
index 184308d7a48..7d506c3401a 100644
--- a/core/shipped.json
+++ b/core/shipped.json
@@ -1,5 +1,4 @@
{
- "core-version": "8.1.0.0",
"shippedApps": [
"activity",
"admin_audit",
diff --git a/lib/private/api.php b/lib/private/api.php
index 10d58f2d9e6..6d7354c7193 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -231,7 +231,8 @@ class OC_API {
$picked = reset($shipped['failed']);
$code = $picked['response']->getStatusCode();
$meta = $picked['response']->getMeta();
- $response = new OC_OCS_Result($data, $code, $meta['message']);
+ $headers = $picked['response']->getHeaders();
+ $response = new OC_OCS_Result($data, $code, $meta['message'], $headers);
return $response;
} elseif(!empty($shipped['succeeded'])) {
$responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']);
@@ -244,13 +245,16 @@ class OC_API {
$picked = reset($thirdparty['failed']);
$code = $picked['response']->getStatusCode();
$meta = $picked['response']->getMeta();
- $response = new OC_OCS_Result($data, $code, $meta['message']);
+ $headers = $picked['response']->getHeaders();
+ $response = new OC_OCS_Result($data, $code, $meta['message'], $headers);
return $response;
} else {
$responses = $thirdparty['succeeded'];
}
// Merge the successful responses
- $data = array();
+ $data = [];
+ $codes = [];
+ $header = [];
foreach($responses as $response) {
if($response['shipped']) {
@@ -258,8 +262,9 @@ class OC_API {
} else {
$data = array_merge_recursive($data, $response['response']->getData());
}
- $codes[] = array('code' => $response['response']->getStatusCode(),
- 'meta' => $response['response']->getMeta());
+ $header = array_merge_recursive($header, $response['response']->getHeaders());
+ $codes[] = ['code' => $response['response']->getStatusCode(),
+ 'meta' => $response['response']->getMeta()];
}
// Use any non 100 status codes
@@ -273,8 +278,7 @@ class OC_API {
}
}
- $result = new OC_OCS_Result($data, $statusCode, $statusMessage);
- return $result;
+ return new OC_OCS_Result($data, $statusCode, $statusMessage, $header);
}
/**
diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php
index 651b268a35e..de8672bc4cd 100644
--- a/lib/private/appframework/dependencyinjection/dicontainer.php
+++ b/lib/private/appframework/dependencyinjection/dicontainer.php
@@ -226,6 +226,10 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $this->getServer();
});
+ $this->registerService('OCP\\AppFramework\\IAppContainer', function ($c) {
+ return $c;
+ });
+
// commonly used attributes
$this->registerService('UserId', function ($c) {
return $c->query('OCP\\IUserSession')->getSession()->get('user_id');
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index 65ae49dfcd2..6905dd8f5f2 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -71,11 +71,13 @@ class Manager extends PublicEmitter implements IGroupManager {
*/
private $cachedUserGroups = array();
+ /** @var \OC\SubAdmin */
+ private $subAdmin = null;
/**
* @param \OC\User\Manager $userManager
*/
- public function __construct($userManager) {
+ public function __construct(\OC\User\Manager $userManager) {
$this->userManager = $userManager;
$cachedGroups = & $this->cachedGroups;
$cachedUserGroups = & $this->cachedUserGroups;
@@ -314,4 +316,19 @@ class Manager extends PublicEmitter implements IGroupManager {
}
return $matchingUsers;
}
+
+ /**
+ * @return \OC\SubAdmin
+ */
+ public function getSubAdmin() {
+ if (!$this->subAdmin) {
+ $this->subAdmin = new \OC\SubAdmin(
+ $this->userManager,
+ $this,
+ \OC::$server->getDatabaseConnection()
+ );
+ }
+
+ return $this->subAdmin;
+ }
}
diff --git a/lib/private/legacy/subadmin.php b/lib/private/legacy/subadmin.php
new file mode 100644
index 00000000000..d10b6e90bb5
--- /dev/null
+++ b/lib/private/legacy/subadmin.php
@@ -0,0 +1,172 @@
+<?php
+/**
+ * @author Bart Visscher <bartv@thisnet.nl>
+ * @author Georg Ehrke <georg@owncloud.com>
+ * @author Jörn Friedrich Dreyer <jfd@butonic.de>
+ * @author Lukas Reschke <lukas@owncloud.com>
+ * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/**
+ * This class provides all methods needed for managing groups.
+ *
+ * Hooks provided:
+ * post_createSubAdmin($gid)
+ * post_deleteSubAdmin($gid)
+ */
+class OC_SubAdmin{
+
+ /**
+ * add a SubAdmin
+ * @param string $uid uid of the SubAdmin
+ * @param string $gid gid of the group
+ * @return boolean
+ */
+ public static function createSubAdmin($uid, $gid) {
+ $groupManager = \OC::$server->getGroupManager();
+ $userManager = \OC::$server->getUserManager();
+ $subAdmin = $groupManager->getSubAdmin();
+
+ return $subAdmin->createSubAdmin($userManager->get($uid), $groupManager->get($gid));
+ }
+
+ /**
+ * delete a SubAdmin
+ * @param string $uid uid of the SubAdmin
+ * @param string $gid gid of the group
+ * @return boolean
+ */
+ public static function deleteSubAdmin($uid, $gid) {
+ $groupManager = \OC::$server->getGroupManager();
+ $userManager = \OC::$server->getUserManager();
+ $subAdmin = $groupManager->getSubAdmin();
+
+ return $subAdmin->deleteSubAdmin($userManager->get($uid), $groupManager->get($gid));
+ }
+
+ /**
+ * get groups of a SubAdmin
+ * @param string $uid uid of the SubAdmin
+ * @return array
+ */
+ public static function getSubAdminsGroups($uid) {
+ $groupManager = \OC::$server->getGroupManager();
+ $userManager = \OC::$server->getUserManager();
+ $subAdmin = $groupManager->getSubAdmin();
+
+ $groups = $subAdmin->getSubAdminsGroups($userManager->get($uid));
+
+ // New class returns IGroup[] so convert back
+ $gids = [];
+ foreach ($groups as $group) {
+ $gids[] = $group->getGID();
+ }
+ return $gids;
+ }
+
+ /**
+ * get SubAdmins of a group
+ * @param string $gid gid of the group
+ * @return array
+ */
+ public static function getGroupsSubAdmins($gid) {
+ $groupManager = \OC::$server->getGroupManager();
+ $subAdmin = $groupManager->getSubAdmin();
+
+ $users = $subAdmin->getGroupsSubAdmins($groupManager->get($gid));
+
+ // New class returns IUser[] so convert back
+ $uids = [];
+ foreach ($users as $user) {
+ $uids[] = $user->getUID();
+ }
+ return $uids;
+ }
+
+ /**
+ * get all SubAdmins
+ * @return array
+ */
+ public static function getAllSubAdmins() {
+ $groupManager = \OC::$server->getGroupManager();
+ $subAdmin = $groupManager->getSubAdmin();
+
+ $subAdmins = $subAdmin->getAllSubAdmins();
+
+ // New class returns IUser[] so convert back
+ $result = [];
+ foreach ($subAdmins as $subAdmin) {
+ $result[] = [
+ 'gid' => $subAdmin['group']->getGID(),
+ 'uid' => $subAdmin['user']->getUID(),
+ ];
+ }
+ return $result;
+ }
+
+ /**
+ * checks if a user is a SubAdmin of a group
+ * @param string $uid uid of the subadmin
+ * @param string $gid gid of the group
+ * @return bool
+ */
+ public static function isSubAdminofGroup($uid, $gid) {
+ $groupManager = \OC::$server->getGroupManager();
+ $userManager = \OC::$server->getUserManager();
+ $subAdmin = $groupManager->getSubAdmin();
+
+ return $subAdmin->isSubAdminOfGroup($userManager->get($uid), $groupManager->get($gid));
+ }
+
+ /**
+ * checks if a user is a SubAdmin
+ * @param string $uid uid of the subadmin
+ * @return bool
+ */
+ public static function isSubAdmin($uid) {
+ $groupManager = \OC::$server->getGroupManager();
+ $userManager = \OC::$server->getUserManager();
+ $subAdmin = $groupManager->getSubAdmin();
+
+ return $subAdmin->isSubAdmin($userManager->get($uid));
+ }
+
+ /**
+ * checks if a user is a accessible by a subadmin
+ * @param string $subadmin uid of the subadmin
+ * @param string $user uid of the user
+ * @return bool
+ */
+ public static function isUserAccessible($subadmin, $user) {
+ $groupManager = \OC::$server->getGroupManager();
+ $userManager = \OC::$server->getUserManager();
+ $subAdmin = $groupManager->getSubAdmin();
+
+ return $subAdmin->isUserAccessible($userManager->get($subadmin), $userManager->get($user));
+ }
+
+ /*
+ * alias for self::isSubAdminofGroup()
+ */
+ public static function isGroupAccessible($subadmin, $group) {
+ return self::isSubAdminofGroup($subadmin, $group);
+ }
+}
diff --git a/lib/private/ocs/result.php b/lib/private/ocs/result.php
index 916e25e45ae..2c3f676510c 100644
--- a/lib/private/ocs/result.php
+++ b/lib/private/ocs/result.php
@@ -51,8 +51,9 @@ class OC_OCS_Result{
* @param mixed $data the data to return
* @param int $code
* @param null|string $message
+ * @param array $headers
*/
- public function __construct($data=null, $code=100, $message=null) {
+ public function __construct($data = null, $code = 100, $message = null, $headers = []) {
if ($data === null) {
$this->data = array();
} elseif (!is_array($data)) {
@@ -62,6 +63,7 @@ class OC_OCS_Result{
}
$this->statusCode = $code;
$this->message = $message;
+ $this->headers = $headers;
}
/**
diff --git a/lib/private/subadmin.php b/lib/private/subadmin.php
index ec4f9f3b899..0e130a7700a 100644
--- a/lib/private/subadmin.php
+++ b/lib/private/subadmin.php
@@ -2,10 +2,9 @@
/**
* @author Bart Visscher <bartv@thisnet.nl>
* @author Georg Ehrke <georg@owncloud.com>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
@@ -24,171 +23,235 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-OC_Hook::connect('OC_User', 'post_deleteUser', 'OC_SubAdmin', 'post_deleteUser');
-OC_Hook::connect('OC_User', 'post_deleteGroup', 'OC_SubAdmin', 'post_deleteGroup');
-/**
- * This class provides all methods needed for managing groups.
- *
- * Hooks provided:
- * post_createSubAdmin($gid)
- * post_deleteSubAdmin($gid)
- */
-class OC_SubAdmin{
+
+namespace OC;
+
+use OC\Hooks\PublicEmitter;
+use OCP\IUser;
+use OCP\IUserManager;
+use OCP\IGroup;
+use OCP\IGroupManager;
+use OCP\IDBConnection;
+
+class SubAdmin extends PublicEmitter {
+
+ /** @var IUserManager */
+ private $userManager;
+
+ /** @var IGroupManager */
+ private $groupManager;
+
+ /** @var IDBConnection */
+ private $dbConn;
+
+ public function __construct(IUserManager $userManager,
+ IGroupManager $groupManager,
+ IDBConnection $dbConn) {
+ $this->userManager = $userManager;
+ $this->groupManager = $groupManager;
+ $this->dbConn = $dbConn;
+
+ $this->userManager->listen('\OC\User', 'postDelete', function($user) {
+ $this->post_deleteUser($user);
+ });
+ $this->groupManager->listen('\OC\Group', 'postDelete', function($group) {
+ $this->post_deleteGroup($group);
+ });
+ }
/**
* add a SubAdmin
- * @param string $uid uid of the SubAdmin
- * @param string $gid gid of the group
- * @return boolean
+ * @param IUser $user user to be SubAdmin
+ * @param IGroup $group group $user becomes subadmin of
+ * @return bool
*/
- public static function createSubAdmin($uid, $gid) {
- $stmt = OC_DB::prepare('INSERT INTO `*PREFIX*group_admin` (`gid`,`uid`) VALUES(?,?)');
- $stmt->execute(array($gid, $uid));
- OC_Hook::emit( "OC_SubAdmin", "post_createSubAdmin", array( "gid" => $gid ));
+ public function createSubAdmin(IUser $user, IGroup $group) {
+ $qb = $this->dbConn->getQueryBuilder();
+
+ $result = $qb->insert('group_admin')
+ ->values([
+ 'gid' => $qb->createNamedParameter($group->getGID()),
+ 'uid' => $qb->createNamedParameter($user->getUID())
+ ])
+ ->execute();
+
+ $this->emit('\OC\SubAdmin', 'postCreateSubAdmin', [$user, $group]);
+ \OC_Hook::emit("OC_SubAdmin", "post_createSubAdmin", ["gid" => $group->getGID()]);
return true;
}
/**
* delete a SubAdmin
- * @param string $uid uid of the SubAdmin
- * @param string $gid gid of the group
- * @return boolean
+ * @param IUser $user the user that is the SubAdmin
+ * @param IGroup $group the group
+ * @return bool
*/
- public static function deleteSubAdmin($uid, $gid) {
- $stmt = OC_DB::prepare('DELETE FROM `*PREFIX*group_admin` WHERE `gid` = ? AND `uid` = ?');
- $stmt->execute(array($gid, $uid));
- OC_Hook::emit( "OC_SubAdmin", "post_deleteSubAdmin", array( "gid" => $gid ));
+ public function deleteSubAdmin(IUser $user, IGroup $group) {
+ $qb = $this->dbConn->getQueryBuilder();
+
+ $result = $qb->delete('group_admin')
+ ->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
+ ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
+ ->execute();
+
+ $this->emit('\OC\SubAdmin', 'postDeleteSubAdmin', [$user, $group]);
+ \OC_Hook::emit("OC_SubAdmin", "post_deleteSubAdmin", ["gid" => $group->getGID()]);
return true;
}
/**
* get groups of a SubAdmin
- * @param string $uid uid of the SubAdmin
- * @return array
+ * @param IUser $user the SubAdmin
+ * @return IGroup[]
*/
- public static function getSubAdminsGroups($uid) {
- $stmt = OC_DB::prepare('SELECT `gid` FROM `*PREFIX*group_admin` WHERE `uid` = ?');
- $result = $stmt->execute(array($uid));
- $gids = array();
- while($row = $result->fetchRow()) {
- $gids[] = $row['gid'];
+ public function getSubAdminsGroups(IUser $user) {
+ $qb = $this->dbConn->getQueryBuilder();
+
+ $result = $qb->select('gid')
+ ->from('group_admin')
+ ->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
+ ->execute();
+
+ $groups = [];
+ while($row = $result->fetch()) {
+ $groups[] = $this->groupManager->get($row['gid']);
}
- return $gids;
+
+ return $groups;
}
/**
* get SubAdmins of a group
- * @param string $gid gid of the group
- * @return array
+ * @param IGroup $group the group
+ * @return IUser[]
*/
- public static function getGroupsSubAdmins($gid) {
- $stmt = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*group_admin` WHERE `gid` = ?');
- $result = $stmt->execute(array($gid));
- $uids = array();
- while($row = $result->fetchRow()) {
- $uids[] = $row['uid'];
+ public function getGroupsSubAdmins(IGroup $group) {
+ $qb = $this->dbConn->getQueryBuilder();
+
+ $result = $qb->select('uid')
+ ->from('group_admin')
+ ->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
+ ->execute();
+
+ $users = [];
+ while($row = $result->fetch()) {
+ $users[] = $this->userManager->get($row['uid']);
}
- return $uids;
+
+ return $users;
}
/**
* get all SubAdmins
* @return array
*/
- public static function getAllSubAdmins() {
- $stmt = OC_DB::prepare('SELECT * FROM `*PREFIX*group_admin`');
- $result = $stmt->execute();
- $subadmins = array();
- while($row = $result->fetchRow()) {
- $subadmins[] = $row;
+ public function getAllSubAdmins() {
+ $qb = $this->dbConn->getQueryBuilder();
+
+ $result = $qb->select('*')
+ ->from('group_admin')
+ ->execute();
+
+ $subadmins = [];
+ while($row = $result->fetch()) {
+ $subadmins[] = [
+ 'user' => $this->userManager->get($row['uid']),
+ 'group' => $this->groupManager->get($row['gid'])
+ ];
}
return $subadmins;
}
/**
* checks if a user is a SubAdmin of a group
- * @param string $uid uid of the subadmin
- * @param string $gid gid of the group
+ * @param IUser $user
+ * @param IGroup $group
* @return bool
*/
- public static function isSubAdminofGroup($uid, $gid) {
- $stmt = OC_DB::prepare('SELECT COUNT(*) AS `count` FROM `*PREFIX*group_admin` WHERE `uid` = ? AND `gid` = ?');
- $result = $stmt->execute(array($uid, $gid));
- $result = $result->fetchRow();
- if($result['count'] >= 1) {
- return true;
- }
- return false;
+ public function isSubAdminofGroup(IUser $user, IGroup $group) {
+ $qb = $this->dbConn->getQueryBuilder();
+
+ $result = $qb->select('*')
+ ->from('group_admin')
+ ->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
+ ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
+ ->execute();
+
+ return !empty($result->fetch()) ? true : false;
}
/**
* checks if a user is a SubAdmin
- * @param string $uid uid of the subadmin
+ * @param IUser $user
* @return bool
*/
- public static function isSubAdmin($uid) {
+ public function isSubAdmin(IUser $user) {
// Check if the user is already an admin
- if(OC_Group::inGroup($uid, 'admin' )) {
+ if ($this->groupManager->isAdmin($user->getUID())) {
return true;
}
- $stmt = OC_DB::prepare('SELECT COUNT(*) AS `count` FROM `*PREFIX*group_admin` WHERE `uid` = ?');
- $result = $stmt->execute(array($uid));
- $result = $result->fetchRow();
- if($result['count'] > 0) {
- return true;
- }
- return false;
+ $qb = $this->dbConn->getQueryBuilder();
+
+ $result = $qb->select('gid')
+ ->from('group_admin')
+ ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
+ ->setMaxResults(1)
+ ->execute()
+ ->fetch();
+
+ return $result === false ? false : true;
}
/**
* checks if a user is a accessible by a subadmin
- * @param string $subadmin uid of the subadmin
- * @param string $user uid of the user
+ * @param IUser $subadmin
+ * @param IUser $user
* @return bool
*/
- public static function isUserAccessible($subadmin, $user) {
- if(!self::isSubAdmin($subadmin)) {
+ public function isUserAccessible($subadmin, $user) {
+ if(!$this->isSubAdmin($subadmin)) {
return false;
}
- if(OC_User::isAdminUser($user)) {
+ if($this->groupManager->isAdmin($user->getUID())) {
return false;
}
- $accessiblegroups = self::getSubAdminsGroups($subadmin);
+ $accessiblegroups = $this->getSubAdminsGroups($subadmin);
foreach($accessiblegroups as $accessiblegroup) {
- if(OC_Group::inGroup($user, $accessiblegroup)) {
+ if($accessiblegroup->inGroup($user)) {
return true;
}
}
return false;
}
- /*
- * alias for self::isSubAdminofGroup()
- */
- public static function isGroupAccessible($subadmin, $group) {
- return self::isSubAdminofGroup($subadmin, $group);
- }
-
/**
- * delete all SubAdmins by uid
- * @param array $parameters
+ * delete all SubAdmins by $user
+ * @param IUser $user
* @return boolean
*/
- public static function post_deleteUser($parameters) {
- $stmt = OC_DB::prepare('DELETE FROM `*PREFIX*group_admin` WHERE `uid` = ?');
- $stmt->execute(array($parameters['uid']));
+ private function post_deleteUser($user) {
+ $qb = $this->dbConn->getQueryBuilder();
+
+ $result = $qb->delete('group_admin')
+ ->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
+ ->execute();
+
return true;
}
/**
- * delete all SubAdmins by gid
- * @param array $parameters
+ * delete all SubAdmins by $group
+ * @param IGroup $group
* @return boolean
*/
- public static function post_deleteGroup($parameters) {
- $stmt = OC_DB::prepare('DELETE FROM `*PREFIX*group_admin` WHERE `gid` = ?');
- $stmt->execute(array($parameters['gid']));
+ private function post_deleteGroup($group) {
+ $qb = $this->dbConn->getQueryBuilder();
+
+ $result = $qb->delete('group_admin')
+ ->where($qb->expr()->eq('gid', $qb->createNamedParameter($group->getGID())))
+ ->execute();
+
return true;
}
}
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 9e5207c2a18..1e4421c39d7 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -315,6 +315,9 @@ class Updater extends BasicEmitter {
if ($this->updateStepEnabled) {
$this->doCoreUpgrade();
+ // install new shipped apps on upgrade
+ OC_Installer::installShippedApps();
+
// update all shipped apps
$disabledApps = $this->checkAppsRequirements();
$this->doAppUpgrade();
diff --git a/settings/controller/checksetupcontroller.php b/settings/controller/checksetupcontroller.php
index 2ff55fc72c9..bd0737aacc4 100644
--- a/settings/controller/checksetupcontroller.php
+++ b/settings/controller/checksetupcontroller.php
@@ -195,7 +195,7 @@ class CheckSetupController extends Controller {
return '';
}
-
+
/**
* Whether the php version is still supported (at time of release)
* according to: https://secure.php.net/supported-versions.php
@@ -244,7 +244,7 @@ class CheckSetupController extends Controller {
// there are two different memcached modules for PHP
// we only support memcached and not memcache
// https://code.google.com/p/memcached/wiki/PHPClientComparison
- return !extension_loaded('memcached') && extension_loaded('memcache');
+ return !(!extension_loaded('memcached') && extension_loaded('memcache'));
}
/**
diff --git a/settings/controller/userscontroller.php b/settings/controller/userscontroller.php
index d9b6ba7f721..ddabd308a50 100644
--- a/settings/controller/userscontroller.php
+++ b/settings/controller/userscontroller.php
@@ -167,7 +167,7 @@ class UsersController extends Controller {
'name' => $user->getUID(),
'displayname' => $user->getDisplayName(),
'groups' => (empty($userGroups)) ? $this->groupManager->getUserGroupIds($user) : $userGroups,
- 'subadmin' => \OC_SubAdmin::getSubAdminsGroups($user->getUID()),
+ 'subadmin' => $this->subAdminFactory->getSubAdminsOfGroups($user->getUID()),
'quota' => $this->config->getUserValue($user->getUID(), 'files', 'quota', 'default'),
'storageLocation' => $user->getHome(),
'lastLogin' => $user->getLastLogin() * 1000,
diff --git a/settings/js/apps.js b/settings/js/apps.js
index d51c642c9c9..987153b778c 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -161,8 +161,8 @@ OC.Settings.Apps = OC.Settings.Apps || {
var page = $('#app-' + app.id);
- // image loading kung-fu
- if (app.preview) {
+ // image loading kung-fu (IE doesn't properly scale SVGs, so disable app icons)
+ if (app.preview && !OC.Util.isIE()) {
var currentImage = new Image();
currentImage.src = app.preview;
diff --git a/tests/lib/api.php b/tests/lib/api.php
index f8f03965711..1d1f97c4942 100644
--- a/tests/lib/api.php
+++ b/tests/lib/api.php
@@ -14,11 +14,13 @@ class Test_API extends \Test\TestCase {
* @param string $message
*/
function buildResponse($shipped, $data, $code, $message=null) {
- return array(
+ $resp = new OC_OCS_Result($data, $code, $message);
+ $resp->addHeader('KEY', 'VALUE');
+ return [
'shipped' => $shipped,
- 'response' => new OC_OCS_Result($data, $code, $message),
+ 'response' => $resp,
'app' => $this->getUniqueID('testapp_'),
- );
+ ];
}
// Validate details of the result
@@ -79,11 +81,11 @@ class Test_API extends \Test\TestCase {
}
function dataProviderTestOneResult() {
- return array(
- array(100, true),
- array(101, false),
- array(997, false),
- );
+ return [
+ [100, true],
+ [101, false],
+ [997, false],
+ ];
}
/**
@@ -94,47 +96,47 @@ class Test_API extends \Test\TestCase {
*/
public function testOneResult($statusCode, $succeeded) {
// Setup some data arrays
- $data1 = array(
- 'users' => array(
- 'tom' => array(
+ $data1 = [
+ 'users' => [
+ 'tom' => [
'key' => 'value',
- ),
- 'frank' => array(
+ ],
+ 'frank' => [
'key' => 'value',
- ),
- ));
+ ],
+ ]];
// Test merging one success result
$response = $this->buildResponse(true, $data1, $statusCode);
- $result = OC_API::mergeResponses(array($response));
+ $result = OC_API::mergeResponses([$response]);
$this->assertEquals($response['response'], $result);
$this->checkResult($result, $succeeded);
}
function dataProviderTestMergeResponses() {
- return array(
+ return [
// Two shipped success results
- array(true, 100, true, 100, true),
+ [true, 100, true, 100, true],
// Two shipped results, one success and one failure
- array(true, 100, true, 998, false),
+ [true, 100, true, 998, false],
// Two shipped results, both failure
- array(true, 997, true, 998, false),
+ [true, 997, true, 998, false],
// Two third party success results
- array(false, 100, false, 100, true),
+ [false, 100, false, 100, true],
// Two third party results, one success and one failure
- array(false, 100, false, 998, false),
+ [false, 100, false, 998, false],
// Two third party results, both failure
- array(false, 997, false, 998, false),
+ [false, 997, false, 998, false],
// One of each, both success
- array(false, 100, true, 100, true),
- array(true, 100, false, 100, true),
+ [false, 100, true, 100, true],
+ [true, 100, false, 100, true],
// One of each, both failure
- array(false, 997, true, 998, false),
+ [false, 997, true, 998, false],
// One of each, shipped success
- array(false, 997, true, 100, true),
+ [false, 997, true, 100, true],
// One of each, third party success
- array(false, 100, true, 998, false),
- );
+ [false, 100, true, 998, false],
+ ];
}
/**
* @dataProvider dataProviderTestMergeResponses
@@ -175,9 +177,11 @@ class Test_API extends \Test\TestCase {
$this->checkResult($result, $succeeded);
$resultData = $result->getData();
$resultMeta = $result->getMeta();
+ $resultHeaders = $result->getHeaders();
$resultStatusCode = $result->getStatusCode();
$this->assertArrayHasKey('jan', $resultData['users']);
+ $this->assertArrayHasKey('KEY', $resultHeaders);
// check if the returned status message matches the selected status code
if ($resultStatusCode === 997) {
diff --git a/tests/lib/subadmin.php b/tests/lib/subadmin.php
new file mode 100644
index 00000000000..0855e514c7e
--- /dev/null
+++ b/tests/lib/subadmin.php
@@ -0,0 +1,264 @@
+<?php
+/**
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+namespace Test;
+
+class SubAdmin extends \Test\TestCase {
+
+ /** @var \OCP\IUserManager */
+ private $userManager;
+
+ /** @var \OCP\IGroupManager */
+ private $groupManager;
+
+ /** @var \OCP\IDBConnection */
+ private $dbConn;
+
+ /** @var \OCP\IUser[] */
+ private $users;
+
+ /** @var \OCP\IGroup[] */
+ private $groups;
+
+ public function setup() {
+ $this->users = [];
+ $this->groups = [];
+
+ $this->userManager = \OC::$server->getUserManager();
+ $this->groupManager = \OC::$server->getGroupManager();
+ $this->dbConn = \OC::$server->getDatabaseConnection();
+
+ // Create 3 users and 3 groups
+ for ($i = 0; $i < 3; $i++) {
+ $this->users[] = $this->userManager->createUser('user'.$i, 'user');
+ $this->groups[] = $this->groupManager->createGroup('group'.$i);
+ }
+
+ // Create admin group
+ if (!$this->groupManager->groupExists('admin')) {
+ $this->groupManager->createGroup('admin');
+ }
+ }
+
+ public function tearDown() {
+ foreach($this->users as $user) {
+ $user->delete();
+ }
+
+ foreach($this->groups as $group) {
+ $group->delete();
+ }
+ }
+
+ public function testCreateSubAdmin() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
+
+ // Look for subadmin in the database
+ $qb = $this->dbConn->getQueryBuilder();
+ $result = $qb->select(['gid', 'uid'])
+ ->from('group_admin')
+ ->where($qb->expr()->eq('gid', $qb->createNamedParameter($this->groups[0]->getGID())))
+ ->andWHere($qb->expr()->eq('uid', $qb->createNamedParameter($this->users[0]->getUID())))
+ ->execute()
+ ->fetch();
+ $this->assertEquals(
+ [
+ 'gid' => $this->groups[0]->getGID(),
+ 'uid' => $this->users[0]->getUID()
+ ], $result);
+
+ // Delete subadmin
+ $result = $qb->delete('*PREFIX*group_admin')
+ ->where($qb->expr()->eq('gid', $qb->createNamedParameter($this->groups[0]->getGID())))
+ ->andWHere($qb->expr()->eq('uid', $qb->createNamedParameter($this->users[0]->getUID())))
+ ->execute();
+ }
+
+ public function testDeleteSubAdmin() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
+ $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[0]));
+
+ // DB query should be empty
+ $qb = $this->dbConn->getQueryBuilder();
+ $result = $qb->select(['gid', 'uid'])
+ ->from('group_admin')
+ ->where($qb->expr()->eq('gid', $qb->createNamedParameter($this->groups[0]->getGID())))
+ ->andWHere($qb->expr()->eq('uid', $qb->createNamedParameter($this->users[0]->getUID())))
+ ->execute()
+ ->fetch();
+ $this->assertEmpty($result);
+ }
+
+ public function testGetSubAdminsGroups() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[1]));
+
+ $result = $subAdmin->getSubAdminsGroups($this->users[0]);
+
+ $this->assertContains($this->groups[0], $result);
+ $this->assertContains($this->groups[1], $result);
+ $this->assertNotContains($this->groups[2], $result);
+
+ $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[0]));
+ $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[1]));
+ }
+
+ public function testGetGroupsSubAdmins() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[1], $this->groups[0]));
+
+ $result = $subAdmin->getGroupsSubAdmins($this->groups[0]);
+
+ $this->assertContains($this->users[0], $result);
+ $this->assertContains($this->users[1], $result);
+ $this->assertNotContains($this->users[2], $result);
+
+ $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[0]));
+ $this->assertTrue($subAdmin->deleteSubAdmin($this->users[1], $this->groups[0]));
+ }
+
+ public function testGetAllSubAdmin() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[1], $this->groups[1]));
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[2], $this->groups[1]));
+
+ $result = $subAdmin->getAllSubAdmins();
+
+ $this->assertContains(['user' => $this->users[0], 'group' => $this->groups[0]], $result);
+ $this->assertContains(['user' => $this->users[1], 'group' => $this->groups[1]], $result);
+ $this->assertContains(['user' => $this->users[2], 'group' => $this->groups[1]], $result);
+ }
+
+ public function testIsSubAdminofGroup() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
+
+ $this->assertTrue($subAdmin->isSubAdminOfGroup($this->users[0], $this->groups[0]));
+ $this->assertFalse($subAdmin->isSubAdminOfGroup($this->users[0], $this->groups[1]));
+ $this->assertFalse($subAdmin->isSubAdminOfGroup($this->users[1], $this->groups[0]));
+
+ $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[0]));
+ }
+
+ public function testIsSubAdmin() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
+
+ $this->assertTrue($subAdmin->isSubAdmin($this->users[0]));
+ $this->assertFalse($subAdmin->isSubAdmin($this->users[1]));
+
+ $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[0]));
+ }
+
+ public function testIsSubAdminAsAdmin() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+ $this->groupManager->get('admin')->addUser($this->users[0]);
+
+ $this->assertTrue($subAdmin->isSubAdmin($this->users[0]));
+ }
+
+ public function testIsUserAccessible() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+ $this->groups[0]->addUser($this->users[1]);
+ $this->groups[1]->addUser($this->users[1]);
+ $this->groups[1]->addUser($this->users[2]);
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[2], $this->groups[2]));
+
+ $this->assertTrue($subAdmin->isUserAccessible($this->users[0], $this->users[1]));
+ $this->assertFalse($subAdmin->isUserAccessible($this->users[0], $this->users[2]));
+ $this->assertFalse($subAdmin->isUserAccessible($this->users[2], $this->users[0]));
+
+ $this->assertTrue($subAdmin->deleteSubAdmin($this->users[0], $this->groups[0]));
+ $this->assertTrue($subAdmin->deleteSubAdmin($this->users[2], $this->groups[2]));
+ }
+
+ public function testIsUserAccessibleAsUser() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+ $this->assertFalse($subAdmin->isUserAccessible($this->users[0], $this->users[1]));
+ }
+
+ public function testIsUserAccessibleAdmin() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+ $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
+ $this->groupManager->get('admin')->addUser($this->users[1]);
+
+ $this->assertFalse($subAdmin->isUserAccessible($this->users[0], $this->users[1]));
+
+ }
+
+ public function testPostDeleteUser() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+
+ $user = array_shift($this->users);
+ foreach($this->groups as $group) {
+ $this->assertTrue($subAdmin->createSubAdmin($user, $group));
+ }
+
+ $user->delete();
+ $this->assertEmpty($subAdmin->getAllSubAdmins());
+ }
+
+ public function testPostDeleteGroup() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+
+ $group = array_shift($this->groups);
+ foreach($this->users as $user) {
+ $this->assertTrue($subAdmin->createSubAdmin($user, $group));
+ }
+
+ $group->delete();
+ $this->assertEmpty($subAdmin->getAllSubAdmins());
+ }
+
+ public function testHooks() {
+ $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
+
+ $test = $this;
+ $u = $this->users[0];
+ $g = $this->groups[0];
+ $count = 0;
+
+ $subAdmin->listen('\OC\SubAdmin', 'postCreateSubAdmin', function ($user, $group) use ($test, $u, $g, &$count) {
+ $test->assertEquals($u->getUID(), $user->getUID());
+ $test->assertEquals($g->getGID(), $group->getGID());
+ $count++;
+ });
+
+ $subAdmin->listen('\OC\SubAdmin', 'postDeleteSubAdmin', function ($user, $group) use ($test, $u, $g, &$count) {
+ $test->assertEquals($u->getUID(), $user->getUID());
+ $test->assertEquals($g->getGID(), $group->getGID());
+ $count++;
+ });
+
+ $this->assertTrue($subAdmin->createSubAdmin($u, $g));
+ $this->assertEquals(1, $count);
+
+ $this->assertTrue($subAdmin->deleteSubAdmin($u, $g));
+ $this->assertEquals(2, $count);
+ }
+
+}
diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php
index 6fab43d6a16..408ddc45589 100644
--- a/tests/settings/controller/userscontrollertest.php
+++ b/tests/settings/controller/userscontrollertest.php
@@ -153,6 +153,22 @@ class UsersControllerTest extends \Test\TestCase {
404, 'admin@bar.com',
2323, 'bar@dummy.com'));
+ $this->container['SubAdminFactory']
+ ->expects($this->at(0))
+ ->method('getSubAdminsOfGroups')
+ ->with('foo')
+ ->will($this->returnValue([]));
+ $this->container['SubAdminFactory']
+ ->expects($this->at(1))
+ ->method('getSubAdminsOfGroups')
+ ->with('admin')
+ ->will($this->returnValue([]));
+ $this->container['SubAdminFactory']
+ ->expects($this->at(2))
+ ->method('getSubAdminsOfGroups')
+ ->with('bar')
+ ->will($this->returnValue([]));
+
$expectedResponse = new DataResponse(
array(
0 => array(
@@ -199,11 +215,6 @@ class UsersControllerTest extends \Test\TestCase {
public function testIndexSubAdmin() {
$this->container['IsAdmin'] = false;
- $this->container['SubAdminFactory']
- ->expects($this->once())
- ->method('getSubAdminsOfGroups')
- ->with('username')
- ->will($this->returnValue(['SubGroup1', 'SubGroup2']));
$user = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
@@ -321,6 +332,15 @@ class UsersControllerTest extends \Test\TestCase {
2323, 'bar@dummy.com'
));
+ $this->container['SubAdminFactory']
+ ->method('getSubAdminsOfGroups')
+ ->will($this->returnValueMap([
+ ['username' , ['SubGroup1', 'SubGroup2']],
+ ['foo', []],
+ ['admin', []],
+ ['bar', []],
+ ]));
+
$expectedResponse = new DataResponse(
[
0 => [
@@ -452,6 +472,23 @@ class UsersControllerTest extends \Test\TestCase {
404, 'admin@bar.com',
2323, 'bar@dummy.com'));
+ $this->container['SubAdminFactory']
+ ->expects($this->at(0))
+ ->method('getSubAdminsOfGroups')
+ ->with('foo')
+ ->will($this->returnValue([]));
+ $this->container['SubAdminFactory']
+ ->expects($this->at(1))
+ ->method('getSubAdminsOfGroups')
+ ->with('admin')
+ ->will($this->returnValue([]));
+ $this->container['SubAdminFactory']
+ ->expects($this->at(2))
+ ->method('getSubAdminsOfGroups')
+ ->with('bar')
+ ->will($this->returnValue([]));
+
+
$expectedResponse = new DataResponse(
array(
0 => array(
@@ -532,6 +569,12 @@ class UsersControllerTest extends \Test\TestCase {
->with('')
->will($this->returnValue([$user]));
+ $this->container['SubAdminFactory']
+ ->expects($this->once())
+ ->method('getSubAdminsOfGroups')
+ ->with('foo')
+ ->will($this->returnValue([]));
+
$expectedResponse = new DataResponse(
array(
0 => array(
@@ -591,6 +634,11 @@ class UsersControllerTest extends \Test\TestCase {
->method('createUser')
->will($this->onConsecutiveCalls($user));
+ $this->container['SubAdminFactory']
+ ->expects($this->once())
+ ->method('getSubAdminsOfGroups')
+ ->with('foo')
+ ->will($this->returnValue([]));
$expectedResponse = new DataResponse(
array(
@@ -613,11 +661,6 @@ class UsersControllerTest extends \Test\TestCase {
public function testCreateSuccessfulWithoutGroupSubAdmin() {
$this->container['IsAdmin'] = false;
- $this->container['SubAdminFactory']
- ->expects($this->once())
- ->method('getSubAdminsOfGroups')
- ->with('username')
- ->will($this->returnValue(['SubGroup1', 'SubGroup2']));
$user = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$user
@@ -671,6 +714,13 @@ class UsersControllerTest extends \Test\TestCase {
->with($user)
->will($this->onConsecutiveCalls(['SubGroup1', 'SubGroup2']));
+ $this->container['SubAdminFactory']
+ ->method('getSubAdminsOfGroups')
+ ->will($this->returnValueMap([
+ ['username', ['SubGroup1', 'SubGroup2']],
+ ['foo', []],
+ ]));
+
$expectedResponse = new DataResponse(
array(
'name' => 'foo',
@@ -740,6 +790,12 @@ class UsersControllerTest extends \Test\TestCase {
->with($user)
->will($this->onConsecutiveCalls(array('NewGroup', 'ExistingGroup')));
+ $this->container['SubAdminFactory']
+ ->expects($this->once())
+ ->method('getSubAdminsOfGroups')
+ ->with('foo')
+ ->will($this->returnValue([]));
+
$expectedResponse = new DataResponse(
array(
'name' => 'foo',
@@ -761,11 +817,6 @@ class UsersControllerTest extends \Test\TestCase {
public function testCreateSuccessfulWithGroupSubAdmin() {
$this->container['IsAdmin'] = false;
- $this->container['SubAdminFactory']
- ->expects($this->once())
- ->method('getSubAdminsOfGroups')
- ->with('username')
- ->will($this->returnValue(['SubGroup1', 'SubGroup2']));
$user = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$user
@@ -819,6 +870,13 @@ class UsersControllerTest extends \Test\TestCase {
->with($user)
->will($this->onConsecutiveCalls(['SubGroup1']));
+ $this->container['SubAdminFactory']
+ ->method('getSubAdminsOfGroups')
+ ->will($this->returnValueMap([
+ ['username', ['SubGroup1', 'SubGroup2']],
+ ['foo', []],
+ ]));
+
$expectedResponse = new DataResponse(
array(
'name' => 'foo',
@@ -1286,6 +1344,11 @@ class UsersControllerTest extends \Test\TestCase {
list($user, $expectedResult) = $this->mockUser();
+ $this->container['SubAdminFactory']
+ ->method('getSubAdminsOfGroups')
+ ->with($user->getUID())
+ ->will($this->returnValue([]));
+
$result = self::invokePrivate($this->container['UsersController'], 'formatUserForIndex', [$user]);
$this->assertEquals($expectedResult, $result);
}
@@ -1323,6 +1386,11 @@ class UsersControllerTest extends \Test\TestCase {
)
->will($this->returnValue('1'));
+ $this->container['SubAdminFactory']
+ ->method('getSubAdminsOfGroups')
+ ->with($user->getUID())
+ ->will($this->returnValue([]));
+
$result = self::invokePrivate($this->container['UsersController'], 'formatUserForIndex', [$user]);
$this->assertEquals($expectedResult, $result);
}
@@ -1341,6 +1409,11 @@ class UsersControllerTest extends \Test\TestCase {
$expectedResult['isRestoreDisabled'] = true;
+ $this->container['SubAdminFactory']
+ ->method('getSubAdminsOfGroups')
+ ->with($user->getUID())
+ ->will($this->returnValue([]));
+
$result = self::invokePrivate($this->container['UsersController'], 'formatUserForIndex', [$user]);
$this->assertEquals($expectedResult, $result);
}
@@ -1380,6 +1453,11 @@ class UsersControllerTest extends \Test\TestCase {
$expectedResult['isRestoreDisabled'] = true;
+ $this->container['SubAdminFactory']
+ ->method('getSubAdminsOfGroups')
+ ->with($user->getUID())
+ ->will($this->returnValue([]));
+
$result = self::invokePrivate($this->container['UsersController'], 'formatUserForIndex', [$user]);
$this->assertEquals($expectedResult, $result);
}
diff --git a/version.php b/version.php
index cc5a18b1cb3..008bb7dafc6 100644
--- a/version.php
+++ b/version.php
@@ -25,7 +25,7 @@
// We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades
// between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel
// when updating major/minor version number.
-$OC_Version = array(9, 0, 0, 0);
+$OC_Version = array(9, 0, 0, 1);
// The human readable string
$OC_VersionString = '9.0 pre alpha';