egroupware/admin/newaccount.php

198 lines
7.8 KiB
PHP
Raw Normal View History

2000-08-18 05:24:22 +02:00
<?php
/**************************************************************************\
* phpGroupWare - administration *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
2000-08-18 05:24:22 +02:00
2000-09-25 23:13:52 +02:00
$phpgw_info["flags"]["disable_message_class"] = True;
$phpgw_info["flags"]["disable_send_class"] = True;
$phpgw_info["flags"]["currentapp"] = "admin";
2000-08-18 05:24:22 +02:00
include("../header.inc.php");
if ($submit) {
if (! $n_loginid)
2000-09-07 22:49:55 +02:00
$error = "<br>" . lang("You must enter a loginid");
2000-08-18 05:24:22 +02:00
if (! $n_passwd)
2000-09-07 22:49:55 +02:00
$error .= "<br>" . lang("You must enter a password");
2000-08-18 05:24:22 +02:00
if ($n_passwd == $n_loginid)
2000-09-07 22:49:55 +02:00
$error = "<br>" . lang("The login and password can not be the same");
2000-08-18 05:24:22 +02:00
if ($n_passwd != $n_passwd_2)
2000-09-07 22:49:55 +02:00
$error .= "<br>" . lang("The two passwords are not the same");
2000-08-18 05:24:22 +02:00
if (count($new_permissions) == 0)
2000-09-07 22:49:55 +02:00
$error .= "<br>" . lang("You must add at least 1 permission to this account");
2000-09-26 00:27:40 +02:00
$phpgw->db->query("select account_lid from accounts where account_lid='$n_loginid'");
2000-08-18 05:24:22 +02:00
$phpgw->db->next_record();
if ($phpgw->db->f("loginid"))
2000-09-07 22:49:55 +02:00
$error .= "<br>" . lang("That loginid has already been taken");
2000-08-18 05:24:22 +02:00
if (! $error) {
$phpgw->db->lock(array("accounts","preferences"));
$phpgw->common->preferences_add($n_loginid,"maxmatchs","15");
$phpgw->common->preferences_add($n_loginid,"theme","default");
$phpgw->common->preferences_add($n_loginid,"tz_offset","0");
$phpgw->common->preferences_add($n_loginid,"dateformat","m/d/Y");
$phpgw->common->preferences_add($n_loginid,"timeformat","12");
$phpgw->common->preferences_add($n_loginid,"lang","en");
2000-09-13 00:14:33 +02:00
$phpgw->common->preferences_add($n_loginid,"addressbook_view_company","True");
$phpgw->common->preferences_add($n_loginid,"addressbook_view_lastname","True");
$phpgw->common->preferences_add($n_loginid,"addressbook_view_firstname","True");
2000-08-18 05:24:22 +02:00
// Even if they don't have access to the calendar, we will add these.
// Its better then the calendar being all messed up, they will be deleted
// the next time the update there preferences.
$phpgw->common->preferences_add($n_loginid,"weekstarts","Monday");
$phpgw->common->preferences_add($n_loginid,"workdaystarts","9");
$phpgw->common->preferences_add($n_loginid,"workdayends","17");
2000-08-18 05:24:22 +02:00
while ($permission = each($new_permissions)) {
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
$phpgw->accounts->add_app($permission[0]);
2000-08-18 05:24:22 +02:00
}
}
//$phpgw->permissions->add("hr");
2000-08-18 05:24:22 +02:00
if ($n_anonymous && ! $n_admin)
$phpgwpermissions->add("anonymous");
2000-09-26 00:27:40 +02:00
$sql = "insert into accounts (account_lid,account_pwd,account_firstname,account_lastname,"
. "account_permissions,account_groups,account_status,account_lastpwd_change) values ('$n_loginid'"
. ",'" . md5($n_passwd) . "','" . addslashes($n_firstname) . "','"
. addslashes($n_lastname) . "','" . $phpgw->accounts->add_app("",True)
. "','" . $phpgw->accounts->array_to_string("none",$n_groups) . "','A',0)";
2000-08-18 05:24:22 +02:00
$phpgw->db->query($sql);
$phpgw->db->unlock();
$sep = $phpgw->common->filesystem_separator();
2000-08-18 05:24:22 +02:00
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
2000-08-18 05:24:22 +02:00
umask(000);
if (! @mkdir($basedir . $n_loginid, 0707)) {
// $cd = 36;
2000-08-18 05:24:22 +02:00
} else {
$cd = 28;
}
Header("Location: " . $phpgw->link("accounts.php","cd=$cd"));
exit;
}
}
$phpgw->common->phpgw_header();
2000-08-18 05:24:22 +02:00
$phpgw->common->navbar();
?>
2000-09-03 22:25:31 +02:00
<form method="POST" action="<?php echo $phpgw->link("newaccount.php"); ?>">
2000-08-18 05:24:22 +02:00
<?php
if ($error) {
2000-09-07 22:49:55 +02:00
echo "<center>" . lang("Error") . ":$error</center>";
2000-08-18 05:24:22 +02:00
}
?>
<center>
<table border=0 width=65%>
<tr>
2000-09-07 22:49:55 +02:00
<td><?php echo lang("LoginID"); ?></td>
2000-08-18 05:24:22 +02:00
<td><input name="n_loginid" value="<?php echo $n_loginid; ?>"></td>
</tr>
<tr>
2000-09-07 22:49:55 +02:00
<td><?php echo lang("Password"); ?></td>
2000-08-18 05:24:22 +02:00
<td><input type="password" name="n_passwd" value="<?php echo $n_passwd; ?>"></td>
</tr>
<tr>
2000-09-07 22:49:55 +02:00
<td><?php echo lang("Re-Enter Password"); ?></td>
2000-08-18 05:24:22 +02:00
<td><input type="password" name="n_passwd_2" value="<?php echo $n_passwd_2; ?>"></td>
</tr>
<tr>
2000-09-07 22:49:55 +02:00
<td><?php echo lang("First Name"); ?></td>
2000-08-18 05:24:22 +02:00
<td><input name="n_firstname" value="<?php echo $n_firstname; ?>"></td>
</tr>
<tr>
2000-09-07 22:49:55 +02:00
<td><?php echo lang("Last Name"); ?></td>
2000-08-18 05:24:22 +02:00
<td><input name="n_lastname" value="<?php echo $n_lastname; ?>"></td>
</tr>
<tr>
2000-09-07 22:49:55 +02:00
<td><?php echo lang("Groups"); ?></td>
2000-08-18 05:24:22 +02:00
<td><select name="n_groups[]" multiple><?php
$phpgw->db->query("select * from groups");
while ($phpgw->db->next_record()) {
echo "<option value=\"" . $phpgw->db->f("group_id") . "\"";
if ($n_groups[$phpgw->db->f("group_id")]) {
echo " selected";
}
echo ">" . $phpgw->db->f("group_name") . "</option>";
}
?>
</select></td>
</tr>
<?php
$i = 0;
while ($permission = each($phpgw_info["apps"])) {
if ($permission[1]["enabled"]) {
$perm_display[$i][0] = $permission[0];
$perm_display[$i][1] = $permission[1]["title"];
$i++;
}
}
for ($i=0;$i<200;) { // The $i<200 is only used for a brake
if (! $perm_display[$i][1]) break;
2000-09-07 22:49:55 +02:00
echo '<tr><td>' . lang($perm_display[$i][1]) . '</td>'
2000-08-18 05:24:22 +02:00
. '<td><input type="checkbox" name="new_permissions['
. $perm_display[$i][0] . ']" value="True"';
if ($new_permissions[$perm_display[$i][0]]) {
echo " checked";
}
echo "></td>";
$i++;
if (! $perm_display[$i][1]) break;
2000-09-07 22:49:55 +02:00
echo '<td>' . lang($perm_display[$i][1]) . '</td>'
2000-08-18 05:24:22 +02:00
. '<td><input type="checkbox" name="new_permissions['
. $perm_display[$i][0] . ']" value="True"';
if ($new_permissions[$perm_display[$i][0]]) {
echo " checked";
}
echo "></td></tr>";
$i++;
}
2000-08-27 03:52:30 +02:00
/*
2000-08-18 05:24:22 +02:00
// Just until we can get thing the $phpgw_info["apps"] then figured out
2000-09-07 22:49:55 +02:00
echo "<tr><td>" . lang("Anonymous user") . "</td> <td><input type=\""
2000-08-18 05:24:22 +02:00
. "checkbox\" name=\"new_permissions[anonymous]\" value=\"Y\"></td>";
2000-09-07 22:49:55 +02:00
echo "<td>" . lang("Manager") . "</td> <td><input type=\""
2000-08-18 05:24:22 +02:00
. "checkbox\" name=\"new_permissions[manager]\" value=\"Y\"></td></tr>";
2000-08-27 03:52:30 +02:00
*/
2000-08-18 05:24:22 +02:00
?>
<tr>
<td colspan=2>
2000-09-07 22:49:55 +02:00
<input type="submit" name="submit" value="<?php echo lang("submit"); ?>">
2000-08-18 05:24:22 +02:00
</td>
</tr>
</table>
</center>
</form>
<?php
$phpgw->common->phpgw_footer();
2000-09-25 23:13:52 +02:00
?>