mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
Added better error checking to new/edit account and new/edit applications
This commit is contained in:
parent
832daa9f4e
commit
7fb5ee338e
@ -25,9 +25,14 @@
|
||||
}
|
||||
|
||||
if ($submit) {
|
||||
$totalerrors = 0;
|
||||
|
||||
if (strlen($n_loginid) > 8)
|
||||
$error[$totalerrors++] = lang("The loginid can not be more then 8 characters");
|
||||
|
||||
if ($old_loginid != $n_loginid) {
|
||||
if (account_exsists($n_loginid)) {
|
||||
$error .= "<br>" . lang("That loginid has already been taken");
|
||||
$error[$totalerrors++] = lang("That loginid has already been taken");
|
||||
}
|
||||
$c_loginid = $n_loginid;
|
||||
$n_loginid = $old_loginid;
|
||||
@ -35,18 +40,18 @@
|
||||
|
||||
if ($n_passwd || $n_passwd_2) {
|
||||
if ($n_passwd != $n_passwd_2) {
|
||||
$error .= lang("The two passwords are not the same");
|
||||
$error[$totalerrors++] = lang("The two passwords are not the same");
|
||||
}
|
||||
if (! $n_passwd){
|
||||
$error .= lang("You must enter a password");
|
||||
$error[$totalerrors++] = lang("You must enter a password");
|
||||
}
|
||||
}
|
||||
|
||||
if (count($new_permissions) == 0){
|
||||
$error .= "<br>" . lang("You must add at least 1 permission to this account");
|
||||
$error[$totalerrors++] = "<br>" . lang("You must add at least 1 permission to this account");
|
||||
}
|
||||
|
||||
if (! $error) {
|
||||
if (! $totalerrors) {
|
||||
$cd = account_edit(array("loginid" => $n_loginid, "permissions" => $new_permissions,
|
||||
"firstname" => $n_firstname, "lastname" => $n_lastname,
|
||||
"passwd" => $n_passwd, "account_status" => $account_status,
|
||||
@ -74,7 +79,7 @@
|
||||
<input type="hidden" name="old_loginid" value="<? echo $phpgw->db->f("account_lid"); ?>">
|
||||
<?php
|
||||
if ($error) {
|
||||
echo "<center>" . lang("Error") . ":$error</center>";
|
||||
echo "<center>" . $phpgw->common->error_list($error) . "</center>";
|
||||
}
|
||||
?>
|
||||
<center>
|
||||
|
@ -24,9 +24,25 @@
|
||||
$t->set_file(array("form" => "application_form.tpl"));
|
||||
|
||||
if ($submit) {
|
||||
if (! $n_app_name || ! $n_app_title) {
|
||||
$error = lang("You must enter an application name and title.");
|
||||
} else {
|
||||
$totalerrors = 0;
|
||||
|
||||
if (! $n_app_name)
|
||||
$error[$totalerrors++] = lang("You must enter an application name.");
|
||||
|
||||
if (! $n_app_title)
|
||||
$error[$totalerrors++] = lang("You must enter an application title.");
|
||||
|
||||
if ($old_app_name != $n_app_name) {
|
||||
$phpgw->db->query("select count(*) from applications where app_name='"
|
||||
. addslashes($n_app_name) . "'");
|
||||
$phpgw->db->next_record();
|
||||
|
||||
if ($phpgw->db->f(0) != 0) {
|
||||
$error[$totalerrors++] = lang("That application name already exsists.");
|
||||
}
|
||||
}
|
||||
|
||||
if (! $totalerrors) {
|
||||
$phpgw->db->query("update applications set app_name='" . addslashes($n_app_name) . "',"
|
||||
. "app_title='" . addslashes($n_app_title) . "', app_enabled='"
|
||||
. "$n_app_enabled' where app_name='$old_app_name'");
|
||||
@ -38,19 +54,22 @@
|
||||
$phpgw->db->query("select * from applications where app_name='$app_name'");
|
||||
$phpgw->db->next_record();
|
||||
|
||||
if ($error) {
|
||||
if ($totalerrors) {
|
||||
$phpgw->common->phpgw_header();
|
||||
$phpgw->common->navbar();
|
||||
|
||||
$t->set_var("error","<p><center>" . $phpgw->common->error_list($error) . "</center><br>");
|
||||
} else {
|
||||
$t->set_var("error","");
|
||||
|
||||
$n_app_name = $phpgw->db->f("app_name");
|
||||
$n_app_title = $phpgw->db->f("app_title");
|
||||
$n_app_enabled = $phpgw->db->f("app_enabled");
|
||||
$old_app_name = $phpgw->db->f("app_name");
|
||||
}
|
||||
|
||||
$t->set_var("lang_header",lang("Edit application"));
|
||||
|
||||
if ($error) {
|
||||
$t->set_var("error","<p><center>$error</center><br>");
|
||||
} else {
|
||||
$t->set_var("error","");
|
||||
}
|
||||
$t->set_var("hidden_vars",'<input type="hidden" name="old_app_name" value="' . $phpgw->db->f("app_name") . '">');
|
||||
$t->set_var("hidden_vars",'<input type="hidden" name="old_app_name" value="' . $old_app_name . '">');
|
||||
|
||||
$t->set_var("form_action",$phpgw->link("editapplication.php"));
|
||||
$t->set_var("lang_app_name",lang("application name"));
|
||||
@ -58,9 +77,9 @@
|
||||
$t->set_var("lang_enabled",lang("enabled"));
|
||||
$t->set_var("lang_submit_button",lang("edit"));
|
||||
|
||||
$t->set_var("app_name_value",$phpgw->db->f("app_name"));
|
||||
$t->set_var("app_title_value",$phpgw->db->f("app_title"));
|
||||
$t->set_var("app_enabled_checked",($phpgw->db->f("app_enabled") == 1?" checked":""));
|
||||
$t->set_var("app_name_value",$n_app_name);
|
||||
$t->set_var("app_title_value",$n_app_title);
|
||||
$t->set_var("app_enabled_checked",($n_app_enabled?" checked":""));
|
||||
|
||||
$t->pparse("out","form");
|
||||
|
||||
|
@ -23,6 +23,9 @@
|
||||
if ($submit) {
|
||||
$totalerrors = 0;
|
||||
|
||||
if (strlen($n_loginid) > 8)
|
||||
$error[$totalerrors++] = lang("The loginid can not be more then 8 characters");
|
||||
|
||||
if (! $n_loginid)
|
||||
$error[$totalerrors++] = lang("You must enter a loginid");
|
||||
|
||||
|
@ -11,9 +11,7 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
if ($submit) {
|
||||
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
|
||||
}
|
||||
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
|
||||
|
||||
$phpgw_info["flags"]["disable_message_class"] = True;
|
||||
$phpgw_info["flags"]["disable_send_class"] = True;
|
||||
@ -25,29 +23,39 @@
|
||||
$t->set_file(array("form" => "application_form.tpl"));
|
||||
|
||||
if ($submit) {
|
||||
if (! $n_app_name || ! $n_app_title) {
|
||||
$error = lang("You must enter an application name and title.");
|
||||
} else {
|
||||
$totalerrors = 0;
|
||||
|
||||
$phpgw->db->query("select count(*) from applications where app_name='"
|
||||
. addslashes($n_app_name) . "'");
|
||||
$phpgw->db->next_record();
|
||||
|
||||
if ($phpgw->db->f(0) != 0) {
|
||||
$error[$totalerrors++] = lang("That application name already exsists.");
|
||||
}
|
||||
|
||||
if (! $n_app_name)
|
||||
$error[$totalerrors++] = lang("You must enter an application name.");
|
||||
|
||||
if (! $n_app_title)
|
||||
$error[$totalerrors++] = lang("You must enter an application title.");
|
||||
|
||||
if (! $totalerrors) {
|
||||
$phpgw->db->query("insert into applications (app_name,app_title,app_enabled) values('"
|
||||
. addslashes($n_app_name) . "','" . addslashes($n_app_title) . "',"
|
||||
. "$n_app_enabled)");
|
||||
. addslashes($n_app_name) . "','" . addslashes($n_app_title) . "',"
|
||||
. "$n_app_enabled)");
|
||||
|
||||
Header("Location: " . $phpgw->link("applications.php"));
|
||||
exit;
|
||||
} else {
|
||||
$t->set_var("error","<p><center>" . $phpgw->common->error_list($error) . "</center><br>");
|
||||
}
|
||||
}
|
||||
if ($error) {
|
||||
$phpgw->common->phpgw_header();
|
||||
$phpgw->common->navbar();
|
||||
}
|
||||
|
||||
$t->set_var("lang_header",lang("Add new application"));
|
||||
|
||||
if ($error) {
|
||||
$t->set_var("error","<p><center>$error</center><br>");
|
||||
} else {
|
||||
} else { // else submit
|
||||
$t->set_var("error","");
|
||||
}
|
||||
$phpgw->common->phpgw_header();
|
||||
$phpgw->common->navbar();
|
||||
|
||||
$t->set_var("lang_header",lang("Add new application"));
|
||||
|
||||
$t->set_var("hidden_vars","");
|
||||
$t->set_var("form_action",$phpgw->link("newapplication.php"));
|
||||
@ -56,9 +64,9 @@
|
||||
$t->set_var("lang_enabled",lang("enabled"));
|
||||
$t->set_var("lang_submit_button",lang("add"));
|
||||
|
||||
$t->set_var("app_name_value","");
|
||||
$t->set_var("app_title_value","");
|
||||
$t->set_var("app_enabled_checked","");
|
||||
$t->set_var("app_name_value",$n_app_name);
|
||||
$t->set_var("app_title_value",$n_app_value);
|
||||
$t->set_var("app_enabled_checked",($n_app_enabled?" checked":""));
|
||||
|
||||
$t->pparse("out","form");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user