From: Nicolas LÅ“uillet Date: Fri, 16 Jan 2015 19:06:57 +0000 (+0100) Subject: Merge pull request #690 from doc75/log_auth_error X-Git-Tag: 1.9beta~34 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=170a1407fea8b43a62854e115f90fd5cace44f01;hp=c86b40f014848b2f9ccf4dfbead71694a41be569;p=github%2Fwallabag%2Fwallabag.git Merge pull request #690 from doc75/log_auth_error Add message in web server log in case of authentication failure --- diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 75766919..8b0d3a19 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 { @@ -194,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' : @@ -220,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; @@ -753,10 +786,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); @@ -783,8 +817,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']); diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php index 5acd08ba..be06a433 100755 --- a/inc/poche/Routing.class.php +++ b/inc/poche/Routing.class.php @@ -102,7 +102,8 @@ class Routing $this->wallabag->login($this->referer); } elseif (isset($_GET['feed']) && isset($_GET['user_id'])) { $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); - $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type']); + $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0); + $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit); } //allowed ONLY to logged in user diff --git a/themes/baggy/home.twig b/themes/baggy/home.twig index abebe455..93515080 100755 --- a/themes/baggy/home.twig +++ b/themes/baggy/home.twig @@ -59,7 +59,11 @@ {{ block('pager') }} {% if view == 'home' %}{% if nb_results > 1 %}

{% trans "Mark all the entries as read" %}

{% endif %}{% endif %} {% if searchterm is defined %}{% trans "Tag these results as" %} {{ searchterm }}{% endif %}
- + + {% if searchterm is defined %}{% trans "Delete results matching" %} {{ searchterm }}{% endif %}
+ + {% if tag %}{% trans "Mark all articles from this tag as read" %}
{% endif %} + {% if tag %} {% if constant('EPUB') == 1 %}{% trans "Download as ePub3" %}{% endif %} {% if constant('MOBI') == 1 %}{% trans "Download as Mobi" %}{% endif %} diff --git a/themes/default/home.twig b/themes/default/home.twig index c5db5802..b9000559 100755 --- a/themes/default/home.twig +++ b/themes/default/home.twig @@ -59,7 +59,11 @@ {{ block('pager') }} {% if view == 'home' %}{% if nb_results > 1 %}

{% trans "Mark all the entries as read" %}

{% endif %}{% endif %} {% if searchterm is defined %}{% trans "Tag these results as" %} {{ searchterm }}{% endif %}
- + + {% if searchterm is defined %}{% trans "Delete results matching" %} {{ searchterm }}{% endif %}
+ + {% if tag %}{% trans "Mark all articles from this tag as read" %}
{% endif %} + {% if tag %} {% if constant('EPUB') == 1 %}{% trans "Download as ePub3" %}{% endif %} {% if constant('MOBI') == 1 %}{% trans "Download as Mobi" %}{% endif %} @@ -73,6 +77,6 @@ {% if constant('MOBI') == 1 %}{% trans "Download as Mobi" %}{% endif %} {% if constant('PDF') == 1 %}{% trans "Download as PDF" %}{% endif %} {% endif %} - + {% endif %} {% endblock %}