Reverted changes of date() to gdate(), added tests to confirm existence of private RSS feed, and finalized changes to the user session usage with rss.php
This commit is contained in:
parent
342d1c3205
commit
84e603aa91
10 changed files with 68 additions and 45 deletions
|
@ -486,7 +486,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
|
||||||
} else {
|
} else {
|
||||||
$time = strtotime($date);
|
$time = strtotime($date);
|
||||||
}
|
}
|
||||||
$datetime = date('Y-m-d H:i:s', $time);
|
$datetime = gmdate('Y-m-d H:i:s', $time);
|
||||||
|
|
||||||
if ($short === '') {
|
if ($short === '') {
|
||||||
$short = null;
|
$short = null;
|
||||||
|
|
|
@ -584,7 +584,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
|
||||||
|
|
||||||
if (is_int($days)) {
|
if (is_int($days)) {
|
||||||
$query .= ' AND B.bDatetime > "'
|
$query .= ' AND B.bDatetime > "'
|
||||||
. date('Y-m-d H:i:s', time() - (86400 * $days))
|
. gmdate('Y-m-d H:i:s', time() - (86400 * $days))
|
||||||
. '"';
|
. '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -571,8 +571,6 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||||
$this->db->sql_freeresult($dbresult);
|
$this->db->sql_freeresult($dbresult);
|
||||||
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
$id = $_SESSION[$this->getSessionKey()]
|
|
||||||
= $row[$this->getFieldName('primary')];
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -111,7 +111,7 @@ TXT;
|
||||||
$this->assertEquals($bmDescription, stripslashes($bm['bDescription']));
|
$this->assertEquals($bmDescription, stripslashes($bm['bDescription']));
|
||||||
$this->assertEquals($bmTags, $bm['tags']);
|
$this->assertEquals($bmTags, $bm['tags']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
date('Y-m-d H:i:s', strtotime($bmDatetime)),
|
gmdate('Y-m-d H:i:s', strtotime($bmDatetime)),
|
||||||
$bm['bDatetime']
|
$bm['bDatetime']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ TXT;
|
||||||
$this->assertEquals($bmDescription, stripslashes($bm['bDescription']));
|
$this->assertEquals($bmDescription, stripslashes($bm['bDescription']));
|
||||||
$this->assertEquals($bmTags, $bm['tags']);
|
$this->assertEquals($bmTags, $bm['tags']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
date('Y-m-d H:i:s', strtotime($bmDatetime)),
|
gmdate('Y-m-d H:i:s', strtotime($bmDatetime)),
|
||||||
$bm['bDatetime']
|
$bm['bDatetime']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,15 +164,16 @@ class TestBaseApi extends TestBase
|
||||||
*
|
*
|
||||||
* Useful for testing HTML pages or ajax URLs.
|
* Useful for testing HTML pages or ajax URLs.
|
||||||
*
|
*
|
||||||
* @param string $urlSuffix Suffix for the URL
|
* @param string $urlSuffix Suffix for the URL
|
||||||
* @param mixed $auth If user authentication is needed (true/false)
|
* @param mixed $auth If user authentication is needed (true/false)
|
||||||
* or array with username and password
|
* 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
|
* @return array(HTTP_Request2, integer) HTTP request object and user id
|
||||||
*
|
*
|
||||||
* @uses getRequest()
|
* @uses getRequest()
|
||||||
*/
|
*/
|
||||||
protected function getLoggedInRequest($urlSuffix = null, $auth = true)
|
protected function getLoggedInRequest($urlSuffix = null, $auth = true, $privateKey = false)
|
||||||
{
|
{
|
||||||
if (is_array($auth)) {
|
if (is_array($auth)) {
|
||||||
list($username, $password) = $auth;
|
list($username, $password) = $auth;
|
||||||
|
@ -180,7 +181,13 @@ class TestBaseApi extends TestBase
|
||||||
$username = 'testuser';
|
$username = 'testuser';
|
||||||
$password = 'testpassword';
|
$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(
|
$req = new HTTP_Request2(
|
||||||
$GLOBALS['unittestUrl'] . '/login.php?unittestMode=1',
|
$GLOBALS['unittestUrl'] . '/login.php?unittestMode=1',
|
||||||
|
@ -234,7 +241,7 @@ class TestBaseApi extends TestBase
|
||||||
*/
|
*/
|
||||||
protected function setUnittestConfig($arConfig)
|
protected function setUnittestConfig($arConfig)
|
||||||
{
|
{
|
||||||
$str = '<' . "?php\r\n";
|
$str = '<' . "?php\n";
|
||||||
foreach ($arConfig as $name => $value) {
|
foreach ($arConfig as $name => $value) {
|
||||||
$str .= '$' . $name . ' = '
|
$str .= '$' . $name . ' = '
|
||||||
. var_export($value, true) . ";\n";
|
. var_export($value, true) . ";\n";
|
||||||
|
@ -253,4 +260,4 @@ class TestBaseApi extends TestBase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -76,5 +76,32 @@ class www_bookmarksTest extends TestBaseApi
|
||||||
$this->assertEquals(1, (string)$elements[0]['value']);
|
$this->assertEquals(1, (string)$elements[0]['value']);
|
||||||
}//end testDefaultPrivacyBookmarksAdd
|
}//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
|
}//end class www_bookmarksTest
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,23 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
/***************************************************************************
|
/**
|
||||||
Copyright (C) 2005 - 2006 Scuttle project
|
* Ajax script to retrieve new Private Key
|
||||||
http://sourceforge.net/projects/scuttle/
|
*
|
||||||
http://scuttle.org/
|
* PHP version 5.
|
||||||
|
*
|
||||||
This program is free software; you can redistribute it and/or modify
|
* @category Bookmarking
|
||||||
it under the terms of the GNU General Public License as published by
|
* @package SemanticScuttle
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
* @author Christian Weiske <cweiske@cweiske.de>
|
||||||
(at your option) any later version.
|
* @author Mark Pemberton <mpemberton5@gmail.com>
|
||||||
|
* @license AGPL http://www.gnu.org/licenses/agpl.html
|
||||||
This program is distributed in the hope that it will be useful,
|
* @link http://sourceforge.net/projects/semanticscuttle
|
||||||
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
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
|
header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
|
||||||
header("Cache-Control: no-cache, must-revalidate");
|
header("Cache-Control: no-cache, must-revalidate");
|
||||||
|
|
|
@ -51,7 +51,7 @@ if ($userservice->isLoggedOn()) {
|
||||||
array_push(
|
array_push(
|
||||||
$tplVars['rsschannels'],
|
$tplVars['rsschannels'],
|
||||||
array(
|
array(
|
||||||
filter($sitename . sprintf(T_(': (private) ')) . $currentUsername),
|
filter($sitename . sprintf(T_(': Recent bookmarks (private)')) . $currentUsername),
|
||||||
createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey())
|
createURL('rss', filter($currentUsername, 'url') . '?sort='.getSortOrder().'&privatekey='.$currentUser->getPrivateKey())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -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){
|
function getNewPrivateKey(input, response){
|
||||||
var pk = document.getElementById('pPrivateKey');
|
var pk = document.getElementById('pPrivateKey');
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
|
|
14
www/rss.php
14
www/rss.php
|
@ -71,7 +71,6 @@ if (isset($_GET['privatekey'])) {
|
||||||
|
|
||||||
$watchlist = null;
|
$watchlist = null;
|
||||||
$pagetitle = '';
|
$pagetitle = '';
|
||||||
$isTempLogin = false;
|
|
||||||
if ($user && $user != 'all') {
|
if ($user && $user != 'all') {
|
||||||
if ($user == 'watchlist') {
|
if ($user == 'watchlist') {
|
||||||
$user = $cat;
|
$user = $cat;
|
||||||
|
@ -86,9 +85,7 @@ if ($user && $user != 'all') {
|
||||||
/* if user is not logged in and has valid privatekey */
|
/* if user is not logged in and has valid privatekey */
|
||||||
if (!$userservice->isLoggedOn()) {
|
if (!$userservice->isLoggedOn()) {
|
||||||
if ($privatekey != null) {
|
if ($privatekey != null) {
|
||||||
if ($userservice->loginPrivateKey($privatekey)) {
|
if (!$userservice->loginPrivateKey($privatekey)) {
|
||||||
$isTempLogin = true;
|
|
||||||
} else {
|
|
||||||
$tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
|
$tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
|
||||||
header('Content-type: text/html; charset=utf-8');
|
header('Content-type: text/html; charset=utf-8');
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
|
@ -109,9 +106,7 @@ if ($user && $user != 'all') {
|
||||||
$pagetitle .= ": ". $user;
|
$pagetitle .= ": ". $user;
|
||||||
} else {
|
} else {
|
||||||
if ($privatekey != null) {
|
if ($privatekey != null) {
|
||||||
if ($userservice->loginPrivateKey($privatekey)) {
|
if (!$userservice->loginPrivateKey($privatekey)) {
|
||||||
$isTempLogin = true;
|
|
||||||
} else {
|
|
||||||
$tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
|
$tplVars['error'] = sprintf(T_('Failed to Autenticate User with username %s using private key'), $user);
|
||||||
header('Content-type: text/html; charset=utf-8');
|
header('Content-type: text/html; charset=utf-8');
|
||||||
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
$templateservice->loadTemplate('error.404.tpl', $tplVars);
|
||||||
|
@ -168,11 +163,6 @@ $tplVars['feedlastupdate'] = date('r', strtotime($latestdate));
|
||||||
|
|
||||||
$templateservice->loadTemplate('rss.tpl', $tplVars);
|
$templateservice->loadTemplate('rss.tpl', $tplVars);
|
||||||
|
|
||||||
/* If temporary login, please log out */
|
|
||||||
if ($isTempLogin) {
|
|
||||||
$userservice->logout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($usecache) {
|
if ($usecache) {
|
||||||
// Cache output if existing copy has expired
|
// Cache output if existing copy has expired
|
||||||
$cacheservice->End($hash);
|
$cacheservice->End($hash);
|
||||||
|
|
Loading…
Reference in a new issue