Skip to content
27 changes: 16 additions & 11 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

class helper_plugin_task extends DokuWiki_Plugin {

function getMethods() {
$result = array();
$result[] = array(
Expand Down Expand Up @@ -50,7 +50,7 @@ function getMethods() {
);
return $result;
}

/**
* Returns the column header for the Pagelist Plugin
*/
Expand Down Expand Up @@ -124,20 +124,23 @@ function getTasks($ns, $num = NULL, $filter = '', $user = NULL) {
// skip assigned and not new tasks if filter is 'new'
if (($filter == 'new') && ($task['user']['name'] || ($task['status'] != 0))) continue;

// filter is 'due' or 'overdue'
// filter is 'due' or 'overdue'
if (in_array($filter, array('due', 'overdue'))) {
if (!$date || ($date > time()) || ($task['status'] > 2)) continue;
elseif (($date + 86400 < time()) && ($filter == 'due')) continue;
elseif (($date + 86400 > time()) && ($filter == 'overdue')) continue;
}
}

// Filter task if user is specified
if($user && (!isset($task['user']['id']) || $user !== $task['user']['id'])) continue;

$result[$task['key']] = array(
'id' => $id,
'date' => $date,
'user' => $task['user']['name'],
'status' => $this->statusLabel($task['status']),
'priority' => $task['priority'],
'perm' => $perm,
// 'perm' => $perm,
'file' => $task['file'],
'exists' => true,
);
Expand Down Expand Up @@ -350,8 +353,10 @@ function _vtodo($id, $task) {
'UID:'.$id.'@'.$_SERVER['SERVER_NAME'].CRLF.
'URL:'.wl($id, '', true, '&').CRLF.
'SUMMARY:'.$this->_vsc($meta['title']).CRLF;
if ($meta['description']['abstract'])
if (isset($meta['description']['abstract']) && $meta['description']['abstract'])
$ret .= 'DESCRIPTION:'.$this->_vsc($meta['description']['abstract']).CRLF;
elseif (isset($meta['description']) && $meta['description'])
$ret .= 'DESCRIPTION:'.$this->_vsc($meta['description']).CRLF;
if ($meta['subject'])
$ret .= 'CATEGORIES:'.$this->_vcategories($meta['subject']).CRLF;
if ($task['date']['created'])
Expand Down Expand Up @@ -396,10 +401,10 @@ function _vstatus($status) {
switch ($status) {
case -1:
return 'CANCELLED';
case 1:
case 1:
case 2:
return 'IN-PROCESS';
case 3:
case 3:
case 4:
return 'COMPLETED';
default:
Expand Down Expand Up @@ -427,7 +432,7 @@ function _vclass($id) {
/**
* Show the form to create a new task.
* The function just forwards the call to the old or new function.
*
*
* @param string $ns The DokuWiki namespace in which the new task
* page shall be created
* @param bool $selectUser If false then create a simple input line for the user field.
Expand All @@ -447,7 +452,7 @@ function _newTaskForm($ns, $selectUser=false, $selectUserGroup=NULL) {
/**
* Show the form to create a new task.
* This is the new version using class dokuwiki\Form\Form.
*
*
* @see _newTaskForm
*/
protected function _newTaskFormNew($ns, $selectUser=false, $selectUserGroup=NULL) {
Expand Down Expand Up @@ -531,7 +536,7 @@ protected function _newTaskFormNew($ns, $selectUser=false, $selectUserGroup=NULL
/**
* Show the form to create a new task.
* This is the old version, creating all HTML code on its own.
*
*
* @see _newTaskForm
*/
protected function _newTaskFormOld($ns, $selectUser=false, $selectUserGroup=NULL) {
Expand Down
2 changes: 1 addition & 1 deletion ics.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$data['vtodo'].
'END:VCALENDAR'.CRLF;

header("Content-Disposition: attachment; filename='$filename'");
header("Content-Disposition: attachment; filename=$filename");
header('Content-Length: '.strlen($output));
header('Connection: close');
header("Content-Type: text/Calendar; name='$filename'");
Expand Down
46 changes: 23 additions & 23 deletions syntax/task.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Esther Brunner <wikidesign@gmail.com>
*/

class syntax_plugin_task_task extends DokuWiki_Syntax_Plugin {

var $my = NULL;
Expand All @@ -14,34 +14,34 @@ class syntax_plugin_task_task extends DokuWiki_Syntax_Plugin {
function getType() { return 'substition'; }
function getSort() { return 305; }
function getPType() { return 'block';}

function connectTo($mode) {
$this->Lexer->addSpecialPattern('~~TASK.*?~~', $mode, 'plugin_task_task');
}

function handle($match, $state, $pos, Doku_Handler $handler) {
global $ID;
global $INFO;
global $ACT;
global $REV;

// strip markup and split arguments
$match = substr($match, 6, -2);
$priority = strspn(strstr($match, '!'), '!');
$match = trim($match, ':!');
list($user, $date) = explode('?', $match);
list($user, $date) = array_pad(explode('?', $match), 2, null);

if ($my =& plugin_load('helper', 'task')) {
$date = $my->_interpretDate($date);

$task = array(
'user' => array('name' => $user),
'date' => array('due' => $date),
'priority' => $priority
);

// save task meta file if changes were made
// but only for already existing tasks, or when the page is saved
// save task meta file if changes were made
// but only for already existing tasks, or when the page is saved
// $REV prevents overwriting current task information with old revision ones
if(@file_exists(metaFN($ID, '.task')) && $ACT != 'preview' && !$REV) {
$current = $my->readTask($ID);
Expand All @@ -53,17 +53,17 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
}
}
return array($user, $date, $priority);
}
function render($mode, Doku_Renderer $renderer, $data) {
}

function render($mode, Doku_Renderer $renderer, $data) {
global $ID;

list($user, $date, $priority) = $data;

// XHTML output
if ($mode == 'xhtml') {
$renderer->nocache();

// prepare data
$this->_loadHelper();

Expand All @@ -88,7 +88,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
}

$class .= '"';

// generate output
$renderer->doc .= '<div class="vcalendar">'.DOKU_LF
. '<fieldset'.$class.'>'.DOKU_LF
Expand All @@ -106,7 +106,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
} elseif ($task['date']['due']) {
$this->_tablerow('date', $this->_hCalDate($task['date']['due']), $renderer, $due);
}

// show status update form only to logged in users
if(isset($_SERVER['REMOTE_USER'])) {
$this->_tablerow('status', $status, $renderer);
Expand All @@ -117,15 +117,15 @@ function render($mode, Doku_Renderer $renderer, $data) {
'</div>'.DOKU_LF;

return true;

// for metadata renderer
} elseif ($mode == 'metadata') {
return true;
}

return false;
}

/**
* Outputs a table row
*/
Expand All @@ -140,7 +140,7 @@ function _tablerow($header, $data, &$renderer, $trclass = '', $tdclass = '') {
$renderer->tablecell_close();
$renderer->tablerow_close();
}

/**
* Loads the helper plugin and gets task data for current ID
*/
Expand All @@ -149,7 +149,7 @@ function _loadHelper() {
$this->my =& plugin_load('helper', 'task');
if (!is_object($this->my)) return false;
$this->task = $this->my->readTask($ID);
return $true;
return true;
}

/**
Expand Down Expand Up @@ -194,7 +194,7 @@ function _statusMenu($options, $status) {
/**
* Returns the XHTML for the status popup menu.
* This is the new version using class dokuwiki\Form\Form.
*
*
* @see _statusMenu
*/
function _statusMenuNew($options, $status) {
Expand Down Expand Up @@ -233,7 +233,7 @@ function _statusMenuNew($options, $status) {
/**
* Returns the XHTML for the status popup menu.
* Old function generating all HTML on its own.
*
*
* @see _statusMenu
*/
function _statusMenuOld($options, $status) {
Expand Down Expand Up @@ -298,4 +298,4 @@ function _hCalDate($date) {
return '<abbr class="due" title="'.$this->my->_vdate($date, true).'">' . strftime($onlydate, $date) . '</abbr>';
}
}
// vim:ts=4:sw=4:et:enc=utf-8:
// vim:ts=4:sw=4:et:enc=utf-8:
26 changes: 13 additions & 13 deletions syntax/tasks.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Task Plugin, tasks component: lists tasks of a given namespace
*
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Esther Brunner <wikidesign@gmail.com>
*/
Expand All @@ -19,7 +19,7 @@ public function __construct() {
function getType() { return 'substition'; }
function getPType() { return 'block'; }
function getSort() { return 306; }

function connectTo($mode) {
$this->Lexer->addSpecialPattern('\{\{tasks>.+?\}\}', $mode, 'plugin_task_tasks');
}
Expand All @@ -30,7 +30,7 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
$match = substr($match, 8, -2); // strip {{topic> from start and }} from end
list($match, $flags) = explode('&', $match, 2);
$flags = explode('&', $flags);
list($match, $refine) = explode(' ', $match, 2);
list($match, $refine) = array_pad(explode(' ', $match, 2), 2, null);
list($ns, $filter) = explode('?', $match, 2);

if (($ns == '*') || ($ns == ':')) $ns = '';
Expand All @@ -47,12 +47,12 @@ function render($mode, Doku_Renderer $renderer, $data) {

if (!$filter || ($filter == 'select')) {
$select = true;
$filter = trim($_REQUEST['filter']);
$filter = trim($_REQUEST['filter'] ?? null);
}
$filter = strtolower($filter);
$filters = $this->_viewFilters();
if (!in_array($filter, $filters)) $filter = 'open';
if(isset($_REQUEST['view_user'])) $user = $_REQUEST['view_user'];
$user = $_REQUEST['view_user'] ?? null;

if ($this->helper) $pages = $this->helper->getTasks($ns, NULL, $filter, $user);

Expand Down Expand Up @@ -108,7 +108,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
return false;
}

// show view filter popup if not
// show view filter popup if not
if ($select) $renderer->doc .= $this->_viewMenu($filter);

// prepare pagelist columns
Expand All @@ -129,7 +129,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
$pagelist->addPage($page);
}
$renderer->doc .= $pagelist->finishList();
$renderer->doc .= $this->_paginationLinks($numOfPages, $currentPage, $filter);
$renderer->doc .= $this->_paginationLinks($numOfPages ?? 0, $currentPage ?? 0, $filter);

// show form to create a new task?
if($perm_create && ($this->getConf('tasks_formposition') == 'bottom')) {
Expand All @@ -150,7 +150,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
}
return false;
}

/* ---------- (X)HTML Output Functions ---------- */

/**
Expand All @@ -168,7 +168,7 @@ function _viewMenu($filter) {
/**
* Show a popup to select the task view filter.
* This is the new version using class dokuwiki\Form\Form.
*
*
* @see _viewMenu
*/
function _viewMenuNew($filter) {
Expand Down Expand Up @@ -205,7 +205,7 @@ function _viewMenuNew($filter) {
$form->addHTML('<label class="simple"><span>'.$this->getLang('view_user').':</span>', $pos++);
$input = $form->addCheckbox('view_user', NULL, $pos++);
$input->attr('value', $_SERVER['REMOTE_USER']);
if ($_REQUEST['view_user']) {
if (isset($_REQUEST['view_user']) && $_REQUEST['view_user']) {
$input->attr('checked', 'checked');
}
$form->addHTML('</label>', $pos++);
Expand All @@ -224,7 +224,7 @@ function _viewMenuNew($filter) {
/**
* Show a popup to select the task view filter.
* Old function generating all HTML on its own.
*
*
* @see _viewMenu
*/
function _viewMenuOld($filter) {
Expand Down Expand Up @@ -261,7 +261,7 @@ function _viewMenuOld($filter) {

return $ret;
}

/**
* Returns an array of available view filters for the task list
*/
Expand All @@ -274,7 +274,7 @@ function _viewFilters() {
}
return $filters;
}

/**
* Returns pagination links if more than one page
*/
Expand Down