Some fix after rebase

This commit is contained in:
Nicolas Le Goff
2013-11-18 17:05:07 +01:00
parent 678f741660
commit 0e1203f595
9 changed files with 32 additions and 32 deletions

View File

@@ -12,11 +12,11 @@
namespace Alchemy\Phrasea\ACL; namespace Alchemy\Phrasea\ACL;
use Alchemy\Phrasea\Model\Entities\Basket; use Alchemy\Phrasea\Model\Entities\Basket;
use User_Adapter; use Alchemy\Phrasea\Model\Entities\User;
class BasketACL class BasketACL
{ {
public function hasAccess(Basket $basket, User_Adapter $user) public function hasAccess(Basket $basket, User $user)
{ {
if ($this->isOwner($basket, $user)) { if ($this->isOwner($basket, $user)) {
return true; return true;
@@ -24,7 +24,7 @@ class BasketACL
if ($basket->getValidation()) { if ($basket->getValidation()) {
foreach ($basket->getValidation()->getParticipants() as $participant) { foreach ($basket->getValidation()->getParticipants() as $participant) {
if ($participant->getUsrId() === $user->get_id()) { if ($participant->getUsrId() === $user->getId()) {
return true; return true;
} }
} }
@@ -33,8 +33,8 @@ class BasketACL
return false; 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();
} }
} }

View File

@@ -147,13 +147,14 @@ class Dashboard implements ControllerProviderInterface
public function addAdmins(Application $app, Request $request) public function addAdmins(Application $app, Request $request)
{ {
if (count($admins = $request->request->get('admins', [])) > 0) { if (count($admins = $request->request->get('admins', [])) > 0) {
if (!in_array($app['authentication']->getUser()->getId(), $admins)) { if (!in_array($app['authentication']->getUser()->getId(), $admins)) {
$admins[] = $app['authentication']->getUser()->getId(); $admins[] = $app['authentication']->getUser()->getId();
} }
if ($admins > 0) { 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()); $app['manipulator.acl']->resetAdminRights($app['manipulator.user']->getRepository()->findAdmins());
} }
} }

View File

@@ -267,7 +267,7 @@ class Root implements ControllerProviderInterface
'mod_pres' => $app['authentication']->getUser()->getSettingValue('client_view', '' ), 'mod_pres' => $app['authentication']->getUser()->getSettingValue('client_view', '' ),
'start_page' => $app['authentication']->getUser()->getSettingValue('start_page'), 'start_page' => $app['authentication']->getUser()->getSettingValue('start_page'),
'start_page_query' => $app['authentication']->getUser()->getSettingValue('start_page_query', '') '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', [ return $app['twig']->render('client/home_inter_pub_basket.html.twig', [
'feeds' => Aggregate::createFromUser($app, $app['authentication']->getUser()), 'feeds' => Aggregate::createFromUser($app, $app['authentication']->getUser()),
'image_size' => (int) $app['authentication']->getUser()->getSettingValue('images_size') 'image_size' => (int) $app['authentication']->getUser()->getSettingValue('images_size')
)); ]);
} }
/** /**

View File

@@ -230,11 +230,11 @@ class Push implements ControllerProviderInterface
$receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : ''; $receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';
$params = [ $params = [
'from' => $app['authentication']->getUser()->get_id() 'from' => $app['authentication']->getUser()->getId()
, 'from_email' => $app['authentication']->getUser()->get_email() , 'from_email' => $app['authentication']->getUser()->getEmail()
, 'to' => $user_receiver->get_id() , 'to' => $user_receiver->getId()
, 'to_email' => $user_receiver->get_email() , 'to_email' => $user_receiver->getEmail()
, 'to_name' => $user_receiver->get_display_name() , 'to_name' => $user_receiver->getDisplayName()
, 'url' => $url , 'url' => $url
, 'accuse' => $receipt , 'accuse' => $receipt
, 'message' => $request->request->get('message') , 'message' => $request->request->get('message')
@@ -263,7 +263,7 @@ class Push implements ControllerProviderInterface
} }
return $app->json($ret); return $app->json($ret);
}]->bind('prod_push_send'); })->bind('prod_push_send');
$controllers->post('/validate/', function (Application $app) { $controllers->post('/validate/', function (Application $app) {
$request = $app['request']; $request = $app['request'];
@@ -345,7 +345,7 @@ class Push implements ControllerProviderInterface
} }
if (!$found) { if (!$found) {
$participants[$app['authentication']->getUser()->get_id()] = [ $participants[$app['authentication']->getUser()->getId()] = [
'see_others' => 1, 'see_others' => 1,
'usr_id' => $app['authentication']->getUser()->getId(), 'usr_id' => $app['authentication']->getUser()->getId(),
'agree' => 0, 'agree' => 0,
@@ -427,11 +427,11 @@ class Push implements ControllerProviderInterface
$receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : ''; $receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';
$params = [ $params = [
'from' => $app['authentication']->getUser()->get_id(), 'from' => $app['authentication']->getUser()->getId(),
'from_email' => $app['authentication']->getUser()->get_email(), 'from_email' => $app['authentication']->getUser()->getEmail(),
'to' => $participant_user->get_id(), 'to' => $participant_user->get_id(),
'to_email' => $participant_user->get_email(), 'to_email' => $participant_user->getEmail(),
'to_name' => $participant_user->get_display_name(), 'to_name' => $participant_user->getDisplayName(),
'url' => $url, 'url' => $url,
'accuse' => $receipt, 'accuse' => $receipt,
'message' => $request->request->get('message'), 'message' => $request->request->get('message'),
@@ -464,7 +464,7 @@ class Push implements ControllerProviderInterface
} }
return $app->json($ret); return $app->json($ret);
}]->bind('prod_push_validate'); })->bind('prod_push_validate');
$controllers->get('/user/{usr_id}/', function (Application $app, $usr_id) use ($userFormatter) { $controllers->get('/user/{usr_id}/', function (Application $app, $usr_id) use ($userFormatter) {
$datas = null; $datas = null;

View File

@@ -532,7 +532,8 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
try { try {
$this->app['phraseanet.appbox']->get_connection()->beginTransaction(); $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) $this->app['acl']->get($user)->revoke_access_from_bases($delete)
->give_access_to_base($create) ->give_access_to_base($create)
->give_access_to_sbas($create_sbas); ->give_access_to_sbas($create_sbas);

View File

@@ -860,7 +860,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
try { try {
$sql = "UPDATE usr SET create_db='0' WHERE create_db='1' AND usr_id != :usr_id"; $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 = $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(); $stmt->closeCursor();
$sql = "UPDATE usr SET create_db='1' WHERE usr_id IN (" . implode(',', $admins) . ")"; $sql = "UPDATE usr SET create_db='1' WHERE usr_id IN (" . implode(',', $admins) . ")";

View File

@@ -100,7 +100,7 @@ interface User_Interface
public function set_notification_preference(Application $app, $notification_id, $value); public function set_notification_preference(Application $app, $notification_id, $value);
public function get_display_name(); public function getDisplayName();
public function get_nonce(); public function get_nonce();

View File

@@ -320,7 +320,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* *
* @return Basket * @return Basket
*/ */
protected function insertOneBasket(\User_Adapter $user = null) protected function insertOneBasket(User $user = null)
{ {
$basket = new Basket(); $basket = new Basket();
$basket->setOwner($user ?: self::$DI['user']); $basket->setOwner($user ?: self::$DI['user']);
@@ -616,7 +616,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* *
* @return BasketElement * @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 = new BasketElement();
$element->setRecord($record ?: self::$DI['record_1']); $element->setRecord($record ?: self::$DI['record_1']);

View File

@@ -91,12 +91,10 @@ class userTest extends \PhraseanetTestCase
$user = $this->get_user(); $user = $this->get_user();
$user->setPrefs('images_per_page', 35); $user->setPrefs('images_per_page', 35);
$user = new \User_Adapter($user->get_id(), self::$DI['app']); $this->assertNull($user->getSettingValue('lalala'));
$this->assertSame(666, $user->getSettingValue('images_size'));
$this->assertNull($user->getPrefs('lalala')); $this->assertSame(42, $user->getSettingValue('images_per_page'));
$this->assertEquals(666, $user->getPrefs('images_size')); $this->assertSame(User::$defaultUserSettings['editing_top_box'], $user->getSettingValue('editing_top_box'));
$this->assertEquals(35, $user->getPrefs('images_per_page'));
$this->assertEquals(\User_Adapter::$def_values['editing_top_box'], $user->getPrefs('editing_top_box'));
if (null === $data) { if (null === $data) {
self::$DI['app']['conf']->remove('user-settings'); self::$DI['app']['conf']->remove('user-settings');