noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 08/11: Task #1207 - Administration MODELE #1


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 08/11: Task #1207 - Administration MODELE #1207 : permet d'effacer des modèles vides
Date: Thu, 05 Nov 2015 10:21:11 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 928ffdc5821651fa5eaab2753be14a1f7036f4c8
Author: Dany De Bontridder <address@hidden>
Date:   Thu Nov 5 10:15:13 2015 +0100

    Task #1207 - Administration MODELE
    #1207 : permet d'effacer des modèles vides
---
 include/modele.inc.php |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/include/modele.inc.php b/include/modele.inc.php
index fe6bd3d..7740592 100644
--- a/include/modele.inc.php
+++ b/include/modele.inc.php
@@ -399,29 +399,38 @@ if ($sa == 'list')
                        echo HtmlInput::button_anchor(_('Retour'), 
'?action=modele_mgt');
                        return;
                }
-
+                $mod_id=HtmlInput::default_value_request('m', 0);
+                if ( $mod_id == 0 || isNumber($mod_id) == 0 )
+                {
+                    echo _('Donnée invalide');
+                    return;
+                }
                $cn = new Database();
                $msg = "dossier";
-               $name = $cn->get_value("select mod_name from modeledef where 
mod_id=$1", array($_REQUEST['m']));
+               $name = $cn->get_value("select mod_name from modeledef where 
mod_id=$1", array($mod_id));
                if (strlen(trim($name)) == 0)
                {
                        echo "<h2 class=\"error\"> $msg inexistant</h2>";
                        return;
                }
-               $sql = "drop database " . domaine . "mod" . 
sql_string($_REQUEST['m']);
-               ob_start();
-               if ($cn->exec_sql($sql) == false)
-               {
-                       ob_end_clean();
+                // Before dropping database check that database exist
+                if ( $cn->exist_database(domaine.'mod'.$mod_id) == 1) 
+                {
+                    $sql = "drop database " . domaine . "mod" . 
sql_string($mod_id);
+                    ob_start();
+                    if ($cn->exec_sql($sql) == false)
+                    {
+                            ob_end_clean();
 
-                       echo "<h2 class=\"error\">";
-                        printf (_("Base de donnée %s mod %s est accèdée, 
déconnectez-vous d'abord"),domaine,$_REQUEST['m'] )
-                                . "</h2>";
-                       exit;
-               }
-               ob_flush();
+                            echo "<h2 class=\"error\">";
+                            printf (_("Base de donnée %s mod %s est accèdée, 
déconnectez-vous d'abord"),domaine,$mod_id )
+                                    . "</h2>";
+                            exit;
+                    }
+                    ob_flush();
+                }
                $sql = "delete from modeledef where mod_id=$1";
-               $cn->exec_sql($sql, array($_REQUEST['m']));
+               $cn->exec_sql($sql, array($mod_id));
                print '<h2 class="error">';
                printf (_("Le modèle %s est effacé")."</H2>",$name );
                echo HtmlInput::button_anchor(_('Retour'), 
'?action=modele_mgt');



reply via email to

[Prev in Thread] Current Thread [Next in Thread]