This commit is contained in:
Romain Neutron
2013-05-29 21:21:02 +02:00
parent e36e7ad085
commit 38f38290c8
35 changed files with 1577 additions and 1592 deletions

View File

@@ -133,7 +133,6 @@ use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGenerator; use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Form\FormFactory; use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormTypeInterface; use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
@@ -246,12 +245,12 @@ class Application extends SilexApplication
$this->register(new ReCaptchaServiceProvider()); $this->register(new ReCaptchaServiceProvider());
$this['recaptcha.public-key'] = $this->share(function (Application $app) { $this['recaptcha.public-key'] = $this->share(function (Application $app) {
if($app['phraseanet.registry']->get('GV_captchas')) { if ($app['phraseanet.registry']->get('GV_captchas')) {
return $app['phraseanet.registry']->get('GV_captcha_public_key'); return $app['phraseanet.registry']->get('GV_captcha_public_key');
} }
}); });
$this['recaptcha.private-key'] = $this->share(function (Application $app) { $this['recaptcha.private-key'] = $this->share(function (Application $app) {
if($app['phraseanet.registry']->get('GV_captchas')) { if ($app['phraseanet.registry']->get('GV_captchas')) {
return $app['phraseanet.registry']->get('GV_captcha_private_key'); return $app['phraseanet.registry']->get('GV_captcha_private_key');
} }
}); });

View File

