aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-xinc/poche/Poche.class.php44
1 files changed, 31 insertions, 13 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index baa08788..ea196ce2 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -266,6 +266,15 @@ class Poche
266 } 266 }
267 foreach($entry_ids as $id) { 267 foreach($entry_ids as $id) {
268 $msg = 'delete link #' . $id; 268 $msg = 'delete link #' . $id;
269
270 // deleting tags and tags_entries
271 $tags = $this->store->retrieveTagsByEntry($id);
272 foreach ($tags as $tag) {
273 $this->store->removeTagForEntry($id, $tag['id']);
274 $this->store->cleanUnusedTag($tag['id']);
275 }
276
277 // deleting pictures
269 if ($this->store->deleteById($id, $this->user->getId())) { 278 if ($this->store->deleteById($id, $this->user->getId())) {
270 if (DOWNLOAD_PICTURES) { 279 if (DOWNLOAD_PICTURES) {
271 Picture::removeDirectory(ABS_PATH . $id); 280 Picture::removeDirectory(ABS_PATH . $id);
@@ -278,7 +287,7 @@ class Poche
278 } 287 }
279 Tools::logm($msg); 288 Tools::logm($msg);
280 } 289 }
281 Tools::redirect(); 290 Tools::redirect('?');
282 break; 291 break;
283 case 'toggle_fav' : 292 case 'toggle_fav' :
284 $this->store->favoriteById($id, $this->user->getId()); 293 $this->store->favoriteById($id, $this->user->getId());
@@ -441,6 +450,7 @@ class Poche
441 $token = $this->user->getConfigValue('token'); 450 $token = $this->user->getConfigValue('token');
442 $http_auth = (isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['REMOTE_USER'])) ? true : false; 451 $http_auth = (isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['REMOTE_USER'])) ? true : false;
443 $only_user = ($this->store->listUsers() > 1) ? false : true; 452 $only_user = ($this->store->listUsers() > 1) ? false : true;
453 $https = substr(Tools::getPocheUrl(), 0, 5) == 'https';
444 $tpl_vars = array( 454 $tpl_vars = array(
445 'themes' => $themes, 455 'themes' => $themes,
446 'languages' => $languages, 456 'languages' => $languages,
@@ -453,7 +463,8 @@ class Poche
453 'token' => $token, 463 'token' => $token,
454 'user_id' => $this->user->getId(), 464 'user_id' => $this->user->getId(),
455 'http_auth' => $http_auth, 465 'http_auth' => $http_auth,
456 'only_user' => $only_user 466 'only_user' => $only_user,
467 'https' => $https
457 ); 468 );
458 Tools::logm('config view'); 469 Tools::logm('config view');
459 break; 470 break;
@@ -590,7 +601,7 @@ class Poche
590 601
591 $count = $this->store->getEntriesByViewCount($view, $this->user->getId(), $id); 602 $count = $this->store->getEntriesByViewCount($view, $this->user->getId(), $id);
592 603
593 if ($count > 0) { 604 if ($count && $count > 0) {
594 $this->pagination->set_total($count); 605 $this->pagination->set_total($count);
595 $page_links = str_replace(array('previous', 'next'), array(_('previous'), _('next')), 606 $page_links = str_replace(array('previous', 'next'), array(_('previous'), _('next')),
596 $this->pagination->page_links('?view=' . $view . '&sort=' . $_SESSION['sort'] . (($id)?'&id='.$id:'') . '&' )); 607 $this->pagination->page_links('?view=' . $view . '&sort=' . $_SESSION['sort'] . (($id)?'&id='.$id:'') . '&' ));
@@ -894,14 +905,18 @@ class Poche
894 */ 905 */
895 public function export() 906 public function export()
896 { 907 {
897 $filename = "wallabag-export-".$this->user->getId()."-".date("Y-m-d").".json"; 908 $filename = "wallabag-export-".$this->user->getId()."-".date("Y-m-d").".json";
898 header('Content-Disposition: attachment; filename='.$filename); 909 header('Content-Disposition: attachment; filename='.$filename);
899 910
900 $entries = $this->store->retrieveAllWithTags($this->user->getId()); 911 $entries = $this->store->retrieveAllWithTags($this->user->getId());
901 echo $this->tpl->render('export.twig', array( 912 if ($entries) {
902 'export' => Tools::renderJson($entries), 913 echo $this->tpl->render('export.twig', array(
903 )); 914 'export' => Tools::renderJson($entries),
904 Tools::logm('export view'); 915 ));
916 Tools::logm('export view');
917 } else {
918 Tools::logm('error accessing database while exporting');
919 }
905 } 920 }
906 921
907 /** 922 /**
@@ -977,7 +992,7 @@ class Poche
977 if (0 == $limit) { 992 if (0 == $limit) {
978 $limit = count($entries); 993 $limit = count($entries);
979 } 994 }
980 if (count($entries) > 0) { 995 if ($entries && count($entries) > 0) {
981 for ($i = 0; $i < min(count($entries), $limit); $i++) { 996 for ($i = 0; $i < min(count($entries), $limit); $i++) {
982 $entry = $entries[$i]; 997 $entry = $entries[$i];
983 $newItem = $feed->createNewItem(); 998 $newItem = $feed->createNewItem();
@@ -989,7 +1004,10 @@ class Poche
989 $feed->addItem($newItem); 1004 $feed->addItem($newItem);
990 } 1005 }
991 } 1006 }
992 1007 else
1008 {
1009 Tools::logm("database error while generating feeds");
1010 }
993 $feed->genarateFeed(); 1011 $feed->genarateFeed();
994 exit; 1012 exit;
995 } 1013 }