'+
'

'+
'

'+
@@ -343,7 +343,7 @@ function cancelEdit(e)
function saveTask(form)
{
- if(flag.needAuth && !flag.isLogged && flag.canAllRead) return false;
+ if(flag.needAuth && !flag.isLogged) return false;
var tz = -1 * (new Date()).getTimezoneOffset();
setAjaxErrorTrigger();
var nocache = '&rnd='+Math.random();
@@ -463,14 +463,8 @@ function updateAccessStatus()
$('#bar .menu-owner').hide();
$('#bar .bar-delim').hide();
}
- if(!flag.canAllRead && !flag.isLogged) {
- $('#page_tasks').hide();
- $('#lists').hide();
- } else {
- $('#page_tasks').show();
- }
}
- if(flag.needAuth && flag.canAllRead && !flag.isLogged) {
+ if(flag.needAuth && !flag.isLogged) {
$('#page_tasks').addClass('readonly')
$("#authstr").text(lang.readonly).show();
addsearchToggle(1);
@@ -511,13 +505,7 @@ function logout()
}, 'json');
flag.isLogged = false;
updateAccessStatus();
- if(flag.canAllRead) {
- loadTasks();
- }
- else {
- $('#total').html('0');
- $('#tasklist').html('');
- }
+ loadLists();
return false;
}
@@ -613,7 +601,7 @@ function setSort(v, init)
else if(v == 2) $('#sort>.btnstr').text($('#sortByDueDate').text());
else return;
- if(flag.needAuth && flag.canAllRead && !flag.isLogged) {
+ if(flag.needAuth && !flag.isLogged) {
$("#tasklist").sortable('disable');
return;
}
@@ -624,7 +612,6 @@ function setSort(v, init)
if(!init)
{
curList.sort = sortBy;
- tabLists[curList.i].sort = sortBy;
changeTaskOrder();
setAjaxErrorTrigger()
var nocache = '&rnd='+Math.random();
@@ -833,7 +820,10 @@ function mttTabSelected(el, indx)
$('#searchbarkeyword').text('');
$('#searchbar').hide();
}
- if(flag.canAllRead) $('#rss_icon').find('a').attr('href', 'feed.php?list='+tabLists[indx].id);
+ //if(tabLists[indx].published)
+ $('#rss_icon').find('a').attr('href', 'feed.php?list='+tabLists[indx].id);
+ if(tabLists[indx].published) $('#btnPublish').addClass('mtt-item-checked');
+ else $('#btnPublish').removeClass('mtt-item-checked');
}
curList = tabLists[indx];
flag.tagsChanged = true;
@@ -911,7 +901,6 @@ function toggleAllNotes(show)
function loadLists(onInit)
{
- if(flag.needAuth && !flag.isLogged && !flag.canAllRead) return false;
if(filter.search != '') {
filter.search = '';
$('#searchbarkeyword').text('');
@@ -937,7 +926,11 @@ function loadLists(onInit)
}
curList = tabLists[0];
loadTasks();
- if(flag.canAllRead) $('#rss_icon').show().find('a').attr('href', 'feed.php?list='+curList.id);
+ if(curList.published) $('#btnPublish').addClass('mtt-item-checked');
+ else $('#btnPublish').removeClass('mtt-item-checked');
+ //if(curList.published)
+ $('#rss_icon').show().find('a').attr('href', 'feed.php?list='+curList.id);
+ $('#page_tasks').show();
}
else {
curList = 0;
@@ -945,6 +938,7 @@ function loadLists(onInit)
$('#page_tasks h3').children().addClass('invisible');
$('#mylistscontainer .mtt-need-list').addClass('mtt-disabled');
$('#rss_icon').hide();
+ if(flag.needAuth && !flag.isLogged) $('#page_tasks').hide();
}
ti += '';
$('#lists>ul').html(ti);
@@ -1011,7 +1005,7 @@ function addsearchToggle(toSearch)
}
else
{
- if(flag.needAuth && flag.canAllRead && !flag.isLogged) return false;
+ if(flag.needAuth && !flag.isLogged) return false;
showhide($('#htab_newtask'), $('#htab_search'));
// reload tasks when we return to task tab (from search tab)
if(filter.search != '') {
@@ -1095,7 +1089,7 @@ function saveSettings(frm)
function submitFullTask(form)
{
- if(flag.needAuth && !flag.isLogged && flag.canAllRead) return false;
+ if(flag.needAuth && !flag.isLogged) return false;
setAjaxErrorTrigger();
var nocache = '&rnd='+Math.random();
$.post('ajax.php?fullNewTask'+nocache, { list:curList.id, tag:filter.tag, title: form.task.value, note:form.note.value, prio:form.prio.value, tags:form.tags.value, duedate:form.duedate.value }, function(json){
@@ -1115,3 +1109,17 @@ function submitFullTask(form)
flag.tagsChanged = true;
return false;
}
+
+function publishCurList()
+{
+ if(!curList) return false;
+ setAjaxErrorTrigger();
+ var nocache = '&rnd='+Math.random();
+ $.post('ajax.php?publishList'+nocache, { list:curList.id, publish:curList.published?0:1 }, function(json){
+ resetAjaxErrorTrigger();
+ if(!parseInt(json.total)) return;
+ curList.published = curList.published?0:1;
+ if(curList.published) $('#btnPublish').addClass('mtt-item-checked');
+ else $('#btnPublish').removeClass('mtt-item-checked');
+ }, 'json');
+}
diff --git a/src/ajax.php b/src/ajax.php
index 0daa4e1..8170921 100644
--- a/src/ajax.php
+++ b/src/ajax.php
@@ -16,23 +16,29 @@ $lang = new Lang();
if(isset($_GET['loadLists']))
{
- check_read_access();
+ if($needAuth && !is_logged()) $sqlWhere = 'WHERE published=1';
+ else $sqlWhere = '';
$t = array();
$t['total'] = 0;
- $q = $db->dq("SELECT * FROM lists ORDER BY id ASC");
+ $q = $db->dq("SELECT * FROM lists $sqlWhere ORDER BY id ASC");
while($r = $q->fetch_assoc($q))
{
$t['total']++;
- $t['list'][] = array('id'=>$r['id'], 'name'=>htmlarray($r['name']), 'sort'=>$r['sorting']);
+ $t['list'][] = array(
+ 'id' => $r['id'],
+ 'name' => htmlarray($r['name']),
+ 'sort' => (int)$r['sorting'],
+ 'published' => $r['published'] ? 1 :0,
+ );
}
echo json_encode($t);
exit;
}
elseif(isset($_GET['loadTasks']))
{
- check_read_access();
stop_gpc($_GET);
$listId = (int)_get('list');
+ check_read_access($listId);
$sqlWhere = ' AND list_id='. $listId;
if(_get('compl') == 0) $sqlWhere .= ' AND compl=0';
$inner = '';
@@ -295,8 +301,8 @@ elseif(isset($_POST['logout']))
}
elseif(isset($_GET['suggestTags']))
{
- check_read_access();
$listId = (int)_get('list');
+ check_read_access($listId);
$begin = trim(_get('q'));
$limit = (int)_get('limit');
if($limit<1) $limit = 8;
@@ -325,6 +331,7 @@ elseif(isset($_GET['setPrio']))
elseif(isset($_GET['tagCloud']))
{
$listId = (int)_get('list');
+ check_read_access($listId);
$a = array();
$q = $db->dq("SELECT name,tags_count FROM tags WHERE list_id=$listId AND tags_count>0 ORDER BY tags_count ASC");
while($r = $q->fetch_row()) {
@@ -409,6 +416,15 @@ elseif(isset($_GET['setSort']))
echo json_encode(array('total'=>1));
exit;
}
+elseif(isset($_GET['publishList']))
+{
+ check_write_access();
+ $listId = (int)_post('list');
+ $publish = (int)_post('publish');
+ $db->ex("UPDATE lists SET published=? WHERE id=$listId", array($publish ? 1 : 0));
+ echo json_encode(array('total'=>1));
+ exit;
+}
###################################################################################################
@@ -436,9 +452,16 @@ function prepareTaskRow($r, $tz)
);
}
-function check_read_access()
+function check_read_access($listId = null)
{
- if(canAllRead() || is_logged()) return;
+ global $db;
+ if(!isset($config['password']) || $config['password'] == '') return true;
+ if(is_logged()) return true;
+ if($listId)
+ {
+ $id = $db->sq("SELECT id FROM lists WHERE id=? AND published=1", array($listId));
+ if($id) return;
+ }
echo json_encode( array('total'=>0, 'list'=>array(), 'denied'=>1) );
exit;
}
diff --git a/src/common.php b/src/common.php
index f5823ba..d51aedd 100644
--- a/src/common.php
+++ b/src/common.php
@@ -69,7 +69,6 @@ class Config
'title' => array('default'=>'', 'type'=>'s'),
'lang' => array('default'=>'en', 'type'=>'s'),
'password' => array('default'=>'', 'type'=>'s'),
- 'allowread' => array('default'=>0, 'type'=>'i'),
'smartsyntax' => array('default'=>1, 'type'=>'i'),
'autotz' => array('default'=>1, 'type'=>'i'),
'autotag' => array('default'=>1, 'type'=>'i'),
diff --git a/src/db/config.php.default b/src/db/config.php.default
index 4666c1f..a190f65 100644
--- a/src/db/config.php.default
+++ b/src/db/config.php.default
@@ -19,10 +19,6 @@ $config['lang'] = "en";
# or leave empty that everyone could read/write todolist
$config['password'] = "";
-# Allow readonly access for the others when password above is set:
-# 0 - No access, 1 - Read only
-$config['allowread'] = 0;
-
# To disable smart syntax uncomment the line below
#$config['smartsyntax'] = 0;
diff --git a/src/feed.php b/src/feed.php
index 4a7ca09..b662c62 100644
--- a/src/feed.php
+++ b/src/feed.php
@@ -12,16 +12,16 @@ require_once('./lang/class.default.php');
require_once('./lang/'.$config['lang'].'.php');
$lang = new Lang();
-if(!canAllRead()) {
- die("Access denied!
Disable password protection or Grant read access");
-}
-
$listId = (int)_get('list');
$listData = $db->sqa("SELECT * FROM lists WHERE id=$listId");
+if($needAuth && (!$listData || !$listData['published'])) {
+ die("Access denied!
List is not published.");
+}
if(!$listData) {
die("No such list");
}
+
$listData['_feed_title'] = sprintf($lang->get('feed_title'), $listData['name']);
$listData['_feed_descr'] = sprintf($lang->get('feed_description'), $listData['name']);
htmlarray_ref($listData);
diff --git a/src/index.php b/src/index.php
index 7bd0106..edc1fd9 100644
--- a/src/index.php
+++ b/src/index.php
@@ -62,7 +62,6 @@ $().ready(function(){
if($needAuth)
{
echo "\tflag.needAuth = true;\n";
- if(!canAllRead()) echo "\tflag.canAllRead = false;\n";
if(is_logged()) echo "\tflag.isLogged = true;\n";
echo "\tupdateAccessStatus();\n";
}
@@ -202,11 +201,12 @@ $().ajaxStop( function(r,s) {$("#loading").fadeOut();} );
-