@@ -12,8 +12,6 @@
namespace Alchemy\Phrasea\Application; namespace Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Application as PhraseaApplication; use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\Authentication\Context;
use Alchemy\Phrasea\Core\Event\PreAuthenticate;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Controller\Api\Oauth2; use Alchemy\Phrasea\Controller\Api\Oauth2;
use Alchemy\Phrasea\Controller\Api\V1; use Alchemy\Phrasea\Controller\Api\V1;
@@ -63,7 +61,6 @@ return call_user_func(function($environment = 'prod') {
$app->mount('/api/oauthv2', new Oauth2()); $app->mount('/api/oauthv2', new Oauth2());
$app->mount('/api/v1', new V1()); $app->mount('/api/v1', new V1());
/** /**
* Route Errors * Route Errors
*/ */

View File

@@ -123,7 +123,7 @@ return call_user_func(function($environment = null) {
} elseif ($e instanceof \Exception_NotFound) { } elseif ($e instanceof \Exception_NotFound) {
$code = 404; $code = 404;
$message = 'Not Found'; $message = 'Not Found';
} elseif($e instanceof \Exception_UnauthorizedAction) { } elseif ($e instanceof \Exception_UnauthorizedAction) {
$code = 403; $code = 403;
$message = 'Forbidden'; $message = 'Forbidden';
} else { } else {

View File

@@ -51,14 +51,14 @@ class AccountCreator
/** /**
* Creates an account * Creates an account
* *
* @param Application $app The application * @param Application $app The application
* @param string $id The base for user login * @param string $id The base for user login
* @param string $email The email * @param string $email The email
* @param array $templates Some extra templates to apply with the ones of this creator * @param array $templates Some extra templates to apply with the ones of this creator
* *
* @return \User_Adapter * @return \User_Adapter
* *
* @throws RuntimeException In case the AccountCreator is disabled * @throws RuntimeException In case the AccountCreator is disabled
* @throws InvalidArgumentException In case a user with the same email already exists * @throws InvalidArgumentException In case a user with the same email already exists
*/ */
public function create(Application $app, $id, $email = null, array $templates = array()) public function create(Application $app, $id, $email = null, array $templates = array())

View File

@@ -54,7 +54,7 @@ class Authenticator
/** /**
* Open user session * Open user session
* *
* @param \User_Adapter $user * @param \User_Adapter $user
* *
* @return Session * @return Session
* *

View File

@@ -9,7 +9,7 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Alchemy\Phrasea\Authentication\Exception;; namespace Alchemy\Phrasea\Authentication\Exception;
use Alchemy\Phrasea\Exception\RuntimeException; use Alchemy\Phrasea\Exception\RuntimeException;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;

View File

@@ -47,7 +47,7 @@ class FailureManager
/** /**
* Saves an authentication failure * Saves an authentication failure
* *
* @param string $username * @param string $username
* @param Request $request * @param Request $request
* *
* @return FailureManager * @return FailureManager
@@ -70,7 +70,7 @@ class FailureManager
/** /**
* Checks a request for previous failures * Checks a request for previous failures
* *
* @param string $username * @param string $username
* @param Request $request * @param Request $request
* *
* @return FailureManager * @return FailureManager

View File

@@ -12,8 +12,8 @@ interface PasswordAuthenticationInterface
/** /**
* Validates credentials for a web based authentication * Validates credentials for a web based authentication
* *
* @param string $username * @param string $username
* @param string $password * @param string $password
* @param Request $request * @param Request $request
* *
* @return integer|null * @return integer|null

View File

@@ -11,8 +11,6 @@
namespace Alchemy\Phrasea\Authentication\Provider; namespace Alchemy\Phrasea\Authentication\Provider;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\RuntimeException;
use Alchemy\Phrasea\Authentication\Provider\Token\Token; use Alchemy\Phrasea\Authentication\Provider\Token\Token;
use Alchemy\Phrasea\Authentication\Provider\Token\Identity; use Alchemy\Phrasea\Authentication\Provider\Token\Identity;
use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException; use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException;

View File

@@ -15,7 +15,6 @@ use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\Provider\Token\Token; use Alchemy\Phrasea\Authentication\Provider\Token\Token;
use Alchemy\Phrasea\Authentication\Provider\Token\Identity; use Alchemy\Phrasea\Authentication\Provider\Token\Identity;
use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException; use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException;
use Alchemy\Phrasea\Exception\RuntimeException;
use Guzzle\Http\Client as Guzzle; use Guzzle\Http\Client as Guzzle;
use Guzzle\Http\ClientInterface; use Guzzle\Http\ClientInterface;
use Guzzle\Common\Exception\GuzzleException; use Guzzle\Common\Exception\GuzzleException;

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Authentication\Provider; namespace Alchemy\Phrasea\Authentication\Provider;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\Provider\Token\Token; use Alchemy\Phrasea\Authentication\Provider\Token\Token;
use Alchemy\Phrasea\Authentication\Provider\Token\Identity; use Alchemy\Phrasea\Authentication\Provider\Token\Identity;
use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException; use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException;
@@ -230,7 +229,7 @@ class GooglePlus extends AbstractProvider
throw new NotAuthenticatedException('Error while retrieving user info'); throw new NotAuthenticatedException('Error while retrieving user info');
} }
try{ try {
$plusData = $this->plus->people->get('me'); $plusData = $this->plus->people->get('me');
} catch (\Google_Exception $e) { } catch (\Google_Exception $e) {
throw new NotAuthenticatedException('Error while retrieving user info', $e->getCode(), $e); throw new NotAuthenticatedException('Error while retrieving user info', $e->getCode(), $e);

View File

@@ -11,11 +11,9 @@
namespace Alchemy\Phrasea\Authentication\Provider; namespace Alchemy\Phrasea\Authentication\Provider;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\Provider\Token\Token; use Alchemy\Phrasea\Authentication\Provider\Token\Token;
use Alchemy\Phrasea\Authentication\Provider\Token\Identity; use Alchemy\Phrasea\Authentication\Provider\Token\Identity;
use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException; use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException;
use Alchemy\Phrasea\Exception\RuntimeException;
use Guzzle\Http\Client as Guzzle; use Guzzle\Http\Client as Guzzle;
use Guzzle\Http\ClientInterface; use Guzzle\Http\ClientInterface;
use Guzzle\Common\Exception\GuzzleException; use Guzzle\Common\Exception\GuzzleException;

View File

@@ -60,7 +60,7 @@ interface ProviderInterface
* successful or failure. * successful or failure.
* *
* @param Application $app * @param Application $app
* @param Request $request * @param Request $request
* *
* @throws NotAuthenticatedException In case the authentication failed. * @throws NotAuthenticatedException In case the authentication failed.
*/ */
@@ -103,9 +103,9 @@ interface ProviderInterface
/** /**
* Creates a provider * Creates a provider
* *
* @param UrlGenerator $generator * @param UrlGenerator $generator
* @param SessionInterface $session * @param SessionInterface $session
* @param array $options * @param array $options
*/ */
public static function create(UrlGenerator $generator, SessionInterface $session, array $options); public static function create(UrlGenerator $generator, SessionInterface $session, array $options);
} }

View File

@@ -11,11 +11,9 @@
namespace Alchemy\Phrasea\Authentication\Provider; namespace Alchemy\Phrasea\Authentication\Provider;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\Provider\Token\Token; use Alchemy\Phrasea\Authentication\Provider\Token\Token;
use Alchemy\Phrasea\Authentication\Provider\Token\Identity; use Alchemy\Phrasea\Authentication\Provider\Token\Identity;
use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException; use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException;
use Alchemy\Phrasea\Exception\RuntimeException;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGenerator; use Symfony\Component\Routing\Generator\UrlGenerator;

View File

@@ -25,7 +25,7 @@ class TokenValidator
/** /**
* Returns true if the token is valid * Returns true if the token is valid
* *
* @param type $token * @param type $token
* @return boolean * @return boolean
*/ */
public function isValid($token) public function isValid($token)

View File

@@ -61,6 +61,7 @@ class LessCompile extends Command
if (0 === $failures) { if (0 === $failures) {
$output->writeln('<info>Build done !</info>'); $output->writeln('<info>Build done !</info>');
return 0; return 0;
} }

View File

@@ -124,7 +124,7 @@ class Fields implements ControllerProviderInterface
return $app->json($fields); return $app->json($fields);
} }
public function getLanguage(Application $app, Request $request) public function getLanguage(Application $app, Request $request)
{ {
return $app->json(array( return $app->json(array(
'something_wrong' => _('Something wrong happened, please try again or contact an admin.'), 'something_wrong' => _('Something wrong happened, please try again or contact an admin.'),
@@ -220,7 +220,8 @@ class Fields implements ControllerProviderInterface
return new Response($json, 200, array('Content-Type' => 'application/json')); return new Response($json, 200, array('Content-Type' => 'application/json'));
} }
public function createField(Application $app, Request $request, $sbas_id) { public function createField(Application $app, Request $request, $sbas_id)
{
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
$data = $this->getFieldJsonFromRequest($app, $request); $data = $this->getFieldJsonFromRequest($app, $request);
@@ -243,7 +244,8 @@ class Fields implements ControllerProviderInterface
)))); ))));
} }
public function listFields(Application $app, $sbas_id) { public function listFields(Application $app, $sbas_id)
{
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
return $app->json($databox->get_meta_structure()->toArray()); return $app->json($databox->get_meta_structure()->toArray());
@@ -303,7 +305,7 @@ class Fields implements ControllerProviderInterface
$data = $this->requestBodyToJson($request); $data = $this->requestBodyToJson($request);
$required = $this->getMandatoryFieldProperties(); $required = $this->getMandatoryFieldProperties();
foreach($data as $field) { foreach ($data as $field) {
foreach ($required as $key) { foreach ($required as $key) {
if (false === array_key_exists($key, $field)) { if (false === array_key_exists($key, $field)) {
$app->abort(400, sprintf('The entity must contain a key `%s`', $key)); $app->abort(400, sprintf('The entity must contain a key `%s`', $key));
@@ -374,7 +376,7 @@ class Fields implements ControllerProviderInterface
{ {
try { try {
\databox_field::loadClassFromTagName($field['tag']); \databox_field::loadClassFromTagName($field['tag']);
} catch(\Exception_Databox_metadataDescriptionNotFound $e) { } catch (\Exception_Databox_metadataDescriptionNotFound $e) {
throw new BadRequestHttpException(_(sprintf('Provided tag %s is unknown.', $field['tag']))); throw new BadRequestHttpException(_(sprintf('Provided tag %s is unknown.', $field['tag'])));
} }
} }

View File

@@ -12,7 +12,6 @@
namespace Alchemy\Phrasea\Controller\Api; namespace Alchemy\Phrasea\Controller\Api;
use Alchemy\Phrasea\Authentication\Context; use Alchemy\Phrasea\Authentication\Context;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\Authentication\Exception\AccountLockedException; use Alchemy\Phrasea\Authentication\Exception\AccountLockedException;
use Alchemy\Phrasea\Authentication\Exception\RequireCaptchaException; use Alchemy\Phrasea\Authentication\Exception\RequireCaptchaException;
use Alchemy\Phrasea\Core\Event\PreAuthenticate; use Alchemy\Phrasea\Core\Event\PreAuthenticate;

View File

@@ -879,8 +879,8 @@ class Login implements ControllerProviderInterface
/** /**
* *
* @param PhraseaApplication $app * @param PhraseaApplication $app
* @param string $providerId * @param string $providerId
* @return ProviderInterface * @return ProviderInterface
* @throws NotFoundHttpException * @throws NotFoundHttpException
*/ */

View File

@@ -1607,7 +1607,7 @@ class ACL implements cache_cacheableInterface
$collections = array(); $collections = array();
foreach($rs as $row) { foreach ($rs as $row) {
$collections[] = \collection::get_from_base_id($this->app, $row['base_id']); $collections[] = \collection::get_from_base_id($this->app, $row['base_id']);
} }

View File

@@ -25,7 +25,7 @@ class API_V1_Timer implements ServiceProviderInterface
$callback = function (Event $event) use ($app) { $callback = function (Event $event) use ($app) {
$name = $event->getName(); $name = $event->getName();
$n = 1; $n = 1;
while(isset($app['api.timers']->{$name})) { while (isset($app['api.timers']->{$name})) {
$n++; $n++;
$name = $event->getName() . '#' . $n; $name = $event->getName() . '#' . $n;
} }

View File

@@ -373,7 +373,7 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
*/ */
public function get_publisher() public function get_publisher()
{ {
if ( ! $this->publisher instanceof Feed_Publisher_Adapter) { if (! $this->publisher instanceof Feed_Publisher_Adapter) {
try { try {
$this->publisher = new Feed_Publisher_Adapter($this->app, $this->publisher_id); $this->publisher = new Feed_Publisher_Adapter($this->app, $this->publisher_id);
} catch (\Exception_Feed_PublisherNotFound $e) { } catch (\Exception_Feed_PublisherNotFound $e) {

View File

@@ -112,6 +112,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
$buffer[$field->get_name()] = ctype_digit($val) ? (int) $val : $val; $buffer[$field->get_name()] = ctype_digit($val) ? (int) $val : $val;
} }
} }
return array('record' => array('description' => $buffer)); return array('record' => array('description' => $buffer));
} }

View File

@@ -147,4 +147,3 @@ class databox_descriptionStructure implements IteratorAggregate, Countable
return count($this->elements); return count($this->elements);
} }
} }

View File

@@ -872,9 +872,9 @@ class databox_field implements cache_cacheableInterface
/** /**
* *
* @param \Alchemy\Phrasea\Application $app * @param \Alchemy\Phrasea\Application $app
* @param databox $databox * @param databox $databox
* @param type $name * @param type $name
* @param type $multi * @param type $multi
* *
* @return databox_field * @return databox_field
* *

View File

@@ -61,4 +61,3 @@ class patch_379 implements patchInterface
return true; return true;
} }
} }

View File

@@ -114,7 +114,6 @@ class patch_380a3 implements patchInterface
$stmt->closeCursor(); $stmt->closeCursor();
unset($stmt); unset($stmt);
$sql = "CALL explode_log_table(',')"; $sql = "CALL explode_log_table(',')";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(); $stmt->execute();

View File

@@ -10,8 +10,6 @@
*/ */
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
use Alchemy\Phrasea\Exception\RuntimeException;
class phrasea class phrasea
{ {

View File

@@ -233,8 +233,8 @@ class random
/** /**
* Get the validation token for one user and one validation basket * Get the validation token for one user and one validation basket
* *
* @param integer $userId * @param integer $userId
* @param integer $basketId * @param integer $basketId
* *
* @return string The token * @return string The token
* *

File diff suppressed because it is too large Load Diff