]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use Group methods for searching, fixes #4201
authorArthur Schiwon <blizzz@owncloud.com>
Wed, 21 Aug 2013 11:15:31 +0000 (13:15 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Fri, 30 Aug 2013 10:37:46 +0000 (12:37 +0200)
core/ajax/share.php

index d3c6a8456a60422c204e7668e0d0c784d8a97d44..648f0a71bd44da7c93fbaccb88388c7db92aac99 100644 (file)
@@ -181,10 +181,10 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
 //                                             }
 //                                     }
 //                             }
+                               $groups = OC_Group::getGroups($_GET['search']);
                                if ($sharePolicy == 'groups_only') {
-                                       $groups = OC_Group::getUserGroups(OC_User::getUser());
-                               } else {
-                                       $groups = OC_Group::getGroups();
+                                       $usergroups = OC_Group::getUserGroups(OC_User::getUser());
+                                       $groups = array_intersect($groups, $usergroups);
                                }
                                $count = 0;
                                $users = array();
@@ -219,11 +219,10 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
                                
                                foreach ($groups as $group) {
                                        if ($count < 15) {
-                                               if (stripos($group, $_GET['search']) !== false
-                                                       && (!isset($_GET['itemShares'])
+                                               if (!isset($_GET['itemShares'])
                                                        || !isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP])
                                                        || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP])
-                                                       || !in_array($group, $_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]))) {
+                                                       || !in_array($group, $_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP])) {
                                                        $shareWith[] = array(
                                                                'label' => $group.' ('.$l->t('group').')',
                                                                'value' => array(