Fix #1137
This commit is contained in:
parent
020b144ed1
commit
6bfa75077f
|
@ -66,9 +66,8 @@ include_once ("head.php");
|
||||||
<td>
|
<td>
|
||||||
<select name="type" id="type" class="inl">
|
<select name="type" id="type" class="inl">
|
||||||
<?php
|
<?php
|
||||||
$db->query("SELECT distinct(type) FROM defquotas WHERE TYPE != 'default' ORDER by type");
|
foreach($quota->listtype() as $type) {
|
||||||
while($db->next_record()) {
|
if ($type=="default") continue;
|
||||||
$type = $db->f("type");
|
|
||||||
echo "<option value=\"$type\">$type</option>\n";
|
echo "<option value=\"$type\">$type</option>\n";
|
||||||
}
|
}
|
||||||
?></select>
|
?></select>
|
||||||
|
|
|
@ -35,23 +35,28 @@ if (!$admin->enabled) {
|
||||||
__("This page is restricted to authorized staff");
|
__("This page is restricted to authorized staff");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
$fields = array (
|
||||||
|
"action" => array ("post", "string", ""),
|
||||||
|
"type" => array ("post", "string", ""),
|
||||||
|
"del_confirm" => array ("post", "string", ""),
|
||||||
|
);
|
||||||
|
getFields($fields);
|
||||||
|
|
||||||
if($_POST["action"] == "add") {
|
if($action == "add") {
|
||||||
$type = $_POST['type'];
|
|
||||||
|
|
||||||
if($quota->addtype($type)) {
|
if($quota->addtype($type)) {
|
||||||
$error=_("Account type"). " \"$type\" "._("added");
|
$error=_("Account type"). " \"".htmlentities($type)."\" "._("added");
|
||||||
} else {
|
} else {
|
||||||
$error=_("Account type"). " \"$type\" "._("could not be added");
|
$error=_("Account type"). " \"".htmlentities($type)."\" "._("could not be added");
|
||||||
}
|
}
|
||||||
include("adm_defquotas.php");
|
include("adm_defquotas.php");
|
||||||
} else if($_POST["action"] == "delete") {
|
} else if($action == "delete") {
|
||||||
if(@$_POST["del_confirm"] == "y"){
|
if($del_confirm == "y"){
|
||||||
if($_POST['type']) {
|
if(!empty($type)) {
|
||||||
if($quota->deltype($_POST['type'])) {
|
if($quota->deltype($type)) {
|
||||||
$error=_("Account type"). " \"$type\" "._("deleted");
|
$error=_("Account type"). " \"".htmlentities($type)."\" "._("deleted");
|
||||||
} else {
|
} else {
|
||||||
$error=_("Account type"). " \"$type\" "._("could not be deleted");
|
$error=_("Account type"). " \"".htmlentities($type)."\" "._("could not be deleted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
include("adm_defquotas.php");
|
include("adm_defquotas.php");
|
||||||
|
@ -60,11 +65,11 @@ if($_POST["action"] == "add") {
|
||||||
?>
|
?>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h3><?php printf(_("Deleting quota %s"),$_POST["type"]); ?> : </h3>
|
<h3><?php printf(_("Deleting quota %s"),$type); ?> : </h3>
|
||||||
|
|
||||||
<form action="adm_dodefquotas.php" method="post">
|
<form action="adm_dodefquotas.php" method="post">
|
||||||
<input type="hidden" name="action" value="delete" />
|
<input type="hidden" name="action" value="delete" />
|
||||||
<input type="hidden" name="type" value="<?php echo $_POST["type"] ?>" />
|
<input type="hidden" name="type" value="<?php echo $type ?>" />
|
||||||
<input type="hidden" name="del_confirm" value="y" />
|
<input type="hidden" name="del_confirm" value="y" />
|
||||||
<p class="error"><?php __("WARNING : Confirm the deletion of the quota"); ?></p>
|
<p class="error"><?php __("WARNING : Confirm the deletion of the quota"); ?></p>
|
||||||
<p><?php echo $_POST["type"]; ?></p>
|
<p><?php echo $_POST["type"]; ?></p>
|
||||||
|
@ -77,7 +82,7 @@ if($_POST["action"] == "add") {
|
||||||
</html>
|
</html>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
} else if($_POST["action"] == "modify") {
|
} else if($action == "modify") {
|
||||||
reset($_POST);
|
reset($_POST);
|
||||||
$c=array();
|
$c=array();
|
||||||
foreach($_POST as $key => $val) {
|
foreach($_POST as $key => $val) {
|
||||||
|
|
|
@ -262,11 +262,15 @@ class m_quota {
|
||||||
* @return boolean true if all went ok
|
* @return boolean true if all went ok
|
||||||
*/
|
*/
|
||||||
function addtype($type) {
|
function addtype($type) {
|
||||||
global $db;
|
global $db,$err;
|
||||||
$qlist=$this->qlist();
|
$qlist=$this->qlist();
|
||||||
reset($qlist);
|
reset($qlist);
|
||||||
if(empty($type))
|
if(empty($type)) return false;
|
||||||
return false;
|
$type=strtolower($type);
|
||||||
|
if (!preg_match("#^[a-z0-9]*$#",$type)) {
|
||||||
|
$err->raise("quota", "Type can only contains characters a-z and 0-9");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
while (list($key,$val)=each($qlist)) {
|
while (list($key,$val)=each($qlist)) {
|
||||||
if(!$db->query("INSERT IGNORE INTO defquotas (quota,type) VALUES('$key', '$type');")
|
if(!$db->query("INSERT IGNORE INTO defquotas (quota,type) VALUES('$key', '$type');")
|
||||||
|| $db->affected_rows() == 0)
|
|| $db->affected_rows() == 0)
|
||||||
|
@ -276,6 +280,21 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------- */
|
||||||
|
/**
|
||||||
|
* List for quotas
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function listtype() {
|
||||||
|
global $db;
|
||||||
|
$db->query("SELECT distinct(type) FROM defquotas ORDER by type");
|
||||||
|
$t=array();
|
||||||
|
while ($db->next_record()) {
|
||||||
|
$t[] = $db->f("type");
|
||||||
|
}
|
||||||
|
return $t;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/**
|
/**
|
||||||
* Delete an account type for quotas
|
* Delete an account type for quotas
|
||||||
|
|
Loading…
Reference in New Issue