diff --git a/Layout/default/Devicetype/Index.php b/Layout/default/Devicetype/Index.php
index f09a21d50..d36b5e3ea 100644
--- a/Layout/default/Devicetype/Index.php
+++ b/Layout/default/Devicetype/Index.php
@@ -4,7 +4,7 @@ $pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Devicetype";
?>
-
@@ -106,7 +106,7 @@ $pagination_entity_name = "Devicetype";
});
-
+
\ No newline at end of file
diff --git a/application/Device/DeviceController.php b/application/Device/DeviceController.php
index 0a11dc525..37c9b49c6 100644
--- a/application/Device/DeviceController.php
+++ b/application/Device/DeviceController.php
@@ -95,7 +95,7 @@ class DeviceController extends mfBaseController
$data = [];
$data['name'] = trim($r->name);
$data['devicetype_id'] = $r->devicetype_id;
- if (trim($r->pop_id)=="0") {
+ if (trim($r->pop_id) == "0") {
$data['pop_id'] = NULL;
} else {
$data['pop_id'] = $r->pop_id;
@@ -181,32 +181,6 @@ class DeviceController extends mfBaseController
}
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
- $returnUrl="Device";
- $returnAction = "Index";
- $returnVariables = array();
- $returnAnker = "";
- if ($this->request->returnto) {
-
- if (strpos($this->request->returnto, "-") !== false) {
- $urls = explode('-', $this->request->returnto);
- $urlCounter = 0;
- $returnUrlGen = "";
- foreach ($urls as $url) {
- if ($urlCounter > 0) {
- $returnUrlGen .= "/";
- }
- $returnUrlGen .= ucfirst($url);
- $urlCounter++;
- }
- $returnAction = "";
- $returnVariables['id'] = $id;
- $returnUrl = $returnUrlGen;
- } else {
- $returnUrl = ucfirst($this->request->returnto);
-
- }
- }
-
if ($mode == "edit") {
$this->layout()->setFlash("Device erfolgreich geƤndert", "success");
@@ -216,4 +190,62 @@ class DeviceController extends mfBaseController
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
+ protected function apiAction()
+ {
+ if (!$this->me->is(["Admin"])) {
+ $this->redirect("Dashboard");
+ }
+ $do = $this->request->do;
+ $format = $this->request->format;
+ $filename = $this->request->filename;
+ $id = $this->request->id;
+ $ip = $this->request->ip;
+
+ $data = [];
+
+ switch ($do) {
+ case "getconfig":
+ $return = $this->getConfig($id, $format, $filename);
+ break;
+ case "createconfig":
+ $return = $this->createConfig($ip);
+ break;
+ default:
+ $return = false;
+ }
+
+ }
+
+ private function getConfig($id, $format, $filename)
+ {
+ $configDownload = DeviceModel::getconifgdownload($id, $format);
+//
+
+// header('Content-Type: application/octet-stream');
+ header('Content-Type: text/plain');
+ header('Content-disposition: attachment; filename="' . $filename . '"');
+ echo $configDownload;
+
+ exit;
+ }
+
+ private function createConfig($ip)
+ {
+ $r = $this->request;
+ $id = $r->id;
+ $createConfig = DeviceModel::configcreate($ip);
+ if ($createConfig->success==="true")
+ {
+ $this->layout()->setFlash("Backup wurde erfolgreich erstellt", "success");
+ }
+ else
+ {
+ $this->layout()->setFlash("Backup konnte nicht erstellt werden. Fehler: ".$createConfig->error, "error");
+ }
+ $returnUrl = "Device";
+ $returnAction = "Detail";
+ $returnVariables['id'] = $id;
+ return $this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
+ }
+
}
\ No newline at end of file
diff --git a/application/Device/DeviceModel.php b/application/Device/DeviceModel.php
index 8c9de7072..b5df9bdcc 100644
--- a/application/Device/DeviceModel.php
+++ b/application/Device/DeviceModel.php
@@ -108,8 +108,8 @@ class DeviceModel
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Device", "*", "$where ORDER BY name");
- if($db->num_rows($res)) {
- while($data = $db->fetch_object($res)) {
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_object($res)) {
$items[] = new Device($data);
}
}
@@ -121,9 +121,9 @@ class DeviceModel
$where = "1=1 ";
//var_dump($filter);exit;
- if(array_key_exists("pop_id", $filter)) {
+ if (array_key_exists("pop_id", $filter)) {
$popid = $filter['pop_id'];
- if(is_numeric($popid)) {
+ if (is_numeric($popid)) {
$where .= " AND pop_id=$popid";
}
}
diff --git a/application/Devicemanufactor/Devicemanufactor.php b/application/Devicemanufactor/Devicemanufactor.php
index 8edb05baf..b07d7722a 100644
--- a/application/Devicemanufactor/Devicemanufactor.php
+++ b/application/Devicemanufactor/Devicemanufactor.php
@@ -1,5 +1,4 @@