Merge pull request #9 from pvalsecc/master
Better getGroups implementation
This commit is contained in:
@@ -42,8 +42,9 @@ class OC_GROUP_SQL extends \OC_Group_Backend implements \OCP\GroupInterface
|
||||
if(empty($this -> settings['sql_group_table']))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
$rows = $this -> helper -> runQuery('getGroups', array(), false, true);
|
||||
}
|
||||
$search = "%".$search."%";
|
||||
$rows = $this -> helper -> runQuery('getGroups', array('search' => $search), false, true, array('limit' => $limit, 'offset' => $offset));
|
||||
if($rows === false)
|
||||
{
|
||||
return [];
|
||||
@@ -75,5 +76,20 @@ class OC_GROUP_SQL extends \OC_Group_Backend implements \OCP\GroupInterface
|
||||
}
|
||||
return $users;
|
||||
}
|
||||
|
||||
public function countUsersInGroup($gid, $search = '') {
|
||||
if(empty($this -> settings['sql_group_table']))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
$search = "%".$search."%";
|
||||
$count = $this -> helper -> runQuery('countUsersInGroup', array('gid' => $gid, 'search' => $search));
|
||||
if($count === false)
|
||||
{
|
||||
return 0;
|
||||
} else {
|
||||
return intval(reset($count));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -182,12 +182,16 @@ class Helper {
|
||||
break;
|
||||
|
||||
case 'getGroups':
|
||||
$query = "SELECT distinct ".$this->settings['col_group_name']." FROM ".$this->settings['sql_group_table'];
|
||||
$query = "SELECT distinct ".$this->settings['col_group_name']." FROM ".$this->settings['sql_group_table']." WHERE ".$this->settings['col_group_name']." LIKE :search";
|
||||
break;
|
||||
|
||||
case 'getGroupUsers':
|
||||
$query = "SELECT distinct ".$this->settings['col_group_username']." FROM ".$this->settings['sql_group_table']." WHERE ".$this->settings['col_group_name']." = :gid";
|
||||
break;
|
||||
|
||||
case 'countUsersInGroup':
|
||||
$query = "SELECT count(".$this->settings['col_group_username'].") FROM ".$this->settings['sql_group_table']." WHERE ".$this->settings['col_group_name']." = :gid AND ".$this->settings['col_group_username']." LIKE :search";
|
||||
break;
|
||||
}
|
||||
|
||||
if(isset($limits['limit']) && $limits['limit'] !== null)
|
||||
|
||||
@@ -404,7 +404,7 @@ class OC_USER_SQL extends \OC_User_Backend implements \OCP\IUserBackend, \OCP\Us
|
||||
}
|
||||
else
|
||||
{
|
||||
$search = "%".$this -> doUserDomainMapping("")."%";
|
||||
$search = "%".$this -> doUserDomainMapping("")."%";
|
||||
}
|
||||
|
||||
$rows = $this -> helper -> runQuery('getUsers', array('search' => $search), false, true, array('limit' => $limit, 'offset' => $offset));
|
||||
|
||||
Reference in New Issue
Block a user