diff --git a/bureau/admin/dom_edit.inc.php b/bureau/admin/dom_edit.inc.php
index 2d98da96..47ebad45 100755
--- a/bureau/admin/dom_edit.inc.php
+++ b/bureau/admin/dom_edit.inc.php
@@ -32,7 +32,7 @@ $dom->unlock();
-
+
array ("post", "string", ""),
"sub" => array ("post", "string", ""),
"type" => array ("post", "string", $dom->type_local),
- "sub_domain_id" => array ("post", "integer", ""),
+ "sub_domain_id" => array ("post", "integer", 0),
);
getFields($fields);
@@ -61,9 +61,14 @@ $r=$dom->set_sub_domain($domain,$sub,$type,$value, $sub_domain_id);
$dom->unlock();
if (!$r) {
- $noread=true;
- include("dom_subedit.php");
- exit();
+ if ($sub_domain_id!=0) {
+ $noread=true;
+ include("dom_subedit.php");
+ } else {
+ // it was a creation, not an edit
+ include("dom_edit.php");
+ }
+ exit();
} else {
$t = time();
// XXX: we assume the cron job is at every 5 minutes
diff --git a/bureau/admin/dom_subedit.php b/bureau/admin/dom_subedit.php
index 5b3a1154..98e6456c 100644
--- a/bureau/admin/dom_subedit.php
+++ b/bureau/admin/dom_subedit.php
@@ -32,7 +32,7 @@ include_once("head.php");
$fields = array (
- "sub_domain_id" => array ("request", "integer", ""),
+ "sub_domain_id" => array ("request", "integer", 0),
);
getFields($fields);
diff --git a/bureau/class/m_dom.php b/bureau/class/m_dom.php
index 96b2bc8a..b1c58dcc 100644
--- a/bureau/class/m_dom.php
+++ b/bureau/class/m_dom.php
@@ -1339,9 +1339,11 @@ class m_dom {
* @param string $sub SUBdomain
* @return boolean tell you if the subdomain can be installed there
*/
- function can_create_subdomain($dom, $sub, $type, $sub_domain_id = 'null') {
+ function can_create_subdomain($dom, $sub, $type, $sub_domain_id = 0) {
global $db, $msg;
- $msg->log("dom", "can_create_subdomain", $dom . "/" . $sub);
+
+ $sub_domain_id=intval($sub_domain_id);
+ $msg->log("dom", "can_create_subdomain", $dom . "/" . $sub . "/" .$type . "/" . $sub_domain_id);
// Get the compatibility list for this domain type
$db->query("select upper(compatibility) as compatibility from domaines_type where upper(name)=upper(?);", array($type));
@@ -1382,7 +1384,7 @@ class m_dom {
* de $type (url, ip, dossier...)
* @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
*/
- function set_sub_domain($dom, $sub, $type, $dest, $sub_domain_id = null) {
+ function set_sub_domain($dom, $sub, $type, $dest, $sub_domain_id = 0) {
global $db, $msg, $cuid, $bro;
$msg->log("dom", "set_sub_domain", $dom . "/" . $sub . "/" . $type . "/" . $dest);
// Locked ?
@@ -1420,12 +1422,12 @@ class m_dom {
return false;
}
- if (!is_null($sub_domain_id) && !empty($sub_domain_id)) { // It's not a creation, it's an edit. Delete the old one
+ if ($sub_domain_id!=0) { // It's not a creation, it's an edit. Delete the old one
$this->del_sub_domain($sub_domain_id);
}
// Re-create the one we want
- if (!$db->query("replace into sub_domaines (compte,domaine,sub,valeur,type,web_action) values (?, ?, ?, ?, ?, 'UPDATE');", array( $cuid , $dom , $sub , $dest , $type ))) {
+ if (!$db->query("INSERT INTO sub_domaines (compte,domaine,sub,valeur,type,web_action) VALUES (?, ?, ?, ?, ?, 'UPDATE');", array( $cuid , $dom , $sub , $dest , $type ))) {
echo "query failed: " . $db->Error;
return false;
}
|