Fix latest merge

This commit is contained in:
Nicolas Le Goff
2014-06-19 16:11:27 +02:00
parent a8da584666
commit 1250f8ab0b
60 changed files with 880 additions and 2417 deletions

2
composer.lock generated
View File

@@ -4930,7 +4930,7 @@
"silex/web-profiler": 20, "silex/web-profiler": 20,
"doctrine/migrations": 20, "doctrine/migrations": 20,
"behat/behat": 20, "behat/behat": 20,
"behat/gherkin": 20 "behat/gherkin": 20,
"mediavorus/mediavorus": 20, "mediavorus/mediavorus": 20,
"media-alchemyst/media-alchemyst": 20, "media-alchemyst/media-alchemyst": 20,
"php-ffmpeg/php-ffmpeg": 20, "php-ffmpeg/php-ffmpeg": 20,

View File

@@ -73,7 +73,6 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
$app['dispatcher']->dispatch(PhraseaEvents::API_RESULT, new ApiResultEvent($request, $response)); $app['dispatcher']->dispatch(PhraseaEvents::API_RESULT, new ApiResultEvent($request, $response));
}); });
$app['dispatcher']->addSubscriber(new ApiCorsSubscriber($app)); $app['dispatcher']->addSubscriber(new ApiCorsSubscriber($app));
$app['dispatcher']->dispatch(PhraseaEvents::API_LOAD_END, new ApiLoadEndEvent());
return $app; return $app;
}, isset($environment) ? $environment : PhraseaApplication::ENV_PROD); }, isset($environment) ? $environment : PhraseaApplication::ENV_PROD);

View File

@@ -196,7 +196,6 @@ class Lightbox implements ControllerProviderInterface
->assert('item_id', '\d+'); ->assert('item_id', '\d+');
$controllers->get('/validate/{basket}/', function (SilexApplication $app, $basket) { $controllers->get('/validate/{basket}/', function (SilexApplication $app, $basket) {
try { try {
\Session_Logger::updateClientInfos($app, 6); \Session_Logger::updateClientInfos($app, 6);
} catch (SessionNotFound $e) { } catch (SessionNotFound $e) {
@@ -290,7 +289,6 @@ class Lightbox implements ControllerProviderInterface
->assert('basket', '\d+'); ->assert('basket', '\d+');
$controllers->get('/feeds/entry/{entry_id}/', function (SilexApplication $app, $entry_id) { $controllers->get('/feeds/entry/{entry_id}/', function (SilexApplication $app, $entry_id) {
try { try {
\Session_Logger::updateClientInfos($app, 6); \Session_Logger::updateClientInfos($app, 6);
} catch (SessionNotFound $e) { } catch (SessionNotFound $e) {

View File

@@ -122,7 +122,7 @@ class Permalink extends AbstractDelivery
} else { } else {
$record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef); $record = \media_Permalink_Adapter::challenge_token($app, $databox, $token, $record_id, $subdef);
if (! ($record instanceof \record_adapter)) { if (!($record instanceof \record_adapter)) {
throw new NotFoundHttpException('Wrong token.'); throw new NotFoundHttpException('Wrong token.');
} }
} }

View File

@@ -17,7 +17,7 @@ use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
class DoDownload implements ControllerProviderInterface class DoDownload implements ControllerProviderInterface
@@ -144,12 +144,12 @@ class DoDownload implements ControllerProviderInterface
$app->abort(404, 'Download file not found'); $app->abort(404, 'Download file not found');
} }
$app['dispatcher']->addListener(KernelEvents::RESPONSE, function (PostResponseEvent $event) use ($list, $app) { $app['dispatcher']->addListener(KernelEvents::RESPONSE, function (FilterResponseEvent $event) use ($list, $app) {
\set_export::log_download( \set_export::log_download(
$app, $app,
$list, $list,
$event->getRequest()->get('type'), $event->getRequest()->get('type'),
!!$event->getRequest->get('anonymous', false), !!$event->getRequest()->get('anonymous', false),
(isset($list['email']) ? $list['email'] : '') (isset($list['email']) ? $list['email'] : '')
); );
}); });

View File

@@ -32,7 +32,7 @@ class Push implements ControllerProviderInterface
protected function getUserFormatter(Application $app) protected function getUserFormatter(Application $app)
{ {
return function (User $user) use ($app) { return function (User $user) use ($app) {
$subtitle = array_filter([$user->getPosition(), $user->getCompany()]); $subtitle = array_filter([$user->getJob(), $user->getCompany()]);
return [ return [
'type' => 'USER', 'type' => 'USER',
@@ -218,10 +218,10 @@ class Push implements ControllerProviderInterface
$app['EM']->flush(); $app['EM']->flush();
$arguments = array( $arguments = array(
'ssel_id' => $Basket->getId(), 'basket' => $Basket->getId(),
); );
if (!$app['phraseanet.registry']->get('GV_force_push_authentication') || !$request->get('force_authentication')) { if (!$app['conf']->get(['registry', 'actions', 'force-authentication']) || !$request->get('force_authentication')) {
$arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $user_receiver); $arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $user_receiver);
} }

View File

@@ -269,6 +269,7 @@ class Account implements ControllerProviderInterface
ORDER BY s.created DESC'; ORDER BY s.created DESC';
$query = $app['EM']->createQuery($dql); $query = $app['EM']->createQuery($dql);
$query->setMaxResults(100);
$query->setParameters(['usr_id' => $app['session']->get('usr_id')]); $query->setParameters(['usr_id' => $app['session']->get('usr_id')]);
$sessions = $query->getResult(); $sessions = $query->getResult();

View File

@@ -64,8 +64,9 @@ class Developers implements ControllerProviderInterface
->assert('application', '\d+') ->assert('application', '\d+')
->bind('submit_application_callback'); ->bind('submit_application_callback');
$controllers->post('/application/{id}/webhook/', $this->call('renewAppWebhook')) $controllers->post('/application/{application}/webhook/', 'controller.account.developers:renewAppWebhook')
->assert('id', '\d+') ->before($app['middleware.api-application.converter'])
->assert('application', '\d+')
->bind('submit_application_webhook'); ->bind('submit_application_webhook');
return $controllers; return $controllers;
@@ -124,14 +125,14 @@ class Developers implements ControllerProviderInterface
* @param integer $id The application id * @param integer $id The application id
* @return JsonResponse * @return JsonResponse
*/ */
public function renewAppWebhook(Application $app, Request $request, $id) public function renewAppWebhook(Application $app, Request $request, ApiApplication $application)
{ {
if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
$app->abort(400, _('Bad request format, only JSON is allowed')); $app->abort(400, _('Bad request format, only JSON is allowed'));
} }
if (null !== $request->request->get("webhook")) { if (null !== $request->request->get("webhook")) {
$app['manipulator.api-application']->setWebhook($request->request->get("webhook")); $app['manipulator.api-application']->setWebhookUrl($application, $request->request->get("webhook"));
} else { } else {
return $app->json(['success' => false]); return $app->json(['success' => false]);
} }

View File

@@ -60,7 +60,7 @@ class Session implements ControllerProviderInterface
); );
if ($app['authentication']->isAuthenticated()) { if ($app['authentication']->isAuthenticated()) {
$usr_id = $app['authentication']->getUser()->get_id(); $usr_id = $app['authentication']->getUser()->getId();
if ($usr_id != $request->request->get('usr')) { // I logged with another user if ($usr_id != $request->request->get('usr')) { // I logged with another user
$ret['status'] = 'disconnected'; $ret['status'] = 'disconnected';

View File

@@ -757,7 +757,7 @@ class Xmlhttp implements ControllerProviderInterface
$lcoll .= ($lcoll?",":"") . $collection->get_coll_id(); $lcoll .= ($lcoll?",":"") . $collection->get_coll_id();
} }
$site = $app['phraseanet.configuration']['main']['key']; $site = $app['phraseanet.configuration']['main']['key'];
$usr_id = $app['authentication']->getUser()->get_id(); $usr_id = $app['authentication']->getUser()->getId();
$tids = explode('.', $request->get('id')); $tids = explode('.', $request->get('id'));
$thid = implode('.', $tids); $thid = implode('.', $tids);

View File

@@ -110,6 +110,7 @@ class RegistryManipulator
'export-title-choice' => false, 'export-title-choice' => false,
'default-export-title' => 'title', 'default-export-title' => 'title',
'social-tools' => 'none', 'social-tools' => 'none',
'force-authentication' => false,
], ],
'ftp' => [ 'ftp' => [
'ftp-enabled' => false, 'ftp-enabled' => false,

View File

@@ -12,7 +12,7 @@
namespace Alchemy\Phrasea\Core\Event\Subscriber; namespace Alchemy\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Entities\SessionModule; use Alchemy\Phrasea\Model\Entities\SessionModule;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
@@ -109,7 +109,8 @@ class SessionManagerSubscriber implements EventSubscriberInterface
return; return;
} }
$session = $this->app['EM']->find('Entities\Session', $this->app['session']->get('session_id'));
$session = $this->app['repo.sessions']->find($this->app['session']->get('session_id'));
$idle = 0; $idle = 0;
if (isset($this->app["phraseanet.configuration"]["session"]["idle"])) { if (isset($this->app["phraseanet.configuration"]["session"]["idle"])) {

View File

@@ -47,6 +47,10 @@ class ActionsFormType extends AbstractType
'label' => 'Enable this setting to share on Facebook and Twitter', 'label' => 'Enable this setting to share on Facebook and Twitter',
'choices' => ['none' => 'Disabled', 'publishers' => 'Publishers', 'all' => 'Enabled'], 'choices' => ['none' => 'Disabled', 'publishers' => 'Publishers', 'all' => 'Enabled'],
]); ]);
$builder->add('force-authentication', 'checkbox', [
'label' => 'Enable Forcing authentication to see push content',
'help_message' => 'Adds an option to the push form submission to restrict push recipient(s) to Phraseanet users only.',
]);
} }
public function getName() public function getName()

View File

@@ -11,7 +11,8 @@
namespace Alchemy\Phrasea\Helper; namespace Alchemy\Phrasea\Helper;
use Symfony\Component\HttpFoundation\Request; use Doctrine\DBAL\DBALException;
use Alchemy\Phrasea\Core\Connection\ConnectionProvider;
class DatabaseHelper extends Helper class DatabaseHelper extends Helper
{ {
@@ -26,15 +27,30 @@ class DatabaseHelper extends Helper
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false; $connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
try { try {
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, null, array(), false); $conn = $this->app['dbal.provider']->get([
'host' => $hostname,
'port' => $port,
'user' => $user,
'password' => $password
]);
$conn->connect();
$connection_ok = true; $connection_ok = true;
} catch (\Exception $e) { } catch (\Exception $e) {
} }
if ($dbname && $connection_ok === true) { if (null !== $dbname && $connection_ok) {
try { try {
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname, array(), false); $conn = $this->app['dbal.provider']->get([
'host' => $hostname,
'port' => $port,
'user' => $user,
'password' => $password,
'dbname' => $dbname,
]);
$conn->connect();
$db_ok = true; $db_ok = true;
$sql = "SHOW TABLE STATUS"; $sql = "SHOW TABLE STATUS";

View File

@@ -119,12 +119,18 @@ class ApiApplication
*/ */
private $grantPassword = false; private $grantPassword = false;
/** /**
* @ORM\OneToMany(targetEntity="ApiAccount", mappedBy="application", cascade={"remove"}) * @ORM\OneToMany(targetEntity="ApiAccount", mappedBy="application", cascade={"remove"})
**/ **/
private $accounts; private $accounts;
/**
* @var string
*
* @ORM\Column(name="webhook_url", type="string", length=128)
*/
private $webhookUrl;
public function __construct() public function __construct()
{ {
$this->accounts = new ArrayCollection(); $this->accounts = new ArrayCollection();
@@ -398,6 +404,22 @@ class ApiApplication
return $this->website; return $this->website;
} }
/**
* @param string $webhookUrl
*/
public function setWebhookUrl($webhookUrl)
{
$this->webhookUrl = $webhookUrl;
}
/**
* @return string
*/
public function getWebhookUrl()
{
return $this->webhookUrl;
}
/** /**
* @param ApiAccount $account * @param ApiAccount $account
* *

View File

@@ -83,6 +83,12 @@ class ApiApplicationManipulator implements ManipulatorInterface
$this->update($application); $this->update($application);
} }
public function setWebhookUrl(ApiApplication $application, $url)
{
$this->doSetWebhookUrl($application, $url);
$this->update($application);
}
private function doSetType(ApiApplication $application, $type) private function doSetType(ApiApplication $application, $type)
{ {
if (!in_array($type, [ApiApplication::DESKTOP_TYPE, ApiApplication::WEB_TYPE])) { if (!in_array($type, [ApiApplication::DESKTOP_TYPE, ApiApplication::WEB_TYPE])) {
@@ -114,4 +120,13 @@ class ApiApplicationManipulator implements ManipulatorInterface
$application->setWebsite($url); $application->setWebsite($url);
} }
private function doSetWebhookUrl(ApiApplication $application, $url)
{
if (false === filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) {
throw new InvalidArgumentException(sprintf('Webhook Url %s is not legal.', $url));
}
$application->setWebhookUrl($url);
}
} }

View File

@@ -1,722 +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 Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
*
* @package Feeds
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cacheableInterface
{
/**
*
* @var int
*/
protected $id;
/**
*
* @var collection
*/
protected $collection;
/**
*
* @var array
*/
protected $publishers;
/**
*
* @var boolean
*/
protected $public;
/**
*
* @var Feed_Publisher_Adapter
*/
protected $owner;
/**
*
* @var string
*/
protected $icon_url;
const CACHE_ENTRY_NUMBER = 'entrynumber';
const CACHE_USER_TOKEN = 'usr_token';
const MAX_ENTRIES = 20;
public function __construct(Application $app, $id)
{
$this->app = $app;
$this->id = (int) $id;
$this->load();
return $this;
}
protected function load()
{
try {
$datas = $this->get_data_from_cache();
$this->title = $datas['title'];
$this->subtitle = $datas['subtitle'];
$this->collection = $datas['base_id'] ? collection::get_from_base_id($this->app, $datas['base_id']) : null;
$this->created_on = $datas['created_on'];
$this->updated_on = $datas['updated_on'];
$this->public = $datas['public'];
return $this;
} catch (\Exception $e) {
}
$sql = 'SELECT id, title, subtitle, created_on, updated_on, base_id, public
FROM feeds WHERE id = :feed_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':feed_id' => $this->id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row)
throw new NotFoundHttpException('Feed not found');
$this->title = $row['title'];
$this->subtitle = $row['subtitle'];
if (!is_null($row['base_id']))
$this->collection = collection::get_from_base_id($this->app, $row['base_id']);
$this->created_on = new DateTime($row['created_on']);
$this->updated_on = new DateTime($row['updated_on']);
$this->public = !!$row['public'];
$base_id = $this->collection instanceof collection ? $this->collection->get_base_id() : null;
$datas = array(
'title' => $this->title
, 'subtitle' => $this->subtitle
, 'base_id' => $base_id
, 'created_on' => $this->created_on
, 'updated_on' => $this->updated_on
, 'public' => $this->public
);
$this->set_data_to_cache($datas);
return $this;
}
/**
*
* @return string
*/
public function get_icon_url()
{
if ($this->icon_url) {
return $this->icon_url;
}
$url = '/skins/icons/rss32.gif';
$file = $this->app['root.path']
. '/www/custom/feed_' . $this->get_id() . '.jpg';
if (file_exists($file)) {
$url = '/custom/feed_' . $this->get_id() . '.jpg';
}
$this->icon_url = $url;
return $this->icon_url;
}
/**
*
* @param string $file The path to the file
* @return Feed_Adapter
*/
public function set_icon($file)
{
if (!file_exists($file)) {
throw new \Alchemy\Phrasea\Exception\InvalidArgumentException('File does not exists');
}
$config_file = $this->app['root.path'] . '/config/feed_' . $this->get_id() . '.jpg';
$www_file = $this->app['root.path'] . '/www/custom/feed_' . $this->get_id() . '.jpg';
copy($file, $config_file);
copy($file, $www_file);
$this->icon_url = null;
return $this;
}
public function set_created_on(DateTime $created_on)
{
$sql = 'UPDATE feeds SET created_on = :created_on
WHERE id = :feed_id';
$params = array(
':created_on' => $created_on->format(DATE_ISO8601)
, ':feed_id' => $this->get_id()
);
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->created_on = $created_on;
$this->delete_data_from_cache();
return $this;
}
public function reset_icon()
{
$config_file = $this->app['root.path']
. '/config/feed_' . $this->get_id() . '.jpg';
$www_file = $this->app['root.path']
. '/www/custom/feed_' . $this->get_id() . '.jpg';
if (is_file($config_file))
unlink($config_file);
if (is_file($www_file))
unlink($www_file);
$this->icon_url = null;
return $this;
}
/**
*
* @return boolean
*/
public function is_aggregated()
{
return false;
}
/**
*
* @param User_Adapter $user
* @return boolean
*/
public function is_owner(User_Adapter $user)
{
$this->load_publishers();
if (!$this->owner) {
return false;
}
return $this->owner->get_user()->get_id() === $user->get_id();
}
/**
*
* @param User_Adapter $user
* @return boolean
*/
public function is_publisher(User_Adapter $user)
{
return in_array($user->get_id(), array_keys($this->get_publishers()));
}
/**
* Tells if a user has access to the feed
*
* @param User_Adapter $user
* @return type
*/
public function has_access(User_Adapter $user)
{
if ($this->get_collection() instanceof collection) {
return $user->ACL()->has_access_to_base($this->collection->get_base_id());
}
return true;
}
/**
*
* @return boolean
*/
public function is_public()
{
if ($this->get_collection() instanceof collection) {
return false;
}
return $this->public;
}
/**
*
* @return array
*/
public function get_publishers()
{
return $this->load_publishers();
}
/**
*
* @return collection
*/
public function get_collection()
{
return $this->collection;
}
/**
*
* @param User_Adapter $user
* @return Feed_Adapter
*/
public function add_publisher(User_Adapter $user)
{
if (in_array($user->get_id(), array_keys($this->get_publishers()))) {
return $this;
}
Feed_Publisher_Adapter::create($this->app, $user, $this, false);
$this->publishers = null;
return $this;
}
/**
*
* @return array
*/
protected function load_publishers()
{
if (is_array($this->publishers)) {
return $this->publishers;
}
$sql = 'SELECT id, usr_id, owner FROM feed_publishers
WHERE feed_id = :feed_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':feed_id' => $this->id));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
foreach ($rs as $row) {
try {
$publisher = new Feed_Publisher_Adapter($this->app, $row['id']);
} catch (\Exception_Feed_PublisherNotFound $e) {
continue;
}
$this->publishers[$row['usr_id']] = $publisher;
if ($publisher->is_owner()) {
$this->owner = $publisher;
}
}
return $this->publishers;
}
/**
*
* @return int
*/
public function get_id()
{
return $this->id;
}
/**
*
* @param collection $collection
* @return Feed_Adapter
*/
public function set_collection(collection $collection = null)
{
$base_id = null;
if ($collection instanceof collection) {
$base_id = $collection->get_base_id();
}
$sql = 'UPDATE feeds SET base_id = :base_id, updated_on = NOW()
WHERE id = :feed_id';
$params = array(':base_id' => $base_id, ':feed_id' => $this->get_id());
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->collection = $collection;
$this->delete_data_from_cache();
return $this;
}
/**
*
* @param boolean $boolean
* @return Feed_Adapter
*/
public function set_public($boolean)
{
$boolean = !!$boolean;
$sql = 'UPDATE feeds SET public = :public, updated_on = NOW()
WHERE id = :feed_id';
$params = array(
':public' => $boolean ? '1' : '0',
':feed_id' => $this->get_id()
);
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->public = $boolean;
$this->delete_data_from_cache();
$feed_collection = new Feed_Collection($this->app, array());
$feed_collection->delete_data_from_cache(Feed_Collection::CACHE_PUBLIC);
return $this;
}
/**
*
* @param string $title
* @return Feed_Adapter
*/
public function set_title($title)
{
$title = trim(strip_tags($title));
if ($title === '')
throw new Exception_InvalidArgument();
$sql = 'UPDATE feeds SET title = :title, updated_on = NOW()
WHERE id = :feed_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':title' => $title, ':feed_id' => $this->get_id()));
$stmt->closeCursor();
$this->title = $title;
$this->delete_data_from_cache();
return $this;
}
/**
*
* @param string $subtitle
* @return Feed_Adapter
*/
public function set_subtitle($subtitle)
{
$subtitle = strip_tags($subtitle);
$sql = 'UPDATE feeds SET subtitle = :subtitle, updated_on = NOW()
WHERE id = :feed_id';
$params = array(':subtitle' => $subtitle, ':feed_id' => $this->get_id());
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$this->subtitle = $subtitle;
$this->delete_data_from_cache();
return $this;
}
public static function create(Application $app, User_Adapter $user, $title, $subtitle)
{
$sql = 'INSERT INTO feeds (id, title, subtitle, created_on, updated_on)
VALUES (null, :title, :subtitle, NOW(), NOW())';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':title' => $title, ':subtitle' => $subtitle));
$stmt->closeCursor();
$feed_id = $app['phraseanet.appbox']->get_connection()->lastInsertId();
$feed = new self($app, $feed_id);
Feed_Publisher_Adapter::create($app, $user, $feed, true);
return $feed;
}
public static function load_with_user(Application $app, User_Adapter $user, $id)
{
$feed = new self($app, $id);
$coll = $feed->get_collection();
if (
$feed->is_public()
|| $coll === null
|| in_array($coll->get_base_id(), array_keys($user->ACL()->get_granted_base()))
) {
return $feed;
}
throw new NotFoundHttpException('Feed not found');
}
/**
*
* @return int
*/
public function get_count_total_entries()
{
try {
return $this->get_data_from_cache(self::CACHE_ENTRY_NUMBER);
} catch (\Exception $e) {
}
$sql = 'SELECT count(id) as number
FROM feed_entries WHERE feed_id = :feed_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':feed_id' => $this->get_id()));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$number = $row ? (int) $row['number'] : 0;
$stmt->closeCursor();
$this->set_data_to_cache($number, self::CACHE_ENTRY_NUMBER);
return $number;
}
/**
*
* @return void
*/
public function delete()
{
$this->reset_icon();
while ($this->get_count_total_entries() > 0) {
$entries_coll = $this->get_entries(0, 10);
foreach ($entries_coll->get_entries() as $entry) {
$entry->delete();
}
unset($entries_coll);
$this->delete_data_from_cache(self::CACHE_ENTRY_NUMBER);
}
foreach ($this->get_publishers() as $publishers)
$publishers->delete();
$sql = 'DELETE FROM feed_tokens WHERE feed_id = :feed_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':feed_id' => $this->get_id()));
$stmt->closeCursor();
$sql = 'DELETE FROM feeds WHERE id = :feed_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':feed_id' => $this->get_id()));
$stmt->closeCursor();
$this->delete_data_from_cache();
$feed_coll = new Feed_Collection($this->app, array());
$feed_coll->delete_data_from_cache(Feed_Collection::CACHE_PUBLIC);
return;
}
/**
*
* @param int $offset_start
* @param int $how_many
* @return Feed_Entry_Collection
*/
public function get_entries($offset_start, $how_many)
{
$offset_start = (int) $offset_start;
$how_many = $how_many > self::MAX_ENTRIES ? self::MAX_ENTRIES : (int) $how_many;
$sql = 'SELECT id
FROM feed_entries
WHERE feed_id = :feed_id
ORDER BY id DESC
LIMIT ' . $offset_start . ', ' . $how_many;
$params = array(
':feed_id' => $this->get_id()
);
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$result = new Feed_Entry_Collection();
foreach ($rs as $row) {
$entry = new Feed_Entry_Adapter($this->app, $this, $row['id']);
$result->add_entry($entry);
}
return $result;
}
/**
*
* @param registryInterface $registry
* @param string $format
* @param int $page
* @return Feed_Link
*/
public function get_homepage_link(registryInterface $registry, $format, $page = null)
{
if (!$this->is_public()) {
return null;
}
switch ($format) {
case self::FORMAT_ATOM:
return new Feed_Link(
sprintf('%s/feeds/feed/%s/atom/%s'
, rtrim($registry->get('GV_ServerName'), '/')
, $this->get_id()
, ($page ? '?page=' . $page : '')
)
, sprintf('%s - %s', $this->get_title(), 'Atom')
, 'application/atom+xml'
);
break;
case self::FORMAT_RSS:
default:
return new Feed_Link(
sprintf('%s/feeds/feed/%s/rss/%s'
, rtrim($registry->get('GV_ServerName'), '/')
, $this->get_id()
, ($page ? '?page=' . $page : '')
)
, sprintf('%s - %s', $this->get_title(), 'RSS')
, 'application/rss+xml'
);
break;
}
}
/**
*
* @param User_Adapter $user
* @param boolean $renew
* @return string
*/
protected function get_token(User_Adapter $user, $renew = false)
{
$cache_key = self::CACHE_USER_TOKEN . '_' . $user->get_id();
try {
if (!$renew) {
return $this->get_data_from_cache($cache_key);
}
} catch (\Exception $e) {
}
$sql = 'SELECT token FROM feed_tokens
WHERE usr_id = :usr_id AND feed_id = :feed_id
AND aggregated IS NULL';
$params = array(
':usr_id' => $user->get_id(),
':feed_id' => $this->get_id()
);
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row || $renew === true) {
$token = random::generatePassword(12, random::LETTERS_AND_NUMBERS);
$sql = 'REPLACE INTO feed_tokens (id, token, feed_id, usr_id, aggregated)
VALUES (null, :token, :feed_id, :usr_id, :aggregated)';
$params = array(
':token' => $token
, ':feed_id' => $this->get_id()
, ':usr_id' => $user->get_id()
, ':aggregated' => null
);
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$this->delete_data_from_cache($cache_key);
} else {
$token = $row['token'];
}
$this->set_data_to_cache($token, $cache_key);
return $token;
}
/**
*
* @param registryInterface $registry
* @param User_Adapter $user
* @param string $format
* @param int $page
* @param boolean $renew_token
* @return Feed_Link
*/
public function get_user_link(registryInterface $registry, User_Adapter $user, $format, $page = null, $renew_token = false)
{
switch ($format) {
case self::FORMAT_ATOM:
return new Feed_Link(
sprintf('%s/feeds/userfeed/%s/%s/atom/'
, rtrim($registry->get('GV_ServerName'), '/')
, $this->get_token($user, $renew_token)
, $this->get_id()
, ($page ? '?page=' . $page : '')
)
, sprintf('%s - %s', $this->get_title(), 'Atom')
, 'application/atom+xml'
);
break;
case self::FORMAT_RSS:
return new Feed_Link(
sprintf('%s/feeds/userfeed/%s/%s/rss/%s'
, rtrim($registry->get('GV_ServerName'), '/')
, $this->get_token($user, $renew_token)
, $this->get_id()
, ($page ? '?page=' . $page : '')
)
, sprintf('%s - %s', $this->get_title(), 'RSS')
, 'application/rss+xml'
);
break;
}
}
public function get_cache_key($option = null)
{
return 'feed_adapter_' . $this->get_id() . '_' . ($option ? '_' . $option : '');
}
public function get_data_from_cache($option = null)
{
return $this->app['phraseanet.appbox']->get_data_from_cache($this->get_cache_key($option));
}
public function set_data_to_cache($value, $option = null, $duration = 0)
{
return $this->app['phraseanet.appbox']->set_data_to_cache($value, $this->get_cache_key($option), $duration);
}
public function delete_data_from_cache($option = null)
{
return $this->app['phraseanet.appbox']->delete_data_from_cache($this->get_cache_key($option));
}
}

