From e5ff72b860bee8bfff3950586466e0450e6cadd7 Mon Sep 17 00:00:00 2001 From: Louis Ouellet Date: Tue, 29 Oct 2024 10:47:32 -0400 Subject: [PATCH 1/9] Fixing an offset access error: TypeError: Cannot access offset of type string on string. An unforeseen error has occured. This is most likely a bug somewhere. It might be a problem in the task plugin. /home/aleneri/www/lib/plugins/task/helper.php:353 --- helper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helper.php b/helper.php index 9621f1f..7fecef1 100644 --- a/helper.php +++ b/helper.php @@ -350,8 +350,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']) From c6f9403f2596d9bd97e1f1920bce5c309724ec5a Mon Sep 17 00:00:00 2001 From: Louis Ouellet Date: Tue, 29 Oct 2024 10:47:50 -0400 Subject: [PATCH 2/9] Code Cleanup --- helper.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/helper.php b/helper.php index 7fecef1..ccf57d6 100644 --- a/helper.php +++ b/helper.php @@ -5,7 +5,7 @@ */ class helper_plugin_task extends DokuWiki_Plugin { - + function getMethods() { $result = array(); $result[] = array( @@ -50,7 +50,7 @@ function getMethods() { ); return $result; } - + /** * Returns the column header for the Pagelist Plugin */ @@ -124,12 +124,12 @@ 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; - } + } $result[$task['key']] = array( 'id' => $id, @@ -398,10 +398,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: @@ -429,7 +429,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. @@ -449,7 +449,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) { @@ -533,7 +533,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) { From 4765e935f5f85b0baeb1e52f714a240e0e6ed8fa Mon Sep 17 00:00:00 2001 From: Louis Ouellet Date: Tue, 29 Oct 2024 10:48:35 -0400 Subject: [PATCH 3/9] Fixing an issue with the filename during download, where the file's name would include the quotes. --- ics.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ics.php b/ics.php index 01033df..cdc9323 100644 --- a/ics.php +++ b/ics.php @@ -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'"); From 07966efe65a0fdcc6d8df88deb97b296257399e2 Mon Sep 17 00:00:00 2001 From: Louis Ouellet Date: Tue, 29 Oct 2024 11:13:07 -0400 Subject: [PATCH 4/9] Commented an undefined variable. To be revised --- helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper.php b/helper.php index ccf57d6..c5c3c6d 100644 --- a/helper.php +++ b/helper.php @@ -137,7 +137,7 @@ function getTasks($ns, $num = NULL, $filter = '', $user = NULL) { 'user' => $task['user']['name'], 'status' => $this->statusLabel($task['status']), 'priority' => $task['priority'], - 'perm' => $perm, + // 'perm' => $perm, 'file' => $task['file'], 'exists' => true, ); From 352b0ed07bd83fc2857ba949d42abf474eafae51 Mon Sep 17 00:00:00 2001 From: Louis Ouellet Date: Tue, 29 Oct 2024 11:14:39 -0400 Subject: [PATCH 5/9] Code Cleanup --- syntax/task.php | 40 ++++++++++++++++++++-------------------- syntax/tasks.php | 16 ++++++++-------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/syntax/task.php b/syntax/task.php index 5d2f92e..f02f9e1 100644 --- a/syntax/task.php +++ b/syntax/task.php @@ -5,7 +5,7 @@ * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Esther Brunner */ - + class syntax_plugin_task_task extends DokuWiki_Syntax_Plugin { var $my = NULL; @@ -14,17 +14,17 @@ 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, '!'), '!'); @@ -33,15 +33,15 @@ function handle($match, $state, $pos, Doku_Handler $handler) { 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); @@ -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(); @@ -88,7 +88,7 @@ function render($mode, Doku_Renderer $renderer, $data) { } $class .= '"'; - + // generate output $renderer->doc .= '
'.DOKU_LF . ''.DOKU_LF @@ -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); @@ -117,7 +117,7 @@ function render($mode, Doku_Renderer $renderer, $data) { '
'.DOKU_LF; return true; - + // for metadata renderer } elseif ($mode == 'metadata') { return true; @@ -125,7 +125,7 @@ function render($mode, Doku_Renderer $renderer, $data) { return false; } - + /** * Outputs a table row */ @@ -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 */ @@ -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) { @@ -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) { @@ -298,4 +298,4 @@ function _hCalDate($date) { return '' . strftime($onlydate, $date) . ''; } } -// vim:ts=4:sw=4:et:enc=utf-8: +// vim:ts=4:sw=4:et:enc=utf-8: diff --git a/syntax/tasks.php b/syntax/tasks.php index 4332749..30507fe 100644 --- a/syntax/tasks.php +++ b/syntax/tasks.php @@ -1,7 +1,7 @@ */ @@ -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'); } @@ -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 @@ -150,7 +150,7 @@ function render($mode, Doku_Renderer $renderer, $data) { } return false; } - + /* ---------- (X)HTML Output Functions ---------- */ /** @@ -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) { @@ -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) { @@ -261,7 +261,7 @@ function _viewMenuOld($filter) { return $ret; } - + /** * Returns an array of available view filters for the task list */ @@ -274,7 +274,7 @@ function _viewFilters() { } return $filters; } - + /** * Returns pagination links if more than one page */ From 4ef33093187b7227b10ad96f1f05c46ddbf17e11 Mon Sep 17 00:00:00 2001 From: Louis Ouellet Date: Tue, 29 Oct 2024 11:15:11 -0400 Subject: [PATCH 6/9] Fixed Warnings for undefined keys and variables --- syntax/task.php | 4 ++-- syntax/tasks.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/syntax/task.php b/syntax/task.php index f02f9e1..da4d14c 100644 --- a/syntax/task.php +++ b/syntax/task.php @@ -29,8 +29,8 @@ function handle($match, $state, $pos, Doku_Handler $handler) { $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); diff --git a/syntax/tasks.php b/syntax/tasks.php index 30507fe..9270f67 100644 --- a/syntax/tasks.php +++ b/syntax/tasks.php @@ -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 = ''; @@ -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); @@ -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')) { @@ -205,7 +205,7 @@ function _viewMenuNew($filter) { $form->addHTML('', $pos++); From 176a4ce1db33104596d2402bb050577e9b428c4e Mon Sep 17 00:00:00 2001 From: Louis Ouellet Date: Tue, 29 Oct 2024 11:18:45 -0400 Subject: [PATCH 7/9] Fixed a typo --- syntax/task.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/task.php b/syntax/task.php index da4d14c..2a67bad 100644 --- a/syntax/task.php +++ b/syntax/task.php @@ -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; } /** From 3a23ea4f92e6304c86e084136cb59dbe667d42c9 Mon Sep 17 00:00:00 2001 From: Louis Ouellet Date: Tue, 29 Oct 2024 11:42:26 -0400 Subject: [PATCH 8/9] Added missing code of an option Show only my tasks that is enabled by default in the task form --- helper.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/helper.php b/helper.php index c5c3c6d..a9588a0 100644 --- a/helper.php +++ b/helper.php @@ -131,6 +131,9 @@ function getTasks($ns, $num = NULL, $filter = '', $user = NULL) { elseif (($date + 86400 > time()) && ($filter == 'overdue')) continue; } + // Filter task if user is specified + if($user && $user != $task['user']['id']) continue; + $result[$task['key']] = array( 'id' => $id, 'date' => $date, From 4badbb365946fd935456d1a59c77920ef7b909ed Mon Sep 17 00:00:00 2001 From: Louis Ouellet Date: Tue, 29 Oct 2024 11:46:53 -0400 Subject: [PATCH 9/9] Added missing code of an option Show only my tasks that is enabled by default in the task form --- helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper.php b/helper.php index a9588a0..6e20455 100644 --- a/helper.php +++ b/helper.php @@ -132,7 +132,7 @@ function getTasks($ns, $num = NULL, $filter = '', $user = NULL) { } // Filter task if user is specified - if($user && $user != $task['user']['id']) continue; + if($user && (!isset($task['user']['id']) || $user !== $task['user']['id'])) continue; $result[$task['key']] = array( 'id' => $id,