mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Merge branch 'replace_users' of https://github.com/nlegoff/Phraseanet into nlegoff-replace_users
Conflicts: lib/classes/ACL.php lib/classes/User/Adapter.php lib/classes/eventsmanager/notify/autoregister.php lib/classes/eventsmanager/notify/order.php lib/classes/eventsmanager/notify/orderdeliver.php lib/classes/eventsmanager/notify/ordernotdelivered.php lib/classes/eventsmanager/notify/push.php lib/classes/eventsmanager/notify/register.php lib/classes/eventsmanager/notify/validate.php lib/classes/eventsmanager/notify/validationdone.php lib/classes/eventsmanager/notify/validationreminder.php lib/classes/module/report/add.php lib/classes/module/report/edit.php lib/classes/module/report/push.php lib/classes/module/report/sent.php lib/classes/module/report/validate.php lib/classes/record/preview.php
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Doctrine\ORM\Query;
|
||||
|
||||
class patch_320alpha2a implements patchInterface
|
||||
{
|
||||
@@ -56,20 +57,22 @@ class patch_320alpha2a implements patchInterface
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
$sql = 'SELECT * FROM usr WHERE nonce IS NULL';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
$dql = 'SELECT u FROM Phraseanet:User u WHERE u.nonce IS NULL';
|
||||
$q = $app['EM']->createQuery($dql);
|
||||
$q->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
|
||||
$users = $q->getResult();
|
||||
|
||||
$sql = 'UPDATE usr SET nonce = :nonce WHERE usr_id = :usr_id';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
foreach ($rs as $row) {
|
||||
$nonce = random::generatePassword(16);
|
||||
$params = [':usr_id' => $row['usr_id'], ':nonce' => $nonce];
|
||||
$stmt->execute($params);
|
||||
$n = 0;
|
||||
foreach ($users as $user) {
|
||||
$user->setNonce(random::generatePassword(16));
|
||||
$app['EM']->persist($user);
|
||||
$n++;
|
||||
if ($n %100 === 0) {
|
||||
$app['EM']->flush();
|
||||
}
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
$app['EM']->flush();
|
||||
|
||||
$sql = 'SELECT task_id, `class` FROM task2';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
|
@@ -97,7 +97,6 @@ class patch_320alpha4a implements patchInterface
|
||||
$xp_struct = $databox->get_xpath_structure();
|
||||
|
||||
foreach ($sxe->description->children() as $fname => $field) {
|
||||
|
||||
$src = trim(isset($field['src']) ? $field['src'] : '');
|
||||
if (array_key_exists($src, $phrasea_maps)) {
|
||||
$src = $phrasea_maps[$src];
|
||||
|
@@ -17,7 +17,7 @@ use Alchemy\Phrasea\Model\Entities\FeedPublisher;
|
||||
use Gedmo\Timestampable\TimestampableListener;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class patch_320alpha4b implements patchInterface
|
||||
class patch_320alpha4b extends patchAbstract
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.2.0-alpha.4';
|
||||
@@ -38,7 +38,7 @@ class patch_320alpha4b implements patchInterface
|
||||
*/
|
||||
public function getDoctrineMigrations()
|
||||
{
|
||||
return ['feed'];
|
||||
return ['user', 'feed'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@ class patch_320alpha4b implements patchInterface
|
||||
*/
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,8 +62,6 @@ class patch_320alpha4b implements patchInterface
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
$feeds = [];
|
||||
|
||||
try {
|
||||
$sql = 'ALTER TABLE `ssel` ADD `migrated` INT NOT NULL DEFAULT "0"';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
@@ -88,8 +86,9 @@ class patch_320alpha4b implements patchInterface
|
||||
|
||||
$app['EM']->getEventManager()->removeEventSubscriber(new TimestampableListener());
|
||||
foreach ($rs as $row) {
|
||||
$user = User_Adapter::getInstance($row['usr_id'], $app);
|
||||
|
||||
if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) {
|
||||
continue;
|
||||
}
|
||||
$feed = $this->get_feed($appbox, $user, $row['pub_restrict'], $row['homelink'], $app);
|
||||
|
||||
if (! $feed instanceof Feed) {
|
||||
@@ -99,8 +98,8 @@ class patch_320alpha4b implements patchInterface
|
||||
$publishers = $feed->getPublishers();
|
||||
|
||||
$entry = new FeedEntry();
|
||||
$entry->setAuthorEmail($user->get_email());
|
||||
$entry->setAuthorName($user->get_display_name());
|
||||
$entry->setAuthorEmail($user->getEmail());
|
||||
$entry->setAuthorName($user->getDisplayName());
|
||||
$entry->setFeed($feed);
|
||||
$entry->setPublisher($publishers->first());
|
||||
$entry->setTitle($row['name']);
|
||||
@@ -175,9 +174,9 @@ class patch_320alpha4b implements patchInterface
|
||||
}
|
||||
protected static $feeds = [];
|
||||
|
||||
protected function get_feed(appbox $appbox, User_Adapter $user, $pub_restrict, $homelink, Application $app)
|
||||
protected function get_feed(appbox $appbox, User $user, $pub_restrict, $homelink, Application $app)
|
||||
{
|
||||
$user_key = 'user_' . $user->get_id();
|
||||
$user_key = 'user_' . $user->getId();
|
||||
if ($homelink == '1') {
|
||||
$feed_key = 'feed_homelink';
|
||||
} elseif ($pub_restrict == '1') {
|
||||
@@ -188,11 +187,11 @@ class patch_320alpha4b implements patchInterface
|
||||
|
||||
if ( ! array_key_exists($user_key, self::$feeds) || ! isset(self::$feeds[$user_key][$feed_key])) {
|
||||
if ($homelink == '1')
|
||||
$title = $user->get_display_name() . ' - ' . 'homelink Feed';
|
||||
$title = $user->getDisplayName() . ' - ' . 'homelink Feed';
|
||||
elseif ($pub_restrict == '1')
|
||||
$title = $user->get_display_name() . ' - ' . 'private Feed';
|
||||
$title = $user->getDisplayName() . ' - ' . 'private Feed';
|
||||
else
|
||||
$title = $user->get_display_name() . ' - ' . 'public Feed';
|
||||
$title = $user->getDisplayName() . ' - ' . 'public Feed';
|
||||
|
||||
$feed = new Feed();
|
||||
$publisher = new FeedPublisher();
|
||||
@@ -201,7 +200,7 @@ class patch_320alpha4b implements patchInterface
|
||||
$feed->addPublisher($publisher);
|
||||
$publisher->setFeed($feed);
|
||||
$publisher->setOwner(true);
|
||||
$publisher->setUsrId($user->get_id());
|
||||
$publisher->setUser($user);
|
||||
|
||||
if ($homelink) {
|
||||
$feed->setPublic(true);
|
||||
|
@@ -214,7 +214,7 @@ class patch_360alpha1a implements patchInterface
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'SELECT usr_id, basket_id, p.id as participant_id
|
||||
$sql = 'SELECT user_id, basket_id, p.id as participant_id
|
||||
FROM ValidationParticipants p, ValidationSessions s
|
||||
WHERE p.ValidationSession_Id = s.id';
|
||||
|
||||
@@ -236,7 +236,7 @@ class patch_360alpha1a implements patchInterface
|
||||
$params = [
|
||||
':participant_id' => $row['participant_id'],
|
||||
':basket_id' => $row['basket_id'],
|
||||
':usr_id' => $row['usr_id'],
|
||||
':usr_id' => $row['user_id'],
|
||||
];
|
||||
$stmt->execute($params);
|
||||
}
|
||||
|
@@ -56,13 +56,7 @@ class patch_360alpha2a implements patchInterface
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
|
||||
$sql = 'UPDATE usr SET usr_mail = NULL
|
||||
WHERE usr_mail IS NOT NULL
|
||||
AND usr_login LIKE "(#deleted%"';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
$app['EM']->getConnection()->executeUpdate('UPDATE Users u SET u.email = NULL WHERE u.email IS NOT NULL AND u.deleted = 1');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -68,7 +68,6 @@ class patch_370alpha4a implements patchInterface
|
||||
$tagBasename = new \Alchemy\Phrasea\Metadata\Tag\TfBasename();
|
||||
|
||||
foreach ($rs as $row) {
|
||||
|
||||
if (strpos(strtolower($row['src']), 'tf-parentdir') !== false) {
|
||||
$update[] = ['id' => $row['id'], 'src' => $tagDirname->getTagname()];
|
||||
}
|
||||
|
@@ -56,7 +56,6 @@ class patch_370alpha5a implements patchInterface
|
||||
*/
|
||||
public function apply(base $databox, Application $app)
|
||||
{
|
||||
|
||||
$sql = 'SELECT id, src FROM metadatas_structure';
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
@@ -76,13 +76,10 @@ class patch_370alpha6a implements patchInterface
|
||||
$subdefgroups = $databox->get_subdef_structure();
|
||||
|
||||
foreach ($subdefgroups as $groupname => $subdefs) {
|
||||
|
||||
foreach ($subdefs as $name => $subdef) {
|
||||
|
||||
$this->addScreenDeviceOption($subdefgroups, $subdef, $groupname);
|
||||
|
||||
if (in_array($name, ['preview', 'thumbnail'])) {
|
||||
|
||||
if ($name == 'thumbnail' || $subdef->getSubdefType()->getType() != \Alchemy\Phrasea\Media\Subdef\Subdef::TYPE_VIDEO) {
|
||||
$this->addMobileSubdefImage($subdefgroups, $subdef, $groupname);
|
||||
} else {
|
||||
|
@@ -15,7 +15,7 @@ use Alchemy\Phrasea\Model\Entities\LazaretSession;
|
||||
use MediaAlchemyst\Exception\ExceptionInterface as MediaAlchemystException;
|
||||
use MediaAlchemyst\Specification\Image as ImageSpec;
|
||||
|
||||
class patch_370alpha7a implements patchInterface
|
||||
class patch_370alpha7a extends patchAbstract
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.7.0-alpha.7';
|
||||
@@ -36,7 +36,7 @@ class patch_370alpha7a implements patchInterface
|
||||
*/
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ class patch_370alpha7a implements patchInterface
|
||||
*/
|
||||
public function getDoctrineMigrations()
|
||||
{
|
||||
return ['lazaret'];
|
||||
return ['user', 'lazaret'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,11 +87,12 @@ class patch_370alpha7a implements patchInterface
|
||||
$i = 0;
|
||||
|
||||
foreach ($rs as $row) {
|
||||
|
||||
$filePath = $app['root.path'] . '/tmp/lazaret/' . $row['filepath'];
|
||||
if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
|
||||
$spec = new ImageSpec();
|
||||
|
||||
$spec->setResizeMode(ImageSpec::RESIZE_MODE_INBOUND_FIXEDRATIO);
|
||||
@@ -112,7 +113,7 @@ class patch_370alpha7a implements patchInterface
|
||||
$borderFile = new \Alchemy\Phrasea\Border\File($app, $media, $collection);
|
||||
|
||||
$lazaretSession = new LazaretSession();
|
||||
$lazaretSession->setUsrId($row['usr_id']);
|
||||
$lazaretSession->setUser($user);
|
||||
|
||||
$lazaretFile = new LazaretFile();
|
||||
$lazaretFile->setBaseId($row['base_id']);
|
||||
|
@@ -13,7 +13,7 @@ use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Model\Entities\Session;
|
||||
use Alchemy\Phrasea\Model\Entities\SessionModule;
|
||||
|
||||
class patch_380alpha11a implements patchInterface
|
||||
class patch_380alpha11a extends patchAbstract
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.8.0-alpha.11';
|
||||
@@ -50,7 +50,7 @@ class patch_380alpha11a implements patchInterface
|
||||
*/
|
||||
public function getDoctrineMigrations()
|
||||
{
|
||||
return ['session'];
|
||||
return ['user', 'session'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,6 +72,10 @@ class patch_380alpha11a implements patchInterface
|
||||
}
|
||||
|
||||
foreach ($rs as $row) {
|
||||
if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$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']);
|
||||
@@ -82,7 +86,7 @@ class patch_380alpha11a implements patchInterface
|
||||
|
||||
$session = new Session();
|
||||
$session
|
||||
->setUsrId($row['usr_id'])
|
||||
->setUser($user)
|
||||
->setUserAgent($row['user_agent'])
|
||||
->setUpdated($updated)
|
||||
->setToken($row['token'])
|
||||
|
@@ -59,7 +59,7 @@ class patch_381alpha3a implements patchInterface
|
||||
$propSql = $propArgs = [];
|
||||
$n = 0;
|
||||
|
||||
foreach (\User_Adapter::$def_values as $prop => $value) {
|
||||
foreach ($app['settings']->getUsersSettings() as $prop => $value) {
|
||||
if ('start_page_query' === $prop) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ class patch_383alpha1a implements patchInterface
|
||||
}
|
||||
|
||||
// Remove deleted users sessions
|
||||
$sql = 'SELECT s.id FROM `Sessions` s, usr u WHERE u.usr_login LIKE "(#deleted%" AND u.usr_id = s.usr_id';
|
||||
$sql = 'SELECT s.id FROM `Sessions` s INNER JOIN Users u ON (u.id = s.user_id) WHERE u.deleted = 1';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
@@ -10,8 +10,9 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
|
||||
class patch_383alpha2a implements patchInterface
|
||||
class patch_383alpha2a extends patchAbstract
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.8.3-alpha.2';
|
||||
@@ -57,15 +58,21 @@ class patch_383alpha2a implements patchInterface
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
// Clean validation sessions where initiator_id does not exist anymore
|
||||
$sql = 'SELECT DISTINCT(v.id) AS validation_session_id FROM `ValidationSessions` v LEFT JOIN usr u ON (v.initiator_id = u.usr_id) WHERE u.usr_id IS NULL';
|
||||
$sql = 'SELECT DISTINCT(v.id) AS validation_session_id FROM `ValidationSessions` v LEFT JOIN Users u ON (v.initiator_id = u.id) WHERE u.id IS NULL';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if (null !== $vsession = $app['EM']->find('Phraseanet:ValidationSession', $row['validation_session_id'])) {
|
||||
try {
|
||||
$vsession = $app['EM']->createQuery('SELECT PARTIAL s.{id} FROM Phraseanet:ValidationSession s WHERE s.id = :id')
|
||||
->setParameters(['id' => $row['validation_session_id']])
|
||||
->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true)
|
||||
->getSingleResult();
|
||||
$app['EM']->remove($vsession);
|
||||
} catch (NoResultException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,105 +0,0 @@
|
||||
<?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 Doctrine\ORM\Query\ResultSetMapping;
|
||||
|
||||
class patch_383alpha4a implements patchInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.8.3-alpha.4';
|
||||
|
||||
/** @var array */
|
||||
private $concern = [base::APPLICATION_BOX];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDoctrineMigrations()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
$em = $app['EM'];
|
||||
$mappingFieldType = $mappingFieldResult = new ResultSetMapping();
|
||||
|
||||
$rs = $em->createNativeQuery(
|
||||
"SHOW FIELDS FROM usr WHERE Field = 'usr_login';",
|
||||
$mappingFieldType->addScalarResult('Type', 'Type')
|
||||
)->getSingleResult();
|
||||
|
||||
if (0 !== strpos(strtolower($rs['Type']), 'varbinary')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// As 'usr_login' field type is varbinary it can contain any charset (utf8 or latin1).
|
||||
// Compare usr_login to usr_login converted to utf8>utf32>utf8
|
||||
// will detect broken char for latin1 encoded string.
|
||||
// Then detected 'usr_login' fields must be converted from latin1 to utf8.
|
||||
$rs = $em->createNativeQuery(
|
||||
'SELECT t.usr_id, t.login_utf8 FROM (
|
||||
SELECT usr_id,
|
||||
usr_login AS login_unknown_charset,
|
||||
CONVERT(CAST(usr_login AS CHAR CHARACTER SET latin1) USING utf8) AS login_utf8,
|
||||
CONVERT(CONVERT(CAST(usr_login AS CHAR CHARACTER SET utf8) USING utf32) USING utf8) AS login_utf8_utf32_utf8
|
||||
FROM usr
|
||||
) AS t
|
||||
WHERE t.login_utf8_utf32_utf8 != t.login_unknown_charset',
|
||||
$mappingFieldResult->addScalarResult('usr_id', 'usr_id')->addScalarResult('login_utf8', 'login_utf8')
|
||||
)->getResult();
|
||||
|
||||
foreach ($rs as $row) {
|
||||
$em->getConnection()->executeQuery(sprintf('UPDATE usr SET usr_login="%s" WHERE usr_id=%d', $row['login_utf8'], $row['usr_id']));
|
||||
}
|
||||
|
||||
foreach ([
|
||||
// drop index
|
||||
"ALTER TABLE usr DROP INDEX usr_login;",
|
||||
// change field type
|
||||
"ALTER TABLE usr MODIFY usr_login VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_bin;",
|
||||
// recreate index
|
||||
"CREATE UNIQUE INDEX usr_login ON usr (usr_login);"
|
||||
] as $sql) {
|
||||
$em->getConnection()->executeQuery($sql);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -10,9 +10,12 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Model\Entities\FtpCredential;
|
||||
use Alchemy\Phrasea\Model\Entities\Order;
|
||||
use Alchemy\Phrasea\Model\Entities\OrderElement;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use Gedmo\Timestampable\TimestampableListener;
|
||||
|
||||
class patch_390alpha1a implements patchInterface
|
||||
class patch_390alpha1a extends patchAbstract
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0-alpha.1';
|
||||
@@ -49,7 +52,7 @@ class patch_390alpha1a implements patchInterface
|
||||
*/
|
||||
public function getDoctrineMigrations()
|
||||
{
|
||||
return ['ftp-credential'];
|
||||
return ['user', 'order'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,10 +60,18 @@ class patch_390alpha1a implements patchInterface
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
$sql = 'DELETE FROM Orders';
|
||||
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'DELETE FROM OrderElements';
|
||||
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$conn = $app['phraseanet.appbox']->get_connection();
|
||||
$sql = 'SELECT usr_id, activeFTP, addrFTP, loginFTP,
|
||||
retryFTP, passifFTP, pwdFTP, destFTP, prefixFTPfolder
|
||||
FROM usr';
|
||||
$sql = 'SELECT id, usr_id, created_on, `usage`, deadline, ssel_id FROM `order`';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
@@ -68,22 +79,61 @@ class patch_390alpha1a implements patchInterface
|
||||
|
||||
$n = 0;
|
||||
$em = $app['EM'];
|
||||
$em->getEventManager()->removeEventSubscriber(new TimestampableListener());
|
||||
|
||||
foreach ($rs as $row) {
|
||||
$credential = new FtpCredential();
|
||||
$credential->setActive($row['activeFTP']);
|
||||
$credential->setAddress($row['addrFTP']);
|
||||
$credential->setLogin($row['loginFTP']);
|
||||
$credential->setMaxRetry((Integer) $row['retryFTP']);
|
||||
$credential->setPassive($row['passifFTP']);
|
||||
$credential->setPassword($row['pwdFTP']);
|
||||
$credential->setReceptionFolder($row['destFTP']);
|
||||
$credential->setRepositoryPrefixName($row['prefixFTPfolder']);
|
||||
$credential->setUsrId($row['usr_id']);
|
||||
$sql = 'SELECT count(id) as todo
|
||||
FROM order_elements
|
||||
WHERE deny = NULL
|
||||
AND order_id = :id';
|
||||
|
||||
$em->persist($credential);
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute([':id' => $row['id']]);
|
||||
$todo = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$n++;
|
||||
$user = $this->loadUser($app['EM'], $row['usr_id']);
|
||||
|
||||
try {
|
||||
$basket = $app['EM']->createQuery('SELECT PARTIAL b.{id} FROM Phraseanet:Basket b WHERE b.id = :id')
|
||||
->setParameters(['id' => $row['ssel_id']])
|
||||
->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true)
|
||||
->getSingleResult();
|
||||
} catch (NoResultException $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$order = new Order();
|
||||
$order->setUser($user)
|
||||
->setTodo($todo['todo'])
|
||||
->setOrderUsage($row['usage'])
|
||||
->setDeadline(new \DateTime($row['deadline']))
|
||||
->setCreatedOn(new \DateTime($row['created_on']))
|
||||
->setBasket($basket);
|
||||
|
||||
$em->persist($order);
|
||||
|
||||
$sql = 'SELECT base_id, record_id, order_master_id, deny
|
||||
FROM order_elements
|
||||
WHERE order_id = :id';
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute([':id' => $row['id']]);
|
||||
$elements = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$orderElement = new OrderElement();
|
||||
$user = $this->loadUser($app['EM'], $row['usr_id']);
|
||||
$orderElement->setBaseId($element['base_id'])
|
||||
->setDeny($element['deny'] === null ? null : (Boolean) $element['deny'])
|
||||
->setOrder($order)
|
||||
->setOrderMaster($user)
|
||||
->setRecordId($element['record_id']);
|
||||
|
||||
$order->addElement($orderElement);
|
||||
$em->persist($orderElement);
|
||||
}
|
||||
|
||||
if ($n % 100 === 0) {
|
||||
$em->flush();
|
||||
@@ -94,6 +144,8 @@ class patch_390alpha1a implements patchInterface
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
|
||||
$em->getEventManager()->addEventSubscriber(new TimestampableListener());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,139 +0,0 @@
|
||||
<?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\Order;
|
||||
use Alchemy\Phrasea\Model\Entities\OrderElement;
|
||||
use Gedmo\Timestampable\TimestampableListener;
|
||||
|
||||
class patch_390alpha1b implements patchInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0-alpha.1';
|
||||
|
||||
/** @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 ['order'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
$sql = 'DELETE FROM Orders';
|
||||
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'DELETE FROM OrderElements';
|
||||
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$conn = $app['phraseanet.appbox']->get_connection();
|
||||
$sql = 'SELECT id, usr_id, created_on, `usage`, deadline, ssel_id FROM `order`';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$n = 0;
|
||||
$em = $app['EM'];
|
||||
$em->getEventManager()->removeEventSubscriber(new TimestampableListener());
|
||||
$basketRepository = $em->getRepository('Phraseanet:Basket');
|
||||
|
||||
foreach ($rs as $row) {
|
||||
$sql = 'SELECT count(id) as todo
|
||||
FROM order_elements
|
||||
WHERE deny = NULL
|
||||
AND order_id = :id';
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute([':id' => $row['id']]);
|
||||
$todo = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$order = new Order();
|
||||
$order->setUsrId($row['usr_id'])
|
||||
->setTodo($todo['todo'])
|
||||
->setOrderUsage($row['usage'])
|
||||
->setDeadline(new \DateTime($row['deadline']))
|
||||
->setCreatedOn(new \DateTime($row['created_on']))
|
||||
->setBasket($basketRepository->find($row['ssel_id']));
|
||||
|
||||
$em->persist($order);
|
||||
|
||||
$sql = 'SELECT base_id, record_id, order_master_id, deny
|
||||
FROM order_elements
|
||||
WHERE order_id = :id';
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute([':id' => $row['id']]);
|
||||
$elements = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$orderElement = new OrderElement();
|
||||
$orderElement->setBaseId($element['base_id'])
|
||||
->setDeny($element['deny'] === null ? null : (Boolean) $element['deny'])
|
||||
->setOrder($order)
|
||||
->setOrderMasterId($element['order_master_id'])
|
||||
->setRecordId($element['record_id']);
|
||||
|
||||
$order->addElement($orderElement);
|
||||
$em->persist($orderElement);
|
||||
}
|
||||
|
||||
if ($n % 100 === 0) {
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
}
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
|
||||
$em->getEventManager()->addEventSubscriber(new TimestampableListener());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,234 +0,0 @@
|
||||
<?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 Doctrine\ORM\EntityManager;
|
||||
use Alchemy\Phrasea\Model\Entities\User;
|
||||
use Gedmo\Timestampable\TimestampableListener;
|
||||
|
||||
class patch_390alpha2a implements patchInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0-alpha.2';
|
||||
|
||||
/** @var array */
|
||||
private $concern = [base::APPLICATION_BOX];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_release()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function concern()
|
||||
{
|
||||
return $this->concern;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDoctrineMigrations()
|
||||
{
|
||||
return ['user'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
$sql = 'DELETE FROM Users';
|
||||
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$conn = $app['phraseanet.appbox']->get_connection();
|
||||
$em = $app['EM'];
|
||||
|
||||
$em->getEventManager()->removeEventSubscriber(new TimestampableListener());
|
||||
|
||||
$this->updateUsers($em, $conn);
|
||||
$this->updateModels($em, $conn);
|
||||
|
||||
$em->getEventManager()->addEventSubscriber(new TimestampableListener());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets user entity from usr table.
|
||||
*/
|
||||
private function updateUsers(EntityManager $em, $conn)
|
||||
{
|
||||
$sql = 'SELECT activite, adresse, create_db, canchgftpprofil, canchgprofil, ville,
|
||||
societe, pays, usr_mail, fax, usr_prenom, geonameid, invite, fonction, last_conn, lastModel,
|
||||
usr_nom, ldap_created, locale, usr_login, mail_locked, mail_notifications, nonce, usr_password, push_list,
|
||||
request_notifications, salted_password, usr_sexe, tel, timezone, cpostal, usr_creationdate, usr_modificationdate
|
||||
FROM usr';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$n = 0;
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$user = new User();
|
||||
$user->setActivity($row['activite']);
|
||||
$user->setAddress($row['adresse']);
|
||||
$user->setAdmin(!!$row['create_db']);
|
||||
$user->setCanChangeFtpProfil(!!$row['canchgftpprofil']);
|
||||
$user->setCanChangeProfil(!!$row['canchgprofil']);
|
||||
$user->setCity($row['ville']);
|
||||
$user->setCompany($row['societe']);
|
||||
$user->setCountry((string) $row['pays']);
|
||||
$user->setEmail($row['usr_mail']);
|
||||
$user->setFax($row['fax']);
|
||||
$user->setFirstName($row['usr_prenom']);
|
||||
if ($row['geonameid'] > 0) {
|
||||
$user->setGeonameId($row['geonameid']);
|
||||
}
|
||||
$user->setGuest(!!$row['invite']);
|
||||
$user->setJob($row['fonction']);
|
||||
$user->setLastConnection(new \DateTime($row['last_conn']));
|
||||
$user->setLastModel($row['lastModel']);
|
||||
$user->setLastName($row['usr_nom']);
|
||||
$user->setLdapCreated(!!$row['ldap_created']);
|
||||
try {
|
||||
$user->setLocale($row['locale']);
|
||||
} catch (\InvalidArgumentException $e ) {
|
||||
|
||||
}
|
||||
$user->setLogin($row['usr_login']);
|
||||
|
||||
if (substr($row['usr_login'], 0, 10) === '(#deleted_') {
|
||||
$user->setDeleted(true);
|
||||
}
|
||||
|
||||
$user->setMailLocked(!!$row['mail_locked']);
|
||||
$user->setMailNotificationsActivated(!!$row['mail_notifications']);
|
||||
$user->setNonce($row['nonce']);
|
||||
$user->setPassword($row['usr_password']);
|
||||
$user->setPushList($row['push_list']);
|
||||
$user->setRequestNotificationsActivated(!!$row['request_notifications']);
|
||||
$user->setSaltedPassword(!!$row['salted_password']);
|
||||
|
||||
switch ($row['usr_sexe']) {
|
||||
case 0:
|
||||
$gender = User::GENDER_MISS;
|
||||
break;
|
||||
case 1:
|
||||
$gender = User::GENDER_MRS;
|
||||
break;
|
||||
case 2:
|
||||
$gender = User::GENDER_MR;
|
||||
break;
|
||||
default:
|
||||
$gender = null;
|
||||
}
|
||||
|
||||
$user->setGender($gender);
|
||||
$user->setPhone($row['tel']);
|
||||
$user->setTimezone($row['timezone']);
|
||||
$user->setZipCode($row['cpostal']);
|
||||
$user->setCreated(new \DateTime($row['usr_creationdate']));
|
||||
$user->setupdated(new \DateTime($row['usr_modificationdate']));
|
||||
|
||||
$em->persist($user);
|
||||
|
||||
$n++;
|
||||
|
||||
if ($n % 100 === 0) {
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
}
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets model from usr table.
|
||||
*/
|
||||
private function updateModels(EntityManager $em, $conn)
|
||||
{
|
||||
$sql = "SELECT model_of, usr_login
|
||||
FROM usr
|
||||
WHERE model_of > 0";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$n = 0;
|
||||
|
||||
$repository = $em->getRepository('Phraseanet:User');
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$template = $repository->findOneByLogin($row['usr_login']);
|
||||
|
||||
if (null === $loginOwner = $this->getLoginFromId($conn, $row['model_of'])) {
|
||||
// remove template with no owner
|
||||
$em->remove($template);
|
||||
} else {
|
||||
$owner = $repository->findOneByLogin($loginOwner);
|
||||
$template->setModelOf($owner);
|
||||
$em->persist($owner);
|
||||
}
|
||||
|
||||
$n++;
|
||||
|
||||
if ($n % 100 === 0) {
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
}
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns user login from its id.
|
||||
*/
|
||||
private function getLoginFromId($conn, $id)
|
||||
{
|
||||
$sql = "SELECT usr_login
|
||||
FROM usr
|
||||
WHERE usr_id = :id";
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute([':id' => $id]);
|
||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
if (count($row) === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $row['usr_login'];
|
||||
}
|
||||
}
|
@@ -12,7 +12,7 @@
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Model\Entities\UserQuery;
|
||||
|
||||
class patch_390alpha3a implements patchInterface
|
||||
class patch_390alpha3a extends patchAbstract
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0-alpha.3';
|
||||
@@ -49,7 +49,7 @@ class patch_390alpha3a implements patchInterface
|
||||
*/
|
||||
public function getDoctrineMigrations()
|
||||
{
|
||||
return ['user-query'];
|
||||
return ['user', 'user-query'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,9 +73,13 @@ class patch_390alpha3a implements patchInterface
|
||||
$em = $app['EM'];
|
||||
|
||||
foreach ($rs as $row) {
|
||||
if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$userQuery = new UserQuery();
|
||||
$userQuery->setQuery($row['query']);
|
||||
$userQuery->setUsrId($row['usr_id']);
|
||||
$userQuery->setUser($user);
|
||||
|
||||
$em->persist($userQuery);
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Model\Entities\UserSetting;
|
||||
|
||||
class patch_390alpha4a implements patchInterface
|
||||
class patch_390alpha4a extends patchAbstract
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0-alpha.4';
|
||||
@@ -77,10 +77,14 @@ class patch_390alpha4a implements patchInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$userSetting = new UserSetting();
|
||||
$userSetting->setName($row['prop']);
|
||||
$userSetting->setValue($row['value']);
|
||||
$userSetting->setUsrId($row['usr_id']);
|
||||
$userSetting->setUser($user);
|
||||
|
||||
$em->persist($userSetting);
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Model\Entities\UserNotificationSetting;
|
||||
|
||||
class patch_390alpha5a implements patchInterface
|
||||
class patch_390alpha5a extends patchAbstract
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0-alpha.5';
|
||||
@@ -74,10 +74,14 @@ class patch_390alpha5a implements patchInterface
|
||||
$em = $app['EM'];
|
||||
|
||||
foreach ($rs as $row) {
|
||||
if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$userSetting = new UserNotificationSetting();
|
||||
$userSetting->setName($row['prop']);
|
||||
$userSetting->setValue($row['value']);
|
||||
$userSetting->setUsrId($row['usr_id']);
|
||||
$userSetting->setUser($user);
|
||||
|
||||
$em->persist($userSetting);
|
||||
|
||||
|
@@ -13,8 +13,9 @@ use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Model\Entities\FtpExport;
|
||||
use Alchemy\Phrasea\Model\Entities\FtpExportElement;
|
||||
use Gedmo\Timestampable\TimestampableListener;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
|
||||
class patch_390alpha6a implements patchInterface
|
||||
class patch_390alpha6a extends patchAbstract
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0-alpha.6';
|
||||
@@ -93,9 +94,7 @@ class patch_390alpha6a implements patchInterface
|
||||
$n = 0;
|
||||
|
||||
foreach ($rs as $row) {
|
||||
try {
|
||||
$user = \User_Adapter::getInstance($row['usr_id'], $app);
|
||||
} catch (\Exception $e) {
|
||||
if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@ use Alchemy\Phrasea\Model\Entities\FeedPublisher;
|
||||
use Alchemy\Phrasea\Model\Entities\FeedToken;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
|
||||
class patch_390alpha7a implements patchInterface
|
||||
class patch_390alpha7a extends patchAbstract
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0-alpha.7';
|
||||
@@ -133,12 +133,16 @@ class patch_390alpha7a implements patchInterface
|
||||
$fpRes = $fpStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($fpRes as $fpRow) {
|
||||
if (null === $user = $this->loadUser($app['EM'], $fpRow['usr_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$feedPublisher = new FeedPublisher();
|
||||
$feedPublisher->setFeed($feed);
|
||||
$feed->addPublisher($feedPublisher);
|
||||
$feedPublisher->setCreatedOn(new \DateTime($fpRow['created_on']));
|
||||
$feedPublisher->setIsOwner((Boolean) $fpRow['owner']);
|
||||
$feedPublisher->setUsrId($fpRow['usr_id']);
|
||||
$feedPublisher->setUser($user);
|
||||
|
||||
$feStmt->execute([':feed_id' => $row['id'], ':publisher_id' => $fpRow['id']]);
|
||||
$feRes = $feStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
@@ -177,10 +181,14 @@ class patch_390alpha7a implements patchInterface
|
||||
$ftRes = $ftStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($ftRes as $ftRow) {
|
||||
if (null === $user = $this->loadUser($app['EM'], $ftRow['usr_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$token = new FeedToken();
|
||||
$token->setFeed($feed);
|
||||
$feed->addToken($token);
|
||||
$token->setUsrId($ftRow['usr_id']);
|
||||
$token->setUser($user);
|
||||
$token->setValue($ftRow['token']);
|
||||
|
||||
$em->persist($token);
|
||||
@@ -204,8 +212,12 @@ class patch_390alpha7a implements patchInterface
|
||||
$faRes = $faStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($faRes as $faRow) {
|
||||
if (null === $user = $this->loadUser($app['EM'], $faRow['usr_id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$token = new AggregateToken();
|
||||
$token->setUsrId($faRow['usr_id']);
|
||||
$token->setUser($user);
|
||||
$token->setValue($faRow['token']);
|
||||
|
||||
$em->persist($token);
|
||||
|
@@ -57,7 +57,6 @@ class patch_390alpha9a implements patchInterface
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
$this->updateRegistry($app);
|
||||
$this->updateUsers($appbox);
|
||||
$this->updateDoctrineUsers($app);
|
||||
$this->updateDataboxPrefs($appbox);
|
||||
}
|
||||
@@ -78,27 +77,6 @@ class patch_390alpha9a implements patchInterface
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
private function updateUsers(\appbox $appbox)
|
||||
{
|
||||
$sql = 'SELECT usr_id, locale FROM usr WHERE locale IS NOT NULL';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
$stmt->execute();
|
||||
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = 'UPDATE usr SET locale = :locale WHERE usr_id = :usr_id';
|
||||
$stmt = $appbox->get_connection()->prepare($sql);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$stmt->execute([
|
||||
':locale' => $this->extractLocale($row['locale']),
|
||||
':usr_id' => $row['usr_id'],
|
||||
]);
|
||||
}
|
||||
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
private function updateDoctrineUsers(Application $app)
|
||||
{
|
||||
$dql = 'SELECT u FROM Phraseanet:User u WHERE u.locale IS NOT NULL';
|
||||
|
@@ -12,10 +12,10 @@
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Model\Entities\Task;
|
||||
|
||||
class patch_390alpha10a implements patchInterface
|
||||
class patch_390alpha9b implements patchInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $release = '3.9.0-alpha.10';
|
||||
private $release = '3.9.0-alpha.9b';
|
||||
|
||||
/** @var array */
|
||||
private $concern = [base::APPLICATION_BOX];
|
||||
@@ -33,7 +33,7 @@ class patch_390alpha10a implements patchInterface
|
||||
*/
|
||||
public function require_all_upgrades()
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
Reference in New Issue
Block a user