View File

@@ -386,7 +386,7 @@ class caption_Field_Value implements cache_cacheableInterface
$bestnote = 0; $bestnote = 0;
foreach ($nodes as $node) { foreach ($nodes as $node) {
$note = 0; $note = 0;
$note += ($node->getAttribute("lng") == $this->app['locale.I18n']) ? 4 : 0; $note += ($node->getAttribute("lng") == $this->app['locale']) ? 4 : 0;
$note += ($node->getAttribute("w") == $term_noacc) ? 2 : 0; $note += ($node->getAttribute("w") == $term_noacc) ? 2 : 0;
if($context_noacc != "") if($context_noacc != "")
$note += ($node->getAttribute("k") == $context_noacc) ? 1 : 0; $note += ($node->getAttribute("k") == $context_noacc) ? 1 : 0;

View File

@@ -188,7 +188,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
$fields[$field->get_name()] = array( $fields[$field->get_name()] = array(
'values' => $values, 'values' => $values,
'name' => $field->get_name(), 'name' => $field->get_name(),
'label' => $field->get_databox_field()->get_label($this->app['locale.I18n']), 'label' => $field->get_databox_field()->get_label($this->app['locale']),
'separator' => $field->get_databox_field()->get_separator(), 'separator' => $field->get_databox_field()->get_separator(),
'sbas_id' => $field->get_databox_field()->get_databox()->get_sbas_id() 'sbas_id' => $field->get_databox_field()->get_databox()->get_sbas_id()
); );

View File

@@ -1385,7 +1385,7 @@ class databox extends base
$stmt->closeCursor(); $stmt->closeCursor();
foreach ($rs as $row) { foreach ($rs as $row) {
$TOU[$row['locale']] = ['updated_on' => $row['updated_on'], 'value' => $row['value']]; $TOU[$row['locale']] = ['updated_on' => $row['updated_on'], 'value' => $row['value']];
} }
$missing_locale = []; $missing_locale = [];
@@ -1397,14 +1397,16 @@ class databox extends base
} }
} }
$TOU = array_intersect_key($TOU, $avLanguages);
$date_obj = new DateTime(); $date_obj = new DateTime();
$date = $this->app['date-formatter']->format_mysql($date_obj); $date = $this->app['date-formatter']->format_mysql($date_obj);
$sql = "INSERT INTO pref (id, prop, value, locale, updated_on, created_on) $sql = "INSERT INTO pref (id, prop, value, locale, updated_on, created_on)
VALUES (null, 'ToU', '', :locale, :date, NOW())"; VALUES (null, 'ToU', '', :locale, :date, NOW())";
$stmt = $this->get_connection()->prepare($sql); $stmt = $this->get_connection()->prepare($sql);
foreach ($missing_locale as $v) { foreach ($missing_locale as $v) {
$stmt->execute([':locale' => $v, ':date' => $date]); $stmt->execute([':locale' => $v, ':date' => $date]);
$TOU[$v] = ['updated_on' => $date, 'value' => '']; $TOU[$v] = ['updated_on' => $date, 'value' => ''];
} }
$stmt->closeCursor(); $stmt->closeCursor();
$this->cgus = $TOU; $this->cgus = $TOU;

