summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/group.php12
-rw-r--r--lib/private/group/backend.php22
-rw-r--r--lib/private/group/database.php25
-rw-r--r--lib/private/group/group.php6
-rw-r--r--lib/private/group/manager.php34
-rwxr-xr-xlib/private/preview.php2
-rw-r--r--lib/private/user/manager.php4
7 files changed, 40 insertions, 65 deletions
diff --git a/lib/private/group.php b/lib/private/group.php
index d9f430f833b..ea6384bae3e 100644
--- a/lib/private/group.php
+++ b/lib/private/group.php
@@ -274,17 +274,7 @@ class OC_Group {
* @returns array with display names (value) and user ids(key)
*/
public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
- $group = self::getManager()->get($gid);
- if ($group) {
- $users = $group->searchDisplayName($search, $limit, $offset);
- $displayNames = array();
- foreach ($users as $user) {
- $displayNames[$user->getUID()] = $user->getDisplayName();
- }
- return $displayNames;
- } else {
- return array();
- }
+ return self::getManager()->displayNamesInGroup($gid, $search, $limit, $offset);
}
/**
diff --git a/lib/private/group/backend.php b/lib/private/group/backend.php
index b0ed0d90d76..cc61fce1615 100644
--- a/lib/private/group/backend.php
+++ b/lib/private/group/backend.php
@@ -33,7 +33,7 @@ define('OC_GROUP_BACKEND_CREATE_GROUP', 0x00000001);
define('OC_GROUP_BACKEND_DELETE_GROUP', 0x00000010);
define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00000100);
define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00001000);
-define('OC_GROUP_BACKEND_GET_DISPLAYNAME', 0x00010000);
+define('OC_GROUP_BACKEND_GET_DISPLAYNAME', 0x00010000); //OBSOLETE
define('OC_GROUP_BACKEND_COUNT_USERS', 0x00100000);
/**
@@ -45,7 +45,6 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
OC_GROUP_BACKEND_DELETE_GROUP => 'deleteGroup',
OC_GROUP_BACKEND_ADD_TO_GROUP => 'addToGroup',
OC_GROUP_BACKEND_REMOVE_FROM_GOUP => 'removeFromGroup',
- OC_GROUP_BACKEND_GET_DISPLAYNAME => 'displayNamesInGroup',
OC_GROUP_BACKEND_COUNT_USERS => 'countUsersInGroup',
);
@@ -137,23 +136,4 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
return array();
}
-
- /**
- * @brief get a list of all display names in a group
- * @param string $gid
- * @param string $search
- * @param int $limit
- * @param int $offset
- * @return array with display names (value) and user ids (key)
- */
- public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
- $displayNames = array();
- $users = $this->usersInGroup($gid, $search, $limit, $offset);
- foreach ($users as $user) {
- $displayNames[$user] = $user;
- }
-
- return $displayNames;
- }
-
}
diff --git a/lib/private/group/database.php b/lib/private/group/database.php
index 3815dcff2e5..df0d84d0d2a 100644
--- a/lib/private/group/database.php
+++ b/lib/private/group/database.php
@@ -225,29 +225,4 @@ class OC_Group_Database extends OC_Group_Backend {
return $result->fetchOne();
}
- /**
- * @brief get a list of all display names in a group
- * @param string $gid
- * @param string $search
- * @param int $limit
- * @param int $offset
- * @return array with display names (value) and user ids (key)
- */
- public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
- $displayNames = array();
-
- $stmt = OC_DB::prepare('SELECT `*PREFIX*users`.`uid`, `*PREFIX*users`.`displayname`'
- .' FROM `*PREFIX*users`'
- .' INNER JOIN `*PREFIX*group_user` ON `*PREFIX*group_user`.`uid` = `*PREFIX*users`.`uid`'
- .' WHERE `gid` = ? AND `*PREFIX*group_user`.`uid` LIKE ?',
- $limit,
- $offset);
- $result = $stmt->execute(array($gid, $search.'%'));
- $users = array();
- while ($row = $result->fetchRow()) {
- $displayName = trim($row['displayname'], ' ');
- $displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;
- }
- return $displayNames;
- }
}
diff --git a/lib/private/group/group.php b/lib/private/group/group.php
index 3efbb6e7023..7593bb68d1a 100644
--- a/lib/private/group/group.php
+++ b/lib/private/group/group.php
@@ -212,11 +212,7 @@ class Group {
public function searchDisplayName($search, $limit = null, $offset = null) {
$users = array();
foreach ($this->backends as $backend) {
- if ($backend->implementsActions(OC_GROUP_BACKEND_GET_DISPLAYNAME)) {
- $userIds = array_keys($backend->displayNamesInGroup($this->gid, $search, $limit, $offset));
- } else {
- $userIds = $backend->usersInGroup($this->gid, $search, $limit, $offset);
- }
+ $userIds = $backend->usersInGroup($this->gid, $search, $limit, $offset);
$users = $this->getVerifiedUsers($userIds);
if (!is_null($limit) and $limit <= 0) {
return array_values($users);
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index f591bd32aba..d31225e3c2e 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -158,4 +158,38 @@ class Manager extends PublicEmitter {
}
return array_values($groups);
}
+
+ /**
+ * @brief get a list of all display names in a group
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with display names (value) and user ids (key)
+ */
+ public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
+ $group = $this->get($gid);
+ if(is_null($group)) {
+ return array();
+ }
+ // only user backends have the capability to do a complex search for users
+ $groupUsers = $group->searchUsers('', $limit, $offset);
+ $search = trim($search);
+ if(!empty($search)) {
+ //TODO: for OC 7 earliest: user backend should get a method to check selected users against a pattern
+ $filteredUsers = $this->userManager->search($search);
+ $testUsers = true;
+ } else {
+ $filteredUsers = array();
+ $testUsers = false;
+ }
+
+ $matchingUsers = array();
+ foreach($groupUsers as $user) {
+ if(!$testUsers || isset($filteredUsers[$user->getUID()])) {
+ $matchingUsers[$user->getUID()] = $user->getDisplayName();
+ }
+ }
+ return $matchingUsers;
+ }
}
diff --git a/lib/private/preview.php b/lib/private/preview.php
index 361073a0916..2964b83c508 100755
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -615,7 +615,7 @@ class Preview {
return;
}
- if ($newXSize < $x || $newYSize < $y) {
+ if (($newXSize < $x || $newYSize < $y) && $scalingUp) {
if ($newXSize > $x) {
$cropX = floor(($newXSize - $x) * 0.5);
$image->crop($cropX, 0, $x, $newYSize);
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php
index 14698452e88..6f6fd80a8ef 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/user/manager.php
@@ -174,12 +174,12 @@ class Manager extends PublicEmitter {
$backendUsers = $backend->getUsers($pattern, $limit, $offset);
if (is_array($backendUsers)) {
foreach ($backendUsers as $uid) {
- $users[] = $this->getUserObject($uid, $backend);
+ $users[$uid] = $this->getUserObject($uid, $backend);
}
}
}
- usort($users, function ($a, $b) {
+ uasort($users, function ($a, $b) {
/**
* @var \OC\User\User $a
* @var \OC\User\User $b