mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-08 18:44:30 +00:00

Conflicts: lib/Alchemy/Phrasea/Controller/Prod/Push.php lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php lib/conf.d/migrations.yml Conflicts: lib/Alchemy/Phrasea/ACL/BasketACL.php lib/Alchemy/Phrasea/Authentication/Authenticator.php lib/Alchemy/Phrasea/Controller/Prod/Order.php lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php lib/Alchemy/Phrasea/Controller/Root/Session.php lib/Alchemy/Phrasea/Model/Entities/Basket.php lib/Alchemy/Phrasea/Model/Entities/BasketElement.php lib/Alchemy/Phrasea/Model/Entities/Feed.php lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php lib/Alchemy/Phrasea/Model/Entities/FtpExport.php lib/Alchemy/Phrasea/Model/Entities/Session.php lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php lib/Alchemy/Phrasea/Model/Entities/UsrList.php lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php lib/classes/API/V1/adapter.php templates/mobile/lightbox/sc_note.html.twig templates/web/admin/connected-users.html.twig templates/web/admin/publications/fiche.html.twig templates/web/lightbox/IE6/agreement_box.html.twig templates/web/lightbox/agreement_box.html.twig templates/web/lightbox/basket_content_report.html.twig templates/web/lightbox/sc_note.html.twig templates/web/prod/WorkZone/Browser/Basket.html.twig templates/web/prod/WorkZone/Browser/Results.html.twig templates/web/prod/WorkZone/Macros.html.twig templates/web/prod/actions/Feedback/List-Share.html.twig templates/web/prod/actions/Feedback/ListsMacros.html.twig templates/web/prod/orders/order_box.html.twig templates/web/prod/orders/order_item.html.twig templates/web/prod/upload/lazaret.html.twig tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php
129 lines
3.4 KiB
PHP
129 lines
3.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2014 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
use Alchemy\Phrasea\Application;
|
|
use Alchemy\Phrasea\Model\Entities\Session;
|
|
use Alchemy\Phrasea\Model\Entities\SessionModule;
|
|
|
|
class patch_380alpha11a implements patchInterface
|
|
{
|
|
/** @var string */
|
|
private $release = '3.8.0-alpha.11';
|
|
|
|
/** @var array */
|
|
private $concern = [base::APPLICATION_BOX];
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function get_release()
|
|
{
|
|
return $this->release;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function require_all_upgrades()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function concern()
|
|
{
|
|
return $this->concern;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getDoctrineMigrations()
|
|
{
|
|
return ['session'];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function apply(base $appbox, Application $app)
|
|
{
|
|
try {
|
|
$sql = 'SELECT usr_id, user_agent, ip, platform, browser, app,
|
|
browser_version, screen, token, nonce, lastaccess, created_on
|
|
FROM cache';
|
|
$stmt = $appbox->get_connection()->prepare($sql);
|
|
$stmt->execute();
|
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
$stmt->closeCursor();
|
|
} catch (\PDOException $e) {
|
|
// this may fail on oldest versions
|
|
return false;
|
|
}
|
|
|
|
foreach ($rs as $row) {
|
|
$created = $updated = null;
|
|
if ('0000-00-00 00:00:00' !== $row['created_on']) {
|
|
$created = \DateTime::createFromFormat('Y-m-d H:i:s', $row['created_on']);
|
|
}
|
|
if ('0000-00-00 00:00:00' !== $row['lastaccess']) {
|
|
$updated = \DateTime::createFromFormat('Y-m-d H:i:s', $row['lastaccess']);
|
|
}
|
|
|
|
$user = $app['manipulator.user']->getRepository()->find($row['usr_id']);
|
|
|
|
$session = new Session();
|
|
$session
|
|
->setUser($user)
|
|
->setUserAgent($row['user_agent'])
|
|
->setUpdated($updated)
|
|
->setToken($row['token'])
|
|
->setPlatform($row['platform'])
|
|
->setNonce($row['nonce'])
|
|
->setIpAddress($row['ip'])
|
|
->setCreated($created)
|
|
->setBrowserVersion($row['browser_version'])
|
|
->setBrowserName($row['browser']);
|
|
|
|
$sizes = explode ('x', $row['screen']);
|
|
|
|
if (2 === count($sizes)) {
|
|
$session
|
|
->setScreenWidth($sizes[0])
|
|
->setScreenHeight($sizes[1]);
|
|
}
|
|
|
|
if (false !== $apps = @unserialize($row['app'])) {
|
|
foreach ($apps as $appli) {
|
|
$module = new SessionModule();
|
|
$module
|
|
->setModuleId($appli)
|
|
->setCreated($created)
|
|
->setSession($session)
|
|
->setUpdated($updated);
|
|
|
|
$session->addModule($module);
|
|
|
|
$app['EM']->persist($module);
|
|
}
|
|
}
|
|
|
|
$app['EM']->persist($session);
|
|
}
|
|
|
|
$app['EM']->flush();
|
|
|
|
return true;
|
|
}
|
|
}
|