Merge branch 'master' into jquery

Conflicts:
	doc/ChangeLog
This commit is contained in:
Christian Weiske 2011-03-20 22:15:34 +01:00
commit bc178983b3
22 changed files with 180 additions and 64 deletions

View file

@ -208,7 +208,7 @@
<target name="release" depends="check,zip,package,deploy-sf,svntag"
<target name="release" depends="check,zip,package,deploy-sf"
description="Release the version on sourceforge"
>
<!-- meta-target -->
@ -307,17 +307,6 @@
</target>
<target name="svntag"
description="create the svn tag for the current version"
>
<exec
command="svn cp ${svnpath}trunk ${svnpath}/tags/${version} -m 'tag version ${version}'"
escape="false" checkreturn="true"
/>
</target>
<target name="check"
description="Check variables"
>
@ -327,4 +316,4 @@
<fail unless="sffilepath" message="Sourceforge project file path not defined!" />
</target>
</project>
</project>

View file

@ -30,7 +30,8 @@ window.onload = function() {
if(strlen($description['cdDatetime'])>0) {
echo T_('Last modification:').' '.$description['cdDatetime'].', ';
$lastUser = $userservice->getUser($description['uId']);
echo '<a href="'.createURL('profile', $lastUser['username']).'">'.$lastUser['username'].'</a>';
echo '<a href="'.createURL('profile', $lastUser['username']).'">'
. SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>';
}
?>
</td>

View file

@ -312,7 +312,8 @@ if ($currenttag!= '') {
$copy .= T_('you');
} else {
$copy .= '<a href="' . createURL('bookmarks', $row['username']) . '">'
. $row['username'] . '</a>';
. SemanticScuttle_Model_UserArray::getName($row)
. '</a>';
}
// others

View file

@ -56,7 +56,7 @@ $this->includeTemplate($GLOBALS['top_include']);
<th align="left"><?php echo T_('Export bookmarks'); ?></th>
<td>
<a href="../api/export_html.php"><?php echo T_('HTML file (for browsers)')?></a> /
<a href="../api/posts/all"><?php echo T_('XML file (like del.icio.us)')?></a> /
<a href="../api/posts_all.php"><?php echo T_('XML file (like del.icio.us)')?></a> /
<a href="../api/export_csv.php"><?php echo T_('CSV file (for spreadsheet tools)')?></a>
</td>
</tr>

View file

@ -18,7 +18,7 @@ if ($lastUsers && count($lastUsers) > 0) {
foreach ($lastUsers as $row) {
echo '<tr><td>';
echo '<a href="'.createURL('profile', $row['username']).'">';
echo $row['username'];
echo SemanticScuttle_Model_UserArray::getName($row);
echo '</a>';
echo ' (<a href="'.createURL('bookmarks', $row['username']).'">'.T_('bookmarks').'</a>)';
echo '</td></tr>';

View file

@ -20,7 +20,8 @@ window.onload = function() {
if(strlen($description['cdDatetime'])>0) {
echo T_('Last modification:').' '.$description['cdDatetime'].', ';
$lastUser = $userservice->getUser($description['uId']);
echo '<a href="'.createURL('profile', $lastUser['username']).'">'.$lastUser['username'].'</a>';
echo '<a href="' . createURL('profile', $lastUser['username']) . '">'
. SemanticScuttle_Model_UserArray::getName($lastUser) . '</a>';
}
?>
</td>

View file

@ -14,7 +14,14 @@ if ($users && count($users) > 0) {
<?php
$contents = '<';
foreach ($users as $row) {
echo '<li><strong>'.$row['username'].'</strong> (<a href="'.createURL('profile', $row['username']).'">'.T_('profile').'</a> '.T_('created in').' '.date('M Y',strtotime($row['uDatetime'])).') : <a href="'.createURL('bookmarks', $row['username']).'">'.T_('bookmarks').'</a></li>';
echo '<li><strong>'
. SemanticScuttle_Model_UserArray::getName($row) . '</strong>'
. ' (<a href="' . createURL('profile', $row['username']) . '">'
. T_('profile') . '</a> '
. T_('created in') . ' '
. date('M Y', strtotime($row['uDatetime'])) . ')'
. ' : <a href="' . createURL('bookmarks', $row['username']).'">'
. T_('bookmarks') . '</a></li>';
}
?>
</ul>

View file

@ -3,16 +3,24 @@ ChangeLog for SemantiScuttle
0.9X.X - 2010-XX-XX
-------------------
- Fix bug #3187177: Wrong URL / Export XML Bookmarks
- Fix bug in getTagsForBookmarks() that fetched all tags
- Fix bug #3073215: Updating bookmark time does not work
- Fix bug #3074816: French translation breaks edit javascript
- Fix bug #3111254: Search in my_watchlist results in error
- Show error message on mysqli connection errors
- Implement request #3054906: Show user's full name instead of nickname
- Implement patch #3059829: update FR_CA translation
- Show error message on mysqli connection errors
- Update php-gettext library to 1.0.10
- api/posts/add respects the "replace" parameter now
0.97.2 - 2011-02-17
-------------------
- Fix bug #3178597: Broken link to context in gsearch admin index page
- Fix bug #3074816: French translation breaks edit javascript
- Fix bug #3111254: Search in my_watchlist results in error
- Fix bug #3073215: Updating bookmark time does not work
- Fix bug #3065284: AjaxVote problem with Webkit browsers
0.97.1 - 2010-09-30
-------------------
This is a security release! We do highly recommend to update

4
doc/developers/doc-TODO Normal file
View file

@ -0,0 +1,4 @@
- Which fields are searched?
title, description, private note, username, tags
- What are [isbn] and so for?

View file

@ -0,0 +1,41 @@
<?php
/**
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
/**
* Mostly static methods that help working with a user row array from database.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
class SemanticScuttle_Model_UserArray
{
/**
* Returns full user name as specified in the profile if it is set,
* otherwise the nickname/loginname is returned.
*
* @param array $row User row array from database
*
* @return string Full name or username
*/
public static function getName($row)
{
if (isset($row['name']) && $row['name']) {
return $row['name'];
}
return $row['username'];
}
}
?>

View file

@ -253,18 +253,18 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
/**
* Counts bookmarks for a user.
*
* @param integer $uId User ID
* @param string $range Range of bookmarks:
* 'public', 'shared', 'private'
* or 'all'
* @param integer $uId User ID
* @param string $status Bookmark visibility/privacy settings:
* 'public', 'shared', 'private'
* or 'all'
*
* @return integer Number of bookmarks
*/
public function countBookmarks($uId, $range = 'public')
public function countBookmarks($uId, $status = 'public')
{
$sql = 'SELECT COUNT(*) as "0" FROM '. $this->getTableName();
$sql.= ' WHERE uId = ' . intval($uId);
switch ($range) {
switch ($status) {
case 'all':
//no constraints
break;
@ -439,7 +439,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
* @param string $title Bookmark title
* @param string $description Long bookmark description
* @param string $privateNote Private note for the user.
* @param string $status Bookmark visibility:
* @param string $status Bookmark visibility / privacy settings:
* 0 - public
* 1 - shared
* 2 - private
@ -554,7 +554,7 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
* @param string $title Bookmark title
* @param string $description Long bookmark description
* @param string $privateNote Private note for the user.
* @param string $status Bookmark visibility:
* @param string $status Bookmark visibility / privacy setting:
* 0 - public
* 1 - shared
* 2 - private
@ -734,7 +734,8 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
if (SQL_LAYER == 'mysql4') {
$query_1 .= 'SQL_CALC_FOUND_ROWS ';
}
$query_1 .= 'B.*, U.'. $userservice->getFieldName('username');
$query_1 .= 'B.*, U.'. $userservice->getFieldName('username')
. ', U.name';
$query_2 = ' FROM '. $userservice->getTableName() .' AS U'
. ', '. $this->getTableName() .' AS B';

View file

@ -68,6 +68,7 @@ require_once 'SemanticScuttle/Service.php';
require_once 'SemanticScuttle/DbService.php';
require_once 'SemanticScuttle/Service/Factory.php';
require_once 'SemanticScuttle/functions.php';
require_once 'SemanticScuttle/Model/UserArray.php';
if (count($GLOBALS['serviceoverrides']) > 0
&& !defined('UNIT_TEST_MODE')

View file

@ -17,9 +17,6 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
}
require_once 'prepare.php';
require_once 'PHPUnit/Framework/TestSuite.php';
PHPUnit_Util_Filter::addFileToFilter(__FILE__);
/**
* SemanticScuttle unit tests.

View file

@ -120,7 +120,7 @@ class Bookmark2TagTest extends TestBase
$this->b2ts->attachTags($bid, array('foo', 'bar', 'fuu'));
$tags = $this->b2ts->getTagsForBookmark($bid);
$this->assertType('array', $tags);
$this->assertInternalType('array', $tags);
$this->assertContains('foo', $tags);
$this->assertContains('bar', $tags);
$this->assertContains('fuu', $tags);
@ -141,10 +141,10 @@ class Bookmark2TagTest extends TestBase
$alltags = $this->b2ts->getTagsForBookmarks(
array($bid1, $bid2)
);
$this->assertType('array', $alltags);
$this->assertInternalType('array', $alltags);
$this->assertEquals(2, count($alltags));
$this->assertType('array', $alltags[$bid1]);
$this->assertType('array', $alltags[$bid2]);
$this->assertInternalType('array', $alltags[$bid1]);
$this->assertInternalType('array', $alltags[$bid2]);
$this->assertEquals(0, count($alltags[$bid1]));
$this->assertEquals(0, count($alltags[$bid2]));
}
@ -179,9 +179,9 @@ class Bookmark2TagTest extends TestBase
$alltags = $this->b2ts->getTagsForBookmarks(
array($bid1, $bid2, $bid3, $bid4)
);
$this->assertType('array', $alltags);
$this->assertInternalType('array', $alltags);
foreach ($alltags as $bid => $btags) {
$this->assertType('array', $btags);
$this->assertInternalType('array', $btags);
if ($bid == $bid1) {
$this->assertEquals(3, count($btags));
$this->assertContains('foo', $btags);

View file

@ -263,7 +263,7 @@ class BookmarkTest extends TestBase
$bookmark = $this->bs->getBookmark($bid);
$ret = $this->bs->bookmarksExist(array($bookmark['bAddress']));
$this->assertType('array', $ret);
$this->assertInternalType('array', $ret);
$this->assertEquals(1, count($ret));
$this->assertTrue($ret[$bookmark['bAddress']]);
}
@ -291,7 +291,7 @@ class BookmarkTest extends TestBase
$bookmark2['bAddress']
)
);
$this->assertType('array', $ret);
$this->assertInternalType('array', $ret);
$this->assertEquals(2, count($ret));
$this->assertTrue($ret[$bookmark['bAddress']]);
$this->assertTrue($ret[$bookmark2['bAddress']]);
@ -308,7 +308,7 @@ class BookmarkTest extends TestBase
public function testBookmarksExistFalseSingle()
{
$ret = $this->bs->bookmarksExist(array('does-not-exist'));
$this->assertType('array', $ret);
$this->assertInternalType('array', $ret);
$this->assertEquals(1, count($ret));
$this->assertFalse($ret['does-not-exist']);
}
@ -329,7 +329,7 @@ class BookmarkTest extends TestBase
'does-not-exist-3',
);
$ret = $this->bs->bookmarksExist($bms);
$this->assertType('array', $ret);
$this->assertInternalType('array', $ret);
$this->assertEquals(3, count($ret));
$this->assertFalse($ret['does-not-exist']);
$this->assertFalse($ret['does-not-exist-2']);
@ -366,7 +366,7 @@ class BookmarkTest extends TestBase
'does-not-exist-3'
)
);
$this->assertType('array', $ret);
$this->assertInternalType('array', $ret);
$this->assertEquals(5, count($ret));
$this->assertTrue($ret[$bookmark['bAddress']]);
$this->assertTrue($ret[$bookmark2['bAddress']]);
@ -475,7 +475,7 @@ class BookmarkTest extends TestBase
foreach ($bms['bookmarks'] as $bm) {
$this->assertArrayHasKey('tags', $bm);
$this->assertType('array', $bm['tags']);
$this->assertInternalType('array', $bm['tags']);
if ($bm['bId'] == $bid) {
$this->assertContains('foo', $bm['tags']);
$this->assertContains('bar', $bm['tags']);
@ -756,7 +756,7 @@ class BookmarkTest extends TestBase
$bm = $this->bs->getBookmark($bid, true);
$this->assertArrayHasKey('tags', $bm);
$this->assertType('array', $bm['tags']);
$this->assertInternalType('array', $bm['tags']);
$this->assertContains('foo', $bm['tags']);
$this->assertContains('bar', $bm['tags']);
}
@ -874,7 +874,7 @@ class BookmarkTest extends TestBase
$bid = $this->addBookmark($uid, $url);
$bm = $this->bs->getBookmarkByAddress($url);
$this->assertType('array', $bm);
$this->assertInternalType('array', $bm);
$this->assertEquals($url, $bm['bAddress']);
}
@ -900,7 +900,7 @@ class BookmarkTest extends TestBase
$bid = $this->addBookmark($uid, $url);
$bm = $this->bs->getBookmarkByAddress($incomplete);
$this->assertType('array', $bm);
$this->assertInternalType('array', $bm);
$this->assertEquals($url, $bm['bAddress']);
}
@ -951,7 +951,7 @@ class BookmarkTest extends TestBase
$this->assertEquals('new description', $bm['bDescription']);
$this->assertEquals('new private note', $bm['bPrivateNote']);
$this->assertEquals(1, $bm['bStatus']);
$this->assertType('array', $bm['tags']);
$this->assertInternalType('array', $bm['tags']);
$this->assertEquals(1, count($bm['tags']));
$this->assertContains('new', $bm['tags']);
}

View file

@ -11,10 +11,6 @@
* @link http://sourceforge.net/projects/semanticscuttle
*/
require_once 'PHPUnit/Framework.php';
PHPUnit_Util_Filter::addFileToFilter(__FILE__);
/**
* Base unittest class that provides several helper methods.
*

View file

@ -11,10 +11,6 @@
* @link http://sourceforge.net/projects/semanticscuttle
*/
require_once 'PHPUnit/Framework.php';
PHPUnit_Util_Filter::addFileToFilter(__FILE__);
/**
* Base unittest class for web API tests.
*

68
tests/UserArrayTest.php Normal file
View file

@ -0,0 +1,68 @@
<?php
/**
* SemanticScuttle - your social bookmark manager.
*
* PHP version 5.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
require_once 'prepare.php';
/**
* Unit tests for the SemanticScuttle user array model.
*
* @category Bookmarking
* @package SemanticScuttle
* @author Christian Weiske <cweiske@cweiske.de>
* @license GPL http://www.gnu.org/licenses/gpl.html
* @link http://sourceforge.net/projects/semanticscuttle
*/
class UserArrayTest extends PHPUnit_Framework_TestCase
{
public function testGetNameLongName()
{
$this->assertEquals(
'John Doe',
SemanticScuttle_Model_UserArray::getName(
array(
'name' => 'John Doe',
'username' => 'jdoe'
)
)
);
}
public function testGetNameUsernameIfNameIsEmpty()
{
$this->assertEquals(
'jdoe',
SemanticScuttle_Model_UserArray::getName(
array(
'name' => '',
'username' => 'jdoe'
)
)
);
}
public function testGetNameUsernameIfNameIsNotSet()
{
$this->assertEquals(
'jdoe',
SemanticScuttle_Model_UserArray::getName(
array(
'username' => 'jdoe'
)
)
);
}
}
?>

View file

@ -143,7 +143,7 @@ class UserTest extends TestBase
$uid = $this->addUser();
$users = $this->us->getObjectUsers();
$this->assertEquals(1, count($users));
$this->assertType('SemanticScuttle_Model_User', reset($users));
$this->assertInstanceOf('SemanticScuttle_Model_User', reset($users));
}
@ -160,7 +160,7 @@ class UserTest extends TestBase
$uid3 = $this->addUser();
$users = $this->us->getObjectUsers();
$this->assertEquals(3, count($users));
$this->assertType('SemanticScuttle_Model_User', reset($users));
$this->assertInstanceOf('SemanticScuttle_Model_User', reset($users));
}

View file

@ -31,7 +31,9 @@ if($GLOBALS['enableGoogleCustomSearch']==false) {
echo '<p><small>';
echo T_('Admin tips: ');
echo T_('To refresh manually Google Custom Search Engine, goes to: ');
echo '<a href="http://www.google.com/coop/cse/cref?cref='.ROOT.'search/context.php">http://www.google.com/coop/cse/cref</a><br/>';
echo '<a href="http://www.google.com/coop/cse/cref?cref='
. ROOT . 'gsearch/context.php">http://www.google.com/coop/cse/cref</a>'
. '<br/>';
echo T_('If no result appears, check that all the urls are valid in the admin section.');
echo '</small></p>';

View file

@ -155,7 +155,10 @@ function processVotingResult() {
var bmnode = document.getElementById('bmv-'+bookmark);
bmnode.parentNode.replaceChild(
response.getElementsByTagName('html')[0].firstChild,
xmlhttp.responseXML.importNode(
response.getElementsByTagName('html')[0].firstChild,
true
),
bmnode
);
}

View file

@ -116,7 +116,7 @@ foreach ($bookmarks_tmp as $key => $row) {
'title' => $row['bTitle'],
'link' => $_link,
'description' => $row['bDescription'],
'creator' => $row['username'],
'creator' => SemanticScuttle_Model_UserArray::getName($row),
'pubdate' => $_pubdate,
'tags' => $row['tags']
);