Permet de choisir le server de BDD à la création du membre
This commit is contained in:
parent
770ccb5fb6
commit
bc763fce61
|
@ -99,6 +99,24 @@ if (isset($error) && $error) {
|
||||||
?></select>
|
?></select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<?php
|
||||||
|
__("Wich database server for this user ?");
|
||||||
|
echo "<br/>";
|
||||||
|
echo "<i>"._("Warning: you can't change it after the creation of the user.")."</i>";
|
||||||
|
?>
|
||||||
|
</th>
|
||||||
|
<td><?php
|
||||||
|
echo "<select name='db_server_id' id='db_server_id' >";
|
||||||
|
foreach ($mysql->list_db_servers() as $ldb ) {
|
||||||
|
echo "<option value='".$ldb['id']."'>".$ldb['name']."</option>";
|
||||||
|
}
|
||||||
|
echo "</select>";
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<?php if (variable_get('hosting_tld') || $dom->enum_domains()) { ?>
|
<?php if (variable_get('hosting_tld') || $dom->enum_domains()) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2">
|
<th colspan="2">
|
||||||
|
|
|
@ -31,6 +31,7 @@ $fields = array (
|
||||||
"pass" => array ("post", "string", ""),
|
"pass" => array ("post", "string", ""),
|
||||||
"passconf" => array ("post", "string", ""),
|
"passconf" => array ("post", "string", ""),
|
||||||
"canpass" => array ("post", "integer", ""),
|
"canpass" => array ("post", "integer", ""),
|
||||||
|
"db_server_id" => array ("post", "integer", ""),
|
||||||
"notes" => array ("post", "string", ""),
|
"notes" => array ("post", "string", ""),
|
||||||
"nom" => array ("post", "string", ""),
|
"nom" => array ("post", "string", ""),
|
||||||
"prenom" => array ("post", "string", ""),
|
"prenom" => array ("post", "string", ""),
|
||||||
|
@ -48,7 +49,7 @@ if ($pass != $passconf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attemp to create, exit if fail
|
// Attemp to create, exit if fail
|
||||||
if (!($u=$admin->add_mem($login, $pass, $nom, $prenom, $nmail, $canpass, $type, 0, $notes, 0, $create_dom_list))) {
|
if (!($u=$admin->add_mem($login, $pass, $nom, $prenom, $nmail, $canpass, $type, 0, $notes, 0, $create_dom_list, $db_server_id))) {
|
||||||
$error=$err->errstr();
|
$error=$err->errstr();
|
||||||
include ("adm_add.php");
|
include ("adm_add.php");
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -156,7 +156,7 @@ while (list($key,$val)=each($r))
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr class="lst<?php echo $col; ?>" >
|
<tr class="lst<?php echo $col; ?>" >
|
||||||
<td></td><td></td>
|
<td/><td ><i><?php echo _("DB:").' '.$val['db_server_name']?></i></td>
|
||||||
<td colspan="8" >
|
<td colspan="8" >
|
||||||
<div id="admlistbtn">
|
<div id="admlistbtn">
|
||||||
<span class="ina<?php if ($col==2) echo "v"; ?> lst<?php echo $col; ?>">
|
<span class="ina<?php if ($col==2) echo "v"; ?> lst<?php echo $col; ?>">
|
||||||
|
|
|
@ -160,6 +160,7 @@ class m_admin {
|
||||||
l.*,
|
l.*,
|
||||||
m.*,
|
m.*,
|
||||||
parent.login as parentlogin,
|
parent.login as parentlogin,
|
||||||
|
dbs.name as db_server_name,
|
||||||
m.renewed + INTERVAL m.duration MONTH as expiry,
|
m.renewed + INTERVAL m.duration MONTH as expiry,
|
||||||
CASE
|
CASE
|
||||||
WHEN m.duration IS NULL THEN 0
|
WHEN m.duration IS NULL THEN 0
|
||||||
|
@ -169,6 +170,7 @@ class m_admin {
|
||||||
|
|
||||||
FROM membres as m
|
FROM membres as m
|
||||||
LEFT JOIN membres as parent ON (parent.uid = m.creator)
|
LEFT JOIN membres as parent ON (parent.uid = m.creator)
|
||||||
|
LEFT JOIN db_servers as dbs ON (m.db_server_id = dbs.id)
|
||||||
LEFT JOIN local as l ON (m.uid = l.uid) ;");
|
LEFT JOIN local as l ON (m.uid = l.uid) ;");
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
$lst_users_properties[$db->f('muid')]=$db->Record;
|
$lst_users_properties[$db->f('muid')]=$db->Record;
|
||||||
|
@ -414,13 +416,17 @@ class m_admin {
|
||||||
* @pararm $type string Account type for quotas
|
* @pararm $type string Account type for quotas
|
||||||
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
* @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, $create_dom=false) {
|
function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom=false, $db_server_id) {
|
||||||
global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks;
|
global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks;
|
||||||
$err->log("admin","add_mem",$login."/".$mail);
|
$err->log("admin","add_mem",$login."/".$mail);
|
||||||
if (!$this->enabled) {
|
if (!$this->enabled) {
|
||||||
$err->raise("admin",_("-- Only administrators can access this page! --"));
|
$err->raise("admin",_("-- Only administrators can access this page! --"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (empty($db_server_id)) {
|
||||||
|
$err->raise("admin",_("Missing db_server field"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (($login=="")||($pass=="")) {
|
if (($login=="")||($pass=="")) {
|
||||||
$err->raise("admin",_("All fields are mandatory"));
|
$err->raise("admin",_("All fields are mandatory"));
|
||||||
return false;
|
return false;
|
||||||
|
@ -465,7 +471,7 @@ class m_admin {
|
||||||
$uid=$db->Record["nextid"];
|
$uid=$db->Record["nextid"];
|
||||||
if ($uid<=2000) $uid=2000;
|
if ($uid<=2000) $uid=2000;
|
||||||
}
|
}
|
||||||
$db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created, notes) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes');");
|
$db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created,notes,db_server_id) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes', '$db_server_id');");
|
||||||
$db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');");
|
$db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');");
|
||||||
$this->renew_update($uid, $duration);
|
$this->renew_update($uid, $duration);
|
||||||
exec("sudo /usr/lib/alternc/mem_add ".$login." ".$uid);
|
exec("sudo /usr/lib/alternc/mem_add ".$login." ".$uid);
|
||||||
|
|
|
@ -301,7 +301,7 @@ class m_mem {
|
||||||
* @return TRUE si la session est correcte, FALSE sinon.
|
* @return TRUE si la session est correcte, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
function unsu() {
|
function unsu() {
|
||||||
global $cuid;
|
global $cuid,$mysql;
|
||||||
if (!$this->olduid)
|
if (!$this->olduid)
|
||||||
return false;
|
return false;
|
||||||
$this->su($this->olduid);
|
$this->su($this->olduid);
|
||||||
|
|
Loading…
Reference in New Issue