search display name instead of uid; fix key/value order for array access

This commit is contained in:
Björn Schießle 2013-01-28 15:58:40 +01:00
parent c00b66fe5b
commit 590c4aa710
2 changed files with 2 additions and 2 deletions

View file

@ -164,7 +164,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
$users = OC_User::getDisplayNames($_GET['search'], $limit, $offset);
}
$offset += $limit;
foreach ($users as $displayName => $uid) {
foreach ($users as $uid => $displayName) {
if ((!isset($_GET['itemShares']) || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]) || !in_array($uid, $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])) && $uid != OC_User::getUser()) {
$shareWith[] = array('label' => $displayName, 'value' => array('shareType' => OCP\Share::SHARE_TYPE_USER, 'shareWith' => $uid));
$count++;

View file

@ -155,7 +155,7 @@ class OC_User_Database extends OC_User_Backend {
*/
public function getDisplayNames($search = '', $limit = null, $offset = null) {
$displayNames = array();
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset);
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`displayname`) LIKE LOWER(?)', $limit, $offset);
$result = $query->execute(array($search.'%'));
$users = array();
while ($row = $result->fetchRow()) {