]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
messages d'erreur si pas possible d'ajouter ou de supprimer un lien
authornicosomb <nicolas@loeuillet.org>
Tue, 23 Apr 2013 07:38:57 +0000 (09:38 +0200)
committernicosomb <nicolas@loeuillet.org>
Tue, 23 Apr 2013 07:38:57 +0000 (09:38 +0200)
inc/functions.php
inc/store/sqlite.class.php

index 205f3968130dd51da4809679ca5ae2cb758479dc..750d430e125cfe1a95d6589c89a544d60a3b044e 100644 (file)
@@ -125,8 +125,6 @@ function prepare_url($url)
         }
     }
 
-    $msg->add('e', 'error during url preparation');
-    logm('error during url preparation');
     return FALSE;
 }
 
@@ -311,26 +309,39 @@ function action_to_do($action, $url, $id = 0)
 
             if (MyTool::isUrl($url)) {
                 if($parametres_url = prepare_url($url)) {
-                    $store->add($url, $parametres_url['title'], $parametres_url['content']);
-                    $last_id = $store->getLastId();
-                    if (DOWNLOAD_PICTURES) {
-                        $content = filtre_picture($parametres_url['content'], $url, $last_id);
+                    if ($store->add($url, $parametres_url['title'], $parametres_url['content'])) {
+                        $last_id = $store->getLastId();
+                        if (DOWNLOAD_PICTURES) {
+                            $content = filtre_picture($parametres_url['content'], $url, $last_id);
+                        }
+                        $msg->add('s', 'the link has been added successfully');
                     }
-                    $msg->add('s', 'the link has been added successfully');
+                    else {
+                        $msg->add('e', 'error during insertion : the link wasn\'t added');
+                    }
+                }
+                else {
+                    $msg->add('e', 'error during url preparation : the link wasn\'t added');
+                    logm('error during url preparation');
                 }
             }
             else {
-                $msg->add('e', 'the link has been added successfully');
+                $msg->add('e', 'error during url preparation : the link is not valid');
                 logm($url . ' is not a valid url');
             }
 
             logm('add link ' . $url);
             break;
         case 'delete':
-            remove_directory(ABS_PATH . $id);
-            $store->deleteById($id);
-            $msg->add('s', 'the link has been deleted successfully');
-            logm('delete link #' . $id);
+            if ($store->deleteById($id)) {
+                remove_directory(ABS_PATH . $id);
+                $msg->add('s', 'the link has been deleted successfully');
+                logm('delete link #' . $id);
+            }
+            else {
+                $msg->add('e', 'the link wasn\'t deleted');
+                logm('error : can\'t delete link #' . $id);
+            }
             break;
         case 'toggle_fav' :
             $store->favoriteById($id);
index d5208a295865e488118d307c2168143326a5d883..cda412e6b8659766abda8e12fd5275d314416a0e 100644 (file)
@@ -107,6 +107,7 @@ class Sqlite extends Store {
         $sql_action     = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
         $params_action  = array($url, $title, $content);
         $query          = $this->executeQuery($sql_action, $params_action);
+        return $query;
     }
 
     public function deleteById($id) {
@@ -114,6 +115,7 @@ class Sqlite extends Store {
         $sql_action     = "DELETE FROM entries WHERE id=?";
         $params_action  = array($id);
         $query          = $this->executeQuery($sql_action, $params_action);
+        return $query;
     }
 
     public function favoriteById($id) {