X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=mw_pages.php;h=bb6d9b6f2e752bc700f5345064edd58b9336bce7;hb=refs%2Ftags%2Fmw_pages.0.4;hp=19119b9035de5c56580d473beba2248c333e8611;hpb=45a6dd3372d573176aaf5d3e2232091ba3173e04;p=mw_pages diff --git a/mw_pages.php b/mw_pages.php index 19119b9..bb6d9b6 100644 --- a/mw_pages.php +++ b/mw_pages.php @@ -101,31 +101,43 @@ function install_sqlite($env){ $data = $env->data(); $sgbd = $data->sgbd(); - $EXISTS = $sgbd->table_exists("#--pages"); - if(!isset($EXISTS)){ + try{ + $EXISTS = $sgbd->table_exists("#--pages"); + } + catch(Exception $e){ return "impossible de savoir si la table #--pages existe"; } if($EXISTS){ return "la table #--pages existe deja"; } - $sql = - "CREATE TABLE #--pages" - ."( id INTEGER NOT NULL PRIMARY KEY" - .", id_parent INTEGER NULL" - .", title VARCHAR NULL" - .", content TEXT NULL" - .", date_creation TEXT NOT NULL" - .", user_creation INTEGER NOT NULL" - .", date_last_update TEXT NOT NULL" - .", user_last_update INTEGER NOT NULL" - .", enabled INTEGER NOT NULL DEFAULT 1" - .", position INTEGER NOT NULL DEFAULT 0" - .")"; - if(!$sgbd->query($sql)){ + try{ + $sql = + "CREATE TABLE #--pages" + ."( id INTEGER NOT NULL PRIMARY KEY" + .", id_parent INTEGER NULL" + .", title VARCHAR NULL" + .", content TEXT NULL" + .", date_creation TEXT NOT NULL" + .", user_creation INTEGER NOT NULL" + .", date_last_update TEXT NOT NULL" + .", user_last_update INTEGER NOT NULL" + .", enabled INTEGER NOT NULL DEFAULT 1" + .", position INTEGER NOT NULL DEFAULT 0" + .")"; + $sgbd->query($sql); + } + catch(Exception $e){ return "imposible de creer la table #--pages"; } - if(!$sgbd->query("INSERT INTO #--action_status(action, id_status) VALUES('pages/admin', 1)")){ - $sgbd->query("DROP TABLE \"main\".\"#--pages\""); + $DELETE_TABLE = false; + try{ + $sgbd->query("INSERT INTO #--action_status(action, id_status) VALUES('pages/admin', 1)"); + } + catch(Exception $e){ + try{ + $sgbd->query("DROP TABLE \"main\".\"#--pages\""); + } + catch(Exception $e){} return "impossible d'ajouter un statut pour l'action pages/admin"; } return true; @@ -134,31 +146,42 @@ function install_mysql($env){ $data = $env->data(); $sgbd = $data->sgbd(); - $EXISTS = $sgbd->table_exists("#--pages"); - if(!isset($EXISTS)){ + try{ + $EXISTS = $sgbd->table_exists("#--pages"); + } + catch(Exception $e){ return "impossible de savoir si la table #--pages existe"; } if($EXISTS){ return "la table #--pages existe deja"; } - $sql = - "CREATE TABLE #--pages" - ."( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY" - .", id_parent INT(11) NULL" - .", title VARCHAR(255) NULL" - .", content TEXT NULL" - .", date_creation DATETIME NOT NULL" - .", user_creation INT(11) NOT NULL" - .", date_last_update DATETIME NOT NULL" - .", user_last_update INT(11) NOT NULL" - .", enabled TINYINT NOT NULL DEFAULT '1'" - .", position INT(11) NOT NULL DEFAULT '0'" - .") DEFAULT CHARSET=utf8"; - if(!$sgbd->query($sql)){ + try{ + $sql = + "CREATE TABLE #--pages" + ."( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY" + .", id_parent INT(11) NULL" + .", title VARCHAR(255) NULL" + .", content TEXT NULL" + .", date_creation DATETIME NOT NULL" + .", user_creation INT(11) NOT NULL" + .", date_last_update DATETIME NOT NULL" + .", user_last_update INT(11) NOT NULL" + .", enabled TINYINT NOT NULL DEFAULT '1'" + .", position INT(11) NOT NULL DEFAULT '0'" + .") DEFAULT CHARSET=utf8"; + $sgbd->query($sql); + } + catch(Exception $e){ return "imposible de creer la table #--pages"; } - if(!$sgbd->query("INSERT INTO #--action_status(action, id_status) VALUES('pages/admin', 1)")){ - $sgbd->query("DROP TABLE #--pages"); + try{ + $sgbd->query("INSERT INTO #--action_status(action, id_status) VALUES('pages/admin', 1)"); + } + catch(Exception $e){ + try{ + $sgbd->query("DROP TABLE #--pages"); + } + catch(Exception $e){} return "impossible d'ajouter un statut pour l'action pages/admin"; } return true; @@ -214,17 +237,31 @@ $sgbd = $data->sgbd(); if(!$this->disable($env)) return "impossible de desactiver le plugin"; $data->del_config("plugins_pages_start_id"); - $EXISTS = $sgbd->table_exists("#--pages"); - if(!isset($EXISTS)){ + try{ + $EXISTS = $sgbd->table_exists("#--pages"); + } + catch(Exception $e){ return "impossible de savoir si la table #--pages existe"; } if(!$EXISTS){ // return "la table #--pages n'existe pas"; } - elseif(!$sgbd->query("DROP TABLE \"main\".\"#--pages\"")){ - return "imposible de supprimer la table #--pages"; + else{ + try{ + $sgbd->query("DROP TABLE \"main\".\"#--pages\""); + } + catch(Exception $e){ + return "imposible de supprimer la table #--pages"; + } + } + try{ + $sgbd->query("DELETE FROM #--action_status WHERE action='pages/admin'"); + } + catch(Exception $e){ + return + "Le plugin a bien été désinstallé" + ." mais impossible d'enlever les droits pages/admin/* de la table action_status"; } - $sgbd->query("DELETE FROM #--action_status WHERE action='pages/admin'"); return true; } @@ -233,17 +270,31 @@ $sgbd = $data->sgbd(); if(!$this->disable($env)) return "impossible de desactiver le plugin"; $data->del_config("plugins_pages_start_id"); - $EXISTS = $sgbd->table_exists("#--pages"); - if(!isset($EXISTS)){ + try{ + $EXISTS = $sgbd->table_exists("#--pages"); + } + catch(Exception $e){ return "impossible de savoir si la table #--pages existe"; } if(!$EXISTS){ // return "la table #--pages n'existe pas"; } - elseif(!$sgbd->query("DROP TABLE #--pages")){ - return "imposible de supprimer la table #--pages"; + else{ + try{ + $sgbd->query("DROP TABLE #--pages"); + } + catch(Exception $e){ + return "imposible de supprimer la table #--pages"; + } + } + try{ + $sgbd->query("DELETE FROM #--action_status WHERE action='pages/admin'"); + } + catch(Exception $e){ + return + "Le plugin a bien été désinstallé" + ." mais impossible d'enlever les droits pages/admin/* de la table action_status"; } - $sgbd->query("DELETE FROM #--action_status WHERE action='pages/admin'"); return true; }