diff options
author | Yalçın Can <ylcncn@gmail.com> | 2011-07-27 14:23:37 +0300 |
---|---|---|
committer | Yalçın Can <ylcncn@gmail.com> | 2011-07-27 14:23:37 +0300 |
commit | efd842174fdd37f8eb2c460c7adb21954bcfbe9d (patch) | |
tree | a2ab3cc25db92b901b69ce1bc0ad1dedb5d498ef /www | |
parent | 8cd40b3d76e191b2fbe95b044f69aed07cc27664 (diff) | |
parent | 81aa17b8523d95310c90366d9af09767db0c84f2 (diff) | |
download | semanticscuttle-efd842174fdd37f8eb2c460c7adb21954bcfbe9d.tar.gz semanticscuttle-efd842174fdd37f8eb2c460c7adb21954bcfbe9d.tar.bz2 |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'www')
-rw-r--r-- | www/ajaxGetNewPrivateKey.php | 35 | ||||
-rw-r--r-- | www/bookmarks.php | 27 | ||||
-rw-r--r-- | www/index.php | 23 | ||||
-rw-r--r-- | www/js/jstree-1.0-rc2/MultiComboBox.js | 72 | ||||
-rw-r--r-- | www/jsScuttle.php | 18 | ||||
-rw-r--r-- | www/profile.php | 33 | ||||
-rw-r--r-- | www/rss.php | 34 | ||||
-rw-r--r-- | www/tags.php | 24 |
8 files changed, 186 insertions, 80 deletions
diff --git a/www/ajaxGetNewPrivateKey.php b/www/ajaxGetNewPrivateKey.php new file mode 100644 index 0000000..eacebd8 --- /dev/null +++ b/www/ajaxGetNewPrivateKey.php @@ -0,0 +1,35 @@ +<?php +/** + * 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"); + +$httpContentType = 'text/xml'; +require_once 'www-header.php'; + +$us = SemanticScuttle_Service_Factory::get('User'); + +/* Managing all possible inputs */ +isset($_GET['url']) ? define('GET_URL', $_GET['url']): define('GET_URL', ''); + +echo '<?xml version="1.0" encoding="utf-8"?>'; +?> +<response> +<method> +getNewPrivateKey +</method> +<result> +<?php echo $us->getNewPrivateKey(); ?> +</result> +</response> diff --git a/www/bookmarks.php b/www/bookmarks.php index efc1680..72c063e 100644 --- a/www/bookmarks.php +++ b/www/bookmarks.php @@ -229,12 +229,14 @@ if ($templatename == 'editbookmark.tpl') { $tplVars['sidebar_blocks'] = array('watchstatus'); if (!$cat) { //user page without tags + $rssTitle = "My Bookmarks"; $cat = NULL; $tplVars['currenttag'] = NULL; //$tplVars['sidebar_blocks'][] = 'menu2'; $tplVars['sidebar_blocks'][] = 'linked'; $tplVars['sidebar_blocks'][] = 'popular'; } else { //pages with tags + $rssTitle = "Tags" . $catTitle; $rssCat = '/'. filter($cat, 'url'); $tplVars['currenttag'] = $cat; $tplVars['sidebar_blocks'][] = 'tagactions'; @@ -264,9 +266,32 @@ if ($templatename == 'editbookmark.tpl') { // Set template vars $tplVars['rsschannels'] = array( - array(filter($sitename .': '. $pagetitle), createURL('rss', filter($user, 'url') . $rssCat.'?sort='.getSortOrder())) + array( + sprintf(T_('%s: %s'), $sitename, $rssTitle), + createURL('rss', filter($user, 'url')) + . $rssCat . '?sort='.getSortOrder() + ) ); + if ($userservice->isLoggedOn()) { + $currentUsername = $currentUser->getUsername(); + if ($userservice->isPrivateKeyValid($currentUser->getPrivateKey())) { + array_push( + $tplVars['rsschannels'], + array( + sprintf( + T_('%s: %s (+private %s)'), + $sitename, $rssTitle, $currentUsername + ), + createURL('rss', filter($currentUsername, 'url')) + . $rssCat + . '?sort=' . getSortOrder() + . '&privateKey=' . $currentUser->getPrivateKey() + ) + ); + } + } + $tplVars['page'] = $page; $tplVars['start'] = $start; $tplVars['bookmarkCount'] = $start + 1; diff --git a/www/index.php b/www/index.php index f6704ae..7fbb84c 100644 --- a/www/index.php +++ b/www/index.php @@ -42,9 +42,30 @@ if (GET_ACTION == "logout") { // Header variables $tplVars['loadjs'] = true; $tplVars['rsschannels'] = array( -array(sprintf(T_('%s: Recent bookmarks'), $sitename), createURL('rss').'?sort='.getSortOrder()) + array( + sprintf(T_('%s: Recent bookmarks'), $sitename), + createURL('rss') . '?sort=' . getSortOrder() + ) ); +if ($userservice->isLoggedOn()) { + if ($userservice->isPrivateKeyValid($currentUser->getPrivateKey())) { + $currentUsername = $currentUser->getUsername(); + array_push( + $tplVars['rsschannels'], + array( + sprintf( + T_('%s: Recent bookmarks (+private %s)'), + $sitename, $currentUsername + ), + createURL('rss') + . '?sort=' . getSortOrder() + . '&privateKey=' . $currentUser->getPrivateKey() + ) + ); + } +} + if ($usecache) { // Generate hash for caching on $hashtext = $_SERVER['REQUEST_URI']; diff --git a/www/js/jstree-1.0-rc2/MultiComboBox.js b/www/js/jstree-1.0-rc2/MultiComboBox.js deleted file mode 100644 index b263c8b..0000000 --- a/www/js/jstree-1.0-rc2/MultiComboBox.js +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved. - Available via Academic Free License >= 2.1 OR the modified BSD license. - see: http://dojotoolkit.org/license for details -*/ - -/* SemanticScuttle: This script is a light modification of dojox.form.MultiComboBox -This fork allows specific use until DOJO 1.2.3 in Google CDN. */ - - - -if(!dojo._hasResource["js.MultiComboBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["js.MultiComboBox"] = true; -dojo.provide("js.MultiComboBox"); -dojo.experimental("js.MultiComboBox"); -dojo.require("dijit.form.ComboBox"); -dojo.require("dijit.form.ValidationTextBox"); - -dojo.declare("js.MultiComboBox", - [dijit.form.ValidationTextBox, dijit.form.ComboBoxMixin],{ - // - // summary: A ComboBox that accpets multiple inputs on a single line? - // - // delimiter: String - // The character to use to separate items in the ComboBox input - delimiter: ",", - _previousMatches: false, - - _setValueAttr: function(value){ - if (this.delimiter && value.length != 0){ - value = value+this.delimiter+" "; - arguments[0] = this._addPreviousMatches(value); - } - this.inherited(arguments); - }, - - _addPreviousMatches: function(/* String */text){ - if(this._previousMatches){ - if(!text.match(new RegExp("^"+this._previousMatches))){ - text = this._previousMatches+text; - } - } - text = this._cleanupDelimiters(text); // SScuttle: this line was moved - return text; // String - }, - - _cleanupDelimiters: function(/* String */text){ - if(this.delimiter){ - text = text.replace(new RegExp(" +"), " "); - text = text.replace(new RegExp("^ *"+this.delimiter+"* *"), ""); - text = text.replace(new RegExp(this.delimiter+" *"+this.delimiter), this.delimiter); - } - return text; - }, - - _autoCompleteText: function(/* String */text){ - arguments[0] = this._addPreviousMatches(text); - this.inherited(arguments); - }, - - _startSearch: function(/* String */text){ - text = this._cleanupDelimiters(text); - var re = new RegExp("^.*"+this.delimiter+" *"); - - if((this._previousMatches = text.match(re))){ - arguments[0] = text.replace(re, ""); - } - this.inherited(arguments); - } -}); - -}
\ No newline at end of file diff --git a/www/jsScuttle.php b/www/jsScuttle.php index 5e5f31b..de97fd2 100644 --- a/www/jsScuttle.php +++ b/www/jsScuttle.php @@ -90,6 +90,24 @@ 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) { + pk.value = response.trim(); + } else { + loadXMLDocProc('<?php echo ROOT; ?>ajaxGetNewPrivateKey.php'); + } + return false; +} + function getTitle(input, response){ var title = document.getElementById('titleField'); if (title.value == '') { diff --git a/www/profile.php b/www/profile.php index ccdb7a8..63f4da8 100644 --- a/www/profile.php +++ b/www/profile.php @@ -23,12 +23,16 @@ require_once 'www-header.php'; /* Service creation: only useful services are created */ // No specific services +$tplVars['loadjs'] = true; /* Managing all possible inputs */ +isset($_POST['submittedPK']) ? define('POST_SUBMITTEDPK', $_POST['submittedPK']): define('POST_SUBMITTEDPK', ''); isset($_POST['submitted']) ? define('POST_SUBMITTED', $_POST['submitted']): define('POST_SUBMITTED', ''); isset($_POST['pPass']) ? define('POST_PASS', $_POST['pPass']): define('POST_PASS', ''); isset($_POST['pPassConf']) ? define('POST_PASSCONF', $_POST['pPassConf']): define('POST_PASSCONF', ''); isset($_POST['pName']) ? define('POST_NAME', $_POST['pName']): define('POST_NAME', ''); +isset($_POST['pPrivateKey']) ? define('POST_PRIVATEKEY', $_POST['pPrivateKey']): define('POST_PRIVATEKEY', ''); +isset($_POST['pEnablePrivateKey']) ? define('POST_ENABLEPRIVATEKEY', $_POST['pEnablePrivateKey']): define('POST_ENABLEPRIVATEKEY', ''); isset($_POST['pMail']) ? define('POST_MAIL', $_POST['pMail']): define('POST_MAIL', ''); isset($_POST['pPage']) ? define('POST_PAGE', $_POST['pPage']): define('POST_PAGE', ''); isset($_POST['pDesc']) ? define('POST_DESC', $_POST['pDesc']): define('POST_DESC', ''); @@ -61,10 +65,19 @@ if ($user) { exit(); } +$tplVars['privateKeyIsEnabled'] = ''; if ($userservice->isLoggedOn() && $user == $currentUser->getUsername()) { - $title = T_('My Profile'); + $title = T_('My Profile'); + $tplVars['privateKey'] = $currentUser->getPrivateKey(true); + + if ($userservice->isPrivateKeyValid($currentUser->getPrivateKey())) { + $tplVars['privateKeyIsEnabled'] = 'checked="checked"'; + } else { + $tplVars['privateKeyIsEnabled'] = ''; + } } else { - $title = T_('Profile') .': '. $user; + $title = T_('Profile') .': '. $user; + $tplVars['privateKey'] = ''; } $tplVars['pagetitle'] = $title; $tplVars['subtitle'] = $title; @@ -72,11 +85,19 @@ $tplVars['subtitle'] = $title; $tplVars['user'] = $user; $tplVars['userid'] = $userid; +/* Update Private Key */ +if (POST_SUBMITTEDPK!='' && $currentUser->getId() == $userid) { + $userinfo = $userservice->getObjectUserByUsername($user); + $tplVars['privateKey'] = $userservice->getNewPrivateKey(); +} + if (POST_SUBMITTED!='' && $currentUser->getId() == $userid) { $error = false; $detPass = trim(POST_PASS); $detPassConf = trim(POST_PASSCONF); $detName = trim(POST_NAME); + $detPrivateKey = trim(POST_PRIVATEKEY); + $detEnablePrivateKey = trim(POST_ENABLEPRIVATEKEY); $detMail = trim(POST_MAIL); $detPage = trim(POST_PAGE); $detDesc = filter(POST_DESC); @@ -102,13 +123,19 @@ if (POST_SUBMITTED!='' && $currentUser->getId() == $userid) { $tplVars['error'] = T_('E-mail address is not valid.'); } if (!$error) { - if (!$userservice->updateUser($userid, $detPass, $detName, $detMail, $detPage, $detDesc)) { + if (!$userservice->updateUser($userid, $detPass, $detName, $detMail, $detPage, $detDesc, $detPrivateKey, $detEnablePrivateKey)) { $tplVars['error'] = T_('An error occurred while saving your changes.'); } else { $tplVars['msg'] = T_('Changes saved.'); } } $userinfo = $userservice->getObjectUserByUsername($user); + $tplVars['privateKey'] = $userinfo->getPrivateKey(true); + if ($userservice->isPrivateKeyValid($userinfo->getPrivateKey())) { + $tplVars['privateKeyIsEnabled'] = 'checked="checked"'; + } else { + $tplVars['privateKeyIsEnabled'] = ''; + } } if (!$userservice->isLoggedOn() || $currentUser->getId() != $userid) { diff --git a/www/rss.php b/www/rss.php index 50240e5..d888726 100644 --- a/www/rss.php +++ b/www/rss.php @@ -64,7 +64,12 @@ if (!isset($rssEntries) || $rssEntries <= 0) { $rssEntries = $maxRssEntries; } +$privateKey = null; +if (isset($_GET['privateKey'])) { + $privateKey = $_GET['privateKey']; +} +$userid = null; $watchlist = null; $pagetitle = ''; if ($user && $user != 'all') { @@ -78,8 +83,22 @@ if ($user && $user != 'all') { } else { if ($userinfo = $userservice->getUserByUsername($user)) { $userid =& $userinfo[$userservice->getFieldName('primary')]; + /* if user is not logged in and has valid privateKey */ + if (!$userservice->isLoggedOn()) { + if ($privateKey != null) { + 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); + //throw a 404 error + exit(); + } + } + } + } else { $tplVars['error'] = sprintf(T_('User with username %s was not found'), $user); + header('Content-type: text/html; charset=utf-8'); $templateservice->loadTemplate('error.404.tpl', $tplVars); //throw a 404 error exit(); @@ -87,7 +106,17 @@ if ($user && $user != 'all') { } $pagetitle .= ": ". $user; } else { - $userid = null; + if ($privateKey != null) { + 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); + //throw a 404 error + exit(); + } + } else { + $userid = null; + } } if ($cat) { @@ -100,7 +129,8 @@ $tplVars['feeddescription'] = sprintf(T_('Recent bookmarks posted to %s'), $GLOB $bookmarks = $bookmarkservice->getBookmarks( 0, $rssEntries, $userid, $cat, - null, getSortOrder(), $watchlist + null, getSortOrder(), $watchlist, + null, null, null ); $bookmarks_tmp = filter($bookmarks['bookmarks']); diff --git a/www/tags.php b/www/tags.php index a4e6555..127f6c5 100644 --- a/www/tags.php +++ b/www/tags.php @@ -67,9 +67,31 @@ if ($usecache) { $tplVars['pagetitle'] = T_('Tags') .': '. $cat; $tplVars['loadjs'] = true; $tplVars['rsschannels'] = array( -array(filter($sitename .': '. $pagetitle), createURL('rss', 'all/'. filter($cat, 'url')).'?sort='.getSortOrder()) + array( + sprintf(T_('%s: tagged with "%s"'), $sitename, $cat), + createURL('rss', 'all/' . filter($cat, 'url')) + . '?sort='.getSortOrder() + ) ); +if ($userservice->isLoggedOn()) { + if ($userservice->isPrivateKeyValid($currentUser->getPrivateKey())) { + $currentUsername = $currentUser->getUsername(); + array_push( + $tplVars['rsschannels'], + array( + sprintf( + T_('%s: tagged with "%s" (+private %s)'), + $sitename, $cat, $currentUsername + ), + createURL('rss', filter($currentUsername, 'url')) + . '?sort=' . getSortOrder() + . '&privateKey=' . $currentUser->getPrivateKey() + ) + ); + } +} + // Pagination $perpage = getPerPageCount($currentUser); if (intval(GET_PAGE) > 1) { |