From 541b9aae3a8f96b0a800dbccf348e360c92a292c Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Fri, 23 Nov 2018 00:10:20 +0100 Subject: [dozmod] add network share submodule --- .../dozmod/pages/networkshares.inc.php | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 modules-available/dozmod/pages/networkshares.inc.php (limited to 'modules-available/dozmod/pages/networkshares.inc.php') diff --git a/modules-available/dozmod/pages/networkshares.inc.php b/modules-available/dozmod/pages/networkshares.inc.php new file mode 100644 index 00000000..d0bbe03a --- /dev/null +++ b/modules-available/dozmod/pages/networkshares.inc.php @@ -0,0 +1,63 @@ + $shareid]); + if ($res) Message::addSuccess('networkshare-deleted'); + } + } else if ($action === 'save') { + User::assertPermission('networkshares.save'); + $shareid = Request::post('shareid', false, 'int'); + $sharename = Request::post('sharename', false, 'string'); + $path = Request::post('path', false, 'string'); + $target = Request::post('target', null, 'string'); + $username = Request::post('username', null, 'string'); + $password = Request::post('password', null, 'string'); + if ($sharename && $path) { + if ($shareid) { + Database::exec('UPDATE sat.presetnetworkshare SET sharename = :sharename, path = :path, target = :target, username = :username, password = :password' + .' WHERE shareid = :shareid', compact('shareid', 'sharename', 'path', 'target', 'username', 'password')); + } else { + Database::exec('INSERT INTO sat.presetnetworkshare (sharename, path, target, username, password, active)' + .' VALUES (:sharename, :path, :target, :username, :password, 0)', compact('sharename', 'path', 'target', 'username', 'password')); + } + Message::addSuccess('networkshare-saved'); + } + } else if ($action === 'toggleActive') { + User::assertPermission('networkshares.save'); + $shareid = Request::post('shareid', false, 'int'); + Database::exec('UPDATE sat.presetnetworkshare SET active = !active WHERE shareid = :shareid', compact('shareid')); + } + User::assertPermission('networkshares.view'); + } + + public static function doRender() + { + $show = Request::get('show', 'list', 'string'); + if ($show === 'list') { + $res = Database::simpleQuery('SELECT * FROM sat.presetnetworkshare;'); + $rows = array(); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $row['specificUser'] = $row['username'] && $row['password']; + $rows[] = $row; + } + Render::addTemplate('networkshares', ['networkshares' => $rows, 'hasEditPermissions' => User::hasPermission('networkshares.save')]); + } else if ($show === 'edit') { + $shareid = Request::get('shareid', 0, 'int'); + $data = Database::queryFirst('SELECT * FROM sat.presetnetworkshare WHERE shareid = :shareid', ['shareid' => $shareid]); + if ($data['username'] && $data['password']) $data['specificUser'] = 'selected'; + else $data['loggedInUser'] = 'selected'; + Render::addTemplate('networkshares-edit', $data); + } + } + +} -- cgit v1.2.3-55-g7522