]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Reverted changes of date() to gdate(), added tests to confirm existence of private...
authorMark Pemberton <mpemberton5@gmail.com>
Sat, 4 Jun 2011 04:29:04 +0000 (00:29 -0400)
committerMark Pemberton <mpemberton5@gmail.com>
Sat, 4 Jun 2011 04:29:04 +0000 (00:29 -0400)
src/SemanticScuttle/Service/Bookmark.php
src/SemanticScuttle/Service/Bookmark2Tag.php
src/SemanticScuttle/Service/User.php
tests/Api/PostsAddTest.php
tests/TestBaseApi.php
tests/www/bookmarksTest.php
www/ajaxGetNewPrivateKey.php
www/index.php
www/jsScuttle.php
www/rss.php

index f69b4d12bedde0c556821dd9ec2a9cd3b3f7a855..17ab7badcbd1df8dc56d9c9e6274a1f64006c00d 100644 (file)
@@ -486,7 +486,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
         } else {
             $time = strtotime($date);
         }
-        $datetime = date('Y-m-d H:i:s', $time);
+        $datetime = gmdate('Y-m-d H:i:s', $time);
 
         if ($short === '') {
             $short = null;
index fc59a1c2297cf07d59a93010bdcc364d4b7f4274..04ee43ded7630f6b670137f36e18d4bb77ec5026 100644 (file)
@@ -584,7 +584,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
 
         if (is_int($days)) {
             $query .= ' AND B.bDatetime > "'
-                . date('Y-m-d H:i:s', time() - (86400 * $days))
+                . gmdate('Y-m-d H:i:s', time() - (86400 * $days))
                 . '"';
         }
 
index 18d5a290a1e8ce00c1d9f19dd2d7dcab83f1240d..a4870b7f7104121b89ce1cdb889116227f2b50f5 100644 (file)
@@ -571,8 +571,6 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
         $this->db->sql_freeresult($dbresult);
 
         if ($row) {
-            $id = $_SESSION[$this->getSessionKey()]
-                = $row[$this->getFieldName('primary')];
             return true;
         } else {
             return false;
index 2613a8725198083d55ca9d9d98913fc5e07cfca0..e6d053112d9293a3a80fc9c983e61f898bdb0e17 100644 (file)
@@ -111,7 +111,7 @@ TXT;
         $this->assertEquals($bmDescription, stripslashes($bm['bDescription']));
         $this->assertEquals($bmTags, $bm['tags']);
         $this->assertEquals(
-            date('Y-m-d H:i:s', strtotime($bmDatetime)),
+            gmdate('Y-m-d H:i:s', strtotime($bmDatetime)),
             $bm['bDatetime']
         );
     }
@@ -173,7 +173,7 @@ TXT;
         $this->assertEquals($bmDescription, stripslashes($bm['bDescription']));
         $this->assertEquals($bmTags, $bm['tags']);
         $this->assertEquals(
-            date('Y-m-d H:i:s', strtotime($bmDatetime)),
+            gmdate('Y-m-d H:i:s', strtotime($bmDatetime)),
             $bm['bDatetime']
         );
     }
index 20574f33b6fa38fa647958ad89b5f8ea35844eff..d8917aa4849fff8c18cd03ecf71bda6af5c66ecb 100644 (file)
@@ -164,15 +164,16 @@ class TestBaseApi extends TestBase
      *
      * Useful for testing HTML pages or ajax URLs.
      *
-     * @param string $urlSuffix Suffix for the URL
-     * @param mixed  $auth      If user authentication is needed (true/false)
-     *                          or array with username and password
+     * @param string  $urlSuffix Suffix for the URL
+     * @param mixed   $auth      If user authentication is needed (true/false)
+     *                           or array with username and password
+     * @param boolean $privateKey True if to add user with private key
      *
      * @return array(HTTP_Request2, integer) HTTP request object and user id
      *
      * @uses getRequest()
      */
-    protected function getLoggedInRequest($urlSuffix = null, $auth = true)
+    protected function getLoggedInRequest($urlSuffix = null, $auth = true, $privateKey = false)
     {
         if (is_array($auth)) {
             list($username, $password) = $auth;
@@ -180,7 +181,13 @@ class TestBaseApi extends TestBase
             $username = 'testuser';
             $password = 'testpassword';
         }
-        $uid = $this->addUser($username, $password);
+        //include privatekey if requested
+        if ($privateKey) {
+            $pKey = $this->us->getNewPrivateKey();
+        } else {
+            $pKey = null;
+        }
+        $uid = $this->addUser($username, $password, $pKey);
 
         $req = new HTTP_Request2(
             $GLOBALS['unittestUrl'] . '/login.php?unittestMode=1',
@@ -234,7 +241,7 @@ class TestBaseApi extends TestBase
      */
     protected function setUnittestConfig($arConfig)
     {
-        $str = '<' . "?php\r\n";
+        $str = '<' . "?php\n";
         foreach ($arConfig as $name => $value) {
             $str .= '$' . $name . ' = '
                 . var_export($value, true) . ";\n";
@@ -253,4 +260,4 @@ class TestBaseApi extends TestBase
         );
     }
 }
-?>
\ No newline at end of file
+?>
index df360ccd58bd91449acb5a86fd9ff9f9fb6bd11c..eaf78bf849f6d24d5107048270f287113650d13c 100755 (executable)
@@ -76,5 +76,32 @@ class www_bookmarksTest extends TestBaseApi
         $this->assertEquals(1, (string)$elements[0]['value']);
     }//end testDefaultPrivacyBookmarksAdd
 
