/[scire]/scire/client.php
Gentoo

Contents of /scire/client.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 99 - (show annotations) (download)
Wed Jun 14 01:52:27 2006 UTC (12 years, 1 month ago) by codeman
File size: 6352 byte(s)
 various updates around the board.  mainly focusing on client and user
 pages.  some DB updates and asthetic changes.
 preparing for user sessions


1 <?php
2 include('.lib/common.php');
3
4 $smarty->assign('leftbar', "on");
5 $leftbar_menu = array();
6
7 add_leftbar($leftbar_menu, "&#171;&#171;Cancel", "clients.php");
8
9
10 $clientid = "";
11
12 #####################################################
13 #Deal with submitted forms.
14
15 ###############################################
16 #Adding a client to clientgroups.
17 if ($_POST['addgroup_confirm']) {
18 $ingroups = $acl->get_object_groups($_POST['gacl_clientid'],'AXO');
19 $clientdata = $acl->get_object_data($_POST['gacl_clientid'], 'AXO');
20 $newgroups = $_POST['addgroupid'];
21 #remove first.
22 foreach ($ingroups as $ingroup) {
23 if (!in_array($ingroup, $newgroups)) {
24 $acl->del_group_object($ingroup, $clientdata[0][0], $clientdata[0][1], 'AXO');
25 }
26 }
27 foreach ($newgroups as $newgroup) {
28 print "newgroup: $newgroup";
29 $acl->add_group_object($newgroup, $clientdata[0][0], $clientdata[0][1], 'AXO');
30 }
31 $_GET['Action'] = "edit";
32 $_GET['clientid'] = $_POST['clientid'];
33 }
34
35 ###############################################
36 # Adding a client.
37 if ($_POST['addhostname']) {
38 if ($_POST['addhostname'] and $_POST['ip'] and $_POST['mac']) {
39 $status = scire_add_client($_POST['digest'], $_POST['addhostname'], $_POST['mac'], $_POST['ip'], $_POST['gli_profile'], $_POST['osid'], $_POST['contact'], $_POST['status'], $_POST['installtime'], $_POST['assetid']);
40 if ($status == 1) { $status = "Client Addition successfull"; }
41 $obj_id = $acl->add_object("clients", $_POST['addhostname'], $_POST['addhostname'], 1, 0, 'AXO');
42 #print "Object id: $obj_id <BR>";
43 if ($_POST['groups']) {
44 #print "Adding client to groups ".$_POST['groups'];
45 foreach( $_POST['groups'] as $group) {
46 $worked = $acl->add_group_object($group, "clients", $_POST['addhostname'], 'AXO');
47 #if ($worked) {
48 # print "Group $group Addition successfull.<br>";
49 #} else {
50 # print "ERROR adding group $group <br>";
51 #}
52 }
53 }
54 } else {
55 $status = "Error required fields are not filled!";
56 }
57 header('Location: ' . $baseurl . 'clients.php');
58 }
59 ###############################################
60 # Editing a client's information.
61 if ($_POST['edithostname']) {
62 $clientinfo = get_scire_client($_GET['clientid']);
63 $smarty->assign('client', $clientinfo);
64
65 if ($_POST['digest'] and ($_POST['digest'] != $clientinfo['digest'])) {
66 $fields['digest'] = $_POST['digest'];
67 }
68 if ($_POST['mac'] and ($_POST['mac'] != $clientinfo['mac'])){
69 $fields['mac'] = $_POST['mac'];
70 }
71 if ($_POST['ip'] and ($_POST['ip'] != $clientinfo['ip'])) {
72 $fields['ip'] = $_POST['ip'];
73 }
74 if ($_POST['gli_profile'] and ($_POST['gli_profile'] != $clientinfo['gli_profile'])) {
75 $fields['gli_profile'] = $_POST['gli_profile'];
76 }
77 if ($_POST['osid'] and ($_POST['osid'] != $clientinfo['osid'])) {
78 $fields['osid'] = $_POST['osid'];
79 }
80 if ($_POST['contact'] and ($_POST['contact'] != $clientinfo['contact'])) {
81 $fields['contact'] = $_POST['contact'];
82 }
83 if ($_POST['status'] and ($_POST['status'] != $clientinfo['status'])) {
84 $fields['status'] = $_POST['status'];
85 }
86 if ($_POST['installtime'] and ($_POST['installtime'] != $clientinfo['installtime'])) {
87 $fields['installtime'] = $_POST['installtime'];
88 }
89 if ($_POST['assetid'] and ($_POST['assetid'] != $clientinfo['assetid'])) {
90 $fields['assetid'] = $_POST['assetid'];
91 }
92 #special case for hostname, must change the ACLs
93 if ($_POST['edithostname'] and ($_POST['edithostname'] != $clientinfo['hostname'])) {
94 $fields['hostname'] = $_POST['edithostname'];
95 $result = $acl->edit_object($_POST['gacl_clientid'],"clients", $_POST['edithostname'], $_POST['edithostname'],1, 0, 'AXO');
96 }
97 $status = scire_edit_client($_POST['clientid'], $fields);
98 $_GET['Action'] = "edit";
99 $_GET['clientid'] = $_POST['clientid'];
100 }
101
102 ###############################################
103 # Delete a client.
104 if ($_POST['delete_confirm']) {
105 $status = scire_del_client($_POST['clientid']);
106 $id = $acl->get_object_id("clients", $_POST['gacl_clientid'], 'AXO');
107 $acl->del_object($id, 'AXO', TRUE); #True means erase referencing objects.
108 header('Location: ' . $baseurl . 'clients.php');
109 }
110
111 switch($_GET['Action']) {
112 case "addgroup":
113 $smarty->assign('desc', "Add a client to a client group.");
114 $smarty->assign('clientid', $_GET['clientid']);
115 $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT));
116 $smarty->assign('gacl_clientid', $_GET['gacl_clientid']);
117 $ingroups = array();
118 $ingroups = $acl->get_object_groups($_GET['gacl_clientid'],'AXO');
119 var_dump($ingroups);
120 $smarty->assign('ingroups', $ingroups);
121 case "create":
122 $smarty->assign('desc', "Add a client.");
123 $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT));
124 $smarty->assign('gli_profiles', get_scire_gli_profiles());
125 $smarty->assign('oss', get_scire_oss());
126 $smarty->assign('users', get_scire_users('username', 'desc'));
127 break;
128 case "edit":
129 #make the topbar look good
130 $smarty->assign('desc', "Edit client information.");
131 $clientinfo = get_scire_client($_GET['clientid']);
132 $smarty->assign('client', $clientinfo);
133 $smarty->assign('gli_profiles', get_scire_gli_profiles());
134 $smarty->assign('oss', get_scire_oss());
135 $smarty->assign('users', get_scire_users('username', 'desc'));
136
137 $clientgroups = array();
138 $id = $acl->get_object_id("clients",$clientinfo['hostname'],'AXO');
139 $smarty->assign('gacl_clientid', $id);
140 $groups = $acl->get_object_groups($id,'AXO');
141 if ($groups) {
142 foreach ($groups as $group) {
143 $group_data = $acl->get_group_data($group, 'AXO');
144 $clientgroups_entry['name'] = $group_data[3];
145 $clientgroups_entry['id'] = $group_data[0];
146 if ($group_data[1]) {
147 $parent_group_data = $acl->get_group_data($group_data[1],'AXO');
148 $clientgroups_entry['parent'] = $parent_group_data[3];
149 } else {
150 $clientgroups_entry['parent'] = "";
151 }
152 array_push($clientgroups, $clientgroups_entry);
153 }
154 }
155 $smarty->assign('groups', $clientgroups);
156 break;
157 case "delete":
158 $clientinfo = get_scire_client($_GET['clientid']);
159 $smarty->assign('client', $clientinfo);
160 $id = $acl->get_object_id("clients",$clientinfo['hostname'],'AXO');
161 $smarty->assign('gacl_clientid', $id);
162 break;
163 }
164
165
166 $smarty->assign('leftbar_menu', $leftbar_menu);
167 $smarty->assign('Action', $_GET['Action']);
168 $smarty->assign('status', $status);
169 $smarty->display('client.tpl');
170 var_dump($_POST);
171 ?>

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20