Main Page | Directories | File List | File Members

stats/index.php

Go to the documentation of this file.
00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: index.php 5429 2006-02-17 22:59:20Z toddy $
00006 #
00007 #  Copyright 2004-2004 (c) Mathieu Roy <yeupou--at--gnu.org>
00008 #                          Yves Perrin <yves.perrin--at--cern.ch>
00009 #
00010 # The Savane project is free software; you can redistribute it and/or
00011 # modify it under the terms of the GNU General Public License
00012 # as published by the Free Software Foundation; either version 2
00013 # of the License, or (at your option) any later version.
00014 #
00015 # The Savane project is distributed in the hope that it will be useful,
00016 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 # GNU General Public License for more details.
00019 #
00020 # You should have received a copy of the GNU General Public License
00021 # along with the Savane project; if not, write to the Free Software
00022 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00023 
00024 # Later, this page will provide per group and per group type statistics.
00025 
00026 require "../include/pre.php";
00027 
00028 site_header(array('title'=>"Statistics"));
00029 
00030 ######################## BETWEEN TWO DATES
00031 
00032 if (!$update)
00033 {
00034   $since_month = date("m")-1;
00035   $since_day = date("d");
00036   $since_year = date("Y");
00037 
00038   $until_month = date("m");
00039   $until_day = date("d");
00040   $until_year = date("Y");
00041 
00042   $hour = date("H");
00043   $min = date("i");
00044 }
00045 else
00046 {
00047   # If the user selected date, assume he speaks of completed days
00048   $hour = 0;
00049   $min = 0;
00050 }
00051 
00052 $since = mktime($hour,$min,0,$since_month, $since_day, $since_year);
00053 $until = mktime($hour,$min,0,$until_month, $until_day, $until_year);
00054 
00055 $form_opening = '<form action="'.$PHP_SELF.'#options" method="GET">';
00056 $form_submit = '<input class="bold" value="'._("Apply").'" name="update" type="submit" />';
00057 # I18N
00058 # The strings are two dates.
00059 # Example: "From 12. September 2005 till 14. September 2005"
00060 print html_show_displayoptions(sprintf(_("From %s till %s."),
00061                                        calendar_selectbox("day",$since_day,"since_day").calendar_selectbox("month",$since_month,"since_month").'<input type="text" value="'.addslashes($since_year).'" name="since_year" size="4" maxlength="4" />',
00062                                        
00063                                        calendar_selectbox("day",$until_day,"until_day").calendar_selectbox("month",$until_month,"until_month").'<input type="text" value="'.addslashes($until_year).'" name="until_year" size="4" maxlength="4" />'),
00064                                $form_opening,
00065                                $form_submit);
00066 
00067 print '
00068 <p><h3>'.html_anchor(sprintf(_("From %s till %s"),format_date($sys_datefmt,$since),format_date($sys_datefmt,$until)),"between").'</h3>';
00069 
00070 if ($since > $until)
00071 {
00072   print '<p class="error">'._("Apparently, the period you asked for is incoherent.").'</p>';
00073 }
00074 
00075 
00076 
00077 print '
00078 <h4>'._("Accounts:").'</h4>
00079 ';
00080 
00081 $count_users = stats_getusers();
00082 $count_groups = stats_getprojects();
00083 
00084 $content = array();
00085 $total = array();
00086 
00087 $count = stats_getusers("add_date>='$since' AND add_date<='$until'");
00088 $key = ngettext("New user", "New users", $count);
00089 $content[$key] = $count;
00090 $total[$key] = $count_users;
00091 print '&nbsp;&nbsp;- '.sprintf(ngettext("%s new user", "%s new users", $count),$count)."<br />\n";
00092 
00093 $count = stats_getprojects("","","register_time>='$since' AND register_time<='$until'");
00094 $key = ngettext("New group", "New groups", $count);
00095 $content[$key] = $count;
00096 $total[$key] = $count_groups;
00097 print '&nbsp;&nbsp;- '.sprintf(ngettext("%s new project", "%s new projects", $count),$count)."<br />\n";
00098 
00099 print '</p><p>'._("New users and new groups / total:");
00100 graphs_build($content,0,0,$total);
00101 unset($content,$total);
00102 
00103 
00104 $total_patch = stats_getitems("patch");
00105 $total_task = stats_getitems("task");
00106 $total_bugs = stats_getitems("bugs");
00107 $total_support = stats_getitems("support");
00108 
00109 
00110 print '</p>
00111 <p><h4>'._("Trackers:").'</h4>
00112 ';
00113 
00114 ### FIXME: ngettext force us to split several sentences in different bit.
00115 ### It may be severily unsuitable for proper translation.
00116 
00117 $content = array();
00118 $content_total = array();
00119 
00120 if ($total_support > 0)
00121 {
00122   $count = stats_getitems("support", 0, "date>='$since' AND date<='$until'");
00123   $total = $count;
00124   $total_open = 0;
00125   $count_open = stats_getitems("support", 3, "date>='$since' AND date<='$until'");
00126   $total_open += $count_open;
00127 
00128   print '&nbsp;&nbsp;- '
00129   # I18N
00130   # Please note that the next two msgids are in fact one sentence. They are
00131   # always displayed together. The reason for the split is to allow translators
00132   # to be able to use the correct plural form in both cases. The function
00133   # ngettext() does not allow to use more than one variable per call, so the
00134   # call had to be split.
00135   # The second msgid is re-used a few times in this code, for bugs, tasks
00136   # and so on. All those sentences are equivalent to the one about support
00137   # requests, please translate those half-sentences accordingly.
00138   .sprintf(ngettext("%s new support request,", "%s new support requests,", $count), $count)." "
00139   .sprintf(ngettext("including %s already closed", "including %s already closed", $count_open), $count_open)."<br />\n";
00140   $key = ngettext("Support request", "Support requests", $count);
00141   $content[$key] = $count;
00142   $content_total[$key] = $total_support;
00143 }
00144 
00145 if ($total_bugs > 0)
00146 {
00147   $count = stats_getitems("bugs", 0, "date>='$since' AND date<='$until'");
00148   $total += $count;
00149   $count_open = stats_getitems("bugs", 3, "date>='$since' AND date<='$until'");
00150   $total_open += $count_open;
00151 
00152   print '&nbsp;&nbsp;- '
00153   # I18N
00154   # This is to be used with "including %s already closed", see above
00155   .sprintf(ngettext("%s new bug,", "%s new bugs,", $count), $count)." "
00156   .sprintf(ngettext("including %s already closed", "including %s already closed", $count_open), $count_open)."<br />\n";
00157   $key = ngettext("Bug", "Bugs", $count);
00158   $content[$key] = $count;
00159   $content_total[$key] = $total_bugs;
00160 }
00161 
00162 if ($total_task > 0)
00163 {
00164   $count = stats_getitems("task", 0, "date>='$since' AND date<='$until'");
00165   $total += $count;
00166   $count_open = stats_getitems("task", 3, "date>='$since' AND date<='$until'");
00167   $total_open += $count_open;
00168 
00169   print '&nbsp;&nbsp;- '
00170   # I18N
00171   # This is to be used with "including %s already closed", see above
00172   .sprintf(ngettext("%s new task,", "%s new tasks,", $count), $count)." "
00173   .sprintf(ngettext("including %s already closed", "including %s already closed", $count_open), $count_open)."<br />\n";
00174   $key = ngettext("Task", "Tasks", $count);
00175   $content[$key] = $count;
00176   $content_total[$key] = $total_task;
00177 }
00178 
00179 if ($total_patch > 0)
00180 {
00181   $count = stats_getitems("patch", 0, "date>='$since' AND date<='$until'");
00182   $total += $count;
00183   $count_open = stats_getitems("patch", 3, "date>='$since' AND date<='$until'");
00184   $total_open += $count_open;
00185 
00186   print '&nbsp;&nbsp;- '
00187   # I18N
00188   # This is to be used with "including %s already closed", see above
00189   .sprintf(ngettext("%s new patch,", "%s new patches,", $count), $count)." "
00190   .sprintf(ngettext("including %s already closed", "including %s already closed", $count_open), $count_open)."<br />\n";
00191   $key = ngettext("Patch", "Patches", $count);
00192   $content[$key] = $count;
00193   $content_total[$key] = $total_patch;
00194 }
00195 
00196 if ($total_patch < 1 &&  $total_task  < 1 && $total_support < 1 && $total_bugs < 1)
00197 {
00198   print _("The trackers looks unused, no items were found");
00199 }
00200 else
00201 {
00202   print "<br />\n&nbsp;&nbsp;- "
00203   # I18N
00204   # This is to be used with "including %s already closed", see above
00205   .sprintf(ngettext("%s new item,", "%s new items,", $total), $total)." "
00206   .sprintf(ngettext("including %s already closed", "including %s already closed", $total_open), $total_open)."<br />\n";
00207 
00208   print '</p><p>'._("New items per tracker / tracker total:");
00209   graphs_build($content,0,0,$content_total);
00210   unset($content,$content_total);
00211 }
00212 
00213 print "</p>\n";
00214 
00215 print '<p>&nbsp;</p>';
00216 
00217 ##################### GENERAL
00218 print '
00219 <p><h3>'.html_anchor(_("Overall"),"overall").'</h3>';
00220 
00221 print '
00222 <h4>'._("Accounts:").'</h4>
00223 ';
00224 
00225 $content = array();
00226 
00227 #print _("Are listed only active accounts.");
00228 
00229 print '&nbsp;&nbsp;- '.sprintf(ngettext("%s user", "%s users", $count_users), $count_users)."<br />\n";
00230 $count_groups_private = stats_getprojects("","0");
00231 print '&nbsp;&nbsp;- '
00232 # I18N
00233 # This is to be used with "including %s in private state", see above
00234 .sprintf(ngettext("%s project,", "%s projects,", $count_groups), $count_groups)." "
00235 .sprintf(ngettext("including %s in private state", "including %s in private state", $count_groups_private), $count_groups_private)."<br />\n";
00236 
00237 $result = db_query("SELECT type_id,name FROM group_type ORDER BY type_id");
00238 while ($eachtype = db_fetch_array($result))
00239 {
00240   $content[$eachtype['name']] = stats_getprojects($eachtype['type_id']);
00241 }
00242 
00243 print '</p><p>'._("Projects per group type:");
00244 graphs_build($content,0,0);
00245 unset($content);
00246 
00247 
00248 
00249 print '</p>
00250 <p><h4>'._("Trackers:").'</h4>
00251 ';
00252 
00253 $content = array();
00254 
00255 $count = $total_support;
00256 $total = $count;
00257 $total_open = 0;
00258 if ($count > 0)
00259 {
00260   $count_open = stats_getitems("support", 1);
00261   $total_open += $count_open;
00262 
00263   print '&nbsp;&nbsp;- '
00264   # I18N
00265   # This is to be used with "including %s still open", see above
00266   .sprintf(ngettext("%s support request,", "%s support requests,", $count), $count)." "
00267   .sprintf(ngettext("including %s still open", "including %s still open", $count_open), $count_open)."<br />\n";
00268 
00269   $content[ngettext("Support request", "Support requests", $count)] = $count;
00270 }
00271 
00272 $count = $total_bugs;
00273 $total += $count;
00274 if ($count > 0)
00275 {
00276   $count_open = stats_getitems("bugs", 1);
00277   $total_open += $count_open;
00278 
00279   print '&nbsp;&nbsp;- '
00280   # I18N
00281   # This is to be used with "including %s still open", see above
00282   .sprintf(ngettext("%s bug,", "%s bugs,", $count), $count)." "
00283   .sprintf(ngettext("including %s still open", "including %s still open", $count_open), $count_open)."<br />\n";
00284 
00285   $content[ngettext("Bug", "Bugs", $count)] = $count;
00286 }
00287 
00288 $count = $total_task;
00289 $total += $count;
00290 if ($count > 0)
00291 {
00292   $count_open = stats_getitems("task", 1);
00293   $total_open += $count_open;
00294 
00295   print '&nbsp;&nbsp;- '
00296   # I18N
00297   # This is to be used with "including %s still open", see above
00298   .sprintf(ngettext("%s task,", "%s tasks,", $count), $count)." "
00299   .sprintf(ngettext("including %s still open", "including %s still open", $count_open), $count_open)."<br />\n";
00300 
00301   $content[ngettext("Task", "Tasks", $count)] = $count;
00302 }
00303 
00304 $count = $total_patch;
00305 $total += $count;
00306 if ($count > 0)
00307 {
00308   $count_open = stats_getitems("patch", 1);
00309   $total_open += $count_open;
00310 
00311   print '&nbsp;&nbsp;- '
00312   # I18N
00313   # This is to be used with "including %s still open", see above
00314   .sprintf(ngettext("%s patch,", "%s patches,", $count), $count)." "
00315   .sprintf(ngettext("including %s still open", "including %s still open", $count_open), $count_open)."<br />\n";
00316 
00317   $content[ngettext("Patch", "Patches", $count)] = $count;
00318 }
00319 print "<br />\n&nbsp;&nbsp;- "
00320 # I18N
00321 # This is to be used with "including %s still open", see above
00322 .sprintf(ngettext("%s item,", "%s items,", $total), $total)." "
00323 .sprintf(ngettext("including %s still open", "including %s still open", $total_open), $total_open)."<br />\n";
00324 
00325 
00326 print '</p><p>'._("Items per tracker:");
00327 graphs_build($content,0,0);
00328 unset($content);
00329 
00330 
00331 
00332 print '</p>
00333 <p><h4>'._("Themes:").'</h4>
00334 ';
00335 
00336 # Get the more popular themes. 7 at most, all superior to 0%
00337 $themes_list = theme_list(1);
00338 $popular_themes = array();
00339 while (list(,$theme) = each($themes_list))
00340 {
00341   # Get the number of users of the theme
00342   unset($count);
00343   $count = stats_getthemeusers($theme);
00344   if ($theme == $GLOBALS['sys_themedefault'])
00345     { 
00346       # If it is the default theme, add the users that use the default
00347       $count += stats_getthemeusers("");
00348     }
00349 
00350   # Compute the percentage of users using it
00351   $percent = ($count / $count_users) * 100;
00352   
00353   # Store it only if superior to 0
00354   if (round($percent))
00355     {
00356       $popular_themes[$theme] = $percent;
00357     }
00358 }
00359 
00360 # Print the most popular theme
00361 arsort($popular_themes);
00362 unset($themes);
00363 while (list($theme,$percent) = each($popular_themes))
00364 {
00365   if ($themes)
00366     { $themes .= ", "; }
00367   $themes .= sprintf(_("%s (%s%%)"), $theme, round($percent));
00368 }
00369 
00370 print sprintf(_("Most popular color themes are: %s."), $themes);
00371 
00372 print '
00373 </p>';
00374 
00375 site_footer(0);
00376 
00377 ?>

Generated on Sun Feb 26 13:23:04 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4