diff --git a/inc/policybase.class.php b/inc/policybase.class.php
index ab4be8ce..f6a5f00e 100644
--- a/inc/policybase.class.php
+++ b/inc/policybase.class.php
@@ -180,8 +180,8 @@ public function unapply(PluginFlyvemdmFleet $fleet, $value, $itemtype, $itemId)
/**
* @return string
*/
- public function showValueInput() {
- $html = '';
+ public function showValueInput($value = '', $itemtype = '', $itemId = 0) {
+ $html = '';
return $html;
}
@@ -220,7 +220,6 @@ public function getPolicyData() {
/**
* Generate the form for add or edit a policy
*
- * @param PluginFlyvemdmPolicyBase $policy to be edited
* @param string $mode add or update
* @param array $_input values for update
* @return string html
@@ -229,8 +228,18 @@ public function formGenerator(
$mode = 'add',
array $_input = []
) {
+ $task = new PluginFlyvemdmTask();
+ $value = '';
+ $itemtype = '';
+ $itemId = 0;
+ if (!$task->isNewID($_input['task'])) {
+ $task->getFromDB($_input['task']);
+ $value = $task->getField('value');
+ $itemtype = $task->getField('itemtype');
+ $itemId = $task->getField('items_id');
+ }
$form['mode'] = $mode;
- $form['input'] = $this->showValueInput();
+ $form['input'] = $this->showValueInput($value, $itemtype, $itemId);
if ($mode == "update") {
$form['url'] = Toolbox::getItemTypeFormURL(PluginFlyvemdmTask::class);
$form['rand'] = mt_rand();
diff --git a/inc/policyboolean.class.php b/inc/policyboolean.class.php
index 7691761c..b0988a73 100644
--- a/inc/policyboolean.class.php
+++ b/inc/policyboolean.class.php
@@ -86,11 +86,8 @@ public function getMqttMessage($value, $itemtype, $itemId) {
return $array;
}
- /**
- * @return int|string
- */
- public function showValueInput() {
- return Dropdown::showYesNo('value', '0', -1, ['display' => false]);
+ public function showValueInput($value = '', $itemtype = '', $itemId = 0) {
+ return Dropdown::showYesNo('value', $value, -1, ['display' => false]);
}
/**
diff --git a/inc/policydeployapplication.class.php b/inc/policydeployapplication.class.php
index 049a5b6a..5a6c3b83 100644
--- a/inc/policydeployapplication.class.php
+++ b/inc/policydeployapplication.class.php
@@ -197,17 +197,18 @@ public function unapply(PluginFlyvemdmFleet $fleet, $value, $itemtype, $itemId)
return true;
}
- /**
- * @return string
- */
- public function showValueInput() {
+ public function showValueInput($value = '', $itemtype = '', $itemId = 0) {
+ $value = json_decode($value, JSON_OBJECT_AS_ARRAY);
$out = PluginFlyvemdmPackage::dropdown([
- 'display' => false,
- 'displaywith' => ['alias'],
- 'name' => 'items_id',
+ 'display' => false,
+ 'displaywith' => ['alias'],
+ 'name' => 'items_id',
+ 'value' => $itemId,
]);
- $out .= '';
- $out .= '';
+ $itemtype = PluginFlyvemdmPackage::class;
+ $removeOnDelete = $value['remove_on_delete'];
+ $out .= '';
+ $out .= '';
return $out;
}
diff --git a/inc/policydeployfile.class.php b/inc/policydeployfile.class.php
index a3184900..5677a788 100644
--- a/inc/policydeployfile.class.php
+++ b/inc/policydeployfile.class.php
@@ -246,18 +246,19 @@ public function unapply(PluginFlyvemdmFleet $fleet, $value, $itemtype, $itemId)
/**
* @return string|void
*/
- public function showValueInput() {
+ public function showValueInput($value = '') {
$out = PluginFlyvemdmFile::dropdown([
'display' => false,
'name' => 'items_id',
]);
- $out .= '';
+ $out .= '';
$out .= '
';
$out .= __('copy to', 'flyvemdm');
$out .= '
';
$out .= PluginFlyvemdmWellknownpath::dropdown([
- 'display' => false,
- 'name' => 'destination_base',
+ 'display' => false,
+ 'name' => 'destination_base',
+ 'value' => $value,
]);
$out .= '';
$out .= '';
diff --git a/inc/policydropdown.class.php b/inc/policydropdown.class.php
index 217851b9..51f46d31 100644
--- a/inc/policydropdown.class.php
+++ b/inc/policydropdown.class.php
@@ -98,8 +98,8 @@ public function translateData() {
/**
* @return int|string
*/
- public function showValueInput() {
- return Dropdown::showFromArray('value', $this->valueList, ['display' => false]);
+ public function showValueInput($value = '', $itemtype = '', $itemId = 0) {
+ return Dropdown::showFromArray('value', $this->valueList, ['display' => false, 'value' => $value]);
}
/**
diff --git a/inc/policyinterface.class.php b/inc/policyinterface.class.php
index 89226d78..ef7ce114 100644
--- a/inc/policyinterface.class.php
+++ b/inc/policyinterface.class.php
@@ -119,8 +119,12 @@ public function unapply(PluginFlyvemdmFleet $fleet, $value, $itemtype, $itemId);
/**
* return HTML input to set policy value
+ * @param string $value value of the task
+ * @param string $itemtype type of the item linked to the task
+ * @param integer $itemId ID of the item
+ * @return string
*/
- public function showValueInput();
+ public function showValueInput($value = '', $itemtype = '', $itemId = 0);
/**