From cfd495d1f2af98cedae0c3fb20f4daa25b435e89 Mon Sep 17 00:00:00 2001
From: Alan Garcia
Date: Thu, 17 Jan 2013 10:09:48 +0000
Subject: [PATCH] =?UTF-8?q?Fusion=20des=20formulaire=20d'=C3=A9dition/cr?=
=?UTF-8?q?=C3=A9ation=20FTP.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fix #1402
---
.gitattributes | 2 -
bureau/admin/bro_main.php | 2 +-
bureau/admin/ftp_add.php | 83 -------------------------------------
bureau/admin/ftp_doadd.php | 57 -------------------------
bureau/admin/ftp_doedit.php | 44 ++++++++++++--------
bureau/admin/ftp_edit.php | 34 +++++++++------
bureau/admin/ftp_list.php | 2 +-
bureau/admin/menu_ftp.php | 2 +-
8 files changed, 51 insertions(+), 175 deletions(-)
delete mode 100644 bureau/admin/ftp_add.php
delete mode 100644 bureau/admin/ftp_doadd.php
diff --git a/.gitattributes b/.gitattributes
index 6db0b974..9c83faac 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -150,9 +150,7 @@ bureau/admin/dom_substatus.php -text
bureau/admin/domlist.php -text
bureau/admin/favicon.ico -text
bureau/admin/foot.php -text
-bureau/admin/ftp_add.php -text
bureau/admin/ftp_del.php -text
-bureau/admin/ftp_doadd.php -text
bureau/admin/ftp_doedit.php -text
bureau/admin/ftp_edit.php -text
bureau/admin/ftp_list.php -text
diff --git a/bureau/admin/bro_main.php b/bureau/admin/bro_main.php
index e4d43b55..871b556a 100644
--- a/bureau/admin/bro_main.php
+++ b/bureau/admin/bro_main.php
@@ -588,7 +588,7 @@ else {
else {
?>
-
+
cancreate("ftp")) {
- $error=_("You cannot add any new ftp account, your quota is over.");
- $fatal=1;
-}
-
-$fields = array (
- "id" => array ("post", "integer", 0),
- "prefixe" => array ("post", "string", ""),
- "login" => array ("post", "string", ""),
- "dir" => array ("post", "string", ""),
- "pass" => array ("post", "string", ""),
- "passconf" => array ("post", "string", ""),
- "submit" => array ("post", "string", ""),
-);
-getFields($fields);
-
-
-?>
-
-
-
-$error
";
- if (isset($fatal) && $fatal) {
- include_once("foot.php");
- exit();
- }
-}
-?>
-
-show_help("ftp_add"); ?>
-
-
diff --git a/bureau/admin/ftp_doadd.php b/bureau/admin/ftp_doadd.php
deleted file mode 100644
index 2bfcf8d9..00000000
--- a/bureau/admin/ftp_doadd.php
+++ /dev/null
@@ -1,57 +0,0 @@
- array ("post", "string", ""),
- "login" => array ("post", "string", ""),
- "dir" => array ("post", "string", ""),
- "pass" => array ("post", "string", ""),
- "passconf" => array ("post", "string", ""),
-);
-getFields($fields);
-
-if ($pass != $passconf) {
- $error = _("Passwords do not match");
- include("ftp_add.php");
- exit();
-}
-
-$r=$ftp->add_ftp($prefixe,$login,$pass,$dir);
-if (!$r) {
- $error=$err->errstr();
- include("ftp_add.php");
- exit();
-} else {
- $error=_("The FTP account has been successfully created");
- include("ftp_list.php");
- exit();
-}
-?>
diff --git a/bureau/admin/ftp_doedit.php b/bureau/admin/ftp_doedit.php
index f5f10678..1e64b3a4 100644
--- a/bureau/admin/ftp_doedit.php
+++ b/bureau/admin/ftp_doedit.php
@@ -30,6 +30,7 @@
require_once("../class/config.php");
$fields = array (
"id" => array ("post", "integer", ""),
+ "create" => array ("post", "integer", ""),
"pass" => array ("post", "string", ""),
"passconf" => array ("post", "string", ""),
"prefixe" => array ("post", "string", ""),
@@ -39,25 +40,32 @@ $fields = array (
getFields($fields);
-if (!$id) {
- $error=_("No account selected!");
-} else {
- if ($pass != $passconf) {
- $error = _("Passwords do not match");
- include("ftp_edit.php");
- exit();
- }
+if ($pass != $passconf) {
+ $error = _("Passwords do not match");
+ include("ftp_edit.php");
+ exit();
+}
- $r=$ftp->put_ftp_details($id,$prefixe,$login,$pass,$dir);
- if (!$r) {
- $error=$err->errstr();
- include("ftp_edit.php");
- exit();
- } else {
- $error=_("The ftp account has been successfully changed");
- include("ftp_list.php");
- exit();
- }
+if (! $id && !$create) { //not a creation and not an edit
+ $error=_("Error: neither a creation nor an edition");
+ include("ftp_list.php");
+ exit();
+}
+
+if (! $id ) { //create
+ $r=$ftp->add_ftp($prefixe,$login,$pass,$dir);
+} else { // edit
+ $r=$ftp->put_ftp_details($id,$prefixe,$login,$pass,$dir);
+}
+
+if (!$r) {
+ $error=$err->errstr();
+ include("ftp_edit.php");
+ exit();
+} else {
+ $error=_("The ftp account has been successfully changed");
+ include("ftp_list.php");
+ exit();
}
include_once("head.php");
diff --git a/bureau/admin/ftp_edit.php b/bureau/admin/ftp_edit.php
index f7a2da0c..1f2ba334 100644
--- a/bureau/admin/ftp_edit.php
+++ b/bureau/admin/ftp_edit.php
@@ -31,20 +31,29 @@ require_once("../class/config.php");
include_once("head.php");
$fields = array (
- "id" => array ("request", "integer", ""),
+ "id" => array ("request", "integer", ""),
+ "create" => array ("get", "integer", "0"),
+ "dir" => array ("get", "string", "0"),
);
getFields($fields);
-if (!$id) {
- $error=_("No account selected!");
-} else {
- $r=$ftp->get_ftp_details($id);
- if (!$r) {
- $error=$err->errstr();
- }
+if (!$id && !$create) {
+ $error=_("Neither a creation nor a edition");
+ include_once("foot.php");
+ exit();
}
+
+if (!$id && $create) { //creation
+ echo ""._("Create a FTP account")."
";
+} else {
+ echo ""._("Editing a FTP account")."
";
+ $r=$ftp->get_ftp_details($id);
+ if (!$r) {
+ $error=$err->errstr();
+ }
+}
+
?>
-
$error";
@@ -55,10 +64,11 @@ if (isset($error) && $error) {