Systeme de cache pour l'affichage des propriétés des membres.
Diminution du nombre de requetes (on passe de 2*nb_de_membres requetes à... une.)
This commit is contained in:
parent
6a0d10f8a0
commit
d842567d2a
|
@ -75,30 +75,32 @@ class m_admin {
|
||||||
* table <code>membres</code> and <code>local</code> of the corresponding account.
|
* table <code>membres</code> and <code>local</code> of the corresponding account.
|
||||||
* Returns FALSE if an error occurs.
|
* Returns FALSE if an error occurs.
|
||||||
*/
|
*/
|
||||||
function get($uid) {
|
function get($uid,$recheck=false) {
|
||||||
global $err,$db;
|
global $err,$db,$lst_users_properties;
|
||||||
// $err->log("admin","get",$uid);
|
// $err->log("admin","get",$uid);
|
||||||
if (!$this->enabled) {
|
if (!$this->enabled) {
|
||||||
$err->raise("admin",_("-- Only administrators can access this page! --"));
|
$err->raise("admin",_("-- Only administrators can access this page! --"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("SELECT m.*, parent.login as parentlogin FROM membres as m LEFT JOIN membres as parent ON (parent.uid = m.creator) WHERE m.uid='$uid';");
|
|
||||||
if ($db->num_rows()) {
|
if (!isset($lst_users_properties) || empty($lst_users_properties) || !is_array($lst_users_properties) || $recheck ) {
|
||||||
$db->next_record();
|
$lst_users_properties=array();
|
||||||
$c=$db->Record;
|
$db->query("SELECT m.*, l.*, parent.login as parentlogin FROM membres as m LEFT JOIN membres as parent ON (parent.uid = m.creator) LEFT JOIN local as l ON (m.uid = l.uid) ;");
|
||||||
} else {
|
while ($db->next_record()) {
|
||||||
|
$lst_users_properties[$db->f('uid')]=$db->Record;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !isset($lst_users_properties[$uid]) ) {
|
||||||
|
if ( !$recheck ) {
|
||||||
|
// don't exist, but is not a forced check. Do a forced check
|
||||||
|
return $this->get($uid, true);
|
||||||
|
}
|
||||||
$err->raise("admin",_("Account not found"));
|
$err->raise("admin",_("Account not found"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("SELECT * FROM local WHERE uid='$uid';");
|
|
||||||
if ($db->num_rows()) {
|
return $lst_users_properties[$uid];
|
||||||
$db->next_record();
|
|
||||||
reset($db->Record);
|
|
||||||
while (list($key,$val)=each($db->Record)) {
|
|
||||||
$c[$key]=$val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue