summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbretticvs <bsdee@frii.com>2011-03-15 07:53:39 +0100
committerChristian Weiske <cweiske@cweiske.de>2011-03-15 07:53:39 +0100
commit65bd4bfab86fc47be3ce125640ebd49163f24f4b (patch)
tree7f1c5464bfee6204f19d361bd1425d0328e9e1c9
parent4cc46f268676d8df88ce6003df2a7bc9249fe7fb (diff)
downloadsemanticscuttle-65bd4bfab86fc47be3ce125640ebd49163f24f4b.tar.gz
semanticscuttle-65bd4bfab86fc47be3ce125640ebd49163f24f4b.tar.bz2
Updates for feature request 3164348: Make default privacy configurable.
-rw-r--r--data/config.default.php17
-rw-r--r--data/config.php.dist22
-rw-r--r--data/templates/bookmarks.tpl.php2
-rw-r--r--tests/BookmarkTest.php24
-rw-r--r--www/api/posts_add.php2
-rw-r--r--www/bookmarks.php4
-rw-r--r--www/edit.php2
-rw-r--r--www/import.php4
-rw-r--r--www/importNetscape.php4
9 files changed, 72 insertions, 9 deletions
diff --git a/data/config.default.php b/data/config.default.php
index bd67c7b..cd611f1 100644
--- a/data/config.default.php
+++ b/data/config.default.php
@@ -14,6 +14,13 @@
* @link http://sourceforge.net/projects/semanticscuttle/
*/
+/**
+ * Array for defaults.
+ *
+ * @var array
+ */
+$defaults = array();
+
/***************************************************
* HTML output configuration
@@ -493,6 +500,16 @@ $votingMode = 2;
*/
$hideBelowVoting = null;
+/**
+ * Default privacy setting for bookmarks:
+ * 0 - Public
+ * 1 - Shared with Watchlist
+ * 2 - Private
+ *
+ * @var integer
+ */
+$defaults['privacy'] = 0;
+
/****************************
* Website Thumbnails
diff --git a/data/config.php.dist b/data/config.php.dist
index c135e8e..0f849e2 100644
--- a/data/config.php.dist
+++ b/data/config.php.dist
@@ -8,6 +8,13 @@
*/
/**
+ * Array for defaults.
+ *
+ * @var array
+ */
+$defaults = array();
+
+/**
* The name of this site.
*
* @var string
@@ -116,6 +123,21 @@ $adminemail = 'admin@example.org';
$admin_users = array();
+/***************************************************
+ * Bookmarks
+ */
+
+/**
+ * Default privacy setting for bookmarks.
+ * 0 - Public
+ * 1 - Shared with Watchlist
+ * 2 - Private
+ *
+ * @var integer
+ */
+$defaults['privacy'] = 0;
+
+
/**
* You have completed the basic configuration!
* More options can be found in config.default.php.
diff --git a/data/templates/bookmarks.tpl.php b/data/templates/bookmarks.tpl.php
index e32d3c9..44dfe90 100644
--- a/data/templates/bookmarks.tpl.php
+++ b/data/templates/bookmarks.tpl.php
@@ -256,7 +256,7 @@ if ($currenttag!= '') {
foreach ($bookmarks as $key => &$row) {
switch ($row['bStatus']) {
case 0:
- $access = '';
+ $access = ' public';
break;
case 1:
$access = ' shared';
diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php
index f54fe9a..aa0b8c3 100644
--- a/tests/BookmarkTest.php
+++ b/tests/BookmarkTest.php
@@ -1343,6 +1343,30 @@ class BookmarkTest extends TestBase
}
+ /**
+ * Test that the default privacy setting in
+ * $GLOBALS['defaults']['privacy'] is used
+ * as expected.
+ *
+ * @return void
+ */
+ public function testDefaultPrivacy()
+ {
+ $GLOBALS['defaults']['privacy'] = 1;
+ $uid = $this->addUser();
+ $this->us->setCurrentUserId($uid);
+ $bid = $this->bs->addBookmark('http://www.somedomain.com', 'mybookmark1', 'descr1', 'privatenote1', $GLOBALS['defaults']['privacy'], array());
+ $bm = $this->bs->getBookmark($bid);
+ $this->assertEquals('1', $bm['bStatus']);
+ $GLOBALS['defaults']['privacy'] = 2;
+ $uid = $this->addUser();
+ $this->us->setCurrentUserId($uid);
+ $bid = $this->bs->addBookmark('http://www.anotherdomain.com', 'mybookmark2', 'descr2', 'privatenote2', $GLOBALS['defaults']['privacy'], array());
+ $bm = $this->bs->getBookmark($bid);
+ $this->assertEquals('2', $bm['bStatus']);
+ }//end function testDefaultPrivacy
+
+
}
diff --git a/www/api/posts_add.php b/www/api/posts_add.php
index 7f9dc59..80d6515 100644
--- a/www/api/posts_add.php
+++ b/www/api/posts_add.php
@@ -81,7 +81,7 @@ if (isset($_REQUEST['dt']) && (trim($_REQUEST['dt']) != '')) {
$replace = isset($_REQUEST['replace']) && ($_REQUEST['replace'] == 'yes');
-$status = 0;
+$status = $GLOBALS['defaults']['privacy'];
if (isset($_REQUEST['status'])) {
$status_str = trim($_REQUEST['status']);
if (is_numeric($status_str)) {
diff --git a/www/bookmarks.php b/www/bookmarks.php
index 5241481..d4fe051 100644
--- a/www/bookmarks.php
+++ b/www/bookmarks.php
@@ -185,7 +185,7 @@ if ($templatename == 'editbookmark.tpl') {
'bDescription' => stripslashes(POST_DESCRIPTION),
'bPrivateNote' => stripslashes(POST_PRIVATENOTE),
'tags' => (POST_TAGS ? explode(',', stripslashes(POST_TAGS)) : array()),
- 'bStatus' => 0,
+ 'bStatus' => $GLOBALS['defaults']['privacy'],
);
$tplVars['tags'] = POST_TAGS;
} else {
@@ -201,7 +201,7 @@ if ($templatename == 'editbookmark.tpl') {
'bDescription' => stripslashes(GET_DESCRIPTION),
'bPrivateNote' => stripslashes(GET_PRIVATENOTE),
'tags' => (GET_TAGS ? explode(',', stripslashes(GET_TAGS)) : array()),
- 'bStatus' => 0
+ 'bStatus' => $GLOBALS['defaults']['privacy']
);
}
diff --git a/www/edit.php b/www/edit.php
index fbea163..cbfa30b 100644
--- a/www/edit.php
+++ b/www/edit.php
@@ -33,7 +33,7 @@ isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TIT
isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('POST_ADDRESS', '');
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
isset($_POST['privateNote']) ? define('POST_PRIVATENOTE', $_POST['privateNote']): define('POST_PRIVATENOTE', '');
-isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
+isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', $GLOBALS['defaults']['privacy']);
isset($_POST['tags']) ? define('POST_TAGS', $_POST['tags']): define('POST_TAGS', '');
isset($_GET['popup']) ? define('GET_POPUP', $_GET['popup']): define('GET_POPUP', '');
diff --git a/www/import.php b/www/import.php
index 5263aba..3aa2714 100644
--- a/www/import.php
+++ b/www/import.php
@@ -27,7 +27,7 @@ require_once 'www-header.php';
/* Managing all possible inputs */
// First input is $_FILES
// Other inputs
-isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
+isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', $GLOBALS['defaults']['privacy']);
if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
@@ -36,7 +36,7 @@ if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['si
if (is_numeric(POST_STATUS)) {
$status = intval(POST_STATUS);
} else {
- $status = 2;
+ $status = $GLOBALS['defaults']['privacy'];
}
$depth = array();
diff --git a/www/importNetscape.php b/www/importNetscape.php
index e23c156..b476c40 100644
--- a/www/importNetscape.php
+++ b/www/importNetscape.php
@@ -28,7 +28,7 @@ $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
/* Managing all possible inputs */
// First input is $_FILES
// Other inputs
-isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
+isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', $GLOBALS['defaults']['privacy']);
$countImportedBookmarks = 0;
$tplVars['msg'] = '';
@@ -39,7 +39,7 @@ if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['si
if (is_numeric(POST_STATUS)) {
$status = intval(POST_STATUS);
} else {
- $status = 2;
+ $status = $GLOBALS['defaults']['privacy'];
}
// File handle