From d842567d2aed62939e1367cc98968c10f0226e41 Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Wed, 23 Jan 2013 15:12:18 +0000 Subject: [PATCH] =?UTF-8?q?Systeme=20de=20cache=20pour=20l'affichage=20des?= =?UTF-8?q?=20propri=C3=A9t=C3=A9s=20des=20membres.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Diminution du nombre de requetes (on passe de 2*nb_de_membres requetes à... une.) --- bureau/class/m_admin.php | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/bureau/class/m_admin.php b/bureau/class/m_admin.php index 1abf638e..715afb21 100644 --- a/bureau/class/m_admin.php +++ b/bureau/class/m_admin.php @@ -75,30 +75,32 @@ class m_admin { * table membres and local of the corresponding account. * Returns FALSE if an error occurs. */ - function get($uid) { - global $err,$db; + function get($uid,$recheck=false) { + global $err,$db,$lst_users_properties; // $err->log("admin","get",$uid); if (!$this->enabled) { $err->raise("admin",_("-- Only administrators can access this page! --")); 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()) { - $db->next_record(); - $c=$db->Record; - } else { + + if (!isset($lst_users_properties) || empty($lst_users_properties) || !is_array($lst_users_properties) || $recheck ) { + $lst_users_properties=array(); + $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) ;"); + 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")); return false; } - $db->query("SELECT * FROM local WHERE uid='$uid';"); - if ($db->num_rows()) { - $db->next_record(); - reset($db->Record); - while (list($key,$val)=each($db->Record)) { - $c[$key]=$val; - } - } - return $c; + + return $lst_users_properties[$uid]; }