View File

@@ -60,7 +60,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
$data = $dom_xml->saveXml(); $data = $dom_xml->saveXml();
API_Webhook::create($this->app['phraseanet.appbox'], API_Webhook::NEW_FEED_ENTRY, array_merge( API_Webhook::create($this->app['phraseanet.appbox'], API_Webhook::NEW_FEED_ENTRY, array_merge(
array('feed_id' => $entry->get_feed()->get_id()), $params array('feed_id' => $entry->getFeed()->getId()), $params
)); ));
$Query = new \User_Query($this->app); $Query = new \User_Query($this->app);

View File

@@ -261,8 +261,8 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea
} }
$sql = 'SELECT p.id, p.token, p.activated, p.created_on, p.last_modified $sql = '
, p.label SELECT p.id, p.token, p.activated, p.created_on, p.last_modified, p.label
FROM permalinks p FROM permalinks p
WHERE p.subdef_id = :subdef_id'; WHERE p.subdef_id = :subdef_id';
$stmt = $this->databox->get_connection()->prepare($sql); $stmt = $this->databox->get_connection()->prepare($sql);
@@ -270,8 +270,9 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
if ( ! $row) if (!$row) {
throw new Exception_Media_SubdefNotFound (); throw new Exception_Media_SubdefNotFound ();
}
$this->id = (int) $row['id']; $this->id = (int) $row['id'];
$this->token = $row['token']; $this->token = $row['token'];
@@ -363,10 +364,11 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea
public static function challenge_token(Application $app, databox $databox, $token, $record_id, $name) public static function challenge_token(Application $app, databox $databox, $token, $record_id, $name)
{ {
$sql = 'SELECT p.id $sql = 'SELECT p.id
FROM permalinks p, subdef s FROM permalinks p
INNER JOIN subdef s
ON (s.subdef_id = p.subdef_id)
WHERE s.record_id = :record_id WHERE s.record_id = :record_id
AND s.name = :name AND s.name = :name
AND s.subdef_id = p.subdef_id
AND activated = "1" AND activated = "1"
AND token = :token'; AND token = :token';

File diff suppressed because it is too large Load Diff

View File

@@ -150,6 +150,6 @@ $groups = array(
'//include/jslibs/SWFUpload/swfupload.js' '//include/jslibs/SWFUpload/swfupload.js'
, '//include/jslibs/SWFUpload/plugins/swfupload.queue.js' , '//include/jslibs/SWFUpload/plugins/swfupload.queue.js'
] ]
]; );
return $groups; return $groups;

View File

@@ -8,7 +8,7 @@
{% block content_account %} {% block content_account %}
<form name="updatingDemand" id="updatingDemand" action="{{ path("submit_update_account") }}" method="post"> <form name="updatingDemand" id="updatingDemand" action="{{ path("submit_update_account") }}" method="post">
<table style="table-layout: fixed; width:100%"> <table style="table-layout: fixed; width:100%;">
<tr> <tr>
<td style="width: 180px; text-align: right">&nbsp;</td> <td style="width: 180px; text-align: right">&nbsp;</td>
<td width="15px" style="width: 15px">&nbsp;</td> <td width="15px" style="width: 15px">&nbsp;</td>
@@ -17,16 +17,26 @@
{% for sbasId, baseInfo in inscriptions %} {% for sbasId, baseInfo in inscriptions %}
{% set sbasName = sbasId | sbas_labels(app) %} {% set sbasName = sbasId | sbas_labels(app) %}
<tr> <tr>
<td colspan="3" style="text-align: center;"><h3>{{ sbasName }}</h3></td> <td colspan="3" style="text-align: center;">
<h3 style="background: #191919;border: 1px solid #333333;color:#eee">{{ sbasName }}</h3>
</td>
</tr> </tr>
{% if baseInfo["registrations"]["by-type"]["accepted"]|length > 0 %} {% if baseInfo["registrations"]["by-type"]["accepted"]|length > 0 %}
{% for baseId in baseInfo["registrations"]["by-type"]["accepted"] %} <tr>
<th colspan="3" style="text-align: center">
{{ "Allowed access to the following collections" | trans }}
</th>
</tr>
{% for baseId, base in baseInfo["registrations"]["by-type"]["accepted"] %}
<tr> <tr>
<td colspan="3" style="text-align:center;"> <td colspan="3" style="text-align:center;">
{{ "login::register: acces authorise sur la collection" | trans }}{{ sbasName }} <span style="color: lightgreen;">
<a class="inscriptlink" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}"> <b>{{ base["coll-name"] }}</b>
</span>
(<a class="inscriptlink" style="font-size: 10px" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}">
{{ "login::register::CGU: lire les CGU" | trans }} {{ "login::register::CGU: lire les CGU" | trans }}
</a> </a>)
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@@ -36,13 +46,20 @@
</tr> </tr>
{% endif %} {% endif %}
{% if baseInfo["registrations"]["by-type"]["rejected"]|length > 0 %} {% if baseInfo["registrations"]["by-type"]["rejected"]|length > 0 %}
{% for baseId in baseInfo["registrations"]["by-type"]["rejected"] %} <tr>
<th colspan="3" style="text-align: center">
{{ "Rejected access to the following collections" | trans }}
</th>
</tr>
{% for baseId, base in baseInfo["registrations"]["by-type"]["rejected"] %}
<tr> <tr>
<td colspan="3" style="text-align:center;"> <td colspan="3" style="text-align:center;">
<span style="color: red;">{{ "login::register: acces refuse sur la collection" | trans }}{{ sbasName }} <span style="color: red;">
<a class="inscriptlink" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}"> <b>{{ base["coll-name"] }}</b>
{{ "login::register::CGU: lire les CGU" | trans }} (<a class="inscriptlink" style="font-size: 10px" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}">
</a> {{ "login::register::CGU: lire les CGU" | trans }}
</a>)
</span>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@@ -52,13 +69,18 @@
</tr> </tr>
{% endif %} {% endif %}
{% if baseInfo["registrations"]["by-type"]["pending"]|length > 0 %} {% if baseInfo["registrations"]["by-type"]["pending"]|length > 0 %}
{% for baseId in baseInfo["registrations"]["by-type"]["pending"] %} <tr>
<th colspan="3" style="text-align: center">
{{ "Pending access to the following collections" | trans }}
</th>
</tr>
{% for baseId, base in baseInfo["registrations"]["by-type"]["pending"] %}
<tr> <tr>
<td colspan="3" style="text-align:center;"> <td colspan="3" style="text-align:center;">
<span style="color: orange;">{{ "login::register: en attente d\'acces sur" | trans }} {{ sbasId |sbas_labels(app) }}</span> <span style="color: #ffff00;"><b>{{ base["coll-name"] }}</b></span>
<a class="inscriptlink" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}"> (<a class="inscriptlink" style="font-size: 10px" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}">
{{ "login::register::CGU: lire les CGU" | trans }} {{ "login::register::CGU: lire les CGU" | trans }}
</a> </a>)
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@@ -68,13 +90,18 @@
</tr> </tr>
{% endif %} {% endif %}
{% if baseInfo["registrations"]["by-type"]["in-time"]|length > 0 %} {% if baseInfo["registrations"]["by-type"]["in-time"]|length > 0 %}
{% for baseId in baseInfo["registrations"]["by-type"]["in-time"] %} <tr>
<th colspan="3" style="text-align: center">
{{ "Temporary access to the following collections" | trans }}
</th>
</tr>
{% for baseId, base in baseInfo["registrations"]["by-type"]["in-time"] %}
<tr> <tr>
<td colspan="3" style="text-align:center;"> <td colspan="3" style="text-align:center;">
<span>{{ "login::register: acces temporaire sur" | trans }} {{ sbasId |sbas_labels(app) }}</span> <span style="color: lightskyblue;"><b>{{ base["coll-name"] }}</b></span>
<a class="inscriptlink" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}"> (<a class="inscriptlink" style="font-size: 10px" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}">
{{ "login::register::CGU: lire les CGU" | trans }} {{ "login::register::CGU: lire les CGU" | trans }}
</a> </a>)
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@@ -84,13 +111,18 @@
</tr> </tr>
{% endif %} {% endif %}
{% if baseInfo["registrations"]["by-type"]["out-dated"]|length > 0 %} {% if baseInfo["registrations"]["by-type"]["out-dated"]|length > 0 %}
{% for baseId in baseInfo["registrations"]["by-type"]["out-dated"] %} <tr>
<th colspan="3" style="text-align: center">
{{ "Outdated access to the following collections" | trans }}
</th>
</tr>
{% for baseId, base in baseInfo["registrations"]["by-type"]["out-dated"] %}
<tr> <tr>
<td colspan="3" style="text-align:center;"> <td colspan="3" style="text-align:center;">
<span style="color:red;">{{ "login::register: acces temporaire termine sur" | trans }}{{ sbasId |sbas_labels(app) }}</span> <span style="color:darkred;"><b>{{ base["coll-name"] }}</b></span>
<a class="inscriptlink" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}"> (<a class="inscriptlink" style="font-size: 10px" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}">
{{ "login::register::CGU: lire les CGU" | trans }} {{ "login::register::CGU: lire les CGU" | trans }}
</a> </a>)
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@@ -100,13 +132,18 @@
</tr> </tr>
{% endif %} {% endif %}
{% if baseInfo["registrations"]["by-type"]["inactive"]|length > 0 %} {% if baseInfo["registrations"]["by-type"]["inactive"]|length > 0 %}
{% for baseId in baseInfo["registrations"]["by-type"]["inactive"] %} <tr>
<th colspan="3" style="text-align: center">
{{ "Suspended access to the following collections" | trans }}
</th>
</tr>
{% for baseId, base in baseInfo["registrations"]["by-type"]["inactive"] %}
<tr> <tr>
<td colspan="3" style="text-align:center;"> <td colspan="3" style="text-align:center;">
<span style="color:red;">{{ "login::register: acces supendu sur" | trans }} {{ sbasId |sbas_labels(app) }}</span> <span style="color:orangered;"><b>{{ base["coll-name"] }}</b></span>
<a class="inscriptlink" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}"> (<a class="inscriptlink" style="font-size: 10px" href="{{ path('get_tou', {'to_display[]' : sbasId}) }}">
{{ "login::register::CGU: lire les CGU" | trans }} {{ "login::register::CGU: lire les CGU" | trans }}
</a> </a>)
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@@ -117,14 +154,17 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% for sbasId, baseInfo in inscriptions %} {% for sbasId, baseInfo in inscriptions %}
{% if baseInfo["config"]["cgu"] is not none %} {% if attribute(baseInfo["config"]["cgu"], app['locale']) is defined %}
{% set TOU = attribute(baseInfo["config"]["cgu"], app['locale']) %}
<tr> <tr>
<td colspan="3" style="text-align: center;">{{ "login::register: L\'acces aux bases ci-dessous implique l\'acceptation des Conditions Generales d\'Utilisation (CGU) suivantes" | trans }}</td> <td colspan="3" style="text-align: center;">
<i class="icon-warning"></i>
<h4>{{ "Access to the above bases constitutes acceptance of the following Terms of Use (TOU)." | trans }}</h4>
</td>
</tr> </tr>
<tr> <tr>
<td colspan="3" style="text-align: center;"><div style="width: 90%; height: 120px; text-align: left; overflow: auto;">{{ baseInfo["config"]["cgu"] }}</div></td> <td colspan="3" style="text-align: center;"><blockquote class="cgu" style="width: 90%; height: 120px; text-align: left; overflow: auto;">{{ TOU['value'] }}</blockquote></td>
</tr> </tr>
{% endif %} {% endif %}
{% for baseId, collInfo in baseInfo["config"]["collections"] if (collInfo['registration'] is none and collInfo['can-register']) %} {% for baseId, collInfo in baseInfo["config"]["collections"] if (collInfo['registration'] is none and collInfo['can-register']) %}
@@ -147,8 +187,5 @@
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
</table> </table>
<div class="form-actions">
<input type="submit" class="btn btn-info" value="{{ "boutton::valider" | trans }}">
</div>
</form> </form>
{% endblock %} {% endblock %}

View File

