-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunit_add.php
94 lines (82 loc) · 2.72 KB
/
unit_add.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
<?php
// add a domain
// $Id: unit_add.php,v 2.31 2007-03-14 12:10:52 turbo Exp $
//
// {{{ Setup session etc
require("./include/pql_session.inc");
require($_SESSION["path"]."/include/pql_config.inc");
require($_SESSION["path"]."/include/pql_control.inc");
$url["domain"] = pql_format_urls($_REQUEST["domain"]);
$url["rootdn"] = pql_format_urls($_REQUEST["rootdn"]);
$url["unit"] = pql_format_urls($_REQUEST["unit"]);
include($_SESSION["path"]."/header.html");
?>
<span class="title1"><?php echo pql_complete_constant($LANG->_('Create subbranch in domain %domain%'),
array('domain' => pql_maybe_decode($_REQUEST["domain"]))); ?></span>
<br><br>
<?php
// }}}
// {{{ Check if domain exist
if(!$_pql->get_dn($_REQUEST["domain"], '(objectclass=*)', 'BASE')) {
echo "Domain "".$_REQUEST["domain"]."" does not exists";
exit();
}
// }}}
if($_REQUEST["unit"]) {
// {{{ Check if unit exist
if(pql_get_define("PQL_CONF_REFERENCE_DOMAINS_WITH", $_REQUEST["rootdn"]) == "dc")
$filter = "(&(dc=".$_REQUEST["unit"].")(objectclass=domain))";
else
$filter = "(&(ou=".$_REQUEST["unit"].")(objectclass=organizationalUnit))";
if($_pql->get_dn($_REQUEST["domain"], $filter, 'ONELEVEL')) {
$msg = urlencode($LANG->_('This sub unit already exists'));
pql_header("home.php?msg=$msg");
}
// }}}
// {{{ Setup URL referal and success message
$msg = urlencode(pql_complete_constant($LANG->_('Sub unit %unit% successfully created'),
array("unit" => $_REQUEST["unit"])));
if(pql_get_define("PQL_CONF_AUTO_RELOAD"))
$rlnb = "&rlnb=1";
$url = "domain_detail.php?rootdn=".$url["rootdn"]."&domain=".$url["domain"]."&msg=$msg$rlnb";
// }}}
// {{{ Add unit to database
if(pql_unit_add($_REQUEST["domain"], $_REQUEST["unit"]))
pql_header($url);
else {
$msg = urlencode($LANG->_('Failed to create the sub unit') . ": " . ldap_error($_pql->ldap_linkid));
pql_header("home.php?msg=$msg");
}
// }}}
} else {
// {{{ Show form
?>
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post">
<table cellspacing="0" cellpadding="3" border="0">
<th colspan="3" align="left"><?php echo $LANG->_('Create unit')?></th>
<tr>
<td class="title"><?php echo $LANG->_('Unit name')?></td>
<td><input type="text" name="unit" size="30"></td>
</tr>
<tr><td><input type="submit" value="Create"></td></tr>
</th>
</table>
<input type="hidden" name="rootdn" value="<?php echo $url["rootdn"]?>">
<input type="hidden" name="domain" value="<?php echo $url["domain"]?>">
</form>
<?php
// }}}
}
?>
</body>
</html>
<?php
pql_flush();
/*
* Local variables:
* mode: php
* mode: font-lock
* tab-width: 4
* End:
*/
?>