Skip to content
Extraits de code Groupes Projets
Valider 1934bb1e rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

Merge pull request #9794 from piwik/change_writable_setting

Add possibility to set a system setting is writable/not writable
parents 027427f7 4c3776de
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -2,6 +2,11 @@
This is a changelog for Piwik platform developers. All changes for our HTTP API's, Plugins, Themes, etc will be listed here.
## Piwik 2.16.1
### New features
* New method `setIsWritableByCurrentUser` for `SystemSetting` to change the writable permission for certain system settings via DI.
## Piwik 2.16.0
### New features
......
......@@ -66,6 +66,16 @@ class SystemSetting extends Setting
return $this->writableByCurrentUser;
}
/**
* Set whether setting is writable or not. For example to hide setting from the UI set it to false.
*
* @param bool $isWritable
*/
public function setIsWritableByCurrentUser($isWritable)
{
$this->writableByCurrentUser = (bool) $isWritable;
}
/**
* Returns `true` if this setting can be displayed for the current user, `false` if otherwise.
*
......
......@@ -116,7 +116,7 @@ class ConfigReader
{
$key = strtolower($key);
$passwordFields = array(
'password', 'secret', 'apikey', 'privatekey', 'admin_pass'
'password', 'secret', 'apikey', 'privatekey', 'admin_pass', 'md5', 'sha1'
);
foreach ($passwordFields as $value) {
if (strpos($key, $value) !== false) {
......
......@@ -175,6 +175,21 @@ class SystemSettingTest extends IntegrationTestCase
$this->assertFalse($setting->isWritableByCurrentUser());
}
public function test_setIsWritableByCurrentUser()
{
$this->setSuperUser();
$setting = $this->addSystemSetting('myusersetting', 'mytitle');
$setting->setPluginName('MyPluginName');
$this->assertTrue($setting->isWritableByCurrentUser());
$setting->setIsWritableByCurrentUser(false);
$this->assertFalse($setting->isWritableByCurrentUser());
$setting->setIsWritableByCurrentUser(true);
$this->assertTrue($setting->isWritableByCurrentUser());
}
/**
* @expectedException \Exception
* @expectedExceptionMessage CoreAdminHome_PluginSettingChangeNotAllowed
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter