Author Topic: Add Date and Status to RSS Feed (Mod)  (Read 5819 times)

eddiewebb

  • Scorpionfish
  • ***
  • Posts: 67
    • Edward A. Webb (.com)
Add Date and Status to RSS Feed (Mod)
« on: July 11, 2009, 03:50:46 pm »
After using TF for my personal tasks I moved it into my workplace. I now keep track of any task over 30 minutes.

Each week my manager wants to know "where does XYZ stand?"  or "Have you started LMNOP?"

To make both our lives easier I just email him a link to the RSS feed with the key each morning.
http://mytaskfreaksite.org//rss.php?user=eddie&c=6a8dc54th67d8687od92ee4a1e5fad94dc

But he needs to know when it will be complete and where my progress stands.

Enter updated RSS!  Which enhances the look to something like...

Project: Task Name
Friday, July 17, 2009 8:00 PM

Description of Task..yada yada
Latest Update: The latest comment for this task - gives manager an idea of your progress.
------------------------------
Target: July 17, 2009
Not Started

I don't know if it is worth updating future versions of TF, but it has been a huge help to me.

Please see Enterprise TaskFreak Patch Post for this complete patch with others
http://forum.taskfreak.com/index.php?topic=1628



Code: [Select]
<item>
<title><![CDATA[<?php echo $pProject.$objItem->title?>]]></title>
<?php 
        
if ($objItem->deadlineDate != '9999-00-00' || $objItem->description) { 
?>

<description><![CDATA[<?php
/** Edited by Eddie Webb July 2009 - adds task status to feed, changed layout (text, date, status)
 - show yer manager! **/
            
if ($objItem->description) {
                echo 
"\n".$objItem->description.'<br /><hr width="100" align="left">';
            }
            if (
$objItem->deadlineDate != '9999-00-00') {
                echo 
'Target: '.$objItem->getDte('deadlineDate','USA').'<br /> ';
            } 
echo "<strong>";
if ($objItem->itemStatus->statusKey) {
echo "\n".$objItem->itemStatus->statusKey * (100/FRK_STATUS_LEVELS) . "% Complete ";
}else{
echo "Not Started ";
}
echo "</strong>";
?>
]]></description>
<?php
        
}
?>

<?php /** 
PubDate Added by Eddie Webb - July 2009 - 
Very hacked way to allow rss feed to be sorted by due date
assumes 5pm deadline of current location 
**/ 
?>

<pubDate>
<?php
if (
$objItem->deadlineDate != '9999-00-00') {
            echo 
date(DATE_RSSstrtotime($objItem->getDte('deadlineDate','USA'))+(3600*17) );
       }
?>

</pubDate>
<link><?php echo PRJ_WWW_URL?>?rssId=<?php echo $objItem->id?></link>
</item>
« Last Edit: September 03, 2009, 07:17:01 pm by eddiewebb »
Edward A. Webb | IT Analyst

eddiewebb

  • Scorpionfish
  • ***
  • Posts: 67
    • Edward A. Webb (.com)
Re: Add Date and Status to RSS Feed (Mod)
« Reply #1 on: July 29, 2009, 05:22:55 pm »
I have added the latest comment to mix, and now have something that looks a little nicer in IE.

Also I decided just to create a dedicated Status RSS and added the link to the header file in 

includes/html/header

FIND this line;
Code: [Select]
<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="<?php echo PRJ_WWW_URL?>rss.php?user=<?php echo $objUser->username?>&c=<?php echo $objUser->getRssCode(); ?>" />ADD this line just below;
Code: [Select]
<link rel="alternate" type="application/rss+xml" title="RSS Status Feed" href="<?php echo PRJ_WWW_URL?>status_rss.php?user=<?php echo $objUser->username?>&c=<?php echo $objUser->getRssCode(); ?>" />


That will add an RSS feed that points to status_rss.php, so here's that (in its entirety);
Code: [Select]
<?php
/****************************************************************************\
* TaskFreak!                                                                 *
* multi user                                                                 *
******************************************************************************
* Version: 0.6.1                                                             *
* Authors: Stan Ozier <taskfreak@gmail.com>                                  *
* License:  http://www.gnu.org/licenses/gpl.txt (GPL)                        *
******************************************************************************
* This file is part of "TaskFreak! single user" program.                     *
*                                                                            *
* TaskFreak! single user is free software; you can redistribute it and/or    *
* modify it under the terms of the GNU General Public License as published   *
* by the Free Software Foundation; either version 2 of the License, or (at   *
* your option) any later version.                                            *
*                                                                            *
* TaskFreak! single user is distributed in the hope that it will be          *
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of     *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
* GNU General Public License for more details.                               *
*                                                                            *
* You should have received a copy of the GNU General Public License          *
* along with this program; if not, write to the Free Software                *
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA *
\****************************************************************************/


