mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
Merge pull request #786 from romainneutron/fix-1572
[3.8] Fix #1572 : Add configuration customization
This commit is contained in:
@@ -1334,11 +1334,27 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->app['phraseanet.configuration']['user-settings'])) {
|
||||
$this->_prefs = array_replace(
|
||||
$this->_prefs,
|
||||
// remove keys that are not defined in default values
|
||||
array_intersect_key(
|
||||
$this->app['phraseanet.configuration']['user-settings'],
|
||||
self::$def_values
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$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();
|
||||
@@ -1352,7 +1368,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->notification_preferences_loaded = true;
|
||||
$this->notifications_preferences_loaded = true;
|
||||
}
|
||||
|
||||
public function get_notifications_preference(Application $app, $notification_id)
|
||||
|
@@ -201,6 +201,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
return new Client($DI['app'], array());
|
||||
});
|
||||
|
||||
self::$DI['user']->purgePreferences();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
|
@@ -58,6 +58,30 @@ class userTest extends PhraseanetPHPUnitAbstract
|
||||
$this->assertSame(\User_Adapter::$def_values['editing_top_box'], $user->getPrefs('editing_top_box'));
|
||||
}
|
||||
|
||||
public function testGetPrefWithACustomizedConf()
|
||||
{
|
||||
$data = isset(self::$DI['app']['phraseanet.configuration']['user-settings']) ? self::$DI['app']['phraseanet.configuration']['user-settings'] : null;
|
||||
|
||||
self::$DI['app']['phraseanet.configuration']['user-settings'] = array(
|
||||
'images_per_page' => 42,
|
||||
'images_size' => 666,
|
||||
'lalala' => 'didou',
|
||||
);
|
||||
|
||||
$user = $this->get_user();
|
||||
|
||||
$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'));
|
||||
|
||||
if (null === $data) {
|
||||
unset(self::$DI['app']['phraseanet.configuration']['user-settings']);
|
||||
} else {
|
||||
self::$DI['app']['phraseanet.configuration']['user-settings'] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetPref()
|
||||
{
|
||||
$user = $this->get_user();
|
||||
|
Reference in New Issue
Block a user