mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 06:53:15 +00:00
Merge remote-tracking branch 'upstream/master' into 20150306-elastic-indexer
Conflicts: bin/console bower.json composer.json composer.lock lib/Alchemy/Phrasea/Application.php lib/Alchemy/Phrasea/Border/Manager.php lib/Alchemy/Phrasea/Controller/Api/V1.php lib/Alchemy/Phrasea/Core/PhraseaEvents.php lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php lib/classes/caption/field.php lib/classes/record/Interface.php templates/web/prod/index.html.twig www/skins/prod/000000/prodcolor.css
This commit is contained in:
@@ -58,7 +58,7 @@ class ValidationParticipant
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="ValidationSession", inversedBy="participants", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="ValidationSession_id", referencedColumnName="id")
|
||||
* @ORM\JoinColumn(name="validation_session_id", referencedColumnName="id")
|
||||
*/
|
||||
private $session;
|
||||
|
||||
|
@@ -217,6 +217,7 @@ class UserManager
|
||||
$this->cleanFtpExports($user);
|
||||
$this->cleanAuthProvider($user);
|
||||
$this->cleanUserSessions($user);
|
||||
$this->cleanOauthApplication($user);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,4 +236,18 @@ class UserManager
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
}
|
||||
private function cleanOauthApplication(User $user)
|
||||
{
|
||||
$accounts = $this->objectManager->getRepository('Phraseanet:ApiAccount')->findByUser($user);
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$this->objectManager->remove($account);
|
||||
}
|
||||
|
||||
$apps = $this->objectManager->getRepository('Phraseanet:ApiApplication')->findByCreator($user);
|
||||
|
||||
foreach ($apps as $app) {
|
||||
$this->objectManager->remove($app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,84 +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.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Model;
|
||||
|
||||
use Doctrine\DBAL\Logging\SQLLogger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Log doctrine sql request with monolog
|
||||
*
|
||||
* Please move this to a service provider as follow
|
||||
* http://srcmvn.com/blog/2011/11/10/doctrine-dbal-query-logging-with-monolog-in-silex/
|
||||
*/
|
||||
class MonologSQLLogger implements SQLLogger
|
||||
{
|
||||
const JSON = 'json';
|
||||
const YAML = 'yaml';
|
||||
const VDUMP = 'vdump';
|
||||
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
private $start;
|
||||
private $output = [];
|
||||
private $outputType;
|
||||
|
||||
/**
|
||||
* Tell which monolog user to use and which format to output
|
||||
*
|
||||
* @param LoggerInterface $logger A monolog logger instance
|
||||
* @param string $type the output format
|
||||
*/
|
||||
public function __construct(LoggerInterface $logger, $type = self::YAML)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
$this->outputType = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function startQuery($sql, array $params = null, array $types = null)
|
||||
{
|
||||
$this->start = microtime(true);
|
||||
|
||||
$this->output["sql"] = $sql;
|
||||
|
||||
if ($params) {
|
||||
$this->output["params"] = $params;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function stopQuery()
|
||||
{
|
||||
$mstime = microtime(true) - $this->start;
|
||||
|
||||
$this->output["times"] = $mstime . " seconds";
|
||||
if ($this->outputType == self::JSON) {
|
||||
$this->log(json_encode($this->output));
|
||||
} elseif ($this->outputType == self::YAML) {
|
||||
$this->log(\Symfony\Component\Yaml\Yaml::dump($this->output));
|
||||
} else {
|
||||
$this->log(var_export($this->output, true));
|
||||
}
|
||||
}
|
||||
|
||||
protected function log($message)
|
||||
{
|
||||
$this->logger->debug($message);
|
||||
}
|
||||
}
|
@@ -24,4 +24,13 @@ class ApiAccountRepository extends EntityRepository
|
||||
|
||||
return $qb->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
|
||||
public function findByUser(User $user)
|
||||
{
|
||||
$qb = $this->createQueryBuilder('acc');
|
||||
$qb->where($qb->expr()->eq('acc.user', ':user'));
|
||||
$qb->setParameter(':user', $user);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
@@ -79,10 +79,10 @@ class FeedItemRepository extends EntityRepository
|
||||
try {
|
||||
$record = $item->getRecord($app);
|
||||
} catch (NotFoundHttpException $e) {
|
||||
$app['EM']->remove($item);
|
||||
$app['orm.em']->remove($item);
|
||||
continue;
|
||||
} catch (\Exception_Record_AdapterNotFound $e) {
|
||||
$app['EM']->remove($item);
|
||||
$app['orm.em']->remove($item);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class FeedItemRepository extends EntityRepository
|
||||
}
|
||||
}
|
||||
|
||||
$app['EM']->flush();
|
||||
$app['orm.em']->flush();
|
||||
$execution++;
|
||||
} while (count($items) < $nbItems && count($result) !== 0);
|
||||
|
||||
|
@@ -71,13 +71,13 @@ class RegistrationRepository extends EntityRepository
|
||||
SELECT dbname, sbas.sbas_id, time_limited,
|
||||
UNIX_TIMESTAMP( limited_from ) AS limited_from,
|
||||
UNIX_TIMESTAMP( limited_to ) AS limited_to,
|
||||
bas.server_coll_id, usr.usr_id, basusr.actif,
|
||||
bas.server_coll_id, Users.id, basusr.actif,
|
||||
bas.base_id AS bas_id , " . $rsm->generateSelectClause(['d' => 'd',]) . "
|
||||
FROM (usr, bas, sbas)
|
||||
LEFT JOIN basusr ON ( usr.usr_id = basusr.usr_id AND bas.base_id = basusr.base_id )
|
||||
LEFT JOIN Registrations d ON ( d.user_id = usr.usr_id AND bas.base_id = d.base_id )
|
||||
FROM (Users, bas, sbas)
|
||||
LEFT JOIN basusr ON ( Users.id = basusr.usr_id AND bas.base_id = basusr.base_id )
|
||||
LEFT JOIN Registrations d ON ( d.user_id = Users.id AND bas.base_id = d.base_id )
|
||||
WHERE bas.active = 1 AND bas.sbas_id = sbas.sbas_id
|
||||
AND usr.usr_id = ?
|
||||
AND Users.id = ?
|
||||
AND model_of = 0";
|
||||
|
||||
$query = $this->_em->createNativeQuery($sql, $rsm);
|
||||
|
@@ -50,6 +50,16 @@ class UserRepository extends EntityRepository
|
||||
return $this->findOneBy(['login' => $login]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds deleted users.
|
||||
*
|
||||
* @return User[]
|
||||
*/
|
||||
public function findDeleted()
|
||||
{
|
||||
return $this->findBy(['deleted' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a user by email.
|
||||
*
|
||||
|
Reference in New Issue
Block a user