-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuser_edit_attribute.php
149 lines (132 loc) · 5.33 KB
/
user_edit_attribute.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
// edit an attribute of user
// $Id: user_edit_attribute.php,v 2.67 2007-11-20 11:50:03 turbo Exp $
//
// This file gets iterated through at least 2 times for any attribute (sequenced by "$submit"):
// 1) $submit is unset: Set the default value of the attribute (usually from "$oldvalue")
// and print out the form.
// 2) $submit is 1 (or 2?): Validate the input. The name of the input variable changes depending on
// which attribute is being edited.
// If the input is valid, save it, else print out the form again and return to step 2.
// {{{ Setup session etc
require("./include/pql_session.inc");
require($_SESSION["path"]."/include/pql_config.inc");
require($_SESSION["path"]."/include/config_plugins.inc");
require($_SESSION["path"]."/include/pql_krbafs.inc");
require($_SESSION["path"]."/include/pql_ppolicy.inc");
$url["domain"] = pql_format_urls($_REQUEST["domain"]);
$url["rootdn"] = pql_format_urls($_REQUEST["rootdn"]);
$url["user"] = pql_format_urls($_REQUEST["user"]);
require_once($_SESSION["path"]."/include/dlw_porting.inc");
// These variable are "_GET" the first time, and "_POST" the other times.
if (empty($session)) {
dlw_expect_from(__FILE__, __LINE__, '_REQUEST', array('domain', 'user', 'rootdn', 'oldvalue', 'view', 'attrib', 'PHPSESSID'));
dlw_expect_from(__FILE__, __LINE__, '_POST', array());
} else {
dlw_expect_from(__FILE__, __LINE__, '_POST', array('domain', 'user', 'rootdn', 'oldvalue', 'view', 'attrib', 'submit'));
}
$_pql = new pql($_SESSION["USER_HOST"], $_SESSION["USER_DN"], $_SESSION["USER_PASS"]);
include($_SESSION["path"]."/header.html");
// }}}
// {{{ Get some default values
if(!$_REQUEST["domain"] && $_REQUEST["user"]) {
// We're called without branchname - try to reconstruct it
$tmpdn = explode(',', $_REQUEST["user"]);
if($tmpdn[1]) {
unset($tmpdn[0]);
$_REQUEST["domain"] = implode(",", $tmpdn);
} else
$_REQUEST["domain"] = $tmpdn[count($tmpdn)-1];
}
// Get default domain name for this domain
$defaultdomain = $_pql->get_attribute($_REQUEST["domain"], pql_get_define("PQL_ATTR_DEFAULTDOMAIN"));
// Get the username. Prettier than the DN
$username = $_pql->get_attribute($_REQUEST["user"], pql_get_define("PQL_ATTR_CN"));
if(!$username) {
// No common name, use uid field
$username = $_pql->get_attribute($_REQUEST["user"], pql_get_define("PQL_ATTR_UID"));
} elseif(is_array($username)) {
$username = $username[0];
}
// }}}
// {{{ Forward back to users detail page (called by attribute_save).
function attribute_forward($msg, $rlnb = false) {
$url["domain"] = pql_format_urls($_REQUEST["domain"]);
$url["rootdn"] = pql_format_urls($_REQUEST["rootdn"]);
$url["user"] = pql_format_urls($_REQUEST["user"]);
$link = "user_detail.php?rootdn=" . $url["rootdn"] . "&domain=" . $url["domain"]
. "&user=" . $url["user"] . "&view=" . $_REQUEST["view"] . "&msg=".urlencode($msg);
if ($rlnb)
$link .= "&rlnb=2";
pql_header($link);
}
// }}}
// {{{ Select (and load) which attribute have to be included
$plugin = pql_plugin_get_filename(pql_plugin_get($_REQUEST["attrib"]));
if(!$plugin) {
die("<span class=\"error\">ERROR: No plugin file defined for attribute '<i>".$_REQUEST["attrib"]."</i>'</span>");
} elseif(!file_exists($_SESSION["path"]."/include/$plugin")) {
die("<span class=\"error\">ERROR: Plugin file defined for attribute '<i>".$_REQUEST["attrib"]."</i>' does not exists!</span>");
}
if(pql_get_define("PQL_CONF_DEBUG_ME")) {
echo "include: include/$plugin<br>";
}
include($_SESSION["path"]."/include/$plugin");
// }}}
?>
<span class="title1"><?php echo pql_complete_constant($LANG->_('Change user data for %user%'), array('user' => $username)); ?></span>
<br><br>
<?php
if(pql_get_define("PQL_CONF_DEBUG_ME")) {
echo "REQUEST:";
ksort($_REQUEST);
printr($_REQUEST);
}
// {{{ Select what to do
// DLW: One of these days this submit==1 stuff has to be replaced with
// human readable text such as submit="verify".
if(empty($_REQUEST["submit"])) {
$_REQUEST["submit"] = 0;
}
if(($_REQUEST["submit"] == 1) or ($_REQUEST["submit"] == 2)) {
if(attribute_check("modify")) {
attribute_save("modify");
} else {
attribute_print_form();
}
} elseif(($_REQUEST["submit"] == 3) and (($_REQUEST["attrib"] == 'dnmember') or
($_REQUEST["attrib"] == 'memberuid') or
($_REQUEST["attrib"] == 'dnmoderator') or
($_REQUEST["attrib"] == 'dnsender'))) {
attribute_print_form($_REQUEST["action"]);
} elseif($_REQUEST["submit"] == 4) {
// SAVE change directly, no need for a form
attribute_save($_REQUEST["action"]);
} elseif(($_REQUEST["submit"] == 5) and ($_REQUEST["attrib"] == sprintf("%s", pql_get_define("PQL_ATTR_ISACTIVE")))) {
attribute_save($_REQUEST["action"]);
} else {
if(($_REQUEST["attrib"] == sprintf("%s", pql_get_define("PQL_ATTR_GROUP_CONFIRM"))) or
($_REQUEST["attrib"] == sprintf("%s", pql_get_define("PQL_ATTR_GROUP_MEMBERS_ONLY"))) or
($_REQUEST["attrib"] == sprintf("%s", pql_get_define("PQL_ATTR_START_ADVANCED"))) or
($_REQUEST["attrib"] == sprintf("%s", pql_get_define("PQL_ATTR_DISABLE_ADVANCED_MODE")))) {
// It's one of those user toggles - go save!
attribute_save($_REQUEST["action"]);
} else {
attribute_init();
attribute_print_form();
}
}
// }}}
?>
</body>
</html>
<?php
pql_flush();
/*
* Local variables:
* mode: php
* mode: font-lock
* tab-width: 4
* End:
*/
?>