/[scire]/scire/client.php
Gentoo

Diff of /scire/client.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 98 Revision 99
33} 33}
34 34
35############################################### 35###############################################
36# Adding a client. 36# Adding a client.
37if ($_POST['addhostname']) { 37if ($_POST['addhostname']) {
38 if ($_POST['passwd'] == $_POST['passwd2']) {
39 if ($_POST['addhostname'] and $_POST['passwd'] and $_POST['email']) { 38 if ($_POST['addhostname'] and $_POST['ip'] and $_POST['mac']) {
40 $status = scire_add_client($_POST['addhostname'], $_POST['passwd'], $_POST['real_name'], $_POST['comment'], $_POST['email'], $_POST['phone'], $_POST['pager']); 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']);
41 if ($status == 1) { $status = "Client Addition successfull"; } 40 if ($status == 1) { $status = "Client Addition successfull"; }
42 $obj_id = $acl->add_object("clients", $_POST['addhostname'], $_POST['addhostname'], 1, 0, 'AXO'); 41 $obj_id = $acl->add_object("clients", $_POST['addhostname'], $_POST['addhostname'], 1, 0, 'AXO');
43 #print "Object id: $obj_id <BR>"; 42 #print "Object id: $obj_id <BR>";
44 if ($_POST['groups']) { 43 if ($_POST['groups']) {
45 #print "Adding client to groups ".$_POST['groups']; 44 #print "Adding client to groups ".$_POST['groups'];
46 foreach( $_POST['groups'] as $group) { 45 foreach( $_POST['groups'] as $group) {
47 $worked = $acl->add_group_object($group, "clients", $_POST['addhostname'], 'AXO'); 46 $worked = $acl->add_group_object($group, "clients", $_POST['addhostname'], 'AXO');
48 #if ($worked) { 47 #if ($worked) {
49 # print "Group $group Addition successfull.<br>"; 48 # print "Group $group Addition successfull.<br>";
50 #} else { 49 #} else {
51 # print "ERROR adding group $group <br>"; 50 # print "ERROR adding group $group <br>";
52 #} 51 #}
53 }
54 } 52 }
55 } else {
56 $status = "Error required fields are not filled!";
57 } 53 }
58 } else { 54 } else {
59 $status = "Error passwords do not match!"; 55 $status = "Error required fields are not filled!";
60 } 56 }
61 header('Location: ' . $baseurl . 'clients.php'); 57 header('Location: ' . $baseurl . 'clients.php');
62} 58}
63############################################### 59###############################################
64# Editing a client's information. 60# Editing a client's information.
65if ($_POST['edithostname']) { 61if ($_POST['edithostname']) {
66 $clientinfo = get_scire_client($_GET['clientid']); 62 $clientinfo = get_scire_client($_GET['clientid']);
67 $smarty->assign('client', $clientinfo); 63 $smarty->assign('client', $clientinfo);
68 64
69 if ($_POST['real_name'] and ($_POST['real_name'] != $clientinfo['real_name'])) { 65 if ($_POST['digest'] and ($_POST['digest'] != $clientinfo['digest'])) {
70 $fields['real_name'] = $_POST['real_name']; 66 $fields['digest'] = $_POST['digest'];
71 } 67 }
72 if ($_POST['comment'] and ($_POST['comment'] != $clientinfo['comment'])){ 68 if ($_POST['mac'] and ($_POST['mac'] != $clientinfo['mac'])){
73 $fields['comment'] = $_POST['comment']; 69 $fields['mac'] = $_POST['mac'];
74 } 70 }
75 if ($_POST['email'] and ($_POST['email'] != $clientinfo['email'])) { 71 if ($_POST['ip'] and ($_POST['ip'] != $clientinfo['ip'])) {
76 $fields['email'] = $_POST['email']; 72 $fields['ip'] = $_POST['ip'];
77 } 73 }
78 if ($_POST['phone'] and ($_POST['phone'] != $clientinfo['phone'])) { 74 if ($_POST['gli_profile'] and ($_POST['gli_profile'] != $clientinfo['gli_profile'])) {
79 $fields['phone'] = $_POST['phone']; 75 $fields['gli_profile'] = $_POST['gli_profile'];
80 } 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 }
81 if ($_POST['pager'] and ($_POST['pager'] != $clientinfo['pager'])) { 89 if ($_POST['assetid'] and ($_POST['assetid'] != $clientinfo['assetid'])) {
82 $fields['pager'] = $_POST['pager']; 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');
83 } 96 }
84 $status = scire_edit_client($_POST['clientid'], $fields); 97 $status = scire_edit_client($_POST['clientid'], $fields);
85 $_GET['Action'] = "edit"; 98 $_GET['Action'] = "edit";
86 $_GET['clientid'] = $_POST['clientid']; 99 $_GET['clientid'] = $_POST['clientid'];
87} 100}
106 var_dump($ingroups); 119 var_dump($ingroups);
107 $smarty->assign('ingroups', $ingroups); 120 $smarty->assign('ingroups', $ingroups);
108 case "create": 121 case "create":
109 $smarty->assign('desc', "Add a client."); 122 $smarty->assign('desc', "Add a client.");
110 $smarty->assign('groups', $acl->format_groups($acl->sort_groups('AXO'), TEXT)); 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'));
111 break; 127 break;
112 case "edit": 128 case "edit":
113 #make the topbar look good 129 #make the topbar look good
114 $smarty->assign('desc', "Edit client information."); 130 $smarty->assign('desc', "Edit client information.");
115 $clientinfo = get_scire_client($_GET['clientid']); 131 $clientinfo = get_scire_client($_GET['clientid']);
116 $smarty->assign('client', $clientinfo); 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'));
117 136
118 $clientgroups = array(); 137 $clientgroups = array();
119 $id = $acl->get_object_id("clients",$clientinfo['hostname'],'AXO'); 138 $id = $acl->get_object_id("clients",$clientinfo['hostname'],'AXO');
120 $smarty->assign('gacl_clientid', $id); 139 $smarty->assign('gacl_clientid', $id);
121 $groups = $acl->get_object_groups($id,'AXO'); 140 $groups = $acl->get_object_groups($id,'AXO');

Legend:
Removed from v.98  
changed lines
  Added in v.99

  ViewVC Help
Powered by ViewVC 1.1.20