diff --git a/add_ad_group.php b/add_ad_group.php index 21516fd..56e791f 100644 --- a/add_ad_group.php +++ b/add_ad_group.php @@ -3,12 +3,8 @@ KVM-VDI Tadas Ustinavičius -Vilnius University. -Center of Information Technology Development. - - Vilnius,Lithuania. -2016-07-21 +2017-06-05 */ include ('functions/config.php'); require_once('functions/functions.php'); @@ -22,83 +18,31 @@ - + + +
+
- \ No newline at end of file diff --git a/inc/infrastructure/UpdateADGroups.php b/inc/infrastructure/UpdateADGroups.php new file mode 100644 index 0000000..d13cddb --- /dev/null +++ b/inc/infrastructure/UpdateADGroups.php @@ -0,0 +1,36 @@ + 'nologin')); + exit; +} +slash_vars(); +$type=''; +if (isset($_POST['type'])) + $type=$_POST['type']; +if ($type=='new'){ + if (!empty($_POST['group_name'])) + $group_name=$_POST['group_name']; + else{ + echo json_encode(array('error' => _('Empty group.'))); + exit; + } + $existing=get_SQL_line("SELECT id FROM ad_groups WHERE name = '$group_name'"); + if (!empty($existing[0])){ + echo json_encode(array('error' => _('Group already exists.'))); + exit; + } + add_SQL_line("INSERT INTO ad_groups (name) VALUES ('$group_name')"); + echo json_encode(array('success' => _('New group added.'))); + exit; +} +if ($type=='delete'){ + $group=$_POST['group']; + foreach ($user as $id){ + add_SQL_line("DELETE FROM ad_groups WHERE id='$id' LIMIT 1"); + } + echo json_encode(array('success' => _('Group deleted.'))); + exit; +} diff --git a/inc/js/kvm-vdi.js b/inc/js/kvm-vdi.js index 016ca97..e1c2e65 100644 --- a/inc/js/kvm-vdi.js +++ b/inc/js/kvm-vdi.js @@ -138,8 +138,32 @@ function showAlert(title, text, icon, type){ } }); } +//================================================================== $(document).ready( function() { $('#RefreshButton').click(function() { refresh_screen(); }); + $('#AddADGroupButton').click(function() { + if(!$('#ADGroup')[0].checkValidity()){ + $('#ADGroup').find('input[type="submit"]').click(); + } + else{ + $.post({ + url : 'inc/infrastructure/UpdateADGroups.php', + data: { + type : 'new', + group_name : $('#GroupName').val(), + }, + success:function (data) { + var reply=jQuery.parseJSON(data); + if ("error" in reply) + showAlert("Error", reply.error, "fa fa-exclamation-triangle fa-fw", "error"); + if ("success" in reply) + showAlert("Success", reply.success, "fa fa-check-circle-o fa-fw", "success"); + refresh_screen(); + $("#GroupName").val(""); + } + }); + } + }); }); diff --git a/update_ad_groups.php b/update_ad_groups.php deleted file mode 100644 index 44c0387..0000000 --- a/update_ad_groups.php +++ /dev/null @@ -1,34 +0,0 @@ -