Ich würde mich über Tests und Feedback freuen, ob man das zum Einbau vorschlagen sollte.
Ersetzt wird die Funktion auth_loglogin in conlib/local.php.
Alter Code (aus V4.6.15-Beta):
Code: Alles auswählen
function auth_loglogin($uid)
{
global $cfg, $client, $lang, $auth, $sess, $saveLoginTime;
$perm = new Contenido_Perm;
$storeLoginTime = "true";
$lastentry = $this->db->nextid($cfg["tab"]["actionlog"]);
$timestamp = date("Y-m-d H:i:s");
$idcatart = "0";
/* Extract clients */
$sql = "SELECT idclient FROM ".$cfg["tab"]["clients"]." ORDER BY idclient ASC";
$this->db->query($sql);
$clients = array();
while ($this->db->next_record())
{
array_push ($clients, $this->db->f("idclient"));
}
$found = 0;
foreach ($clients as $key=>$value)
{
/* Extract languages */
$sql = "SELECT idlang FROM ".$cfg["tab"]["clients_lang"]." WHERE idclient = '".$value."' ORDER BY idlang";
$this->db->query($sql);
while ($this->db->next_record())
{
$qlang = $this->db->f("idlang");
if ($found != 1)
{
$client = $value;
}
if ($perm->have_perm_client_lang($value, $qlang) && $found == 0)
{
$client = $value;
$lang = $qlang;
$found = 1;
}
}
}
if (isset($idcat) && isset($idart))
{
$sql = "SELECT idcatart
FROM
". $cfg["tab"]["cat_art"] ."
WHERE
idcat = $idcat AND
idart = $idart";
$this->db->query($sql);
$this->db->next_record();
$idcatart = $this->db->f("idcatart");
}
if (!is_numeric($client)) { return; }
if (!is_numeric($lang)) { return; }
$idaction = $perm->getIDForAction("login");
$sql = "INSERT INTO
". $cfg["tab"]["actionlog"]."
SET
idlog = $lastentry,
user_id = '" . $uid . "',
idclient = $client,
idlang = $lang,
idaction = $idaction,
idcatart = $idcatart,
logtimestamp = '$timestamp'";
$this->db->query($sql);
$sess->register("saveLoginTime");
$saveLoginTime = true;
}
Code: Alles auswählen
function auth_loglogin($uid)
{
global $cfg, $client, $lang, $auth, $sess, $saveLoginTime;
$perm = new Contenido_Perm;
$storeLoginTime = "true";
$lastentry = $this->db->nextid($cfg["tab"]["actionlog"]);
$timestamp = date("Y-m-d H:i:s");
$idcatart = "0";
/* Extract clients */
$bFound = false;
// Get user settings for default client
$sql = "SELECT value FROM ".$cfg["tab"]["user_prop"]." WHERE type = 'backend' AND ".
"name = 'default_idclient' AND user_id = '".$uid."'";
$this->db->query($sql);
if ($this->db->next_record())
{
$iTmpClient = $this->db->f("value");
if (is_numeric($iTmpClient))
{
// Check, if current user have right to access a language of the client
$sql = "SELECT tblClientLangs.idlang FROM ".
$cfg["tab"]["clients"]." AS tblClients, ".$cfg["tab"]["clients_lang"]." AS tblClientLangs ".
"WHERE tblClients.idclient = tblClientLangs.idclient AND tblClients.idclient = '".$iTmpClient."' ORDER BY idlang ASC";
$this->db->query($sql);
while ($this->db->next_record() && !$bFound)
{
$iTmpLang = $this->db->f("idlang");
if ($perm->have_perm_client_lang($iTmpClient, $iTmpLang))
{
$client = $iTmpClient;
$lang = $iTmpLang;
$bFound = true;
}
}
}
}
if (!$bFound)
{
// No default client specified for the user, find the first accessible client and language for the user
// All the needed information should be available in clients_lang - but the previous code was designed with a
// reference to the clients table. Maybe fail-safe technology, who knows...
$sql = "SELECT tblClientLangs.idclient, tblClientLangs.idlang FROM ".
$cfg["tab"]["clients"]." AS tblClients, ".$cfg["tab"]["clients_lang"]." AS tblClientLangs ".
"WHERE tblClients.idclient = tblClientsLang.idclient ORDER BY idclient ASC, idlang ASC";
$this->db->query($sql);
while ($this->db->next_record() && !$bFound)
{
$iTmpClient = $this->db->f("idclient");
$iTmpLang = $this->db->f("idlang");
if ($perm->have_perm_client_lang($iTmpClient, $iTmpLang))
{
$client = $iTmpClient;
$lang = $iTmpLang;
$bFound = true;
}
}
}
if (isset($idcat) && isset($idart))
{
$sql = "SELECT idcatart
FROM
". $cfg["tab"]["cat_art"] ."
WHERE
idcat = $idcat AND
idart = $idart";
$this->db->query($sql);
$this->db->next_record();
$idcatart = $this->db->f("idcatart");
}
if (!is_numeric($client)) { return; }
if (!is_numeric($lang)) { return; }
$idaction = $perm->getIDForAction("login");
$sql = "INSERT INTO
". $cfg["tab"]["actionlog"]."
SET
idlog = $lastentry,
user_id = '" . $uid . "',
idclient = $client,
idlang = $lang,
idaction = $idaction,
idcatart = $idcatart,
logtimestamp = '$timestamp'";
$this->db->query($sql);
$sess->register("saveLoginTime");
$saveLoginTime = true;
}
Area/Type: backend
Eigenschaft: default_idclient
Wert: ID des Standard-Clients
Haken: Aus Performance-Gründen wird nur die user_prop-Tabelle überprüft, Gruppen-Einstellungen werden ignoriert.
Gruß
HerrB