/[scire]/scire/clients.php
Gentoo

Contents of /scire/clients.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 186 - (show annotations) (download)
Sat Mar 17 03:23:00 2007 UTC (11 years, 6 months ago) by codeman
File size: 7451 byte(s)
adding a line to grab/use the default value if none is already set.

1 <?php
2 include('.lib/common.php');
3
4 $smarty->assign('leftbar', "on");
5 $leftbar_menu = array();
6 $leftbar_submenu = array();
7 $template = "clients.tpl";
8 $status = "";
9 $smarty->assign('statusfilters', array('', 'Pending','Active','Inactive','Rejected','Retired', 'All'));
10
11 ############################################
12 ## Deal with submitted forms first.
13 if ($_POST['addgroupname']) { #Adding a group.
14 if (!$_POST['parentgroup']) {
15 $_POST['parentgroup'] = 0;
16 }
17 $newgroup_id = $acl->add_group($_POST['addgroupname'], $_POST['addgroupname'], $_POST['parentgroup'], 'AXO');
18 $_GET['Action'] = "created";
19 $_GET['View'] = "groups";
20 $status = "Client Group Created Successfully.";
21 }
22 if ($_POST['editgroupname']) {
23 $group_id = $acl->edit_group($_POST['groupid'], $_POST['editgroupname'], $_POST['editgroupname'], $_POST['parentgroup'], 'AXO');
24 $_GET['Action'] = "edited";
25 $_GET['View'] = "groups";
26 $status = "Client Group Edited Successfully.";
27 }
28 if($_POST['delgroup_confirm']) {
29 #Check if the group has children.
30 $result = $acl->del_group($_POST['delgroup'],TRUE, 'AXO');
31 if ($result) {
32 $status = "Group deleted successfully.";
33 } else {
34 $status = "ERROR: Group could not be successfully deleted.";
35 }
36 $_GET['Action'] = "deleted";
37 $_GET['View'] = "groups";
38 }
39 #Admin access only.
40 if($_POST['pend_approve']) {
41 foreach ($_POST['pending_ids'] as $pend_id) {
42 $result = scire_approve_client($pend_id);
43 if ($result) {
44 $status .= "Client $pend_id approved successfully.";
45 $clientinfo = get_scire_client($pend_id);
46 $obj_id = $acl->add_object("clients", $clientinfo['hostname'], $clientinfo['hostname'], 1, 0, 'AXO');
47 print "Object id: $obj_id <BR>";
48 } else {
49 $status .= "ERROR: Client $pend_id could not be successfully approved.";
50 }
51 }
52 }
53 if($_POST['pend_reject']) {
54 foreach ($_POST['pending_ids'] as $pend_id) {
55 $result = scire_reject_client($pend_id);
56 if ($result) {
57 $status .= "Client $pend_id rejected!";
58 } else {
59 $status .= "ERROR: Client $pend_id could not be successfully rejected.";
60 }
61 }
62 }
63
64
65 if($_POST['statusfilter']) {
66 $_GET['View'] = $_POST['statusfilter'];
67 }
68
69
70
71
72 $smarty->assign('desc', "View, create, edit, and delete clients");
73
74 ########################################
75 # Generate content
76
77 switch($_GET['View']) {
78 case "groups":
79 $template = "clients_groups.tpl";
80 switch($_GET['Action']) {
81 case "create":
82 add_leftbar($leftbar_menu, "&#171;&#171;Cancel", "clients.php?View=groups");
83 $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT));
84 break;
85 case "edit":
86 add_leftbar($leftbar_menu, "&#171;&#171;Cancel", "clients.php?View=groups");
87 $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT));
88 $smarty->assign('groupid', $_GET['groupid']);
89 $smarty->assign('groupdata', $acl->get_group_data($_GET['groupid'], 'AXO'));
90 break;
91 case "delete":
92 add_leftbar($leftbar_menu, "&#171;&#171;Cancel", "clients.php?View=groups");
93 $smarty->assign('groupid', $_GET['groupid']);
94 break;
95 default: #Show clientgroups.
96 add_leftbar($leftbar_menu, "Clients", "clients.php");
97 add_leftbar($leftbar_menu, "Permissions", "clients.php?View=permissions");
98 $smarty->assign('leftbar_submenu_title', "Actions");
99 add_leftbar($leftbar_submenu, "Create Client Group", "clients.php?View=groups&Action=create");
100
101
102 $groups = $acl->format_groups($acl->sort_groups('AXO'), HTML);
103 $smarty->assign('groups', $groups);
104
105 break;
106 }
107 break;
108 case "permissions":
109 $smarty->assign('leftbar_submenu_title', "Actions");
110 add_leftbar($leftbar_submenu, "Assign Permission", "assign_permission.php");
111 $template = "permissions.tpl";
112 $smarty->assign('type','clients');
113 $ugroups = $acl->format_groups($acl->sort_groups('aro'), 'ARRAY');
114 $smarty->assign('ugroups', $ugroups);
115 $cgroups = $acl->format_groups($acl->sort_groups('axo'), 'ARRAY');
116 $smarty->assign('cgroups', $cgroups);
117
118 #pre_var_dump($groups);
119
120 $acls = array();
121 #Format of search: aco_section, aco_value, aro_section, aro_value, aro_group_name, axo_section, axo_value, axo_group_name, return_value
122 $result_acl_ids = $acl->search_acl(FALSE,FALSE,
123 FALSE,FALSE,FALSE,
124 FALSE,FALSE,FALSE,FALSE);
125 foreach ($result_acl_ids as $acl_id) {
126 $this_acl = $acl->get_acl($acl_id);
127 if ($this_acl['aco']['scire_ui']) {
128 next;
129 } else {
130 array_push($acls, $this_acl);
131 }
132 }
133 #pre_var_dump($acls);
134 $smarty->assign('acls',$acls);
135 break;
136 case "Pending":
137 case "Inactive":
138 case "Rejected":
139 case "Retired":
140 case "All":
141 #Will need to grab only pending clients. Will need to hardcode the field list unless making settings for it.
142 add_leftbar($leftbar_menu, "View Groups", "clients.php?View=groups");
143 add_leftbar($leftbar_menu, "View Permissions", "clients.php?View=permissions");
144
145 #Set information about the fields (display name, sortable)
146 $f_attr = get_clients_fields();
147 $smarty->assign('f_attr', $f_attr);
148
149 if (!$_GET['sorton']) {
150 $_GET['sorton'] = 'installtime';
151 }
152 if (!$_GET['sortdir']) {
153 $_GET['sortdir'] = 'asc';
154 }
155 $smarty->assign('sorton', $_GET['sorton']);
156 $smarty->assign('sortdir', $_GET['sortdir']);
157
158 #Grab the field list.
159 $fields = explode(',', $_SESSION['settings']['clients_page_fields']);
160 $fields = array("hostname", "ip", "mac", "digest", "status", "installtime");
161 $smarty->assign('fields',$fields);
162
163 $clients = get_scire_clients($_GET['sorton'], $_GET['sortdir'], $_GET['View']);
164 $smarty->assign('clients', $clients);
165 break;
166 default: #Show clients.
167 add_leftbar($leftbar_menu, "View Groups", "clients.php?View=groups");
168 add_leftbar($leftbar_menu, "View Permissions", "clients.php?View=permissions");
169 $smarty->assign('leftbar_submenu_title', "Actions");
170 add_leftbar($leftbar_submenu, "Create Client", "client.php?Action=create");
171
172 ############################################
173 ## Deal with sorting for the query.
174 if (!$_GET['sorton']) {
175 $_GET['sorton'] = $_SESSION['settings']['clients_page_sorton'];
176 }
177 if (!$_GET['sortdir']) {
178 $_GET['sortdir'] = $_SESSION['settings']['clients_page_sortdir'];
179 }
180 $smarty->assign('sorton', $_GET['sorton']);
181 $smarty->assign('sortdir', $_GET['sortdir']);
182
183 $clients = get_scire_clients($_GET['sorton'], $_GET['sortdir']);
184 #var_dump($clients);
185 foreach ($clients as $key => $client) {
186 $id = $acl->get_object_id("clients",$client['hostname'],'AXO');
187 $groups = $acl->get_object_groups($id,'AXO');
188 $group_string = "";
189 if ($groups) {
190 foreach ($groups as $group) {
191 $group_data = $acl->get_group_data($group, 'AXO');
192 $group_string .= $group_data[3]. " | ";
193 }
194 }
195 $clients[$key]['groups'] = $group_string;
196 }
197
198 #Set information about the fields (display name, sortable)
199 $f_attr = get_clients_fields();
200 $smarty->assign('f_attr', $f_attr);
201
202 #Grab the field list.
203 if ($_SESSION['settings']['clients_page_fields']) {
204 $fields = explode(',', $_SESSION['settings']['clients_page_fields']);
205 } else {
206 $fields = explode(',', get_default_clients_fields());
207 }
208 $smarty->assign('fields',$fields);
209
210 $smarty->assign('clients', $clients);
211 break;
212 }
213
214 $smarty->assign('leftbar_menu', $leftbar_menu);
215 $smarty->assign('leftbar_submenu', $leftbar_submenu);
216 $smarty->assign('View', $_GET['View']);
217 $smarty->assign('Action', $_GET['Action']);
218 $smarty->assign('status', $status);
219 $smarty->display($template);
220 #var_dump($_POST);
221 ?>

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20