Activation et desactivation OK

This commit is contained in:
Alan Garcia 2011-01-29 18:26:32 +00:00
parent dacbd14cf9
commit c3ed3a7ecc
4 changed files with 49 additions and 3 deletions

1
.gitattributes vendored
View File

@ -99,6 +99,7 @@ bureau/admin/dom_subdel.php -text
bureau/admin/dom_subdodel.php -text
bureau/admin/dom_subdoedit.php -text
bureau/admin/dom_subedit.php -text
bureau/admin/dom_substatus.php -text
bureau/admin/domlist.php -text
bureau/admin/foot.php -text
bureau/admin/ftp_add.php -text

View File

@ -94,7 +94,7 @@ if ($r['dns_action']=='UPDATE') {?>
gestion des sous-domaines
-->
<table class="tlist">
<tr><th colspan="2"><?php __("Actions"); ?></th><th><?php __("Subdomain"); ?></th><th><?php __("Type");?></th><th><?php __("Place"); ?></th><th><?php __("Enable")?></th><th><?php __("Pending");?></tr>
<tr><th colspan="2"><?php __("Actions"); ?></th><th><?php __("Subdomain"); ?></th><th><?php __("Type");?></th><th><?php __("Place"); ?></th><th><?php __("Status")?></th><th><?php __("Pending");?></tr>
<?php
$col=1;
for($i=0;$i<$r["nsub"];$i++) {
@ -114,12 +114,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'])."&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'])."&status=enable'>";__("Enable");echo "</a>";
break;
case 'DISABLE':
__("Desactivation pending");

View File

@ -0,0 +1,33 @@
<?php
require_once("../class/config.php");
$fields = array (
"domain" => array ("request", "string", ""),
"sub" => array ("request", "string", ""),
"type" => array ("request", "string", ""),
"value" => array ("request", "string", ""),
"status" => array ("request", "string", ""),
);
getFields($fields);
$dom->lock();
$r=$dom->sub_domain_change_status($domain,$sub,$type,$value,$status);
$dom->unlock();
if (!$r) {
$error=$err->errstr();
$noread=true;
include("dom_edit.php");
exit();
} else {
$t = time();
// XXX: we assume the cron job is at every 5 minutes
$error=strtr(_("The modifications will take effect at %time. Server time is %now."), array('%now' => date('H:i:s', $t), '%time' => date('H:i:s', ($t-($t%300)+300))));
foreach($fields as $k=>$v) unset($k);
}
include("dom_edit.php");
exit;
?>

View File

@ -174,6 +174,16 @@ class m_dom {
return true;
}
function sub_domain_change_status($domain,$sub,$type,$value,$status) {
global $db,$err,$cuid;
$err->log("dom","sub_domain_change_status");
$status=strtoupper($status);
if (! in_array($status,array('ENABLE', 'DISABLE'))) return false;
$db->query("update sub_domaines set enable='$status' where domaine='$domain' and sub='$sub' and lower(type)=lower('$type') and valeur='$value'");
return true;
}
/* ----------------------------------------------------------------- */
/**
@ -203,7 +213,7 @@ class m_dom {
$db->query("UPDATE sub_domaines SET web_action='UPDATE' WHERE domaine='$dom';");
$db->query("UPDATE domaines SET dns_action='UPDATE' WHERE domaine='$dom';");
# TODO : some work with domain sensitive classes
# TODO : some work with domain sensitive classes
return true;
}
@ -836,7 +846,7 @@ class m_dom {
}
if (! $this->can_create_subdomain($dom,$sub,$type,$value_old)) {
# TODO have a real error code
# TODO have a real error code
$err->raise("dom", 654);
return false;
}