/[scire]/scire/user.php
Gentoo

Contents of /scire/user.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 128 - (show annotations) (download)
Sat Jul 15 05:21:58 2006 UTC (11 years, 10 months ago) by codeman
File size: 6191 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", "users.php");
8
9
10 $userid = "";
11
12 #####################################################
13 #Deal with submitted forms.
14
15 ###############################################
16 #Adding a user to usergroups.
17 if ($_POST['addgroup_confirm']) {
18 $ingroups = $acl->get_object_groups($_POST['gacl_userid'],'ARO');
19 $userdata = $acl->get_object_data($_POST['gacl_userid'], 'ARO');
20 $newgroups = $_POST['addgroupid'];
21 #remove first.
22 foreach ($ingroups as $ingroup) {
23 if (!in_array($ingroup, $newgroups)) {
24 $acl->del_group_object($ingroup, $userdata[0][0], $userdata[0][1], 'ARO');
25 }
26 }
27 foreach ($newgroups as $newgroup) {
28 print "newgroup: $newgroup";
29 $acl->add_group_object($newgroup, $userdata[0][0], $userdata[0][1], 'ARO');
30 }
31 $_GET['Action'] = "edit";
32 $_GET['userid'] = $_POST['userid'];
33 }
34
35 ###############################################
36 # Adding a user.
37 if ($_POST['addusername']) {
38 if ($_POST['passwd'] == $_POST['passwd2']) {
39 if ($_POST['addusername'] and $_POST['passwd'] and $_POST['email']) {
40 $status = scire_add_user($_POST['addusername'], $_POST['passwd'], $_POST['real_name'], $_POST['comment'], $_POST['email'], $_POST['phone'], $_POST['pager']);
41 if ($status == 1) { $status = "User Addition successfull"; }
42 $obj_id = $acl->add_object("users", $_POST['addusername'], $_POST['addusername'], 1, 0, 'ARO');
43 #print "Object id: $obj_id <BR>";
44 if ($_POST['groups']) {
45 #print "Adding user to groups ".$_POST['groups'];
46 foreach( $_POST['groups'] as $group) {
47 $worked = $acl->add_group_object($group, "users", $_POST['addusername'], 'ARO');
48 #if ($worked) {
49 # print "Group $group Addition successfull.<br>";
50 #} else {
51 # print "ERROR adding group $group <br>";
52 #}
53 }
54 }
55 } else {
56 $status = "Error required fields are not filled!";
57 }
58 } else {
59 $status = "Error passwords do not match!";
60 }
61 header('Location: ' . $baseurl . 'users.php');
62 }
63 ###############################################
64 # Editing a user's information.
65 if ($_POST['editusername']) {
66 $userinfo = get_scire_user($_GET['userid']);
67 $smarty->assign('user', $userinfo);
68
69 if ($_POST['real_name'] and ($_POST['real_name'] != $userinfo['real_name'])) {
70 $fields['real_name'] = $_POST['real_name'];
71 }
72 if ($_POST['comment'] and ($_POST['comment'] != $userinfo['comment'])){
73 $fields['comment'] = $_POST['comment'];
74 }
75 if ($_POST['email'] and ($_POST['email'] != $userinfo['email'])) {
76 $fields['email'] = $_POST['email'];
77 }
78 if ($_POST['phone'] and ($_POST['phone'] != $userinfo['phone'])) {
79 $fields['phone'] = $_POST['phone'];
80 }
81 if ($_POST['pager'] and ($_POST['pager'] != $userinfo['pager'])) {
82 $fields['pager'] = $_POST['pager'];
83 }
84 #special case for hostname, must change the ACLs
85 if ($_POST['editusername'] and ($_POST['editusername'] != $userinfo['username'])) {
86 $fields['username'] = $_POST['editusername'];
87 $result = $acl->edit_object($_POST['gacl_userid'],"users", $_POST['editusername'], $_POST['editusername'],1, 0, 'ARO');
88 }
89
90
91 $status = scire_edit_user($_POST['userid'], $fields);
92 $_GET['Action'] = "edit";
93 $_GET['userid'] = $_POST['userid'];
94 }
95
96 ###############################################
97 # Delete a user.
98 if ($_POST['delete_confirm']) {
99 $status = scire_del_user($_POST['userid']);
100 $id = $acl->get_object_id("users", $_POST['gacl_userid'], 'ARO');
101 $acl->del_object($id, 'ARO', TRUE); #True means erase referencing objects.
102 header('Location: ' . $baseurl . 'users.php');
103 }
104
105 switch($_GET['Action']) {
106 case "addgroup":
107 $smarty->assign('userid', $_GET['userid']);
108 $smarty->assign('groups', $acl->format_groups($acl->sort_groups('aro'), TEXT));
109 $smarty->assign('gacl_userid', $_GET['gacl_userid']);
110 $ingroups = array();
111 $ingroups = $acl->get_object_groups($_GET['gacl_userid'],'ARO');
112 #var_dump($ingroups);
113 $smarty->assign('ingroups', $ingroups);
114 case "create":
115 $smarty->assign('desc', "Add a user.");
116 $smarty->assign('groups', $acl->format_groups($acl->sort_groups('aro'), TEXT));
117 break;
118 case "edit":
119 $acls = array();
120 #make the topbar look good
121 $smarty->assign('desc', "Edit user information.");
122 $userinfo = get_scire_user($_GET['userid']);
123 $smarty->assign('user', $userinfo);
124
125 $usergroups = array();
126 $id = $acl->get_object_id("users",$userinfo['username'],'ARO');
127 $smarty->assign('gacl_userid', $id);
128 $groups = $acl->get_object_groups($id,'ARO');
129 if ($groups) {
130 foreach ($groups as $group) {
131 $group_data = $acl->get_group_data($group, 'ARO');
132 $usergroups_entry['name'] = $group_data[3];
133 $usergroups_entry['id'] = $group_data[0];
134 if ($group_data[1]) {
135 $parent_group_data = $acl->get_group_data($group_data[1],'ARO');
136 $usergroups_entry['parent'] = $parent_group_data[3];
137 } else {
138 $usergroups_entry['parent'] = "";
139 }
140 array_push($usergroups, $usergroups_entry);
141 $result_acl_ids = $acl->search_acl(FALSE,FALSE,
142 FALSE,FALSE,FALSE,
143 FALSE,FALSE,$group_data[3],FALSE);
144 foreach ($result_acl_ids as $acl_id) {
145 array_push($acls, $acl->get_acl($acl_id));
146 }
147 }
148 }
149 $smarty->assign('groups', $usergroups);
150 $cgroups = $acl->format_groups($acl->sort_groups('axo'), 'ARRAY');
151 $smarty->assign('cgroups', $cgroups);
152 #Format of search: aco_section, aco_value, aro_section, aro_value, aro_group_name, axo_section, axo_value, axo_group_name, return_value
153 $result_acl_ids = $acl->search_acl(FALSE,FALSE,
154 'users',$userinfo['username'],FALSE,
155 FALSE,FALSE,FALSE,FALSE);
156 foreach ($result_acl_ids as $acl_id) {
157 array_push($acls, $acl->get_acl($acl_id));
158 }
159 #pre_var_dump($acls);
160 $smarty->assign('acls',$acls);
161 break;
162 case "delete":
163 $userinfo = get_scire_user($_GET['userid']);
164 $smarty->assign('user', $userinfo);
165 $id = $acl->get_object_id("users",$userinfo['username'],'ARO');
166 $smarty->assign('gacl_userid', $id);
167 break;
168 }
169
170
171 $smarty->assign('leftbar_menu', $leftbar_menu);
172 $smarty->assign('Action', $_GET['Action']);
173 $smarty->assign('status', $status);
174 $smarty->display('user.tpl');
175 #var_dump($_POST);
176 ?>

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20