This commit is contained in:
Alan Garcia 2012-12-03 08:11:06 +00:00
parent a80eb63f4f
commit da09f231b0
5 changed files with 61 additions and 38 deletions

View File

@ -38,14 +38,15 @@ if (!$admin->enabled) {
}
$fields = array (
"canpass" => array ("request", "integer", 1),
"login" => array ("request", "string", null),
"pass" => array ("request", "string", null),
"canpass" => array ("request", "integer", 1),
"login" => array ("request", "string", null),
"pass" => array ("request", "string", null),
"passconf" => array ("request", "string", null),
"notes" => array ("request", "string", null),
"nom" => array ("request", "string", null),
"prenom" => array ("request", "string", null),
"nmail" => array ("request", "string", null),
"notes" => array ("request", "string", null),
"nom" => array ("request", "string", null),
"prenom" => array ("request", "string", null),
"nmail" => array ("request", "string", null),
"create_dom" => array ("request", "integer", 0),
);
getFields($fields);

View File

@ -46,37 +46,17 @@ if ($pass != $passconf) {
include("adm_add.php");
exit();
}
if (!($u=$admin->add_mem($login, $pass, $nom, $prenom, $nmail, $canpass, $type, 0, $notes))) {
// Attemp to create, exit if fail
if (!($u=$admin->add_mem($login, $pass, $nom, $prenom, $nmail, $canpass, $type, 0, $notes, 0, $create_dom_list))) {
$error=$err->errstr();
include ("adm_add.php");
exit;
} else {
// Add here all what you want when an account is created !
$mem->su($u);
/*
* 1 = hébergement dns, en effet, les
* domaines *.koumbit.net ne sont pas forcément sur le serveur
*
* 1 = noerase = empêche à l'utilisateur de modifier le dns ou de
* supprimer le domaine
*
* 1 = force = ne tient pas compte du whois ou des droits de tld
*/
// FIXME: rien à faire ici. Ca devrait être dans la classe.
if (isset($create_dom) && ($create_dom == 1) && !is_null($create_dom_list)) {
// make sure we don't have multiple dots there
$dom->lock();
$dom->add_domain($login.".".preg_replace("/^\.\.*/", "", $create_dom_list),1,1,1);
$dom->unlock();
}
$ftp->add_ftp($login,"",$pass,"/");
$mem->unsu();
$error=_("The new member has been successfully created");
include("adm_list.php");
exit;
}
$error=_("The new member has been successfully created");
include("adm_list.php");
exit;
?>

View File

@ -283,7 +283,35 @@ class m_admin {
return true;
}
// When the admin want to delegate a subdomain to an account
function add_shared_domain($u, $domain_name) {
global $db,$err,$dom,$mem,$cuid;
$err->log("admin","add_shared_domain",$u."/".$domain_name);
if (! $mem->checkright() ) {
$err->raise("admin",_("-- Only administrators can do that! --"));
return false;
}
// Check if this domain exist on this admin account
if (! in_array($domain_name, $dom->enum_domains())) {
$err->raise("admin",_("You don't seem to be allowed to delegate this domain"));
$err->log("admin","add_shared_domain","domain not allowed");
return false;
}
// Clean the domain_name
$domain_name=preg_replace("/^\.\.*/", "", $domain_name);
$mem->su($u);
$dom->lock();
// option : 1=hébergement dns, 1=noerase, empeche de modifier, 1=force
$dom->add_domain($mem->user['login'].".".$domain_name,1,1,1);
$dom->unlock();
$mem->unsu();
return true;
}
/* ----------------------------------------------------------------- */
/** Creates a new hosted account
*
@ -300,7 +328,7 @@ class m_admin {
* @pararm $type string Account type for quotas
* @return boolean Returns FALSE if an error occurs, TRUE if not.
*/
function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0) {
function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom=false) {
global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks;
$err->log("admin","add_mem",$login."/".$mail);
if (!$this->enabled) {
@ -367,8 +395,14 @@ class m_admin {
*/
$hooks->invoke("alternc_add_member");
// New hook way
$hooks->invoke("hook_admin_add_member", array(), array('quota')); // First !!! The quota !!! Etherway, we can't be sure to be able to create all
$hooks->invoke("hook_admin_add_member");
$mem->unsu();
if (!empty($create_dom)) {
$this->add_shared_domain($uid, $create_dom);
}
return $uid;
} else {
$err->raise("admin",_("This login already exists"));
@ -376,7 +410,6 @@ class m_admin {
}
}
/* ----------------------------------------------------------------- */
/** AlternC's standard function called when a user is created
* This sends an email if configured through the interface.

View File

@ -97,6 +97,12 @@ class m_ftp {
}
}
function hook_admin_add_member() {
global $mem,$err;
$err->log("ftp","hook_admin_add_member");
return $this->add_ftp($mem->user['login'],"",$mem->user['pass'],"/");
}
/* ----------------------------------------------------------------- */
/** Retourne les détails d'un compte FTP (voir get_list)
* Le tableau est celui du compte d'id spécifié

View File

@ -514,7 +514,10 @@ class m_quota {
* globals $cuid is the appropriate user
*/
function hook_admin_add_member() {
global $err;
$err->log("quota","hook_admin_add_member");
$this->addquotas();
$this->getquota('',true); // actualise quota
}