mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Some fix after rebase
This commit is contained in:
@@ -12,11 +12,11 @@
|
||||
namespace Alchemy\Phrasea\ACL;
|
||||
|
||||
use Alchemy\Phrasea\Model\Entities\Basket;
|
||||
use User_Adapter;
|
||||
use Alchemy\Phrasea\Model\Entities\User;
|
||||
|
||||
class BasketACL
|
||||
{
|
||||
public function hasAccess(Basket $basket, User_Adapter $user)
|
||||
public function hasAccess(Basket $basket, User $user)
|
||||
{
|
||||
if ($this->isOwner($basket, $user)) {
|
||||
return true;
|
||||
@@ -24,7 +24,7 @@ class BasketACL
|
||||
|
||||
if ($basket->getValidation()) {
|
||||
foreach ($basket->getValidation()->getParticipants() as $participant) {
|
||||
if ($participant->getUsrId() === $user->get_id()) {
|
||||
if ($participant->getUsrId() === $user->getId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -33,8 +33,8 @@ class BasketACL
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isOwner(Basket $basket, User_Adapter $user)
|
||||
public function isOwner(Basket $basket, User $user)
|
||||
{
|
||||
return $basket->getUsrId() === $user->get_id();
|
||||
return $basket->getUsrId() === $user->getId();
|
||||
}
|
||||
}
|
||||
|
@@ -147,13 +147,14 @@ class Dashboard implements ControllerProviderInterface
|
||||
public function addAdmins(Application $app, Request $request)
|
||||
{
|
||||
if (count($admins = $request->request->get('admins', [])) > 0) {
|
||||
|
||||
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.user']->promote(array_filter(array_map(function($id) use ($app) {
|
||||
return $app['manipulator.user']->getRepository()->find($id);
|
||||
}, $admins)));
|
||||
$app['manipulator.acl']->resetAdminRights($app['manipulator.user']->getRepository()->findAdmins());
|
||||
}
|
||||
}
|
||||
|
@@ -267,7 +267,7 @@ class Root implements ControllerProviderInterface
|
||||
'mod_pres' => $app['authentication']->getUser()->getSettingValue('client_view', '' ),
|
||||
'start_page' => $app['authentication']->getUser()->getSettingValue('start_page'),
|
||||
'start_page_query' => $app['authentication']->getUser()->getSettingValue('start_page_query', '')
|
||||
)));
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -480,7 +480,7 @@ class Root implements ControllerProviderInterface
|
||||
return $app['twig']->render('client/home_inter_pub_basket.html.twig', [
|
||||
'feeds' => Aggregate::createFromUser($app, $app['authentication']->getUser()),
|
||||
'image_size' => (int) $app['authentication']->getUser()->getSettingValue('images_size')
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -230,11 +230,11 @@ class Push implements ControllerProviderInterface
|
||||
$receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';
|
||||
|
||||
$params = [
|
||||
'from' => $app['authentication']->getUser()->get_id()
|
||||
, 'from_email' => $app['authentication']->getUser()->get_email()
|
||||
, 'to' => $user_receiver->get_id()
|
||||
, 'to_email' => $user_receiver->get_email()
|
||||
, 'to_name' => $user_receiver->get_display_name()
|
||||
'from' => $app['authentication']->getUser()->getId()
|
||||
, 'from_email' => $app['authentication']->getUser()->getEmail()
|
||||
, 'to' => $user_receiver->getId()
|
||||
, 'to_email' => $user_receiver->getEmail()
|
||||
, 'to_name' => $user_receiver->getDisplayName()
|
||||
, 'url' => $url
|
||||
, 'accuse' => $receipt
|
||||
, 'message' => $request->request->get('message')
|
||||
@@ -263,7 +263,7 @@ class Push implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
return $app->json($ret);
|
||||
}]->bind('prod_push_send');
|
||||
})->bind('prod_push_send');
|
||||
|
||||
$controllers->post('/validate/', function (Application $app) {
|
||||
$request = $app['request'];
|
||||
@@ -345,7 +345,7 @@ class Push implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$participants[$app['authentication']->getUser()->get_id()] = [
|
||||
$participants[$app['authentication']->getUser()->getId()] = [
|
||||
'see_others' => 1,
|
||||
'usr_id' => $app['authentication']->getUser()->getId(),
|
||||
'agree' => 0,
|
||||
@@ -427,11 +427,11 @@ class Push implements ControllerProviderInterface
|
||||
$receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';
|
||||
|
||||
$params = [
|
||||
'from' => $app['authentication']->getUser()->get_id(),
|
||||
'from_email' => $app['authentication']->getUser()->get_email(),
|
||||
'from' => $app['authentication']->getUser()->getId(),
|
||||
'from_email' => $app['authentication']->getUser()->getEmail(),
|
||||
'to' => $participant_user->get_id(),
|
||||
'to_email' => $participant_user->get_email(),
|
||||
'to_name' => $participant_user->get_display_name(),
|
||||
'to_email' => $participant_user->getEmail(),
|
||||
'to_name' => $participant_user->getDisplayName(),
|
||||
'url' => $url,
|
||||
'accuse' => $receipt,
|
||||
'message' => $request->request->get('message'),
|
||||
@@ -464,7 +464,7 @@ class Push implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
return $app->json($ret);
|
||||
}]->bind('prod_push_validate');
|
||||
})->bind('prod_push_validate');
|
||||
|
||||
$controllers->get('/user/{usr_id}/', function (Application $app, $usr_id) use ($userFormatter) {
|
||||
$datas = null;
|
||||
|
@@ -532,7 +532,8 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
||||
try {
|
||||
$this->app['phraseanet.appbox']->get_connection()->beginTransaction();
|
||||
|
||||
$user = \User_Adapter::getInstance($usr_id, $this->app);
|
||||
$user = $this->app['manipulator.user']->getRepository()->find($usr_id);
|
||||
|
||||
$this->app['acl']->get($user)->revoke_access_from_bases($delete)
|
||||
->give_access_to_base($create)
|
||||
->give_access_to_sbas($create_sbas);
|
||||
|
@@ -860,7 +860,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
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([':usr_id' => $app['authentication']->getUser()->getId()]);
|
||||
$stmt->closeCursor();
|
||||
|
||||
$sql = "UPDATE usr SET create_db='1' WHERE usr_id IN (" . implode(',', $admins) . ")";
|
||||
|
@@ -100,7 +100,7 @@ interface User_Interface
|
||||
|
||||
public function set_notification_preference(Application $app, $notification_id, $value);
|
||||
|
||||
public function get_display_name();
|
||||
public function getDisplayName();
|
||||
|
||||
public function get_nonce();
|
||||
|
||||
|
@@ -320,7 +320,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
*
|
||||
* @return Basket
|
||||
*/
|
||||
protected function insertOneBasket(\User_Adapter $user = null)
|
||||
protected function insertOneBasket(User $user = null)
|
||||
{
|
||||
$basket = new Basket();
|
||||
$basket->setOwner($user ?: self::$DI['user']);
|
||||
@@ -616,7 +616,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
*
|
||||
* @return BasketElement
|
||||
*/
|
||||
protected function insertOneBasketElement(\User_Adapter $user = null, \record_adapter $record = null)
|
||||
protected function insertOneBasketElement(User $user = null, \record_adapter $record = null)
|
||||
{
|
||||
$element = new BasketElement();
|
||||
$element->setRecord($record ?: self::$DI['record_1']);
|
||||
|
@@ -91,12 +91,10 @@ class userTest extends \PhraseanetTestCase
|
||||
$user = $this->get_user();
|
||||
$user->setPrefs('images_per_page', 35);
|
||||
|
||||
$user = new \User_Adapter($user->get_id(), self::$DI['app']);
|
||||
|
||||
$this->assertNull($user->getPrefs('lalala'));
|
||||
$this->assertEquals(666, $user->getPrefs('images_size'));
|
||||
$this->assertEquals(35, $user->getPrefs('images_per_page'));
|
||||
$this->assertEquals(\User_Adapter::$def_values['editing_top_box'], $user->getPrefs('editing_top_box'));
|
||||
$this->assertNull($user->getSettingValue('lalala'));
|
||||
$this->assertSame(666, $user->getSettingValue('images_size'));
|
||||
$this->assertSame(42, $user->getSettingValue('images_per_page'));
|
||||
$this->assertSame(User::$defaultUserSettings['editing_top_box'], $user->getSettingValue('editing_top_box'));
|
||||
|
||||
if (null === $data) {
|
||||
self::$DI['app']['conf']->remove('user-settings');
|
||||
|
Reference in New Issue
Block a user