00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: index.php 5381 2006-02-15 14:40:03Z yeupou $
00006 #
00007 # Copyright 2005-2006 (c) Mathieu Roy <yeupou--gnu.org>
00008 #
00009 # The Savane project is free software; you can redistribute it and/or
00010 # modify it under the terms of the GNU General Public License
00011 # as published by the Free Software Foundation; either version 2
00012 # of the License, or (at your option) any later version.
00013 #
00014 # The Savane project is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 # GNU General Public License for more details.
00018 #
00019 # You should have received a copy of the GNU General Public License
00020 # along with the Savane project; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00022
00023
00024 require '../include/pre.php';
00025 require_directory("trackers");
00026
00027 register_globals_off();
00028
00029 if (user_isloggedin())
00030 {
00031 site_user_header(array('context'=>'my'));
00032
00033 print '<p>'._("Here's a list of recent items (< 16 days) we think you should have a look at. These are items recently posted on trackers you manage that are still unassigned, items that have been recently assigned to you (by someone else) or news posted on a project you are member of.").'</p>';
00034
00035 # Get the list of projects the user is member of
00036
00037 $sql = "SELECT groups.group_name,"
00038 . "groups.group_id,"
00039 . "groups.unix_group_name,"
00040 . "groups.status "
00041 . "FROM groups,user_group "
00042 . "WHERE groups.group_id=user_group.group_id "
00043 . "AND user_group.user_id='".user_getid()."' "
00044 . "AND groups.status='A' "
00045 . "GROUP BY groups.unix_group_name "
00046 . "ORDER BY groups.unix_group_name";
00047
00048 $result = db_query($sql);
00049 $rows = db_numrows($result);
00050 $usergroups = array();
00051 $usergroups_groupid = array();
00052 if ($result && $rows > 0)
00053 {
00054 for ($j=0; $j<$rows; $j++)
00055 {
00056 unset($nogroups);
00057 $unixname = db_result($result,$j,'unix_group_name');
00058 $usergroups[$unixname] = db_result($result,$j,'group_name');
00059 $usergroups_groupid[$unixname] = db_result($result,$j,'group_id');
00060 }
00061 reset($usergroups);
00062 reset($usergroups_groupid);
00063 }
00064 else
00065 { $nogroups = 1; }
00066
00067
00068 # Get a timestamp to get new items (15 days)
00069 $new_date_limit = mktime(date("H"),
00070 date("i"),
00071 0,
00072 date("m"),
00073 date("d")-15,
00074 date("Y"));
00075
00076 ################ RIGHT PART ############################
00077
00078 print html_splitpage(1);
00079
00080 #### News to approve
00081 # Shown only if the user is news manager somewhere and if any item found
00082 reset($usergroups);
00083 reset($usergroups_groupid);
00084 unset($result);
00085 unset($rows);
00086 # Build an sql request that will fetch any relevant news
00087 $sql = "SELECT group_id,date,id,summary FROM news_bytes ".
00088 "WHERE date > '$new_date_limit' AND is_approved='5' AND (";
00089 $previous = 0;
00090 while (list($group, $groupname) = each ($usergroups))
00091 {
00092 if (member_check(0, $usergroups_groupid[$group],'N3'))
00093 {
00094 if ($previous) { $sql .= "OR "; }
00095 $sql .= "group_id='".$usergroups_groupid[$group]."' ";
00096 $previous = 1;
00097 }
00098 }
00099 $sql .= ") ORDER BY date DESC";
00100
00101 # If there is no relevant group (previous not set), it is not even necessary
00102 # to run the sql command
00103 if ($previous)
00104 {
00105 $result = db_query($sql);
00106 $rows = db_numrows($result);
00107 }
00108
00109 if ($result && $rows > 0)
00110 {
00111 print '<br /><div class="box"><div class="boxtitle">'._("News Waiting for Approval").'</div>';
00112 for ($j=0; $j<$rows; $j++)
00113 {
00114 print '<div class="'.utils_get_alt_row_color($j).'">';
00115 print '<a href="'.$GLOBALS[sys_home].'news/approve.php?approve=1&id='.db_result($result, $j, 'id').'&group='.group_getunixname(db_result($result, $j, 'group_id')).'">'.db_result($result, $j, 'summary').'</a><br />';
00116 # FIXME: num. of new comments?
00117 print '<span class="smaller">'.sprintf(_("Project %s, %s"), group_getname(db_result($result, $j, 'group_id')), format_date($sys_datefmt,db_result($result,$j,'date'))).'</span>';
00118 print '</div>';
00119 }
00120 print '</div>';
00121 }
00122
00123
00124 #### Latest Approved News
00125 print '<br /><div class="box"><div class="boxtitle">'._("News").'</div>';
00126 reset($usergroups);
00127 reset($usergroups_groupid);
00128 # Build an sql request that will fetch any relevant news
00129 $sql = "SELECT group_id,date,forum_id,summary FROM news_bytes ".
00130 "WHERE date > '$new_date_limit' AND (is_approved='0' OR is_approved='1') AND (group_id='".$GLOBALS[sys_group_id]."' ";
00131 while (list($group, $groupname) = each ($usergroups))
00132 {
00133 $sql .= "OR group_id='".$usergroups_groupid[$group]."' ";
00134 }
00135 $sql .= ") ORDER BY date DESC";
00136
00137 $result = db_query($sql);
00138 $rows = db_numrows($result);
00139 if ($result && $rows > 0)
00140 {
00141 for ($j=0; $j<$rows; $j++)
00142 {
00143 print '<div class="'.utils_get_alt_row_color($j).'">';
00144 print '<a href="'.$GLOBALS[sys_home].'forum/forum.php?forum_id='.db_result($result, $j, 'forum_id').'">'.db_result($result, $j, 'summary').'</a><br />';
00145 # FIXME: num. of new comments?
00146 print '<span class="smaller">'.sprintf(_("Project %s, %s"), group_getname(db_result($result, $j, 'group_id')), format_date($sys_datefmt,db_result($result,$j,'date'))).'</span>';
00147 print '</div>';
00148 }
00149 }
00150 else
00151 {
00152 print _("None found");
00153 }
00154 print '</div>';
00155
00156 ################ LEFT PART ############################
00157
00158
00159 print html_splitpage(2);
00160
00161 #### New items to assign
00162 # shown only if the user is tracker manager somewhere and if any item found
00163 # (so the title is included in the function called)
00164 reset($usergroups);
00165 reset($usergroups_groupid);
00166 my_incoming_unassigned_item_list($usergroups);
00167
00168 ### Items newly assigned (not necessarily new items)
00169 print '<br /><div class="box"><div class="boxtitle">'._("Newly Assigned Items").'</div>';
00170 reset($usergroups);
00171 reset($usergroups_groupid);
00172 my_incoming_assigned_item_list($usergroups);
00173 print '</div>';
00174
00175 print html_splitpage(3);
00176
00177 # End
00178
00179 print "\n\n".show_priority_colors_key();
00180
00181
00182 $HTML->footer(array());
00183
00184 }
00185 else
00186 {
00187
00188 exit_not_logged_in();
00189
00190 }
00191
00192 ?>