[Fusionforge-commits] r10324 - in trunk/src/www: export pm
Roland Mas
lolando at libremir.placard.fr.eu.org
Wed Aug 18 16:48:43 CEST 2010
Author: lolando
Date: 2010-08-18 16:48:43 +0200 (Wed, 18 Aug 2010)
New Revision: 10324
Added:
trunk/src/www/export/rssAboTask.php
Modified:
trunk/src/www/pm/browse_task.php
trunk/src/www/pm/detail_task.php
trunk/src/www/pm/mod_task.php
Log:
Merged from Evolvis: RSS feeds for individual tasks
Added: trunk/src/www/export/rssAboTask.php
===================================================================
--- trunk/src/www/export/rssAboTask.php (rev 0)
+++ trunk/src/www/export/rssAboTask.php 2010-08-18 14:48:43 UTC (rev 10324)
@@ -0,0 +1,194 @@
+<?php
+/*-
+ * FusionForge RSS feed for Tasks abonnement
+ *
+ * Copyright © 2010
+ * Patrick Apel <p.apel at tarent.de>
+ * Thorsten Glaser <t.glaser at tarent.de>
+ * All rights reserved.
+ *
+ * This file is part of FusionForge. FusionForge 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 Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge 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 FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *-
+ * RSS feed used in connection with the Tasks Abonnement feature.
+ */
+
+require_once('../env.inc.php');
+require_once $gfwww.'include/pre.php';
+
+require_once $gfcommon.'include/Error.class.php';
+
+require_once $gfcommon.'pm/ProjectTask.class.php';
+require_once $gfcommon.'pm/ProjectGroup.class.php';
+require_once $gfcommon.'include/Group.class.php';
+require_once $gfcommon.'pm/ProjectTaskSqlQueries.php';
+
+global $gfwww, $gfcommon;
+
+$tid = getIntFromRequest('tid');
+if (!$tid)
+ $tid = util_path_info_last_numeric_component();
+if (!$tid) {
+ sysdebug_off("HTTP/1.0 404 Not Found");
+ echo "You forgot to pass the tid.\n";
+ exit;
+}
+
+$tinfo = getGroupProjectIdGroupId($tid);
+
+if (!$tinfo) {
+ sysdebug_off("HTTP/1.0 404 Not Found");
+ echo "There is no task with id ".$tid."!\n";
+ exit;
+}
+
+$group_id = $tinfo['group_id'];
+$group_project_id = $tinfo['group_project_id'];
+$project_task_id = $tinfo['project_task_id'];
+
+$objGroup =& group_get_object($group_id);
+if (!$objGroup || !is_object($objGroup)) {
+ exit_no_group();
+} elseif ($objGroup->isError()) {
+ exit_error('Error',$objGroup->getErrorMessage());
+}
+
+$objProjectGroup = &projectgroup_get_object($group_project_id);
+if(!$objProjectGroup || !is_object($objProjectGroup)) {
+ exit_error('Error',_('No project group was found for this task.'));
+}
+
+$objProjectTask = &projecttask_get_object($project_task_id);
+if(!$objProjectTask || !is_object($objProjectTask)) {
+ exit_error('Error',_('No project task was found.'));
+}
+
+$arrDbMessages = $objProjectTask->getMessages();
+$arrDbHistory = $objProjectTask->getHistory();
+
+$arrMessages = array();
+$arrHistory = array();
+
+while ($arr = db_fetch_array($arrDbMessages)) {
+//realname|email|user_name|project_message_id|project_task_id|body|posted_by|postdate
+ $arr_ = array($arr[0], $arr[1], $arr[2], $arr[3], $arr[4], $arr[5], 'message', $arr[6], $arr[7]);
+ array_push($arrMessages, $arr_);
+}
+
+while ($arr = db_fetch_array($arrDbHistory)) {
+//realname|email|user_name|project_history_id|project_task_id|field_name|>>old_value<<|mod_by|mod_date
+ $arr_ = array($arr[0], $arr[1], $arr[2], $arr[3], $arr[4], $arr[5], $arr[6], $arr[7], $arr[8]);
+ array_push($arrHistory, $arr_);
+}
+
+$arrHistoryMessages = array_merge($arrMessages, $arrHistory);
+
+/* Bubblesort should be good enough as solution */
+$j = count($arrHistoryMessages);
+$l = $j;
+
+for($i=0; $i<$j; $i++){
+ for($k=0; $k<$l; $k++){
+ if($arrHistoryMessages[$i][8]<$arrHistoryMessages[$k][8]){
+ $tmp=$arrHistoryMessages[$k];
+ $arrHistoryMessages[$k]=$arrHistoryMessages[$i];
+ $arrHistoryMessages[$i]=$tmp;
+ }
+ }
+}
+
+$updates = array_reverse($arrHistoryMessages);
+
+writeRssFeedBegin($objProjectTask, $objGroup, $objProjectGroup);
+writeRssFeedItem($objProjectTask, $updates);
+writeRssFeedEnd();
+
+/* the rss feed may not be out of format! Otherwise the rss feed would not be shown correctly
+ * & has to be & because of utf-8 encondig
+ **/
+function writeRssFeedBegin($objProjectTask, $objGroup, $objProjectGroup) {
+ //UTF-8 encoded. A special sign like & for example needed to be written like &
+ /* It is possible to format a rss feed with cascading style sheet and xsl, but it does not work with
+ * Firefox version 3.6.6, so I did not make use of it. */
+
+ sysdebug_off('Content-Type: application/rss+xml; charset=utf-8');
+
+ print'<?xml version="1.0" encoding="utf-8"?>';
+ print'<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">';
+ print'<rss version="2.0">';
+ print'<channel>';
+ print '<link>' . util_make_url("/pm/t_follow.php/" . $objProjectTask->getID()) . '</link>';
+ print'<title>';
+ print $objGroup->getPublicName().' '.' - ';
+ print $objProjectTask->getSummary();
+ print'</title>';
+ print'<description>';
+
+ printf(_('Update history of the task with the name %1$s and the ID %2$d.') . ' ', $objProjectTask->getSummary(), $objProjectTask->getID());
+ print _('Current values of the task’s…').' => ';
+
+ print ' '._('Subproject:').' '.$objProjectGroup->getName().' |';
+ print ' '._('Summary:').' '.$objProjectTask->getSummary().' |';
+ print ' '._('Complete:').' '.$objProjectTask->getPercentComplete().'% |';
+ print ' '._('Status:').' '.$objProjectTask->getStatusName().' |';
+ print ' '._('Details:').' '.$objProjectTask->getDetails().' |';
+
+ print'</description>';
+ //print'<language>en-us</language>';
+ print'<copyright>'.'Copyright 2000-'.date('Y').' '.forge_get_config('forge_name').'</copyright>';
+ print'<webMaster>'.forge_get_config('admin_email').'</webMaster>';
+ print'<lastBuildDate>'.gmdate('D, d M Y G:i:s',time()). ' GMT'.'</lastBuildDate>';
+ print'<docs>http://blogs.law.harvard.edu/tech/rss</docs>';
+
+}
+
+/* Chronological order of updates as rss feed items */
+function writeRssFeedItem($objProjectTask, $updates) {
+
+ foreach($updates as $update){
+ $update[6]==='message' ? $title = _('Comment') : $title = $update[5];
+ $update[6]==='message' ? $description = $update[5] : $description = $update[6];
+ $objGfUser = &user_get_object($update[7]);
+ print'<item>';
+ print'<title>';
+ print $title;
+ print'</title>';
+ print'<description>';
+ print _('Updated value').': ';
+ print $description.' | ';
+ print _('Posted by').': ';
+ print $objGfUser->getUnixName().' | ';
+ print _('Update time').': ';
+ print gmdate('D, d M Y G:i:s',$update[8]);
+ print'</description>';
+ print '<link>' . util_make_url("/pm/t_follow.php/" . $objProjectTask->getID()) . '</link>';
+ print'<author>';
+ print $objGfUser->getEmail();
+ print'</author>';
+ print '<guid isPermaLink="true">' . util_make_url("/export/rssAboTask.php?tid=" . $objProjectTask->getID()) . '</guid>';
+ print'<pubDate>';
+ print gmdate('D, d M Y G:i:s',$update[8]);
+ print'</pubDate>';
+ print'</item>';
+
+ }
+}
+
+function writeRssFeedEnd() {
+ print'</channel>';
+ print'</rss>';
+}
+
+?>
Modified: trunk/src/www/pm/browse_task.php
===================================================================
--- trunk/src/www/pm/browse_task.php 2010-08-18 14:48:35 UTC (rev 10323)
+++ trunk/src/www/pm/browse_task.php 2010-08-18 14:48:43 UTC (rev 10324)
@@ -170,6 +170,7 @@
'priority'=>0);
$title_arr=array();
+ $title_arr[] = "";
$title_arr[]=_('Task Id');
if ($display_col['summary'])
$title_arr[]=_('Task Summary');
@@ -194,7 +195,11 @@
$url = getStringFromServer('PHP_SELF')."?func=detailtask&project_task_id=".$pt_arr[$i]->getID()."&group_id=".$group_id."&group_project_id=".$group_project_id;
echo '
- <tr class="priority'.$pt_arr[$i]->getPriority().'">'.
+ <tr class="priority'.$pt_arr[$i]->getPriority().'"><td style="width:16px; background-color:#FFFFFF">' .
+ util_make_link("/export/rssAboTask.php?tid=" .
+ $pt_arr[$i]->getID(), html_image('ic/rss.png',
+ 16, 16, array('border' => '0'))
+ ) . "</td>\n" .
'<td>'.
($IS_ADMIN?'<input type="checkbox" name="project_task_id_list[]" value="'.
$pt_arr[$i]->getID() .'" /> ':'').
Modified: trunk/src/www/pm/detail_task.php
===================================================================
--- trunk/src/www/pm/detail_task.php 2010-08-18 14:48:35 UTC (rev 10323)
+++ trunk/src/www/pm/detail_task.php 2010-08-18 14:48:43 UTC (rev 10324)
@@ -54,6 +54,14 @@
<strong><?php echo _('Priority') ?>:</strong><br />
<?php echo $pt->getPriority(); ?>
</td>
+
+ <td>
+ <?php echo util_make_link("/export/rssAboTask.php?tid=" .
+ $project_task_id, html_image('ic/rss.png',
+ 16, 16, array('border' => '0')) . " " .
+ _('Subscribe to task'));
+ ?>
+ </td>
</tr>
<tr>
Modified: trunk/src/www/pm/mod_task.php
===================================================================
--- trunk/src/www/pm/mod_task.php 2010-08-18 14:48:35 UTC (rev 10323)
+++ trunk/src/www/pm/mod_task.php 2010-08-18 14:48:43 UTC (rev 10324)
@@ -83,6 +83,13 @@
<td colspan="2">
<a href="<?php echo getStringFromServer('PHP_SELF')."?func=deletetask&project_task_id=$project_task_id&group_id=$group_id&group_project_id=$group_project_id"; ?>"><?php echo _('Delete this task') ?></a>
</td>
+ <td>
+ <?php echo util_make_link("/export/rssAboTask.php?tid=" .
+ $project_task_id, html_image('ic/rss.png',
+ 16, 16, array('border' => '0')) . " " .
+ _('Subscribe to task'));
+ ?>
+ </td>
</tr>
<tr>
More information about the Fusionforge-commits
mailing list