mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
Merge pull request #837 from romainneutron/fix-1618
[3.8] Fix user settings precedence
This commit is contained in:
@@ -1320,16 +1320,6 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
$sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':id' => $this->id));
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $row) {
|
||||
$this->_prefs[$row['prop']] = $row['value'];
|
||||
}
|
||||
|
||||
foreach (self::$def_values as $k => $v) {
|
||||
if (!isset($this->_prefs[$k])) {
|
||||
if ($k == 'start_page_query' && $this->app['phraseanet.registry']->get('GV_defaultQuery')) {
|
||||
@@ -1351,6 +1341,16 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
);
|
||||
}
|
||||
|
||||
$sql = 'SELECT prop, value FROM usr_settings WHERE usr_id= :id';
|
||||
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':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;
|
||||
|
@@ -92,11 +92,14 @@ class userTest extends PhraseanetPHPUnitAbstract
|
||||
);
|
||||
|
||||
$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->assertSame(666, $user->getPrefs('images_size'));
|
||||
$this->assertSame(42, $user->getPrefs('images_per_page'));
|
||||
$this->assertSame(\User_Adapter::$def_values['editing_top_box'], $user->getPrefs('editing_top_box'));
|
||||
$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'));
|
||||
|
||||
if (null === $data) {
|
||||
unset(self::$DI['app']['phraseanet.configuration']['user-settings']);
|
||||
|
Reference in New Issue
Block a user