Move updateClientInfos functioon to Session_Logger

This commit is contained in:
Nicolas Le Goff
2013-08-22 10:51:45 +02:00
parent 8790399214
commit e07c57d409
8 changed files with 92 additions and 99 deletions

View File

@@ -1496,88 +1496,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this->_prefs[$prop];
}
public static function updateClientInfos(Application $app, $app_id)
{
if (!$app['authentication']->isAuthenticated()) {
return;
}
$session = $app['EM']->find('Entities\Session', $app['session']->get('session_id'));
if (!$session) {
throw new SessionNotFound('No session found');
}
if (!$session->hasModuleId($app_id)) {
$module = new \Entities\SessionModule();
$module->setModuleId($app_id);
$module->setSession($session);
$session->addModule($module);
$app['EM']->persist($module);
$app['EM']->persist($session);
$app['EM']->flush();
}
$usr_id = $app['authentication']->getUser()->get_id();
$user = User_Adapter::getInstance($usr_id, $app);
$appName = array(
'1' => 'Prod',
'2' => 'Client',
'3' => 'Admin',
'4' => 'Report',
'5' => 'Thesaurus',
'6' => 'Compare',
'7' => 'Validate',
'8' => 'Upload',
'9' => 'API'
);
if (isset($appName[$app_id])) {
$sbas_ids = array_keys($user->ACL()->get_granted_sbas());
foreach ($sbas_ids as $sbas_id) {
try {
$logger = $app['phraseanet.logger']($app['phraseanet.appbox']->get_databox($sbas_id));
$connbas = connection::getPDOConnection($app, $sbas_id);
$sql = 'SELECT appli FROM log WHERE id = :log_id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':log_id' => $logger->get_id()));
$row3 = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row3)
throw new Exception('no log');
$applis = unserialize($row3['appli']);
if (!in_array($app_id, $applis)) {
$applis[] = $app_id;
}
$sql = 'UPDATE log SET appli = :applis WHERE id = :log_id';
$params = array(
':applis' => serialize($applis)
, ':log_id' => $logger->get_id()
);
$stmt = $connbas->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
} catch (Exception $e) {
}
}
}
return;
}
public static function get_sys_admins(Application $app)
{
$sql = 'SELECT usr_id, usr_login FROM usr

View File

@@ -150,8 +150,6 @@ interface User_Interface
public function getPrefs($prop);
public static function updateClientInfos(Application $app, $app_id);
public static function get_sys_admins(Application $app);
public static function set_sys_admins(Application $app, $admins);