La fonction sub_domain_change_status utilise maintenant l'id systeme du sub_domain

This commit is contained in:
Alan Garcia 2013-07-02 15:31:16 +00:00
parent b142df090d
commit 8681618566
3 changed files with 16 additions and 12 deletions

View File

@ -31,8 +31,8 @@ require_once("../class/config.php");
include_once("head.php");
$fields = array (
"domain" => array ("request", "string", ""),
"sub" => array ("request", "string", ""),
"domain" => array ("request", "string", (empty($domain)?"":$domain) ),
"sub" => array ("request", "string", (empty($sub)?"":$sub) ),
);
getFields($fields);
@ -154,14 +154,14 @@ for($i=0;$i<$r["nsub"];$i++) {
switch ($r['sub'][$i]['enable']) {
case 'ENABLED':
__("Enabled");
echo "<br/><a href='dom_substatus.php?domain=".urlencode($r["name"])."&amp;sub=".urlencode($r["sub"][$i]["name"])."&amp;type=".urlencode($r["sub"][$i]["type"])."&amp;value=".urlencode($r["sub"][$i]['dest'])."&amp;status=disable'>";__("Disable");echo "</a>";
echo "<br/><a href='dom_substatus.php?sub_id=".urlencode($r["sub"][$i]["id"])."&amp;status=disable'>";__("Disable");echo "</a>";
break;
case 'ENABLE':
__("Activation pending");
break;
case 'DISABLED':
__("Disabled");
echo "<br/><a href='dom_substatus.php?domain=".urlencode($r["name"])."&amp;sub=".urlencode($r["sub"][$i]["name"])."&amp;type=".urlencode($r["sub"][$i]["type"])."&amp;value=".urlencode($r["sub"][$i]['dest'])."&amp;status=enable'>";__("Enable");echo "</a>";
echo "<br/><a href='dom_substatus.php?sub_id=".urlencode($r["sub"][$i]["id"])."&amp;status=enable'>";__("Enable");echo "</a>";
break;
case 'DISABLE':
__("Desactivation pending");

View File

@ -2,17 +2,19 @@
require_once("../class/config.php");
$fields = array (
"domain" => array ("request", "string", ""),
"sub" => array ("request", "string", ""),
"type" => array ("request", "string", ""),
"value" => array ("request", "string", ""),
"sub_id" => array ("request", "integer", ""),
"status" => array ("request", "string", ""),
);
getFields($fields);
$dom->lock();
$r=$dom->sub_domain_change_status($domain,$sub,$type,$value,$status);
$r=$dom->sub_domain_change_status($sub_id,$status);
# Usefull for dom_edit
$domi = $dom->get_sub_domain_all($sub_id);
$domain=$domi['domain'];
$sub=$domi['name'];
$dom->unlock();

View File

@ -206,13 +206,15 @@ class m_dom {
return true;
}
function sub_domain_change_status($domain,$sub,$type,$value,$status) {
function sub_domain_change_status($sub_id,$status) {
global $db,$err,$cuid;
$err->log("dom","sub_domain_change_status");
$sub_id=intval($sub_id);
$status=strtoupper($status);
if (! in_array($status,array('ENABLE', 'DISABLE'))) return false;
// FIXME: add check with can_create_subdomain
$db->query("update sub_domaines set enable='$status' where domaine='$domain' and sub='$sub' and lower(type)=lower('$type') and valeur='$value'");
$db->query("update sub_domaines set enable='$status' where id = '$sub_id'");
return true;
}
@ -916,7 +918,7 @@ class m_dom {
$compatibility_lst = explode(",",$db->f('compatibility'));
// Get the list of type of subdomains already here who have the same name
$db->query("select * from sub_domaines where sub='$sub' and domaine='$dom' and not id = $sub_domain_id and web_action != 'DELETE'");
$db->query("select * from sub_domaines where sub='$sub' and domaine='$dom' and not id = $sub_domain_id and web_action != 'DELETE' and enabled not in ('DISABLED', 'DISABLE') ");
#$db->query("select * from sub_domaines where sub='$sub' and domaine='$dom';");
while ($db->next_record()) {
// And if there is a domain with a incompatible type, return false