]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Updates for feature request 3164348: Make default privacy configurable.
authorbretticvs <bsdee@frii.com>
Tue, 15 Mar 2011 06:53:39 +0000 (07:53 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 15 Mar 2011 06:53:39 +0000 (07:53 +0100)
data/config.default.php
data/config.php.dist
data/templates/bookmarks.tpl.php
tests/BookmarkTest.php
www/api/posts_add.php
www/bookmarks.php
www/edit.php
www/import.php
www/importNetscape.php

index bd67c7b3600c2ed46ebd0c409d10590c45222b55..cd611f1b36c60e1dda9d763e0587be85dd3c7905 100644 (file)
  * @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
index c135e8e46192f679644a9d126af78c007719e159..0f849e2182b41091a8831632dc29ab98f8b36249 100644 (file)
@@ -7,6 +7,13 @@
  * See config.default.inc.php for more options.
  */
 
+/**
+ * Array for defaults.
+ *
+ * @var array 
+ */
+$defaults = array();
+
 /**
  * The name of this site.
  *
@@ -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.
index e32d3c9e35b52b5d515904f0af78993ccd7516bd..44dfe905a800248a7a0be4406667afa2945fb356 100644 (file)
@@ -256,7 +256,7 @@ if ($currenttag!= '') {
        foreach ($bookmarks as $key => &$row) {
                switch ($row['bStatus']) {
                        case 0:
-                               $access = '';
+                               $access = ' public';
                                break;
                        case 1:
                                $access = ' shared';
index f54fe9af76e3ca401b55e704eb3e551606beba49..aa0b8c3aa51918d9ae72e3f25ed5ecf3a7728bd0 100644 (file)
@@ -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
+
+
 
 }
 
index 7f9dc59d4df1432f9db6c90393d3dc56ec96d934..80d65155703ed5a5c96679fde4e77da12b7de94e 100644 (file)
@@ -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)) {
index 5241481bffff976c3a80ac1cd5c27f1da61459ac..d4fe051f15205055185e4bab7c90002870f8713d 100644 (file)
@@ -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'] 
                         );
                        }
                                
index fbea163bc430a1479f56c0f90817bb95d15cdcda..cbfa30b160c351aa57b0bafcc78c33c3edf6b7f8 100644 (file)
@@ -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', '');
index 5263aba455cc014d4c04ff20e7ea526b9dad7e3c..3aa2714623be6919c0eea71fc3f86bc2998ec449 100644 (file)
@@ -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();
index e23c156e2bc9ad541cb673c756e9df3320ed522d..b476c40c53b4b6247a077ccb28223219ff52eeda 100644 (file)
@@ -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