+
+    /**
+     * Test that the private RSS link exists when a user
+     * has a private key and is enabled
+     */
+    public function testVerifyPrivateRSSLinkExists()
+    {
+        list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true, true);
+
+        $user = $this->us->getUser($uId);
+        $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/'
+            . $user['username'];
+        $req->setUrl($reqUrl);
+        $req->setMethod(HTTP_Request2::METHOD_GET);
+        $response = $req->send();
+        $response_body = $response->getBody();
+        $this->assertNotEquals('', $response_body, 'Response is empty');
+
+        $x = simplexml_load_string($response_body);
+        $ns = $x->getDocNamespaces();
+        $x->registerXPathNamespace('ns', reset($ns));
+
+        $elements = $x->xpath('//ns:link');
+        $this->assertEquals(5, count($elements), 'Number of Links in Head not correct');
+        $this->assertContains('privatekey=', (string)$elements[4]['href']);
+    }//end testVerifyPrivateRSSLinkExists
+
 }//end class www_bookmarksTest
 ?>
index 59545a2366309c67694373c8ad040ac48288236e..eacebd867ce31fbd654883cfb8ad2a19c9e527a6 100644 (file)
@@ -1,23 +1,16 @@
 <?php
-/***************************************************************************
- Copyright (C) 2005 - 2006 Scuttle project
- http://sourceforge.net/projects/scuttle/
- http://scuttle.org/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- ***************************************************************************/
+/**
+ * Ajax script to retrieve new Private Key
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package  SemanticScuttle
+ * @author   Christian Weiske <cweiske@cweiske.de>
+ * @author   Mark Pemberton <mpemberton5@gmail.com>
+ * @license  AGPL http://www.gnu.org/licenses/agpl.html
+ * @link     http://sourceforge.net/projects/semanticscuttle
+ */
 
 header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
 header("Cache-Control: no-cache, must-revalidate");
index 931d64d45ac98814f10719a40e9aed2d668e6ca3..fab235fc8404bf9004c425b82622b8b3c8675729 100644 (file)
@@ -51,7 +51,7 @@ if ($userservice->isLoggedOn()) {
         array_push(
             $tplVars['rsschannels'],
             array(
-                filter($sitename . sprintf(T_(': (private) ')) . $currentUsername),
+                filter($sitename . sprintf(T_(': Recent bookmarks (private)')) . $currentUsername),
                 createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&amp;privatekey='.$currentUser->getPrivateKey())
             )
         );
index 76b49dc084e8312135d11e63423c76ccb0b24cab..3ca41ec8ed942e6fa9cf8f2c05a14835bd2ef144 100644 (file)
@@ -89,6 +89,14 @@ function useAddress(ele) {
     }
 }
 
+/**
+ * Makes an ajax call to PHP script to generate an new Private Key
+ *
+ * @param input    Calling object
+ * @param response Response object that returned value is placed
+ *
+ * @return boolean Returns false to halt execution after call
+ */
 function getNewPrivateKey(input, response){
     var pk = document.getElementById('pPrivateKey');
     if (response != null) {
index 8c81e0eb81ab8b075083fdaed5a7a8163d43a95a..29275341debae57ee5c2f40aa831dac40d2e8135 100644 (file)
@@ -71,7 +71,6 @@ if (isset($_GET['privatekey'])) {
 
 $watchlist = null;
 $pagetitle = '';
-$isTempLogin = false;
 if ($user && $user != 'all') {
     if ($user == 'watchlist') {
         $user = $cat;
@@ -86,9 +85,7 @@ if ($user && $user != 'all') {
             /* if user is not logged in and has valid privatekey */
             if (!$userservice->isLoggedOn()) {
                 if ($privatekey != null) {
-                    if ($userservice->loginPrivateKey($privatekey)) {
-                        $isTempLogin = true;
-                    } else {
+                    if (!$userservice->loginPrivateKey($privatekey)) {
                         $tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
                         header('Content-type: text/html; charset=utf-8');
                         $templateservice->loadTemplate('error.404.tpl', $tplVars);
@@ -109,9 +106,7 @@ if ($user && $user != 'all') {
     $pagetitle .= ": ". $user;
 } else {
     if ($privatekey != null) {
-        if ($userservice->loginPrivateKey($privatekey)) {
-            $isTempLogin = true;
-        } else {
+        if (!$userservice->loginPrivateKey($privatekey)) {
             $tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
             header('Content-type: text/html; charset=utf-8');
             $templateservice->loadTemplate('error.404.tpl', $tplVars);
@@ -168,11 +163,6 @@ $tplVars['feedlastupdate'] = date('r', strtotime($latestdate));
 
 $templateservice->loadTemplate('rss.tpl', $tplVars);
 
-/* If temporary login, please log out */
-if ($isTempLogin) {
-    $userservice->logout();
-}
-
 if ($usecache) {
     // Cache output if existing copy has expired
     $cacheservice->End($hash);