@@ -18,6 +18,11 @@
"server": "{{ app['geonames.server-uri'] }}", "server": "{{ app['geonames.server-uri'] }}",
"limit": 40 "limit": 40
}); });
$('legend').bind('click', function() {
$(".form-info").hide(200);
$($(this).data('target')).show();
});
}); });
</script> </script>
{% endblock %} {% endblock %}
@@ -30,212 +35,215 @@
<div class="row-fluid"> <div class="row-fluid">
<div class="span12"> <div class="span12">
{{ auth_macro.flashes() }} {{ auth_macro.flashes() }}
<form name="account" id="account" class="form-horizontal" action="{{ path("submit_update_account") }}" method="post"> <form name="account" id="account" class="form-horizontal" action="{{ path("submit_update_account") }}" method="post">
<div class="row-fluid"> <div class="row-fluid">
<div class="span12 well well-small" id="phr-account"> <div class="span12 well well-small" id="phr-account" style="background: #191919;border: 1px solid #333333;">
<legend>{{ "Informations personnelles" | trans }}</legend> <legend style="margin:10px 0" data-target="#user-info"><i class="icon-user"></i> &nbsp; {{ "Informations personnelles" | trans }}&nbsp; <a style="font-size: 11px;" href="#">({{ "edit" | trans }})</a></legend>
<div class="control-group"> <div id="user-info" class="form-info" style="display:none">
<label class="form_label control-label" for="form_login"><strong>{{ "admin::compte-utilisateur identifiant" | trans }}</strong></label> <div class="control-group">
<div class="controls"> <label class="form_label control-label" for="form_login"><strong>{{ "admin::compte-utilisateur identifiant" | trans }}</strong></label>
<span class="control-span">{{ app["authentication"].getUser().getLogin() }}</span> <div class="controls">
<p class="form_alert help-block"></p> <span class="control-span">{{ app["authentication"].getUser().getLogin() }}</span>
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_gender"><strong>{{ "admin::compte-utilisateur sexe" | trans }}</strong></label>
<div class="controls">
<select name="form_gender" class="input-small">
<option value=""></option>
<option {% if app["authentication"].getUser().getGender() == "0" %}selected{% endif %} value="0" >
{{ "admin::compte-utilisateur:sexe: mademoiselle" | trans }}
</option>
<option {% if app["authentication"].getUser().getGender() == "1" %}selected{% endif %} value="1" >
{{ "admin::compte-utilisateur:sexe: madame" | trans }}
</option>
<option {% if app["authentication"].getUser().getGender() == "2" %}selected{% endif %} value="2" >
{{ "admin::compte-utilisateur:sexe: monsieur" | trans }}
</option>
</select>
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_lastname"><strong>{{ "admin::compte-utilisateur nom" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_lastname" id="form_lastname" value="{{ app["authentication"].getUser().getLastName() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_firstname"><strong>{{ "admin::compte-utilisateur prenom" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_firstname" id="form_firstname" value="{{ app["authentication"].getUser().getFirstName() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_firstname"><strong>{{ "admin::compte-utilisateur email" | trans }}</strong></label>
<div class="controls">
<span class="control-span">{{ app["authentication"].getUser().getEmail() }} <a href="{{ path("account_reset_email") }}" target="_self">{{ "login:: Changer mon adresse email" | trans }}</a></span>
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="control-label"><strong>{{ "Password" | trans }}</strong></label>
<div class="controls">
<span class="control-span"><a href="{{ path("reset_password") }}" target="_self">{{ "admin::compte-utilisateur changer mon mot de passe" | trans }}</a></span>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_address"><strong>{{ "admin::compte-utilisateur adresse" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_address" id="form_address" value="{{ app["authentication"].getUser().getAddress() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_zip"><strong>{{ "admin::compte-utilisateur code postal" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_zip" id="form_zip" value="{{ app["authentication"].getUser().getZipCode() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_city"><strong>{{ "admin::compte-utilisateur ville" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge geoname_field" type="text" name="form_geonameid" id="form_geonameid" value="{{ app["authentication"].getUser().getGeonameId() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_function"><strong>{{ "admin::compte-utilisateur poste" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_function" id="form_function" value="{{ app["authentication"].getUser().getActivity() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_company"><strong>{{ "admin::compte-utilisateur societe" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_company" id="form_company" value="{{ app["authentication"].getUser().getCompany() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_activity"><strong>{{ "admin::compte-utilisateur activite" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_activity" id="form_activity" value="{{ app["authentication"].getUser().getJob() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_phone"><strong>{{ "admin::compte-utilisateur telephone" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_phone" id="form_phone" value="{{ app["authentication"].getUser().getPhone() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_fax"><strong>{{ "admin::compte-utilisateur fax" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_fax" id="form_fax" value="{{ app["authentication"].getUser().getFax() }}" />
<p class="form_alert help-block"></p>
</div>
</div> </div>
</div> </div>
<div class="control-group"> <legend style="margin:10px 0" data-target="#user-notification"><i class="icon-envelope"></i> &nbsp; {{ "Notification par email" | trans }}&nbsp; <a style="font-size: 11px;" href="#">({{ "edit" | trans }})</a></legend>
<label class="form_label control-label" for="form_gender"><strong>{{ "admin::compte-utilisateur sexe" | trans }}</strong></label> <div id="user-notification" class="form-info" style="display:none">
<div class="controls"> {% for notification_group, nots in notifications%}
<select name="form_gender" class="input-xlarge"> <div class="control-group">
<option value=""></option> <span class="pull-left"><strong>{{ notification_group }}</strong></span>
<option {% if app["authentication"].getUser().getGender() == "0" %}selected{% endif %} value="0" > <div class="controls">
{{ "admin::compte-utilisateur:sexe: mademoiselle" | trans }} <ul class="unstyled well">
</option> {% for notification in nots %}
<option {% if app["authentication"].getUser().getGender() == "1" %}selected{% endif %} value="1" > <li>
{{ "admin::compte-utilisateur:sexe: madame" | trans }} <label class="checkbox" for="notif_{{ notification["id"] }}">
</option> <input type="checkbox" id="notif_{{ notification["id"] }}" name="notifications[{{ notification["id"] }}]" {% if app['settings'].getUserNotificationSetting(app["authentication"].getUser(), notification["id"]) %}checked{% endif %} value="1"/>
<option {% if app["authentication"].getUser().getGender() == "2" %}selected{% endif %} value="2" > {{ notification["description"] }}
{{ "admin::compte-utilisateur:sexe: monsieur" | trans }} </label>
</option> <p class="form_alert help-block"></p>
</select> </li>
<p class="form_alert help-block"></p> {% endfor %}
</div> </ul>
</div> </div>
<div class="control-group"> </div>
<label class="form_label control-label" for="form_lastname"><strong>{{ "admin::compte-utilisateur nom" | trans }}</strong></label> {% endfor %}
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_lastname" id="form_lastname" value="{{ app["authentication"].getUser().getLastName() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_firstname"><strong>{{ "admin::compte-utilisateur prenom" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_firstname" id="form_firstname" value="{{ app["authentication"].getUser().getFirstName() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_firstname"><strong>{{ "admin::compte-utilisateur email" | trans }}</strong></label>
<div class="controls">
<span class="control-span">{{ app["authentication"].getUser().getEmail() }} <a href="{{ path("account_reset_email") }}" target="_self">{{ "login:: Changer mon adresse email" | trans }}</a></span>
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="control-label"><strong>{{ "Password" | trans }}</strong></label>
<div class="controls">
<span class="control-span"><a href="{{ path("reset_password") }}" target="_self">{{ "admin::compte-utilisateur changer mon mot de passe" | trans }}</a></span>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_address"><strong>{{ "admin::compte-utilisateur adresse" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_address" id="form_address" value="{{ app["authentication"].getUser().getAddress() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_zip"><strong>{{ "admin::compte-utilisateur code postal" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_zip" id="form_zip" value="{{ app["authentication"].getUser().getZipCode() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_city"><strong>{{ "admin::compte-utilisateur ville" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge geoname_field" type="text" name="form_geonameid" id="form_geonameid" value="{{ app["authentication"].getUser().getGeonameId() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_function"><strong>{{ "admin::compte-utilisateur poste" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_function" id="form_function" value="{{ app["authentication"].getUser().getActivity() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_company"><strong>{{ "admin::compte-utilisateur societe" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_company" id="form_company" value="{{ app["authentication"].getUser().getCompany() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_activity"><strong>{{ "admin::compte-utilisateur activite" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_activity" id="form_activity" value="{{ app["authentication"].getUser().getJob() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_phone"><strong>{{ "admin::compte-utilisateur telephone" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_phone" id="form_phone" value="{{ app["authentication"].getUser().getPhone() }}" />
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_fax"><strong>{{ "admin::compte-utilisateur fax" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_fax" id="form_fax" value="{{ app["authentication"].getUser().getFax() }}" />
<p class="form_alert help-block"></p>
</div>
</div> </div>
<legend style="margin:10px 0;border:none" data-target="#user-ftp"><i class="icon-globe"></i> &nbsp; {{ "FTP" | trans }}&nbsp; <a style="font-size: 11px;" href="#">({{ "edit" | trans }})</a></legend>
<div id="user-ftp" class="form-info" style="display:none">
{% set ftpCredential = app["authentication"].getUser().getFtpCredential() %}
<legend>{{ "Notification par email" | trans }}</legend> {% if ftpCredential is not none %}
<div class="control-group">
<div class="controls">
<label class="form_label checkbox" for="form_activeFTP">{{ "admin::compte-utilisateur:ftp: Activer le compte FTP" | trans }}
<input class="input_element input-xlarge" type="checkbox" name="form_activeFTP" id="form_activeFTP" {% if ftpCredential.isActive() %}checked{% endif %} onchange="if(this.checked){$('#ftpinfos').slideDown();}else{$('#ftpinfos').slideUp();}" />
</label>
<p class="form_alert help-block"></p>
</div>
</div>
{% endif %}
{% for notification_group, nots in notifications%} <div id="ftpinfos" style="display:{% if ftpCredential is none or ftpCredential.isActive() %}block{% else %}none{% endif %}">
<div class="control-group"> <div class="control-group">
<span class="pull-left"><strong>{{ notification_group }}</strong></span> <label class="form_label control-label" for="form_addressFTP"><strong>{{ "phraseanet:: adresse" | trans }}</strong></label>
<div class="controls"> <div class="controls">
<ul class="unstyled well"> <input class="input_element input-xlarge" type="text" name="form_addressFTP" id="form_addressFTP" value="{{ ftpCredential is not none ? ftpCredential.getAddress() : '' }}" />
{% for notification in nots %} <p class="form_alert help-block"></p>
<li> </div>
<label class="checkbox" for="notif_{{ notification["id"] }}">
<input type="checkbox" id="notif_{{ notification["id"] }}" name="notifications[{{ notification["id"] }}]" {% if app['settings'].getUserNotificationSetting(app["authentication"].getUser(), notification["id"]) %}checked{% endif %} value="1"/>
{{ notification["description"] }}
</label>
<p class="form_alert help-block"></p>
</li>
{% endfor %}
</ul>
</div> </div>
</div> <div class="control-group">
{% endfor %} <label class="form_label control-label" for="form_loginFTP"><strong>{{ "admin::compte-utilisateur identifiant" | trans }}</strong></label>
<div class="controls">
<legend>{{ "FTP" | trans }}</legend> <input class="input_element input-xlarge" type="text" name="form_loginFTP" id="form_loginFTP" value="{{ ftpCredential is not none ? ftpCredential.getLogin() : '' }}" />
<p class="form_alert help-block"></p>
{% set ftpCredential = app["authentication"].getUser().getFtpCredential() %} </div>
{% if ftpCredential is not none %}
<div class="control-group">
<div class="controls">
<label class="form_label checkbox" for="form_activeFTP">{{ "admin::compte-utilisateur:ftp: Activer le compte FTP" | trans }}
<input class="input_element input-xlarge" type="checkbox" name="form_activeFTP" id="form_activeFTP" {% if ftpCredential.isActive() %}checked{% endif %} onchange="if(this.checked){$('#ftpinfos').slideDown();}else{$('#ftpinfos').slideUp();}" />
</label>
<p class="form_alert help-block"></p>
</div> </div>
</div> <div class="control-group">
{% endif %} <label class="form_label control-label" for="form_pwdFTP"><strong>{{ "admin::compte-utilisateur mot de passe" | trans }}</strong></label>
<div class="controls">
<div id="ftpinfos" style="display:{% if ftpCredential is none or ftpCredential.isActive() %}block{% else %}none{% endif %}"> <input class="input_element input-xlarge" type="text" name="form_pwdFTP" id="form_pwdFTP" value="{{ ftpCredential is not none ? ftpCredential.getPassword() : '' }}" />
<div class="control-group"> <p class="form_alert help-block"></p>
<label class="form_label control-label" for="form_addressFTP"><strong>{{ "phraseanet:: adresse" | trans }}</strong></label> </div>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_addressFTP" id="form_addressFTP" value="{{ ftpCredential is not none ? ftpCredential.getAddress() : '' }}" />
<p class="form_alert help-block"></p>
</div> </div>
</div> <div class="control-group">
<div class="control-group"> <label class="form_label control-label" for="form_destFTP"><strong>{{ "admin::compte-utilisateur:ftp: repertoire de destination ftp" | trans }}</strong></label>
<label class="form_label control-label" for="form_loginFTP"><strong>{{ "admin::compte-utilisateur identifiant" | trans }}</strong></label> <div class="controls">
<div class="controls"> <input class="input_element input-xlarge" type="text" name="form_destFTP" id="form_destFTP" value="{{ ftpCredential is not none ? ftpCredential.getReceptionFolder() : '' }}" />
<input class="input_element input-xlarge" type="text" name="form_loginFTP" id="form_loginFTP" value="{{ ftpCredential is not none ? ftpCredential.getLogin() : '' }}" /> <p class="form_alert help-block"></p>
<p class="form_alert help-block"></p> </div>
</div> </div>
</div> <div class="control-group">
<div class="control-group"> <label class="form_label control-label" for="form_prefixFTPfolder"><strong>{{ "admin::compte-utilisateur:ftp: prefixe des noms de dossier ftp" | trans }}</strong></label>
<label class="form_label control-label" for="form_pwdFTP"><strong>{{ "admin::compte-utilisateur mot de passe" | trans }}</strong></label> <div class="controls">
<div class="controls"> <input class="input_element input-xlarge" type="text" name="form_prefixFTPfolder" id="form_prefixFTPfolder" value="{{ ftpCredential is not none ? ftpCredential.getRepositoryPrefixName() : '' }}" />
<input class="input_element input-xlarge" type="text" name="form_pwdFTP" id="form_pwdFTP" value="{{ ftpCredential is not none ? ftpCredential.getPassword() : '' }}" /> <p class="form_alert help-block"></p>
<p class="form_alert help-block"></p> </div>
</div> </div>
</div> <div class="control-group">
<div class="control-group"> <div class="controls">
<label class="form_label control-label" for="form_destFTP"><strong>{{ "admin::compte-utilisateur:ftp: repertoire de destination ftp" | trans }}</strong></label> <label class="form_label checkbox" for="form_passifFTP">
<div class="controls"> {{ "admin::compte-utilisateur:ftp: Utiliser le mode passif" | trans }}
<input class="input_element input-xlarge" type="text" name="form_destFTP" id="form_destFTP" value="{{ ftpCredential is not none ? ftpCredential.getReceptionFolder() : '' }}" /> <input class="input_element input-xlarge" type="checkbox" name="form_passifFTP" id="form_passifFTP" {% if ftpCredential is not none and ftpCredential.isPassive() %}checked{% endif %} />
<p class="form_alert help-block"></p> </label>
<p class="form_alert help-block"></p>
</div>
</div> </div>
</div> <div class="control-group">
<div class="control-group"> <label class="form_label control-label" for="form_retryFTP"><strong>{{ "admin::compte-utilisateur:ftp: Nombre d\'essais max" | trans }}</strong></label>
<label class="form_label control-label" for="form_prefixFTPfolder"><strong>{{ "admin::compte-utilisateur:ftp: prefixe des noms de dossier ftp" | trans }}</strong></label> <div class="controls">
<div class="controls"> <input class="input_element input-xlarge" type="text" name="form_retryFTP" id="form_retryFTP" value="{{ ftpCredential is not none ? ftpCredential.getMaxRetry() : '' }}" />
<input class="input_element input-xlarge" type="text" name="form_prefixFTPfolder" id="form_prefixFTPfolder" value="{{ ftpCredential is not none ? ftpCredential.getRepositoryPrefixName() : '' }}" /> <p class="form_alert help-block"></p>
<p class="form_alert help-block"></p> </div>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="form_label checkbox" for="form_passifFTP">
{{ "admin::compte-utilisateur:ftp: Utiliser le mode passif" | trans }}
<input class="input_element input-xlarge" type="checkbox" name="form_passifFTP" id="form_passifFTP" {% if ftpCredential is not none and ftpCredential.isPassive() %}checked{% endif %} />
</label>
<p class="form_alert help-block"></p>
</div>
</div>
<div class="control-group">
<label class="form_label control-label" for="form_retryFTP"><strong>{{ "admin::compte-utilisateur:ftp: Nombre d\'essais max" | trans }}</strong></label>
<div class="controls">
<input class="input_element input-xlarge" type="text" name="form_retryFTP" id="form_retryFTP" value="{{ ftpCredential is not none ? ftpCredential.getMaxRetry() : '' }}" />
<p class="form_alert help-block"></p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="form-actions"> <div class="well well-large" style="border: 1px solid #333333;">
<input type="submit" class="btn btn-info btn-" value="{{ "boutton::valider" | trans }}"> <div style="max-width: 400px;margin-left: 52px">
<input type="submit" class="btn btn-info btn-block btn-large" value="{{ 'boutton::valider' | trans }}"/>
</div>
</div> </div>
</div> </div>
</form> </form>

View File

@@ -4,7 +4,7 @@
{% extends "common/index_bootstrap.html.twig" %} {% extends "common/index_bootstrap.html.twig" %}
{% block stylesheet %} {% block stylesheet %}
<link rel="stylesheet" type="text/css" href="{{ path('minifier', { 'f' : 'skins/build/account.css,include/jslibs/jquery.contextmenu.css' }) }}"/> <link rel="stylesheet" type="text/css" href="{{ path('minifier', { 'f' : 'assets/build/account.css,include/jslibs/jquery.contextmenu.css' }) }}"/>
<style type="text/css"> <style type="text/css">
.context-menu-theme-vista .context-menu-item .context-menu-item-inner { .context-menu-theme-vista .context-menu-item .context-menu-item-inner {
padding: 4px 20px; padding: 4px 20px;

View File

@@ -16,7 +16,7 @@
<div class="row-fluid"> <div class="row-fluid">
<div class="span12"> <div class="span12">
{{ auth_macro.flashes() }} {{ auth_macro.flashes() }}
<form method="POST" action="{{ path("reset_email") }}" id="mainform" name="changeEmail" class="form-horizontal"> <form method="POST" action="{{ path("reset_email") }}" id="mainform" name="changeEmail" class="form-horizontal" style="background: #191919;border: 1px solid #333333;padding-top:20px">
<div class="control-group"> <div class="control-group">
<label class="control-label" for="form_login">{{ "admin::compte-utilisateur identifiant" | trans }}</label> <label class="control-label" for="form_login">{{ "admin::compte-utilisateur identifiant" | trans }}</label>
<div class="controls"> <div class="controls">
@@ -44,13 +44,14 @@
<div class="error-view"></div> <div class="error-view"></div>
</div> </div>
</div> </div>
<div class="form-actions" style="background-color: transparent;"> <div style="max-width: 400px;margin-left: 220px">
<input type="submit" class="btn btn-success" value="{{ "boutton::valider" | trans }}" style="margin: 20px auto;" /> <input type="submit" class="btn btn-success btn-medium" value="{{ "boutton::valider" | trans }}" style="margin: 20px auto;" />
<input type="button" class="btn" value="{{ "boutton::annuler" | trans }}" onclick="self.location.replace('/account/');" /> <input type="button" class="btn" value="{{ "boutton::annuler" | trans }}" onclick="self.location.replace('/account/');" />
</div> </div>
</form> </form>
<div class="well well-small alert-info"> <div class="well well-small alert-info">
{{ "admin::compte-utilisateur: Pourquoi me demande-t-on mon mot de passe pour changer mon adresse email ?" | trans }} <i class="icon icon-info-sign"></i> &nbsp;
<b>{{ "admin::compte-utilisateur: Pourquoi me demande-t-on mon mot de passe pour changer mon adresse email ?" | trans }}</b>
<br /> <br />
{{ "admin::compte-utilisateur: Votre adresse e-mail sera utilisee lors de la perte de votre mot de passe afin de pouvoir le reinitialiser, il est important que vous soyez la seule personne a pouvoir la changer." | trans }} {{ "admin::compte-utilisateur: Votre adresse e-mail sera utilisee lors de la perte de votre mot de passe afin de pouvoir le reinitialiser, il est important que vous soyez la seule personne a pouvoir la changer." | trans }}
</div> </div>

View File

@@ -9,23 +9,25 @@
{% block content_account %} {% block content_account %}
<div class="row-fluid"> <div class="row-fluid">
<div class="span12"> <div class="span12">
<div class="well well-small alert-info"> <div class="well well-small" style="background: steelblue; border: 1px solid #333;">
{% trans %}If you notice any unfamiliar devices or locations, click 'End Activity' to end the session.{% endtrans %} {% set end_activity = "End Activity"|trans %}
{% set button = '&nbsp;<a href="#" class="btn btn-inverse btn-small" style="box-shadow:none">'~end_activity~'</a>&nbsp;'|raw %}
<i class="icon icon-warning-sign"></i>&nbsp;<b style="font-size: 12px;">{% trans with {'%button%': button}%}If you notice any unfamiliar devices or locations, click on button %button% to end the session.{% endtrans %}</b>
</div> </div>
<table class="table table-striped"> <table class="table table-striped table-bordered" style="border-color: #333333">
<thead> <thead>
<tr> <tr>
<th></th> <th style="border-color: #333333"></th>
<th> <th style="border-color: #333333">
{{ 'Date de connexion' | trans }} {{ 'Date de connexion' | trans }}
</th> </th>
<th> <th style="border-color: #333333">
{{ 'Dernier access' | trans }} {{ 'Dernier access' | trans }}
</th> </th>
<th> <th style="border-color: #333333">
{{ 'IP' | trans }} {{ 'IP' | trans }}
</th> </th>
<th> <th style="border-color: #333333">
{{ 'Browser' | trans }} {{ 'Browser' | trans }}
</th> </th>
</tr> </tr>
@@ -33,25 +35,25 @@
<tbody> <tbody>
{% for session in sessions %} {% for session in sessions %}
{% set row = session['session'] %} {% set row = session['session'] %}
<tr id="row-{{ row.Id() }}"> <tr id="row-{{ row.Id() }}" >
<td> <td style="border-color: #333333;text-align: center">
{% if app['session'].get('session_id') != row.Id() %} {% if app['session'].get('session_id') != row.Id() %}
<a href="{{ path('delete_session', {"id": row.Id()}) }}" title="{% trans %}End Activity{% endtrans %}" class="btn btn-inverse btn-small delete-session"><i class="icon-remove"> {% trans %}End Activity{% endtrans %}</i></a> <a href="{{ path('delete_session', {"id": row.Id()}) }}" title="{% trans %}End Activity{% endtrans %}" class="btn btn-inverse btn-small input-block-level delete-session">{% trans %}End Activity{% endtrans %}</a>
{% else %} {% else %}
{{ 'Current session' | trans }} <span style="color:darkseagreen;font-weight: bold">{{ 'Current session' | trans }}</span>
{% endif %} {% endif %}
</td> </td>
<td> <td style="border-color: #333333">
{{ app['date-formatter'].getDate(row.getCreated()) }} {{ app['date-formatter'].getDate(row.getCreated()) }}
</td> </td>
<td> <td style="border-color: #333333">
{{ app['date-formatter'].getDate(row.getUpdated()) }} {{ app['date-formatter'].getDate(row.getUpdated()) }}
</td> </td>
<td> <td style="border-color: #333333">
{{ row.getIpAddress() }} {{ row.getIpAddress() }}
{{ session['info'] }} {{ session['info'] }}
</td> </td>
<td> <td style="border-color: #333333">
{{ row.getBrowserName() }} {{ row.getBrowserVersion() }} {{ row.getBrowserName() }} {{ row.getBrowserVersion() }}
</td> </td>
</tr> </tr>

View File

@@ -35,7 +35,7 @@
dataType: 'json', dataType: 'json',
data: { data: {
module : 3, module : 3,
usr : {{ app['authentication'].getUser().get_id() }} usr : {{ app['authentication'].getUser().getId() }}
}, },
error: function(){ error: function(){
window.setTimeout("pollNotifications();", 10000); window.setTimeout("pollNotifications();", 10000);
@@ -44,14 +44,14 @@
window.setTimeout("pollNotifications();", 10000); window.setTimeout("pollNotifications();", 10000);
}, },
success: function(data){ success: function(data){
if(data) if (data) {
manageSession(data); manageSession(data);
}
var t = 120000; var t = 120000;
if(data.apps && parseInt(data.apps)>1) if (data.apps && parseInt(data.apps) > 1) {
t = Math.round((Math.sqrt(parseInt(data.apps)-1) * 1.3 * 120000)); t = Math.round((Math.sqrt(parseInt(data.apps)-1) * 1.3 * 120000));
}
window.setTimeout("pollNotifications();", t); window.setTimeout("pollNotifications();", t);
return;
} }
}); });
} }
@@ -79,106 +79,82 @@
reset_template_ask_choice: '{{ 'Would you like to reset rights before applying the template?' | trans | e('js') }}' reset_template_ask_choice: '{{ 'Would you like to reset rights before applying the template?' | trans | e('js') }}'
}; };
$(document).ready(function(){ //
$(window).bind('resize',function(){resize();}); // function enableFormsCallback(datas)
resize(); // {
}); // $('#right-ajax').removeClass('loading').html(datas);
} // enableForms($('#right-ajax form:not(.no-ajax)'));
//
// $.each($('#right-ajax a:not(.no-ajax)'),function(i, el){
// enableLink($(el));
// });
// return;
// }
//
// function enableLink(link) {
// $(link).bind('click',function(event){
// var dest = link.attr('href');
//
// if(dest && dest.indexOf('#') !== 0) {
// $('#right-ajax').empty().addClass('loading').parent().show();
//
// $.get(dest, function(data) {
// enableFormsCallback(data);
// });
// }
// });
// }
function enableFormsCallback(datas) // function activeTree(click) {
{ // $('#FNDR').treeview({
$('#right-ajax').removeClass('loading').html(datas); // collapsed: true,
enableForms($('#right-ajax form:not(.no-ajax)')); // animated: "medium"
// });
//
// $.each($('#tree a[target=right]'),function(){
// var dest = $(this).attr('href');
//
// $(this).bind('click',function(){
// $('#right-ajax').empty().addClass('loading').parent().show();
//
// $.get(dest, function(data) {
// enableFormsCallback(data);
// });
//
// $('#tree .selected').removeClass('selected');
// $(this).parent().addClass('selected');
//
// return false;
// });
//
// $(this).removeAttr('target');
// });
//
// if(click === true) {
// if($('#tree .selected').length > 0)
// $('#tree .selected a').trigger('click');
// else
// $('.zone_online_users').trigger('click');
// }
// }
$.each($('#right-ajax a:not(.no-ajax)'),function(i, el){ $(window).bind('resize',function(){resize();});
enableLink($(el));
});
return;
}
function enableLink(link) {
$(link).bind('click',function(event){
var dest = link.attr('href');
if(dest && dest.indexOf('#') !== 0) {
$('#right-ajax').empty().addClass('loading').parent().show();
$.get(dest, function(data) {
enableFormsCallback(data);
});
return false;
}
});
}
function activeTree(click)
{
$('#FNDR').treeview({
collapsed: true,
animated: "medium"
});
$.each($('#tree a[target=right]'),function(){
var dest = $(this).attr('href');
$(this).bind('click',function(){
$('#right-ajax').empty().addClass('loading').parent().show();
$.get(dest, function(data) {
enableFormsCallback(data);
});
$('#tree .selected').removeClass('selected');
$(this).parent().addClass('selected');
return false;
});
$(this).removeAttr('target');
});
if(click === true)
{
if($('#tree .selected').length > 0)
$('#tree .selected a').trigger('click');
else
$('.zone_online_users').trigger('click');
}
}
$(document).ready(
function(){
resize();
setTimeout('pollNotifications();',15000);
activeTree(true);
}
);
function resize()
{
bodySize.y = $(window).height() - $('#mainMenu').outerHeight();
bodySize.x = $(window).width();
}
$(window).bind('resize',function(){resize();});
function reloadTree(position, click){
$.ajax({
type: "GET",
url: "/admin/tree/",
data: {
position : position
},
success: function(datas){
$('#FNDR').empty().append(datas);
activeTree(click);
return;
}
});
}
// function reloadTree(position, click){
// $.ajax({
// type: "GET",
// url: "/admin/tree/",
// data: {
// position : position
// },
// success: function(datas){
// $('#FNDR').empty().append(datas);
// activeTree(click);
//
// return;
// }
// });
// }
</script> </script>
<script type="text/javascript" src="{{ path('minifier', { 'f' : '/assets/requirejs/require.js,/scripts/apps/admin/require.config.js,/scripts/apps/admin/main/main.js' }) }}"></script> <script type="text/javascript" src="{{ path('minifier', { 'f' : '/assets/requirejs/require.js,/scripts/apps/admin/require.config.js,/scripts/apps/admin/main/main.js' }) }}"></script>
{% endblock %} {% endblock %}

View File

@@ -1,60 +1,62 @@
<div class="page-header"> <div id="admin_setup_registry">
<h1>{{ 'Setup' | trans }}</h1> <div class="page-header">
</div> <h1>{{ 'Setup' | trans }}</h1>
<form class="form-horizontal" id="GV_form_head">
<div class="control-group">
<label class="control-label">Adresse : </label>
<div class="controls">
<input type="text" class="input-xxlarge" readonly="readonly" value="{{ app['conf'].get('servername') }}" />
</div>
</div> </div>
<div class="control-group">
<label class="control-label">Installation : </label>
<div class="controls">
<input type="text" class="input-xxlarge" readonly="readonly" value="{{ app['root.path'] }}" />
</div>
</div>
<div class="control-group">
<label class="control-label">Maintenance : </label>
<div class="controls">
<input type="checkbox" readonly="readonly" disabled="disabled"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Debug : </label>
<div class="controls">
<input type="checkbox" readonly="readonly" disabled="disabled" {{ app['debug'] ? "checked='checked'" : '' }} />
</div>
</div>
</form>
<form class="form-horizontal" id="GV_form_head">
{{ form_start(form, {'method': 'POST', 'action' : path('setup_display_globals'), 'attr': {'class' : 'form-horizontal'}}) }}
{% for daform in form %}
<fieldset>
<legend>{{ daform.vars['label'] }}</legend>
{% for formdata in daform %}
<div class="control-group"> <div class="control-group">
{{ form_label(formdata, null, { 'label_attr': {'class' : 'control-label'} } ) }} <label class="control-label">Adresse : </label>
<div class="controls"> <div class="controls">
{{ form_widget(formdata, {'attr': {'class': 'input-xxlarge'}}) }} <input type="text" class="input-xxlarge" readonly="readonly" value="{{ app['conf'].get('servername') }}" />
</div> </div>
<div>{{ formdata.vars['help_message'] }}</div>
{{ form_rest(formdata) }}
</div> </div>
{% endfor %} <div class="control-group">
{{ form_rest(daform) }} <label class="control-label">Installation : </label>
</fieldset> <div class="controls">
{% endfor %} <input type="text" class="input-xxlarge" readonly="readonly" value="{{ app['root.path'] }}" />
<div class="well well-large"> </div>
<div style="max-width: 400px;margin: 0 auto 10px;"> </div>
<input type="submit" class="btn btn-warning btn-block btn-large" value="{{ 'boutton::valider' | trans }}"/> <div class="control-group">
<label class="control-label">Maintenance : </label>
<div class="controls">
<input type="checkbox" readonly="readonly" disabled="disabled"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Debug : </label>
<div class="controls">
<input type="checkbox" readonly="readonly" disabled="disabled" {{ app['debug'] ? "checked='checked'" : '' }} />
</div>
</div>
</form>
{{ form_start(form, {'method': 'POST', 'action' : path('setup_display_globals'), 'attr': {'class' : 'form-horizontal'}}) }}
{% for daform in form %}
<fieldset>
<legend>{{ daform.vars['label'] }}</legend>
{% for formdata in daform %}
<div class="control-group">
{{ form_label(formdata, null, { 'label_attr': {'class' : 'control-label'} } ) }}
<div class="controls">
{{ form_widget(formdata, {'attr': {'class': 'input-xxlarge'}}) }}
</div>
<div class="help-message text-info">{{ formdata.vars['help_message'] | raw }}</div>
{{ form_rest(formdata) }}
</div>
{% endfor %}
{{ form_rest(daform) }}
</fieldset>
{% endfor %}
<div class="well well-large">
<div style="max-width: 400px;margin: 0 auto 10px;">
<input type="submit" class="btn btn-warning btn-block btn-large" value="{{ 'boutton::valider' | trans }}"/>
</div>
</div> </div>
{{ form_end(form) }}
</div> </div>
{{ form_end(form) }}
<script type='text/javascript'> <script type='text/javascript'>
{% autoescape false %} {% autoescape false %}

View File

@@ -130,7 +130,8 @@
</li> </li>
<li> <li>
<a target="right" href="{{ path('admin_database_display_cgus', { 'databox_id' : sbas_id } ) }}" class="ajax"> <a target="right" href="{{ path('admin_database_display_cgus', { 'databox_id' : sbas_id } ) }}" class="ajax">
<span>{{ 'admin:: CGUs' | trans }}</span> <img src="/skins/icons/miniadjust02.gif"/>
<span>{{ 'Terms of use' | trans }}</span>
</a> </a>
</li> </li>
<li> <li>
@@ -186,7 +187,7 @@
</li> </li>
{% endif %} {% endif %}
{% if app['acl'].get(app['authentication'].getUser()).has_right_on_base( collection.get_base_id(), 'canadmin')) %} {% if app['acl'].get(app['authentication'].getUser()).has_right_on_base(collection.get_base_id(), 'canadmin') %}
<li> <li>
<a target="right" href="{{ path('admin_users_search', { 'base_id' : [ collection.get_base_id() ] }) }}" class="ajax"> <a target="right" href="{{ path('admin_users_search', { 'base_id' : [ collection.get_base_id() ] }) }}" class="ajax">
<img src="/skins/admin/Users.png"/> <img src="/skins/admin/Users.png"/>

View File

@@ -1,17 +1,20 @@
{% import 'common/macros.html.twig' as macro %} {% import 'common/macros.html.twig' as macro %}
{% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'canmodifrecord')|default(false) %} {% set business = false %}
{% if app['authentication'].getUser() is not none %}
{% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
{% endif %}
{% if view == 'answer' %} {% if view == 'answer' %}
{{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), searchOptions|default(null), business, false, true) }} {{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, false, true) }}
{% elseif view == 'lazaret' %} {% elseif view == 'lazaret' %}
{{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), searchOptions|default(null), business, true, true) }} {{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, true, true) }}
{% elseif view == 'preview' %} {% elseif view == 'preview' %}
{{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), searchOptions|default(null), business, true, false) }} {{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, true, false) }}
{% elseif view == 'basket' %} {% elseif view == 'basket' %}
{{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), searchOptions|default(null), business, true, false) }} {{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, true, false) }}
{% elseif view == 'overview' %} {% elseif view == 'overview' %}
{{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), searchOptions|default(null), business, false, false) }} {{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, false, false) }}
{% elseif view == 'publi' %} {% elseif view == 'publi' %}
{{ macro.format_caption(record, '', null, business, true, true) }} {{ macro.format_caption(record, '', null, business, true, true) }}
{% endif %} {% endif %}

View File

@@ -110,7 +110,7 @@
{% endif %} {% endif %}
{{ _self.caption_field(field, bounceable|default(true), extra_classes) }} {{ _self.caption_field(field, bounceable|default(true), extra_classes) }}
{% endfor %} {% endfor %}
{% if technical_data|default(true) and app['authentication'].getUser() is not none and app['authentication'].getUser().getPrefs('technical_display') == 'group' %} {% if technical_data|default(true) and app['authentication'].getUser() is not none and app['settings'].getUserSetting(app['authentication'].getUser(), 'technical_display') == 'group' %}
<hr/> <hr/>
{% include 'common/technical_datas.html.twig' %} {% include 'common/technical_datas.html.twig' %}
{% endif %} {% endif %}

View File

@@ -67,21 +67,21 @@
> >
</td> </td>
</tr> </tr>
{% if application.get_type() == constant("API_OAuth2_Application::WEB_TYPE") %} {% if application.getType() == constant("WEB_TYPE", application) %}
<tr> <tr>
<td> <td>
{% trans "Define a webhook URL" %} {{ "Define a webhook URL" | trans }}
<p style="font-size: 10px;max-width: 450px"> <p style="font-size: 10px;max-width: 450px">
{% trans "Gives the option to your application to communicate with Phraseanet. This webhook can be used to trigger some actions on your application side." %} {{ "Gives the option to your application to communicate with Phraseanet. This webhook can be used to trigger some actions on your application side." | trans }}
</p> </p>
</td> </td>
<td class="url_callback"> <td class="url_callback">
<span class="url_webhook_input">{{ application.getWebhook() }}</span> <span class="url_webhook_input">{{ application.getWebhookUrl() }}</span>
<a href="{{ path("submit_application_webhook", {"id" : application.get_id()}) }}" class="save_webhook btn btn-small btn-info" style="display:none;"> <a href="{{ path("submit_application_webhook", {"application" : application.getId()}) }}" class="save_webhook btn btn-small btn-info" style="display:none;">
{% trans "Save" %} {{ "Save" | trans }}
</a> </a>
<button type="button" class="webhook-modify-btn btn btn-small"> <button type="button" class="webhook-modify-btn btn btn-small">
{% trans "Modify" %} {{ "Modify" | trans }}
</button> </button>
</td> </td>
</tr> </tr>

View File

@@ -83,21 +83,12 @@
<div class="lightbox_container"> <div class="lightbox_container">
{% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(first_item.getRecord(app).get_base_id(), 'canmodifrecord') %} {% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(first_item.getRecord(app).get_base_id(), 'canmodifrecord') %}
{% if first_item %} {% if first_item %}
{{caption.format_caption(first_item.get_record(), '', null null, business, false, fals)}} {{macro.format_caption(first_item.getRecord(app), '', null, business, false, false)}}
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="innerBottom" style="position:relative;bottom:0;width:100%;height:196px;"> <div id="innerBottom" style="position:relative;bottom:0;width:100%;height:196px;">
<div class="" style="height:30px;width:100%;"> <div class="" style="height:30px;width:100%;">

View File

@@ -11,7 +11,6 @@
{% set basket_element = basket.getElements().first() %} {% set basket_element = basket.getElements().first() %}
<div id="innerWrapper" style="top:10px;left:10px;position:relative;width:100%;height:100%;"> <div id="innerWrapper" style="top:10px;left:10px;position:relative;width:100%;height:100%;">
<div id="innerTop" style="bottom:186px;position:relative;bottom:0;width:100%;"> <div id="innerTop" style="bottom:186px;position:relative;bottom:0;width:100%;">
<div id="record_wrapper" class="single PNBleft" style="overflow:hidden;"> <div id="record_wrapper" class="single PNBleft" style="overflow:hidden;">
<div id="record_main" class="record_display_box PNBleft" style=""> <div id="record_main" class="record_display_box PNBleft" style="">
<div class="header ui-widget-header ui-corner-all left"> <div class="header ui-widget-header ui-corner-all left">
@@ -95,7 +94,7 @@
<div class="lightbox_container"> <div class="lightbox_container">
{% if basket_element %} {% if basket_element %}
{% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(basket_element.getRecord(app).get_base_id(), 'canmodifrecord') %} {% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(basket_element.getRecord(app).get_base_id(), 'canmodifrecord') %}
{{caption.format_caption(basket_element.getRecord(app), '', null, null, business, false, false)}} {{macro.format_caption(basket_element.getRecord(app), '', null, business, false, false)}}
{% endif %} {% endif %}
</div> </div>
</div> </div>
@@ -109,15 +108,6 @@
</div> </div>
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div id="innerBottom" style="position:relative;bottom:0;width:100%;height:196px;"> <div id="innerBottom" style="position:relative;bottom:0;width:100%;height:196px;">
<div class="" style="height:30px;width:100%;"> <div class="" style="height:30px;width:100%;">

View File

@@ -12,8 +12,6 @@
href="{{ path('minifier', { 'f' : 'skins/lightbox/lightbox.css' }) }}" media="screen"/> href="{{ path('minifier', { 'f' : 'skins/lightbox/lightbox.css' }) }}" media="screen"/>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="PNB10"> <div class="PNB10">
<div class="PNB" id="top_container"> <div class="PNB" id="top_container">
@@ -83,7 +81,7 @@
<div class="lightbox_container PNB"> <div class="lightbox_container PNB">
{% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(first_item.getRecord(app).get_base_id(), 'canmodifrecord') %} {% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(first_item.getRecord(app).get_base_id(), 'canmodifrecord') %}
{% if first_item %} {% if first_item %}
{{caption.format_caption(first_item.getRecord(app), '', null, null, business, false, false)}} {{macro.format_caption(first_item.getRecord(app), '', null, business, false, false)}}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@@ -12,11 +12,8 @@
href="{{ path('minifier', { 'f' : 'include/jslibs/jquery.contextmenu.css,skins/lightbox/lightbox.css' }) }}" media="screen"/> href="{{ path('minifier', { 'f' : 'include/jslibs/jquery.contextmenu.css,skins/lightbox/lightbox.css' }) }}" media="screen"/>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% set basket_element = basket.getElements().first() %} {% set basket_element = basket.getElements().first() %}
<div class="PNB10"> <div class="PNB10">
<div class="PNB" id="top_container"> <div class="PNB" id="top_container">
<div id="record_wrapper" class="PNB single" style="right:250px;"> <div id="record_wrapper" class="PNB single" style="right:250px;">
@@ -98,7 +95,7 @@
<div class="lightbox_container PNB"> <div class="lightbox_container PNB">
{% if basket_element %} {% if basket_element %}
{% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(basket_element.getRecord(app).get_base_id(), 'canmodifrecord') %} {% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(basket_element.getRecord(app).get_base_id(), 'canmodifrecord') %}
{{caption.format_caption(basket_element.getRecord(app), '', null, null, business, false, false)}} {{macro.format_caption(basket_element.getRecord(app), '', null, business, false, false)}}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@@ -13,7 +13,7 @@
</div> </div>
{% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'canmodifrecord') %} {% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
{% if record.is_from_reg() %} {% if record.is_from_reg() %}
{{caption.format_caption(record, '', null, null, business, false, true)}} {{macro.format_caption(record, '', null, null, business, false, true)}}
{% else %} {% else %}
{{caption.format_caption(record, highlight, searchEngine, searchOptions, business, false, true)}} {{macro.format_caption(record, highlight, searchEngine, business, false, true)}}
{% endif %} {% endif %}

View File

@@ -154,7 +154,7 @@
{% trans %}Accuse de reception{% endtrans %} {% trans %}Accuse de reception{% endtrans %}
</label> </label>
</div> </div>
{% if app['phraseanet.registry'].get('GV_force_push_authentication') %} {% if app['conf'].get(['registry', 'actions', 'force-authentication']) %}
<div class="control-group"> <div class="control-group">
<label for="PushForceAuthentication" class="checkbox"> <label for="PushForceAuthentication" class="checkbox">
<input id="PushForceAuthentication" type="checkbox" checked="checked" name="force_authentication" value="1"/> <input id="PushForceAuthentication" type="checkbox" checked="checked" name="force_authentication" value="1"/>

View File

@@ -114,7 +114,7 @@
}, },
success: function(data){ success: function(data){
if(data && typeof(data.status) && data.status == "disconnected") { if(data && typeof(data.status) && data.status == "disconnected") {
alert("{% trans 'phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier' %}"); alert("{{ 'phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier' | trans }}");
self.location.replace(self.location.href); self.location.replace(self.location.href);
} }
//if(manageSession(data)) //if(manageSession(data))

View File

@@ -172,25 +172,27 @@ class LightboxTest extends \PhraseanetAuthenticatedWebTestCase
public function testValidate() public function testValidate()
{ {
$this->authenticate(self::$DI['app']); $this->authenticate(self::$DI['app']);
$basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4); $basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4);
$path = self::$DI['app']['url_generator']->generate('lightbox_validation', array(
'basket' => $basket->getId()
));
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
self::$DI['client']->request('GET', $path);
$crawler = self::$DI['client']->request('GET', '/lightbox/validate/' . $basket->getId() . '/'); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset()); $this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
$this->set_user_agent(self::USER_AGENT_IE6, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_IE6, self::$DI['app']);
self::$DI['client']->request('GET', $path);
$crawler = self::$DI['client']->request('GET', '/lightbox/validate/' . $basket->getId() . '/'); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset()); $this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
$this->set_user_agent(self::USER_AGENT_IPHONE, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_IPHONE, self::$DI['app']);
self::$DI['client']->request('GET', $path);
$crawler = self::$DI['client']->request('GET', '/lightbox/validate/' . $basket->getId() . '/'); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset()); $this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
} }
@@ -222,26 +224,27 @@ class LightboxTest extends \PhraseanetAuthenticatedWebTestCase
public function testFeedEntry() public function testFeedEntry()
{ {
$this->authenticate(self::$DI['app']); $this->authenticate(self::$DI['app']);
$entry = self::$DI['app']['EM']->find('Phraseanet:Feed', 1)->getEntries()->first();
$path = self::$DI['app']['url_generator']->generate('lightbox_feed_entry', array(
'entry_id' => $entry->getId()
));
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
self::$DI['client']->request('GET', $path);
$feed = self::$DI['app']['EM']->find('Phraseanet:Feed', 1); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$entry = $feed->getEntries()->first();
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $entry->getId() . '/');
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset()); $this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
$this->set_user_agent(self::USER_AGENT_IE6, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_IE6, self::$DI['app']);
self::$DI['client']->request('GET', $path);
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $entry->getId() . '/'); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset()); $this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
$this->set_user_agent(self::USER_AGENT_IPHONE, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_IPHONE, self::$DI['app']);
self::$DI['client']->request('GET', $path);
$crawler = self::$DI['client']->request('GET', '/lightbox/feeds/entry/' . $entry->getId() . '/'); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
$this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset()); $this->assertEquals('UTF-8', self::$DI['client']->getResponse()->getCharset());
} }

