|
|
|
@ -195,11 +195,11 @@ class UserGroup extends Model |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param int $type |
|
|
|
|
* @param string $extraWhereCondition |
|
|
|
|
* |
|
|
|
|
* @return int |
|
|
|
|
*/ |
|
|
|
|
public function get_count() |
|
|
|
|
public function get_count($extraWhereCondition = '') |
|
|
|
|
{ |
|
|
|
|
$authorCondition = ''; |
|
|
|
|
|
|
|
|
@ -217,6 +217,7 @@ class UserGroup extends Model |
|
|
|
|
INNER JOIN $this->access_url_rel_usergroup a |
|
|
|
|
ON (u.id = a.usergroup_id) |
|
|
|
|
WHERE access_url_id = $urlId $authorCondition |
|
|
|
|
$extraWhereCondition |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
@ -230,6 +231,7 @@ class UserGroup extends Model |
|
|
|
|
FROM {$this->table} a |
|
|
|
|
WHERE 1 = 1 |
|
|
|
|
$authorCondition |
|
|
|
|
AND $extraWhereCondition |
|
|
|
|
"; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
if (Database::num_rows($result)) { |
|
|
|
@ -1112,45 +1114,43 @@ class UserGroup extends Model |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param int $sidx |
|
|
|
|
* @param int $sord |
|
|
|
|
* @param int $start |
|
|
|
|
* @param int $limit |
|
|
|
|
* @param int $sidx |
|
|
|
|
* @param int $sord |
|
|
|
|
* @param int $start |
|
|
|
|
* @param int $limit |
|
|
|
|
* @param string $extraWhereCondition |
|
|
|
|
* |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public function getUsergroupsPagination($sidx, $sord, $start, $limit) |
|
|
|
|
public function getUsergroupsPagination($sidx, $sord, $start, $limit, $extraWhereCondition = '') |
|
|
|
|
{ |
|
|
|
|
$sord = in_array(strtolower($sord), ['asc', 'desc']) ? $sord : 'desc'; |
|
|
|
|
|
|
|
|
|
$start = (int) $start; |
|
|
|
|
$limit = (int) $limit; |
|
|
|
|
|
|
|
|
|
$sqlFrom = "{$this->table} u "; |
|
|
|
|
$sqlWhere = '1 = 1 '; |
|
|
|
|
|
|
|
|
|
if ($this->getUseMultipleUrl()) { |
|
|
|
|
$urlId = api_get_current_access_url_id(); |
|
|
|
|
$from = $this->table." u |
|
|
|
|
INNER JOIN {$this->access_url_rel_usergroup} a |
|
|
|
|
ON (u.id = a.usergroup_id)"; |
|
|
|
|
$where = [' access_url_id = ?' => $urlId]; |
|
|
|
|
} else { |
|
|
|
|
$from = $this->table.' u '; |
|
|
|
|
$where = []; |
|
|
|
|
$sqlFrom .= " INNER JOIN {$this->access_url_rel_usergroup} a ON (u.id = a.usergroup_id) "; |
|
|
|
|
$sqlWhere .= " AND a.access_url_id = $urlId "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($this->allowTeachers()) { |
|
|
|
|
if (!api_is_platform_admin()) { |
|
|
|
|
$userId = api_get_user_id(); |
|
|
|
|
$where = [' author_id = ?' => $userId]; |
|
|
|
|
$sqlWhere .= " AND author_id = $userId "; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result = Database::select( |
|
|
|
|
'u.*', |
|
|
|
|
$from, |
|
|
|
|
[ |
|
|
|
|
'where' => $where, |
|
|
|
|
'order' => "name $sord", |
|
|
|
|
'LIMIT' => "$start , $limit", |
|
|
|
|
] |
|
|
|
|
if ($extraWhereCondition) { |
|
|
|
|
$sqlWhere .= " AND $extraWhereCondition "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result = Database::store_result( |
|
|
|
|
Database::query("SELECT u.* FROM $sqlFrom WHERE $sqlWhere ORDER BY name $sord LIMIT $start, $limit") |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$new_result = []; |
|
|
|
|