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

Commit

Permalink
feat(config): lock mqtt prefix if new data is created
Browse files Browse the repository at this point in the history
Signed-off-by: Domingo Oropeza <[email protected]>
  • Loading branch information
DIOHz0r committed May 15, 2018
1 parent 44a68e3 commit b6b28a0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions inc/agent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@ public function prepareInputForUpdate($input) {
public function post_addItem() {
// Notify the agent about its fleets
$this->updateSubscription();

if (PluginFlyvemdmConfig::canUpdate()) {
// Here we must update mqtt_prefix_locked
}
}

public function post_getFromDB() {
Expand Down
7 changes: 7 additions & 0 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,4 +531,11 @@ public function isGlpiConfigured() {

return true;
}

public function prepareInputForUpdate($input) {
if ($input['mqtt_prefix'] != $this->fields['mqtt_prefix'] && $this->fields['mqtt_prefix_locked'] == 0) {
$input['mqtt_prefix_locked'] = 1;
}
return $input;
}
}
4 changes: 4 additions & 0 deletions inc/fleet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ public function post_addItem() {
$topic = $this->getTopic();
$this->notify("$topic/Policy/$policyName", null, 0, 1);
}

if (PluginFlyvemdmConfig::canUpdate()) {
// Here we must update mqtt_prefix_locked
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions inc/invitation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ public function post_addItem() {

// Sent invitation email
$this->sendInvitation();

if (PluginFlyvemdmConfig::canUpdate()) {
// Here we must update mqtt_prefix_locked
}
}

public function post_updateItem($history = 1) {
Expand Down
1 change: 1 addition & 0 deletions install/installer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ protected function createInitialConfig() {
'mqtt_user' => self::BACKEND_MQTT_USER,
'mqtt_passwd' => $MdmMqttPassword,
'mqtt_prefix' => '',
'mqtt_prefix_locked' => '0',
'instance_id' => $instanceId,
'registered_profiles_id' => '',
'guest_profiles_id' => '',
Expand Down
8 changes: 6 additions & 2 deletions tpl/config-messagequeue.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
</tr>
<tr class="tab_bg_1">
<td>{{ __('MQTT prefix', 'flyvemdm') }}</td>
<td><input type="text" name="mqtt_prefix" value="{{ config.mqtt_prefix }}"></td>
<td>{{ __('Prepend all topics with a prefix (useful if a MQTT broker is mutualized). The mqtt daemon must be restarted.', 'flyvemdm') }}</td>
<td><input type="text" name="mqtt_prefix" value="{{ config.mqtt_prefix }}"
{% if (config.mqtt_prefix_locked) == 1 %}disabled{% endif %}></td>
<td>{{ __('Prepend all topics with a prefix (useful if a MQTT broker is mutualized). The mqtt daemon must be restarted after the change.', 'flyvemdm') }}
<br>
<span class="red">{{ __('Note: This value can be changed only once and if no new invitation, agent or fleet has been created.', 'flyvemdm') }}</span>
</td>
</tr>
<tr class="tab_bg_1">
<td>{{ __('MQTT broker port for TLS', 'flyvemdm') }}</td>
Expand Down

0 comments on commit b6b28a0

Please sign in to comment.