]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #690 from doc75/log_auth_error
authorNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 16 Jan 2015 19:06:57 +0000 (20:06 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 16 Jan 2015 19:06:57 +0000 (20:06 +0100)
Add message in web server log in case of authentication failure

inc/poche/Poche.class.php
inc/poche/Routing.class.php
themes/baggy/home.twig
themes/default/home.twig

index 757669194872acca7c70025adf214cb4a83e1fdc..8b0d3a19fad82d1a828772a82d88e591a98689f1 100755 (executable)
@@ -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&amp;id=' . $entry['id']);
index 5acd08ba608d0704b8d6a76e2152363ba4afe808..be06a433dce544c17a72c5d015a4b0f083348fe6 100755 (executable)
@@ -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
index abebe455f11d159f742c1ffe8141e1e6a4f6ccd2..93515080d20f83ade7c672ed610357703f17e14c 100755 (executable)
             {{ block('pager') }}
             {% if view == 'home' %}{% if nb_results > 1 %}<p><a title="{% trans "Mark all the entries as read" %}"  href="./?action=archive_all">{% trans "Mark all the entries as read" %}</a></p>{% endif %}{% endif %}
             {% if searchterm is defined %}<a title="{% trans "Tag these results as" %} {{ searchterm }}" href="./?action=add_tag&search={{ searchterm }}">{% trans "Tag these results as" %} {{ searchterm }}</a>{% endif %}<br />
-            
+
+            {% if searchterm is defined %}<a title="{% trans "Delete results matching" %} {{ searchterm }}" href="./?action=delete&search={{ searchterm }}">{% trans "Delete results matching" %} {{ searchterm }}</a>{% endif %}<br />
+
+            {% if tag %}<a title="{% trans "Mark all articles from this tag as read" %}" href="./?action=toggle_archive&amp;tag_id={{ tag.id }}">{% trans "Mark all articles from this tag as read" %}</a><br />{% endif %}
+
             {% if tag %}
             {% if constant('EPUB') == 1 %}<a title="{% trans "Download the articles from this tag in an epub file" %}" href="./?epub&amp;method=tag&amp;value={{ tag.value }}">{% trans "Download as ePub3" %}</a>{% endif %}
             {% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this tag in a mobi file" %}" href="./?mobi&amp;method=tag&amp;value={{ tag.value }}">{% trans "Download as Mobi" %}</a>{% endif %}
index c5db58024096465276674a2edce4f017da74c442..b90005598cbbb5ffa3e924fce530427720c09230 100755 (executable)
             {{ block('pager') }}
             {% if view == 'home' %}{% if nb_results > 1 %}<p><a title="{% trans "Mark all the entries as read" %}"  href="./?action=archive_all">{% trans "Mark all the entries as read" %}</a></p>{% endif %}{% endif %}
             {% if searchterm is defined %}<a title="{% trans "Tag these results as" %} {{ searchterm }}" href="./?action=add_tag&search={{ searchterm }}">{% trans "Tag these results as" %} {{ searchterm }}</a>{% endif %}<br />
-            
+
+            {% if searchterm is defined %}<a title="{% trans "Delete results matching" %} {{ searchterm }}" href="./?action=delete&search={{ searchterm }}">{% trans "Delete results matching" %} {{ searchterm }}</a>{% endif %}<br />
+
+            {% if tag %}<a title="{% trans "Mark all articles from this tag as read" %}" href="./?action=toggle_archive&amp;tag_id={{ tag.id }}">{% trans "Mark all articles from this tag as read" %}</a><br />{% endif %}
+
             {% if tag %}
             {% if constant('EPUB') == 1 %}<a title="{% trans "Download the articles from this tag in an epub file" %}" href="./?epub&amp;method=tag&amp;value={{ tag.value }}">{% trans "Download as ePub3" %}</a>{% endif %}
             {% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this tag in a mobi file" %}" href="./?mobi&amp;method=tag&amp;value={{ tag.value }}">{% trans "Download as Mobi" %}</a>{% endif %}
@@ -73,6 +77,6 @@
             {% if constant('MOBI') == 1 %}<a title="{% trans "Download the articles from this category in a mobi file" %}" href="./?mobi&amp;method=category&amp;value={{ view }}">{% trans "Download as Mobi" %}</a>{% endif %}
             {% if constant('PDF') == 1 %}<a title="{% trans "Download the articles from this category in a pdf file" %}" href="./?pdf&amp;method=category&amp;value={{ view }}">{% trans "Download as PDF" %}</a>{% endif %}
             {% endif %}
-            
+
             {% endif %}
 {% endblock %}