include './_include.php';

include 
PRJ_CLASS_PATH.'tzn_generic.php';
include 
PRJ_CLASS_PATH.TZN_DB_CLASS;
include 
PRJ_CLASS_PATH.'tzn_user.php';

include 
PRJ_CLASS_PATH.'pkg_member.php';
include 
PRJ_CLASS_PATH.'pkg_project.php';

$objItemList = new ItemStats();


// --- check user ---------------------------------------------------------
$pUserIsLoggedIn false;

$objUser = new Member();

if (
$pUserName Tzn::getReg($_REQUEST['user'],"^[a-zA-Z0-9]+$")) {
if ($objUser->loadByKey('username',$pUserName)) {
$pUserIsLoggedIn $objUser->checkRssCode($_REQUEST['c']);
}
}
// --- Filter per date -----------------------------------------------------

// show today's tasks

$sqlFilter '((deadlineDate >= \''
    
.strftime(TZN_DATE_SQL,PRJ_DTE_NOW).'\' AND statusKey < '
    
.FRK_STATUS_LEVELS.')'.' OR statusKey < '.FRK_STATUS_LEVELS.')';
if (@
constant('FRK_NO_DEADLINE_TOO')) {
    
// show tasks with no deadline (unplanned tasks)
    
$sqlFilter .= ' AND deadlineDate <> \'9999-00-00\'';
} else {
    
$sqlFilter '('.$sqlFilter
     .
' OR (deadlineDate = \'9999-00-00\' AND statusKey < '
        
.FRK_STATUS_LEVELS.'))';
}

$objItemList->addDateFilter($sqlFilter);

// --- Filter per user's projects -----------------------------------------

$pOwnOnly = @constant('FRK_DEFAULT_RSS_OWN_ONLY');

if (!
$pOwnOnly) {
$objUserProjectList = new ProjectStats();
$objUserProjectList->addOrder('statusKey ASC, name ASC');
$objUserProjectList->addHaving('projectStatus_statusKey < 40');
$objUserProjectList->loadList($objUser->id,(!$objUser->checkLevel(6)));

// user can only access his own projects
if ($objUserProjectList->rMore()) {
        $arrProject = array();
        while($objTmp $objUserProjectList->rNext()) {
            $arrProject[] = $objTmp->id;
        }
        $objItemList->addWhere('(ii.projectId IN ('.implode(',',$arrProject).')'
.' OR ii.memberId = '.$objUser->id.' OR ii.authorId = '
.$objUser->id.')');
        unset($arrProject);
} else {
$pOwnOnly true;
}
}

if (
$pOwnOnly) {
// no project to look at? just list own tasks then!
$objItemList->addWhere('ii.memberId='.$objUser->id
.' OR ii.authorId='.$objUser->id);
}

// --- private tasks --------------------------------------------------------

$sqlFilter '(showPrivate';
if (
$objUser->checkLevel(12)) {
    
$sqlFilter .= ' < 2';
} else {
    
$sqlFilter .= ' = 0';
}
$sqlFilter .= ' OR (showPrivate = 2 AND (ii.authorId = '.$objUser->id
.
' OR ii.memberId = '.$objUser->id.')))';
$objItemList->addWhere($sqlFilter);


// --- Task order ---------------------------------------------------------

$pSort = ($_REQUEST['sort'])?$_REQUEST['sort']:
((defined('FRK_SORT_COLUMN'))?FRK_SORT_COLUMN:'deadlineDate');
$pDir = ($_REQUEST['dir'])?$_REQUEST['dir']:
((defined('FRK_SORT_ORDER'))?FRK_SORT_ORDER:1);
$objItemList->setOrder($pSort,$pDir);

// number of items to load

if ($pUserIsLoggedIn && defined('FRK_DEFAULT_RSS_SIZE')) {

    
$objItemList->addWhere('ii.memberId='.$objUser->id);
    
$objItemList->setPagination(FRK_DEFAULT_RSS_SIZE);
    
$objItemList->loadList();
    
}

