diff options
Diffstat (limited to 'inc/functions.php')
-rw-r--r-- | inc/functions.php | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/inc/functions.php b/inc/functions.php index 0303aab6..b830b616 100644 --- a/inc/functions.php +++ b/inc/functions.php | |||
@@ -145,8 +145,6 @@ function prepare_url($url) | |||
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | $msg->add('e', 'error during url preparation'); | ||
149 | logm('error during url preparation'); | ||
150 | return FALSE; | 148 | return FALSE; |
151 | } | 149 | } |
152 | 150 | ||
@@ -331,26 +329,39 @@ function action_to_do($action, $url, $id = 0) | |||
331 | 329 | ||
332 | if (MyTool::isUrl($url)) { | 330 | if (MyTool::isUrl($url)) { |
333 | if($parametres_url = prepare_url($url)) { | 331 | if($parametres_url = prepare_url($url)) { |
334 | $store->add($url, $parametres_url['title'], $parametres_url['content']); | 332 | if ($store->add($url, $parametres_url['title'], $parametres_url['content'])) { |
335 | $last_id = $store->getLastId(); | 333 | $last_id = $store->getLastId(); |
336 | if (DOWNLOAD_PICTURES) { | 334 | if (DOWNLOAD_PICTURES) { |
337 | $content = filtre_picture($parametres_url['content'], $url, $last_id); | 335 | $content = filtre_picture($parametres_url['content'], $url, $last_id); |
336 | } | ||
337 | $msg->add('s', 'the link has been added successfully'); | ||
338 | } | 338 | } |
339 | $msg->add('s', 'the link has been added successfully'); | 339 | else { |
340 | $msg->add('e', 'error during insertion : the link wasn\'t added'); | ||
341 | } | ||
342 | } | ||
343 | else { | ||
344 | $msg->add('e', 'error during url preparation : the link wasn\'t added'); | ||
345 | logm('error during url preparation'); | ||
340 | } | 346 | } |
341 | } | 347 | } |
342 | else { | 348 | else { |
343 | $msg->add('e', 'the link has been added successfully'); | 349 | $msg->add('e', 'error during url preparation : the link is not valid'); |
344 | logm($url . ' is not a valid url'); | 350 | logm($url . ' is not a valid url'); |
345 | } | 351 | } |
346 | 352 | ||
347 | logm('add link ' . $url); | 353 | logm('add link ' . $url); |
348 | break; | 354 | break; |
349 | case 'delete': | 355 | case 'delete': |
350 | remove_directory(ABS_PATH . $id); | 356 | if ($store->deleteById($id)) { |
351 | $store->deleteById($id); | 357 | remove_directory(ABS_PATH . $id); |
352 | $msg->add('s', 'the link has been deleted successfully'); | 358 | $msg->add('s', 'the link has been deleted successfully'); |
353 | logm('delete link #' . $id); | 359 | logm('delete link #' . $id); |
360 | } | ||
361 | else { | ||
362 | $msg->add('e', 'the link wasn\'t deleted'); | ||
363 | logm('error : can\'t delete link #' . $id); | ||
364 | } | ||
354 | break; | 365 | break; |
355 | case 'toggle_fav' : | 366 | case 'toggle_fav' : |
356 | $store->favoriteById($id); | 367 | $store->favoriteById($id); |