diff options
-rw-r--r-- | inc/functions.php | 35 | ||||
-rw-r--r-- | inc/store/sqlite.class.php | 2 |
2 files changed, 25 insertions, 12 deletions
diff --git a/inc/functions.php b/inc/functions.php index 205f3968..750d430e 100644 --- a/inc/functions.php +++ b/inc/functions.php | |||
@@ -125,8 +125,6 @@ function prepare_url($url) | |||
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | $msg->add('e', 'error during url preparation'); | ||
129 | logm('error during url preparation'); | ||
130 | return FALSE; | 128 | return FALSE; |
131 | } | 129 | } |
132 | 130 | ||
@@ -311,26 +309,39 @@ function action_to_do($action, $url, $id = 0) | |||
311 | 309 | ||
312 | if (MyTool::isUrl($url)) { | 310 | if (MyTool::isUrl($url)) { |
313 | if($parametres_url = prepare_url($url)) { | 311 | if($parametres_url = prepare_url($url)) { |
314 | $store->add($url, $parametres_url['title'], $parametres_url['content']); | 312 | if ($store->add($url, $parametres_url['title'], $parametres_url['content'])) { |
315 | $last_id = $store->getLastId(); | 313 | $last_id = $store->getLastId(); |
316 | if (DOWNLOAD_PICTURES) { | 314 | if (DOWNLOAD_PICTURES) { |
317 | $content = filtre_picture($parametres_url['content'], $url, $last_id); | 315 | $content = filtre_picture($parametres_url['content'], $url, $last_id); |
316 | } | ||
317 | $msg->add('s', 'the link has been added successfully'); | ||
318 | } | 318 | } |
319 | $msg->add('s', 'the link has been added successfully'); | 319 | else { |
320 | $msg->add('e', 'error during insertion : the link wasn\'t added'); | ||
321 | } | ||
322 | } | ||
323 | else { | ||
324 | $msg->add('e', 'error during url preparation : the link wasn\'t added'); | ||
325 | logm('error during url preparation'); | ||
320 | } | 326 | } |
321 | } | 327 | } |
322 | else { | 328 | else { |
323 | $msg->add('e', 'the link has been added successfully'); | 329 | $msg->add('e', 'error during url preparation : the link is not valid'); |
324 | logm($url . ' is not a valid url'); | 330 | logm($url . ' is not a valid url'); |
325 | } | 331 | } |
326 | 332 | ||
327 | logm('add link ' . $url); | 333 | logm('add link ' . $url); |
328 | break; | 334 | break; |
329 | case 'delete': | 335 | case 'delete': |
330 | remove_directory(ABS_PATH . $id); | 336 | if ($store->deleteById($id)) { |
331 | $store->deleteById($id); | 337 | remove_directory(ABS_PATH . $id); |
332 | $msg->add('s', 'the link has been deleted successfully'); | 338 | $msg->add('s', 'the link has been deleted successfully'); |
333 | logm('delete link #' . $id); | 339 | logm('delete link #' . $id); |
340 | } | ||
341 | else { | ||
342 | $msg->add('e', 'the link wasn\'t deleted'); | ||
343 | logm('error : can\'t delete link #' . $id); | ||
344 | } | ||
334 | break; | 345 | break; |
335 | case 'toggle_fav' : | 346 | case 'toggle_fav' : |
336 | $store->favoriteById($id); | 347 | $store->favoriteById($id); |
diff --git a/inc/store/sqlite.class.php b/inc/store/sqlite.class.php index d5208a29..cda412e6 100644 --- a/inc/store/sqlite.class.php +++ b/inc/store/sqlite.class.php | |||
@@ -107,6 +107,7 @@ class Sqlite extends Store { | |||
107 | $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)'; | 107 | $sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)'; |
108 | $params_action = array($url, $title, $content); | 108 | $params_action = array($url, $title, $content); |
109 | $query = $this->executeQuery($sql_action, $params_action); | 109 | $query = $this->executeQuery($sql_action, $params_action); |
110 | return $query; | ||
110 | } | 111 | } |
111 | 112 | ||
112 | public function deleteById($id) { | 113 | public function deleteById($id) { |
@@ -114,6 +115,7 @@ class Sqlite extends Store { | |||
114 | $sql_action = "DELETE FROM entries WHERE id=?"; | 115 | $sql_action = "DELETE FROM entries WHERE id=?"; |
115 | $params_action = array($id); | 116 | $params_action = array($id); |
116 | $query = $this->executeQuery($sql_action, $params_action); | 117 | $query = $this->executeQuery($sql_action, $params_action); |
118 | return $query; | ||
117 | } | 119 | } |
118 | 120 | ||
119 | public function favoriteById($id) { | 121 | public function favoriteById($id) { |