1 | <?php
|
---|
2 | /*
|
---|
3 | $Id: rss_tasks.php 1924 2008-02-08 07:30:23Z andrewsimpson $
|
---|
4 |
|
---|
5 | (c) 2005 - 2009 Andrew Simpson <andrew.simpson at paradise.net.nz>
|
---|
6 |
|
---|
7 | WebCollab
|
---|
8 | ---------------------------------------
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under the
|
---|
11 | terms of the GNU General Public License as published by the Free Software Foundation;
|
---|
12 | either version 2 of the License, or (at your option) any later version.
|
---|
13 |
|
---|
14 | This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
---|
16 | PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
---|
17 |
|
---|
18 | You should have received a copy of the GNU General Public License along with this
|
---|
19 | program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
---|
20 | Cambridge, MA 02139, USA.
|
---|
21 |
|
---|
22 | Function:
|
---|
23 | ---------
|
---|
24 |
|
---|
25 | RSS feed generator
|
---|
26 |
|
---|
27 | */
|
---|
28 |
|
---|
29 | require_once('path.php' );
|
---|
30 | require_once(BASE.'path_config.php' );
|
---|
31 | require_once(BASE_CONFIG.'config.php' );
|
---|
32 | require_once(BASE.'rss/rss_common.php' );
|
---|
33 |
|
---|
34 | include_once(BASE.'includes/common.php');
|
---|
35 | include_once(BASE.'database/database.php');
|
---|
36 |
|
---|
37 | //secure variables
|
---|
38 | $content = '';
|
---|
39 |
|
---|
40 | //HTTP login
|
---|
41 | if(! rss_login() ) {
|
---|
42 |
|
---|
43 | rss_error('401', 'Project login' );
|
---|
44 | }
|
---|
45 |
|
---|
46 | //get time of last modified task
|
---|
47 | if(! ($q = db_query('SELECT '.$epoch.'MAX(edited) ) AS last FROM '.PRE.'tasks', 0 ) ) ) {
|
---|
48 |
|
---|
49 | rss_error('500', 'Project last edit' );
|
---|
50 | }
|
---|
51 |
|
---|
52 | if(! $last_mod = db_result($q, 0, 0 ) ) {
|
---|
53 | $last_mod = gmmktime();
|
---|
54 | }
|
---|
55 |
|
---|
56 | //check when last request was made
|
---|
57 | rss_last_mod($last_mod);
|
---|
58 |
|
---|
59 | //xml uses UTF-8 exclusively - tell the database to use UTF-8 too.
|
---|
60 | db_user_locale('UTF-8');
|
---|
61 |
|
---|
62 | //get site names
|
---|
63 | if(! ($q = db_query('SELECT * FROM site_name', 0 ) ) ) {
|
---|
64 |
|
---|
65 | rss_error('500', 'Project site name' );
|
---|
66 | }
|
---|
67 |
|
---|
68 | $row = @db_fetch_array($q, 0 );
|
---|
69 | define('MANAGER_NAME', $row['manager_name'] );
|
---|
70 | define('ABBR_MANAGER_NAME', $row['abbr_manager_name'] );
|
---|
71 |
|
---|
72 | //set the usergroup permissions on queries (Admin can see all)
|
---|
73 | if(ADMIN ) {
|
---|
74 | $tail = ' ';
|
---|
75 | }
|
---|
76 | else {
|
---|
77 | $tail = ' AND ('.PRE.'tasks.globalaccess=\'f\' AND '.PRE.'tasks.usergroupid IN (SELECT usergroupid FROM '.PRE.'usergroups_users WHERE userid='.UID.')
|
---|
78 | OR '.PRE.'tasks.globalaccess=\'t\'
|
---|
79 | OR '.PRE.'tasks.usergroupid=0) ';
|
---|
80 | }
|
---|
81 |
|
---|
82 | //main query
|
---|
83 | if(! ($q = db_query('SELECT '.PRE.'tasks.id AS id,
|
---|
84 | '.PRE.'tasks.name AS taskname,
|
---|
85 | '.PRE.'tasks.status AS status,
|
---|
86 | '.$epoch.' '.PRE.'tasks.edited) AS edited,
|
---|
87 | '.PRE.'tasks.text AS text,
|
---|
88 | '.PRE.'tasks.completed AS completed
|
---|
89 | FROM '.PRE.'tasks
|
---|
90 | WHERE '.PRE.'tasks.parent=0
|
---|
91 | '.$tail.'
|
---|
92 | ORDER BY '.PRE.'tasks.edited DESC', 0 ) ) ) {
|
---|
93 |
|
---|
94 | rss_error('500', 'Project query' );
|
---|
95 | }
|
---|
96 |
|
---|
97 | $filename = basename(__FILE__ );
|
---|
98 |
|
---|
99 | //start xml feed
|
---|
100 | $content = rss_start($last_mod, $filename );
|
---|
101 |
|
---|
102 | //set constants
|
---|
103 | $guid = md5(MANAGER_NAME . BASE_URL);
|
---|
104 |
|
---|
105 | for( $i=0 ; $row = @db_fetch_array($q, $i ) ; ++$i ) {
|
---|
106 |
|
---|
107 | if($row['completed'] == 100 ) {
|
---|
108 | $status = 'Complete';
|
---|
109 | }
|
---|
110 | else {
|
---|
111 | switch($row['status'] ) {
|
---|
112 |
|
---|
113 | case 'nolimit':
|
---|
114 | $status = 'No deadline';
|
---|
115 | break;
|
---|
116 |
|
---|
117 | case 'notactive':
|
---|
118 | $status = 'Planned';
|
---|
119 | break;
|
---|
120 |
|
---|
121 | case 'active':
|
---|
122 | $status = 'Active';
|
---|
123 | break;
|
---|
124 |
|
---|
125 | case 'cantcomplete':
|
---|
126 | $status = "<b>On Hold</b>";
|
---|
127 | break;
|
---|
128 |
|
---|
129 | case 'done':
|
---|
130 | $status = 'Done';
|
---|
131 | break;
|
---|
132 |
|
---|
133 | default:
|
---|
134 | $status = $row['status'];
|
---|
135 | break;
|
---|
136 | }
|
---|
137 | }
|
---|
138 |
|
---|
139 | $content .= "<item>\n".
|
---|
140 | "<title>".$row['taskname']." - ".$status."</title>\n".
|
---|
141 | "<link>".BASE_URL."index.php?taskid=".$row['id']."</link>\n".
|
---|
142 | "<description>".rss_bbcode($row['text'] )."</description>\n".
|
---|
143 | "<pubDate>".rss_time($row['edited'] )."</pubDate>\n".
|
---|
144 | "<guid isPermaLink=\"false\">".$row['id']."-".$guid."</guid>\n".
|
---|
145 | "</item>\n";
|
---|
146 | }
|
---|
147 |
|
---|
148 | //end xml
|
---|
149 | $content .= rss_end();
|
---|
150 |
|
---|
151 | echo $content;
|
---|
152 |
|
---|
153 | ?>
|
---|