From 37cad52229ac61b13f69440243df54e0e2a4536f Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 22 Dec 2014 16:26:23 +0100 Subject: don't call flattr if flattr is disabled --- inc/poche/Poche.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 27d6f4a6..a29cb327 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -405,9 +405,12 @@ class Poche } # flattr checking - $flattr = new FlattrItem(); - $flattr->checkItem($entry['url'], $entry['id']); - + $flattr = NULL; + if (FLATTR) { + $flattr = new FlattrItem(); + $flattr->checkItem($entry['url'], $entry['id']); + } + # tags $tags = $this->store->retrieveTagsByEntry($entry['id']); @@ -812,4 +815,4 @@ class Poche } -} \ No newline at end of file +} -- cgit v1.2.3 From c86b40f014848b2f9ccf4dfbead71694a41be569 Mon Sep 17 00:00:00 2001 From: Guillaume Virlet Date: Wed, 14 May 2014 15:45:52 +0200 Subject: add message in web server log in case of authentication failure to enable the usage of fail2ban on failed login attempts --- inc/poche/Poche.class.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index a29cb327..75766919 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -543,6 +543,8 @@ class Poche Tools::redirect($referer); } $this->messages->add('e', _('login failed: bad login or password')); + // log login failure in web server log to allow fail2ban usage + error_log('user '.$login.' authentication failure'); Tools::logm('login failed'); Tools::redirect(); } -- cgit v1.2.3 From 7f782e44965b005efe01d347dedd1825872b9345 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Mon, 12 Jan 2015 18:49:05 -0500 Subject: Add ability to tag an article on creation --- inc/poche/Poche.class.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index a29cb327..c7c59878 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -180,6 +180,13 @@ class Poche } } + // if there are tags, add them to the new article + if (isset($_GET['tags'])) { + $_POST['value'] = $_GET['tags']; + $_POST['entry_id'] = $last_id; + $this->action('add_tag', $url); + } + $this->messages->add('s', _('the link has been added successfully')); } else { -- cgit v1.2.3 From 512e5e5bd195ea4547dc7fa29f34a9d205bd7a54 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Mon, 12 Jan 2015 19:11:45 -0500 Subject: Add ability to delete all articles matching a search --- inc/poche/Poche.class.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index c7c59878..540aa55e 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -201,18 +201,31 @@ class Poche } break; case 'delete': - $msg = 'delete link #' . $id; - if ($this->store->deleteById($id, $this->user->getId())) { - if (DOWNLOAD_PICTURES) { - Picture::removeDirectory(ABS_PATH . $id); + if (isset($_GET['search'])) { + //when we want to apply a delete to a search + $tags = array($_GET['search']); + $allentry_ids = $this->store->search($tags[0], $this->user->getId()); + $entry_ids = array(); + foreach ($allentry_ids as $eachentry) { + $entry_ids[] = $eachentry[0]; } - $this->messages->add('s', _('the link has been deleted successfully')); + } else { // delete a single article + $entry_ids = array($id); } - else { - $this->messages->add('e', _('the link wasn\'t deleted')); - $msg = 'error : can\'t delete link #' . $id; + foreach($entry_ids as $id) { + $msg = 'delete link #' . $id; + if ($this->store->deleteById($id, $this->user->getId())) { + if (DOWNLOAD_PICTURES) { + Picture::removeDirectory(ABS_PATH . $id); + } + $this->messages->add('s', _('the link has been deleted successfully')); + } + else { + $this->messages->add('e', _('the link wasn\'t deleted')); + $msg = 'error : can\'t delete link #' . $id; + } + Tools::logm($msg); } - Tools::logm($msg); Tools::redirect('?'); break; case 'toggle_fav' : -- cgit v1.2.3 From 13c7f9a462b71e89d5e252b693fc7d00aca249ec Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Mon, 12 Jan 2015 19:52:41 -0500 Subject: Add ability to mark all articles from a tag as read --- inc/poche/Poche.class.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 540aa55e..20897c61 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -240,8 +240,21 @@ class Poche } break; case 'toggle_archive' : - $this->store->archiveById($id, $this->user->getId()); - Tools::logm('archive link #' . $id); + if (isset($_GET['tag_id'])) { + //when we want to archive a whole tag + $tag_id = $_GET['tag_id']; + $allentry_ids = $this->store->retrieveEntriesByTag($tag_id, $this->user->getId()); + $entry_ids = array(); + foreach ($allentry_ids as $eachentry) { + $entry_ids[] = $eachentry[0]; + } + } else { //archive a single article + $entry_ids = array($id); + } + foreach($entry_ids as $id) { + $this->store->archiveById($id, $this->user->getId()); + Tools::logm('archive link #' . $id); + } if ( Tools::isAjaxRequest() ) { echo 1; exit; -- cgit v1.2.3 From 7fe8a9adc44a73221959263b08b516ec20bf85a0 Mon Sep 17 00:00:00 2001 From: Vincent Malley Date: Fri, 16 Jan 2015 11:42:39 -0500 Subject: [RSS] introducing query param 'limit' to restrict the number of items to display in RSS feeds. --- inc/poche/Poche.class.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 20897c61..6a742019 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -784,10 +784,11 @@ class Poche * * @param $token * @param $user_id - * @param $tag_id - * @param string $type + * @param $tag_id if $type is 'tag', the id of the tag to generate feed for + * @param string $type the type of feed to generate + * @param int $limit the maximum number of items (0 means all) */ - public function generateFeeds($token, $user_id, $tag_id, $type = 'home') + public function generateFeeds($token, $user_id, $tag_id, $type = 'home', $limit = 0) { $allowed_types = array('home', 'fav', 'archive', 'tag'); $config = $this->store->getConfigUser($user_id); @@ -814,8 +815,13 @@ class Poche $entries = $this->store->getEntriesByView($type, $user_id); } + // if $limit is set to zero, use all entries + if (0 == $limit) { + $limit = count($entries); + } if (count($entries) > 0) { - foreach ($entries as $entry) { + for ($i = 0; $i < min(count($entries), $limit); $i++) { + $entry = $entries[$i]; $newItem = $feed->createNewItem(); $newItem->setTitle($entry['title']); $newItem->setSource(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']); -- cgit v1.2.3 From 3052cfb7cab3b37e7258f31d18624a9335c0680f Mon Sep 17 00:00:00 2001 From: kaffeeringe Date: Sun, 18 Jan 2015 21:49:05 +0100 Subject: Add Tags on Import I fixed it! And it works for me. But: I am not too good with programming. So better check the code ;-) --- inc/poche/Poche.class.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 16235474..01f919d9 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -192,6 +192,7 @@ class Poche } else { Tools::redirect('?view=home&closewin=true'); } + return $last_id; break; case 'delete': $msg = 'delete link #' . $id; @@ -625,7 +626,18 @@ class Poche $urlsInserted[] = $url; //add if (isset($record['tags']) && trim($record['tags'])) { - // @TODO: set tags + $tags = explode(' ', $record['tags']); + foreach($tags as $tag) { + $entry_id = $id; + $tag_id = $this->store->retrieveTagByValue($tag); + if ($tag_id) { + $this->store->setTagToEntry($tag_id['id'], $entry_id); + } else { + $this->store->createTag($tag); + $tag_id = $this->store->retrieveTagByValue($tag); + $this->store->setTagToEntry($tag_id['id'], $entry_id); + } + } } } -- cgit v1.2.3 From 9a490ad63a08c619bb45ad9bf090790c31ebe92e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Jan 2015 00:02:21 +0100 Subject: from spaces to commas --- inc/poche/Poche.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/poche/Poche.class.php') diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 5a0edbe4..81a18c86 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -664,7 +664,7 @@ class Poche $urlsInserted[] = $url; //add if (isset($record['tags']) && trim($record['tags'])) { - $tags = explode(' ', $record['tags']); + $tags = explode(',', $record['tags']); foreach($tags as $tag) { $entry_id = $id; $tag_id = $this->store->retrieveTagByValue($tag); -- cgit v1.2.3