mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
New method Api\Accounts::isHuge() is used to NOT query members and (not yet working) disable the column in group-list
This commit is contained in:
parent
fe1caad9be
commit
5b1fe16e9e
@ -437,8 +437,14 @@ class admin_ui
|
||||
|
||||
/**
|
||||
* Callback for the nextmatch to get groups
|
||||
*
|
||||
* Does NOT set members for huge installations, but return "is_huge" === true in $rows.
|
||||
*
|
||||
* @param array &$query
|
||||
* @param array|null &$rows on return rows plus boolean value for key "is_huge" === Accounts::isHuge()
|
||||
* @return int total number of rows
|
||||
*/
|
||||
public static function get_groups(&$query, &$rows)
|
||||
public static function get_groups(array &$query, array &$rows=null)
|
||||
{
|
||||
$groups = $GLOBALS['egw']->accounts->search(array(
|
||||
'type' => 'groups',
|
||||
@ -463,7 +469,8 @@ class admin_ui
|
||||
$apps[] = $app;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
$rows = [];
|
||||
$is_huge = $GLOBALS['egw']->accounts->isHuge();
|
||||
foreach($groups as &$group)
|
||||
{
|
||||
$run_rights = $GLOBALS['egw']->acl->get_user_applications($group['account_id'], false, false);
|
||||
@ -475,10 +482,14 @@ class admin_ui
|
||||
}
|
||||
}
|
||||
|
||||
$group['members'] = $GLOBALS['egw']->accounts->members($group['account_id'],true);
|
||||
// do NOT set members for huge installations, but return "is_huge" === true in $rows
|
||||
if (!$is_huge)
|
||||
{
|
||||
$group['members'] = $GLOBALS['egw']->accounts->members($group['account_id'],true);
|
||||
}
|
||||
$rows[] = $group;
|
||||
}
|
||||
|
||||
$rows['is_huge'] = $is_huge;
|
||||
return $GLOBALS['egw']->accounts->total;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@
|
||||
<columns>
|
||||
<column width="30%"/>
|
||||
<column width="15%"/>
|
||||
<column width="25%"/>
|
||||
<column width="25%" disabled="@is_huge"/>
|
||||
<column width="25%"/>
|
||||
</columns>
|
||||
<rows>
|
||||
|
@ -1513,6 +1513,43 @@ class Accounts
|
||||
Cache::setCache($this->config['install_id'], __CLASS__, 'account-'.$account_id, $account, self::READ_CACHE_TIMEOUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of accounts to consider an installation huge
|
||||
*/
|
||||
const HUGE_LIMIT = 500;
|
||||
|
||||
/**
|
||||
* Check if instance is huge, has more than self::HUGE_LIMIT=500 users
|
||||
*
|
||||
* Can be used to disable features not working well for a huge installation.
|
||||
*
|
||||
* @param int|null $set=null to set call with total number of accounts
|
||||
* @return bool
|
||||
*/
|
||||
public function isHuge(int $total=null)
|
||||
{
|
||||
return true;
|
||||
if (isset($total))
|
||||
{
|
||||
$is_huge = $total > self::HUGE_LIMIT;
|
||||
Cache::setInstance(__CLASS__, 'is_huge', $is_huge);
|
||||
return $is_huge;
|
||||
}
|
||||
return Cache::getInstance(__CLASS__, 'is_huge', function()
|
||||
{
|
||||
$save_total = $this->total; // save and restore current total, to not have an unwanted side effect
|
||||
$this->search([
|
||||
'type' => 'accounts',
|
||||
'start' => 0,
|
||||
'offset' => 1,
|
||||
'active' => false, // as this is set by admin_ui::get_users() and therefore we only return the cached result
|
||||
]);
|
||||
$total = $this->total;
|
||||
$this->total = $save_total;
|
||||
return $this->isHuge($total);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal functions not meant to use outside this class!!!
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user