/[scire]/scire/client.php
Gentoo

Contents of /scire/client.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 128 - (show annotations) (download)
Sat Jul 15 05:21:58 2006 UTC (12 years, 1 month ago) by codeman
File size: 7148 byte(s)
various updates regarding permissions
added categories to the code, so that permissions
can be grouped.  A special group will consist of
Scire UI permissions.

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 $acls = array();
130 #make the topbar look good
131 $smarty->assign('desc', "Edit client information.");
132 $clientinfo = get_scire_client($_GET['clientid']);
133 $smarty->assign('client', $clientinfo);
134 $smarty->assign('gli_profiles', get_scire_gli_profiles());
135 $smarty->assign('oss', get_scire_oss());
136 $smarty->assign('users', get_scire_users('username', 'desc'));
137
138 $clientgroups = array();
139 $id = $acl->get_object_id("clients",$clientinfo['hostname'],'AXO');
140 $smarty->assign('gacl_clientid', $id);
141 $groups = $acl->get_object_groups($id,'AXO');
142 if ($groups) {
143 foreach ($groups as $group) {
144 $group_data = $acl->get_group_data($group, 'AXO');
145 $clientgroups_entry['name'] = $group_data[3];
146 $clientgroups_entry['id'] = $group_data[0];
147 if ($group_data[1]) {
148 $parent_group_data = $acl->get_group_data($group_data[1],'AXO');
149 $clientgroups_entry['parent'] = $parent_group_data[3];
150 } else {
151 $clientgroups_entry['parent'] = "";
152 }
153 array_push($clientgroups, $clientgroups_entry);
154 $result_acl_ids = $acl->search_acl(FALSE,FALSE,
155 FALSE,FALSE,FALSE,
156 FALSE,FALSE,$group_data[3],FALSE);
157 foreach ($result_acl_ids as $acl_id) {
158 array_push($acls, $acl->get_acl($acl_id));
159 }
160 }
161 }
162 $smarty->assign('groups', $clientgroups);
163
164 $ugroups = $acl->format_groups($acl->sort_groups('aro'), 'ARRAY');
165 $smarty->assign('ugroups', $ugroups);
166
167 #Format of search: aco_section, aco_value, aro_section, aro_value, aro_group_name, axo_section, axo_value, axo_group_name, return_value
168 $result_acl_ids = $acl->search_acl(FALSE,FALSE,
169 FALSE,FALSE,FALSE,
170 'clients',$clientinfo['hostname'],FALSE,FALSE);
171 foreach ($result_acl_ids as $acl_id) {
172 array_push($acls, $acl->get_acl($acl_id));
173 }
174 #pre_var_dump($acls);
175 $smarty->assign('acls',$acls);
176 break;
177 case "delete":
178 $clientinfo = get_scire_client($_GET['clientid']);
179 $smarty->assign('client', $clientinfo);
180 $id = $acl->get_object_id("clients",$clientinfo['hostname'],'AXO');
181 $smarty->assign('gacl_clientid', $id);
182 break;
183 }
184
185
186 $smarty->assign('leftbar_menu', $leftbar_menu);
187 $smarty->assign('Action', $_GET['Action']);
188 $smarty->assign('status', $status);
189 $smarty->display('client.tpl');
190 #pre_var_dump($_POST);
191 ?>

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20