header('Content-type: text/xml');
echo 
'<'.'?xml version="1.0"?'.'>';
echo 
"\n";
?>

<rss version="2.0">
<channel>
<title>TaskFreak! Todo list</title>
<link><?php echo PRJ_WWW_URL?></link>
<?php
if ($pUserIsLoggedIn && $objItemList->rMore()) {
    while (
$objItem $objItemList->rNext()) {
        
$pProject '';
//print_r($objItem);
        
if ($objItem->project->name) {
            
$pProject $objItem->project->get('name').': ';
        }
// -- Eddie wants comments ! 7/27/09 ------------------
$objCommentList = new ItemComment();

$sqlFilter 'itemId = '.$objItem->id;
$sqlOrder 'postDate DESC';

$objCommentList->addWhere($sqlFilter);
$objCommentList->addOrder($sqlOrder);

$objCommentList->loadList();
$latestComment=$objCommentList->rNext();
// -- end load of comment
?>

<item>
<title><![CDATA[<?php echo $pProject.$objItem->title?>]]></title>
<?php 
        
if ($objItem->deadlineDate != '9999-00-00' || $objItem->description) { 
?>

<description><![CDATA[<?php
/** Edited by Eddie Webb July 2009 - adds task status to feed, changed layout (text, date, status)
 - show yer manager! **/
           
 if ($objItem->description) {
                
echo "\n".$objItem->description."<br />";
            
}
echo '<hr width="100" align="left">';
// show latest comment
if($latestComment) {
echo "<strong>Latest Update:</strong> ".$latestComment->body;
}
echo '<div style="width:150px;background:lightblue;border:1px solid blue">';
//show target date
if ($objItem->deadlineDate != '9999-00-00') {
                echo 
'<strong>Target:</strong> '.$objItem->getDte('deadlineDate','USA').'<br /> ';
            

//show status
echo "<strong>";
if ($objItem->itemStatus->statusKey) {
echo "\n".$objItem->itemStatus->statusKey * (100/FRK_STATUS_LEVELS) . "% Complete ";
}else{
echo "Not Started ";
}
echo "</strong>";
echo "</div>";
            
?>
]]></description>
<?php
        
}
?>

<?php /** 
PubDate Added by Eddie Webb - July 2009 - 
Very hacked way to allow rss feed to be sorted by due date
assumes 5pm deadline of current location 
**/ 
?>

<pubDate>
<?php
if (
$objItem->deadlineDate != '9999-00-00') {
            echo 
date(DATE_RSSstrtotime($objItem->getDte('deadlineDate','USA'))+(3600*17) );
       }
?>

</pubDate>
<link><?php echo PRJ_WWW_URL?>?rssId=<?php echo $objItem->id?></link>
</item>
<?php
    
}

} else {
    include 
PRJ_INCLUDE_PATH.'language/'.FRK_DEFAULT_LANGUAGE.'/freak.php'
?>

<item>
    <title><?php
        
if ($pUserIsLoggedIn) {
            echo 
$langRss['no_task'];
        } else {
            echo 
$langRss['error_login'];
        }
    
?>
</title>
    <link><?php echo PRJ_WWW_URL?></link>
</item>

<?php
}
?>

</channel>
</rss>
Edward A. Webb | IT Analyst

biny

  • Scorpionfish
  • ***
  • Posts: 59
Re: Add Date and Status to RSS Feed (Mod)
« Reply #2 on: July 29, 2009, 05:44:34 pm »
Very very nice!  Much better than the default RSS feed.

Thanks!!

eddiewebb

  • Scorpionfish
  • ***
  • Posts: 67
    • Edward A. Webb (.com)
Re: Add Date and Status to RSS Feed (Mod)
« Reply #3 on: August 05, 2009, 07:31:28 pm »
*Update

--
Now Status RSS will *not* show any tasks marked 'private.'  Essential if you want to add a task like "find a new job"

This also introduced the need to create a unique hash key for the status rss (so a tricky manager doesn't just remove the "status" from URL to view private tasks.


---
Update includes/classes/tzn_member.php
find;
Code: [Select]
function getRssCode() {
return md5($this->firstName.$this->lastName.$this->password);
}

function checkRssCode($code) {
return ($code == $this->getRssCode());
}
Replace With;
Code: [Select]
function getRssCode() {
return md5($this->firstName.$this->lastName.$this->password);
}

// a unique code that alloows manager to view non-private tasks
function getStatusRssCode() {
return md5("manager".$this->firstName.$this->lastName.$this->password."foobar");
}

function checkRssCode($code) {
return ($code == $this->getRssCode());
}

//// a unique code that alloows maanger to view non-prioavte tasks
function checkStatusRssCode($code) {
return ($code == $this->getStatusRssCode());
}


----
Update includes/html/header.php

Find
Code: [Select]
<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="<?php echo PRJ_WWW_URL?>rss.php?user=<?php echo $objUser->username?>&c=<?php echo $objUser->getRssCode(); ?>" />

Add Just Below
Code: [Select]
<link rel="alternate" type="application/rss+xml" title="RSS Status Feed" href="<?php echo PRJ_WWW_URL?>status_rss.php?user=<?php echo $objUser->username?>&c=<?php echo $objUser->getStatusRssCode(); ?>" />

And of course the full Status Rss file

Create /status_rss.php
Code: [Select]
<?php
/****************************************************************************\
* TaskFreak!                                                                 *
* multi user                                                                 *
******************************************************************************
* Version: 0.6.1                                                             *
* Authors: Stan Ozier <taskfreak@gmail.com>                                  *
* License:  http://www.gnu.org/licenses/gpl.txt (GPL)                        *
******************************************************************************
* This file is part of "TaskFreak! single user" program.                     *
*                                                                            *
* TaskFreak! single user is free software; you can redistribute it and/or    *
* modify it under the terms of the GNU General Public License as published   *
* by the Free Software Foundation; either version 2 of the License, or (at   *
* your option) any later version.                                            *
*                                                                            *
* TaskFreak! single user is distributed in the hope that it will be          *
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of     *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
* GNU General Public License for more details.                               *
*                                                                            *
* You should have received a copy of the GNU General Public License          *
* along with this program; if not, write to the Free Software                *
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA *
\****************************************************************************/


include './_include.php';

include 
PRJ_CLASS_PATH.'tzn_generic.php';
include 
PRJ_CLASS_PATH.TZN_DB_CLASS;
include 
PRJ_CLASS_PATH.'tzn_user.php';

include 
PRJ_CLASS_PATH.'pkg_member.php';
include 
PRJ_CLASS_PATH.'pkg_project.php';

$objItemList = new ItemStats();


// --- check user ---------------------------------------------------------
$pUserIsLoggedIn false;

$objUser = new Member();

if (
$pUserName Tzn::getReg($_REQUEST['user'],"^[a-zA-Z0-9]+$")) {
if ($objUser->loadByKey('username',$pUserName)) {
$pUserIsLoggedIn $objUser->checkStatusRssCode($_REQUEST['c']);
}
}
// --- Filter per date -----------------------------------------------------

// show today's tasks

$sqlFilter '((deadlineDate >= \''
    
.strftime(TZN_DATE_SQL,PRJ_DTE_NOW).'\' AND statusKey < '
    
.FRK_STATUS_LEVELS.')'.' OR statusKey < '.FRK_STATUS_LEVELS.')';
if (@
constant('FRK_NO_DEADLINE_TOO')) {
    
// show tasks with no deadline (unplanned tasks)
    
$sqlFilter .= ' AND deadlineDate <> \'9999-00-00\'';
} else {
    
$sqlFilter '('.$sqlFilter
     .
' OR (deadlineDate = \'9999-00-00\' AND statusKey < '
        
.FRK_STATUS_LEVELS.'))';
}

$objItemList->addDateFilter($sqlFilter);

// --- Filter per user's projects -----------------------------------------

$pOwnOnly = @constant('FRK_DEFAULT_RSS_OWN_ONLY');

if (!
$pOwnOnly) {
$objUserProjectList = new ProjectStats();
$objUserProjectList->addOrder('statusKey ASC, name ASC');
$objUserProjectList->addHaving('projectStatus_statusKey < 40');
$objUserProjectList->loadList($objUser->id,(!$objUser->checkLevel(6)));

// user can only access his own projects
if ($objUserProjectList->rMore()) {
        $arrProject = array();
        while($objTmp $objUserProjectList->rNext()) {
            $arrProject[] = $objTmp->id;
        }
        $objItemList->addWhere('(ii.projectId IN ('.implode(',',$arrProject).')'
.' OR ii.memberId = '.$objUser->id.' OR ii.authorId = '
.$objUser->id.')');
        unset($arrProject);
} else {
$pOwnOnly true;
}
}

if (
$pOwnOnly) {
// no project to look at? just list own tasks then!
$objItemList->addWhere('ii.memberId='.$objUser->id
.' OR ii.authorId='.$objUser->id);
}

// --- private tasks --------------------------------------------------------


$sqlFilter 'showPrivate < 2';
$objItemList->addWhere($sqlFilter);


// --- Task order ---------------------------------------------------------

$pSort = ($_REQUEST['sort'])?$_REQUEST['sort']:
((defined('FRK_SORT_COLUMN'))?FRK_SORT_COLUMN:'deadlineDate');
$pDir = ($_REQUEST['dir'])?$_REQUEST['dir']:
((defined('FRK_SORT_ORDER'))?FRK_SORT_ORDER:1);
$objItemList->setOrder($pSort,$pDir);

// number of items to load

if ($pUserIsLoggedIn && defined('FRK_DEFAULT_RSS_SIZE')) {

    
$objItemList->addWhere('ii.memberId='.$objUser->id);
    
$objItemList->setPagination(FRK_DEFAULT_RSS_SIZE);
    
$objItemList->loadList();
    
}

header('Content-type: text/xml');
echo 
'<'.'?xml version="1.0"?'.'>';
echo 
"\n";
?>

<rss version="2.0">
<channel>
<title>TaskFreak! Todo list</title>
<link><?php echo PRJ_WWW_URL?></link>
<?php
if ($pUserIsLoggedIn && $objItemList->rMore()) {
    while (
$objItem $objItemList->rNext()) {
        
$pProject '';
//print_r($objItem);
        
if ($objItem->project->name) {
            
$pProject $objItem->project->get('name').': ';
        }
// -- Eddie wants comments ! 7/27/09 ------------------
$objCommentList = new ItemComment();

$sqlFilter 'itemId = '.$objItem->id;
$sqlOrder 'postDate DESC';

$objCommentList->addWhere($sqlFilter);
$objCommentList->addOrder($sqlOrder);

$objCommentList->loadList();
$latestComment=$objCommentList->rNext();
// -- end load of comment
?>

<item>
<title><![CDATA[<?php echo $pProject.$objItem->title?>]]></title>
<?php 
        
if ($objItem->deadlineDate != '9999-00-00' || $objItem->description) { 
?>

<description><![CDATA[<?php
/** Edited by Eddie Webb July 2009 - adds task status to feed, changed layout (text, date, status)
 - show yer manager! **/
           
 if ($objItem->description) {
                
echo "\n".$objItem->description."<br />";
            
}
echo '<hr width="100" align="left">';
// show latest comment
if($latestComment) {
echo "<strong>Latest Update:</strong> ".$latestComment->body;
}
echo '<div class="stats" xmlns="stats" style="padding-left:5px;width:150px;background:lightblue;border:1px solid blue">';
//show target date
if ($objItem->deadlineDate != '9999-00-00') {
                echo 
'<strong>Target:</strong> '.$objItem->getDte('deadlineDate','USA').'<br /> ';
            

//show status
echo "<strong>";
if ($objItem->itemStatus->statusKey) {
echo "\n".$objItem->itemStatus->statusKey * (100/FRK_STATUS_LEVELS) . "% Complete ";
}else{
echo "Not Started ";
}
echo "</strong>";
echo "</div>";
            
?>
]]></description>
<?php
        
}
?>

<?php /** 
PubDate Added by Eddie Webb - July 2009 - 
Very hacked way to allow rss feed to be sorted by due date
assumes 5pm deadline of current location 
**/ 
?>

<pubDate>
<?php
if (
$objItem->deadlineDate != '9999-00-00') {
            echo 
date(DATE_RSSstrtotime($objItem->getDte('deadlineDate','USA'))+(3600*17) );
       }
?>

</pubDate>
<link><?php echo PRJ_WWW_URL?>?rssId=<?php echo $objItem->id?></link>
</item>
<?php
    
}

} else {
    include 
PRJ_INCLUDE_PATH.'language/'.FRK_DEFAULT_LANGUAGE.'/freak.php'
?>

<item>
    <title><?php
        
if ($pUserIsLoggedIn) {
            echo 
$langRss['no_task'];
        } else {
            echo 
$langRss['error_login'];
        }
    
?>
</title>
    <link><?php echo PRJ_WWW_URL?></link>
</item>

<?php
}
?>

</channel>
</rss>
Edward A. Webb | IT Analyst