View File

@@ -9,31 +9,44 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
{ {
public function testDatafilesRouteAuthenticated() public function testDatafilesRouteAuthenticated()
{ {
self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/'); $path = self::$DI['app']['url_generator']->generate('datafile', array(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'preview',
));
self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$content_disposition = explode(';', $response->headers->get('content-disposition')); $this->assertEquals('inline', explode(';', $response->headers->get('content-disposition'))[0]);
$this->assertEquals('inline', $content_disposition[0]);
$this->assertEquals(self::$DI['record_1']->get_preview()->get_mime(), $response->headers->get('content-type')); $this->assertEquals(self::$DI['record_1']->get_preview()->get_mime(), $response->headers->get('content-type'));
$this->assertEquals(self::$DI['record_1']->get_preview()->get_size(), $response->headers->get('content-length')); $this->assertEquals(self::$DI['record_1']->get_preview()->get_size(), $response->headers->get('content-length'));
} }
public function testDatafilesNonExistentSubdef() public function testDatafilesNonExistentSubdef()
{ {
self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/asubdefthatdoesnotexists/'); $path = self::$DI['app']['url_generator']->generate('datafile', array(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'unknown_preview',
));
self::$DI['client']->request('GET', $path);
$this->assertNotFoundResponse(self::$DI['client']->getResponse()); $this->assertNotFoundResponse(self::$DI['client']->getResponse());
} }
public function testEtag() public function testEtag()
{ {
$record = self::$DI['record_1']; $path = self::$DI['app']['url_generator']->generate('datafile', array(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'preview',
));
self::$DI['client']->request('GET', '/datafiles/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/preview/'); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
/* @var $response \Symfony\Component\HttpFoundation\Response */
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$this->assertNotNull($response->getEtag()); $this->assertNotNull($response->getEtag());
$this->assertInstanceOf('DateTime', $response->getLastModified()); $this->assertInstanceOf('DateTime', $response->getLastModified());
@@ -46,8 +59,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
public function testDatafilesRouteNotAuthenticated() public function testDatafilesRouteNotAuthenticated()
{ {
self::$DI['app']['authentication']->closeAccount(); self::$DI['app']['authentication']->closeAccount();
self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/'); $path = self::$DI['app']['url_generator']->generate('datafile', array(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'preview',
));
self::$DI['client']->request('GET', $path);
$this->assertForbiddenResponse(self::$DI['client']->getResponse()); $this->assertForbiddenResponse(self::$DI['client']->getResponse());
} }
@@ -55,16 +73,27 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
{ {
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock(); self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
self::$DI['record_5']->move_to_collection(self::$DI['collection_no_access'], self::$DI['app']['phraseanet.appbox']); self::$DI['record_5']->move_to_collection(self::$DI['collection_no_access'], self::$DI['app']['phraseanet.appbox']);
self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_5']->get_sbas_id() . '/' . self::$DI['record_5']->get_record_id() . '/preview/'); $path = self::$DI['app']['url_generator']->generate('datafile', array(
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); 'sbas_id' => self::$DI['record_5']->get_sbas_id(),
'record_id' => self::$DI['record_5']->get_record_id(),
'subdef' => 'preview',
));
self::$DI['client']->request('GET', $path);
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
self::$DI['record_5']->move_to_collection(self::$DI['collection'], self::$DI['app']['phraseanet.appbox']); self::$DI['record_5']->move_to_collection(self::$DI['collection'], self::$DI['app']['phraseanet.appbox']);
} }
public function testDatafilesRouteNotAuthenticatedUnknownSubdef() public function testDatafilesRouteNotAuthenticatedUnknownSubdef()
{ {
self::$DI['app']['authentication']->closeAccount(); self::$DI['app']['authentication']->closeAccount();
self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/notfoundreview/'); $path = self::$DI['app']['url_generator']->generate('datafile', array(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'preview',
));
self::$DI['client']->request('GET', $path);
$this->assertForbiddenResponse(self::$DI['client']->getResponse()); $this->assertForbiddenResponse(self::$DI['client']->getResponse());
} }
@@ -80,15 +109,27 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
public function testPermalinkAuthenticatedWithDownloadQuery() public function testPermalinkAuthenticatedWithDownloadQuery()
{ {
$token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token();
$url = '/permalink/v1/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/whateverIwannt.jpg?token=' . $token . '&download=1';
self::$DI['client']->request('GET', $url); $path = self::$DI['app']['url_generator']->generate('permalinks_permalink' ,array(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'label' => 'whatever.jpg',
'subdef' => 'preview',
'token' => $token,
'download' => '1'
));
self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertRegExp('/^attachment;/', $response->headers->get('content-disposition')); $this->assertTrue($response->isOk());
$this->assertRegExp('/^attachment;/', $response->headers->get('content-disposition', ''));
$this->assertEquals(rtrim(self::$DI['app']['conf']->get('servername'), '/') . "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token, $response->headers->get("Link")); $url = self::$DI['app']['url_generator']->generate('permalinks_caption', array(
$this->assertEquals(200, $response->getStatusCode()); 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'token' => $token,
), true);
$this->assertEquals($url, $response->headers->get("Link"));
} }
public function testPermalinkNotAuthenticated() public function testPermalinkNotAuthenticated()
@@ -117,10 +158,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
public function testCaptionWithaWrongToken() public function testCaptionWithaWrongToken()
{ {
$this->assertTrue(self::$DI['app']['authentication']->isAuthenticated()); $this->assertTrue(self::$DI['app']['authentication']->isAuthenticated());
$token = "unexisting_token"; $path = self::$DI['app']['url_generator']->generate('permalinks_caption', array(
$url = '/permalink/v1/' . self::$DI['record_1']->get_sbas_id() . "/" . self::$DI['record_1']->get_record_id() . '/caption/?token='.$token; 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'token' => 'unexisting_token',
));
self::$DI['client']->request('GET', $url); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertEquals(404, $response->getStatusCode()); $this->assertEquals(404, $response->getStatusCode());
@@ -129,9 +173,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
public function testCaptionWithaWrongRecord() public function testCaptionWithaWrongRecord()
{ {
$this->assertTrue(self::$DI['app']['authentication']->isAuthenticated()); $this->assertTrue(self::$DI['app']['authentication']->isAuthenticated());
$url = '/permalink/v1/unexisting_record/unexisting_id/caption/?token=unexisting_token'; $path = self::$DI['app']['url_generator']->generate('permalinks_caption', array(
'sbas_id' => 0,
'record_id' => 4,
'token' => 'unexisting_token',
));
self::$DI['client']->request('GET', $url); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertEquals(404, $response->getStatusCode()); $this->assertEquals(404, $response->getStatusCode());
@@ -163,7 +211,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['app']['subdef.substituer']->substitute($story, $name, $media); self::$DI['app']['subdef.substituer']->substitute($story, $name, $media);
self::$DI['client']->request('GET', '/datafiles/' . $story->get_sbas_id() . '/' . $story->get_record_id() . '/' . $name . '/'); $path = self::$DI['app']['url_generator']->generate('datafile', array(
'sbas_id' => $story->get_sbas_id(),
'record_id' => $story->get_record_id(),
'subdef' => $name,
));
self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
@@ -171,10 +225,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
private function get_a_caption(array $headers = []) private function get_a_caption(array $headers = [])
{ {
$token = self::$DI['record_1']->get_thumbnail()->get_permalink()->get_token(); $path = self::$DI['app']['url_generator']->generate('permalinks_caption', array(
$url = '/permalink/v1/' . self::$DI['record_1']->get_sbas_id() . "/" . self::$DI['record_1']->get_record_id() . '/caption/?token='.$token; 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'token' => self::$DI['record_1']->get_thumbnail()->get_permalink()->get_token(),
));
self::$DI['client']->request('GET', $url); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
foreach ($headers as $name => $value) { foreach ($headers as $name => $value) {
@@ -185,7 +242,7 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertEquals($caption, $response->getContent()); $this->assertEquals($caption, $response->getContent());
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
self::$DI['client']->request('OPTIONS', $url); self::$DI['client']->request('OPTIONS', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('', $response->getContent()); $this->assertEquals('', $response->getContent());
@@ -195,17 +252,29 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
private function get_a_permalinkBCcompatibility(array $headers = []) private function get_a_permalinkBCcompatibility(array $headers = [])
{ {
$token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token();
$url = '/permalink/v1/whateverIwannt/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/' . $token . '/preview/';
self::$DI['client']->request('GET', $url); $path = self::$DI['app']['url_generator']->generate('permalinks_permalink_old' ,array(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'label' => 'whatever',
'subdef' => 'preview',
'token' => $token
));
self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
foreach ($headers as $name => $value) { foreach ($headers as $name => $value) {
$this->assertEquals($value, $response->headers->get($name)); $this->assertEquals($value, $response->headers->get($name));
} }
$this->assertEquals(rtrim(self::$DI['app']['conf']->get(['servername']), '/') . "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token, $response->headers->get("Link")); $url = self::$DI['app']['url_generator']->generate('permalinks_caption', array(
$this->assertEquals(200, $response->getStatusCode()); 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'token' => $token,
), true);
$this->assertEquals($url, $response->headers->get("Link"));
$this->assertTrue($response->isOk());
} }
public function testPermalinkRouteNotAuthenticatedIsOkInPublicFeed() public function testPermalinkRouteNotAuthenticatedIsOkInPublicFeed()
@@ -214,34 +283,51 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
$entry = $feed->getEntries()->first(); $entry = $feed->getEntries()->first();
$item = $entry->getItems()->first(); $item = $entry->getItems()->first();
self::$DI['app']['authentication']->closeAccount(); $path = self::$DI['app']['url_generator']->generate('permalinks_permaview', array(
self::$DI['client']->request('GET', '/permalink/v1/' . $item->getRecord(self::$DI['app'])->get_sbas_id() . '/' . $item->getRecord(self::$DI['app'])->get_record_id() . '/preview/'); 'sbas_id' => $item->getRecord(self::$DI['app'])->get_sbas_id(),
'record_id' => $item->getRecord(self::$DI['app'])->get_record_id(),
'subdef' => 'preview',
));
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode()); self::$DI['app']['authentication']->closeAccount();
self::$DI['client']->request('GET', $path);
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
} }
private function get_a_permaviewBCcompatibility(array $headers = []) private function get_a_permaviewBCcompatibility(array $headers = [])
{ {
$token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token();
$url = '/permalink/v1/whateverIwannt/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/' . $token . '/preview/'; $path = self::$DI['app']['url_generator']->generate('permalinks_permaview_old' ,array(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
$url = $url . 'view/'; 'record_id' => self::$DI['record_1']->get_record_id(),
self::$DI['client']->request('GET', $url); 'label' => 'whatever',
'subdef' => 'preview',
'token' => $token
));
self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
foreach ($headers as $name => $value) { foreach ($headers as $name => $value) {
$this->assertEquals($value, $response->headers->get($name)); $this->assertEquals($value, $response->headers->get($name));
} }
$this->assertEquals(200, $response->getStatusCode()); $this->assertTrue($response->isOk());
} }
private function get_a_permalink(array $headers = []) private function get_a_permalink(array $headers = [])
{ {
$token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token();
$url = '/permalink/v1/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/whateverIwannt.jpg?token=' . $token . '';
self::$DI['client']->request('GET', $url); $path = self::$DI['app']['url_generator']->generate('permalinks_permalink' ,array(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'label' => 'whatever.jpg',
'subdef' => 'preview',
'token' => $token
));
self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertRegExp('/^inline;/', $response->headers->get('content-disposition')); $this->assertRegExp('/^inline;/', $response->headers->get('content-disposition'));
@@ -249,12 +335,17 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertEquals($value, $response->headers->get($name)); $this->assertEquals($value, $response->headers->get($name));
} }
$this->assertEquals(rtrim(self::$DI['app']['conf']->get(['servername']), '/') . "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token, $response->headers->get("Link")); $url = self::$DI['app']['url_generator']->generate('permalinks_caption', array(
$this->assertEquals(200, $response->getStatusCode()); 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'token' => $token,
), true);
$this->assertEquals($url, $response->headers->get("Link"));
$this->assertTrue($response->isOk());
self::$DI['client']->request('OPTIONS', $url); self::$DI['client']->request('OPTIONS', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertEquals(200, $response->getStatusCode()); $this->assertTrue($response->isOk());
$this->assertEquals('', $response->getContent()); $this->assertEquals('', $response->getContent());
$this->assertEquals('GET, HEAD, OPTIONS', $response->headers->get('Allow')); $this->assertEquals('GET, HEAD, OPTIONS', $response->headers->get('Allow'));
} }
@@ -262,9 +353,15 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
private function get_a_permaview(array $headers = []) private function get_a_permaview(array $headers = [])
{ {
$token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token();
$url = '/permalink/v1/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/?token=' . $token . '';
self::$DI['client']->request('GET', $url); $path = self::$DI['app']['url_generator']->generate('permalinks_permaview', array(
'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'preview',
'token' => $token
));
self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
foreach ($headers as $name => $value) { foreach ($headers as $name => $value) {
@@ -273,7 +370,7 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
self::$DI['client']->request('OPTIONS', $url); self::$DI['client']->request('OPTIONS', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('', $response->getContent()); $this->assertEquals('', $response->getContent());

View File

@@ -3,7 +3,7 @@
namespace Alchemy\Tests\Phrasea\Authentication\PersistentCookie; namespace Alchemy\Tests\Phrasea\Authentication\PersistentCookie;
use Alchemy\Phrasea\Authentication\PersistentCookie\Manager; use Alchemy\Phrasea\Authentication\PersistentCookie\Manager;
use Entities\Session; use Alchemy\Phrasea\Model\Entities\Session;
class ManagerTest extends \PhraseanetTestCase class ManagerTest extends \PhraseanetTestCase
{ {

View File

@@ -35,25 +35,33 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$this->assertEquals("application/json", $response->headers->get("content-type"));
$content = json_decode($response->getContent());
$this->assertTrue(is_object($content));
$this->assertObjectHasAttribute('connection', $content);
$this->assertObjectHasAttribute('database', $content);
$this->assertObjectHasAttribute('is_empty', $content);
$this->assertObjectHasAttribute('is_appbox', $content);
$this->assertObjectHasAttribute('is_databox', $content);
$this->assertTrue($content->connection);
} }
public function testRouteMysqlFailed() public function testRouteMysqlFailed()
{ {
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database']; $connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
$params = array( $params = array(
"hostname" => $connexion['host'], "hostname" => $connexion['host'],
"port" => $connexion['port'], "port" => $connexion['port'],
"user" => $connexion['user'], "user" => $connexion['user'] . 'fake',
"password" => "fakepassword", "password" => $connexion['password'],
"dbname" => $connexion['dbname'], "dbname" => $connexion['dbname'],
); );
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$content = json_decode(self::$DI['client']->getResponse()->getContent());
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$this->assertEquals("application/json", $response->headers->get("content-type"));
$content = json_decode($response->getContent());
$this->assertTrue(is_object($content)); $this->assertTrue(is_object($content));
$this->assertObjectHasAttribute('connection', $content); $this->assertObjectHasAttribute('connection', $content);
$this->assertObjectHasAttribute('database', $content); $this->assertObjectHasAttribute('database', $content);
@@ -72,20 +80,21 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
"port" => $connexion['port'], "port" => $connexion['port'],
"user" => $connexion['user'], "user" => $connexion['user'],
"password" => $connexion['password'], "password" => $connexion['password'],
"dbname" => "fake-DTABASE-name" "dbname" => "fake-database-name"
); );
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$content = json_decode(self::$DI['client']->getResponse()->getContent());
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$this->assertEquals("application/json", $response->headers->get("content-type"));
$content = json_decode($response->getContent());
$this->assertTrue(is_object($content)); $this->assertTrue(is_object($content));
$this->assertObjectHasAttribute('connection', $content); $this->assertObjectHasAttribute('connection', $content);
$this->assertObjectHasAttribute('database', $content); $this->assertObjectHasAttribute('database', $content);
$this->assertObjectHasAttribute('is_empty', $content); $this->assertObjectHasAttribute('is_empty', $content);
$this->assertObjectHasAttribute('is_appbox', $content); $this->assertObjectHasAttribute('is_appbox', $content);
$this->assertObjectHasAttribute('is_databox', $content); $this->assertObjectHasAttribute('is_databox', $content);
$this->assertTrue($content->connection);
$this->assertFalse($content->database); $this->assertFalse($content->database);
} }

View File

@@ -2,7 +2,7 @@
namespace Alchemy\Tests\Phrasea\Controller\Admin; namespace Alchemy\Tests\Phrasea\Controller\Admin;
class UsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class UsersTest extends \PhraseanetAuthenticatedWebTestCase
{ {
protected $usersParameters; protected $usersParameters;
@@ -429,11 +429,21 @@ class UsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testImportUserCSVFile() public function testImportUserCSVFile()
{ {
// create a template // create a template
if (false === \User_Adapter::get_usr_id_from_login(self::$DI['app'], 'csv_template')) { if (null === self::$DI['app']['repo.users']->findByLogin('csv_template')) {
$created_user = \User_Adapter::create(self::$DI['app'], 'csv_template', \random::generatePassword(16), null, false, false); $user = self::$DI['app']['manipulator.user']->createTemplate('csv_template', self::$DI['app']['authentication']->getUser());
$created_user->set_template(self::$DI['app']['authentication']->getUser()); self::$DI['app']['acl']->get($user)->update_rights_to_base(self::$DI['collection']->get_base_id(), array('actif'=> 1));
$created_user->ACL()->update_rights_to_base(self::$DI['collection']->get_base_id(), array('actif'=> 1));
} }
$nativeQueryMock = $this->getMockBuilder('Alchemy\Phrasea\Model\NativeQueryProvider')
->disableOriginalConstructor()
->getMock();
$nativeQueryMock->expects($this->once())->method('getModelForUser')->will($this->returnValue([
$user
]));
self::$DI['app']['EM.native-query'] = $nativeQueryMock;
$data = $data =
<<<CSV <<<CSV
gender;last name;first name;login;password;mail;adress;city;zipcode;phone;fax;function;company;activity;country;FTP_active;FTP_adress;loginFTP;pwdFTP;Destination_folder;Passive_mode;Retry;Prefix_creation_folder;by_default__send gender;last name;first name;login;password;mail;adress;city;zipcode;phone;fax;function;company;activity;country;FTP_active;FTP_adress;loginFTP;pwdFTP;Destination_folder;Passive_mode;Retry;Prefix_creation_folder;by_default__send

View File

@@ -6,7 +6,7 @@ use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\Basket; use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\BasketElement; use Alchemy\Phrasea\Model\Entities\BasketElement;
class BasketTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class BasketTest extends \PhraseanetAuthenticatedWebTestCase
{ {
protected $client; protected $client;

View File

@@ -42,20 +42,16 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testManager() public function testManager()
{ {
$accounts = \Bridge_Account::get_accounts_by_user(self::$DI['app'], self::$DI['user']); $basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 1);
$usr_id = self::$DI['user']->get_id();
$basket = $this->insertOneBasket(); self::$DI['client']->request('POST', '/prod/bridge/manager/', array('ssel' => $basket->getId()));
$crawler = self::$DI['client']->request('POST', '/prod/bridge/manager/', array('ssel' => $basket->getId()));
$pageContent = self::$DI['client']->getResponse()->getContent();
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
} }
public function testLogin() public function testLogin()
{ {
self::$DI['client']->request('GET', '/prod/bridge/login/Apitest/'); self::$DI['client']->request('GET', '/prod/bridge/login/Apitest/');
$test = new \Bridge_Api_Apitest(self::$DI['app']['url_generator'], self::$DI['app']['phraseanet.registry'], new \Bridge_Api_Auth_None()); $test = new \Bridge_Api_Apitest(self::$DI['app']['url_generator'], self::$DI['app']['conf'], new \Bridge_Api_Auth_None(), self::$DI['app']['translator']);
$this->assertTrue(self::$DI['client']->getResponse()->getStatusCode() == 302); $this->assertTrue(self::$DI['client']->getResponse()->getStatusCode() == 302);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect($test->get_auth_url())); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect($test->get_auth_url()));
} }

View File

@@ -2,7 +2,7 @@
namespace Alchemy\Tests\Phrasea\Controller\Prod; namespace Alchemy\Tests\Phrasea\Controller\Prod;
class LanguageTest extends \PhraseanetWebTestCase class LanguageTest extends \PhraseanetAuthenticatedTestCase
{ {
protected $client; protected $client;

View File

@@ -100,7 +100,6 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
'cont' => $basket->getId(), 'cont' => $basket->getId(),
]); ]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$data = json_decode($response->getContent(), true); $data = json_decode($response->getContent(), true);

View File

@@ -4,6 +4,7 @@ languages:
default: 'fr' default: 'fr'
main: main:
maintenance: false maintenance: false
key: ''
database: database:
host: 'sql-host' host: 'sql-host'
port: 3306 port: 3306
@@ -172,6 +173,9 @@ registration-fields:
- -
name: company name: company
required: true required: true
-
name: lastname
required: true
- -
name: firstname name: firstname
required: true required: true
@@ -187,3 +191,16 @@ h264-pseudo-streaming:
type: nginx type: nginx
mapping: [] mapping: []
plugins: [] plugins: []
api_cors:
enabled: false
allow_credentials: false
allow_origin: []
allow_headers: []
allow_methods: []
expose_headers: []
max_age: 0
hosts: []
session:
idle: 0
# 1 week
lifetime: 604800

View File

@@ -4,6 +4,7 @@ languages:
default: 'fr' default: 'fr'
main: main:
maintenance: false maintenance: false
key: ''
database: database:
host: 'sql-host' host: 'sql-host'
port: 3306 port: 3306
@@ -172,6 +173,9 @@ registration-fields:
- -
name: company name: company
required: true required: true
-
name: lastname
required: true
- -
name: firstname name: firstname
required: true required: true
@@ -187,3 +191,16 @@ h264-pseudo-streaming:
type: nginx type: nginx
mapping: [] mapping: []
plugins: [] plugins: []
api_cors:
enabled: false
allow_credentials: false
allow_origin: []
allow_headers: []
allow_methods: []
expose_headers: []
max_age: 0
hosts: []
session:
idle: 0
# 1 week
lifetime: 604800

View File

@@ -4,10 +4,10 @@ namespace Alchemy\Tests\Phrasea\Core\Event\Subscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\SessionManagerSubscriber; use Alchemy\Phrasea\Core\Event\Subscriber\SessionManagerSubscriber;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Entities\Session; use Alchemy\Phrasea\Model\Entities\Session;
use Symfony\Component\HttpKernel\Client; use Symfony\Component\HttpKernel\Client;
class SessionManagerSubscriberTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
{ {
public function testEndSession() public function testEndSession()
{ {
@@ -74,7 +74,8 @@ class SessionManagerSubscriberTest extends \PhraseanetWebTestCaseAuthenticatedAb
$session->setUpdated(new \DateTime()); $session->setUpdated(new \DateTime());
$app['EM'] = $this->getMockBuilder('Doctrine\ORM\EntityManager')->disableOriginalConstructor()->getMock(); $app['EM'] = $this->getMockBuilder('Doctrine\ORM\EntityManager')->disableOriginalConstructor()->getMock();
$app['EM']->expects($this->exactly(2))->method('find')->with($this->equalTo('Entities\Session'))->will($this->returnValue($session)); $app['repo.sessions'] = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$app['repo.sessions']->expects($this->exactly(2))->method('find')->will($this->returnValue($session));
$app['EM']->expects($this->exactly(4))->method('persist')->will($this->returnValue(null)); $app['EM']->expects($this->exactly(4))->method('persist')->will($this->returnValue(null));
$app['EM']->expects($this->exactly(2))->method('flush')->will($this->returnValue(null)); $app['EM']->expects($this->exactly(2))->method('flush')->will($this->returnValue(null));
@@ -108,7 +109,10 @@ class SessionManagerSubscriberTest extends \PhraseanetWebTestCaseAuthenticatedAb
$session->setUpdated(new \DateTime('-1 hour')); $session->setUpdated(new \DateTime('-1 hour'));
$app['EM'] = $this->getMockBuilder('Doctrine\ORM\EntityManager')->disableOriginalConstructor()->getMock(); $app['EM'] = $this->getMockBuilder('Doctrine\ORM\EntityManager')->disableOriginalConstructor()->getMock();
$app['EM']->expects($this->once())->method('find')->with($this->equalTo('Entities\Session'))->will($this->returnValue($session)); $app['repo.sessions'] = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$app['repo.sessions']->expects($this->once())->method('find')->will($this->returnValue($session));
$app['EM']->expects($this->any())->method('persist')->will($this->returnValue(null));
$app['EM']->expects($this->any())->method('flush')->will($this->returnValue(null));
$app['phraseanet.configuration']['session'] = array( $app['phraseanet.configuration']['session'] = array(
'idle' => 10, 'idle' => 10,
@@ -143,7 +147,10 @@ class SessionManagerSubscriberTest extends \PhraseanetWebTestCaseAuthenticatedAb
$session->setUpdated(new \DateTime('-1 hour')); $session->setUpdated(new \DateTime('-1 hour'));
$app['EM'] = $this->getMockBuilder('Doctrine\ORM\EntityManager')->disableOriginalConstructor()->getMock(); $app['EM'] = $this->getMockBuilder('Doctrine\ORM\EntityManager')->disableOriginalConstructor()->getMock();
$app['EM']->expects($this->once())->method('find')->with($this->equalTo('Entities\Session'))->will($this->returnValue($session)); $app['repo.sessions'] = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$app['repo.sessions']->expects($this->once())->method('find')->will($this->returnValue($session));
$app['EM']->expects($this->any())->method('persist')->will($this->returnValue(null));
$app['EM']->expects($this->any())->method('flush')->will($this->returnValue(null));
$app['phraseanet.configuration']['session'] = array( $app['phraseanet.configuration']['session'] = array(
'idle' => 10, 'idle' => 10,

View File

@@ -3,6 +3,7 @@
namespace Alchemy\Tests\Phrasea\Notification\Mail; namespace Alchemy\Tests\Phrasea\Notification\Mail;
use Alchemy\Phrasea\Notification\Mail\MailInterface; use Alchemy\Phrasea\Notification\Mail\MailInterface;
use Symfony\Component\Routing\RequestContext;
abstract class MailTestCase extends \PhraseanetTestCase abstract class MailTestCase extends \PhraseanetTestCase
{ {

View File

@@ -59,6 +59,7 @@ class PhraseanetPHPUnitListener implements PHPUnit_Framework_TestListener
public function startTest(PHPUnit_Framework_Test $test) public function startTest(PHPUnit_Framework_Test $test)
{ {
printf("'%s' started\n", self::generateName($test));
if (!static::$enableDurationCapture) { if (!static::$enableDurationCapture) {
return; return;
} }
@@ -113,6 +114,7 @@ class PhraseanetPHPUnitListener implements PHPUnit_Framework_TestListener
private static function generateName(PHPUnit_Framework_Test $test) private static function generateName(PHPUnit_Framework_Test $test)
{ {
return get_class($test) . '::' . $test->getName(); $reflect = new \ReflectionClass($test);
return $reflect->getShortName() . '::' . $test->getName();
} }
} }

View File

@@ -352,7 +352,8 @@ abstract class PhraseanetTestCase extends WebTestCase
$app['url_generator'] = $app->share($app->extend('url_generator', function ($generator, $app) { $app['url_generator'] = $app->share($app->extend('url_generator', function ($generator, $app) {
$host = parse_url($app['conf']->get('servername'), PHP_URL_HOST); $host = parse_url($app['conf']->get('servername'), PHP_URL_HOST);
$generator->setContext(new RequestContext('', 'GET', $host));
$generator->setContext(new RequestContext('', 'GET', $host ?: $app['conf']->get('servername')));
return $generator; return $generator;
})); }));

View File

@@ -2,7 +2,7 @@
use Alchemy\Phrasea\Exception\RuntimeException; use Alchemy\Phrasea\Exception\RuntimeException;
class API_WebhookTest extends PhraseanetPHPUnitAbstract class API_WebhookTest extends \PhraseanetTestCase
{ {
public function testsNewApiHook() public function testsNewApiHook()
{ {

View File

@@ -270,6 +270,30 @@ ul {
padding: 9px 5px; padding: 9px 5px;
} }
/** blockquote style */
blockquote {
page-break-inside: avoid;
background: #f9f9f9;
border-left: 10px solid #ccc;
margin: 1.5em 10px;
padding: 0.5em 10px;
quotes: "\201C""\201D""\2018""\2019";
color: #333;
}
blockquote:before {
color: #ccc;
content: open-quote;
font-size: 4em;
line-height: 0.1em;
margin-right: 0.25em;
vertical-align: -0.4em;
}
blockquote p {
display: inline;
}
/** app css */ /** app css */
.help-block-error { .help-block-error {

View File

@@ -296,3 +296,10 @@ div.switch_right.unchecked {
#tab_demandes .table .btn-group { #tab_demandes .table .btn-group {
display: block; display: block;
} }
#admin_setup_registry .control-label {
min-width: 260px;
}
#admin_setup_registry .form-horizontal .controls, #admin_setup_registry .form-horizontal .help-message {
margin-left: 300px;
}