Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat(api): expose configuration settings
Browse files Browse the repository at this point in the history
grant read access to Config itemtype
  • Loading branch information
btry committed Dec 16, 2016
1 parent 70091d7 commit e9cd70d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 7 additions & 0 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,11 @@ public function prepareInputForAdd($input) {
return $input;
}

public static function undiscloseConfigValue($fields) {
if ($fields['context'] == 'storkmdm'
&& in_array($fields['name'], array('mqtt_passwd'))) {
unset($fields['value']);
}
return $fields;
}
}
3 changes: 1 addition & 2 deletions install/installer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ protected function createRegisteredProfileAccess() {
| PluginStorkmdmEntityconfig::RIGHT_STORKMDM_APP_DOWNLOAD_URL
| PluginStorkmdmEntityconfig::RIGHT_STORKMDM_INVITATION_TOKEN_LIFE,
PluginStorkmdmInvitationlog::$rightname => READ,
Config::$rightname => READ,
User::$rightname => ALLSTANDARDRIGHT,
Profile::$rightname => CREATE,
Entity::$rightname => CREATE,
Expand Down Expand Up @@ -561,7 +562,6 @@ public function uninstall() {
* @param string $dir
*/
protected function rrmdir($dir) {

if (file_exists($dir) && is_dir($dir)) {
$objects = scandir($dir);
foreach ( $objects as $object ) {
Expand All @@ -575,7 +575,6 @@ protected function rrmdir($dir) {
reset($objects);
rmdir($dir);
}

}

/**
Expand Down
3 changes: 2 additions & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
function plugin_init_storkmdm() {
global $PLUGIN_HOOKS, $CFG_GLPI;

$PLUGIN_HOOKS['csrf_compliant']["storkmdm"] = true;
$PLUGIN_HOOKS['csrf_compliant']['storkmdm'] = true;
$PLUGIN_HOOKS['undiscloseConfigValue']['storkmdm'] = array('PluginStorkmdmConfig', 'undiscloseConfigValue');

$plugin = new Plugin();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ public function testRegisteredUserProfileNetworkPortRight($rights) {
* @param array $rights
*/
public function testRegisteredUserProfileConfigRight($rights) {
//disabled for now
//$this->assertEquals(READ, $rights[Config::$rightname]);
$this->assertEquals(READ, $rights[Config::$rightname]);
}

}

0 comments on commit e9cd70d

Please sign in to comment.