diff --git a/features/bootstrap/GuiContext.php b/features/bootstrap/GuiContext.php
index eb6d748ff1..d765709927 100644
--- a/features/bootstrap/GuiContext.php
+++ b/features/bootstrap/GuiContext.php
@@ -14,6 +14,7 @@ require_once __DIR__ . '/../../vendor/autoload.php';
use Alchemy\Phrasea\Application;
use Behat\Behat\Exception\PendingException;
use Behat\MinkExtension\Context\MinkContext;
+use Alchemy\Phrasea\Model\Entities\User;
class GuiContext extends MinkContext
{
@@ -65,9 +66,7 @@ class GuiContext extends MinkContext
*/
public function aUserDoesNotExist($login)
{
- if (false !== $userId = \User_Adapter::get_usr_id_from_login($this->app, $login)) {
- $user = \User_Adapter::getInstance($userId, $this->app);
-
+ if (null !== $user = $this->app['manipulator.user']->getRepository()->findByLogin($login)) {
$user->ACL()->revoke_access_from_bases(array_keys(
$this->app['authentication']->getUser()->ACL()->get_granted_base(array('canadmin'))
));
@@ -81,14 +80,8 @@ class GuiContext extends MinkContext
*/
public function aUserExistsWithAsPassword($login, $password)
{
- if (false === \User_Adapter::get_usr_id_from_login($this->app, $login)) {
- \User_Adapter::create(
- $this->app,
- $login,
- $password,
- $login,
- false
- );
+ if (null === $user = $this->app['manipulator.user']->getRepository()->findByLogin($login)) {
+ $this->app['manipulator.user']->create($login, $password, null, false);
}
}
@@ -168,17 +161,8 @@ class GuiContext extends MinkContext
*/
public function userGuestAccessIsEnable()
{
- if (false === $usrId = \User_Adapter::get_usr_id_from_login($this->app, 'invite')) {
- $user = \User_Adapter::create(
- $this->app,
- 'invite',
- '',
- null,
- false,
- true
- );
- } else {
- $user = \User_Adapter::getInstance($usrId, $this->app);
+ if (null === $user = $this->app['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) {
+ $user = $this->app['manipulator.user']->create(User::USER_GUEST, '');
}
$user->ACL()->give_access_to_sbas(array_keys($this->app['phraseanet.appbox']->get_databoxes()));
@@ -195,9 +179,7 @@ class GuiContext extends MinkContext
*/
public function userGuestAccessIsDisable()
{
- if (false !== $usrId = \User_Adapter::get_usr_id_from_login($this->app, 'invite')) {
- $user = \User_Adapter::getInstance($usrId, $this->app);
-
+ if (null !== $user = $this->app['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) {
foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
$user->ACL()->revoke_access_from_bases(array($collection->get_base_id()));
@@ -227,12 +209,10 @@ class GuiContext extends MinkContext
*/
public function isAuthenticated($login)
{
- if (false == $usrId = \User_Adapter::get_usr_id_from_login($this->app, $login)) {
+ if (null === $user = $this->app['manipulator.user']->getRepository()->findByLogin($login)) {
throw new \Exception(sprintf('User %s does not exists, use the following definition to create it : a user "%s" exists', $login, $login));
}
- $user = \User_Adapter::getInstance($usrId, $this->app);
-
$this->app['authentication']->openAccount($user);
throw new PendingException();
diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php
index 396dfb6ea9..4d2ecf0ca7 100644
--- a/lib/Alchemy/Phrasea/Application.php
+++ b/lib/Alchemy/Phrasea/Application.php
@@ -111,6 +111,7 @@ use Alchemy\Phrasea\Core\Provider\TokensServiceProvider;
use Alchemy\Phrasea\Core\Provider\TranslationServiceProvider;
use Alchemy\Phrasea\Core\Provider\UnicodeServiceProvider;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
+use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Form\Extension\HelpTypeExtension;
use Alchemy\Phrasea\Twig\JSUniqueID;
use Alchemy\Phrasea\Twig\Camelize;
@@ -771,13 +772,11 @@ class Application extends SilexApplication
*/
public function isGuestAllowed()
{
- $usrId = \User_Adapter::get_usr_id_from_login($this, 'invite');
-
- if (!$usrId) {
+ if (null === $user = $this['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) {
return false;
}
- return count($this['acl']->get(\User_Adapter::getInstance($usrId, $this))->get_granted_base()) > 0;
+ return count($this['acl']->get($user)->get_granted_base()) > 0;
}
/**
diff --git a/lib/Alchemy/Phrasea/Authentication/ACLProvider.php b/lib/Alchemy/Phrasea/Authentication/ACLProvider.php
index 88484a05b3..b5b65ee610 100644
--- a/lib/Alchemy/Phrasea/Authentication/ACLProvider.php
+++ b/lib/Alchemy/Phrasea/Authentication/ACLProvider.php
@@ -37,7 +37,7 @@ class ACLProvider
*
* @return \ACL
*/
- public function get(\User_Adapter $user)
+ public function get(User $user)
{
if (null !== $acl = $this->fetchFromCache($user)) {
return $acl;
@@ -61,9 +61,9 @@ class ACLProvider
*
* @return null || \ACL
*/
- private function fetchFromCache(\User_Adapter $user)
+ private function fetchFromCache(User $user)
{
- return $this->hasCache($user) ? self::$cache[$user->get_id()] : null;
+ return $this->hasCache($user) ? self::$cache[$user->getId()] : null;
}
/**
@@ -73,9 +73,9 @@ class ACLProvider
*
* @return boolean
*/
- private function hasCache(\User_Adapter $user)
+ private function hasCache(User $user)
{
- return isset(self::$cache[$user->get_id()]);
+ return isset(self::$cache[$user->getId()]);
}
/**
@@ -85,8 +85,8 @@ class ACLProvider
*
* @return \ACL
*/
- private function fetch(\User_Adapter $user)
+ private function fetch(User $user)
{
- return self::$cache[$user->get_id()] = new \ACL($user, $this->app);
+ return self::$cache[$user->getId()] = new \ACL($user, $this->app);
}
}
diff --git a/lib/Alchemy/Phrasea/Authentication/AccountCreator.php b/lib/Alchemy/Phrasea/Authentication/AccountCreator.php
index 6abd30e64b..baa59a1a23 100644
--- a/lib/Alchemy/Phrasea/Authentication/AccountCreator.php
+++ b/lib/Alchemy/Phrasea/Authentication/AccountCreator.php
@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Authentication;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\Exception\RuntimeException;
+use Alchemy\Phrasea\Model\Entities\User;
class AccountCreator
{
@@ -56,7 +57,7 @@ class AccountCreator
* @param string $email The email
* @param array $templates Some extra templates to apply with the ones of this creator
*
- * @return \User_Adapter
+ * @return User
*
* @throws RuntimeException In case the AccountCreator is disabled
* @throws InvalidArgumentException In case a user with the same email already exists
@@ -70,16 +71,16 @@ class AccountCreator
$login = $id;
$n = 1;
- if (null !== $email && false !== \User_Adapter::get_usr_id_from_email($app, $email)) {
+ if (null !== $email && null !== $app['manipulator.user']->getRepository()->findByEmail($email)) {
throw new InvalidArgumentException('Provided email already exist in account base.');
}
- while (false !== \User_Adapter::get_usr_id_from_login($app, $login)) {
+ while (null !== $app['manipulator.user']->getRepository()->findByLogin($login)) {
$login = $id . '#' . $n;
$n++;
}
- $user = \User_Adapter::create($app, $login, $this->random->generatePassword(), $email, false, false);
+ $user = $app['manipulator.user']->createUser($login, $this->random->generatePassword(), $email);
$base_ids = [];
foreach ($this->appbox->get_databoxes() as $databox) {
diff --git a/lib/Alchemy/Phrasea/Authentication/Authenticator.php b/lib/Alchemy/Phrasea/Authentication/Authenticator.php
index 4a60e7e872..7ef715de6a 100644
--- a/lib/Alchemy/Phrasea/Authentication/Authenticator.php
+++ b/lib/Alchemy/Phrasea/Authentication/Authenticator.php
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Authentication;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\RuntimeException;
+use Alchemy\Phrasea\Model\Entities\User;
use Browser;
use Doctrine\ORM\EntityManager;
use Alchemy\Phrasea\Model\Entities\Session;
@@ -43,7 +44,7 @@ class Authenticator
return $this->user;
}
- public function setUser(\User_Adapter $user = null)
+ public function setUser(User $user = null)
{
$this->user = $user;
@@ -53,13 +54,13 @@ class Authenticator
/**
* Open user session
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return Session
*
* @throws \Exception_InternalServerError
*/
- public function openAccount(\User_Adapter $user)
+ public function openAccount(User $user)
{
$this->session->remove('usr_id');
$this->session->remove('session_id');
@@ -69,7 +70,7 @@ class Authenticator
->setBrowserVersion($this->browser->getVersion())
->setPlatform($this->browser->getPlatform())
->setUserAgent($this->browser->getUserAgent())
- ->setUsrId($user->get_id());
+ ->setUsrId($user->getId());
$this->em->persist($session);
$this->em->flush();
@@ -104,10 +105,8 @@ class Authenticator
throw new RuntimeException('Unable to refresh the session, it does not exist anymore');
}
- try {
- $user = \User_Adapter::getInstance($session->getUsrId(), $this->app);
- } catch (NotFoundHttpException $e) {
- throw new RuntimeException('Unable to refresh the session', $e->getCode(), $e);
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($session->getUsrId())) {
+ throw new RuntimeException('Unable to refresh the session');
}
$this->session->clear();
@@ -145,7 +144,7 @@ class Authenticator
public function reinitUser()
{
if ($this->isAuthenticated()) {
- $this->user = \User_Adapter::getInstance($this->session->get('usr_id'), $this->app);
+ $this->user = $this->app['manipulator.user']->getRepository()->find($this->session->get('usr_id'));
} else {
$this->user = null;
}
diff --git a/lib/Alchemy/Phrasea/Authentication/Manager.php b/lib/Alchemy/Phrasea/Authentication/Manager.php
index bc3779b80e..707fab805a 100644
--- a/lib/Alchemy/Phrasea/Authentication/Manager.php
+++ b/lib/Alchemy/Phrasea/Authentication/Manager.php
@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Authentication;
use Alchemy\Phrasea\Model\Entities\Session;
+use Alchemy\Phrasea\Model\Entities\User;
class Manager
{
@@ -26,11 +27,11 @@ class Manager
/**
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return Session
*/
- public function openAccount(\User_Adapter $user)
+ public function openAccount(User $user)
{
return $this->authenticator->openAccount($user);
}
diff --git a/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php b/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php
index 92620e2da1..bb27e07eec 100644
--- a/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php
+++ b/lib/Alchemy/Phrasea/Authentication/SuggestionFinder.php
@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\Exception\NotAuthenticatedException;
use Alchemy\Phrasea\Authentication\Provider\Token\Token;
use Alchemy\Phrasea\Authentication\Provider\Token\Identity;
+use Alchemy\Phrasea\Model\Entities\User;
class SuggestionFinder
{
@@ -30,7 +31,7 @@ class SuggestionFinder
*
* @param Token $token
*
- * @return null|\User_Adapter
+ * @return null|User
*
* @throws NotAuthenticatedException In case the token is not authenticated.
*/
@@ -47,7 +48,7 @@ class SuggestionFinder
$stmt->closeCursor();
if ($row) {
- return \User_Adapter::getInstance($row['usr_id'], $this->app);
+ return $this->app['manipulator.user']->getRepository()->find($row['usr_id']);
}
}
diff --git a/lib/Alchemy/Phrasea/Command/CreateCollection.php b/lib/Alchemy/Phrasea/Command/CreateCollection.php
index 2cfa3e35a8..320c98f5cd 100644
--- a/lib/Alchemy/Phrasea/Command/CreateCollection.php
+++ b/lib/Alchemy/Phrasea/Command/CreateCollection.php
@@ -60,9 +60,7 @@ class CreateCollection extends Command
}
$app = $this->container;
- $this->container['manipulator.acl']->resetAdminRights(array_map(function ($id) use ($app) {
- return \User_Adapter::getInstance($id, $app);
- }, array_keys(\User_Adapter::get_sys_admins($this->container))));
+ $this->container['manipulator.acl']->resetAdminRights($this->container['manipulator.user']->getRepository()->findAdmins());
$this->container['dispatcher']->dispatch(PhraseaEvents::COLLECTION_CREATE, new CollectionCreateEvent($new_collection));
}
diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php
index 6c1d4392c8..b0ce71250b 100644
--- a/lib/Alchemy/Phrasea/Controller/Admin/Collection.php
+++ b/lib/Alchemy/Phrasea/Controller/Admin/Collection.php
@@ -200,8 +200,9 @@ class Collection implements ControllerProviderInterface
}
foreach (array_filter($newAdmins) as $admin) {
- $user = \User_Adapter::getInstance($admin, $app);
- $app['acl']->get($user)->update_rights_to_base($bas_id, ['order_master' => true]);
+ if (null !== $user = $app['manipulator.user']->getRepository()->find($admin)) {
+ $app['acl']->get($user)->update_rights_to_base($bas_id, array('order_master' => true));
+ }
}
$conn->commit();
diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php
index f53fee9b71..764cb5f1af 100644
--- a/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php
+++ b/lib/Alchemy/Phrasea/Controller/Admin/Dashboard.php
@@ -69,7 +69,7 @@ class Dashboard implements ControllerProviderInterface
$parameters = [
'cache_flushed' => $request->query->get('flush_cache') === 'ok',
- 'admins' => \User_Adapter::get_sys_admins($app),
+ 'admins' => $app['manipulator.user']->getRepository()->findAdmins(),
'email_status' => $emailStatus,
];
@@ -132,9 +132,7 @@ class Dashboard implements ControllerProviderInterface
*/
public function resetAdminRights(Application $app, Request $request)
{
- $app['manipulator.acl']->resetAdminRights(array_map(function ($id) use ($app) {
- return \User_Adapter::getInstance($id, $app);
- }, array_keys(\User_Adapter::get_sys_admins($app))));
+ $app['manipulator.acl']->resetAdminRights($app['manipulator.user']->getRepository()->findAdmins());
return $app->redirectPath('admin_dashbord');
}
@@ -150,15 +148,13 @@ class Dashboard implements ControllerProviderInterface
{
if (count($admins = $request->request->get('admins', [])) > 0) {
- if (!in_array($app['authentication']->getUser()->get_id(), $admins)) {
- $admins[] = $app['authentication']->getUser()->get_id();
+ if (!in_array($app['authentication']->getUser()->getId(), $admins)) {
+ $admins[] = $app['authentication']->getUser()->getId();
}
if ($admins > 0) {
\User_Adapter::set_sys_admins($app, array_filter($admins));
- $app['manipulator.acl']->resetAdminRights(array_map(function ($id) use ($app) {
- return \User_Adapter::getInstance($id, $app);
- }, array_keys(\User_Adapter::get_sys_admins($app))));
+ $app['manipulator.acl']->resetAdminRights($app['manipulator.user']->getRepository()->findAdmins());
}
}
diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php
index f0574df44b..8a30a840d7 100644
--- a/lib/Alchemy/Phrasea/Controller/Admin/Publications.php
+++ b/lib/Alchemy/Phrasea/Controller/Admin/Publications.php
@@ -52,7 +52,7 @@ class Publications implements ControllerProviderInterface
$feed = new Feed();
$publisher->setFeed($feed);
- $publisher->setUsrId($app['authentication']->getUser()->get_id());
+ $publisher->setUsrId($app['authentication']->getUser()->getId());
$publisher->setIsOwner(true);
$feed->addPublisher($publisher);
@@ -193,11 +193,11 @@ class Publications implements ControllerProviderInterface
$error = '';
try {
$request = $app['request'];
- $user = \User_Adapter::getInstance($request->request->get('usr_id'), $app);
- $feed = $app["EM"]->find('Phraseanet:Feed', $id);
+ $user = $app['manipulator.user']->getRepository()->find($request->request->get('usr_id'));
+ $feed = $app["EM"]->find('Alchemy\Phrasea\Model\Entities\Feed', $id);
$publisher = new FeedPublisher();
- $publisher->setUsrId($user->get_id());
+ $publisher->setUsrId($user->getId());
$publisher->setFeed($feed);
$feed->addPublisher($publisher);
diff --git a/lib/Alchemy/Phrasea/Controller/Admin/Users.php b/lib/Alchemy/Phrasea/Controller/Admin/Users.php
index 2f3e47bbec..24dbf71352 100644
--- a/lib/Alchemy/Phrasea/Controller/Admin/Users.php
+++ b/lib/Alchemy/Phrasea/Controller/Admin/Users.php
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Controller\Admin;
use Alchemy\Phrasea\Helper\User as UserHelper;
use Alchemy\Phrasea\Model\Entities\FtpCredential;
+use Alchemy\Phrasea\Model\Entities\User;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -173,24 +174,23 @@ class Users implements ControllerProviderInterface
];
foreach ($users->export() as $user) {
- /* @var $user \User_Adapter */
$userTable[] = [
- $user->get_id(),
- $user->get_login(),
- $user->get_lastname(),
- $user->get_firstname(),
- $user->get_email(),
- $user->get_creation_date()->format(DATE_ATOM),
- $user->get_modification_date()->format(DATE_ATOM),
- $user->get_address(),
- $user->get_city(),
- $user->get_zipcode(),
- $user->get_country(),
- $user->get_tel(),
- $user->get_fax(),
- $user->get_job(),
- $user->get_company(),
- $user->get_position()
+ $user->getId(),
+ $user->getLogin(),
+ $user->getLastName(),
+ $user->getFirstName(),
+ $user->getEmail(),
+ $user->getCreated()->format(DATE_ATOM),
+ $user->getUpdated()->format(DATE_ATOM),
+ $user->getAddress(),
+ $user->getCity(),
+ $user->getZipCode(),
+ $user->getCountry(),
+ $user->getPhone(),
+ $user->getFax(),
+ $user->getJob(),
+ $user->getCompany(),
+ $user->getActivity()
];
}
@@ -241,10 +241,10 @@ class Users implements ControllerProviderInterface
foreach ($elligible_users as $user) {
$datas[] = [
- 'email' => $user->get_email() ? : ''
- , 'login' => $user->get_login() ? : ''
- , 'name' => $user->get_display_name() ? : ''
- , 'id' => $user->get_id()
+ 'email' => $user->getEmail() ? : ''
+ , 'login' => $user->getLogin() ? : ''
+ , 'name' => $user->getDisplayName() ? : ''
+ , 'id' => $user->getId()
];
}
@@ -252,7 +252,6 @@ class Users implements ControllerProviderInterface
});
$controllers->post('/create/', function (Application $app) {
-
$datas = ['error' => false, 'message' => '', 'data' => null];
try {
$request = $app['request'];
@@ -262,10 +261,10 @@ class Users implements ControllerProviderInterface
} else {
$user = $module->create_newuser();
}
- if (!($user instanceof \User_Adapter))
+ if (!($user instanceof User))
throw new \Exception('Unknown error');
- $datas['data'] = $user->get_id();
+ $datas['data'] = $user->getId();
} catch (\Exception $e) {
$datas['error'] = true;
if ($request->request->get('template') == '1') {
@@ -321,22 +320,22 @@ class Users implements ControllerProviderInterface
foreach ($results as $user) {
$buffer[] = [
- $user->get_id()
- , $user->get_login()
- , $user->get_lastname()
- , $user->get_firstname()
- , $user->get_email()
- , $app['date-formatter']->format_mysql($user->get_creation_date())
- , $app['date-formatter']->format_mysql($user->get_modification_date())
- , $user->get_address()
- , $user->get_city()
- , $user->get_zipcode()
- , $user->get_country()
- , $user->get_tel()
- , $user->get_fax()
- , $user->get_job()
- , $user->get_company()
- , $user->get_position()
+ $user->getId()
+ , $user->getLogin()
+ , $user->getLastName()
+ , $user->getFirstName()
+ , $user->getEmail()
+ , $app['date-formatter']->format_mysql($user->getCreated())
+ , $app['date-formatter']->format_mysql($user->getUpdated())
+ , $user->getAddress()
+ , $user->getCity()
+ , $user->getZipCode()
+ , $user->getCountry()
+ , $user->getPhone()
+ , $user->getFax()
+ , $user->getJob()
+ , $user->getCompany()
+ , $user->getActivity()
];
}
} while (count($results) > 0);
@@ -366,7 +365,7 @@ class Users implements ControllerProviderInterface
$sql = 'SELECT usr_id, usr_login FROM usr WHERE model_of = :usr_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]);
+ $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->getId()));
$models = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -458,10 +457,10 @@ class Users implements ControllerProviderInterface
$cache_to_update = [];
foreach ($templates as $usr => $template_id) {
- $user = \User_Adapter::getInstance($usr, $app);
+ $user = $app['manipulator.user']->getRepository()->find($usr);
$cache_to_update[$usr] = true;
- $user_template = \User_Adapter::getInstance($template_id, $app);
+ $user_template = $app['manipulator.user']->getRepository()->find($template_id);
$base_ids = array_keys($app['acl']->get($user_template)->get_granted_base());
$app['acl']->get($user)->apply_model($user_template, $base_ids);
@@ -507,7 +506,7 @@ class Users implements ControllerProviderInterface
$stmt->closeCursor();
foreach ($accept as $usr => $bases) {
- $user = \User_Adapter::getInstance($usr, $app);
+ $user = $app['manipulator.user']->getRepository()->find($usr);
$cache_to_update[$usr] = true;
foreach ($bases as $bas) {
@@ -538,7 +537,7 @@ class Users implements ControllerProviderInterface
}
foreach (array_keys($cache_to_update) as $usr_id) {
- $user = \User_Adapter::getInstance($usr_id, $app);
+ $user = $app['manipulator.user']->getRepository()->find($usr_id);
$app['acl']->get($user)->delete_data_from_cache();
unset($user);
}
@@ -667,7 +666,7 @@ class Users implements ControllerProviderInterface
} elseif (in_array($loginToAdd, $loginNew)) {
$out['errors'][] = $app->trans("Login %login% is already defined in the file at line %line%", ['%login%' => $loginToAdd, '%line%' => $nbLine]);
} else {
- if (\User_Adapter::get_usr_id_from_login($app, $loginToAdd)) {
+ if (null !== $app['manipulator.user']->getRepository()->findByLogin($loginToAdd)) {
$out['errors'][] = $app->trans("Login %login% already exists in database", ['%login%' => $loginToAdd]);
} else {
$loginValid = true;
@@ -680,7 +679,7 @@ class Users implements ControllerProviderInterface
if ($mailToAdd === "") {
$out['errors'][] = $app->trans("Mail line %line% is empty", ['%line%' => $nbLine + 1]);
- } elseif (false !== \User_Adapter::get_usr_id_from_email($app, $mailToAdd)) {
+ } elseif (null !== $app['manipulator.user']->getRepository()->findByEmail($mailToAdd)) {
$out['errors'][] = $app->trans("Email '%email%' for login '%login%' already exists in database", ['%email%' => $mailToAdd, '%login%' => $loginToAdd]);
} else {
$mailValid = true;
@@ -727,7 +726,7 @@ class Users implements ControllerProviderInterface
GROUP BY usr_id";
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]);
+ $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->getId()));
$models = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -807,12 +806,13 @@ class Users implements ControllerProviderInterface
if (isset($curUser['usr_login']) && trim($curUser['usr_login']) !== ''
&& isset($curUser['usr_password']) && trim($curUser['usr_password']) !== ''
&& isset($curUser['usr_mail']) && trim($curUser['usr_mail']) !== '') {
- if (false === \User_Adapter::get_usr_id_from_login($app, $curUser['usr_login'])
- && false === \User_Adapter::get_usr_id_from_email($app, $curUser['usr_mail'])) {
- $NewUser = \User_Adapter::create($app, $curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail'], false);
+ if (null === $app['manipulator.user']->getRepository()->findByLogin($curUser['usr_login'])
+ && false === $app['manipulator.user']->getRepository()->findByEmail($curUser['usr_mail'])) {
+
+ $NewUser = $app['manipulator.user']->createUser($curUser['usr_login'], $curUser['usr_password'], $curUser['usr_mail']);
$ftpCredential = new FtpCredential();
- $ftpCredential->setUsrId($NewUser->get_id());
+ $ftpCredential->setUsrId($NewUser->getId());
if (isset($curUser['activeFTP'])) {
$ftpCredential->setActive((int) $curUser['activeFTP']);
@@ -830,38 +830,38 @@ class Users implements ControllerProviderInterface
$ftpCredential->setRepositoryPrefixName($curUser['prefixFTPfolder']);
}
if (isset($curUser['usr_prenom'])) {
- $NewUser->set_firstname($curUser['usr_prenom']);
+ $NewUser->setFirstName($curUser['usr_prenom']);
}
if (isset($curUser['usr_nom'])) {
- $NewUser->set_lastname($curUser['usr_nom']);
+ $NewUser->setLastName($curUser['usr_nom']);
}
if (isset($curUser['adresse'])) {
- $NewUser->set_address($curUser['adresse']);
+ $NewUser->setAdress($curUser['adresse']);
}
if (isset($curUser['cpostal'])) {
- $NewUser->set_zip($curUser['cpostal']);
+ $NewUser->setZipCode($curUser['cpostal']);
}
if (isset($curUser['usr_sexe'])) {
- $NewUser->set_gender((int) ($curUser['usr_sexe']));
+ $NewUser->setGender((int) ($curUser['usr_sexe']));
}
if (isset($curUser['tel'])) {
- $NewUser->set_tel($curUser['tel']);
+ $NewUser->setPhone($curUser['tel']);
}
if (isset($curUser['fax'])) {
- $NewUser->set_fax($curUser['fax']);
+ $NewUser->setFax($curUser['fax']);
}
if (isset($curUser['activite'])) {
- $NewUser->set_job($curUser['activite']);
+ $NewUser->setJob($curUser['activite']);
}
if (isset($curUser['fonction'])) {
- $NewUser->set_position($curUser['fonction']);
+ $NewUser->setPosition($curUser['fonction']);
}
if (isset($curUser['societe'])) {
- $NewUser->set_company($curUser['societe']);
+ $NewUser->setCompany($curUser['societe']);
}
$app['acl']->get($NewUser)->apply_model(
- \User_Adapter::getInstance($model, $app), array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['manage']))
+ $app['manipulator.user']->getRepository()->find($model), array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('manage')))
);
$nbCreation++;
diff --git a/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php b/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php
index 87a9d7044f..8471828907 100644
--- a/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php
+++ b/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php
@@ -91,7 +91,7 @@ class Oauth2 implements ControllerProviderInterface
return $app->redirectPath('oauth2_authorize', ['error' => 'account-locked']);
}
- $app['authentication']->openAccount(\User_Adapter::getInstance($usr_id, $app));
+ $app['authentication']->openAccount($app['manipulator.user']->getRepository()->find($usr_id));
}
return new Response($app['twig']->render($template, ["auth" => $oauth2_adapter]));
@@ -109,7 +109,7 @@ class Oauth2 implements ControllerProviderInterface
}
}
- $account = $oauth2_adapter->updateAccount($app['authentication']->getUser()->get_id());
+ $account = $oauth2_adapter->updateAccount($app['authentication']->getUser()->getId());
$params['account_id'] = $account->get_id();
diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1.php b/lib/Alchemy/Phrasea/Controller/Api/V1.php
index 9ff9766bc2..c5ff5b05a8 100644
--- a/lib/Alchemy/Phrasea/Controller/Api/V1.php
+++ b/lib/Alchemy/Phrasea/Controller/Api/V1.php
@@ -82,7 +82,7 @@ class V1 implements ControllerProviderInterface
return;
}
- $user = \User_Adapter::getInstance($oauth2_adapter->get_usr_id(), $app);
+ $user = $app['manipulator.user']->getRepository()->find($oauth2_adapter->get_usr_id());
$app['authentication']->openAccount($user);
$oauth2_adapter->remember_this_ses_id($app['session']->get('session_id'));
diff --git a/lib/Alchemy/Phrasea/Controller/Client/Root.php b/lib/Alchemy/Phrasea/Controller/Client/Root.php
index b1e135c434..bce28a9a2d 100644
--- a/lib/Alchemy/Phrasea/Controller/Client/Root.php
+++ b/lib/Alchemy/Phrasea/Controller/Client/Root.php
@@ -91,7 +91,7 @@ class Root implements ControllerProviderInterface
$result = $app['phraseanet.SE']->query($query, ($currentPage - 1) * $perPage, $perPage, $options);
$userQuery = new UserQuery();
- $userQuery->setUsrId($app['authentication']->getUser()->get_id());
+ $userQuery->setUsrId($app['authentication']->getUser()->getId());
$userQuery->setQuery($query);
$app['EM']->persist($userQuery);
@@ -171,7 +171,7 @@ class Root implements ControllerProviderInterface
'per_page' => $perPage,
'search_engine' => $app['phraseanet.SE'],
'search_engine_option' => $options->serialize(),
- 'history' => \queries::history($app, $app['authentication']->getUser()->get_id()),
+ 'history' => \queries::history($app, $app['authentication']->getUser()->getId()),
'result' => $result,
'proposals' => $currentPage === 1 ? $result->getProposals() : null,
'help' => count($resultData) === 0 ? $this->getHelpStartPage($app) : '',
diff --git a/lib/Alchemy/Phrasea/Controller/Lightbox.php b/lib/Alchemy/Phrasea/Controller/Lightbox.php
index c1b83b56f8..d7c89695b8 100644
--- a/lib/Alchemy/Phrasea/Controller/Lightbox.php
+++ b/lib/Alchemy/Phrasea/Controller/Lightbox.php
@@ -44,7 +44,7 @@ class Lightbox implements ControllerProviderInterface
return $app->redirectPath('homepage');
}
- $app['authentication']->openAccount(\User_Adapter::getInstance($usr_id, $app));
+ $app['authentication']->openAccount($app['manipulator.user']->getRepository()->find($usr_id));
try {
$datas = $app['tokens']->helloToken($request->query->get('LOG'));
@@ -468,15 +468,15 @@ class Lightbox implements ControllerProviderInterface
$expires = new \DateTime('+10 days');
$url = $app->url('lightbox', ['LOG' => $app['tokens']->getUrlToken(
\random::TYPE_VALIDATE
- , $basket->getValidation()->getInitiator($app)->get_id()
+ , $basket->getValidation()->getInitiator($app)->getId()
, $expires
, $basket->getId()
)]);
- $to = $basket->getValidation()->getInitiator($app)->get_id();
+ $to = $basket->getValidation()->getInitiator($app)->getId();
$params = [
'ssel_id' => $basket->getId(),
- 'from' => $app['authentication']->getUser()->get_id(),
+ 'from' => $app['authentication']->getUser()->getId(),
'url' => $url,
'to' => $to
];
diff --git a/lib/Alchemy/Phrasea/Controller/Permalink.php b/lib/Alchemy/Phrasea/Controller/Permalink.php
index 261a3c1d14..d6c438c54c 100644
--- a/lib/Alchemy/Phrasea/Controller/Permalink.php
+++ b/lib/Alchemy/Phrasea/Controller/Permalink.php
@@ -154,16 +154,14 @@ class Permalink extends AbstractDelivery
$watermark = $stamp = false;
if ($app['authentication']->isAuthenticated()) {
- $user = \User_Adapter::getInstance($app['authentication']->getUser()->get_id(), $app);
-
- $watermark = !$app['acl']->get($user)->has_right_on_base($record->get_base_id(), 'nowatermark');
+ $watermark = !$app['acl']->get($app['authentication']->getUser())->has_right_on_base($record->get_base_id(), 'nowatermark');
if ($watermark) {
$repository = $app['EM']->getRepository('Phraseanet:BasketElement');
- if (count($repository->findReceivedValidationElementsByRecord($record, $user)) > 0) {
+ if (count($repository->findReceivedValidationElementsByRecord($record, $app['authentication']->getUser())) > 0) {
$watermark = false;
- } elseif (count($repository->findReceivedElementsByRecord($record, $user)) > 0) {
+ } elseif (count($repository->findReceivedElementsByRecord($record, $app['authentication']->getUser())) > 0) {
$watermark = false;
}
}
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php
index 81e82ba00a..26c6566f5d 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php
@@ -173,7 +173,7 @@ class Bridge implements ControllerProviderInterface
try {
$account = \Bridge_Account::load_account($app, $account_id);
- if ($account->get_user()->get_id() !== $app['authentication']->getUser()->get_id()) {
+ if ($account->get_user()->getId() !== $app['authentication']->getUser()->getId()) {
throw new HttpException(403, 'Access forbiden');
}
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Download.php b/lib/Alchemy/Phrasea/Controller/Prod/Download.php
index 07f93f6fc1..778491c79d 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Download.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Download.php
@@ -66,7 +66,7 @@ class Download implements ControllerProviderInterface
$token = $app['tokens']->getUrlToken(
\random::TYPE_DOWNLOAD,
- $app['authentication']->getUser()->get_id(),
+ $app['authentication']->getUser()->getId(),
new \DateTime('+3 hours'), // Token lifetime
serialize($list)
);
@@ -77,7 +77,7 @@ class Download implements ControllerProviderInterface
$app['events-manager']->trigger('__DOWNLOAD__', [
'lst' => $lst,
- 'downloader' => $app['authentication']->getUser()->get_id(),
+ 'downloader' => $app['authentication']->getUser()->getId(),
'subdefs' => $subdefs,
'from_basket' => $ssttid,
'export_file' => $download->getExportName()
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Export.php b/lib/Alchemy/Phrasea/Controller/Prod/Export.php
index b5b43c8398..51d617b63c 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Export.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Export.php
@@ -206,7 +206,7 @@ class Export implements ControllerProviderInterface
$destMails[] = $mail;
} else {
$app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [
- 'usr_id' => $app['authentication']->getUser()->get_id(),
+ 'usr_id' => $app['authentication']->getUser()->getId(),
'lst' => $lst,
'ssttid' => $ssttid,
'dest' => $mail,
@@ -232,7 +232,7 @@ class Export implements ControllerProviderInterface
$url = $app->url('prepare_download', ['token' => $token, 'anonymous']);
- $emitter = new Emitter($app['authentication']->getUser()->get_display_name(), $app['authentication']->getUser()->get_email());
+ $emitter = new Emitter($app['authentication']->getUser()->getDisplayName(), $app['authentication']->getUser()->getEmail());
foreach ($destMails as $key => $mail) {
try {
@@ -253,7 +253,7 @@ class Export implements ControllerProviderInterface
if (count($remaingEmails) > 0) {
foreach ($remaingEmails as $mail) {
$app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [
- 'usr_id' => $app['authentication']->getUser()->get_id(),
+ 'usr_id' => $app['authentication']->getUser()->getId(),
'lst' => $lst,
'ssttid' => $ssttid,
'dest' => $mail,
@@ -264,7 +264,7 @@ class Export implements ControllerProviderInterface
} elseif (!$token && count($destMails) > 0) { //couldn't generate token
foreach ($destMails as $mail) {
$app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', [
- 'usr_id' => $app['authentication']->getUser()->get_id(),
+ 'usr_id' => $app['authentication']->getUser()->getId(),
'lst' => $lst,
'ssttid' => $ssttid,
'dest' => $mail,
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php
index afe6feac1c..6acae14475 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php
@@ -49,7 +49,7 @@ class Feed implements ControllerProviderInterface
$app->abort(404, "Feed not found");
}
- $publisher = $app['EM']->getRepository('Phraseanet:FeedPublisher')->findOneBy(['feed' => $feed, 'usrId' => $app['authentication']->getUser()->get_id()]);
+ $publisher = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedPublisher')->findOneBy(array('feed' => $feed, 'usrId' => $app['authentication']->getUser()->getId()));
if ('' === $title = trim($request->request->get('title', ''))) {
$app->abort(400, "Bad request");
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Order.php b/lib/Alchemy/Phrasea/Controller/Prod/Order.php
index 56e3f38ae8..47b666c4f6 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Order.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Order.php
@@ -94,7 +94,7 @@ class Order implements ControllerProviderInterface
if (!$records->isEmpty()) {
$order = new OrderEntity();
- $order->setUsrId($app['authentication']->getUser()->get_id());
+ $order->setUsrId($app['authentication']->getUser()->getId());
$order->setDeadline((null !== $deadLine = $request->request->get('deadline')) ? new \DateTime($deadLine) : $deadLine);
$order->setOrderUsage($request->request->get('use', ''));
foreach ($records as $key => $record) {
@@ -242,7 +242,7 @@ class Order implements ControllerProviderInterface
throw new NotFoundHttpException('Order not found');
}
- $dest_user = \User_Adapter::getInstance($order->getUsrId(), $app);
+ $dest_user = $app['manipulator.user']->getRepository()->find($order->getUsrId());
$basket = $order->getBasket();
@@ -267,7 +267,7 @@ class Order implements ControllerProviderInterface
$basketElement->setRecord($record);
$basketElement->setBasket($basket);
- $orderElement->setOrderMasterId($app['authentication']->getUser()->get_id());
+ $orderElement->setOrderMasterId($app['authentication']->getUser()->getId());
$orderElement->setDeny(false);
$orderElement->getOrder()->setBasket($basket);
@@ -284,8 +284,8 @@ class Order implements ControllerProviderInterface
$app['events-manager']->trigger('__ORDER_DELIVER__', [
'ssel_id' => $order->getBasket()->getId(),
- 'from' => $app['authentication']->getUser()->get_id(),
- 'to' => $dest_user->get_id(),
+ 'from' => $app['authentication']->getUser()->getId(),
+ 'to' => $dest_user->getId(),
'n' => $n
]);
}
@@ -333,7 +333,7 @@ class Order implements ControllerProviderInterface
$elements = $request->request->get('elements', []);
foreach ($order->getElements() as $orderElement) {
if (in_array($orderElement->getId(),$elements)) {
- $orderElement->setOrderMasterId($app['authentication']->getUser()->get_id());
+ $orderElement->setOrderMasterId($app['authentication']->getUser()->getId());
$orderElement->setDeny(true);
$app['EM']->persist($orderElement);
@@ -346,7 +346,7 @@ class Order implements ControllerProviderInterface
$order->setTodo($order->getTodo() - $n);
$app['events-manager']->trigger('__ORDER_NOT_DELIVERED__', [
- 'from' => $app['authentication']->getUser()->get_id(),
+ 'from' => $app['authentication']->getUser()->getId(),
'to' => $order->getUsrId(),
'n' => $n
]);
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Push.php b/lib/Alchemy/Phrasea/Controller/Prod/Push.php
index 14910240b9..593903f9a2 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Push.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Push.php
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\BasketElement;
+use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\UsrList;
use Alchemy\Phrasea\Model\Entities\UsrListEntry;
use Alchemy\Phrasea\Model\Entities\ValidationSession;
@@ -30,16 +31,16 @@ class Push implements ControllerProviderInterface
{
protected function getUserFormatter()
{
- return function (\User_Adapter $user) {
- $subtitle = array_filter([$user->get_job(), $user->get_company()]);
+ return function (User $user) {
+ $subtitle = array_filter(array($user->getJob(), $user->getCompany()));
return [
'type' => 'USER'
- , 'usr_id' => $user->get_id()
- , 'firstname' => $user->get_firstname()
- , 'lastname' => $user->get_lastname()
- , 'email' => $user->get_email()
- , 'display_name' => $user->get_display_name()
+ , 'usr_id' => $user->getId()
+ , 'firstname' => $user->getFirstName()
+ , 'lastname' => $user->getLastName()
+ , 'email' => $user->getEmail()
+ , 'display_name' => $user->getDisplayName()
, 'subtitle' => implode(', ', $subtitle)
];
};
@@ -87,7 +88,7 @@ class Push implements ControllerProviderInterface
$user = $value->getRessource();
- $Users->set($user->get_id(), $user);
+ $Users->set($user->getId(), $user);
}
}
}
@@ -161,7 +162,7 @@ class Push implements ControllerProviderInterface
try {
$pusher = new RecordHelper\Push($app, $app['request']);
- $push_name = $request->request->get('name', $app->trans('Push from %user%', ['%user%' => $app['authentication']->getUser()->get_display_name()]));
+ $push_name = $request->request->get('name', $app->trans('Push from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName()]));
$push_description = $request->request->get('push_description');
$receivers = $request->request->get('participants');
@@ -176,7 +177,7 @@ class Push implements ControllerProviderInterface
foreach ($receivers as $receiver) {
try {
- $user_receiver = \User_Adapter::getInstance($receiver['usr_id'], $app);
+ $user_receiver = $app['manipulator.user']->getRepository()->find($receiver['usr_id']);
} catch (\Exception $e) {
throw new ControllerException($app->trans('Unknown user %user_id%', ['%user_id%' => $receiver['usr_id']]));
}
@@ -220,15 +221,15 @@ class Push implements ControllerProviderInterface
'basket' => $Basket->getId(),
'LOG' => $app['tokens']->getUrlToken(
\random::TYPE_VIEW,
- $user_receiver->get_id(),
+ $user_receiver->getId(),
null,
$Basket->getId()
)
]);
- $receipt = $request->get('recept') ? $app['authentication']->getUser()->get_email() : '';
+ $receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';
- $params = [
+ $params = array(
'from' => $app['authentication']->getUser()->get_id()
, 'from_email' => $app['authentication']->getUser()->get_email()
, 'to' => $user_receiver->get_id()
@@ -244,7 +245,7 @@ class Push implements ControllerProviderInterface
}
$app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox())
- ->log($BasketElement->getRecord($app), \Session_Logger::EVENT_VALIDATE, $user_receiver->get_id(), '');
+ ->log($BasketElement->getRecord($app), \Session_Logger::EVENT_VALIDATE, $user_receiver->getId(), '');
$app['EM']->flush();
@@ -279,7 +280,7 @@ class Push implements ControllerProviderInterface
$repository = $app['EM']->getRepository('Phraseanet:Basket');
- $validation_name = $request->request->get('name', $app->trans('Validation from %user%', ['%user%' => $app['authentication']->getUser()->get_display_name()]));
+ $validation_name = $request->request->get('name', $app->trans('Validation from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName()]));
$validation_description = $request->request->get('validation_description');
$participants = $request->request->get('participants');
@@ -337,16 +338,16 @@ class Push implements ControllerProviderInterface
$found = false;
foreach ($participants as $key => $participant) {
- if ($participant['usr_id'] == $app['authentication']->getUser()->get_id()) {
+ if ($participant['usr_id'] == $app['authentication']->getUser()->getId()) {
$found = true;
break;
}
}
if (!$found) {
- $participants[$app['authentication']->getUser()->get_id()] = [
+ $participants[$app['authentication']->getUser()->get_id()] = array(
'see_others' => 1,
- 'usr_id' => $app['authentication']->getUser()->get_id(),
+ 'usr_id' => $app['authentication']->getUser()->getId(),
'agree' => 0,
'HD' => 0
];
@@ -359,7 +360,7 @@ class Push implements ControllerProviderInterface
}
try {
- $participant_user = \User_Adapter::getInstance($participant['usr_id'], $app);
+ $participant_user = $app['manipulator.user']->getRepository()->find($participant['usr_id']);
} catch (\Exception $e) {
throw new ControllerException($app->trans('Unknown user %usr_id%', ['%usr_id%' => $participant['usr_id']]));
}
@@ -404,7 +405,7 @@ class Push implements ControllerProviderInterface
$app['EM']->persist($ValidationData);
$app['phraseanet.logger']($BasketElement->getRecord($app)->get_databox())
- ->log($BasketElement->getRecord($app), \Session_Logger::EVENT_PUSH, $participant_user->get_id(), '');
+ ->log($BasketElement->getRecord($app), \Session_Logger::EVENT_PUSH, $participant_user->getId(), '');
$Participant->addData($ValidationData);
}
@@ -417,15 +418,15 @@ class Push implements ControllerProviderInterface
'basket' => $Basket->getId(),
'LOG' => $app['tokens']->getUrlToken(
\random::TYPE_VALIDATE,
- $participant_user->get_id(),
+ $participant_user->getId(),
null,
$Basket->getId()
)
]);
- $receipt = $request->get('recept') ? $app['authentication']->getUser()->get_email() : '';
+ $receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';
- $params = [
+ $params = array(
'from' => $app['authentication']->getUser()->get_id(),
'from_email' => $app['authentication']->getUser()->get_email(),
'to' => $participant_user->get_id(),
@@ -533,8 +534,7 @@ class Push implements ControllerProviderInterface
$email = $request->request->get('email');
try {
- $usr_id = \User_Adapter::get_usr_id_from_email($app, $email);
- $user = \User_Adapter::getInstance($usr_id, $app);
+ $user = $app['manipulator.user']->getRepository()->findByEmail($email);
$result['message'] = $app->trans('User already exists');
$result['success'] = true;
@@ -543,11 +543,11 @@ class Push implements ControllerProviderInterface
}
- if (!$user instanceof \User_Adapter) {
+ if (!$user instanceof User) {
try {
$password = \random::generatePassword();
- $user = \User_Adapter::create($app, $email, $password, $email, false);
+ $user = $app['manipulator.user']->getRepository()->createUser($email, $password, $email);
$user->set_firstname($request->request->get('firstname'))
->set_lastname($request->request->get('lastname'));
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php
index d926da2426..d3d7478413 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php
@@ -73,7 +73,7 @@ class Query implements ControllerProviderInterface
$result = $app['phraseanet.SE']->query($query, (($page - 1) * $perPage), $perPage, $options);
$userQuery = new UserQuery();
- $userQuery->setUsrId($app['authentication']->getUser()->get_id());
+ $userQuery->setUsrId($app['authentication']->getUser()->getId());
$userQuery->setQuery($result->getQuery());
$app['EM']->persist($userQuery);
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Root.php b/lib/Alchemy/Phrasea/Controller/Prod/Root.php
index 284938fbb1..19b780997e 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Root.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Root.php
@@ -119,7 +119,7 @@ class Root implements ControllerProviderInterface
'GV_google_api' => $app['conf']->get(['registry', 'webservices', 'google-charts-enabled']),
'queries_topics' => $queries_topics,
'search_status' => \databox_status::getSearchStatus($app),
- 'queries_history' => \queries::history($app, $app['authentication']->getUser()->get_id()),
+ 'queries_history' => \queries::history($app, $app['authentication']->getUser()->getId()),
'thesau_js_list' => $thjslist,
'thesau_json_sbas' => json_encode($sbas),
'thesau_json_bas2sbas' => json_encode($bas2sbas),
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php
index 56eb7f4d08..aff22b4728 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Tooltip.php
@@ -89,7 +89,7 @@ class Tooltip implements ControllerProviderInterface
public function displayUserBadge(Application $app, $usr_id)
{
- $user = \User_Adapter::getInstance($usr_id, $app);
+ $user = $app['manipulator.user']->getRepository()->find($usr_id);
return $app['twig']->render(
'prod/Tooltip/User.html.twig'
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php
index 1a4919d6d6..7e8c15e2ff 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/Upload.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/Upload.php
@@ -158,7 +158,7 @@ class Upload implements ControllerProviderInterface
$collection = \collection::get_from_base_id($app, $base_id);
$lazaretSession = new LazaretSession();
- $lazaretSession->setUsrId($app['authentication']->getUser()->get_id());
+ $lazaretSession->setUsrId($app['authentication']->getUser()->getId());
$app['EM']->persist($lazaretSession);
diff --git a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php
index db89ed8a4c..e58b18ce20 100644
--- a/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php
+++ b/lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php
@@ -90,26 +90,26 @@ class UsrLists implements ControllerProviderInterface
$owners = $entries = [];
foreach ($list->getOwners() as $owner) {
- $owners[] = [
- 'usr_id' => $owner->getUser($app)->get_id(),
- 'display_name' => $owner->getUser($app)->get_display_name(),
- 'position' => $owner->getUser($app)->get_position(),
- 'job' => $owner->getUser($app)->get_job(),
- 'company' => $owner->getUser($app)->get_company(),
- 'email' => $owner->getUser($app)->get_email(),
+ $owners[] = array(
+ 'usr_id' => $owner->getUser($app)->getId(),
+ 'display_name' => $owner->getUser($app)->getDisplayName(),
+ 'position' => $owner->getUser($app)->getActivity(),
+ 'job' => $owner->getUser($app)->getJob(),
+ 'company' => $owner->getUser($app)->getCompany(),
+ 'email' => $owner->getUser($app)->getEmail(),
'role' => $owner->getRole()
- ];
+ );
}
foreach ($list->getEntries() as $entry) {
- $entries[] = [
- 'usr_id' => $owner->getUser($app)->get_id(),
- 'display_name' => $owner->getUser($app)->get_display_name(),
- 'position' => $owner->getUser($app)->get_position(),
- 'job' => $owner->getUser($app)->get_job(),
- 'company' => $owner->getUser($app)->get_company(),
- 'email' => $owner->getUser($app)->get_email(),
- ];
+ $entries[] = array(
+ 'usr_id' => $owner->getUser($app)->getId(),
+ 'display_name' => $owner->getUser($app)->getDisplayName(),
+ 'position' => $owner->getUser($app)->getActivity(),
+ 'job' => $owner->getUser($app)->getJob(),
+ 'company' => $owner->getUser($app)->getCompany(),
+ 'email' => $owner->getUser($app)->getEmail(),
+ );
}
/* @var $list UsrList */
@@ -201,26 +201,26 @@ class UsrLists implements ControllerProviderInterface
$owners = new ArrayCollection();
foreach ($list->getOwners() as $owner) {
- $owners[] = [
- 'usr_id' => $owner->getUser($app)->get_id(),
- 'display_name' => $owner->getUser($app)->get_display_name(),
- 'position' => $owner->getUser($app)->get_position(),
- 'job' => $owner->getUser($app)->get_job(),
- 'company' => $owner->getUser($app)->get_company(),
- 'email' => $owner->getUser($app)->get_email(),
+ $owners[] = array(
+ 'usr_id' => $owner->getUser($app)->getId(),
+ 'display_name' => $owner->getUser($app)->getDisplayName(),
+ 'position' => $owner->getUser($app)->getActivity(),
+ 'job' => $owner->getUser($app)->getJob(),
+ 'company' => $owner->getUser($app)->getCompany(),
+ 'email' => $owner->getUser($app)->getEmail(),
'role' => $owner->getRole($app)
- ];
+ );
}
foreach ($list->getEntries() as $entry) {
- $entries[] = [
- 'usr_id' => $entry->getUser($app)->get_id(),
- 'display_name' => $entry->getUser($app)->get_display_name(),
- 'position' => $entry->getUser($app)->get_position(),
- 'job' => $entry->getUser($app)->get_job(),
- 'company' => $entry->getUser($app)->get_company(),
- 'email' => $entry->getUser($app)->get_email(),
- ];
+ $entries[] = array(
+ 'usr_id' => $entry->getUser($app)->getId(),
+ 'display_name' => $entry->getUser($app)->getDisplayName(),
+ 'position' => $entry->getUser($app)->getActivity(),
+ 'job' => $entry->getUser($app)->getJob(),
+ 'company' => $entry->getUser($app)->getCompany(),
+ 'email' => $entry->getUser($app)->getEmail(),
+ );
}
return $app->json([
@@ -370,7 +370,7 @@ class UsrLists implements ControllerProviderInterface
$inserted_usr_ids = [];
foreach ($request->request->get('usr_ids') as $usr_id) {
- $user_entry = \User_Adapter::getInstance($usr_id, $app);
+ $user_entry = $app['manipulator.user']->getRepository()->find($usr_id);
if ($list->has($user_entry, $app))
continue;
@@ -383,7 +383,7 @@ class UsrLists implements ControllerProviderInterface
$app['EM']->persist($entry);
- $inserted_usr_ids[] = $user_entry->get_id();
+ $inserted_usr_ids[] = $user_entry->getId();
}
$app['EM']->flush();
@@ -461,10 +461,10 @@ class UsrLists implements ControllerProviderInterface
throw new ControllerException($app->trans('You are not authorized to do this'));
}
- $new_owner = \User_Adapter::getInstance($usr_id, $app);
+ $new_owner = $app['manipulator.user']->getRepository()->find($usr_id);
if ($list->hasAccess($new_owner, $app)) {
- if ($new_owner->get_id() == $app['authentication']->getUser()->get_id()) {
+ if ($new_owner->getId() == $app['authentication']->getUser()->getId()) {
throw new ControllerException('You can not downgrade your Admin right');
}
diff --git a/lib/Alchemy/Phrasea/Controller/Root/Account.php b/lib/Alchemy/Phrasea/Controller/Root/Account.php
index 1a956f3c4e..6fc69828ed 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/Account.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/Account.php
@@ -93,7 +93,7 @@ class Account implements ControllerProviderInterface
$data = $form->getData();
$user = $app['authentication']->getUser();
- if ($app['auth.password-encoder']->isPasswordValid($user->get_password(), $data['oldPassword'], $user->get_nonce())) {
+ if ($app['auth.password-encoder']->isPasswordValid($user->getPassword(), $data['oldPassword'], $user->getNonce())) {
$user->set_password($data['password']);
$app->addFlash('success', $app->trans('login::notification: Mise a jour du mot de passe avec succes'));
@@ -126,7 +126,7 @@ class Account implements ControllerProviderInterface
$user = $app['authentication']->getUser();
- if (!$app['auth.password-encoder']->isPasswordValid($user->get_password(), $password, $user->get_nonce())) {
+ if (!$app['auth.password-encoder']->isPasswordValid($user->getPassword(), $password, $user->getNonce())) {
$app->addFlash('error', $app->trans('admin::compte-utilisateur:ftp: Le mot de passe est errone'));
return $app->redirectPath('account_reset_email');
@@ -145,8 +145,8 @@ class Account implements ControllerProviderInterface
}
$date = new \DateTime('1 day');
- $token = $app['tokens']->getUrlToken(\random::TYPE_EMAIL, $app['authentication']->getUser()->get_id(), $date, $app['authentication']->getUser()->get_email());
- $url = $app->url('account_reset_email', ['token' => $token]);
+ $token = $app['tokens']->getUrlToken(\random::TYPE_EMAIL, $app['authentication']->getUser()->getId(), $date, $app['authentication']->getUser()->getEmail());
+ $url = $app->url('account_reset_email', array('token' => $token));
try {
$receiver = Receiver::fromUser($app['authentication']->getUser());
@@ -179,7 +179,7 @@ class Account implements ControllerProviderInterface
if (null !== $token = $request->query->get('token')) {
try {
$datas = $app['tokens']->helloToken($token);
- $user = \User_Adapter::getInstance((int) $datas['usr_id'], $app);
+ $user = $app['manipulator.user']->getRepository()->find((int) $datas['usr_id']);
$user->set_email($datas['datas']);
$app['tokens']->removeToken($token);
@@ -239,9 +239,9 @@ class Account implements ControllerProviderInterface
{
require_once $app['root.path'] . '/lib/classes/deprecated/inscript.api.php';
- return $app['twig']->render('account/access.html.twig', [
- 'inscriptions' => giveMeBases($app, $app['authentication']->getUser()->get_id())
- ]);
+ return $app['twig']->render('account/access.html.twig', array(
+ 'inscriptions' => giveMeBases($app, $app['authentication']->getUser()->getId())
+ ));
}
/**
@@ -318,11 +318,11 @@ class Account implements ControllerProviderInterface
*/
public function displayAccount(Application $app, Request $request)
{
- return $app['twig']->render('account/account.html.twig', [
+ return $app['twig']->render('account/account.html.twig', array(
'user' => $app['authentication']->getUser(),
'evt_mngr' => $app['events-manager'],
- 'notifications' => $app['events-manager']->list_notifications_available($app['authentication']->getUser()->get_id()),
- ]);
+ 'notifications' => $app['events-manager']->list_notifications_available($app['authentication']->getUser()->getId()),
+ ));
}
/**
@@ -410,7 +410,7 @@ class Account implements ControllerProviderInterface
$requestedNotifications = (array) $request->request->get('notifications', []);
- foreach ($app['events-manager']->list_notifications_available($app['authentication']->getUser()->get_id()) as $notifications) {
+ foreach ($app['events-manager']->list_notifications_available($app['authentication']->getUser()->getId()) as $notifications) {
foreach ($notifications as $notification) {
if (isset($requestedNotifications[$notification['id']])) {
$app['authentication']->getUser()->set_notification_preference($app, $notification['id'], '1');
diff --git a/lib/Alchemy/Phrasea/Controller/Root/Login.php b/lib/Alchemy/Phrasea/Controller/Root/Login.php
index 74b6a12357..e4303d29a3 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/Login.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/Login.php
@@ -23,6 +23,7 @@ use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\Exception\FormProcessingException;
use Alchemy\Phrasea\Exception\RuntimeException;
+use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
use Alchemy\Phrasea\Model\Entities\UsrAuthProvider;
use Alchemy\Phrasea\Notification\Receiver;
@@ -362,7 +363,7 @@ class Login implements ControllerProviderInterface
$data['login'] = $data['email'];
}
- $user = \User_Adapter::create($app, $data['login'], $data['password'], $data['email'], false);
+ $user = $app['manipulator.user']->createUser($data['login'], $data['password'], $data['email'], false);
foreach ([
'gender' => 'set_gender',
@@ -391,11 +392,9 @@ class Login implements ControllerProviderInterface
if ($app['conf']->get(['registry', 'registration', 'auto-register-enabled'])) {
- $template_user_id = \User_Adapter::get_usr_id_from_login($app, 'autoregister');
+ $template_user = $app['manipulator.user']->getRepository()->findbyLogin('autoregister');
- $template_user = \User_Adapter::getInstance($template_user_id, $app);
-
- $base_ids = [];
+ $base_ids = array();
foreach (array_keys($inscOK) as $base_id) {
$base_ids[] = $base_id;
@@ -417,11 +416,11 @@ class Login implements ControllerProviderInterface
$demandOK[$base_id] = true;
}
- $params = [
+ $params = array(
'demand' => $demandOK,
'autoregister' => $autoReg,
- 'usr_id' => $user->get_id()
- ];
+ 'usr_id' => $user->getId()
+ );
$app['events-manager']->trigger('__REGISTER_AUTOREGISTER__', $params);
$app['events-manager']->trigger('__REGISTER_APPROVAL__', $params);
@@ -462,12 +461,12 @@ class Login implements ControllerProviderInterface
]));
}
- private function attachProviderToUser(EntityManager $em, ProviderInterface $provider, \User_Adapter $user)
+ private function attachProviderToUser(EntityManager $em, ProviderInterface $provider, User $user)
{
$usrAuthProvider = new UsrAuthProvider();
$usrAuthProvider->setDistantId($provider->getToken()->getId());
$usrAuthProvider->setProvider($provider->getId());
- $usrAuthProvider->setUsrId($user->get_id());
+ $usrAuthProvider->setUsrId($user->getId());
try {
$provider->logout();
@@ -492,7 +491,7 @@ class Login implements ControllerProviderInterface
}
try {
- $user = \User_Adapter::getInstance((int) $usrId, $app);
+ $user = $app['manipulator.user']->getRepository()->find((int) $usrId);
} catch (\Exception $e) {
$app->addFlash('error', $app->trans('Invalid link.'));
@@ -514,17 +513,17 @@ class Login implements ControllerProviderInterface
* Sends an account unlock email.
*
* @param PhraseaApplication $app
- * @param \User_Adapter $user
+ * @param User $user
*
* @throws InvalidArgumentException
* @throws RuntimeException
*/
- private function sendAccountUnlockEmail(PhraseaApplication $app, \User_Adapter $user)
+ private function sendAccountUnlockEmail(PhraseaApplication $app, User $user)
{
$receiver = Receiver::fromUser($user);
$expire = new \DateTime('+3 days');
- $token = $app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $user->get_id(), $expire, $user->get_email());
+ $token = $app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $user->getId(), $expire, $user->getEmail());
$mail = MailRequestEmailConfirmation::create($app, $receiver);
$mail->setButtonUrl($app->url('login_register_confirm', ['code' => $token]));
@@ -557,14 +556,14 @@ class Login implements ControllerProviderInterface
}
try {
- $user = \User_Adapter::getInstance((int) $datas['usr_id'], $app);
+ $user = $app['manipulator.user']->getRepository()->find((int) $datas['usr_id']);
} catch (\Exception $e) {
$app->addFlash('error', $app->trans('Invalid unlock link.'));
return $app->redirectPath('homepage');
}
- if (!$user->get_mail_locked()) {
+ if (!$user->isMailLocked()) {
$app->addFlash('info', $app->trans('Account is already unlocked, you can login.'));
return $app->redirectPath('homepage');
@@ -621,7 +620,7 @@ class Login implements ControllerProviderInterface
$datas = $app['tokens']->helloToken($token);
- $user = \User_Adapter::getInstance($datas['usr_id'], $app);
+ $user = $app['manipulator.user']->getRepository()->find($datas['usr_id']);
$user->set_password($data['password']);
$app['tokens']->removeToken($token);
@@ -660,7 +659,7 @@ class Login implements ControllerProviderInterface
$data = $form->getData();
try {
- $user = \User_Adapter::getInstance(\User_Adapter::get_usr_id_from_email($app, $data['email']), $app);
+ $user = $app['manipulator.user']->getRepository()->findByEmail($data['email']);
} catch (\Exception $e) {
throw new FormProcessingException($app->trans('phraseanet::erreur: Le compte n\'a pas ete trouve'));
}
@@ -671,7 +670,7 @@ class Login implements ControllerProviderInterface
throw new FormProcessingException($app->trans('Invalid email address'));
}
- $token = $app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $user->get_id(), new \DateTime('+1 day'));
+ $token = $app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $user->getId(), new \DateTime('+1 day'));
if (!$token) {
return $app->abort(500, 'Unable to generate a token');
@@ -680,7 +679,7 @@ class Login implements ControllerProviderInterface
$url = $app->url('login_renew_password', ['token' => $token], true);
$mail = MailRequestPasswordUpdate::create($app, $receiver);
- $mail->setLogin($user->get_login());
+ $mail->setLogin($user->getLogin());
$mail->setButtonUrl($url);
$app['notification.deliverer']->deliver($mail);
@@ -808,10 +807,7 @@ class Login implements ControllerProviderInterface
$app['dispatcher']->dispatch(PhraseaEvents::PRE_AUTHENTICATE, new PreAuthenticate($request, $context));
$password = \random::generatePassword(24);
- $user = \User_Adapter::create($app, 'invite', $password, null, false, true);
-
- $inviteUsrid = \User_Adapter::get_usr_id_from_login($app, 'invite');
- $invite_user = \User_Adapter::getInstance($inviteUsrid, $app);
+ $invite_user = $app['manipulator.user']->createUser('invite', $password);
$usr_base_ids = array_keys($app['acl']->get($user)->get_granted_base());
$app['acl']->get($user)->revoke_access_from_bases($usr_base_ids);
@@ -822,7 +818,7 @@ class Login implements ControllerProviderInterface
$this->postAuthProcess($app, $user);
$response = $this->generateAuthResponse($app, $app['browser'], $request->request->get('redirect'));
- $response->headers->setCookie(new Cookie('invite-usr-id', $user->get_id()));
+ $response->headers->setCookie(new Cookie('invite-usr-id', $user->getId()));
$event = new PostAuthenticate($request, $response, $user, $context);
$app['dispatcher']->dispatch(PhraseaEvents::POST_AUTHENTICATE, $event);
@@ -849,7 +845,7 @@ class Login implements ControllerProviderInterface
}
// move this in an event
- public function postAuthProcess(PhraseaApplication $app, \User_Adapter $user)
+ public function postAuthProcess(PhraseaApplication $app, User $user)
{
$date = new \DateTime('+' . (int) $app['conf']->get(['registry', 'actions', 'validation-reminder-days']) . ' days');
@@ -885,7 +881,7 @@ class Login implements ControllerProviderInterface
$session = $app['authentication']->openAccount($user);
- if ($user->get_locale() != $app['locale']) {
+ if ($user->getLocale() != $app['locale']) {
$user->set_locale($app['locale']);
}
@@ -1047,7 +1043,7 @@ class Login implements ControllerProviderInterface
throw new AuthenticationException(call_user_func($redirector, $params));
}
- $user = \User_Adapter::getInstance($usr_id, $app);
+ $user = $app['manipulator.user']->getRepository()->find($usr_id);
$session = $this->postAuthProcess($app, $user);
@@ -1056,13 +1052,13 @@ class Login implements ControllerProviderInterface
if ($request->cookies->has('postlog') && $request->cookies->get('postlog') == '1') {
if (!$user->is_guest() && $request->cookies->has('invite-usr_id')) {
- if ($user->get_id() != $inviteUsrId = $request->cookies->get('invite-usr_id')) {
+ if ($user->getId() != $inviteUsrId = $request->cookies->get('invite-usr_id')) {
$repo = $app['EM']->getRepository('Phraseanet:Basket');
$baskets = $repo->findBy(['usr_id' => $inviteUsrId]);
foreach ($baskets as $basket) {
- $basket->setUsrId($user->get_id());
+ $basket->setUsrId($user->getId());
$app['EM']->persist($basket);
}
}
diff --git a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php
index 7a1a14b03e..4cd9fb3ef4 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php
@@ -55,15 +55,16 @@ class RSSFeeds implements ControllerProviderInterface
$page = $page < 1 ? 1 : $page;
return $app['feed.formatter-strategy']($format)
- ->createResponse($app, $token->getFeed(), $page, \User_Adapter::getInstance($token->getUsrId(), $app));
+ ->createResponse($app, $token->getFeed(), $page, $app['manipulator.user']->getRepository()->find($token->getUsrId()));
})
->bind('feed_user')
->assert('id', '\d+')
->assert('format', '(rss|atom)');
$controllers->get('/userfeed/aggregated/{token}/{format}/', function (Application $app, $token, $format) {
- $token = $app['EM']->getRepository('Phraseanet:AggregateToken')->findOneBy(["value" => $token]);
- $user = \User_Adapter::getInstance($token->getUsrId(), $app);
+ $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(["value" => $token]);
+
+ $user = $app['manipulator.user']->getRepository()->find($token->getUsrId());
$feeds = $app['EM']->getRepository('Phraseanet:Feed')->getAllForUser($app['acl']->get($user));
diff --git a/lib/Alchemy/Phrasea/Controller/Root/Session.php b/lib/Alchemy/Phrasea/Controller/Root/Session.php
index 10771d695f..08e4eaef45 100644
--- a/lib/Alchemy/Phrasea/Controller/Root/Session.php
+++ b/lib/Alchemy/Phrasea/Controller/Root/Session.php
@@ -57,7 +57,7 @@ class Session implements ControllerProviderInterface
];
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
$ret['status'] = 'disconnected';
@@ -138,7 +138,7 @@ class Session implements ControllerProviderInterface
$app->abort(404, 'Unknown session');
}
- if ($session->getUsrId() !== $app['authentication']->getUser()->get_id()) {
+ if ($session->getUsrId() !== $app['authentication']->getUser()->getId()) {
$app->abort(403, 'Unauthorized');
}
diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php
index 9b075e005d..3c6656c60c 100644
--- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php
+++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php
@@ -777,7 +777,7 @@ class Thesaurus implements ControllerProviderInterface
$bases = $languages = [];
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]);
+ $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->getId()));
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
diff --git a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php
index 1586ed4169..258c4649f8 100644
--- a/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php
+++ b/lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php
@@ -358,7 +358,7 @@ class Xmlhttp implements ControllerProviderInterface
public function EditingPresetsJson(Application $app, Request $request)
{
- $usr_id = $app['authentication']->getUser()->get_id();
+ $usr_id = $app['authentication']->getUser()->getId();
$ret = ['parm' => [
'act' => $request->get('act'),
diff --git a/lib/Alchemy/Phrasea/Controller/User/Notifications.php b/lib/Alchemy/Phrasea/Controller/User/Notifications.php
index 9136aa6ce9..88a56334a0 100644
--- a/lib/Alchemy/Phrasea/Controller/User/Notifications.php
+++ b/lib/Alchemy/Phrasea/Controller/User/Notifications.php
@@ -59,7 +59,7 @@ class Notifications implements ControllerProviderInterface
try {
$app['events-manager']->read(
explode('_', (string) $request->request->get('notifications')),
- $app['authentication']->getUser()->get_id()
+ $app['authentication']->getUser()->getId()
);
return $app->json(['success' => true, 'message' => '']);
diff --git a/lib/Alchemy/Phrasea/Core/Event/PostAuthenticate.php b/lib/Alchemy/Phrasea/Core/Event/PostAuthenticate.php
index 15f538144d..589cc62025 100644
--- a/lib/Alchemy/Phrasea/Core/Event/PostAuthenticate.php
+++ b/lib/Alchemy/Phrasea/Core/Event/PostAuthenticate.php
@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Authentication\Context;
+use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\EventDispatcher\Event as SfEvent;
@@ -23,7 +24,7 @@ class PostAuthenticate extends SfEvent
private $request;
private $response;
- public function __construct(Request $request, Response $response, \User_Adapter $user, Context $context)
+ public function __construct(Request $request, Response $response, User $user, Context $context)
{
$this->request = $request;
$this->response = $response;
diff --git a/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php
index 5b556e03d4..28e1dd0f4e 100644
--- a/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php
+++ b/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php
@@ -57,12 +57,11 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface
$templates = array_filter(array_map(function ($templateId) use ($app) {
try {
if (is_int($templateId) || ctype_digit($templateId)) {
- return \User_Adapter::getInstance($templateId, $app);
- } else {
- $template = \User_Adapter::get_usr_id_from_login($app, $templateId);
- if (false !== $template) {
- return \User_Adapter::getInstance($template, $app);
- }
+ return $app['manipulator.user']->getRepository()->find($templateId);
+ }
+
+ if (false !== $templateId) {
+ return $app['manipulator.user']->getRepository()->find($templateId);
}
} catch (\Exception $e) {
diff --git a/lib/Alchemy/Phrasea/Feed/Aggregate.php b/lib/Alchemy/Phrasea/Feed/Aggregate.php
index c14aa18252..ac1b592017 100644
--- a/lib/Alchemy/Phrasea/Feed/Aggregate.php
+++ b/lib/Alchemy/Phrasea/Feed/Aggregate.php
@@ -12,7 +12,9 @@
namespace Alchemy\Phrasea\Feed;
use Alchemy\Phrasea\Application;
+use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Exception\LogicException;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManager;
use Alchemy\Phrasea\Model\Entities\AggregateToken;
@@ -55,7 +57,7 @@ class Aggregate implements FeedInterface
$this->updatedOn = new \DateTime();
$this->em = $em;
- $tmp_feeds = [];
+ $tmp_feeds = array();
foreach ($feeds as $feed) {
$tmp_feeds[$feed->getId()] = $feed;
@@ -71,14 +73,14 @@ class Aggregate implements FeedInterface
* Creates an aggregate from all the feeds available to a given user.
*
* @param EntityManager $em
- * @param \User_Adapter $user
+ * @param User $user
*
* @return Aggregate
*/
- public static function createFromUser(Application $app, \User_Adapter $user)
+ public static function createFromUser(Application $app, User $user)
{
- $feeds = $app['EM']->getRepository('Phraseanet:Feed')->getAllForUser($app['acl']->get($user));
- $token = $app['EM']->getRepository('Phraseanet:AggregateToken')->findOneBy(['usrId' => $user->get_id()]);
+ $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($user));
+ $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(array('usrId' => $user->getId()));
return new static($app['EM'], $feeds, $token);
}
@@ -115,7 +117,7 @@ class Aggregate implements FeedInterface
return new ArrayCollection();
}
- $feedIds = [];
+ $feedIds = array();
foreach ($this->feeds as $feed) {
$feedIds[] = $feed->getId();
}
@@ -201,7 +203,7 @@ class Aggregate implements FeedInterface
public function getCountTotalEntries()
{
if (count($this->feeds) > 0) {
- $feedIds = [];
+ $feedIds = array();
foreach ($this->feeds as $feed) {
$feedIds[] = $feed->getId();
}
@@ -238,6 +240,6 @@ class Aggregate implements FeedInterface
*/
public static function getPublic(Application $app)
{
- return new static($app['EM'], $app['EM']->getRepository('Phraseanet:Feed')->findBy(['public' => true], ['updatedOn' => 'DESC']));
+ return new static($app['EM'], $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->findBy(array('public' => true), array('updatedOn' => 'DESC')));
}
}
diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php b/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php
index 6892cf0166..be7533249d 100644
--- a/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php
+++ b/lib/Alchemy/Phrasea/Feed/Formatter/AtomFormatter.php
@@ -16,6 +16,7 @@ use Alchemy\Phrasea\Model\Entities\FeedEntry;
use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\Feed\Link\FeedLink;
use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection;
+use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\HttpFoundation\Response;
class AtomFormatter extends FeedFormatterAbstract implements FeedFormatterInterface
@@ -34,7 +35,7 @@ class AtomFormatter extends FeedFormatterAbstract implements FeedFormatterInterf
/**
* {@inheritdoc}
*/
- public function createResponse(Application $app, FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet')
+ public function createResponse(Application $app, FeedInterface $feed, $page, User $user = null, $generator = 'Phraseanet')
{
$content = $this->format($feed, $page, $user, $generator, $app);
$response = new Response($content, 200, ['Content-Type' => 'application/atom+xml']);
@@ -45,7 +46,7 @@ class AtomFormatter extends FeedFormatterAbstract implements FeedFormatterInterf
/**
* {@inheritdoc}
*/
- public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', Application $app = null)
+ public function format(FeedInterface $feed, $page, User $user = null, $generator = 'Phraseanet', Application $app = null)
{
$updated_on = $feed->getUpdatedOn();
diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php b/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php
index c311e4271f..459aec5f67 100644
--- a/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php
+++ b/lib/Alchemy/Phrasea/Feed/Formatter/CoolirisFormatter.php
@@ -17,6 +17,7 @@ use Alchemy\Phrasea\Model\Entities\FeedEntry;
use Alchemy\Phrasea\Model\Entities\FeedItem;
use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection;
use Alchemy\Phrasea\Feed\RSS\FeedRSSImage;
+use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\HttpFoundation\Response;
class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterInterface
@@ -36,7 +37,7 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn
/**
* {@inheritdoc}
*/
- public function createResponse(Application $app, FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet')
+ public function createResponse(Application $app, FeedInterface $feed, $page, User $user = null, $generator = 'Phraseanet')
{
$content = $this->format($feed, $page, $user, $generator, $app);
$response = new Response($content, 200, ['Content-Type' => 'application/rss+xml']);
@@ -47,7 +48,7 @@ class CoolirisFormatter extends FeedFormatterAbstract implements FeedFormatterIn
/**
* {@inheritdoc}
*/
- public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', Application $app = null)
+ public function format(FeedInterface $feed, $page, User $user = null, $generator = 'Phraseanet', Application $app = null)
{
$updated_on = $feed->getUpdatedOn();
diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterInterface.php b/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterInterface.php
index 1dd76396c4..a15aeb5ccb 100644
--- a/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterInterface.php
+++ b/lib/Alchemy/Phrasea/Feed/Formatter/FeedFormatterInterface.php
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Feed\Formatter;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Feed\FeedInterface;
+use Alchemy\Phrasea\Model\Entities\User;
interface FeedFormatterInterface
{
@@ -21,24 +22,24 @@ interface FeedFormatterInterface
*
* @param FeedInterface $feed
* @param type $page
- * @param \User_Adapter $user
+ * @param User $user
* @param type $generator
* @param Application $app
*
* @return string
*/
- public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', Application $app);
+ public function format(FeedInterface $feed, $page, User $user = null, $generator = 'Phraseanet', Application $app);
/**
* Returns an HTTP Response containing a string representation of the feed.
*
* @param FeedInterface $feed
* @param type $page
- * @param \User_Adapter $user
+ * @param User $user
* @param type $generator
* @param Application $app
*
* @return string
*/
- public function createResponse(Application $app, FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet');
+ public function createResponse(Application $app, FeedInterface $feed, $page, User $user = null, $generator = 'Phraseanet');
}
diff --git a/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php b/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php
index 42d5bbad8c..a802118c60 100644
--- a/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php
+++ b/lib/Alchemy/Phrasea/Feed/Formatter/RssFormatter.php
@@ -16,6 +16,7 @@ use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\Feed\Link\FeedLink;
use Alchemy\Phrasea\Feed\Link\LinkGeneratorCollection;
use Alchemy\Phrasea\Feed\RSS\FeedRSSImage;
+use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\HttpFoundation\Response;
use Alchemy\Phrasea\Model\Entities\FeedEntry;
use Alchemy\Phrasea\Feed\Link\FeedLinkGenerator;
@@ -37,7 +38,7 @@ class RssFormatter extends FeedFormatterAbstract implements FeedFormatterInterfa
/**
* {@inheritdoc}
*/
- public function createResponse(Application $app, FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet')
+ public function createResponse(Application $app, FeedInterface $feed, $page, User $user = null, $generator = 'Phraseanet')
{
$content = $this->format($feed, $page, $user, $generator, $app);
$response = new Response($content, 200, ['Content-Type' => 'application/rss+xml']);
@@ -48,7 +49,7 @@ class RssFormatter extends FeedFormatterAbstract implements FeedFormatterInterfa
/**
* {@inheritdoc}
*/
- public function format(FeedInterface $feed, $page, \User_Adapter $user = null, $generator = 'Phraseanet', Application $app = null)
+ public function format(FeedInterface $feed, $page, User $user = null, $generator = 'Phraseanet', Application $app = null)
{
$updated_on = $feed->getUpdatedOn();
diff --git a/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php b/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php
index f4b9b32690..a84282e011 100644
--- a/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php
+++ b/lib/Alchemy/Phrasea/Feed/Link/AggregateLinkGenerator.php
@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\Feed\Aggregate;
use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\Model\Entities\AggregateToken;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Routing\Generator\UrlGenerator;
@@ -42,7 +43,7 @@ class AggregateLinkGenerator implements LinkGeneratorInterface
/**
* {@inheritdoc}
*/
- public function generate(FeedInterface $aggregate, \User_Adapter $user, $format, $page = null, $renew = false)
+ public function generate(FeedInterface $aggregate, User $user, $format, $page = null, $renew = false)
{
if (!$this->supports($aggregate)) {
throw new InvalidArgumentException('AggregateLinkGenerator only support aggregate feeds.');
@@ -50,10 +51,10 @@ class AggregateLinkGenerator implements LinkGeneratorInterface
switch ($format) {
case self::FORMAT_ATOM:
- $params = [
+ $params = array(
'token' => $this->getAggregateToken($user, $renew)->getValue(),
'format' => 'atom'
- ];
+ );
if (null !== $page) {
$params['page'] = $page;
}
@@ -64,10 +65,10 @@ class AggregateLinkGenerator implements LinkGeneratorInterface
'application/atom+xml'
);
case self::FORMAT_RSS:
- $params = [
+ $params = array(
'token' => $this->getAggregateToken($user, $renew)->getValue(),
'format' => 'rss'
- ];
+ );
if (null !== $page) {
$params['page'] = $page;
}
@@ -101,7 +102,7 @@ class AggregateLinkGenerator implements LinkGeneratorInterface
switch ($format) {
case self::FORMAT_ATOM:
- $params = ['format' => 'atom'];
+ $params = array('format' => 'atom');
if (null !== $page) {
$params['page'] = $page;
}
@@ -112,7 +113,7 @@ class AggregateLinkGenerator implements LinkGeneratorInterface
'application/atom+xml'
);
case self::FORMAT_RSS:
- $params = ['format' => 'rss'];
+ $params = array('format' => 'rss');
if (null !== $page) {
$params['page'] = $page;
}
@@ -127,16 +128,16 @@ class AggregateLinkGenerator implements LinkGeneratorInterface
}
}
- private function getAggregateToken(\User_Adapter $user, $renew = false)
+ private function getAggregateToken(User $user, $renew = false)
{
$token = $this->em
- ->getRepository('Phraseanet:AggregateToken')
- ->findOneBy(['usrId' => $user->get_id()]);
+ ->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')
+ ->findOneBy(array('usrId' => $user->getId()));
if (null === $token || true === $renew) {
if (null === $token) {
$token = new AggregateToken();
- $token->setUsrId($user->get_id());
+ $token->setUsrId($user->getId());
}
$token->setValue($this->random->generatePassword(12, \random::LETTERS_AND_NUMBERS));
diff --git a/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php b/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php
index 5e7946e3c9..c41f2723da 100644
--- a/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php
+++ b/lib/Alchemy/Phrasea/Feed/Link/FeedLinkGenerator.php
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Feed\Link;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\Feed\FeedInterface;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityManager;
use Alchemy\Phrasea\Model\Entities\Feed;
use Alchemy\Phrasea\Model\Entities\FeedToken;
@@ -42,7 +43,7 @@ class FeedLinkGenerator implements LinkGeneratorInterface
/**
* {@inheritdoc}
*/
- public function generate(FeedInterface $feed, \User_Adapter $user, $format, $page = null, $renew = false)
+ public function generate(FeedInterface $feed, User $user, $format, $page = null, $renew = false)
{
if (!$this->supports($feed)) {
throw new InvalidArgumentException('FeedLinkGenerator only support aggregate feeds.');
@@ -50,11 +51,11 @@ class FeedLinkGenerator implements LinkGeneratorInterface
switch ($format) {
case self::FORMAT_ATOM:
- $params = [
+ $params = array(
'token' => $this->getFeedToken($feed, $user, $renew)->getValue(),
'id' => $feed->getId(),
'format' => 'atom'
- ];
+ );
if (null !== $page) {
$params['page'] = $page;
}
@@ -65,11 +66,11 @@ class FeedLinkGenerator implements LinkGeneratorInterface
'application/atom+xml'
);
case self::FORMAT_RSS:
- $params = [
+ $params = array(
'token' => $this->getFeedToken($feed, $user, $renew)->getValue(),
'id' => $feed->getId(),
'format' => 'rss'
- ];
+ );
if (null !== $page) {
$params['page'] = $page;
}
@@ -103,10 +104,10 @@ class FeedLinkGenerator implements LinkGeneratorInterface
switch ($format) {
case self::FORMAT_ATOM:
- $params = [
+ $params = array(
'id' => $feed->getId(),
'format' => 'atom'
- ];
+ );
if (null !== $page) {
$params['page'] = $page;
}
@@ -117,10 +118,10 @@ class FeedLinkGenerator implements LinkGeneratorInterface
'application/atom+xml'
);
case self::FORMAT_RSS:
- $params = [
+ $params = array(
'id' => $feed->getId(),
'format' => 'rss'
- ];
+ );
if (null !== $page) {
$params['page'] = $page;
}
@@ -135,17 +136,17 @@ class FeedLinkGenerator implements LinkGeneratorInterface
}
}
- private function getFeedToken(Feed $feed, \User_Adapter $user, $renew = false)
+ private function getFeedToken(Feed $feed, User $user, $renew = false)
{
$token = $this->em
- ->getRepository('Phraseanet:FeedToken')
- ->findOneBy(['usrId' => $user->get_id(), 'feed' => $feed->getId()]);
+ ->getRepository('Alchemy\Phrasea\Model\Entities\FeedToken')
+ ->findOneBy(array('usrId' => $user->getId(), 'feed' => $feed->getId()));
if (null === $token || true === $renew) {
if (null === $token) {
$token = new FeedToken();
$token->setFeed($feed);
- $token->setUsrId($user->get_id());
+ $token->setUsrId($user->getId());
$feed->addToken($token);
$this->em->persist($feed);
diff --git a/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php b/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php
index 44f171fff0..861e52bef1 100644
--- a/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php
+++ b/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorCollection.php
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Feed\Link;
use Alchemy\Phrasea\Feed\FeedInterface;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
+use Alchemy\Phrasea\Model\Entities\User;
class LinkGeneratorCollection implements LinkGeneratorInterface
{
@@ -31,7 +32,7 @@ class LinkGeneratorCollection implements LinkGeneratorInterface
/**
* {@inheritdoc}
*/
- public function generate(FeedInterface $feed, \User_Adapter $user, $format, $page = null, $renew = false)
+ public function generate(FeedInterface $feed, User $user, $format, $page = null, $renew = false)
{
if (null === $generator = $this->findGenerator($feed)) {
throw new InvalidArgumentException(sprintf('Unable to find a valid generator for %s', get_class($feed)));
diff --git a/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorInterface.php b/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorInterface.php
index 4b0b9510e8..f4c46ad7f1 100644
--- a/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorInterface.php
+++ b/lib/Alchemy/Phrasea/Feed/Link/LinkGeneratorInterface.php
@@ -12,14 +12,15 @@
namespace Alchemy\Phrasea\Feed\Link;
use Alchemy\Phrasea\Feed\FeedInterface;
+use Alchemy\Phrasea\Model\Entities\User;
interface LinkGeneratorInterface
{
/**
- * Generates a FeedLink based on given FeedInterface and User_Adapter.
+ * Generates a FeedLink based on given FeedInterface and User.
*
* @param FeedInterface $feed
- * @param \User_Adapter $user
+ * @param User $user
* @param type $format
* @param type $page
* @param type $renew
@@ -28,7 +29,7 @@ interface LinkGeneratorInterface
*
* @throws InvalidArgumentException
*/
- public function generate(FeedInterface $feed, \User_Adapter $user, $format, $page = null, $renew = false);
+ public function generate(FeedInterface $feed, User $user, $format, $page = null, $renew = false);
/**
* Generates a public FeedLink based on given FeedInterface.
diff --git a/lib/Alchemy/Phrasea/Form/Constraint/NewEmail.php b/lib/Alchemy/Phrasea/Form/Constraint/NewEmail.php
index 6b93258bfe..910565774b 100644
--- a/lib/Alchemy/Phrasea/Form/Constraint/NewEmail.php
+++ b/lib/Alchemy/Phrasea/Form/Constraint/NewEmail.php
@@ -27,9 +27,7 @@ class NewEmail extends Constraint
public function isAlreadyRegistered($email)
{
- $ret = (Boolean) \User_Adapter::get_usr_id_from_email($this->app, $email);
-
- return $ret;
+ return (Boolean) $this->app['manipulator.user']->getRepository()->findByEmail($email);
}
public static function create(Application $app)
diff --git a/lib/Alchemy/Phrasea/Form/Constraint/NewLogin.php b/lib/Alchemy/Phrasea/Form/Constraint/NewLogin.php
index fb85a912fa..86fa67439b 100644
--- a/lib/Alchemy/Phrasea/Form/Constraint/NewLogin.php
+++ b/lib/Alchemy/Phrasea/Form/Constraint/NewLogin.php
@@ -27,9 +27,7 @@ class NewLogin extends Constraint
public function isAlreadyRegistered($login)
{
- $ret = (Boolean) \User_Adapter::get_usr_id_from_login($this->app, $login);
-
- return $ret;
+ return (Boolean) $this->app['manipulator.user']->getRepository()->findByLogin($login);
}
public static function create(Application $app)
diff --git a/lib/Alchemy/Phrasea/Helper/Prod.php b/lib/Alchemy/Phrasea/Helper/Prod.php
index ab9bef9094..7a2e720f51 100644
--- a/lib/Alchemy/Phrasea/Helper/Prod.php
+++ b/lib/Alchemy/Phrasea/Helper/Prod.php
@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Helper;
+use Alchemy\Phrasea\Model\Entities\User;
+
class Prod extends Helper
{
@@ -24,7 +26,7 @@ class Prod extends Helper
$bases = $fields = $dates = [];
- if (! $this->app['authentication']->getUser() instanceof \User_Adapter) {
+ if (! $this->app['authentication']->getUser() instanceof User) {
return $search_datas;
}
diff --git a/lib/Alchemy/Phrasea/Helper/User/Edit.php b/lib/Alchemy/Phrasea/Helper/User/Edit.php
index 17cfd32cbc..6ced3a7aa5 100644
--- a/lib/Alchemy/Phrasea/Helper/User/Edit.php
+++ b/lib/Alchemy/Phrasea/Helper/User/Edit.php
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Helper\User;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
+use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate;
use Alchemy\Phrasea\Notification\Receiver;
use Symfony\Component\HttpFoundation\Request;
@@ -60,17 +61,17 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
public function delete_users()
{
foreach ($this->users as $usr_id) {
- if ($this->app['authentication']->getUser()->get_id() === (int) $usr_id) {
+ if ($this->app['authentication']->getUser()->getId() === (int) $usr_id) {
continue;
}
- $user = \User_Adapter::getInstance($usr_id, $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($usr_id);
$this->delete_user($user);
}
return $this;
}
- protected function delete_user(\User_Adapter $user)
+ protected function delete_user(User $user)
{
$list = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin']));
@@ -180,7 +181,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
if (count($this->users) == 1) {
$usr_id = array_pop($this->users);
- $out['main_user'] = \User_Adapter::getInstance($usr_id, $this->app);
+ $out['main_user'] = $this->app['manipulator.user']->getRepository()->find($usr_id);
}
return $out;
@@ -565,9 +566,9 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
$users = $this->users;
- $user = \User_adapter::getInstance(array_pop($users), $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find(array_pop($users));
- if ($user->is_template() || $user->is_special()) {
+ if ($user->isTemplate() || $user->isSpecial()) {
return $this;
}
@@ -592,7 +593,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
throw new \Exception_InvalidArgument('Email addess is not valid');
}
- $old_email = $user->get_email();
+ $old_email = $user->getEmail();
$user->set_firstname($parm['first_name'])
->set_lastname($parm['last_name'])
@@ -607,7 +608,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
->set_tel($parm['telephone'])
->set_fax($parm['fax']);
- $new_email = $user->get_email();
+ $new_email = $user->getEmail();
if ($old_email != $new_email) {
$oldReceiver = $newReceiver = null;
@@ -639,18 +640,18 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
public function apply_template()
{
- $template = \User_adapter::getInstance($this->request->get('template'), $this->app);
+ $template = $this->app['manipulator.user']->getRepository()->find($this->request->get('template'));
- if ($template->get_template_owner()->get_id() != $this->app['authentication']->getUser()->get_id()) {
+ if ($template->getLastModel()->getId() !== $this->app['authentication']->getUser()->getId()) {
throw new AccessDeniedHttpException('You are not the owner of the template');
}
$base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin']));
foreach ($this->users as $usr_id) {
- $user = \User_adapter::getInstance($usr_id, $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($usr_id);
- if ($user->is_template()) {
+ if ($user->isTemplate()) {
continue;
}
@@ -665,7 +666,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
$this->base_id = (int) $this->request->get('base_id');
foreach ($this->users as $usr_id) {
- $user = \User_Adapter::getInstance($usr_id, $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($usr_id);
if ($this->request->get('quota'))
$this->app['acl']->get($user)->set_quotas_on_base($this->base_id, $this->request->get('droits'), $this->request->get('restes'));
else
@@ -686,7 +687,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
if ($vand_and && $vand_or && $vxor_and && $vxor_or) {
foreach ($this->users as $usr_id) {
- $user = \User_Adapter::getInstance($usr_id, $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($usr_id);
$this->app['acl']->get($user)->set_masks_on_base($this->base_id, $vand_and, $vand_or, $vxor_and, $vxor_or);
}
@@ -708,7 +709,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
$base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin']));
foreach ($this->users as $usr_id) {
- $user = \User_Adapter::getInstance($usr_id, $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($usr_id);
if ($this->base_id > 0) {
$this->app['acl']->get($user)->set_limits($this->base_id, $activate, $dmin, $dmax);
@@ -727,13 +728,13 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
$base_ids = array_keys($this->app['acl']->get($this->app['authentication']->getUser())->get_granted_base(['canadmin']));
foreach ($this->users as $usr_id) {
- $user = \User_Adapter::getInstance($usr_id, $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($usr_id);
$ACL = $this->app['acl']->get($user);
- if ($user->is_template()) {
+ if ($user->isTemplate()) {
$template = $user;
- if ($template->get_template_owner()->get_id() !== $this->app['authentication']->getUser()->get_id()) {
+ if ($template->getLastModel()->getId() !== $this->app['authentication']->getUser()->getId()) {
continue;
}
}
diff --git a/lib/Alchemy/Phrasea/Helper/User/Manage.php b/lib/Alchemy/Phrasea/Helper/User/Manage.php
index ec4b5fa08e..f71c3c2d6e 100644
--- a/lib/Alchemy/Phrasea/Helper/User/Manage.php
+++ b/lib/Alchemy/Phrasea/Helper/User/Manage.php
@@ -16,6 +16,7 @@ use Alchemy\Phrasea\Helper\Helper;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailRequestPasswordSetup;
use Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation;
+use Alchemy\Phrasea\Model\Entities\User;
class Manage extends Helper
{
@@ -44,7 +45,7 @@ class Manage extends Helper
$offset_start = (int) $request->get('offset_start');
$offset_start = $offset_start < 0 ? 0 : $offset_start;
- $this->query_parms = [
+ $this->query_parms = array(
'inactives' => $request->get('inactives')
, 'like_field' => $request->get('like_field')
, 'like_value' => $request->get('like_value')
@@ -54,7 +55,7 @@ class Manage extends Helper
, 'srt' => $request->get("srt", \User_Query::SORT_CREATIONDATE)
, 'ord' => $request->get("ord", \User_Query::ORD_DESC)
, 'offset_start' => 0
- ];
+ );
$query = new \User_Query($this->app);
@@ -68,7 +69,7 @@ class Manage extends Helper
->last_model_is($this->query_parms['last_model'])
->get_inactives($this->query_parms['inactives'])
->include_templates(false)
- ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), ['canadmin'])
+ ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), array('canadmin'))
->execute();
return $this->results->get_results();
@@ -81,7 +82,7 @@ class Manage extends Helper
$results_quantity = (int) $this->request->get('per_page');
$results_quantity = ($results_quantity < 10 || $results_quantity > 50) ? 20 : $results_quantity;
- $this->query_parms = [
+ $this->query_parms = array(
'inactives' => $this->request->get('inactives')
, 'like_field' => $this->request->get('like_field')
, 'like_value' => $this->request->get('like_value')
@@ -92,7 +93,7 @@ class Manage extends Helper
, 'ord' => $this->request->get("ord", \User_Query::ORD_DESC)
, 'per_page' => $results_quantity
, 'offset_start' => $offset_start
- ];
+ );
$query = new \User_Query($this->app);
@@ -106,22 +107,16 @@ class Manage extends Helper
->last_model_is($this->query_parms['last_model'])
->get_inactives($this->query_parms['inactives'])
->include_templates(true)
- ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), ['canadmin'])
+ ->on_bases_where_i_am($this->app['acl']->get($this->app['authentication']->getUser()), array('canadmin'))
->limit($offset_start, $results_quantity)
->execute();
- try {
- $invite_id = \User_Adapter::get_usr_id_from_login($this->app, 'invite');
- $invite = \User_Adapter::getInstance($invite_id, $this->app);
- } catch (\Exception $e) {
- $invite = \User_Adapter::create($this->app, 'invite', 'invite', '', false);
+ if (null === $invite = $this->app['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) {
+ $this->app['manipulator.user']->createUser(User::USER_GUEST, User::USER_GUEST);
}
- try {
- $autoregister_id = \User_Adapter::get_usr_id_from_login($this->app, 'autoregister');
- $autoregister = \User_Adapter::getInstance($autoregister_id, $this->app);
- } catch (\Exception $e) {
- $autoregister = \User_Adapter::create($this->app, 'autoregister', 'autoregister', '', false);
+ if (null == $autoregister = $this->app['manipulator.user']->getRepository()->findByLogin(User::USER_AUTOREGISTER)) {
+ $this->app['manipulator.user']->createUser(User::USER_AUTOREGISTER, User::USER_AUTOREGISTER);
}
foreach ($this->query_parms as $k => $v) {
@@ -134,13 +129,13 @@ class Manage extends Helper
->only_templates(true)
->execute()->get_results();
- return [
+ return array(
'users' => $this->results,
'parm' => $this->query_parms,
'invite_user' => $invite,
'autoregister_user' => $autoregister,
'templates' => $templates
- ];
+ );
}
public function create_newuser()
@@ -154,7 +149,7 @@ class Manage extends Helper
$conn = $this->app['phraseanet.appbox']->get_connection();
$sql = 'SELECT usr_id FROM usr WHERE usr_mail = :email';
$stmt = $conn->prepare($sql);
- $stmt->execute([':email' => $email]);
+ $stmt->execute(array(':email' => $email));
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
$count = count($row);
@@ -162,8 +157,7 @@ class Manage extends Helper
$sendCredentials = !!$this->request->get('send_credentials', false);
$validateMail = !!$this->request->get('validate_mail', false);
- $createdUser = \User_Adapter::create($this->app, $email, \random::generatePassword(16), $email, false, false);
- /* @var $createdUser \User_Adapter */
+ $createdUser = $this->app['manipulator.user']->createUser($email, \random::generatePassword(16), $email);
$receiver = null;
try {
@@ -173,12 +167,12 @@ class Manage extends Helper
}
if ($sendCredentials) {
- $urlToken = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->get_id());
+ $urlToken = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->getId());
if ($receiver && false !== $urlToken) {
- $url = $this->app->url('login_renew_password', ['token' => $urlToken]);
+ $url = $this->app->url('login_renew_password', array('token' => $urlToken));
$mail = MailRequestPasswordSetup::create($this->app, $receiver, null, '', $url);
- $mail->setLogin($createdUser->get_login());
+ $mail->setLogin($createdUser->getLogin());
$this->app['notification.deliverer']->deliver($mail);
}
}
@@ -188,18 +182,18 @@ class Manage extends Helper
if ($receiver) {
$expire = new \DateTime('+3 days');
- $token = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->get_id(), $expire, $createdUser->get_email());
- $url = $this->app->url('login_register_confirm', ['code' => $token]);
+ $token = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->getId(), $expire, $createdUser->getEmail());
+ $url = $this->app->url('login_register_confirm', array('code' => $token));
$mail = MailRequestEmailConfirmation::create($this->app, $receiver, null, '', $url, $expire);
$this->app['notification.deliverer']->deliver($mail);
}
}
- $this->usr_id = $createdUser->get_id();
+ $this->usr_id = $createdUser->getId();
} else {
$this->usr_id = $row['usr_id'];
- $createdUser = \User_Adapter::getInstance($this->usr_id, $this->app);
+ $createdUser = $this->app['manipulator.user']->getRepository()->find($this->usr_id);
}
return $createdUser;
@@ -213,9 +207,9 @@ class Manage extends Helper
throw new \Exception_InvalidArgument('Invalid template name');
}
- $created_user = \User_Adapter::create($this->app, $name, \random::generatePassword(16), null, false, false);
+ $created_user = $this->app['manipulator.user']->getRepository()->find($name, \random::generatePassword(16));
$created_user->set_template($this->app['authentication']->getUser());
- $this->usr_id = $this->app['authentication']->getUser()->get_id();
+ $this->usr_id = $this->app['authentication']->getUser()->getId();
return $created_user;
}
diff --git a/lib/Alchemy/Phrasea/Model/Entities/Basket.php b/lib/Alchemy/Phrasea/Model/Entities/Basket.php
index f12d3940dc..abb8c84b89 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/Basket.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/Basket.php
@@ -179,7 +179,7 @@ class Basket
public function setOwner(\User_Adapter $user)
{
- $this->setUsrId($user->get_id());
+ $this->setUsrId($user->getId());
}
public function getOwner(Application $app)
@@ -237,7 +237,7 @@ class Basket
public function setPusher(\User_Adapter $user)
{
- $this->setPusherId($user->get_id());
+ $this->setPusherId($user->getId());
}
public function getPusher(Application $app)
diff --git a/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php b/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php
index 6f4ec17499..f6df5f4fb8 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/BasketElement.php
@@ -283,11 +283,11 @@ class BasketElement
public function getUserValidationDatas(\User_Adapter $user, Application $app)
{
foreach ($this->validation_datas as $validationData) {
- if ($validationData->getParticipant($app)->getUser($app)->get_id() == $user->get_id()) {
+ if ($validationData->getParticipant($app)->getUser($app)->getId() == $user->getId()) {
return $validationData;
}
}
- throw new \Exception('There is no such participant ' . $user->get_email());
+ throw new \Exception('There is no such participant ' . $user->getEmail());
}
}
diff --git a/lib/Alchemy/Phrasea/Model/Entities/Feed.php b/lib/Alchemy/Phrasea/Model/Entities/Feed.php
index cb78a46981..e61b47e139 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/Feed.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/Feed.php
@@ -280,14 +280,14 @@ class Feed implements FeedInterface
/**
* Returns a boolean indicating whether the given User_Adapter is the owner of the feed.
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return boolean
*/
public function isOwner(\User_Adapter $user)
{
$owner = $this->getOwner();
- if ($owner !== null && $user->get_id() === $owner->getUsrId()) {
+ if ($owner !== null && $user->getId() === $owner->getUsrId()) {
return true;
}
@@ -374,14 +374,14 @@ class Feed implements FeedInterface
/**
* Returns a boolean indicating whether the given User_Adapter is a publisher of the feed.
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return boolean
*/
public function isPublisher(\User_Adapter $user)
{
foreach ($this->getPublishers() as $publisher) {
- if ($publisher->getUsrId() == $user->get_id()) {
+ if ($publisher->getUsrId() == $user->getId()) {
return true;
}
}
@@ -392,14 +392,14 @@ class Feed implements FeedInterface
/**
* Returns an instance of FeedPublisher matching to the given User_Adapter
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return FeedPublisher
*/
public function getPublisher(\User_Adapter $user)
{
foreach ($this->getPublishers() as $publisher) {
- if ($publisher->getUsrId() == $user->get_id()) {
+ if ($publisher->getUsrId() == $user->getId()) {
return $publisher;
}
}
@@ -453,7 +453,7 @@ class Feed implements FeedInterface
/**
* Returns a boolean indicating whether the given User_Adapter has access to the feed
*
- * @param \User_Adapter $user
+ * @param User $user
* @param Application $app
*
* @return boolean
diff --git a/lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php b/lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php
index e885c0bbce..4892456dfa 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php
@@ -315,14 +315,14 @@ class FeedEntry
/**
* Returns a boolean indicating whether the given User_Adapter is the publisher of the entry.
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return boolean
*/
public function isPublisher(\User_Adapter $user)
{
if ($this->publisher) {
- if ($this->publisher->getUsrId() === $user->get_id()) {
+ if ($this->publisher->getUsrId() === $user->getId()) {
return true;
}
}
diff --git a/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php b/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php
index 9d20b36669..50489594e5 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/FtpExport.php
@@ -478,13 +478,13 @@ class FtpExport
/**
* Set user
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return FtpExport
*/
public function setUser(\User_Adapter $user)
{
- $this->setUsrId($user->get_id());
+ $this->setUsrId($user->getId());
return $this;
}
diff --git a/lib/Alchemy/Phrasea/Model/Entities/OrderElement.php b/lib/Alchemy/Phrasea/Model/Entities/OrderElement.php
index 462d62930a..1fda66b28b 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/OrderElement.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/OrderElement.php
@@ -98,7 +98,7 @@ class OrderElement
if (isset($this->orderMasterId) && null !== $this->orderMasterId) {
$user = \User_Adapter::getInstance($this->orderMasterId, $app);
- return $user->get_firstname();
+ return $user->getFirstName();
}
return null;
diff --git a/lib/Alchemy/Phrasea/Model/Entities/Session.php b/lib/Alchemy/Phrasea/Model/Entities/Session.php
index bc3928eb72..115c3558f4 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/Session.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/Session.php
@@ -116,7 +116,7 @@ class Session
public function setUser(\User_Adapter $user)
{
- return $this->setUsrId($user->get_id());
+ return $this->setUsrId($user->getId());
}
/**
diff --git a/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php b/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php
index c484828e6d..cedee99432 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php
@@ -142,7 +142,7 @@ class StoryWZ
public function setUser(\User_Adapter $user)
{
- $this->setUsrId($user->get_id());
+ $this->setUsrId($user->getId());
}
public function getUser(Application $app)
diff --git a/lib/Alchemy/Phrasea/Model/Entities/User.php b/lib/Alchemy/Phrasea/Model/Entities/User.php
index 4c860ef3c1..c27739664f 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/User.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/User.php
@@ -406,11 +406,11 @@ class User
*/
public function setGender($gender)
{
- if (null !== $gender && !in_array($gender, [
+ if (null !== $gender && !in_array($gender, array(
self::GENDER_MISS,
self::GENDER_MR,
self::GENDER_MRS
- ])) {
+ ))) {
throw new InvalidArgumentException(sprintf("Invalid gender %s.", $gender));
}
@@ -956,7 +956,7 @@ class User
*/
public function isSpecial()
{
- return in_array($this->login, [self::USER_GUEST, self::USER_AUTOREGISTER]);
+ return in_array($this->login, array(self::USER_GUEST, self::USER_AUTOREGISTER));
}
/**
diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrList.php b/lib/Alchemy/Phrasea/Model/Entities/UsrList.php
index 44bbeecfed..6dfb2451d1 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/UsrList.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/UsrList.php
@@ -212,7 +212,7 @@ class UsrList
public function hasAccess(\User_Adapter $user, Application $app)
{
foreach ($this->getOwners() as $owner) {
- if ($owner->getUser($app)->get_id() == $user->get_id()) {
+ if ($owner->getUser($app)->getId() == $user->getId()) {
return true;
}
}
@@ -228,7 +228,7 @@ class UsrList
public function getOwner(\User_Adapter $user, Application $app)
{
foreach ($this->getOwners() as $owner) {
- if ($owner->getUser($app)->get_id() == $user->get_id()) {
+ if ($owner->getUser($app)->getId() == $user->getId()) {
return $owner;
}
}
@@ -246,7 +246,7 @@ class UsrList
{
return $this->entries->exists(
function ($key, $entry) use ($user, $app) {
- return $entry->getUser($app)->get_id() === $user->get_id();
+ return $entry->getUser($app)->getId() === $user->getId();
}
);
}
diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php b/lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php
index 6cdd23d6c2..e2973782f6 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php
@@ -91,7 +91,7 @@ class UsrListEntry
public function setUser(\User_Adapter $user)
{
- return $this->setUsrId($user->get_id());
+ return $this->setUsrId($user->getId());
}
/**
diff --git a/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php b/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php
index ea69d65834..1f446280a1 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php
@@ -95,7 +95,7 @@ class UsrListOwner
public function setUser(\User_Adapter $user)
{
- return $this->setUsrId($user->get_id());
+ return $this->setUsrId($user->getId());
}
public function getUser(Application $app)
diff --git a/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php b/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php
index 34ae755d07..f183428432 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php
@@ -116,7 +116,7 @@ class ValidationParticipant
*/
public function setUser(\User_Adapter $user)
{
- $this->usr_id = $user->get_id();
+ $this->usr_id = $user->getId();
return $this;
}
diff --git a/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php b/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php
index fc40c4e460..677663647a 100644
--- a/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php
+++ b/lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php
@@ -105,12 +105,12 @@ class ValidationSession
public function isInitiator(\User_Adapter $user)
{
- return $this->getInitiatorId() == $user->get_id();
+ return $this->getInitiatorId() == $user->getId();
}
public function setInitiator(\User_Adapter $user)
{
- $this->initiator_id = $user->get_id();
+ $this->initiator_id = $user->getId();
return;
}
@@ -269,9 +269,9 @@ class ValidationSession
}
} else {
if ($this->getParticipant($user, $app)->getCanSeeOthers()) {
- return $app->trans('Processus de validation recu de %user% et concernant %n% utilisateurs', ['%user%' => $this->getInitiator($app)->get_display_name(), '%n%' => count($this->getParticipants()) - 1]);
+ return $app->trans('Processus de validation recu de %user% et concernant %n% utilisateurs', ['%user%' => $this->getInitiator($app)->getDisplayName(), '%n%' => count($this->getParticipants()) - 1]);
} else {
- return $app->trans('Processus de validation recu de %user%', ['%user%' => $this->getInitiator($app)->get_display_name()]);
+ return $app->trans('Processus de validation recu de %user%', ['%user%' => $this->getInitiator($app)->getDisplayName()]);
}
}
}
@@ -284,11 +284,11 @@ class ValidationSession
public function getParticipant(\User_Adapter $user, Application $app)
{
foreach ($this->getParticipants() as $participant) {
- if ($participant->getUser($app)->get_id() == $user->get_id()) {
+ if ($participant->getUser($app)->getId() == $user->getId()) {
return $participant;
}
}
- throw new NotFoundHttpException('Participant not found ' . $user->get_email());
+ throw new NotFoundHttpException('Participant not found' . $user->get_email());
}
}
diff --git a/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php b/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php
index 70d3c92381..773bd37a1a 100644
--- a/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php
+++ b/lib/Alchemy/Phrasea/Model/Manipulator/ACLManipulator.php
@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\Exception\LogicException;
+use Alchemy\Phrasea\Model\Entities\User;
class ACLManipulator implements ManipulatorInterface
{
@@ -39,13 +40,13 @@ class ACLManipulator implements ManipulatorInterface
/**
* Resets rights for users.
*
- * @param User_Adapter $user
+ * @param User[] $users
*
* @throws InvalidArgumentException
*/
public function resetAdminRights($users)
{
- foreach ($this->makeTraversable($users) as $user) {
+ foreach($this->makeTraversable($users) as $user) {
$this->doResetAdminRights($user);
}
}
@@ -53,9 +54,9 @@ class ACLManipulator implements ManipulatorInterface
/**
* Resets rights for a user.
*
- * @param \User_adapter $user
+ * @param User $user
*/
- private function doResetAdminRights(\User_adapter $user)
+ private function doResetAdminRights(User $user)
{
$acl = $this->ACLProvider->get($user);
$databoxes = $this->appbox->get_databoxes();
@@ -79,12 +80,12 @@ class ACLManipulator implements ManipulatorInterface
{
$collections = $databox->get_collections();
- $acl->update_rights_to_sbas($databox->get_sbas_id(), [
+ $acl->update_rights_to_sbas($databox->get_sbas_id(), array(
'bas_manage' => '1',
'bas_modify_struct' => '1',
'bas_modif_th' => '1',
'bas_chupub' => '1'
- ]);
+ ));
$acl->give_access_to_base(array_map(function (\collection $collection) {
return $collection->get_base_id();
@@ -108,7 +109,7 @@ class ACLManipulator implements ManipulatorInterface
$acl->set_limits($baseId, false);
$acl->remove_quotas_on_base($baseId);
$acl->set_masks_on_base($baseId, '0', '0', '0', '0');
- $acl->update_rights_to_base($baseId, [
+ $acl->update_rights_to_base($baseId, array(
'canputinalbum' => '1',
'candwnldhd' => '1',
'candwnldsubdef' => '1',
@@ -127,7 +128,7 @@ class ACLManipulator implements ManipulatorInterface
'manage' => '1',
'modify_struct' => '1',
'bas_modify_struct' => '1'
- ]);
+ ));
}
/**
@@ -140,7 +141,7 @@ class ACLManipulator implements ManipulatorInterface
private function makeTraversable($var)
{
if (!is_array($var) && !$var instanceof \Traversable) {
- return [$var];
+ return array($var);
}
return $var;
diff --git a/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php
index 3f6a87ff4d..58d6e3c1b4 100644
--- a/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php
+++ b/lib/Alchemy/Phrasea/Model/Repositories/BasketElementRepository.php
@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Model\Entities\BasketElement;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -24,7 +25,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class BasketElementRepository extends EntityRepository
{
- public function findUserElement($element_id, \User_Adapter $user)
+ public function findUserElement($element_id, User $user)
{
$dql = 'SELECT e
FROM Phraseanet:BasketElement e
@@ -35,11 +36,11 @@ class BasketElementRepository extends EntityRepository
WHERE (b.usr_id = :usr_id OR p.usr_id = :same_usr_id)
AND e.id = :element_id';
- $params = [
- 'usr_id' => $user->get_id(),
- 'same_usr_id' => $user->get_id(),
+ $params = array(
+ 'usr_id' => $user->getId(),
+ 'same_usr_id' => $user->getId(),
'element_id' => $element_id
- ];
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
@@ -64,10 +65,10 @@ class BasketElementRepository extends EntityRepository
WHERE e.record_id = :record_id
AND e.sbas_id = :sbas_id';
- $params = [
+ $params = array(
'sbas_id' => $record->get_sbas_id(),
'record_id' => $record->get_record_id()
- ];
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
@@ -84,9 +85,9 @@ class BasketElementRepository extends EntityRepository
LEFT JOIN s.participants p
WHERE e.sbas_id = :sbas_id';
- $params = [
+ $params = array(
'sbas_id' => $databox->get_sbas_id(),
- ];
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
@@ -97,10 +98,10 @@ class BasketElementRepository extends EntityRepository
/**
*
* @param \record_adapter $record
- * @param \User_Adapter $user
+ * @param User $user
* @return \Doctrine\Common\Collections\ArrayCollection
*/
- public function findReceivedElementsByRecord(\record_adapter $record, \User_Adapter $user)
+ public function findReceivedElementsByRecord(\record_adapter $record, User $user)
{
$dql = 'SELECT e
FROM Phraseanet:BasketElement e
@@ -112,11 +113,11 @@ class BasketElementRepository extends EntityRepository
AND e.record_id = :record_id
AND e.sbas_id = :sbas_id';
- $params = [
+ $params = array(
'sbas_id' => $record->get_sbas_id(),
'record_id' => $record->get_record_id(),
- 'usr_id' => $user->get_id()
- ];
+ 'usr_id' => $user->getId()
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
@@ -124,7 +125,7 @@ class BasketElementRepository extends EntityRepository
return $query->getResult();
}
- public function findReceivedValidationElementsByRecord(\record_adapter $record, \User_Adapter $user)
+ public function findReceivedValidationElementsByRecord(\record_adapter $record, User $user)
{
$dql = 'SELECT e
FROM Phraseanet:BasketElement e
@@ -135,11 +136,11 @@ class BasketElementRepository extends EntityRepository
AND e.record_id = :record_id
AND e.sbas_id = :sbas_id';
- $params = [
+ $params = array(
'sbas_id' => $record->get_sbas_id(),
'record_id' => $record->get_record_id(),
- 'usr_id' => $user->get_id()
- ];
+ 'usr_id' => $user->getId()
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
diff --git a/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php
index dd2dec24ca..7af46abbf2 100644
--- a/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php
+++ b/lib/Alchemy/Phrasea/Model/Repositories/BasketRepository.php
@@ -11,8 +11,12 @@
namespace Alchemy\Phrasea\Model\Repositories;
+use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\Basket;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityRepository;
+use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class BasketRepository extends EntityRepository
{
@@ -24,10 +28,10 @@ class BasketRepository extends EntityRepository
/**
* Returns all basket for a given user that are not marked as archived
*
- * @param \User_Adapter $user
+ * @param User $user
* @return \Doctrine\Common\Collections\ArrayCollection
*/
- public function findActiveByUser(\User_Adapter $user, $sort = null)
+ public function findActiveByUser(User $user, $sort = null)
{
$dql = 'SELECT b
FROM Phraseanet:Basket b
@@ -42,7 +46,7 @@ class BasketRepository extends EntityRepository
}
$query = $this->_em->createQuery($dql);
- $query->setParameters(['usr_id' => $user->get_id()]);
+ $query->setParameters(array('usr_id' => $user->getId()));
return $query->getResult();
}
@@ -50,10 +54,10 @@ class BasketRepository extends EntityRepository
/**
* Returns all unread basket for a given user that are not marked as archived
*
- * @param \User_Adapter $user
+ * @param User $user
* @return \Doctrine\Common\Collections\ArrayCollection
*/
- public function findUnreadActiveByUser(\User_Adapter $user)
+ public function findUnreadActiveByUser(User $user)
{
$dql = 'SELECT b
FROM Phraseanet:Basket b
@@ -69,11 +73,11 @@ class BasketRepository extends EntityRepository
)
AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP())';
- $params = [
- 'usr_id_owner' => $user->get_id(),
- 'usr_id_ownertwo' => $user->get_id(),
- 'usr_id_participant' => $user->get_id()
- ];
+ $params = array(
+ 'usr_id_owner' => $user->getId(),
+ 'usr_id_ownertwo' => $user->getId(),
+ 'usr_id_participant' => $user->getId()
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
@@ -85,10 +89,10 @@ class BasketRepository extends EntityRepository
* Returns all baskets that are in validation session not expired and
* where a specified user is participant (not owner)
*
- * @param \User_Adapter $user
+ * @param User $user
* @return \Doctrine\Common\Collections\ArrayCollection
*/
- public function findActiveValidationByUser(\User_Adapter $user, $sort = null)
+ public function findActiveValidationByUser(User $user, $sort = null)
{
$dql = 'SELECT b
FROM Phraseanet:Basket b
@@ -106,12 +110,57 @@ class BasketRepository extends EntityRepository
}
$query = $this->_em->createQuery($dql);
- $query->setParameters([1 => $user->get_id(), 2 => $user->get_id()]);
+ $query->setParameters(array(1 => $user->getId(), 2 => $user->getId()));
return $query->getResult();
}
- public function findContainingRecordForUser(\record_adapter $record, \User_Adapter $user)
+ /**
+ * Find a basket specified by his basket_id and his owner
+ *
+ * @throws NotFoundHttpException
+ * @throws AccessDeniedHttpException
+ * @param type $basket_id
+ * @param User $user
+ * @return Basket
+ */
+ public function findUserBasket(Application $app, $basket_id, User $user, $requireOwner)
+ {
+ $dql = 'SELECT b
+ FROM Alchemy\Phrasea\Model\Entities\Basket b
+ LEFT JOIN b.elements e
+ WHERE b.id = :basket_id';
+
+ $query = $this->_em->createQuery($dql);
+ $query->setParameters(array('basket_id' => $basket_id));
+
+ $basket = $query->getOneOrNullResult();
+
+ /* @var $basket Basket */
+ if (null === $basket) {
+ throw new NotFoundHttpException(_('Basket is not found'));
+ }
+
+ if ($basket->getOwner($app)->getId() != $user->getId()) {
+ $participant = false;
+
+ if ($basket->getValidation() && !$requireOwner) {
+ try {
+ $basket->getValidation()->getParticipant($user, $app);
+ $participant = true;
+ } catch (\Exception $e) {
+
+ }
+ }
+ if (!$participant) {
+ throw new AccessDeniedHttpException(_('You have not access to this basket'));
+ }
+ }
+
+ return $basket;
+ }
+
+ public function findContainingRecordForUser(\record_adapter $record, User $user)
{
$dql = 'SELECT b
@@ -120,10 +169,10 @@ class BasketRepository extends EntityRepository
WHERE e.record_id = :record_id AND e.sbas_id = e.sbas_id
AND b.usr_id = :usr_id';
- $params = [
+ $params = array(
'record_id' => $record->get_record_id(),
- 'usr_id' => $user->get_id()
- ];
+ 'usr_id' => $user->getId()
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
@@ -131,9 +180,9 @@ class BasketRepository extends EntityRepository
return $query->getResult();
}
- public function findWorkzoneBasket(\User_Adapter $user, $query, $year, $type, $offset, $perPage)
+ public function findWorkzoneBasket(User $user, $query, $year, $type, $offset, $perPage)
{
- $params = [];
+ $params = array();
switch ($type) {
case self::RECEIVED:
@@ -141,9 +190,9 @@ class BasketRepository extends EntityRepository
FROM Phraseanet:Basket b
JOIN b.elements e
WHERE b.usr_id = :usr_id AND b.pusher_id IS NOT NULL';
- $params = [
- 'usr_id' => $user->get_id()
- ];
+ $params = array(
+ 'usr_id' => $user->getId()
+ );
break;
case self::VALIDATION_DONE:
$dql = 'SELECT b
@@ -152,10 +201,10 @@ class BasketRepository extends EntityRepository
JOIN b.validation s
JOIN s.participants p
WHERE b.usr_id != ?1 AND p.usr_id = ?2';
- $params = [
- 1 => $user->get_id()
- , 2 => $user->get_id()
- ];
+ $params = array(
+ 1 => $user->getId()
+ , 2 => $user->getId()
+ );
break;
case self::VALIDATION_SENT:
$dql = 'SELECT b
@@ -163,9 +212,9 @@ class BasketRepository extends EntityRepository
JOIN b.elements e
JOIN b.validation v
WHERE b.usr_id = :usr_id';
- $params = [
- 'usr_id' => $user->get_id()
- ];
+ $params = array(
+ 'usr_id' => $user->getId()
+ );
break;
default:
$dql = 'SELECT b
@@ -174,10 +223,10 @@ class BasketRepository extends EntityRepository
LEFT JOIN b.validation s
LEFT JOIN s.participants p
WHERE (b.usr_id = :usr_id OR p.usr_id = :validating_usr_id)';
- $params = [
- 'usr_id' => $user->get_id(),
- 'validating_usr_id' => $user->get_id()
- ];
+ $params = array(
+ 'usr_id' => $user->getId(),
+ 'validating_usr_id' => $user->getId()
+ );
break;
case self::MYBASKETS:
$dql = 'SELECT b
@@ -186,9 +235,9 @@ class BasketRepository extends EntityRepository
LEFT JOIN b.validation s
LEFT JOIN s.participants p
WHERE (b.usr_id = :usr_id)';
- $params = [
- 'usr_id' => $user->get_id()
- ];
+ $params = array(
+ 'usr_id' => $user->getId()
+ );
break;
}
@@ -221,11 +270,11 @@ class BasketRepository extends EntityRepository
/**
* Return all actives validation where current user is involved and user basket
*
- * @param \User_Adapter $user
+ * @param User $user
* @param type $sort
* @return Array
*/
- public function findActiveValidationAndBasketByUser(\User_Adapter $user, $sort = null)
+ public function findActiveValidationAndBasketByUser(User $user, $sort = null)
{
$dql = 'SELECT b
FROM Phraseanet:Basket b
@@ -244,7 +293,7 @@ class BasketRepository extends EntityRepository
}
$query = $this->_em->createQuery($dql);
- $query->setParameters(['usr_id' => $user->get_id()]);
+ $query->setParameters(array('usr_id' => $user->getId()));
return $query->getResult();
}
diff --git a/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php
index c685785673..ac852df021 100644
--- a/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php
+++ b/lib/Alchemy/Phrasea/Model/Repositories/FeedRepository.php
@@ -24,7 +24,6 @@ class FeedRepository extends EntityRepository
/**
* Returns all the feeds a user can access.
*
- * @param User_Adapter $user
* @return \Doctrine\Common\Collections\Collection
*/
public function getAllForUser(\ACL $userACL)
diff --git a/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php
index 8c3649863d..8cd97bc603 100644
--- a/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php
+++ b/lib/Alchemy/Phrasea/Model/Repositories/FtpExportRepository.php
@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Model\Repositories;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityRepository;
/**
@@ -62,12 +63,12 @@ class FtpExportRepository extends EntityRepository
/**
* Returns the exports initiated by a given user.
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return array
*/
- public function findByUser(\User_Adapter $user)
+ public function findByUser(User $user)
{
- return $this->findBy(['usrId' => $user->get_id()]);
+ return $this->findBy(array('usrId' => $user->getId()));
}
}
diff --git a/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php
index abf72bd765..6c9071fe68 100644
--- a/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php
+++ b/lib/Alchemy/Phrasea/Model/Repositories/OrderRepository.php
@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Model\Repositories;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityRepository;
/**
@@ -24,13 +25,13 @@ class OrderRepository extends EntityRepository
/**
* Returns the orders initiated by a given user.
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return array
*/
- public function findByUser(\User_Adapter $user)
+ public function findByUser(User $user)
{
- return $this->findBy(['usrId' => $user->get_id()]);
+ return $this->findBy(array('usrId' => $user->getId()));
}
/**
@@ -75,7 +76,7 @@ class OrderRepository extends EntityRepository
*
* @return integer
*/
- public function countTotalOrders(array $baseIds = [])
+ public function countTotalOrders(array $baseIds = array())
{
$qb = $this
->createQueryBuilder('o');
diff --git a/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php
index 8e28107e28..1f3e27a04b 100644
--- a/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php
+++ b/lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php
@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Application;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -25,7 +26,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class StoryWZRepository extends EntityRepository
{
- public function findByUser(Application $app, \User_Adapter $user, $sort)
+ public function findByUser(Application $app, User $user, $sort)
{
$dql = 'SELECT s FROM Phraseanet:StoryWZ s WHERE s.usr_id = :usr_id ';
@@ -34,7 +35,7 @@ class StoryWZRepository extends EntityRepository
}
$query = $this->_em->createQuery($dql);
- $query->setParameters(['usr_id' => $user->get_id()]);
+ $query->setParameters(array('usr_id' => $user->getId()));
$stories = $query->getResult();
@@ -50,7 +51,7 @@ class StoryWZRepository extends EntityRepository
$this->getEntityManager()->flush();
if ($sort == 'name') {
- $sortedStories = [];
+ $sortedStories = array();
foreach ($stories as $story) {
$sortedStories[] = $story->getRecord($app)->get_title();
}
@@ -71,7 +72,7 @@ class StoryWZRepository extends EntityRepository
return $stories;
}
- public function findByUserAndId(Application $app, \User_Adapter $user, $id)
+ public function findByUserAndId(Application $app, User $user, $id)
{
$story = $this->find($id);
@@ -83,7 +84,7 @@ class StoryWZRepository extends EntityRepository
throw new NotFoundHttpException('Story not found');
}
- if ($story->getUser($app)->get_id() !== $user->get_id()) {
+ if ($story->getUser($app)->getId() !== $user->getId()) {
throw new AccessDeniedHttpException('You have not access to ths story');
}
} else {
@@ -93,14 +94,14 @@ class StoryWZRepository extends EntityRepository
return $story;
}
- public function findUserStory(Application $app, \User_Adapter $user, \record_adapter $Story)
+ public function findUserStory(Application $app, User $user, \record_adapter $Story)
{
$story = $this->findOneBy(
- [
- 'usr_id' => $user->get_id(),
+ array(
+ 'usr_id' => $user->getId(),
'sbas_id' => $Story->get_sbas_id(),
'record_id' => $Story->get_record_id(),
- ]
+ )
);
if ($story) {
@@ -122,10 +123,10 @@ class StoryWZRepository extends EntityRepository
AND s.record_id = :record_id';
$query = $this->_em->createQuery($dql);
- $query->setParameters([
+ $query->setParameters(array(
'sbas_id' => $Story->get_sbas_id(),
'record_id' => $Story->get_record_id(),
- ]);
+ ));
$stories = $query->getResult();
@@ -147,9 +148,9 @@ class StoryWZRepository extends EntityRepository
$dql = 'SELECT s FROM Phraseanet:StoryWZ s WHERE s.sbas_id = :sbas_id';
$query = $this->_em->createQuery($dql);
- $query->setParameters([
+ $query->setParameters(array(
'sbas_id' => $databox->get_sbas_id(),
- ]);
+ ));
$stories = $query->getResult();
diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php
index dbee020012..8b1706facd 100644
--- a/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php
+++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrAuthProviderRepository.php
@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Model\Repositories;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityRepository;
/**
@@ -21,13 +22,13 @@ use Doctrine\ORM\EntityRepository;
*/
class UsrAuthProviderRepository extends EntityRepository
{
- public function findByUser(\User_Adapter $user)
+ public function findByUser(User $user)
{
$dql = 'SELECT u
FROM Phraseanet:UsrAuthProvider u
WHERE u.usr_id = :usrId';
- $params = ['usrId' => $user->get_id()];
+ $params = array('usrId' => $user->getId());
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
@@ -41,7 +42,7 @@ class UsrAuthProviderRepository extends EntityRepository
FROM Phraseanet:UsrAuthProvider u
WHERE u.provider = :providerId AND u.distant_id = :distantId';
- $params = ['providerId' => $providerId, 'distantId' => $distantId];
+ $params = array('providerId' => $providerId, 'distantId' => $distantId);
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php
index 753caf7ddd..d542aa793d 100644
--- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php
+++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListEntryRepository.php
@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Model\Repositories;
+use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\UsrList;
use Alchemy\Phrasea\Model\Entities\UsrListEntry;
use Doctrine\ORM\EntityRepository;
@@ -29,17 +30,17 @@ class UsrListEntryRepository extends EntityRepository
/**
* Get all lists entries matching a given User
*
- * @param \User_Adapter $user
+ * @param User $user
* @param type $like
*/
- public function findUserList(\User_Adapter $user)
+ public function findUserList(User $user)
{
$dql = 'SELECT e FROM Phraseanet:UsrListEntry e
WHERE e.usr_id = :usr_id';
- $params = [
- 'usr_id' => $user->get_id(),
- ];
+ $params = array(
+ 'usr_id' => $user->getId(),
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
@@ -69,10 +70,10 @@ class UsrListEntryRepository extends EntityRepository
JOIN e.list l
WHERE e.usr_id = :usr_id AND l.id = :list_id';
- $params = [
+ $params = array(
'usr_id' => $usr_id,
'list_id' => $list->getId(),
- ];
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
diff --git a/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php b/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php
index 7cc4ef028a..01d8812651 100644
--- a/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php
+++ b/lib/Alchemy/Phrasea/Model/Repositories/UsrListRepository.php
@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Application;
+use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\UsrList;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@@ -29,18 +30,18 @@ class UsrListRepository extends EntityRepository
/**
* Get all lists readable for a given User
*
- * @param \User_Adapter $user
+ * @param User $user
* @return \Doctrine\Common\Collections\ArrayCollection
*/
- public function findUserLists(\User_Adapter $user)
+ public function findUserLists(User $user)
{
$dql = 'SELECT l FROM Phraseanet:UsrList l
JOIN l.owners o
WHERE o.usr_id = :usr_id';
- $params = [
- 'usr_id' => $user->get_id(),
- ];
+ $params = array(
+ 'usr_id' => $user->getId(),
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
@@ -50,11 +51,11 @@ class UsrListRepository extends EntityRepository
/**
*
- * @param \User_Adapter $user
+ * @param User $user
* @param type $list_id
* @return UsrList
*/
- public function findUserListByUserAndId(Application $app, \User_Adapter $user, $list_id)
+ public function findUserListByUserAndId(Application $app, User $user, $list_id)
{
$list = $this->find($list_id);
@@ -73,20 +74,20 @@ class UsrListRepository extends EntityRepository
/**
* Search for a UsrList like '' with a given value, for a user
*
- * @param \User_Adapter $user
+ * @param User $user
* @param type $name
* @return \Doctrine\Common\Collections\ArrayCollection
*/
- public function findUserListLike(\User_Adapter $user, $name)
+ public function findUserListLike(User $user, $name)
{
$dql = 'SELECT l FROM Phraseanet:UsrList l
JOIN l.owners o
WHERE o.usr_id = :usr_id AND l.name LIKE :name';
- $params = [
- 'usr_id' => $user->get_id(),
+ $params = array(
+ 'usr_id' => $user->getId(),
'name' => $name . '%'
- ];
+ );
$query = $this->_em->createQuery($dql);
$query->setParameters($params);
diff --git a/lib/Alchemy/Phrasea/Notification/Emitter.php b/lib/Alchemy/Phrasea/Notification/Emitter.php
index 1ca2d9ccd7..868182a734 100644
--- a/lib/Alchemy/Phrasea/Notification/Emitter.php
+++ b/lib/Alchemy/Phrasea/Notification/Emitter.php
@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Notification;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
+use Alchemy\Phrasea\Model\Entities\User;
class Emitter implements EmitterInterface
{
@@ -47,14 +48,14 @@ class Emitter implements EmitterInterface
/**
* Creates an Emitter given a User
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return Emitter
*
* @throws InvalidArgumentException In case no valid email is found for user
*/
- public static function fromUser(\User_Adapter $user)
+ public static function fromUser(User $user)
{
- return new static($user->get_display_name(), $user->get_email());
+ return new static($user->getDisplayName(), $user->getEmail());
}
}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php
index 256bc741ba..c56b901d14 100644
--- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoNewOrder.php
@@ -12,18 +12,19 @@
namespace Alchemy\Phrasea\Notification\Mail;
use Alchemy\Phrasea\Exception\LogicException;
+use Alchemy\Phrasea\Model\Entities\User;
class MailInfoNewOrder extends AbstractMail
{
- /** @var \User_Adapter */
+ /** @var User */
private $user;
/**
* Set the user that initiates the order
*
- * @param \User_Adapter $user
+ * @param User $user
*/
- public function setUser(\User_Adapter $user)
+ public function setUser(User $user)
{
$this->user = $user;
}
@@ -41,11 +42,11 @@ class MailInfoNewOrder extends AbstractMail
*/
public function getMessage()
{
- if (!$this->user instanceof \User_Adapter) {
+ if (!$this->user instanceof User) {
throw new LogicException('You must set a user before calling getMessage()');
}
- return $this->app->trans('%user% has ordered documents', ['%user%' => $this->user->get_display_name()]);
+ return $this->app->trans('%user% has ordered documents', ['%user%' => $this->user->getDisplayName()]);
}
/**
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php
index 0017f964db..a8da22facb 100644
--- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderCancelled.php
@@ -12,10 +12,11 @@
namespace Alchemy\Phrasea\Notification\Mail;
use Alchemy\Phrasea\Exception\LogicException;
+use Alchemy\Phrasea\Model\Entities\User;
class MailInfoOrderCancelled extends AbstractMail
{
- /** @var \User_Adapter */
+ /** @var User */
private $deliverer;
/** @var integer */
private $quantity;
@@ -33,9 +34,9 @@ class MailInfoOrderCancelled extends AbstractMail
/**
* Sets the user that has denied the some of the order
*
- * @param \User_Adapter $deliverer
+ * @param User $deliverer
*/
- public function setDeliverer(\User_Adapter $deliverer)
+ public function setDeliverer(User $deliverer)
{
$this->deliverer = $deliverer;
}
@@ -53,7 +54,7 @@ class MailInfoOrderCancelled extends AbstractMail
*/
public function getMessage()
{
- if (!$this->deliverer instanceof \User_Adapter) {
+ if (!$this->deliverer instanceof User) {
throw new LogicException('You must set a deliverer before calling getMessage()');
}
if (null === $this->quantity) {
@@ -61,7 +62,7 @@ class MailInfoOrderCancelled extends AbstractMail
}
return $this->app->trans('%user% a refuse %quantity% elements de votre commande', [
- '%user%' => $this->deliverer->get_display_name(),
+ '%user%' => $this->deliverer->getDisplayName(),
'%quantity%' => $this->quantity,
]);
}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php
index e9444dd9f5..a976be10a2 100644
--- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoOrderDelivered.php
@@ -13,12 +13,13 @@ namespace Alchemy\Phrasea\Notification\Mail;
use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Exception\LogicException;
+use Alchemy\Phrasea\Model\Entities\User;
class MailInfoOrderDelivered extends AbstractMail
{
/** @var Basket */
private $basket;
- /** @var \User_Adapter */
+ /** @var User */
private $deliverer;
/**
@@ -34,9 +35,9 @@ class MailInfoOrderDelivered extends AbstractMail
/**
* Sets the user that delivers the order
*
- * @param \User_Adapter $deliverer
+ * @param User $deliverer
*/
- public function setDeliverer(\User_Adapter $deliverer)
+ public function setDeliverer(User $deliverer)
{
$this->deliverer = $deliverer;
}
@@ -62,7 +63,7 @@ class MailInfoOrderDelivered extends AbstractMail
throw new LogicException('You must set a deliverer before calling getMessage');
}
- return $this->app->trans('%user% vous a delivre votre commande, consultez la en ligne a l\'adresse suivante', ['%user%' => $this->deliverer->get_display_name()]);
+ return $this->app->trans('%user% vous a delivre votre commande, consultez la en ligne a l\'adresse suivante', ['%user%' => $this->deliverer->getDisplayName()]);
}
/**
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php
index 5b4ec30d45..e658c3833d 100644
--- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoPushReceived.php
@@ -13,12 +13,13 @@ namespace Alchemy\Phrasea\Notification\Mail;
use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Exception\LogicException;
+use Alchemy\Phrasea\Model\Entities\User;
class MailInfoPushReceived extends AbstractMailWithLink
{
/** @var Basket */
private $basket;
- /** @var \User_Adapter */
+ /** @var User */
private $pusher;
/**
@@ -31,7 +32,7 @@ class MailInfoPushReceived extends AbstractMailWithLink
$this->basket = $basket;
}
- public function setPusher(\User_Adapter $pusher)
+ public function setPusher(User $pusher)
{
$this->pusher = $pusher;
}
@@ -61,7 +62,7 @@ class MailInfoPushReceived extends AbstractMailWithLink
}
return
- $this->app->trans('You just received a push containing %quantity% documents from %user%', ['%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->get_display_name()])
+ $this->app->trans('You just received a push containing %quantity% documents from %user%', ['%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->getDisplayName()])
. "\n" . $this->message;
}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php
index ed436f496c..8e195d2d46 100644
--- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoUserRegistered.php
@@ -12,18 +12,19 @@
namespace Alchemy\Phrasea\Notification\Mail;
use Alchemy\Phrasea\Exception\LogicException;
+use Alchemy\Phrasea\Model\Entities\User;
class MailInfoUserRegistered extends AbstractMail
{
- /** @var \User_Adapter */
+ /** @var User */
private $registeredUser;
/**
* Sets the user that just registered
*
- * @param \User_Adapter $registeredUser
+ * @param User $registeredUser
*/
- public function setRegisteredUser(\User_Adapter $registeredUser)
+ public function setRegisteredUser(User $registeredUser)
{
$this->registeredUser = $registeredUser;
}
@@ -46,8 +47,8 @@ class MailInfoUserRegistered extends AbstractMail
}
return $this->app->trans('admin::register: un utilisateur a fait une demande d\'inscription')
- . "\n\n" . sprintf('%s %s',$this->registeredUser->get_firstname(), $this->registeredUser->get_lastname())
- . "\n\n" . sprintf('%s %s',$this->registeredUser->get_job(), $this->registeredUser->get_company());
+ . "\n\n" . sprintf('%s %s',$this->registeredUser->getFirstName(), $this->registeredUser->getLastName())
+ . "\n\n" . sprintf('%s %s',$this->registeredUser->getJob(), $this->registeredUser->getCompany());
}
/**
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php
index 0490a1f04b..057de54c78 100644
--- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationDone.php
@@ -12,12 +12,13 @@
namespace Alchemy\Phrasea\Notification\Mail;
use Alchemy\Phrasea\Exception\LogicException;
+use Alchemy\Phrasea\Model\Entities\User;
class MailInfoValidationDone extends AbstractMailWithLink
{
/** @var string */
private $title;
- /** @var \User_Adapter */
+ /** @var User */
private $user;
/**
@@ -33,9 +34,9 @@ class MailInfoValidationDone extends AbstractMailWithLink
/**
* Sets the user that finished validation
*
- * @param \User_Adapter $user
+ * @param User $user
*/
- public function setUser(\User_Adapter $user)
+ public function setUser(User $user)
{
$this->user = $user;
}
@@ -53,7 +54,7 @@ class MailInfoValidationDone extends AbstractMailWithLink
}
return $this->app->trans('push::mail:: Rapport de validation de %user% pour %title%', [
- '%user%' => $this->user->get_display_name(),
+ '%user%' => $this->user->getDisplayName(),
'%title%' => $this->title,
]);
}
@@ -68,7 +69,7 @@ class MailInfoValidationDone extends AbstractMailWithLink
}
return $this->app->trans('%user% has just sent its validation report, you can now see it', [
- '%user%' => $this->user->get_display_name(),
+ '%user%' => $this->user->getDisplayName(),
]);
}
diff --git a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php
index abc36abacd..2aa87739c8 100644
--- a/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php
+++ b/lib/Alchemy/Phrasea/Notification/Mail/MailInfoValidationRequest.php
@@ -12,12 +12,13 @@
namespace Alchemy\Phrasea\Notification\Mail;
use Alchemy\Phrasea\Exception\LogicException;
+use Alchemy\Phrasea\Model\Entities\User;
class MailInfoValidationRequest extends AbstractMailWithLink
{
/** @var string */
private $title;
- /** @var \User_Adapter */
+ /** @var User */
private $user;
/** @var integer */
private $duration;
@@ -59,7 +60,7 @@ class MailInfoValidationRequest extends AbstractMailWithLink
throw new LogicException('You must set a title before calling getSubject');
}
- return $this->app->trans("Validation request from %user% for '%title%'", ['%user%' => $this->user->get_display_name(), '%title%' => $this->title]);
+ return $this->app->trans("Validation request from %user% for '%title%'", ['%user%' => $this->user->getDisplayName(), '%title%' => $this->title]);
}
/**
diff --git a/lib/Alchemy/Phrasea/Notification/Receiver.php b/lib/Alchemy/Phrasea/Notification/Receiver.php
index 1707d2d8ee..e3671c882c 100644
--- a/lib/Alchemy/Phrasea/Notification/Receiver.php
+++ b/lib/Alchemy/Phrasea/Notification/Receiver.php
@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Notification;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
+use Alchemy\Phrasea\Model\Entities\User;
class Receiver implements ReceiverInterface
{
@@ -47,14 +48,14 @@ class Receiver implements ReceiverInterface
/**
* Creates a Receiver given a User
*
- * @param \User_Adapter $user
+ * @param User $user
*
* @return Receiver
*
* @throws InvalidArgumentException In case no valid email is found for user
*/
- public static function fromUser(\User_Adapter $user)
+ public static function fromUser(User $user)
{
- return new static($user->get_display_name(), $user->get_email());
+ return new static($user->getDisplayName(), $user->getEmail());
}
}
diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php
index e1fc4a44e2..77527adabc 100644
--- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php
+++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php
@@ -194,8 +194,8 @@ class PhraseaEngine implements SearchEngineInterface
throw new \RuntimeException('Phrasea currently support only authenticated queries');
}
- if (!phrasea_open_session($this->app['session']->get('phrasea_session_id'), $this->app['authentication']->getUser()->get_id())) {
- if (!$ses_id = phrasea_create_session((string) $this->app['authentication']->getUser()->get_id())) {
+ if (!phrasea_open_session($this->app['session']->get('phrasea_session_id'), $this->app['authentication']->getUser()->getId())) {
+ if (!$ses_id = phrasea_create_session((string) $this->app['authentication']->getUser()->getId())) {
throw new \Exception_InternalServerError('Unable to create phrasea session');
}
$this->app['session']->set('phrasea_session_id', $ses_id);
diff --git a/lib/Alchemy/Phrasea/Setup/Installer.php b/lib/Alchemy/Phrasea/Setup/Installer.php
index 91f1ccbe59..16808c21fe 100644
--- a/lib/Alchemy/Phrasea/Setup/Installer.php
+++ b/lib/Alchemy/Phrasea/Setup/Installer.php
@@ -101,7 +101,7 @@ class Installer
private function createUser($email, $password)
{
- $user = \User_Adapter::create($this->app, $email, $password, $email, true);
+ $user = $this->app['manipulator.user']->createUser($email, $password, $email, true);
$this->app['authentication']->openAccount($user);
return $user;
diff --git a/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php b/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php
index 5ac5faf66c..ca6cd114de 100644
--- a/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php
+++ b/lib/Alchemy/Phrasea/Setup/Version/MailChecker.php
@@ -26,7 +26,7 @@ class MailChecker
* @param \Application $app
* @param string $table The table name where to look
*
- * @return array An array of User_Adapter
+ * @return array An array of User
*/
public static function getWrongEmailUsers(Application $app, $table = 'usr')
{
diff --git a/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php b/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php
index 0eb7b006b8..e7fe799397 100644
--- a/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php
+++ b/lib/Alchemy/Phrasea/TaskManager/Job/BridgeJob.php
@@ -55,13 +55,13 @@ class BridgeJob extends AbstractJob
{
$app = $data->getApplication();
- $status = [
+ $status = array(
\Bridge_Element::STATUS_PENDING,
\Bridge_Element::STATUS_PROCESSING,
\Bridge_Element::STATUS_PROCESSING_SERVER
- ];
+ );
- $params = [];
+ $params = array();
$n = 1;
foreach ($status as $stat) {
@@ -96,7 +96,7 @@ class BridgeJob extends AbstractJob
$this->log('error', sprintf("An error occured : %s", $e->getMessage()));
$sql = 'UPDATE bridge_elements SET status = :status WHERE id = :id';
- $params = [':status' => \Bridge_Element::STATUS_ERROR, ':id' => $row['id']];
+ $params = array(':status' => \Bridge_Element::STATUS_ERROR, ':id' => $row['id']);
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
@@ -154,13 +154,13 @@ class BridgeJob extends AbstractJob
switch ($status) {
case \Bridge_Element::STATUS_ERROR:
- $params = [
- 'usr_id' => $account->get_user()->get_id(),
+ $params = array(
+ 'usr_id' => $account->get_user()->getId(),
'reason' => $error_message,
'account_id' => $account->get_id(),
'sbas_id' => $element->get_record()->get_sbas_id(),
'record_id' => $element->get_record()->get_record_id(),
- ];
+ );
$app['events-manager']->trigger('__BRIDGE_UPLOAD_FAIL__', $params);
break;
diff --git a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php
index ed8b3c2de9..3fe9cddf39 100644
--- a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php
+++ b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/ControlProviderInterface.php
@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Vocabulary\ControlProvider;
+use Alchemy\Phrasea\Model\Entities\User;
+
interface ControlProviderInterface
{
@@ -48,10 +50,10 @@ interface ControlProviderInterface
* Find matching Term in the vocabulary repository
*
* @param string $query A scalar quaery
- * @param \User_Adapter $for_user The user doing the query
+ * @param User $for_user The user doing the query
* @param \databox $on_databox The databox where vocabulary should be requested
*
* @return Doctrine\Common\Collections\ArrayCollection
*/
- public function find($query, \User_Adapter $for_user, \databox $on_databox);
+ public function find($query, User $for_user, \databox $on_databox);
}
diff --git a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php
index 344dc89344..8b1d4a48e2 100644
--- a/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php
+++ b/lib/Alchemy/Phrasea/Vocabulary/ControlProvider/UserProvider.php
@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Vocabulary\ControlProvider;
use Alchemy\Phrasea\Application;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\Common\Collections\ArrayCollection;
use Alchemy\Phrasea\Vocabulary\Term;
@@ -45,11 +46,11 @@ class UserProvider implements ControlProviderInterface
/**
*
* @param string $query
- * @param \User_Adapter $for_user
+ * @param User $for_user
* @param \databox $on_databox
* @return \Doctrine\Common\Collections\ArrayCollection
*/
- public function find($query, \User_Adapter $for_user, \databox $on_databox = null)
+ public function find($query, User $for_user, \databox $on_databox = null)
{
$user_query = new \User_Query($this->app);
@@ -67,7 +68,7 @@ class UserProvider implements ControlProviderInterface
foreach ($users as $user) {
$results->add(
- new Term($user->get_display_name(), '', $this, $user->get_id())
+ new Term($user->getDisplayName(), '', $this, $user->getId())
);
}
@@ -81,15 +82,7 @@ class UserProvider implements ControlProviderInterface
*/
public function validate($id)
{
- try {
- \User_Adapter::getInstance($id, $this->app);
-
- return true;
- } catch (\Exception $e) {
-
- }
-
- return false;
+ return (Boolean) $this->app['manipulator.user']->getRepository()->find($id);
}
/**
@@ -99,9 +92,9 @@ class UserProvider implements ControlProviderInterface
*/
public function getValue($id)
{
- $user = \User_Adapter::getInstance($id, $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($id);
- return $user->get_display_name();
+ return $user->getDisplayName();
}
/**
@@ -111,6 +104,6 @@ class UserProvider implements ControlProviderInterface
*/
public function getRessource($id)
{
- return \User_Adapter::getInstance($id, $this->app);
+ return $this->app['manipulator.user']->getRepository()->find($id);
}
}
diff --git a/lib/classes/ACL.php b/lib/classes/ACL.php
index 9b792c7a4b..a1f9d844f2 100644
--- a/lib/classes/ACL.php
+++ b/lib/classes/ACL.php
@@ -10,6 +10,7 @@
*/
use Alchemy\Phrasea\Application;
+use Alchemy\Phrasea\Model\Entities\User;
class ACL implements cache_cacheableInterface
{
@@ -59,7 +60,7 @@ class ACL implements cache_cacheableInterface
*
* @var Array
*/
- protected $_global_rights = [
+ protected $_global_rights = array(
'taskmanager' => false,
'manageusers' => false,
'order' => false,
@@ -80,7 +81,7 @@ class ACL implements cache_cacheableInterface
'bas_chupub' => false,
'candwnldpreview' => true,
'candwnldhd' => true
- ];
+ );
/**
*
@@ -138,20 +139,20 @@ class ACL implements cache_cacheableInterface
return false;
}
- public function grant_hd_on(record_adapter $record, User_Adapter $pusher, $action)
+ public function grant_hd_on(record_adapter $record, User $pusher, $action)
{
$sql = 'REPLACE INTO records_rights
(id, usr_id, sbas_id, record_id, document, `case`, pusher_usr_id)
VALUES
(null, :usr_id, :sbas_id, :record_id, 1, :case, :pusher)';
- $params = [
- ':usr_id' => $this->user->get_id()
+ $params = array(
+ ':usr_id' => $this->user->getId()
, ':sbas_id' => $record->get_sbas_id()
, ':record_id' => $record->get_record_id()
, ':case' => $action
- , ':pusher' => $pusher->get_id()
- ];
+ , ':pusher' => $pusher->getId()
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -162,20 +163,20 @@ class ACL implements cache_cacheableInterface
return $this;
}
- public function grant_preview_on(record_adapter $record, User_Adapter $pusher, $action)
+ public function grant_preview_on(record_adapter $record, User $pusher, $action)
{
$sql = 'REPLACE INTO records_rights
(id, usr_id, sbas_id, record_id, preview, `case`, pusher_usr_id)
VALUES
(null, :usr_id, :sbas_id, :record_id, 1, :case, :pusher)';
- $params = [
- ':usr_id' => $this->user->get_id()
+ $params = array(
+ ':usr_id' => $this->user->getId()
, ':sbas_id' => $record->get_sbas_id()
, ':record_id' => $record->get_record_id()
, ':case' => $action
- , ':pusher' => $pusher->get_id()
- ];
+ , ':pusher' => $pusher->getId()
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -272,7 +273,7 @@ class ACL implements cache_cacheableInterface
return $this;
}
- $sbas_ids = [];
+ $sbas_ids = array();
foreach ($base_ids as $base_id) {
$sbas_ids[] = phrasea::sbasFromBas($this->app, $base_id);
@@ -280,10 +281,10 @@ class ACL implements cache_cacheableInterface
$sbas_ids = array_unique($sbas_ids);
- $sbas_rights = ['bas_manage', 'bas_modify_struct', 'bas_modif_th', 'bas_chupub'];
+ $sbas_rights = array('bas_manage', 'bas_modify_struct', 'bas_modif_th', 'bas_chupub');
- $sbas_to_acces = [];
- $rights_to_give = [];
+ $sbas_to_acces = array();
+ $rights_to_give = array();
foreach ($this->app['acl']->get($template_user)->get_granted_sbas() as $databox) {
$sbas_id = $databox->get_sbas_id();
@@ -308,27 +309,27 @@ class ACL implements cache_cacheableInterface
$this->update_rights_to_sbas($sbas_id, $rights);
}
- $bas_rights = ['canputinalbum', 'candwnldhd'
+ $bas_rights = array('canputinalbum', 'candwnldhd'
, 'candwnldpreview', 'cancmd'
, 'canadmin', 'actif', 'canreport', 'canpush'
, 'canaddrecord', 'canmodifrecord', 'candeleterecord'
, 'chgstatus', 'imgtools'
, 'manage', 'modify_struct'
, 'nowatermark', 'order_master'
- ];
+ );
- $bas_to_acces = $masks_to_give = $rights_to_give = [];
+ $bas_to_acces = $masks_to_give = $rights_to_give = array();
/**
* map masks (and+xor) of template to masks to apply to user on base
* (and_and, and_or, xor_and, xor_or)
*/
- $sbmap = [
- '00' => ['aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'],
- '01' => ['aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'],
- '10' => ['aa' => '1', 'ao' => '1', 'xa' => '0', 'xo' => '0'],
- '11' => ['aa' => '1', 'ao' => '1', 'xa' => '1', 'xo' => '1']
- ];
+ $sbmap = array(
+ '00' => array('aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'),
+ '01' => array('aa' => '1', 'ao' => '0', 'xa' => '1', 'xo' => '0'),
+ '10' => array('aa' => '1', 'ao' => '1', 'xa' => '0', 'xo' => '0'),
+ '11' => array('aa' => '1', 'ao' => '1', 'xa' => '1', 'xo' => '1')
+ );
foreach ($this->app['acl']->get($template_user)->get_granted_base() as $collection) {
$base_id = $collection->get_base_id();
@@ -362,7 +363,7 @@ class ACL implements cache_cacheableInterface
. decbin($mask_xor)
, -32
);
- $m = ['aa' => '', 'ao' => '', 'xa' => '', 'xo' => ''];
+ $m = array('aa' => '', 'ao' => '', 'xa' => '', 'xo' => '');
for ($i = 0; $i < 32; $i++) {
$ax = $mand[$i] . $mxor[$i];
@@ -371,12 +372,12 @@ class ACL implements cache_cacheableInterface
}
}
- $masks_to_give[$base_id] = [
+ $masks_to_give[$base_id] = array(
'aa' => $m['aa']
, 'ao' => $m['ao']
, 'xa' => $m['xa']
, 'xo' => $m['xo']
- ];
+ );
}
$this->give_access_to_base($bas_to_acces);
@@ -448,7 +449,7 @@ class ACL implements cache_cacheableInterface
*/
public function get_cache_key($option = null)
{
- return '_ACL_' . $this->user->get_id() . ($option ? '_' . $option : '');
+ return '_ACL_' . $this->user->getId() . ($option ? '_' . $option : '');
}
/**
@@ -669,10 +670,10 @@ class ACL implements cache_cacheableInterface
* @param array|null $sbas_ids Optionnal sbas_id to restrict the query on
* @return array An array of collection
*/
- public function get_granted_base(Array $rights = [], array $sbas_ids = null)
+ public function get_granted_base(Array $rights = array(), array $sbas_ids = null)
{
$this->load_rights_bas();
- $ret = [];
+ $ret = array();
foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) {
if ($sbas_ids && !in_array($databox->get_sbas_id(), $sbas_ids)) {
@@ -716,16 +717,16 @@ class ACL implements cache_cacheableInterface
* @param Array $rights
* @return Array
*/
- public function get_granted_sbas($rights = [])
+ public function get_granted_sbas($rights = array())
{
if (is_string($rights))
- $rights = [$rights];
+ $rights = array($rights);
assert(is_array($rights));
$this->load_rights_sbas();
- $ret = [];
+ $ret = array();
foreach ($this->_rights_sbas as $sbas_id => $datas) {
$continue = false;
@@ -761,10 +762,10 @@ class ACL implements cache_cacheableInterface
$sql = 'UPDATE usr SET create_db = :create_db WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([
+ $stmt->execute(array(
':create_db' => $boolean ? '1' : '0',
- ':usr_id' => $this->user->get_id()
- ]);
+ ':usr_id' => $this->user->getId()
+ ));
$stmt->closeCursor();
$this->delete_data_from_cache(self::CACHE_IS_ADMIN);
@@ -799,13 +800,13 @@ class ACL implements cache_cacheableInterface
FROM records_rights WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->user->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->user->getId()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
unset($stmt);
- $this->_rights_records_preview = [];
- $this->_rights_records_document = [];
+ $this->_rights_records_preview = array();
+ $this->_rights_records_document = array();
foreach ($rs as $row) {
$currentid = $row["sbas_id"] . "_" . $row["record_id"];
@@ -814,10 +815,10 @@ class ACL implements cache_cacheableInterface
$this->_rights_records_preview[$currentid] = $currentid;
}
- $datas = [
+ $datas = array(
'preview' => $this->_rights_records_preview
, 'document' => $this->_rights_records_document
- ];
+ );
$this->set_data_to_cache($datas, self::CACHE_RIGHTS_RECORDS);
@@ -841,7 +842,7 @@ class ACL implements cache_cacheableInterface
FROM usr WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->user->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->user->getId()));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
unset($stmt);
@@ -878,11 +879,11 @@ class ACL implements cache_cacheableInterface
AND sbas.sbas_id = sbasusr.sbas_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->user->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->user->getId()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $this->_rights_sbas = [];
+ $this->_rights_sbas = array();
$this->_global_rights['bas_modif_th'] = false;
$this->_global_rights['bas_modify_struct'] = false;
@@ -939,11 +940,11 @@ class ACL implements cache_cacheableInterface
AND s.sbas_id = b.sbas_id ';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->user->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->user->getId()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $this->_rights_bas = $this->_limited = [];
+ $this->_rights_bas = $this->_limited = array();
$this->_global_rights['manageusers'] = false;
$this->_global_rights['coll_manage'] = false;
@@ -1000,10 +1001,10 @@ class ACL implements cache_cacheableInterface
if ($row['time_limited'] == '1'
&& ($row['limited_from'] !== '' || $row['limited_to'] !== '')) {
- $this->_limited[$row['base_id']] = [
+ $this->_limited[$row['base_id']] = array(
'dmin' => $row['limited_from'] ? new DateTime($row['limited_from']) : null
, 'dmax' => $row['limited_to'] ? new DateTime($row['limited_to']) : null
- ];
+ );
}
$this->_rights_bas[$row['base_id']]['imgtools']
@@ -1116,10 +1117,10 @@ class ACL implements cache_cacheableInterface
$sql_del = 'DELETE FROM basusr WHERE base_id = :base_id AND usr_id = :usr_id';
$stmt_del = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_del);
- $usr_id = $this->user->get_id();
+ $usr_id = $this->user->getId();
foreach ($base_ids as $base_id) {
- if (!$stmt_del->execute([':base_id' => $base_id, ':usr_id' => $usr_id])) {
+ if (!$stmt_del->execute(array(':base_id' => $base_id, ':usr_id' => $usr_id))) {
throw new Exception('Error while deleteing some rights');
}
}
@@ -1138,13 +1139,13 @@ class ACL implements cache_cacheableInterface
$sql_ins = 'INSERT INTO basusr (id, base_id, usr_id, actif)
VALUES (null, :base_id, :usr_id, "1")';
$stmt_ins = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_ins);
- $usr_id = $this->user->get_id();
- $to_update = [];
+ $usr_id = $this->user->getId();
+ $to_update = array();
$this->load_rights_bas();
foreach ($base_ids as $base_id) {
if (!isset($this->_rights_bas[$base_id])) {
- $stmt_ins->execute([':base_id' => $base_id, ':usr_id' => $usr_id]);
+ $stmt_ins->execute(array(':base_id' => $base_id, ':usr_id' => $usr_id));
} elseif ($this->_rights_bas[$base_id]['actif'] === false) {
$to_update[] = $base_id;
}
@@ -1155,7 +1156,7 @@ class ACL implements cache_cacheableInterface
WHERE usr_id = :usr_id AND base_id = :base_id';
$stmt_upd = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_upd);
foreach ($to_update as $base_id) {
- $stmt_upd->execute([':usr_id' => $usr_id, ':base_id' => $base_id]);
+ $stmt_upd->execute(array(':usr_id' => $usr_id, ':base_id' => $base_id));
}
$stmt_upd->closeCursor();
@@ -1175,11 +1176,11 @@ class ACL implements cache_cacheableInterface
$sql_ins = 'INSERT INTO sbasusr (sbasusr_id, sbas_id, usr_id) VALUES (null, :sbas_id, :usr_id)';
$stmt_ins = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_ins);
- $usr_id = $this->user->get_id();
+ $usr_id = $this->user->getId();
foreach ($sbas_ids as $sbas_id) {
if (!$this->has_access_to_sbas($sbas_id))
- $stmt_ins->execute([':sbas_id' => $sbas_id, ':usr_id' => $usr_id]);
+ $stmt_ins->execute(array(':sbas_id' => $sbas_id, ':usr_id' => $usr_id));
}
$this->delete_data_from_cache(self::CACHE_RIGHTS_SBAS);
@@ -1198,12 +1199,12 @@ class ACL implements cache_cacheableInterface
{
if (!$this->has_access_to_base($base_id) && (!isset($rights['actif']) || $rights['actif'] == '1')) {
- $this->give_access_to_base([$base_id]);
+ $this->give_access_to_base(array($base_id));
}
$sql_up = "UPDATE basusr SET ";
- $sql_args = $params = [];
+ $sql_args = $params = array();
foreach ($rights as $right => $v) {
$sql_args[] = " " . $right . " = :" . $right;
switch ($right) {
@@ -1221,14 +1222,14 @@ class ACL implements cache_cacheableInterface
return $this;
}
- $usr_id = $this->user->get_id();
+ $usr_id = $this->user->getId();
$sql_up .= implode(', ', $sql_args) . ' WHERE base_id = :base_id
AND usr_id = :usr_id';
$params = array_merge(
$params
- , [':base_id' => $base_id, ':usr_id' => $usr_id]
+ , array(':base_id' => $base_id, ':usr_id' => $usr_id)
);
$stmt_up = $this->app['phraseanet.appbox']->get_connection()->prepare($sql_up);
@@ -1252,8 +1253,8 @@ class ACL implements cache_cacheableInterface
(SELECT distinct sbas_id FROM basusr bu, bas b
WHERE usr_id = :usr_id_2 AND b.base_id = bu.base_id)';
- $usr_id = $this->user->get_id();
- $params = [':usr_id_1' => $usr_id, ':usr_id_2' => $usr_id];
+ $usr_id = $this->user->getId();
+ $params = array(':usr_id_1' => $usr_id, ':usr_id_2' => $usr_id);
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -1273,13 +1274,13 @@ class ACL implements cache_cacheableInterface
public function update_rights_to_sbas($sbas_id, $rights)
{
if (!$this->has_access_to_sbas($sbas_id))
- $this->give_access_to_sbas([$sbas_id]);
+ $this->give_access_to_sbas(array($sbas_id));
$sql_up = "UPDATE sbasusr SET ";
- $sql_args = [];
- $usr_id = $this->user->get_id();
- $params = [':sbas_id' => $sbas_id, ':usr_id' => $usr_id];
+ $sql_args = array();
+ $usr_id = $this->user->getId();
+ $params = array(':sbas_id' => $sbas_id, ':usr_id' => $usr_id);
foreach ($rights as $right => $v) {
$sql_args[] = " " . $right . " = :" . $right;
@@ -1315,7 +1316,7 @@ class ACL implements cache_cacheableInterface
WHERE usr_id = :usr_id AND base_id = :base_id ';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->user->get_id(), ':base_id' => $base_id]);
+ $stmt->execute(array(':usr_id' => $this->user->getId(), ':base_id' => $base_id));
$stmt->closeCursor();
unset($stmt);
@@ -1331,13 +1332,13 @@ class ACL implements cache_cacheableInterface
AND usr_id = :usr_id
AND MONTH(lastconn) != MONTH(NOW()) AND restrict_dwnld = 1';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->user->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->user->getId()));
$stmt->closeCursor();
$sql = "UPDATE basusr SET lastconn=now()
WHERE usr_id = :usr_id AND actif = 1";
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->user->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->user->getId()));
$stmt->closeCursor();
unset($stmt);
@@ -1359,12 +1360,12 @@ class ACL implements cache_cacheableInterface
SET remain_dwnld = :restes, restrict_dwnld = 1, month_dwnld_max = :droits
WHERE usr_id = :usr_id AND base_id = :base_id ';
- $params = [
- ':usr_id' => $this->user->get_id(),
+ $params = array(
+ ':usr_id' => $this->user->getId(),
':base_id' => $base_id,
':restes' => $restes,
':droits' => $droits
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -1381,10 +1382,10 @@ class ACL implements cache_cacheableInterface
$sql = 'SELECT * FROM basusr
WHERE base_id = :base_from AND usr_id = :usr_id';
- $params = [
+ $params = array(
':base_from' => $base_id_from,
- ':usr_id' => $this->user->get_id()
- ];
+ ':usr_id' => $this->user->getId()
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -1395,12 +1396,12 @@ class ACL implements cache_cacheableInterface
return $this;
}
- $this->give_access_to_base([$base_id_dest]);
+ $this->give_access_to_base(array($base_id_dest));
- $rights = [
+ $rights = array(
'mask_and' => $row['mask_and'],
'mask_xor' => $row['mask_xor'],
- ];
+ );
if ($row['canputinalbum'])
$rights['canputinalbum'] = true;
@@ -1470,7 +1471,7 @@ class ACL implements cache_cacheableInterface
foreach ($this->get_granted_base([], [$databox->get_sbas_id()]) as $collection) {
$stmt->execute([
':site_id' => $this->app['conf']->get(['main', 'key']),
- ':usr_id' => $this->user->get_id(),
+ ':usr_id' => $this->user->getId(),
':coll_id' => $collection->get_coll_id(),
':mask_and' => $this->get_mask_and($collection->get_base_id()),
':mask_xor' => $this->get_mask_xor($collection->get_base_id()),
@@ -1496,7 +1497,7 @@ class ACL implements cache_cacheableInterface
{
$sql = 'DELETE FROM collusr WHERE usr_id = :usr_id AND site = :site';
$params = [
- ':usr_id' => $this->user->get_id()
+ ':usr_id' => $this->user->getId()
, ':site' => $this->app['conf']->get(['main', 'key'])
];
$stmt = $databox->get_connection()->prepare($sql);
@@ -1508,13 +1509,13 @@ class ACL implements cache_cacheableInterface
public function set_masks_on_base($base_id, $and_and, $and_or, $xor_and, $xor_or)
{
- $vhex = [];
- $datas = [
+ $vhex = array();
+ $datas = array(
'and_and' => $and_and,
'and_or' => $and_or,
'xor_and' => $xor_and,
'xor_or' => $xor_or
- ];
+ );
foreach ($datas as $name => $f) {
$vhex[$name] = "0x";
@@ -1536,7 +1537,7 @@ class ACL implements cache_cacheableInterface
WHERE usr_id = :usr_id and base_id = :base_id";
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':base_id' => $base_id, ':usr_id' => $this->user->get_id()]);
+ $stmt->execute(array(':base_id' => $base_id, ':usr_id' => $this->user->getId()));
$stmt->closeCursor();
unset($stmt);
@@ -1589,12 +1590,12 @@ class ACL implements cache_cacheableInterface
WHERE base_id = :base_id AND usr_id = :usr_id';
}
- $params = [
- ':usr_id' => $this->user->get_id()
+ $params = array(
+ ':usr_id' => $this->user->getId()
, ':base_id' => $base_id
, 'limited_from' => ($limit_from ? $limit_from->format(DATE_ISO8601) : null)
, 'limited_to' => ($limit_to ? $limit_to->format(DATE_ISO8601) : null)
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
@@ -1616,11 +1617,11 @@ class ACL implements cache_cacheableInterface
{
$sql = 'SELECT base_id FROM basusr WHERE order_master="1" AND usr_id= :usr_id ';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->user->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->user->getId()));
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $collections = [];
+ $collections = array();
foreach ($rs as $row) {
$collections[] = \collection::get_from_base_id($this->app, $row['base_id']);
@@ -1643,11 +1644,11 @@ class ACL implements cache_cacheableInterface
WHERE usr_id = :usr_id AND base_id = :base_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([
+ $stmt->execute(array(
':master' => $bool ? 1 : 0,
- ':usr_id' => $this->user->get_id(),
+ ':usr_id' => $this->user->getId(),
':base_id' => $collection->get_base_id()
- ]);
+ ));
$stmt->closeCursor();
return $this;
diff --git a/lib/classes/API/OAuth2/Account.php b/lib/classes/API/OAuth2/Account.php
index 13cc69b6f3..ebba616766 100644
--- a/lib/classes/API/OAuth2/Account.php
+++ b/lib/classes/API/OAuth2/Account.php
@@ -11,6 +11,7 @@
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+use Alchemy\Phrasea\Model\Entities\User;
class API_OAuth2_Account
{
@@ -28,7 +29,7 @@ class API_OAuth2_Account
/**
*
- * @var User_Adapter
+ * @var User
*/
protected $user;
@@ -78,12 +79,12 @@ class API_OAuth2_Account
WHERE api_account_id = :api_account_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':api_account_id' => $this->id]);
+ $stmt->execute(array(':api_account_id' => $this->id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$this->application_id = (int) $row['application_id'];
- $this->user = User_Adapter::getInstance($row['usr_id'], $app);
+ $this->user = $app['manipulator.user']->getRepository()->find($row['usr_id']);
$this->api_version = $row['api_version'];
$this->revoked = ! ! $row['revoked'];
@@ -103,7 +104,7 @@ class API_OAuth2_Account
/**
*
- * @return User_Adapter
+ * @return User
*/
public function get_user()
{
@@ -140,10 +141,10 @@ class API_OAuth2_Account
$sql = 'UPDATE api_accounts SET revoked = :revoked
WHERE api_account_id = :account_id';
- $params = [
+ $params = array(
':revoked' => ($boolean ? '1' : '0')
, 'account_id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -208,26 +209,26 @@ class API_OAuth2_Account
$sql = 'DELETE FROM api_accounts WHERE api_account_id = :account_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute(['account_id' => $this->id]);
+ $stmt->execute(array('account_id' => $this->id));
$stmt->closeCursor();
return;
}
- public static function create(Application $app, User_Adapter $user, API_OAuth2_Application $application)
+ public static function create(Application $app, User $user, API_OAuth2_Application $application)
{
$sql = 'INSERT INTO api_accounts
(api_account_id, usr_id, revoked, api_version, application_id, created)
VALUES (null, :usr_id, :revoked, :api_version, :application_id, :created)';
$datetime = new Datetime();
- $params = [
- ':usr_id' => $user->get_id()
+ $params = array(
+ ':usr_id' => $user->getId()
, ':application_id' => $application->get_id()
, ':api_version' => API_OAuth2_Adapter::API_VERSION
, ':revoked' => 0
, ':created' => $datetime->format("Y-m-d H:i:s")
- ];
+ );
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -238,15 +239,15 @@ class API_OAuth2_Account
return new self($app, $account_id);
}
- public static function load_with_user(Application $app, API_OAuth2_Application $application, User_Adapter $user)
+ public static function load_with_user(Application $app, API_OAuth2_Application $application, User $user)
{
$sql = 'SELECT api_account_id FROM api_accounts
WHERE usr_id = :usr_id AND application_id = :application_id';
- $params = [
- ":usr_id" => $user->get_id(),
+ $params = array(
+ ":usr_id" => $user->getId(),
":application_id" => $application->get_id()
- ];
+ );
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
diff --git a/lib/classes/API/OAuth2/Adapter.php b/lib/classes/API/OAuth2/Adapter.php
index 61835dcdcd..8ef63c11f4 100644
--- a/lib/classes/API/OAuth2/Adapter.php
+++ b/lib/classes/API/OAuth2/Adapter.php
@@ -222,7 +222,7 @@ class API_OAuth2_Adapter extends OAuth2
, 'client_id' => $token->get_account()->get_application()->get_client_id()
, 'session_id' => $token->get_session_id()
, 'revoked' => ($token->get_account()->is_revoked() ? '1' : '0')
- , 'usr_id' => $token->get_account()->get_user()->get_id()
+ , 'usr_id' => $token->get_account()->get_user()->getId()
, 'oauth_token' => $token->get_value()
];
@@ -506,7 +506,7 @@ class API_OAuth2_Adapter extends OAuth2
throw new logicalException("Client property must be set before update an account");
try {
- $user = User_Adapter::getInstance($usr_id, $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($usr_id);
$account = API_OAuth2_Account::load_with_user($this->app, $this->client, $user);
} catch (Exception $e) {
$account = $this->createAccount($usr_id);
@@ -522,7 +522,7 @@ class API_OAuth2_Adapter extends OAuth2
*/
private function createAccount($usr_id)
{
- $user = User_Adapter::getInstance($usr_id, $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($usr_id);
return API_OAuth2_Account::create($this->app, $user, $this->client);
}
diff --git a/lib/classes/API/OAuth2/Application.php b/lib/classes/API/OAuth2/Application.php
index 4c0d6ee67e..bb0926b411 100644
--- a/lib/classes/API/OAuth2/Application.php
+++ b/lib/classes/API/OAuth2/Application.php
@@ -11,6 +11,7 @@
use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+use Alchemy\Phrasea\Model\Entities\User;
class API_OAuth2_Application
{
@@ -41,7 +42,7 @@ class API_OAuth2_Application
/**
*
- * @var User_Adapter
+ * @var User
*/
protected $creator;
@@ -137,7 +138,7 @@ class API_OAuth2_Application
WHERE application_id = :application_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':application_id' => $this->id]);
+ $stmt->execute(array(':application_id' => $this->id));
if (0 === $stmt->rowCount()) {
throw new NotFoundHttpException(sprintf('Application with id %d not found', $this->id));
@@ -145,7 +146,7 @@ class API_OAuth2_Application
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $this->creator = ! $row['creator'] ? null : User_Adapter::getInstance($row['creator'], $this->app);
+ $this->creator = ! $row['creator'] ? null : $this->app['manipulator.user']->getRepository()->find($row['creator']);
$this->type = $row['type'];
$this->name = $row['name'];
$this->description = $row['description'];
@@ -173,7 +174,7 @@ class API_OAuth2_Application
/**
*
- * @return User_Adapter
+ * @return User
*/
public function get_creator()
{
@@ -205,7 +206,7 @@ class API_OAuth2_Application
*/
public function set_type($type)
{
- if ( ! in_array($type, [self::DESKTOP_TYPE, self::WEB_TYPE]))
+ if ( ! in_array($type, array(self::DESKTOP_TYPE, self::WEB_TYPE)))
throw new Exception_InvalidArgument();
$this->type = $type;
@@ -216,10 +217,10 @@ class API_OAuth2_Application
$sql = 'UPDATE api_applications SET type = :type, last_modified = NOW()
WHERE application_id = :application_id';
- $params = [
+ $params = array(
':type' => $this->type
, ':application_id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -249,10 +250,10 @@ class API_OAuth2_Application
$sql = 'UPDATE api_applications SET name = :name, last_modified = NOW()
WHERE application_id = :application_id';
- $params = [
+ $params = array(
':name' => $this->name
, ':application_id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -283,10 +284,10 @@ class API_OAuth2_Application
SET description = :description, last_modified = NOW()
WHERE application_id = :application_id';
- $params = [
+ $params = array(
':description' => $this->description
, ':application_id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -317,10 +318,10 @@ class API_OAuth2_Application
SET website = :website, last_modified = NOW()
WHERE application_id = :application_id';
- $params = [
+ $params = array(
':website' => $this->website
, ':application_id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -351,10 +352,10 @@ class API_OAuth2_Application
SET activated = :activated, last_modified = NOW()
WHERE application_id = :application_id';
- $params = [
+ $params = array(
':activated' => $this->activated
, ':application_id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -385,10 +386,10 @@ class API_OAuth2_Application
SET grant_password = :grant_password, last_modified = NOW()
WHERE application_id = :application_id';
- $params = [
+ $params = array(
':grant_password' => $this->grant_password
, ':application_id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -437,10 +438,10 @@ class API_OAuth2_Application
SET client_id = :client_id, last_modified = NOW()
WHERE application_id = :application_id';
- $params = [
+ $params = array(
':client_id' => $this->client_id
, ':application_id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -471,10 +472,10 @@ class API_OAuth2_Application
SET client_secret = :client_secret, last_modified = NOW()
WHERE application_id = :application_id';
- $params = [
+ $params = array(
':client_secret' => $this->client_secret
, ':application_id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -504,10 +505,10 @@ class API_OAuth2_Application
SET redirect_uri = :redirect_uri, last_modified = NOW()
WHERE application_id = :application_id';
- $params = [
+ $params = array(
':redirect_uri' => $this->redirect_uri
, ':application_id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -518,18 +519,18 @@ class API_OAuth2_Application
/**
*
- * @param User_Adapter $user
+ * @param User $user
* @return API_OAuth2_Account
*/
- public function get_user_account(user_adapter $user)
+ public function get_user_account(User $user)
{
$sql = 'SELECT api_account_id FROM api_accounts
WHERE usr_id = :usr_id AND application_id = :id';
- $params = [
- ':usr_id' => $user->get_id()
+ $params = array(
+ ':usr_id' => $user->getId()
, ':id' => $this->id
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -556,7 +557,7 @@ class API_OAuth2_Application
WHERE application_id = :application_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':application_id' => $this->get_id()]);
+ $stmt->execute(array(':application_id' => $this->get_id()));
$stmt->closeCursor();
return;
@@ -572,11 +573,11 @@ class API_OAuth2_Application
WHERE application_id = :application_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':application_id' => $this->get_id()]);
+ $stmt->execute(array(':application_id' => $this->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $accounts = [];
+ $accounts = array();
foreach ($rs as $row) {
$accounts[] = new API_OAuth2_Account($this->app, $row['api_account_id']);
@@ -588,11 +589,11 @@ class API_OAuth2_Application
/**
*
* @param Application $app
- * @param User_Adapter $user
+ * @param User $user
* @param type $name
* @return API_OAuth2_Application
*/
- public static function create(Application $app, User_Adapter $user = null, $name)
+ public static function create(Application $app, User $user = null, $name)
{
$sql = '
INSERT INTO api_applications (
@@ -608,15 +609,15 @@ class API_OAuth2_Application
$client_secret = API_OAuth2_Token::generate_token();
$client_token = API_OAuth2_Token::generate_token();
- $params = [
- ':usr_id' => $user ? $user->get_id() : null,
+ $params = array(
+ ':usr_id' => $user ? $user->getId() : null,
':name' => $name,
':client_id' => $client_token,
':client_secret' => $client_secret,
':nonce' => $nonce,
':activated' => 1,
':grant_password' => 0
- ];
+ );
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -645,7 +646,7 @@ class API_OAuth2_Application
WHERE client_id = :client_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':client_id' => $client_id]);
+ $stmt->execute(array(':client_id' => $client_id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -655,18 +656,18 @@ class API_OAuth2_Application
return new self($app, $row['application_id']);
}
- public static function load_dev_app_by_user(Application $app, User_Adapter $user)
+ public static function load_dev_app_by_user(Application $app, User $user)
{
$sql = 'SELECT a.application_id
FROM api_applications a, api_accounts b
WHERE a.creator = :usr_id AND a.application_id = b.application_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $user->get_id()]);
+ $stmt->execute(array(':usr_id' => $user->getId()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $apps = [];
+ $apps = array();
foreach ($rs as $row) {
$apps[] = new API_OAuth2_Application($app, $row['application_id']);
}
@@ -674,18 +675,18 @@ class API_OAuth2_Application
return $apps;
}
- public static function load_app_by_user(Application $app, user_adapter $user)
+ public static function load_app_by_user(Application $app, User $user)
{
$sql = 'SELECT a.application_id
FROM api_accounts a, api_applications c
WHERE usr_id = :usr_id AND c.application_id = a.application_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $user->get_id()]);
+ $stmt->execute(array(':usr_id' => $user->getId()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $apps = [];
+ $apps = array();
foreach ($rs as $row) {
$apps[] = new API_OAuth2_Application($app, $row['application_id']);
}
@@ -693,7 +694,7 @@ class API_OAuth2_Application
return $apps;
}
- public static function load_authorized_app_by_user(Application $app, user_adapter $user)
+ public static function load_authorized_app_by_user(Application $app, User $user)
{
$sql = '
SELECT a.application_id
@@ -702,11 +703,11 @@ class API_OAuth2_Application
AND revoked = 0';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $user->get_id()]);
+ $stmt->execute(array(':usr_id' => $user->getId()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $apps = [];
+ $apps = array();
foreach ($rs as $row) {
$apps[] = new API_OAuth2_Application($app, $row['application_id']);
}
diff --git a/lib/classes/API/V1/Interface.php b/lib/classes/API/V1/Interface.php
index 846571091d..df5b608189 100644
--- a/lib/classes/API/V1/Interface.php
+++ b/lib/classes/API/V1/Interface.php
@@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/
-use Alchemy\Phrasea\Model\Entities\Basket;
+use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\HttpFoundation\Request;
use Silex\Application;
@@ -199,7 +199,7 @@ interface API_V1_Interface
* BASKET_ID : required INT
*
*/
- public function delete_basket(Request $request, Basket $basket);
+ public function delete_basket(Request $request, $basket_id);
/**
* Route : /baskets/BASKET_ID/content/FORMAT/
@@ -210,7 +210,7 @@ interface API_V1_Interface
* BASKET_ID : required INT
*
*/
- public function get_basket(Request $request, Basket $basket);
+ public function get_basket(Request $request, $basket_id);
/**
* Route : /baskets/BASKET_ID/title/FORMAT/
@@ -221,7 +221,7 @@ interface API_V1_Interface
* BASKET_ID : required INT
*
*/
- public function set_basket_title(Request $request, Basket $basket);
+ public function set_basket_title(Request $request, $basket_id);
/**
* Route : /baskets/BASKET_ID/description/FORMAT/
@@ -232,7 +232,7 @@ interface API_V1_Interface
* BASKET_ID : required INT
*
*/
- public function set_basket_description(Request $request, Basket $basket);
+ public function set_basket_description(Request $request, $basket_id);
/**
* Route : /publications/list/FORMAT/
@@ -242,7 +242,7 @@ interface API_V1_Interface
* Parameters :
*
*/
- public function search_publications(Request $request, User_Adapter $user);
+ public function search_publications(Request $request, User $user);
/**
* Route : /publications/PUBLICATION_ID/remove/FORMAT/
@@ -264,11 +264,11 @@ interface API_V1_Interface
* PUBLICATION_ID : required INT
*
*/
- public function get_publication(Request $request, $publication_id, User_Adapter $user);
+ public function get_publication(Request $request, $publication_id, User $user);
- public function get_publications(Request $request, User_Adapter $user);
+ public function get_publications(Request $request, User $user);
- public function get_feed_entry(Request $request, $entry, User_Adapter $user);
+ public function get_feed_entry(Request $request, $entry, User $user);
/**
* Route : /users/search/FORMAT/
*
diff --git a/lib/classes/API/V1/adapter.php b/lib/classes/API/V1/adapter.php
index d94ec654c4..639c969cf1 100644
--- a/lib/classes/API/V1/adapter.php
+++ b/lib/classes/API/V1/adapter.php
@@ -23,6 +23,7 @@ use Alchemy\Phrasea\Model\Entities\FeedEntry;
use Alchemy\Phrasea\Model\Entities\FeedItem;
use Alchemy\Phrasea\Model\Entities\LazaretFile;
use Alchemy\Phrasea\Model\Entities\Task;
+use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\UserQuery;
use Alchemy\Phrasea\Model\Entities\ValidationData;
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
@@ -115,14 +116,14 @@ class API_V1_adapter extends API_V1_Abstract
$date = new \DateTime();
$data = $app['task-manager.live-information']->getManager();
- $result->set_datas(['scheduler' => [
+ $result->set_datas(array('scheduler' => array(
'configuration' => $data['configuration'],
'state' => $data['actual'],
'status' => $data['actual'],
'pid' => $data['process-id'],
'process-id' => $data['process-id'],
'updated_on' => $date->format(DATE_ATOM),
- ]]);
+ )));
return $result;
}
@@ -138,12 +139,12 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new \API_V1_result($app, $app['request'], $this);
- $ret = [];
+ $ret = array();
foreach ($app['manipulator.task']->getRepository()->findAll() as $task) {
$ret[] = $this->list_task($app, $task);
}
- $result->set_datas(['tasks' => $ret]);
+ $result->set_datas(array('tasks' => $ret));
return $result;
}
@@ -152,7 +153,7 @@ class API_V1_adapter extends API_V1_Abstract
{
$data = $app['task-manager.live-information']->getTask($task);
- return [
+ return array(
'id' => $task->getId(),
'title' => $task->getName(),
'name' => $task->getName(),
@@ -170,7 +171,7 @@ class API_V1_adapter extends API_V1_Abstract
'auto_start' => $task->getStatus() === Task::STATUS_STARTED,
'crashed' => $task->getCrashed(),
'status' => $task->getStatus(),
- ];
+ );
}
/**
@@ -183,7 +184,7 @@ class API_V1_adapter extends API_V1_Abstract
public function get_task(Application $app, Task $task)
{
$result = new \API_V1_result($app, $app['request'], $this);
- $ret = ['task' => $this->list_task($app, $task)];
+ $ret = array('task' => $this->list_task($app, $task));
$result->set_datas($ret);
return $result;
@@ -201,7 +202,7 @@ class API_V1_adapter extends API_V1_Abstract
$result = new \API_V1_result($app, $app['request'], $this);
$app['manipulator.task']->start($task);
- $result->set_datas(['task' => $this->list_task($app, $task)]);
+ $result->set_datas(array('task' => $this->list_task($app, $task)));
return $result;
}
@@ -218,7 +219,7 @@ class API_V1_adapter extends API_V1_Abstract
$result = new API_V1_result($app, $app['request'], $this);
$app['manipulator.task']->stop($task);
- $result->set_datas(['task' => $this->list_task($app, $task)]);
+ $result->set_datas(array('task' => $this->list_task($app, $task)));
return $result;
}
@@ -251,7 +252,7 @@ class API_V1_adapter extends API_V1_Abstract
$task->setStatus(Task::STATUS_STARTED);
}
- $result->set_datas(['task' => $this->list_task($app, $task)]);
+ $result->set_datas(array('task' => $this->list_task($app, $task)));
return $result;
}
@@ -264,23 +265,23 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function get_cache_info(Application $app)
{
- $caches = [
+ $caches = array(
'main' => $app['cache'],
'op_code' => $app['opcode-cache'],
'doctrine_metadatas' => $this->app['EM']->getConfiguration()->getMetadataCacheImpl(),
'doctrine_query' => $this->app['EM']->getConfiguration()->getQueryCacheImpl(),
'doctrine_result' => $this->app['EM']->getConfiguration()->getResultCacheImpl(),
- ];
+ );
- $ret = [];
+ $ret = array();
foreach ($caches as $name => $service) {
if ($service instanceof \Alchemy\Phrasea\Cache\Cache) {
- $ret['cache'][$name] = [
+ $ret['cache'][$name] = array(
'type' => $service->getName(),
'online' => $service->isOnline(),
'stats' => $service->getStats(),
- ];
+ );
} else {
$ret['cache'][$name] = null;
}
@@ -297,12 +298,12 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function get_config_info(Application $app)
{
- $ret = [];
+ $ret = array();
- $ret['phraseanet']['version'] = [
+ $ret['phraseanet']['version'] = array(
'name' => $app['phraseanet.version']::getName(),
'number' => $app['phraseanet.version']::getNumber(),
- ];
+ );
$ret['phraseanet']['environment'] = $app->getEnvironment();
$ret['phraseanet']['debug'] = $app['debug'];
@@ -323,7 +324,7 @@ class API_V1_adapter extends API_V1_Abstract
try {
$SEStatus = $app['phraseanet.SE']->getStatus();
} catch (\RuntimeException $e) {
- $SEStatus = ['error' => $e->getMessage()];
+ $SEStatus = array('error' => $e->getMessage());
}
$binaries = $app['conf']->get(['main', 'binaries']);
@@ -403,9 +404,9 @@ class API_V1_adapter extends API_V1_Abstract
'type' => $app['phraseanet.SE']->getName(),
'status' => $SEStatus,
'configuration' => $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration(),
- ],
- ],
- 'binary' => [
+ ),
+ ),
+ 'binary' => array(
'phpCli' => isset($binaries['php_binary']) ? $binaries['php_binary'] : null,
'phpIni' => $app['conf']->get(['registry', 'executables', 'php-conf-path']),
'swfExtract' => isset($binaries['swf_extract_binary']) ? $binaries['swf_extract_binary'] : null,
@@ -501,7 +502,7 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new API_V1_result($this->app, $request, $this);
- $result->set_datas(["databoxes" => $this->list_databoxes()]);
+ $result->set_datas(array("databoxes" => $this->list_databoxes()));
return $result;
}
@@ -519,11 +520,11 @@ class API_V1_adapter extends API_V1_Abstract
$result = new API_V1_result($this->app, $request, $this);
$result->set_datas(
- [
+ array(
"collections" => $this->list_databox_collections(
$this->app['phraseanet.appbox']->get_databox($databox_id)
)
- ]
+ )
);
return $result;
@@ -542,12 +543,12 @@ class API_V1_adapter extends API_V1_Abstract
$result = new API_V1_result($this->app, $request, $this);
$result->set_datas(
- [
+ array(
"status" =>
$this->list_databox_status(
$this->app['phraseanet.appbox']->get_databox($databox_id)->get_statusbits()
)
- ]
+ )
);
return $result;
@@ -566,13 +567,13 @@ class API_V1_adapter extends API_V1_Abstract
$result = new API_V1_result($this->app, $request, $this);
$result->set_datas(
- [
+ array(
"document_metadatas" =>
$this->list_databox_metadatas_fields(
$this->app['phraseanet.appbox']->get_databox($databox_id)
->get_meta_structure()
)
- ]
+ )
);
return $result;
@@ -591,10 +592,10 @@ class API_V1_adapter extends API_V1_Abstract
$result = new API_V1_result($this->app, $request, $this);
$result->set_datas(
- [
+ array(
"termsOfUse" =>
$this->list_databox_terms($this->app['phraseanet.appbox']->get_databox($databox_id))
- ]
+ )
);
return $result;
@@ -607,14 +608,14 @@ class API_V1_adapter extends API_V1_Abstract
$record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id);
$fields = $record->get_caption()->get_fields();
- $ret = ['caption_metadatas' => []];
+ $ret = array('caption_metadatas' => array());
foreach ($fields as $field) {
- $ret['caption_metadatas'][] = [
+ $ret['caption_metadatas'][] = array(
'meta_structure_id' => $field->get_meta_struct_id(),
'name' => $field->get_name(),
'value' => $field->get_serialized_values(";"),
- ];
+ );
}
$result->set_datas($ret);
@@ -658,7 +659,7 @@ class API_V1_adapter extends API_V1_Abstract
}
$session = new Alchemy\Phrasea\Model\Entities\LazaretSession();
- $session->setUsrId($app['authentication']->getUser()->get_id());
+ $session->setUsrId($app['authentication']->getUser()->getId());
$app['EM']->persist($session);
$app['EM']->flush();
@@ -667,7 +668,7 @@ class API_V1_adapter extends API_V1_Abstract
$callback = function ($element, $visa, $code) use ($app, &$reasons, &$output) {
if (!$visa->isValid()) {
- $reasons = [];
+ $reasons = array();
foreach ($visa->getResponses() as $response) {
$reasons[] = $response->getMessage($app['translator']);
@@ -694,9 +695,9 @@ class API_V1_adapter extends API_V1_Abstract
$app['border-manager']->process($session, $Package, $callback, $behavior);
- $ret = [
+ $ret = array(
'entity' => null,
- ];
+ );
if ($output instanceof \record_adapter) {
$ret['entity'] = '0';
@@ -720,9 +721,9 @@ class API_V1_adapter extends API_V1_Abstract
$offset_start = max($request->get('offset_start', 0), 0);
$per_page = min(max($request->get('per_page', 10), 1), 20);
- $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['canaddrecord']));
+ $baseIds = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(array('canaddrecord')));
- $lazaretFiles = [];
+ $lazaretFiles = array();
if (count($baseIds) > 0) {
$lazaretRepository = $app['EM']->getRepository('Phraseanet:LazaretFile');
@@ -732,7 +733,7 @@ class API_V1_adapter extends API_V1_Abstract
);
}
- $ret = [];
+ $ret = array();
foreach ($lazaretFiles as $lazaretFile) {
$ret[] = $this->list_lazaret_file($lazaretFile);
@@ -740,11 +741,11 @@ class API_V1_adapter extends API_V1_Abstract
$result = new API_V1_result($this->app, $request, $this);
- $result->set_datas([
+ $result->set_datas(array(
'offset_start' => $offset_start,
'per_page' => $per_page,
'quarantine_items' => $ret,
- ]);
+ ));
return $result;
}
@@ -762,7 +763,7 @@ class API_V1_adapter extends API_V1_Abstract
throw new \API_V1_exception_forbidden('You do not have access to this quarantine item');
}
- $ret = ['quarantine_item' => $this->list_lazaret_file($lazaretFile)];
+ $ret = array('quarantine_item' => $this->list_lazaret_file($lazaretFile));
$result = new API_V1_result($this->app, $request, $this);
@@ -773,7 +774,7 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_lazaret_file(LazaretFile $file)
{
- $checks = [];
+ $checks = array();
if ($file->getChecks()) {
foreach ($file->getChecks() as $checker) {
@@ -784,15 +785,15 @@ class API_V1_adapter extends API_V1_Abstract
$usr_id = null;
if ($file->getSession()->getUser($this->app)) {
- $usr_id = $file->getSession()->getUser($this->app)->get_id();
+ $usr_id = $file->getSession()->getUser($this->app)->getId();
}
- $session = [
+ $session = array(
'id' => $file->getSession()->getId(),
'usr_id' => $usr_id,
- ];
+ );
- return [
+ return array(
'id' => $file->getId(),
'quarantine_session' => $session,
'base_id' => $file->getBaseId(),
@@ -800,10 +801,10 @@ class API_V1_adapter extends API_V1_Abstract
'sha256' => $file->getSha256(),
'uuid' => $file->getUuid(),
'forced' => $file->getForced(),
- 'checks' => $file->getForced() ? [] : $checks,
+ 'checks' => $file->getForced() ? array() : $checks,
'created_on' => $file->getCreated()->format(DATE_ATOM),
'updated_on' => $file->getUpdated()->format(DATE_ATOM),
- ];
+ );
}
/**
@@ -818,7 +819,7 @@ class API_V1_adapter extends API_V1_Abstract
list($ret, $search_result) = $this->prepare_search_request($request);
- $ret['results'] = ['records' => [], 'stories' => []];
+ $ret['results'] = array('records' => array(), 'stories' => array());
foreach ($search_result->getResults() as $record) {
if ($record->is_grouping()) {
@@ -876,7 +877,7 @@ class API_V1_adapter extends API_V1_Abstract
$search_result = $this->app['phraseanet.SE']->query($query, $offsetStart, $perPage, $options);
$userQuery = new UserQuery();
- $userQuery->setUsrId($this->app['authentication']->getUser()->get_id());
+ $userQuery->setUsrId($this->app['authentication']->getUser()->getId());
$userQuery->setQuery($query);
$this->app['EM']->persist($userQuery);
@@ -894,7 +895,7 @@ class API_V1_adapter extends API_V1_Abstract
$this->app['phraseanet.SE']->clearCache();
- $ret = [
+ $ret = array(
'offset_start' => $offsetStart,
'per_page' => $perPage,
'available_results' => $search_result->getAvailable(),
@@ -906,11 +907,11 @@ class API_V1_adapter extends API_V1_Abstract
'suggestions' => array_map(function (SearchEngineSuggestion $suggestion) {
return $suggestion->toArray();
}, $search_result->getSuggestions()->toArray()),
- 'results' => [],
+ 'results' => array(),
'query' => $search_result->getQuery(),
- ];
+ );
- return [$ret, $search_result];
+ return array($ret, $search_result);
}
/**
@@ -941,10 +942,10 @@ class API_V1_adapter extends API_V1_Abstract
return $that->list_story($story);
}, array_values($record->get_grouping_parents()->get_elements()));
- $result->set_datas([
+ $result->set_datas(array(
"baskets" => $baskets,
"stories" => $stories,
- ]);
+ ));
return $result;
}
@@ -965,9 +966,9 @@ class API_V1_adapter extends API_V1_Abstract
$record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id);
$result->set_datas(
- [
+ array(
"record_metadatas" => $this->list_record_caption($record->get_caption())
- ]
+ )
);
return $result;
@@ -991,13 +992,13 @@ class API_V1_adapter extends API_V1_Abstract
->get_record($record_id);
$result->set_datas(
- [
+ array(
"status" =>
$this->list_record_status(
$this->app['phraseanet.appbox']->get_databox($databox_id)
, $record->get_status()
)
- ]
+ )
);
return $result;
@@ -1019,10 +1020,10 @@ class API_V1_adapter extends API_V1_Abstract
$record = $this->app['phraseanet.appbox']->get_databox($databox_id)->get_record($record_id);
- $ret = [];
+ $ret = array();
- $devices = $request->get('devices', []);
- $mimes = $request->get('mimes', []);
+ $devices = $request->get('devices', array());
+ $mimes = $request->get('mimes', array());
foreach ($record->get_embedable_medias($devices, $mimes) as $media) {
if (null !== $embed = $this->list_embedable_media($media)) {
@@ -1030,7 +1031,7 @@ class API_V1_adapter extends API_V1_Abstract
}
}
- $result->set_datas(["embed" => $ret]);
+ $result->set_datas(array("embed" => $ret));
return $result;
}
@@ -1053,10 +1054,10 @@ class API_V1_adapter extends API_V1_Abstract
->get_databox($databox_id)
->get_record($record_id);
- $ret = [];
+ $ret = array();
- $devices = $request->get('devices', []);
- $mimes = $request->get('mimes', []);
+ $devices = $request->get('devices', array());
+ $mimes = $request->get('mimes', array());
foreach ($record->get_embedable_medias($devices, $mimes) as $media) {
if (null !== $embed = $this->list_embedable_media($media)) {
@@ -1064,7 +1065,7 @@ class API_V1_adapter extends API_V1_Abstract
}
}
- $result->set_datas(["embed" => $ret]);
+ $result->set_datas(array("embed" => $ret));
return $result;
}
@@ -1088,7 +1089,7 @@ class API_V1_adapter extends API_V1_Abstract
}
$record->set_metadatas($metadatas);
- $result->set_datas(["record_metadatas" => $this->list_record_caption($record->get_caption())]);
+ $result->set_datas(array("record_metadatas" => $this->list_record_caption($record->get_caption())));
} catch (Exception $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $this->app->trans('An error occured'));
}
@@ -1115,7 +1116,7 @@ class API_V1_adapter extends API_V1_Abstract
if ($n > 31 || $n < 4) {
throw new API_V1_exception_badrequest();
}
- if (!in_array($value, ['0', '1'])) {
+ if (!in_array($value, array('0', '1'))) {
throw new API_V1_exception_badrequest();
}
if (!isset($status_bits[$n])) {
@@ -1130,10 +1131,10 @@ class API_V1_adapter extends API_V1_Abstract
$this->app['phraseanet.SE']->updateRecord($record);
- $result->set_datas([
+ $result->set_datas(array(
"status" =>
$this->list_record_status($databox, $record->get_status())
- ]
+ )
);
} catch (Exception $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $this->app->trans('An error occured'));
@@ -1160,7 +1161,7 @@ class API_V1_adapter extends API_V1_Abstract
$collection = collection::get_from_base_id($this->app, $request->get('base_id'));
$record->move_to_collection($collection, $this->app['phraseanet.appbox']);
- $result->set_datas(["record" => $this->list_record($record)]);
+ $result->set_datas(array("record" => $this->list_record($record)));
} catch (Exception $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $e->getMessage());
}
@@ -1182,7 +1183,7 @@ class API_V1_adapter extends API_V1_Abstract
$databox = $this->app['phraseanet.appbox']->get_databox($databox_id);
try {
$record = $databox->get_record($record_id);
- $result->set_datas(['record' => $this->list_record($record)]);
+ $result->set_datas(array('record' => $this->list_record($record)));
} catch (NotFoundHttpException $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $this->app->trans('Record Not Found'));
} catch (Exception $e) {
@@ -1206,7 +1207,7 @@ class API_V1_adapter extends API_V1_Abstract
$databox = $this->app['phraseanet.appbox']->get_databox($databox_id);
try {
$story = $databox->get_record($story_id);
- $result->set_datas(['story' => $this->list_story($story)]);
+ $result->set_datas(array('story' => $this->list_story($story)));
} catch (NotFoundHttpException $e) {
$result->set_error_message(API_V1_result::ERROR_BAD_REQUEST, $this->app->trans('Story Not Found'));
} catch (Exception $e) {
@@ -1226,9 +1227,9 @@ class API_V1_adapter extends API_V1_Abstract
{
$result = new API_V1_result($this->app, $request, $this);
- $usr_id = $this->app['authentication']->getUser()->get_id();
+ $usr_id = $this->app['authentication']->getUser()->getId();
- $result->set_datas(['baskets' => $this->list_baskets($usr_id)]);
+ $result->set_datas(array('baskets' => $this->list_baskets($usr_id)));
return $result;
}
@@ -1246,7 +1247,7 @@ class API_V1_adapter extends API_V1_Abstract
$baskets = $repo->findActiveByUser($this->app['authentication']->getUser());
- $ret = [];
+ $ret = array();
foreach ($baskets as $basket) {
$ret[] = $this->list_basket($basket);
}
@@ -1277,7 +1278,7 @@ class API_V1_adapter extends API_V1_Abstract
$this->app['EM']->persist($Basket);
$this->app['EM']->flush();
- $result->set_datas(["basket" => $this->list_basket($Basket)]);
+ $result->set_datas(array("basket" => $this->list_basket($Basket)));
return $result;
}
@@ -1286,12 +1287,17 @@ class API_V1_adapter extends API_V1_Abstract
* Delete a basket
*
* @param Request $request
- * @param Basket $basket
+ * @param int $basket_id
* @return array
*/
- public function delete_basket(Request $request, Basket $basket)
+ public function delete_basket(Request $request, $basket_id)
{
- $this->app['EM']->remove($basket);
+ $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket');
+
+ /* @var $repository Alchemy\Phrasea\Model\Repositories\BasketRepository */
+
+ $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['authentication']->getUser(), true);
+ $this->app['EM']->remove($Basket);
$this->app['EM']->flush();
return $this->search_baskets($request);
@@ -1301,18 +1307,24 @@ class API_V1_adapter extends API_V1_Abstract
* Retrieve a basket
*
* @param Request $request
- * @param Basket $basket
+ * @param int $basket_id
* @return API_V1_result
*/
- public function get_basket(Request $request, Basket $basket)
+ public function get_basket(Request $request, $basket_id)
{
$result = new API_V1_result($this->app, $request, $this);
+ $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket');
+
+ /* @var $repository Alchemy\Phrasea\Model\Repositories\BasketRepository */
+
+ $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['authentication']->getUser(), false);
+
$result->set_datas(
- [
- "basket" => $this->list_basket($basket),
- "basket_elements" => $this->list_basket_content($basket)
- ]
+ array(
+ "basket" => $this->list_basket($Basket),
+ "basket_elements" => $this->list_basket_content($Basket)
+ )
);
return $result;
@@ -1326,7 +1338,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_basket_content(Basket $Basket)
{
- $ret = [];
+ $ret = array();
foreach ($Basket->getElements() as $basket_element) {
$ret[] = $this->list_basket_element($basket_element);
@@ -1343,15 +1355,15 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_basket_element(BasketElement $basket_element)
{
- $ret = [
+ $ret = array(
'basket_element_id' => $basket_element->getId(),
'order' => $basket_element->getOrd(),
'record' => $this->list_record($basket_element->getRecord($this->app)),
'validation_item' => null != $basket_element->getBasket()->getValidation(),
- ];
+ );
if ($basket_element->getBasket()->getValidation()) {
- $choices = [];
+ $choices = array();
$agreement = null;
$note = '';
@@ -1361,19 +1373,19 @@ class API_V1_adapter extends API_V1_Abstract
/* @var $validation_datas ValidationData */
$choices[] = [
'validation_user' => [
- 'usr_id' => $user->get_id(),
- 'usr_name' => $user->get_display_name(),
+ 'usr_id' => $user->getId(),
+ 'usr_name' => $user->getDisplayName(),
'confirmed' => $participant->getIsConfirmed(),
'can_agree' => $participant->getCanAgree(),
'can_see_others' => $participant->getCanSeeOthers(),
- 'readonly' => $user->get_id() != $this->app['authentication']->getUser()->get_id(),
+ 'readonly' => $user->getId() != $this->app['authentication']->getUser()->getId(),
],
'agreement' => $validation_datas->getAgreement(),
'updated_on' => $validation_datas->getUpdated()->format(DATE_ATOM),
'note' => null === $validation_datas->getNote() ? '' : $validation_datas->getNote(),
];
- if ($user->get_id() == $this->app['authentication']->getUser()->get_id()) {
+ if ($user->getId() == $this->app['authentication']->getUser()->getId()) {
$agreement = $validation_datas->getAgreement();
$note = null === $validation_datas->getNote() ? '' : $validation_datas->getNote();
}
@@ -1392,19 +1404,26 @@ class API_V1_adapter extends API_V1_Abstract
* Change the name of one basket
*
* @param Request $request
- * @param Basket $basket
+ * @param int $basket_id
* @return API_V1_result
*/
- public function set_basket_title(Request $request, Basket $basket)
+ public function set_basket_title(Request $request, $basket_id)
{
$result = new API_V1_result($this->app, $request, $this);
- $basket->setName($request->get('name'));
+ $name = $request->get('name');
- $this->app['EM']->persist($basket);
+ $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket');
+
+ /* @var $repository Alchemy\Phrasea\Model\Repositories\BasketRepository */
+
+ $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['authentication']->getUser(), true);
+ $Basket->setName($name);
+
+ $this->app['EM']->merge($Basket);
$this->app['EM']->flush();
- $result->set_datas(["basket" => $this->list_basket($basket)]);
+ $result->set_datas(array("basket" => $this->list_basket($Basket)));
return $result;
}
@@ -1413,19 +1432,26 @@ class API_V1_adapter extends API_V1_Abstract
* Change the description of one basket
*
* @param Request $request
- * @param Basket $basket
+ * @param type $basket_id
* @return API_V1_result
*/
- public function set_basket_description(Request $request, Basket $basket)
+ public function set_basket_description(Request $request, $basket_id)
{
$result = new API_V1_result($this->app, $request, $this);
- $basket->setDescription($request->get('description'));
+ $desc = $request->get('description');
- $this->app['EM']->persist($basket);
+ $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket');
+
+ /* @var $repository Alchemy\Phrasea\Model\Repositories\BasketRepository */
+
+ $Basket = $repository->findUserBasket($this->app, $basket_id, $this->app['authentication']->getUser(), true);
+ $Basket->setDescription($desc);
+
+ $this->app['EM']->merge($Basket);
$this->app['EM']->flush();
- $result->set_datas(["basket" => $this->list_basket($basket)]);
+ $result->set_datas(array("basket" => $this->list_basket($Basket)));
return $result;
}
@@ -1434,21 +1460,21 @@ class API_V1_adapter extends API_V1_Abstract
* List all avalaible feeds
*
* @param Request $request
- * @param User_Adapter $user
+ * @param User $user
* @return API_V1_result
*/
- public function search_publications(Request $request, User_Adapter $user)
+ public function search_publications(Request $request, User $user)
{
$result = new API_V1_result($this->app, $request, $this);
$coll = $this->app['EM']->getRepository('Phraseanet:Feed')->getAllForUser($this->app['acl']->get($user));
- $datas = [];
+ $datas = array();
foreach ($coll as $feed) {
$datas[] = $this->list_publication($feed, $user);
}
- $result->set_datas(["feeds" => $datas]);
+ $result->set_datas(array("feeds" => $datas));
return $result;
}
@@ -1467,35 +1493,35 @@ class API_V1_adapter extends API_V1_Abstract
*
* @param Request $request
* @param int $publication_id
- * @param User_Adapter $user
+ * @param User $user
* @return API_V1_result
*/
- public function get_publication(Request $request, $publication_id, User_Adapter $user)
+ public function get_publication(Request $request, $publication_id, User $user)
{
$result = new API_V1_result($this->app, $request, $this);
$feed = $this->app['EM']->getRepository('Phraseanet:Feed')->find($publication_id);
if (!$feed->isAccessible($user, $this->app)) {
- return $result->set_datas([]);
+ return $result->set_datas(array());
}
$offset_start = (int) ($request->get('offset_start') ? : 0);
$per_page = (int) ($request->get('per_page') ? : 5);
$per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5;
- $datas = [
+ $datas = array(
'feed' => $this->list_publication($feed, $user),
'offset_start' => $offset_start,
'per_page' => $per_page,
'entries' => $this->list_publications_entries($feed, $offset_start, $per_page),
- ];
+ );
$result->set_datas($datas);
return $result;
}
- public function get_publications(Request $request, User_Adapter $user)
+ public function get_publications(Request $request, User $user)
{
$result = new API_V1_result($this->app, $request, $this);
@@ -1506,19 +1532,19 @@ class API_V1_adapter extends API_V1_Abstract
$per_page = (($per_page >= 1) && ($per_page <= 20)) ? $per_page : 5;
- $datas = [
+ $datas = array(
'total_entries' => $feed->getCountTotalEntries(),
'offset_start' => $offset_start,
'per_page' => $per_page,
'entries' => $this->list_publications_entries($feed, $offset_start, $per_page),
- ];
+ );
$result->set_datas($datas);
return $result;
}
- public function get_feed_entry(Request $request, $entry_id, User_Adapter $user)
+ public function get_feed_entry(Request $request, $entry_id, User $user)
{
$result = new API_V1_result($this->app, $request, $this);
@@ -1530,9 +1556,9 @@ class API_V1_adapter extends API_V1_Abstract
throw new \API_V1_exception_forbidden('You have not access to the parent feed');
}
- $datas = [
+ $datas = array(
'entry' => $this->list_publication_entry($entry),
- ];
+ );
$result->set_datas($datas);
@@ -1548,7 +1574,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_publication(Feed $feed, $user)
{
- return [
+ return array(
'id' => $feed->getId(),
'title' => $feed->getTitle(),
'subtitle' => $feed->getSubtitle(),
@@ -1559,7 +1585,7 @@ class API_V1_adapter extends API_V1_Abstract
'deletable' => $feed->isOwner($user),
'created_on' => $feed->getCreatedOn()->format(DATE_ATOM),
'updated_on' => $feed->getUpdatedOn()->format(DATE_ATOM),
- ];
+ );
}
/**
@@ -1575,7 +1601,7 @@ class API_V1_adapter extends API_V1_Abstract
$entries = $feed->getEntries($offset_start, $how_many);
- $out = [];
+ $out = array();
foreach ($entries as $entry) {
$out[] = $this->list_publication_entry($entry);
}
@@ -1591,12 +1617,12 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_publication_entry(FeedEntry $entry)
{
- $items = [];
+ $items = array();
foreach ($entry->getItems() as $item) {
$items[] = $this->list_publication_entry_item($item);
}
- return [
+ return array(
'id' => $entry->getId(),
'author_email' => $entry->getAuthorEmail(),
'author_name' => $entry->getAuthorName(),
@@ -1608,7 +1634,7 @@ class API_V1_adapter extends API_V1_Abstract
'feed_id' => $entry->getFeed()->getId(),
'feed_url' => '/feeds/' . $entry->getFeed()->getId() . '/content/',
'url' => '/feeds/entry/' . $entry->getId() . '/',
- ];
+ );
}
/**
@@ -1619,10 +1645,10 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_publication_entry_item(FeedItem $item)
{
- $datas = [
+ $datas = array(
'item_id' => $item->getId()
, 'record' => $this->list_record($item->getRecord($this->app))
- ];
+ );
return $datas;
}
@@ -1672,7 +1698,7 @@ class API_V1_adapter extends API_V1_Abstract
$permalink = null;
}
- return [
+ return array(
'name' => $media->get_name(),
'permalink' => $permalink,
'height' => $media->get_height(),
@@ -1681,7 +1707,7 @@ class API_V1_adapter extends API_V1_Abstract
'devices' => $media->getDevices(),
'player_type' => $media->get_type(),
'mime_type' => $media->get_mime(),
- ];
+ );
}
/**
@@ -1693,7 +1719,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_permalink(media_Permalink_Adapter $permalink)
{
- return [
+ return array(
'created_on' => $permalink->get_created_on()->format(DATE_ATOM),
'id' => $permalink->get_id(),
'is_activated' => $permalink->get_is_activated(),
@@ -1703,7 +1729,7 @@ class API_V1_adapter extends API_V1_Abstract
'page_url' => $permalink->get_page(),
'download_url' => $permalink->get_url() . '&download',
'url' => $permalink->get_url()
- ];
+ );
}
/**
@@ -1716,9 +1742,9 @@ class API_V1_adapter extends API_V1_Abstract
protected function list_record_status(databox $databox, $status)
{
$status = strrev($status);
- $ret = [];
+ $ret = array();
foreach ($databox->get_statusbits() as $bit => $status_datas) {
- $ret[] = ['bit' => $bit, 'state' => !!substr($status, ($bit - 1), 1)];
+ $ret[] = array('bit' => $bit, 'state' => !!substr($status, ($bit - 1), 1));
}
return $ret;
@@ -1732,7 +1758,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_record_caption(caption_record $caption)
{
- $ret = [];
+ $ret = array();
foreach ($caption->get_fields() as $field) {
foreach ($field->get_values() as $value) {
$ret[] = $this->list_record_caption_field($value, $field);
@@ -1750,18 +1776,18 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_record_caption_field(caption_Field_Value $value, caption_field $field)
{
- return [
+ return array(
'meta_id' => $value->getId(),
'meta_structure_id' => $field->get_meta_struct_id(),
'name' => $field->get_name(),
- 'labels' => [
+ 'labels' => array(
'fr' => $field->get_databox_field()->get_label('fr'),
'en' => $field->get_databox_field()->get_label('en'),
'de' => $field->get_databox_field()->get_label('de'),
'nl' => $field->get_databox_field()->get_label('nl'),
- ],
+ ),
'value' => $value->getValue(),
- ];
+ );
}
/**
@@ -1772,7 +1798,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
public function list_basket(Basket $basket)
{
- $ret = [
+ $ret = array(
'basket_id' => $basket->getId(),
'created_on' => $basket->getCreated()->format(DATE_ATOM),
'description' => (string) $basket->getDescription(),
@@ -1781,23 +1807,23 @@ class API_V1_adapter extends API_V1_Abstract
'updated_on' => $basket->getUpdated()->format(DATE_ATOM),
'unread' => !$basket->getIsRead(),
'validation_basket' => !!$basket->getValidation()
- ];
+ );
if ($basket->getValidation()) {
- $users = [];
+ $users = array();
foreach ($basket->getValidation()->getParticipants() as $participant) {
/* @var $participant ValidationParticipant */
$user = $participant->getUser($this->app);
- $users[] = [
- 'usr_id' => $user->get_id(),
- 'usr_name' => $user->get_display_name(),
+ $users[] = array(
+ 'usr_id' => $user->getId(),
+ 'usr_name' => $user->getDisplayName(),
'confirmed' => $participant->getIsConfirmed(),
'can_agree' => $participant->getCanAgree(),
'can_see_others' => $participant->getCanSeeOthers(),
- 'readonly' => $user->get_id() != $this->app['authentication']->getUser()->get_id(),
- ];
+ 'readonly' => $user->getId() != $this->app['authentication']->getUser()->getId(),
+ );
}
$expires_on_atom = $basket->getValidation()->getExpires();
@@ -1807,13 +1833,13 @@ class API_V1_adapter extends API_V1_Abstract
}
$ret = array_merge(
- [
+ array(
'validation_users' => $users,
'expires_on' => $expires_on_atom,
'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['authentication']->getUser()),
'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['authentication']->getUser(), $this->app)->getIsConfirmed(),
'validation_initiator' => $basket->getValidation()->isInitiator($this->app['authentication']->getUser()),
- ], $ret
+ ), $ret
);
}
@@ -1828,15 +1854,15 @@ class API_V1_adapter extends API_V1_Abstract
*/
public function list_record(record_adapter $record)
{
- $technicalInformation = [];
+ $technicalInformation = array();
foreach ($record->get_technical_infos() as $name => $value) {
- $technicalInformation[] = [
+ $technicalInformation[] = array(
'name' => $name,
'value' => $value
- ];
+ );
}
- return [
+ return array(
'databox_id' => $record->get_sbas_id(),
'record_id' => $record->get_record_id(),
'mime_type' => $record->get_mime(),
@@ -1850,7 +1876,7 @@ class API_V1_adapter extends API_V1_Abstract
'technical_informations' => $technicalInformation,
'phrasea_type' => $record->get_type(),
'uuid' => $record->get_uuid(),
- ];
+ );
}
/**
@@ -1884,7 +1910,7 @@ class API_V1_adapter extends API_V1_Abstract
return $field->get_serialized_values();
};
- return [
+ return array(
'@entity@' => self::OBJECT_TYPE_STORY,
'databox_id' => $story->get_sbas_id(),
'story_id' => $story->get_record_id(),
@@ -1893,7 +1919,7 @@ class API_V1_adapter extends API_V1_Abstract
'collection_id' => phrasea::collFromBas($this->app, $story->get_base_id()),
'thumbnail' => $this->list_embedable_media($story->get_thumbnail()),
'uuid' => $story->get_uuid(),
- 'metadatas' => [
+ 'metadatas' => array(
'@entity@' => self::OBJECT_TYPE_STORY_METADATA_BAG,
'dc:contributor' => $format($caption, databox_Field_DCESAbstract::Contributor),
'dc:coverage' => $format($caption, databox_Field_DCESAbstract::Coverage),
@@ -1910,9 +1936,9 @@ class API_V1_adapter extends API_V1_Abstract
'dc:subject' => $format($caption, databox_Field_DCESAbstract::Subject),
'dc:title' => $format($caption, databox_Field_DCESAbstract::Title),
'dc:type' => $format($caption, databox_Field_DCESAbstract::Type),
- ],
+ ),
'records' => $records,
- ];
+ );
}
/**
@@ -1922,7 +1948,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_databoxes()
{
- $ret = [];
+ $ret = array();
foreach ($this->app['phraseanet.appbox']->get_databoxes() as $databox) {
$ret[] = $this->list_databox($databox);
}
@@ -1938,9 +1964,9 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_databox_terms(databox $databox)
{
- $ret = [];
+ $ret = array();
foreach ($databox->get_cgus() as $locale => $array_terms) {
- $ret[] = ['locale' => $locale, 'terms' => $array_terms['value']];
+ $ret[] = array('locale' => $locale, 'terms' => $array_terms['value']);
}
return $ret;
@@ -1953,17 +1979,17 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_databox(databox $databox)
{
- $ret = [];
+ $ret = array();
$ret['databox_id'] = $databox->get_sbas_id();
$ret['name'] = $databox->get_dbname();
$ret['viewname'] = $databox->get_viewname();
- $ret['labels'] = [
+ $ret['labels'] = array(
'en' => $databox->get_label('en'),
'de' => $databox->get_label('de'),
'fr' => $databox->get_label('fr'),
'nl' => $databox->get_label('nl'),
- ];
+ );
$ret['version'] = $databox->get_version();
return $ret;
@@ -1977,7 +2003,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_databox_collections(databox $databox)
{
- $ret = [];
+ $ret = array();
foreach ($databox->get_collections() as $collection) {
$ret[] = $this->list_collection($collection);
@@ -1994,18 +2020,18 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_collection(collection $collection)
{
- $ret = [
+ $ret = array(
'base_id' => $collection->get_base_id(),
'collection_id' => $collection->get_coll_id(),
'name' => $collection->get_name(),
- 'labels' => [
+ 'labels' => array(
'fr' => $collection->get_label('fr'),
'en' => $collection->get_label('en'),
'de' => $collection->get_label('de'),
'nl' => $collection->get_label('nl'),
- ],
+ ),
'record_amount' => $collection->get_record_amount(),
- ];
+ );
return $ret;
}
@@ -2018,23 +2044,23 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_databox_status(array $status)
{
- $ret = [];
+ $ret = array();
foreach ($status as $n => $datas) {
- $ret[] = [
+ $ret[] = array(
'bit' => $n,
'label_on' => $datas['labelon'],
'label_off' => $datas['labeloff'],
- 'labels' => [
+ 'labels' => array(
'en' => $datas['labels_on_i18n']['en'],
'fr' => $datas['labels_on_i18n']['fr'],
'de' => $datas['labels_on_i18n']['de'],
'nl' => $datas['labels_on_i18n']['nl'],
- ],
+ ),
'img_on' => $datas['img_on'],
'img_off' => $datas['img_off'],
'searchable' => !!$datas['searchable'],
'printable' => !!$datas['printable'],
- ];
+ );
}
return $ret;
@@ -2048,7 +2074,7 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_databox_metadatas_fields(databox_descriptionStructure $meta_struct)
{
- $ret = [];
+ $ret = array();
foreach ($meta_struct as $meta) {
$ret[] = $this->list_databox_metadata_field_properties($meta);
}
@@ -2064,18 +2090,18 @@ class API_V1_adapter extends API_V1_Abstract
*/
protected function list_databox_metadata_field_properties(databox_field $databox_field)
{
- $ret = [
+ $ret = array(
'id' => $databox_field->get_id(),
'namespace' => $databox_field->get_tag()->getGroupName(),
'source' => $databox_field->get_tag()->getTagname(),
'tagname' => $databox_field->get_tag()->getName(),
'name' => $databox_field->get_name(),
- 'labels' => [
+ 'labels' => array(
'fr' => $databox_field->get_label('fr'),
'en' => $databox_field->get_label('en'),
'de' => $databox_field->get_label('de'),
'nl' => $databox_field->get_label('nl'),
- ],
+ ),
'separator' => $databox_field->get_separator(),
'thesaurus_branch' => $databox_field->get_tbranch(),
'type' => $databox_field->get_type(),
@@ -2083,7 +2109,7 @@ class API_V1_adapter extends API_V1_Abstract
'multivalue' => $databox_field->is_multi(),
'readonly' => $databox_field->is_readonly(),
'required' => $databox_field->is_required(),
- ];
+ );
return $ret;
}
diff --git a/lib/classes/Bridge/Account.php b/lib/classes/Bridge/Account.php
index e4110f7a15..26fb3a3e71 100644
--- a/lib/classes/Bridge/Account.php
+++ b/lib/classes/Bridge/Account.php
@@ -10,6 +10,7 @@
*/
use Alchemy\Phrasea\Application;
+use Alchemy\Phrasea\Model\Entities\User;
class Bridge_Account
{
@@ -39,7 +40,7 @@ class Bridge_Account
/**
*
- * @var User_Adapter
+ * @var User
*/
protected $user;
@@ -86,7 +87,7 @@ class Bridge_Account
FROM bridge_accounts WHERE id = :id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':id' => $this->id]);
+ $stmt->execute(array(':id' => $this->id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -94,7 +95,7 @@ class Bridge_Account
throw new Bridge_Exception_AccountNotFound('Account Not Found');
$this->dist_id = $row['dist_id'];
- $this->user = User_Adapter::getInstance($row['usr_id'], $this->app);
+ $this->user = $this->app['manipulator.user']->getRepository()->find($row['usr_id']);
$this->name = $row['name'];
$this->updated_on = new DateTime($row['updated_on']);
$this->created_on = new DateTime($row['created_on']);
@@ -143,7 +144,7 @@ class Bridge_Account
/**
*
- * @return User_Adapter
+ * @return User
*/
public function get_user()
{
@@ -190,11 +191,11 @@ class Bridge_Account
$sql = 'UPDATE bridge_accounts
SET name = :name, updated_on = :update WHERE id = :id';
- $params = [
+ $params = array(
':name' => $this->name
, ':id' => $this->id
, ':update' => $this->updated_on->format(DATE_ISO8601)
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -219,7 +220,7 @@ class Bridge_Account
$sql = 'DELETE FROM bridge_accounts WHERE id = :id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':id' => $this->id]);
+ $stmt->execute(array(':id' => $this->id));
$stmt->closeCursor();
return;
@@ -236,7 +237,7 @@ class Bridge_Account
$sql = 'SELECT id, api_id FROM bridge_accounts WHERE id = :account_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':account_id' => $account_id]);
+ $stmt->execute(array(':account_id' => $account_id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -253,20 +254,20 @@ class Bridge_Account
*
* @param Application $app
* @param Bridge_Api $api
- * @param User_Adapter $user
+ * @param User $user
* @param string $distant_id
* @return Bridge_Account
*/
- public static function load_account_from_distant_id(Application $app, Bridge_Api $api, User_Adapter $user, $distant_id)
+ public static function load_account_from_distant_id(Application $app, Bridge_Api $api, User $user, $distant_id)
{
$sql = 'SELECT id FROM bridge_accounts
WHERE api_id = :api_id AND usr_id = :usr_id AND dist_id = :dist_id';
- $params = [
+ $params = array(
':api_id' => $api->get_id()
- , ':usr_id' => $user->get_id()
+ , ':usr_id' => $user->getId()
, ':dist_id' => $distant_id
- ];
+ );
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -292,11 +293,11 @@ class Bridge_Account
LIMIT 0,' . (int) $quantity;
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':api_id' => $api->get_id()]);
+ $stmt->execute(array(':api_id' => $api->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $results = [];
+ $results = array();
foreach ($rs as $row) {
$results[] = new Bridge_Account($app, $api, $row['id']);
@@ -308,20 +309,20 @@ class Bridge_Account
/**
*
* @param Application $app
- * @param user_adapter $user
+ * @param User $user
* @return Bridge_Account
*/
- public static function get_accounts_by_user(Application $app, user_adapter $user)
+ public static function get_accounts_by_user(Application $app, User $user)
{
$sql = 'SELECT id, api_id FROM bridge_accounts WHERE usr_id = :usr_id';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $user->get_id()]);
+ $stmt->execute(array(':usr_id' => $user->getId()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $results = [];
- $apis = [];
+ $results = array();
+ $apis = array();
foreach ($rs as $row) {
$api_id = $row['api_id'];
@@ -342,24 +343,24 @@ class Bridge_Account
*
* @param Application $app
* @param Bridge_Api $api
- * @param User_Adapter $user
+ * @param User $user
* @param string $dist_id
* @param string $name
*
* @return Bridge_Account
*/
- public static function create(Application $app, Bridge_Api $api, User_Adapter $user, $dist_id, $name)
+ public static function create(Application $app, Bridge_Api $api, User $user, $dist_id, $name)
{
$sql = 'INSERT INTO bridge_accounts
(id, api_id, dist_id, usr_id, name, created_on, updated_on)
VALUES (null, :api_id, :dist_id, :usr_id, :name, NOW(), NOW())';
- $params = [
+ $params = array(
':api_id' => $api->get_id()
, ':dist_id' => $dist_id
- , ':usr_id' => $user->get_id()
+ , ':usr_id' => $user->getId()
, ':name' => $name
- ];
+ );
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
diff --git a/lib/classes/Session/Logger.php b/lib/classes/Session/Logger.php
index 37884fb8ce..52cc7dfb5a 100644
--- a/lib/classes/Session/Logger.php
+++ b/lib/classes/Session/Logger.php
@@ -96,10 +96,10 @@ class Session_Logger
*/
public static function create(Application $app, databox $databox, Browser $browser)
{
- $colls = [];
+ $colls = array();
if ($app['authentication']->getUser()) {
- $bases = $app['acl']->get($app['authentication']->getUser())->get_granted_base([], [$databox->get_sbas_id()]);
+ $bases = $app['acl']->get($app['authentication']->getUser())->get_granted_base(array(), array($databox->get_sbas_id()));
foreach ($bases as $collection) {
$colls[] = $collection->get_coll_id();
}
@@ -116,23 +116,23 @@ class Session_Logger
, :browser, :browser_version, :platform, :screen, :ip
, :user_agent, :appli, :fonction, :company, :activity, :country)";
- $params = [
+ $params = array(
':ses_id' => $app['session']->get('session_id'),
- ':usr_login' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_login() : null,
+ ':usr_login' => $app['authentication']->getUser() ? $app['authentication']->getUser()->getLogin() : null,
':site_id' => $app['conf']->get(['main', 'key']),
- ':usr_id' => $app['authentication']->isAuthenticated() ? $app['authentication']->getUser()->get_id() : null,
+ ':usr_id' => $app['authentication']->isAuthenticated() ? $app['authentication']->getUser()->getId() : null,
':browser' => $browser->getBrowser(),
':browser_version' => $browser->getExtendedVersion(),
':platform' => $browser->getPlatform(),
':screen' => $browser->getScreenSize(),
':ip' => $browser->getIP(),
':user_agent' => $browser->getUserAgent(),
- ':appli' => serialize([]),
- ':fonction' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_job() : null,
- ':company' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_company() : null,
- ':activity' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_position() : null,
- ':country' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_country() : null
- ];
+ ':appli' => serialize(array()),
+ ':fonction' => $app['authentication']->getUser() ? $app['authentication']->getUser()->getJob() : null,
+ ':company' => $app['authentication']->getUser() ? $app['authentication']->getUser()->getCompany() : null,
+ ':activity' => $app['authentication']->getUser() ? $app['authentication']->getUser()->getActivity() : null,
+ ':country' => $app['authentication']->getUser() ? $app['authentication']->getUser()->getCountry() : null
+ );
$stmt = $conn->prepare($sql);
$stmt->execute($params);
@@ -143,10 +143,10 @@ class Session_Logger
$stmt = $conn->prepare($sql);
foreach ($colls as $collId) {
- $stmt->execute([
+ $stmt->execute(array(
':log_id' => $log_id,
':coll_id' => $collId
- ]);
+ ));
}
$stmt->closeCursor();
@@ -165,7 +165,7 @@ class Session_Logger
WHERE site = :site AND sit_session = :ses_id';
$params = [
- ':site' => $app['conf']->get(['main', 'key'])
+ ':site' => $app['conf']->get(['main', 'key']),
, ':ses_id' => $app['session']->get('session_id')
];
@@ -205,11 +205,7 @@ class Session_Logger
$app['EM']->flush();
}
- $usrId = $app['authentication']->getUser()->get_id();
-
- $user = User_Adapter::getInstance($usrId, $app);
-
- $appName = [
+ $appName = array(
'1' => 'Prod',
'2' => 'Client',
'3' => 'Admin',
@@ -219,10 +215,10 @@ class Session_Logger
'7' => 'Validate',
'8' => 'Upload',
'9' => 'API'
- ];
+ );
if (isset($appName[$appId])) {
- $sbas_ids = array_keys($app['acl']->get($user)->get_granted_sbas());
+ $sbas_ids = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_sbas());
foreach ($sbas_ids as $sbas_id) {
try {
@@ -231,7 +227,7 @@ class Session_Logger
$connbas = connection::getPDOConnection($app, $sbas_id);
$sql = 'SELECT appli FROM log WHERE id = :log_id';
$stmt = $connbas->prepare($sql);
- $stmt->execute([':log_id' => $logger->get_id()]);
+ $stmt->execute(array(':log_id' => $logger->get_id()));
$row3 = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -245,10 +241,10 @@ class Session_Logger
$sql = 'UPDATE log SET appli = :applis WHERE id = :log_id';
- $params = [
+ $params = array(
':applis' => serialize($applis)
, ':log_id' => $logger->get_id()
- ];
+ );
$stmt = $connbas->prepare($sql);
$stmt->execute($params);
diff --git a/lib/classes/User/Adapter.php b/lib/classes/User/Adapter.php
index 4e53b6184d..aa63baf613 100644
--- a/lib/classes/User/Adapter.php
+++ b/lib/classes/User/Adapter.php
@@ -39,13 +39,13 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
*
* @var array
*/
- protected static $_instance = [];
+ protected static $_instance = array();
/**
*
* @var array
*/
- protected $_prefs = [];
+ protected $_prefs = array();
/**
*
@@ -57,14 +57,14 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
*
* @var array
*/
- public static $def_values = [
+ public static $def_values = array(
'view' => 'thumbs',
'images_per_page' => 20,
'images_size' => 120,
'editing_images_size' => 134,
- 'editing_top_box' => 30,
- 'editing_right_box' => 48,
- 'editing_left_box' => 33,
+ 'editing_top_box' => '180px',
+ 'editing_right_box' => '400px',
+ 'editing_left_box' => '710px',
'basket_sort_field' => 'name',
'basket_sort_order' => 'ASC',
'warning_on_delete_story' => 'true',
@@ -80,21 +80,21 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
'basket_caption_display' => '0',
'basket_status_display' => '0',
'basket_title_display' => '0'
- ];
+ );
/**
*
* @var array
*/
- protected static $available_values = [
- 'view' => ['thumbs', 'list'],
- 'basket_sort_field' => ['name', 'date'],
- 'basket_sort_order' => ['ASC', 'DESC'],
- 'start_page' => ['PUBLI', 'QUERY', 'LAST_QUERY', 'HELP'],
- 'technical_display' => ['0', '1', 'group'],
- 'rollover_thumbnail' => ['caption', 'preview'],
- 'bask_val_order' => ['nat', 'asc', 'desc']
- ];
+ protected static $available_values = array(
+ 'view' => array('thumbs', 'list'),
+ 'basket_sort_field' => array('name', 'date'),
+ 'basket_sort_order' => array('ASC', 'DESC'),
+ 'start_page' => array('PUBLI', 'QUERY', 'LAST_QUERY', 'HELP'),
+ 'technical_display' => array('0', '1', 'group'),
+ 'rollover_thumbnail' => array('caption', 'preview'),
+ 'bask_val_order' => array('nat', 'asc', 'desc')
+ );
/**
*
@@ -326,18 +326,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return array_key_exists($id, self::$_instance) ? self::$_instance[$id] : false;
}
- /**
- *
- * @param Application $app
- */
- protected function set_app(Application $app)
- {
- $this->app = $app;
- if (null !== $app['acl']->get($this)) {
- $app['acl']->get($this)->set_app($app);
- }
- }
-
/**
*
* @param type $pasword
@@ -351,7 +339,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$password = $this->app['auth.password-encoder']->encodePassword($pasword, $this->get_nonce());
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':password' => $password, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':password' => $password, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->password = $password;
@@ -378,7 +366,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$sql = 'UPDATE usr SET usr_mail = :new_email WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':new_email' => $email, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':new_email' => $email, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->email = $email;
$this->delete_data_from_cache();
@@ -386,50 +374,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this;
}
- /**
- *
- * @return string
- */
- public function get_country()
- {
- if ($this->geonameid) {
- try {
- $country = $this->app['geonames.connector']
- ->geoname($this->geonameid)
- ->get('country');
-
- if (isset($country['name'])) {
- return $country['name'];
- }
- } catch (GeonamesExceptionInterface $e) {
-
- }
- }
-
- return '';
- }
-
- /**
- *
- * @param Application $app
- * @param string $login
- *
- * @return integer
- */
- public static function get_usr_id_from_login(Application $app, $login)
- {
- $conn = connection::getPDOConnection($app);
- $sql = 'SELECT usr_id FROM usr WHERE usr_login = :login';
- $stmt = $conn->prepare($sql);
- $stmt->execute([':login' => trim($login)]);
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $stmt->closeCursor();
-
- $usr_id = $row ? (int) $row['usr_id'] : false;
-
- return $usr_id;
- }
-
/**
*
* @param bollean $boolean
@@ -440,7 +384,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$value = $boolean ? '1' : '0';
$sql = 'UPDATE usr SET mail_notifications = :mail_notifications WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':mail_notifications' => $value, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':mail_notifications' => $value, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->mail_notifications = !!$boolean;
$this->delete_data_from_cache();
@@ -458,7 +402,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$value = $boolean ? '1' : '0';
$sql = 'UPDATE usr SET ldap_created = :ldap_created WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':ldap_created' => $value, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':ldap_created' => $value, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->ldap_created = $boolean;
@@ -469,7 +413,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET usr_prenom = :usr_prenom WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_prenom' => $firstname, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':usr_prenom' => $firstname, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->firstname = $firstname;
$this->delete_data_from_cache();
@@ -481,7 +425,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET usr_nom = :usr_nom WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_nom' => $lastname, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':usr_nom' => $lastname, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->lastname = $lastname;
$this->delete_data_from_cache();
@@ -493,7 +437,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET adresse = :adresse WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':adresse' => $address, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':adresse' => $address, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->address = $address;
$this->delete_data_from_cache();
@@ -505,7 +449,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET ville = :city WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':city' => $city, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':city' => $city, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->city = $city;
$this->delete_data_from_cache();
@@ -531,11 +475,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$sql = 'UPDATE usr SET geonameid = :geonameid, pays=:country_code WHERE usr_id = :usr_id';
- $datas = [
+ $datas = array(
':geonameid' => $geonameid,
':usr_id' => $this->get_id(),
':country_code' => $country_code
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($datas);
@@ -551,7 +495,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET cpostal = :cpostal WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':cpostal' => $zip, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':cpostal' => $zip, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->zip = $zip;
$this->delete_data_from_cache();
@@ -563,7 +507,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET usr_sexe = :usr_sexe WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_sexe' => $gender, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':usr_sexe' => $gender, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->gender = $gender;
$this->delete_data_from_cache();
@@ -575,7 +519,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET tel = :tel WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':tel' => $tel, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':tel' => $tel, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->tel = $tel;
$this->delete_data_from_cache();
@@ -587,7 +531,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET fax = :fax WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':fax' => $fax, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':fax' => $fax, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->fax = $fax;
$this->delete_data_from_cache();
@@ -599,7 +543,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET fonction = :fonction WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':fonction' => $job, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':fonction' => $job, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->job = $job;
$this->delete_data_from_cache();
@@ -611,7 +555,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET activite = :activite WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':activite' => $position, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':activite' => $position, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->position = $position;
$this->delete_data_from_cache();
@@ -623,7 +567,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET societe = :company WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':company' => $company, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':company' => $company, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->company = $company;
$this->delete_data_from_cache();
@@ -641,7 +585,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$sql = 'UPDATE usr SET model_of = :owner_id WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':owner_id' => $owner->get_id(), ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this
@@ -669,62 +613,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this;
}
-
- /**
- * @return FtpCredential
- */
- public function getFtpCredential()
- {
- if (null === $this->ftpCredential) {
- $this->ftpCredential = $this->app['EM']->getRepository('Phraseanet:FtpCredential')->findOneBy([
- 'usrId' => $this->get_id()
- ]);
-
- if (null === $this->ftpCredential) {
- $this->ftpCredential = new FtpCredential();
- $this->ftpCredential->setUsrId($this->get_id());
- }
- }
-
- return $this->ftpCredential;
- }
-
- public function is_template()
- {
- return $this->is_template;
- }
-
- public function is_special()
- {
- return in_array($this->login, ['invite', 'autoregister']);
- }
-
- public function get_template_owner()
- {
- return $this->template_owner;
- }
-
- public static function get_usr_id_from_email(Application $app, $email)
- {
- if (is_null($email)) {
- return false;
- }
-
- $conn = connection::getPDOConnection($app);
- $sql = 'SELECT usr_id FROM usr
- WHERE usr_mail = :email
- AND usr_login NOT LIKE "(#deleted_%"
- AND invite="0" AND usr_login != "autoregister"';
- $stmt = $conn->prepare($sql);
- $stmt->execute([':email' => trim($email)]);
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $stmt->closeCursor();
-
- $usr_id = $row ? $row['usr_id'] : false;
-
- return $usr_id;
- }
-
/**
* @todo close all open session
* @return type
@@ -757,37 +645,37 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$sql = 'UPDATE usr SET usr_login = :usr_login , usr_mail = null
WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_login' => '(#deleted_' . $this->get_login() . '_' . $this->get_id(), ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':usr_login' => '(#deleted_' . $this->get_login() . '_' . $this->get_id(), ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$sql = 'DELETE FROM basusr WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->get_id()));
$stmt->closeCursor();
$sql = 'DELETE FROM sbasusr WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->get_id()));
$stmt->closeCursor();
$sql = 'DELETE FROM dsel WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->get_id()));
$stmt->closeCursor();
$sql = 'DELETE FROM edit_presets WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->get_id()));
$stmt->closeCursor();
$sql = 'DELETE FROM tokens WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->get_id()));
$stmt->closeCursor();
$sql = 'DELETE FROM usr_settings WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->get_id()));
$stmt->closeCursor();
unset(self::$_instance[$this->get_id()]);
@@ -813,7 +701,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
FROM usr WHERE usr_id= :id ';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':id' => $id]);
+ $stmt->execute(array(':id' => $id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -866,10 +754,10 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET lastModel = :template_id WHERE usr_id = :usr_id';
- $params = [
+ $params = array(
':usr_id' => $this->get_id()
, ':template_id' => $template->get_login()
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -883,207 +771,13 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{
$sql = 'UPDATE usr SET mail_locked = :mail_locked WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->get_id(), ':mail_locked' => ($boolean ? '1' : '0')]);
+ $stmt->execute(array(':usr_id' => $this->get_id(), ':mail_locked' => ($boolean ? '1' : '0')));
$stmt->closeCursor();
$this->mail_locked = !!$boolean;
return $this;
}
- public function get_mail_locked()
- {
- return $this->mail_locked;
- }
-
- /**
- *
- * @return int
- */
- public function get_id()
- {
- return $this->id;
- }
-
- public function get_ldap_created()
- {
- return $this->ldap_created;
- }
-
- public function is_guest()
- {
- return $this->is_guest;
- }
-
- public function get_login()
- {
- return $this->login;
- }
-
- public function get_password()
- {
- return $this->password;
- }
-
- public function get_email()
- {
- return $this->email;
- }
-
- public function get_firstname()
- {
- return $this->firstname;
- }
-
- public function get_lastname()
- {
- return $this->lastname;
- }
-
- public function get_company()
- {
- return $this->company;
- }
-
- public function get_tel()
- {
- return $this->tel;
- }
-
- public function get_fax()
- {
- return $this->fax;
- }
-
- public function get_job()
- {
- return $this->job;
- }
-
- public function get_position()
- {
- return $this->position;
- }
-
- public function get_zipcode()
- {
- return $this->zip;
- }
-
- public function get_city()
- {
- return $this->city;
- }
-
- public function get_address()
- {
- return $this->address;
- }
-
- public function get_gender()
- {
- return $this->gender;
- }
-
- public function get_geonameid()
- {
- return $this->geonameid;
- }
-
- public function get_last_connection()
- {
- $sql = 'SELECT last_conn FROM usr WHERE usr_id = :usr_id';
-
- $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
-
- $stmt->execute([':usr_id' => $this->get_id()]);
-
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
-
- $stmt->closeCursor();
-
- $date_obj = new DateTime($row['last_conn']);
-
- return $date_obj;
- }
-
- public function get_applied_template()
- {
- return $this->applied_template;
- }
-
- public function get_creation_date()
- {
- return $this->creationdate;
- }
-
- public function get_modification_date()
- {
- return $this->modificationdate;
- }
-
- protected function load_preferences()
- {
- if ($this->preferences_loaded) {
- return $this;
- }
-
- foreach (self::$def_values as $k => $v) {
- if (!isset($this->_prefs[$k])) {
- if ($k == 'start_page_query' && $this->app['conf']->get(['registry', 'searchengine', 'default-query'])) {
- $v = $this->app['conf']->get(['registry', 'searchengine', 'default-query']);
- }
-
- $this->_prefs[$k] = $v;
- }
- }
-
- if ($this->app['conf']->has('user-settings')) {
- $this->_prefs = array_replace(
- $this->_prefs,
- // remove keys that are not defined in default values
- array_intersect_key(
- $this->app['conf']->get('user-settings'),
- self::$def_values
- )
- );
- }
-
- $sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id';
- $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':id' => $this->id]);
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
- $stmt->closeCursor();
-
- foreach ($rs as $row) {
- $this->_prefs[$row['prop']] = $row['value'];
- }
-
- $this->preferences_loaded = true;
-
- return $this;
- }
-
- public function purgePreferences()
- {
- $this->notifications_preferences_loaded = $this->preferences_loaded = false;
- }
-
- protected function load_notifications_preferences(Application $app)
- {
- $this->load_preferences();
-
- $notifications = $app['events-manager']->list_notifications_available($this->id);
-
- foreach ($notifications as $notification_group => $nots) {
- foreach ($nots as $notification) {
- if (!isset($this->_prefs['notification_' . $notification['id']])) {
- $this->_prefs['notification_' . $notification['id']] = '1';
- }
- }
- }
- $this->notifications_preferences_loaded = true;
- }
-
public function get_notifications_preference(Application $app, $notification_id)
{
if (!$this->notifications_preferences_loaded)
@@ -1105,40 +799,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return ;
}
- public function get_display_name()
- {
- if ($this->is_template())
- $display_name = $this->app->trans('modele %name%', ['%name%' => $this->get_login()]);
- elseif (trim($this->lastname) !== '' || trim($this->firstname) !== '')
- $display_name = $this->firstname . ' ' . $this->lastname;
- elseif (trim($this->email) !== '')
- $display_name = $this->email;
- else
- $display_name = $this->app->trans('phraseanet::utilisateur inconnu');
-
- return $display_name;
- }
-
- protected function update_pref($prop, $value)
- {
- try {
- $sql = 'REPLACE INTO usr_settings (usr_id, prop, value)
- VALUES (:usr_id, :prop, :value)';
-
- $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([
- ':usr_id' => $this->id,
- ':prop' => $prop,
- ':value' => $value
- ]);
- $this->delete_data_from_cache();
- } catch (Exception $e) {
-
- }
-
- return $this;
- }
-
public function get_cache_key($option = null)
{
return '_user_' . $this->get_id() . ($option ? '_' . $option : '');
@@ -1195,32 +855,12 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return array_key_exists($prop, $this->_prefs) ? $this->_prefs[$prop] : $default;
}
- public static function get_sys_admins(Application $app)
- {
- $sql = 'SELECT usr_id, usr_login FROM usr
- WHERE create_db="1"
- AND model_of="0"
- AND usr_login NOT LIKE "(#deleted%"';
- $conn = connection::getPDOConnection($app);
- $stmt = $conn->prepare($sql);
- $stmt->execute();
- $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
- $stmt->closeCursor();
-
- $users = [];
-
- foreach ($rs as $row)
- $users[$row['usr_id']] = $row['usr_login'];
-
- return $users;
- }
-
public static function set_sys_admins(Application $app, $admins)
{
try {
$sql = "UPDATE usr SET create_db='0' WHERE create_db='1' AND usr_id != :usr_id";
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $app['authentication']->getUser()->get_id()]);
+ $stmt->execute(array(':usr_id' => $app['authentication']->getUser()->get_id()));
$stmt->closeCursor();
$sql = "UPDATE usr SET create_db='1' WHERE usr_id IN (" . implode(',', $admins) . ")";
@@ -1249,7 +889,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$sql = 'UPDATE usr SET locale = :locale WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':locale' => $locale, ':usr_id' => $this->get_id()]);
+ $stmt->execute(array(':locale' => $locale, ':usr_id' => $this->get_id()));
$stmt->closeCursor();
$this->delete_data_from_cache();
@@ -1258,88 +898,11 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
return $this->locale;
}
- public static function create(Application $app, $login, $password, $email, $admin, $invite = false)
- {
- $conn = $app['phraseanet.appbox']->get_connection();
-
- if (trim($login) == '') {
- throw new \InvalidArgumentException('Invalid username');
- }
-
- if (strlen($login) > 100) {
- throw new \InvalidArgumentException('Username is too long');
- }
-
- if (trim($password) == '') {
- throw new \InvalidArgumentException('Invalid password');
- }
-
- $login = $invite ? 'invite' . random::generatePassword(16) : $login;
-
- $nonce = random::generatePassword(16);
-
- $sql = 'INSERT INTO usr
- (usr_id, usr_login, usr_password, usr_creationdate, usr_mail, create_db, nonce, salted_password, invite)
- VALUES (null, :login, :password, NOW(), :email, :admin, :nonce, 1, :invite)';
-
- $stmt = $conn->prepare($sql);
- $stmt->execute([
- ':login' => $login,
- ':nonce' => $nonce,
- ':password' => $app['auth.password-encoder']->encodePassword($password, $nonce),
- ':email' => ($email ? $email : null),
- ':admin' => ($admin ? '1' : '0'),
- ':invite' => ($invite ? '1' : '0')
- ]);
- $stmt->closeCursor();
-
- $usr_id = $conn->lastInsertId();
-
- $ftpCredential = new FtpCredential();
- $ftpCredential->setUsrId($usr_id);
- $app['EM']->persist($ftpCredential);
- $app['EM']->flush();
-
- if ($invite) {
- $sql = 'UPDATE usr SET usr_login = :login
- WHERE usr_id = :usr_id';
- $stmt = $conn->prepare($sql);
- $stmt->execute([':login' => 'invite'.$usr_id, ':usr_id' => $usr_id]);
- $stmt->closeCursor();
- }
-
- return self::getInstance($usr_id, $app);
- }
-
- protected $nonce;
-
- public function get_nonce()
- {
- if ($this->nonce) {
- return $this->nonce;
- }
-
- $nonce = false;
-
- $sql = 'SELECT nonce FROM usr WHERE usr_id = :usr_id ';
- $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->get_id()]);
- $row = $stmt->fetch(PDO::FETCH_ASSOC);
- $stmt->closeCursor();
- unset($stmt);
-
- $nonce = $row['nonce'];
-
- $this->nonce = $nonce;
-
- return $this->nonce;
- }
-
public function __sleep()
{
- $vars = [];
+ $vars = array();
foreach ($this as $key => $value) {
- if (in_array($key, ['ACL', 'app']))
+ if (in_array($key, array('ACL', 'app')))
continue;
$vars[] = $key;
}
diff --git a/lib/classes/User/Query.php b/lib/classes/User/Query.php
index 4e36dc518b..5999e6ea9f 100644
--- a/lib/classes/User/Query.php
+++ b/lib/classes/User/Query.php
@@ -10,6 +10,7 @@
*/
use Alchemy\Phrasea\Application;
+use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\Common\Collections\ArrayCollection;
class User_Query implements User_QueryInterface
@@ -231,11 +232,11 @@ class User_Query implements User_QueryInterface
if (!$this->app['authentication']->getUser()) {
throw new InvalidArgumentException('Unable to load templates while disconnected');
}
- $sql .= ' AND model_of = ' . $this->app['authentication']->getUser()->get_id();
+ $sql .= ' AND model_of = ' . $this->app['authentication']->getUser()->getId();
} elseif ($this->include_templates === false) {
$sql .= ' AND model_of=0';
} elseif ($this->app['authentication']->getUser()) {
- $sql .= ' AND (model_of=0 OR model_of = ' . $this->app['authentication']->getUser()->get_id() . ' ) ';
+ $sql .= ' AND (model_of=0 OR model_of = ' . $this->app['authentication']->getUser()->getId() . ' ) ';
} else {
$sql .= ' AND model_of=0';
}
@@ -396,7 +397,7 @@ class User_Query implements User_QueryInterface
public function last_model_is($login = null)
{
- $this->last_model = $login instanceof \User_Adapter ? $login->get_login() : $login;
+ $this->last_model = $login instanceof User ? $login->getLogin() : $login;
return $this;
}
@@ -511,7 +512,7 @@ class User_Query implements User_QueryInterface
$users = new ArrayCollection();
foreach ($rs as $row) {
- $users[] = User_Adapter::getInstance($row['usr_id'], $this->app);
+ $users[] = $this->app['manipulator.user']->getRepository()->find($row['usr_id']);
}
$this->results = $users;
diff --git a/lib/classes/appbox/register.php b/lib/classes/appbox/register.php
index 4591d534e1..8f527ea796 100644
--- a/lib/classes/appbox/register.php
+++ b/lib/classes/appbox/register.php
@@ -45,7 +45,7 @@ class appbox_register
$sql = "INSERT INTO demand (date_modif, usr_id, base_id, en_cours, refuser)
VALUES (now(), :usr_id , :base_id, 1, 0)";
$stmt = $this->appbox->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $user->get_id(), ':base_id' => $collection->get_base_id()]);
+ $stmt->execute(array(':usr_id' => $user->getId(), ':base_id' => $collection->get_base_id()));
$stmt->closeCursor();
return $this;
@@ -64,10 +64,10 @@ class appbox_register
{
$sql = 'SELECT base_id FROM demand WHERE usr_id = :usr_id AND en_cours="1" ';
$stmt = $this->appbox->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $user->get_id()]);
+ $stmt->execute(array(':usr_id' => $user->getId()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
- $ret = [];
+ $ret = array();
foreach ($rs as $row) {
$ret[] = collection::get_from_base_id($app, $row['base_id']);
}
@@ -86,7 +86,7 @@ class appbox_register
$lastMonth = new DateTime('-1 month');
$sql = "delete from demand where date_modif < :lastMonth";
$stmt = $appbox->get_connection()->prepare($sql);
- $stmt->execute([':lastMonth' => $lastMonth->format(DATE_ISO8601)]);
+ $stmt->execute(array(':lastMonth' => $lastMonth->format(DATE_ISO8601)));
$stmt->closeCursor();
return;
diff --git a/lib/classes/collection.php b/lib/classes/collection.php
index dbdb488832..5ece2fad59 100644
--- a/lib/classes/collection.php
+++ b/lib/classes/collection.php
@@ -12,6 +12,7 @@
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
+use Alchemy\Phrasea\Model\Entities\User;
class collection implements cache_cacheableInterface
{
@@ -557,7 +558,7 @@ class collection implements cache_cacheableInterface
return $ord['ord'] ?: 1;
}
- public static function create(Application $app, databox $databox, appbox $appbox, $name, User_Adapter $user = null)
+ public static function create(Application $app, databox $databox, appbox $appbox, $name, User $user = null)
{
$sbas_id = $databox->get_sbas_id();
$connbas = $databox->get_connection();
@@ -613,7 +614,7 @@ class collection implements cache_cacheableInterface
return $collection;
}
- public function set_admin($base_id, user_adapter $user)
+ public function set_admin($base_id, User $user)
{
$rights = [
@@ -641,7 +642,7 @@ class collection implements cache_cacheableInterface
return true;
}
- public static function mount_collection(Application $app, databox $databox, $coll_id, User_Adapter $user)
+ public static function mount_collection(Application $app, databox $databox, $coll_id, User $user)
{
$sql = "INSERT INTO bas (base_id, active, server_coll_id, sbas_id, aliases, ord)
diff --git a/lib/classes/eventsmanager/broker.php b/lib/classes/eventsmanager/broker.php
index 2ba1e65d48..9a84235ee4 100644
--- a/lib/classes/eventsmanager/broker.php
+++ b/lib/classes/eventsmanager/broker.php
@@ -13,9 +13,9 @@ use Alchemy\Phrasea\Application;
class eventsmanager_broker
{
- protected $events = [];
- protected $notifications = [];
- protected $pool_classes = [];
+ protected $events = array();
+ protected $notifications = array();
+ protected $pool_classes = array();
/**
*
@@ -32,11 +32,11 @@ class eventsmanager_broker
public function start()
{
- $iterators_pool = [
- 'event' => [
+ $iterators_pool = array(
+ 'event' => array(
'eventsmanager_event_test'
- ],
- 'notify' => [
+ ),
+ 'notify' => array(
'eventsmanager_notify_autoregister',
'eventsmanager_notify_bridgeuploadfail',
'eventsmanager_notify_downloadmailfail',
@@ -50,8 +50,8 @@ class eventsmanager_broker
'eventsmanager_notify_validate',
'eventsmanager_notify_validationdone',
'eventsmanager_notify_validationreminder',
- ]
- ];
+ )
+ );
foreach ($iterators_pool as $type => $iterators) {
foreach ($iterators as $fileinfo) {
@@ -73,7 +73,7 @@ class eventsmanager_broker
return;
}
- public function trigger($event, $array_params = [], &$object = false)
+ public function trigger($event, $array_params = array(), &$object = false)
{
if (array_key_exists($event, $this->events)) {
foreach ($this->events[$event] as $classname) {
@@ -88,7 +88,7 @@ class eventsmanager_broker
{
if ( ! array_key_exists($event, $this->events))
- $this->events[$event] = [];
+ $this->events[$event] = array();
$this->events[$event][] = $object_name;
}
@@ -102,12 +102,12 @@ class eventsmanager_broker
VALUES
(null, :usr_id, :event_type, 1, :mailed, :datas, NOW())';
- $params = [
+ $params = array(
':usr_id' => $usr_id
, ':event_type' => $event_type
, ':mailed' => ($mailed ? 1 : 0)
, ':datas' => $datas
- ];
+ );
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
@@ -127,7 +127,7 @@ class eventsmanager_broker
FROM notifications WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->app['authentication']->getUser()->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->getId()));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -142,10 +142,10 @@ class eventsmanager_broker
ORDER BY created_on DESC
LIMIT ' . ((int) $page * $n) . ', ' . $n;
- $data = ['notifications' => [], 'next' => ''];
+ $data = array('notifications' => array(), 'next' => '');
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->app['authentication']->getUser()->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->getId()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -156,7 +156,7 @@ class eventsmanager_broker
if ( ! isset($this->pool_classes[$type]) || count($content) === 0) {
$sql = 'DELETE FROM notifications WHERE id = :id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':id' => $row['id']]);
+ $stmt->execute(array(':id' => $row['id']));
$stmt->closeCursor();
continue;
}
@@ -165,19 +165,19 @@ class eventsmanager_broker
$display_date = $this->app['date-formatter']->getDate(new DateTime($row['created_on']));
if ( ! isset($data['notifications'][$date_key])) {
- $data['notifications'][$date_key] = [
+ $data['notifications'][$date_key] = array(
'display' => $display_date
- , 'notifications' => []
- ];
+ , 'notifications' => array()
+ );
}
- $data['notifications'][$date_key]['notifications'][$row['id']] = [
+ $data['notifications'][$date_key]['notifications'][$row['id']] = array(
'classname' => $content['class']
, 'time' => $this->app['date-formatter']->getTime(new DateTime($row['created_on']))
, 'icon' => ''
, 'id' => $row['id']
, 'text' => $content['text']
- ];
+ );
}
if (((int) $page + 1) * $n < $total) {
@@ -195,7 +195,7 @@ class eventsmanager_broker
FROM notifications
WHERE usr_id = :usr_id AND unread="1"';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->app['authentication']->getUser()->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->getId()));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -214,7 +214,7 @@ class eventsmanager_broker
FROM notifications WHERE usr_id = :usr_id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->app['authentication']->getUser()->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->getId()));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -230,9 +230,9 @@ class eventsmanager_broker
WHERE usr_id = :usr_id AND unread="1" ORDER BY created_on DESC';
}
- $ret = [];
+ $ret = array();
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $this->app['authentication']->getUser()->get_id()]);
+ $stmt->execute(array(':usr_id' => $this->app['authentication']->getUser()->getId()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -246,19 +246,19 @@ class eventsmanager_broker
if ( ! isset($this->pool_classes[$type]) || count($datas) === 0) {
$sql = 'DELETE FROM notifications WHERE id = :id';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':id' => $row['id']]);
+ $stmt->execute(array(':id' => $row['id']));
$stmt->closeCursor();
continue;
}
$ret[] = array_merge(
$datas
- , [
+ , array(
'created_on' => $this->app['date-formatter']->getPrettyString(new DateTime($row['created_on']))
, 'icon' => $this->pool_classes[$type]->icon_url()
, 'id' => $row['id']
, 'unread' => $row['unread']
- ]
+ )
);
}
@@ -276,7 +276,7 @@ class eventsmanager_broker
AND (id="' . implode('" OR id="', $notifications) . '")';
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
- $stmt->execute([':usr_id' => $usr_id]);
+ $stmt->execute(array(':usr_id' => $usr_id));
$stmt->closeCursor();
return $this;
@@ -284,7 +284,7 @@ class eventsmanager_broker
public function list_notifications_available($usr_id)
{
- $personnal_notifications = [];
+ $personnal_notifications = array();
foreach ($this->notifications as $notification) {
if (!$this->pool_classes[$notification]->is_available($usr_id)) {
@@ -293,12 +293,12 @@ class eventsmanager_broker
$group = $this->pool_classes[$notification]->get_group();
$group = $group === null ? $this->app->trans('Notifications globales') : $group;
- $personnal_notifications[$group][] = [
+ $personnal_notifications[$group][] = array(
'name' => $this->pool_classes[$notification]->get_name()
, 'id' => $notification
, 'description' => $this->pool_classes[$notification]->get_description()
, 'subscribe_emails' => true
- ];
+ );
}
return $personnal_notifications;
diff --git a/lib/classes/eventsmanager/notify/autoregister.php b/lib/classes/eventsmanager/notify/autoregister.php
index ad6521aff3..b007a9652a 100644
--- a/lib/classes/eventsmanager/notify/autoregister.php
+++ b/lib/classes/eventsmanager/notify/autoregister.php
@@ -11,6 +11,7 @@
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoSomebodyAutoregistered;
+use Alchemy\Phrasea\Model\Entities\User;
class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
{
@@ -18,7 +19,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
*
* @var string
*/
- public $events = ['__REGISTER_AUTOREGISTER__'];
+ public $events = array('__REGISTER_AUTOREGISTER__');
/**
*
@@ -38,10 +39,10 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
*/
public function fire($event, $params, &$object)
{
- $default = [
+ $default = array(
'usr_id' => ''
- , 'autoregister' => []
- ];
+ , 'autoregister' => array()
+ );
$params = array_merge($default, $params);
$base_ids = array_keys($params['autoregister']);
@@ -50,7 +51,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
return;
}
- $mailColl = [];
+ $mailColl = array();
$sql = 'SELECT u.usr_id, b.base_id FROM usr u, basusr b
WHERE u.usr_id = b.usr_id
@@ -69,7 +70,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
foreach ($rs as $row) {
if ( ! isset($mailColl[$row['usr_id']]))
- $mailColl[$row['usr_id']] = [];
+ $mailColl[$row['usr_id']] = array();
$mailColl[$row['usr_id']][] = $row['base_id'];
}
@@ -102,9 +103,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
$datas = $dom_xml->saveXml();
- try {
- $registered_user = User_Adapter::getInstance($params['usr_id'], $this->app);
- } catch (Exception $e) {
+ if (null === $registered_user = $this->app['manipulator.user']->getRepository()->find($params['usr_id'])) {
return;
}
@@ -113,9 +112,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
$mailed = false;
if ($this->shouldSendNotificationFor($usr_id)) {
- try {
- $admin_user = User_Adapter::getInstance($usr_id, $this->app);
- } catch (Exception $e) {
+ if (null === $admin_user = $this->app['manipulator.user']->getRepository()->find($usr_id)) {
continue;
}
@@ -140,18 +137,15 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
$sx = simplexml_load_string($datas);
$usr_id = (string) $sx->usr_id;
- try {
- User_Adapter::getInstance($usr_id, $this->app);
- } catch (Exception $e) {
- return [];
+
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($usr_id)) {
+ return array();
}
- $sender = User_Adapter::getInstance($usr_id, $this->app)->get_display_name();
-
$ret = [
- 'text' => $this->app->trans('%user% s\'est enregistre sur une ou plusieurs %before_link% scollections %after_link%', ['%user%' => $sender, '%before_link%' => '', '%after_link%' => ''])
+ 'text' => $this->app->trans('%user% s\'est enregistre sur une ou plusieurs %before_link% scollections %after_link%', ['%user%' => $user->getDisplayName(), '%before_link%' => '', '%after_link%' => ''])
, 'class' => ''
- ];
+ );
return $ret;
}
@@ -176,17 +170,17 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
/**
*
- * @param \User_Adapter $to
- * @param \User_Adapter $registeredUser
+ * @param User $to
+ * @param User $registeredUser
*
* @return boolean
*/
- public function mail(\User_Adapter $to, \User_Adapter $registeredUser)
+ public function mail(User $to, User $registeredUser)
{
$body .= sprintf("Login : %s\n", $registeredUser->get_login());
- $body .= sprintf("%s : %s\n", $this->app->trans('admin::compte-utilisateur nom'), $registeredUser->get_firstname());
- $body .= sprintf("%s : %s\n", $this->app->trans('admin::compte-utilisateur prenom'), $registeredUser->get_lastname());
- $body .= sprintf("%s : %s\n", $this->app->trans('admin::compte-utilisateur email'), $registeredUser->get_email());
+ $body .= sprintf("%s : %s\n", _('admin::compte-utilisateur nom'), $registeredUser->get_firstname());
+ $body .= sprintf("%s : %s\n", _('admin::compte-utilisateur prenom'), $registeredUser->get_lastname());
+ $body .= sprintf("%s : %s\n", _('admin::compte-utilisateur email'), $registeredUser->get_email());
$body .= sprintf("%s/%s\n", $registeredUser->get_job(), $registeredUser->get_company());
$readyToSend = false;
@@ -216,9 +210,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
return false;
}
- try {
- $user = \User_Adapter::getInstance($usr_id, $this->app);
- } catch (\Exception $e) {
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($usr_id)) {
return false;
}
diff --git a/lib/classes/eventsmanager/notify/bridgeuploadfail.php b/lib/classes/eventsmanager/notify/bridgeuploadfail.php
index 7fdf9eeb0a..84f5408d2e 100644
--- a/lib/classes/eventsmanager/notify/bridgeuploadfail.php
+++ b/lib/classes/eventsmanager/notify/bridgeuploadfail.php
@@ -79,7 +79,7 @@ class eventsmanager_notify_bridgeuploadfail extends eventsmanager_notifyAbstract
$readyToSend = false;
try {
- $user = User_Adapter::getInstance($params['usr_id'], $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($params['usr_id']);
$account = Bridge_Account::load_account($this->app, $params['account_id']);
$receiver = Receiver::fromUser($user);
$readyToSend = true;
diff --git a/lib/classes/eventsmanager/notify/feed.php b/lib/classes/eventsmanager/notify/feed.php
index 1a1a9400e2..b41888e9cd 100644
--- a/lib/classes/eventsmanager/notify/feed.php
+++ b/lib/classes/eventsmanager/notify/feed.php
@@ -83,15 +83,14 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
$results = $Query->limit($start, $perLoop)->execute()->get_results();
foreach ($results as $user_to_notif) {
- /* @var $user_to_notif \User_Adapter */
$mailed = false;
- if ($params['notify_email'] && $this->shouldSendNotificationFor($user_to_notif->get_id())) {
+ if ($params['notify_email'] && $this->shouldSendNotificationFor($user_to_notif->getId())) {
$readyToSend = false;
try {
$token = $this->app['tokens']->getUrlToken(
\random::TYPE_FEED_ENTRY
- , $user_to_notif->get_id()
+ , $user_to_notif->getId()
, null
, $entry->getId()
);
@@ -115,7 +114,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
}
}
- $this->broker->notify($user_to_notif->get_id(), __CLASS__, $datas, $mailed);
+ $this->broker->notify($user_to_notif->getId(), __CLASS__, $datas, $mailed);
}
$start += $perLoop;
} while (count($results) > 0);
diff --git a/lib/classes/eventsmanager/notify/order.php b/lib/classes/eventsmanager/notify/order.php
index 75ca544b0d..355b1ad52c 100644
--- a/lib/classes/eventsmanager/notify/order.php
+++ b/lib/classes/eventsmanager/notify/order.php
@@ -18,7 +18,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
*
* @var string
*/
- public $events = ['__NEW_ORDER__'];
+ public $events = array('__NEW_ORDER__');
/**
*
@@ -38,22 +38,22 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
*/
public function fire($event, $params, &$object)
{
- $default = [
+ $default = array(
'usr_id' => ''
- , 'order_id' => []
- ];
+ , 'order_id' => array()
+ );
$params = array_merge($default, $params);
$order_id = $params['order_id'];
- $users = [];
+ $users = array();
try {
$repository = $this->app['EM']->getRepository('Phraseanet:OrderElement');
- $results = $repository->findBy(['orderId' => $order_id]);
+ $results = $repository->findBy(array('orderId' => $order_id));
- $base_ids = [];
+ $base_ids = array();
foreach ($results as $result) {
$base_ids[] = $result->getBaseId();
}
@@ -61,7 +61,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
$query = new User_Query($this->app);
$users = $query->on_base_ids($base_ids)
- ->who_have_right(['order_master'])
+ ->who_have_right(array('order_master'))
->execute()->get_results();
} catch (Exception $e) {
@@ -92,16 +92,14 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
$datas = $dom_xml->saveXml();
- try {
- $orderInitiator = User_Adapter::getInstance($params['usr_id'], $this->app);
- } catch (\Exception $e) {
+ if (null === $orderInitiator = $this->app['manipulator.user']->getRepository()->find($params['usr_id'])) {
return;
}
foreach ($users as $user) {
$mailed = false;
- if ($this->shouldSendNotificationFor($user->get_id())) {
+ if ($this->shouldSendNotificationFor($user->getId())) {
$readyToSend = false;
try {
$receiver = Receiver::fromUser($user);
@@ -119,7 +117,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
}
}
- $this->broker->notify($user->get_id(), __CLASS__, $datas, $mailed);
+ $this->broker->notify($user->getId(), __CLASS__, $datas, $mailed);
}
return;
@@ -138,13 +136,11 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
$usr_id = (string) $sx->usr_id;
$order_id = (string) $sx->order_id;
- try {
- User_Adapter::getInstance($usr_id, $this->app);
- } catch (Exception $e) {
- return [];
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($usr_id)) {
+ return array();
}
- $sender = User_Adapter::getInstance($usr_id, $this->app)->get_display_name();
+ $sender = $user->getDisplayName();
$ret = [
'text' => $this->app->trans('%user% a passe une %opening_link% commande %end_link%', [
@@ -152,7 +148,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
'%opening_link%' => '',
'%end_link%' => '',])
, 'class' => ''
- ];
+ );
return $ret;
}
@@ -182,9 +178,7 @@ class eventsmanager_notify_order extends eventsmanager_notifyAbstract
*/
public function is_available($usr_id)
{
- try {
- $user = \User_Adapter::getInstance($usr_id, $this->app);
- } catch (\Exception $e) {
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($usr_id)) {
return false;
}
diff --git a/lib/classes/eventsmanager/notify/orderdeliver.php b/lib/classes/eventsmanager/notify/orderdeliver.php
index 2fca925580..a97dffbb86 100644
--- a/lib/classes/eventsmanager/notify/orderdeliver.php
+++ b/lib/classes/eventsmanager/notify/orderdeliver.php
@@ -20,7 +20,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
*
* @var string
*/
- public $events = ['__ORDER_DELIVER__'];
+ public $events = array('__ORDER_DELIVER__');
/**
*
@@ -52,12 +52,12 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
*/
public function fire($event, $params, &$object)
{
- $default = [
+ $default = array(
'from' => ''
, 'to' => ''
, 'ssel_id' => ''
, 'n' => ''
- ];
+ );
$params = array_merge($default, $params);
@@ -92,8 +92,8 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
if ($this->shouldSendNotificationFor($params['to'])) {
$readyToSend = false;
try {
- $user_from = User_Adapter::getInstance($params['from'], $this->app);
- $user_to = User_Adapter::getInstance($params['to'], $this->app);
+ $user_from = $this->app['manipulator.user']->getRepository()->find($params['from']);
+ $user_to = $this->app['manipulator.user']->getRepository()->find($params['to']);
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
@@ -107,15 +107,15 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
}
if ($readyToSend) {
- $url = $this->app->url('lightbox_compare', [
- 'basket' => $basket->getId(),
+ $url = $this->app->url('lightbox_compare', array(
+ 'ssel_id' => $basket->getId(),
'LOG' => $this->app['tokens']->getUrlToken(
\random::TYPE_VIEW,
- $user_to->get_id(),
+ $user_to->getId(),
null,
$basket->getId()
)
- ]);
+ ));
$mail = MailInfoOrderDelivered::create($this->app, $receiver, $emitter, null);
$mail->setButtonUrl($url);
@@ -144,25 +144,25 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
$ssel_id = (string) $sx->ssel_id;
$n = (int) $sx->n;
- try {
- User_Adapter::getInstance($from, $this->app);
- } catch (Exception $e) {
- return [];
+ if (null === $user= $this->app['manipulator.user']->getRepository()->find(($from))) {
+ return array();
}
- $sender = User_Adapter::getInstance($from, $this->app)->get_display_name();
+ $sender = $user->getDisplayName();
try {
- $basket = $this->app['converter.basket']->convert($ssel_id);
+ $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket');
+
+ $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['authentication']->getUser(), false);
} catch (Exception $e) {
- return [];
+ return array();
}
$ret = [
'text' => $this->app->trans('%user% vous a delivre %quantity% document(s) pour votre commande %title%', ['%user%' => $sender, '%quantity%' => $n, '%title%' => ''
. $basket->getName() . ''])
, 'class' => ''
- ];
+ );
return $ret;
}
diff --git a/lib/classes/eventsmanager/notify/ordernotdelivered.php b/lib/classes/eventsmanager/notify/ordernotdelivered.php
index 892bdb3dc4..f02c18bad3 100644
--- a/lib/classes/eventsmanager/notify/ordernotdelivered.php
+++ b/lib/classes/eventsmanager/notify/ordernotdelivered.php
@@ -20,7 +20,7 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
*
* @var string
*/
- public $events = ['__ORDER_NOT_DELIVERED__'];
+ public $events = array('__ORDER_NOT_DELIVERED__');
public function __construct(Application $app, eventsmanager_broker $broker)
{
@@ -37,11 +37,11 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
public function fire($event, $params, &$object)
{
- $default = [
+ $default = array(
'from' => ''
, 'to' => ''
, 'n' => ''
- ];
+ );
$params = array_merge($default, $params);
@@ -75,8 +75,8 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
$readyToSend = false;
try {
- $user_from = User_Adapter::getInstance($params['from'], $this->app);
- $user_to = User_Adapter::getInstance($params['to'], $this->app);
+ $user_from = $this->app['manipulator.user']->getRepository()->find($params['from']);
+ $user_to = $this->app['manipulator.user']->getRepository()->find($params['to']);
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
@@ -107,18 +107,16 @@ class eventsmanager_notify_ordernotdelivered extends eventsmanager_notifyAbstrac
$from = (string) $sx->from;
$n = (int) $sx->n;
- try {
- User_Adapter::getInstance($from, $this->app);
- } catch (Exception $e) {
- return [];
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($from)) {
+ return array();
}
- $sender = User_Adapter::getInstance($from, $this->app)->get_display_name();
+ $sender = $user->getDisplayName();
$ret = [
'text' => $this->app->trans('%user% a refuse la livraison de %quantity% document(s) pour votre commande', ['%user%' => $sender, '%quantity%' => $n])
, 'class' => ''
- ];
+ );
return $ret;
}
diff --git a/lib/classes/eventsmanager/notify/push.php b/lib/classes/eventsmanager/notify/push.php
index 46d35cd893..4be79a2f02 100644
--- a/lib/classes/eventsmanager/notify/push.php
+++ b/lib/classes/eventsmanager/notify/push.php
@@ -19,7 +19,7 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
*
* @var string
*/
- public $events = ['__PUSH_DATAS__'];
+ public $events = array('__PUSH_DATAS__');
/**
*
@@ -39,12 +39,12 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
*/
public function fire($event, $params, &$object)
{
- $default = [
+ $default = array(
'from' => ''
, 'to' => ''
, 'message' => ''
, 'ssel_id' => ''
- ];
+ );
$params = array_merge($default, $params);
@@ -83,8 +83,8 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
$repository = $this->app['EM']->getRepository('Phraseanet:Basket');
$basket = $repository->find($params['ssel_id']);
- $user_from = User_Adapter::getInstance($params['from'], $this->app);
- $user_to = User_Adapter::getInstance($params['to'], $this->app);
+ $user_from = $this->app['manipulator.user']->getRepository()->find($params['from']);
+ $user_to = $this->app['manipulator.user']->getRepository()->find($params['to']);
$receiver = Receiver::fromUser($user_to);
$emitter = Emitter::fromUser($user_from);
@@ -119,19 +119,17 @@ class eventsmanager_notify_push extends eventsmanager_notifyAbstract
$from = (string) $sx->from;
- try {
- User_Adapter::getInstance($from, $this->app);
- } catch (Exception $e) {
- return [];
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($from)) {
+ return array();
}
- $sender = User_Adapter::getInstance($from, $this->app)->get_display_name();
+ $sender = $user->getDisplayName();
$ret = [
'text' => $this->app->trans('%user% vous a envoye un %before_link% panier %after_link%', ['%user%' => $sender, '%before_link%' => '', '%after_link%' => ''])
, 'class' => ($unread == 1 ? 'reload_baskets' : '')
- ];
+ );
return $ret;
}
diff --git a/lib/classes/eventsmanager/notify/register.php b/lib/classes/eventsmanager/notify/register.php
index 272dd666b7..c7e2ac085a 100644
--- a/lib/classes/eventsmanager/notify/register.php
+++ b/lib/classes/eventsmanager/notify/register.php
@@ -18,7 +18,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
*
* @var string
*/
- public $events = ['__REGISTER_APPROVAL__'];
+ public $events = array('__REGISTER_APPROVAL__');
/**
*
@@ -38,10 +38,10 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
*/
public function fire($event, $params, &$object)
{
- $default = [
+ $default = array(
'usr_id' => ''
- , 'demand' => []
- ];
+ , 'demand' => array()
+ );
$params = array_merge($default, $params);
$base_ids = $params['demand'];
@@ -50,7 +50,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
return;
}
- $mailColl = [];
+ $mailColl = array();
try {
$sql = 'SELECT u.usr_id, b.base_id
@@ -70,7 +70,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
foreach ($rs as $row) {
if ( ! isset($mailColl[$row['usr_id']]))
- $mailColl[$row['usr_id']] = [];
+ $mailColl[$row['usr_id']] = array();
$mailColl[$row['usr_id']][] = $row['base_id'];
}
@@ -103,10 +103,8 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
$datas = $dom_xml->saveXml();
- try {
- $registeredUser = \User_Adapter::getInstance($params['usr_id'], $this->app);
- } catch (\Exception $e) {
- return;
+ if (null === $registeredUser = $this->app['manipulator.user']->getRepository()->find($params['usr_id'])) {
+ return;
}
foreach ($mailColl as $usr_id => $base_ids) {
@@ -115,7 +113,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
if ($this->shouldSendNotificationFor($usr_id)) {
$readyToSend = false;
try {
- $admin_user = User_Adapter::getInstance($usr_id, $this->app);
+ $admin_user = $this->app['manipulator.user']->getRepository()->find($usr_id);
$receiver = Receiver::fromUser($admin_user);
$readyToSend = true;
} catch (\Exception $e) {
@@ -150,18 +148,16 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
$usr_id = (string) $sx->usr_id;
- try {
- User_Adapter::getInstance($usr_id, $this->app);
- } catch (Exception $e) {
- return [];
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($usr_id)) {
+ return array();
}
- $sender = User_Adapter::getInstance($usr_id, $this->app)->get_display_name();
+ $sender = $user->getDisplayName();
$ret = [
'text' => $this->app->trans('%user% demande votre approbation sur une ou plusieurs %before_link% collections %after_link%', ['%user%' => $sender, '%before_link%' => '', '%after_link%' => ''])
, 'class' => ''
- ];
+ );
return $ret;
}
@@ -195,9 +191,7 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
return false;
}
- try {
- $user = \User_Adapter::getInstance($usr_id, $this->app);
- } catch (\Exception $e) {
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($usr_id)) {
return false;
}
diff --git a/lib/classes/eventsmanager/notify/uploadquarantine.php b/lib/classes/eventsmanager/notify/uploadquarantine.php
index e42e2fc15c..e7a788a2c1 100644
--- a/lib/classes/eventsmanager/notify/uploadquarantine.php
+++ b/lib/classes/eventsmanager/notify/uploadquarantine.php
@@ -11,6 +11,7 @@
use Alchemy\Phrasea\Model\Entities\LazaretCheck;
use Alchemy\Phrasea\Model\Entities\LazaretFile;
+use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoRecordQuarantined;
@@ -73,7 +74,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
//Sender
if (null !== $user = $lazaretFile->getSession()->getUser($this->app)) {
$sender = $domXML->createElement('sender');
- $sender->appendChild($domXML->createTextNode($user->get_display_name()));
+ $sender->appendChild($domXML->createTextNode($user->getDisplayName()));
$root->appendChild($sender);
$this->notifyUser($user, $datas);
@@ -98,14 +99,14 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
/**
* Notifiy an user using the specified datas
*
- * @param \User_Adapter $user
+ * @param User $user
* @param string $datas
*/
- private function notifyUser(\User_Adapter $user, $datas)
+ private function notifyUser(User $user, $datas)
{
$mailed = false;
- if ($this->shouldSendNotificationFor($user->get_id())) {
+ if ($this->shouldSendNotificationFor($user->getId())) {
$readyToSend = false;
try {
$receiver = Receiver::fromUser($user);
@@ -121,7 +122,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
}
}
- $this->broker->notify($user->get_id(), __CLASS__, $datas, $mailed);
+ $this->broker->notify($user->getId(), __CLASS__, $datas, $mailed);
}
/**
@@ -182,9 +183,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
*/
public function is_available($usr_id)
{
- try {
- $user = \User_Adapter::getInstance($usr_id, $this->app);
- } catch (\Exception $e) {
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($usr_id)) {
return false;
}
diff --git a/lib/classes/eventsmanager/notify/validate.php b/lib/classes/eventsmanager/notify/validate.php
index 260d72ee05..cfbf441e53 100644
--- a/lib/classes/eventsmanager/notify/validate.php
+++ b/lib/classes/eventsmanager/notify/validate.php
@@ -20,7 +20,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
*
* @var string
*/
- public $events = ['__PUSH_VALIDATION__'];
+ public $events = array('__PUSH_VALIDATION__');
/**
*
@@ -52,12 +52,12 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
*/
public function fire($event, $params, &$object)
{
- $default = [
+ $default = array(
'from' => ''
, 'to' => ''
, 'message' => ''
, 'ssel_id' => ''
- ];
+ );
$params = array_merge($default, $params);
@@ -93,8 +93,8 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
$readyToSend = false;
try {
- $user_from = User_Adapter::getInstance($params['from'], $this->app);
- $user_to = User_Adapter::getInstance($params['to'], $this->app);
+ $user_from = $this->app['manipulator.user']->getRepository()->find($params['from']);
+ $user_to = $this->app['manipulator.user']->getRepository()->find($params['to']);
$basket = $this->app['EM']
->getRepository('Phraseanet:Basket')
@@ -137,13 +137,11 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
$from = (string) $sx->from;
$ssel_id = (string) $sx->ssel_id;
- try {
- User_Adapter::getInstance($from, $this->app);
- } catch (Exception $e) {
- return [];
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($from)) {
+ return array();
}
- $sender = User_Adapter::getInstance($from, $this->app)->get_display_name();
+ $sender = $user->getDisplayName();
try {
$basket = $this->app['converter.basket']->convert($ssel_id);
@@ -153,7 +151,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
}
$bask_link = ''
. $basket_name . '';
@@ -163,7 +161,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
'%title%' => $bask_link,
])
, 'class' => ($unread == 1 ? 'reload_baskets' : '')
- ];
+ );
return $ret;
}
diff --git a/lib/classes/eventsmanager/notify/validationdone.php b/lib/classes/eventsmanager/notify/validationdone.php
index ffd22decd7..467673d0a9 100644
--- a/lib/classes/eventsmanager/notify/validationdone.php
+++ b/lib/classes/eventsmanager/notify/validationdone.php
@@ -20,7 +20,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
*
* @var string
*/
- public $events = ['__VALIDATION_DONE__'];
+ public $events = array('__VALIDATION_DONE__');
/**
*
@@ -52,11 +52,11 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
*/
public function fire($event, $params, &$object)
{
- $default = [
+ $default = array(
'from' => ''
, 'to' => ''
, 'ssel_id' => ''
- ];
+ );
$params = array_merge($default, $params);
@@ -88,8 +88,8 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
if ($this->shouldSendNotificationFor($params['to'])) {
$readyToSend = false;
try {
- $user_from = User_Adapter::getInstance($params['from'], $this->app);
- $user_to = User_Adapter::getInstance($params['to'], $this->app);
+ $user_from = $this->app['manipulator.user']->getRepository()->find($params['from']);
+ $user_to = $this->app['manipulator.user']->getRepository()->find($params['to']);
$basket = $this->app['EM']
->getRepository('Phraseanet:Basket')
@@ -131,18 +131,18 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
$from = (string) $sx->from;
$ssel_id = (string) $sx->ssel_id;
- try {
- $registered_user = User_Adapter::getInstance($from, $this->app);
- } catch (Exception $e) {
- return [];
+ if (null === $registered_user = $this->app['manipulator.user']->getRepository()->find($from)) {
+ return array();
}
- $sender = $registered_user->get_display_name();
+ $sender = $registered_user->getDisplayName();
try {
- $basket = $this->app['converter.basket']->convert($ssel_id);
+ $repository = $this->app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Basket');
+
+ $basket = $repository->findUserBasket($this->app, $ssel_id, $this->app['authentication']->getUser(), false);
} catch (Exception $e) {
- return [];
+ return array();
}
$ret = [
@@ -151,7 +151,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
. $basket->getName() . ''
])
, 'class' => ''
- ];
+ );
return $ret;
}
@@ -181,9 +181,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
*/
public function is_available($usr_id)
{
- try {
- $user = \User_Adapter::getInstance($usr_id, $this->app);
- } catch (\Exception $e) {
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($usr_id)) {
return false;
}
diff --git a/lib/classes/eventsmanager/notify/validationreminder.php b/lib/classes/eventsmanager/notify/validationreminder.php
index 9ea3a806ce..66734553ef 100644
--- a/lib/classes/eventsmanager/notify/validationreminder.php
+++ b/lib/classes/eventsmanager/notify/validationreminder.php
@@ -20,7 +20,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
*
* @var string
*/
- public $events = ['__VALIDATION_REMINDER__'];
+ public $events = array('__VALIDATION_REMINDER__');
/**
*
@@ -52,12 +52,12 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
*/
public function fire($event, $params, &$object)
{
- $default = [
+ $default = array(
'from' => ''
, 'to' => ''
, 'ssel_id' => ''
, 'url' => ''
- ];
+ );
$params = array_merge($default, $params);
@@ -86,10 +86,10 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
$mailed = false;
- try {
- $user_from = User_Adapter::getInstance($params['from'], $this->app);
- $user_to = User_Adapter::getInstance($params['to'], $this->app);
- } catch (Exception $e) {
+ $user_from = $this->app['manipulator.user']->getRepository()->find($params['from']);
+ $user_to = $this->app['manipulator.user']->getRepository()->find($params['to']);
+
+ if (null === $user_from || null === $user_to) {
return false;
}
@@ -136,13 +136,11 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
$from = (string) $sx->from;
$ssel_id = (string) $sx->ssel_id;
- try {
- User_Adapter::getInstance($from, $this->app);
- } catch (Exception $e) {
- return [];
+ if (null === $user = $this->app['manipulator.user']->getRepository()->find($from)) {
+ return array();
}
- $sender = User_Adapter::getInstance($from, $this->app)->get_display_name();
+ $sender = $user->getDisplayName();
try {
$basket = $this->app['converter.basket']->convert($ssel_id);
@@ -158,7 +156,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
$ret = [
'text' => $this->app->trans('Rappel : Il vous reste %number% jours pour valider %title% de %user%', ['%number%' => $this->app['conf']->get(['registry', 'actions', 'validation-reminder-days']), '%title%' => $bask_link, '%user%' => $sender])
, 'class' => ($unread == 1 ? 'reload_baskets' : '')
- ];
+ );
return $ret;
}
diff --git a/lib/classes/eventsmanager/notifyAbstract.php b/lib/classes/eventsmanager/notifyAbstract.php
index caa43cc599..3fae9a2511 100644
--- a/lib/classes/eventsmanager/notifyAbstract.php
+++ b/lib/classes/eventsmanager/notifyAbstract.php
@@ -34,7 +34,7 @@ abstract class eventsmanager_notifyAbstract extends eventsmanager_eventAbstract
protected function get_prefs($class, $usr_id)
{
- $user = User_Adapter::getInstance($usr_id, $this->app);
+ $user = $this->app['manipulator.user']->getRepository()->find($usr_id);
$pref = $user->get_notifications_preference($this->app, $class);
return null !== $pref ? $pref : 1;
diff --git a/lib/classes/module/console/checkExtension.php b/lib/classes/module/console/checkExtension.php
index 6848722dc1..993c8812eb 100644
--- a/lib/classes/module/console/checkExtension.php
+++ b/lib/classes/module/console/checkExtension.php
@@ -41,9 +41,7 @@ class module_console_checkExtension extends Command
$usrId = $input->getArgument('usr_id');
- try {
- $TestUser = \User_Adapter::getInstance($usrId, $this->container);
- } catch (\Exception $e) {
+ if (null === $TestUser = $this->container['manipulator.user']->getRepository()->find($usrId)) {
$output->writeln("
{% trans with {'%username%' : username} %}Hello %username%{% endtrans %} diff --git a/templates/mobile/api/auth/native_app_access_token.html.twig b/templates/mobile/api/auth/native_app_access_token.html.twig index 1710ae9313..1f14e59fcd 100644 --- a/templates/mobile/api/auth/native_app_access_token.html.twig +++ b/templates/mobile/api/auth/native_app_access_token.html.twig @@ -38,7 +38,7 @@
{% trans with {'%username%' : username} %}Hello %username%{% endtrans %} diff --git a/templates/mobile/lightbox/sc_note.html.twig b/templates/mobile/lightbox/sc_note.html.twig index 40b07e2563..f6e721e341 100644 --- a/templates/mobile/lightbox/sc_note.html.twig +++ b/templates/mobile/lightbox/sc_note.html.twig @@ -1,5 +1,5 @@ {% for validationDatas in basket_element.getValidationDatas() %} - {% set is_mine = validationDatas.getParticipant().getUser(app).get_id() == app['authentication'].getUser().get_id() %} + {% set is_mine = validationDatas.getParticipant().getUser(app).getId() == app['authentication'].getUser().getId() %} {% if validationDatas.getNote() != '' or (validationDatas.getAgreement() is not null and is_mine) %}
{{ 'validation:: note' | trans }} : {{ validationDatas.getNote()|nl2br }}
diff --git a/templates/web/account/account.html.twig b/templates/web/account/account.html.twig index fde83a910c..7711e00911 100644 --- a/templates/web/account/account.html.twig +++ b/templates/web/account/account.html.twig @@ -38,7 +38,7 @@{{ app["authentication"].getUser().get_login() }}
+{{ app["authentication"].getUser().getLogin() }}
usr_id : {{ user.get_id() }} | +usr_id : {{ user.getId() }} | |||||||
{{ 'admin::compte-utilisateur nom' | trans }} : {{ user.get_display_name() }} | +{{ 'admin::compte-utilisateur nom' | trans }} : {{ user.getDisplayName() }} | |||||||
{{ 'admin::compte-utilisateur societe' | trans }} : {{ user.get_company() }} | +{{ 'admin::compte-utilisateur societe' | trans }} : {{ user.getCompany() }} | |||||||
{{ 'admin::compte-utilisateur telephone' | trans }} : {{ user.get_tel() }} | +{{ 'admin::compte-utilisateur telephone' | trans }} : {{ user.getPhone() }} | |||||||
{{ 'admin::compte-utilisateur email' | trans }} : {{ user.get_email() }} | +{{ 'admin::compte-utilisateur email' | trans }} : {{ user.getEmail() }} | |||||||
{{ 'admin::monitor: bases sur lesquelles l\'utilisateur est connecte :' | trans }} : | @@ -102,9 +102,9 @@||||||||
{{ row.getUser(app).get_display_name() }} | +{{ row.getUser(app).getDisplayName() }} | {% else %} -{{ row.getUser(app).get_display_name() }} | +{{ row.getUser(app).getDisplayName() }} | {% endif %}
diff --git a/templates/web/admin/editusers.html.twig b/templates/web/admin/editusers.html.twig
index a872ad1e1d..a408215c82 100644
--- a/templates/web/admin/editusers.html.twig
+++ b/templates/web/admin/editusers.html.twig
@@ -97,7 +97,7 @@
|
{% if main_user is not empty %}
- {% if main_user.is_special is not empty %}
- {% if main_user.get_login() == 'invite' %}
- {{ 'Reglages:: reglages d acces guest' | trans }}
- {% elseif main_user.get_login() == 'autoregister' %}
- {{ 'Reglages:: reglages d inscitpition automatisee' | trans }}
+ {% if main_user.isSpecial is not empty %}
+ {% if main_user.getLogin() == 'invite' %}
+ {{ 'Reglages:: reglages d acces guest' | trans }}
+ {% elseif main_user.getLogin() == 'autoregister' %}
+ {{ 'Reglages:: reglages d inscitpition automatisee' | trans }}
{% endif %}
{% else %}
- {% set display_name = main_user.get_display_name() %}
+ {% set display_name = main_user.getDisplayName() %}
{% trans with {'%display_name%' : display_name} %}Edition des droits de %display_name%{% endtrans %}
{% endif %}
{% else %}
@@ -131,7 +131,7 @@
@@ -435,7 +435,7 @@
- {% if main_user is not empty and main_user.is_template is empty and main_user.is_special is empty %}
+ {% if main_user is not empty and main_user.isTemplate is empty and main_user.isSpecial is empty %}
|
- {{ publisher.getUser(app).get_display_name() }} + {{ publisher.getUser(app).getDisplayName() }} | - {{ publisher.getUser(app).get_email() }} + {{ publisher.getUser(app).getEmail() }} | {% if publisher.isOwner() == true %} diff --git a/templates/web/admin/users.html.twig b/templates/web/admin/users.html.twig index f6b5cdec8b..0553dd89e8 100644 --- a/templates/web/admin/users.html.twig +++ b/templates/web/admin/users.html.twig @@ -26,9 +26,9 @@ {{ 'admin::user: import d\'utilisateurs' | trans }} / {{ 'admin::user: export d\'utilisateurs' | trans }} {{ 'Reglages:: reglages d acces guest' | trans }} - + {{ 'Reglages:: reglages d inscitpition automatisee' | trans }} - + |