logo       


mantisbt/core bugnote_api.php, 1.43, 1.44 database_api.php, 1.54, 1.55: msg#00042

Subject: mantisbt/core bugnote_api.php, 1.43, 1.44 database_api.php, 1.54, 1.55
Update of /cvsroot/mantisbt/mantisbt/core
In directory sc8-pr-cvs16:/tmp/cvs-serv32104/core

Modified Files:
        bugnote_api.php database_api.php 
Log Message:
1. Fixed a bug in db_prepare_date()
2. Added db_prepare_double()
3. Fixed several other time tracking related issues.
4. Fixed the from/to in the queries.
5. Changed the APIs to follow Mantis coding style and variable cleanup 
guidelines.
6. Default the time tracking edit box in the bug note form to 00:00.  This was 
done only when javascript is turned off.

Probably several other things.

Index: bugnote_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/bugnote_api.php,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- bugnote_api.php     18 Apr 2007 20:26:59 -0000      1.43
+++ bugnote_api.php     22 Apr 2007 07:45:33 -0000      1.44
@@ -446,28 +446,40 @@
 
        # --------------------
        # Returns an array of bugnote stats
-       function bugnote_stats_get_events_array( $p_bugnote_id, $p_from, $p_to 
) {
+       # $p_from - Starting date (yyyy-mm-dd) inclusive, if blank, then 
ignored.
+       # $p_to - Ending date (yyyy-mm-dd) inclusive, if blank, then ignored.
+       function bugnote_stats_get_events_array( $p_bug_id, $p_from, $p_to ) {
+               $c_bug_id = db_prepare_int( $p_bug_id );
+               $c_from = db_prepare_date( $p_from );
+               $c_to = db_prepare_date( $p_to );
+
                $t_user_table = config_get( 'mantis_user_table' );
                $t_bugnote_table = config_get( 'mantis_bugnote_table' );
-               $t_from = db_prepare_date( $p_from );
-               $t_to = db_prepare_date( $p_to );
 
-               if ( "" != $t_from ) {
-                       $c_from = " AND bn.date_submitted > '$t_from' ";
+               if ( !is_blank( $c_from ) ) {
+                       $t_from_where = " AND bn.date_submitted >= '$c_from 
00:00:00'";
+               } else {
+                       $t_from_where = '';
                }
-               if ( "" != $t_to ) {
-                       $c_to = " AND bn.date_submitted < '$t_to' ";
+
+               if ( !is_blank( $c_to ) ) {
+                       $t_to_where = " AND bn.date_submitted <= '$c_to 
23:59:59'";
+               } else {
+                       $t_to_where = '';
                }
+
                $t_results = array();
 
                $query = "SELECT username, SUM(time_tracking) sum_time_tracking
                                FROM $t_user_table u, $t_bugnote_table bn
                                WHERE u.id = bn.reporter_id AND
-                               bn.bug_id = '$p_bugnote_id'
-                               $c_from $c_to
+                               bn.bug_id = '$c_bug_id'
+                               $t_from_where $t_to_where
                        GROUP BY u.id";
-               $result = db_query($query);
-               while ($row = db_fetch_array($result)) {
+
+               $result = db_query( $query );
+
+               while ( $row = db_fetch_array( $result ) ) {
                        $t_results[] = $row;
                }
 
@@ -476,41 +488,54 @@
 
        # --------------------
        # Returns an array of bugnote stats
+       # $p_from - Starting date (yyyy-mm-dd) inclusive, if blank, then 
ignored.
+       # $p_to - Ending date (yyyy-mm-dd) inclusive, if blank, then ignored.
        function bugnote_stats_get_project_array( $p_project_id, $p_from, 
$p_to, $p_cost ) {
+               $c_project_id = db_prepare_int( $p_project_id );
+               $c_to = db_prepare_date( $p_to );
+               $c_from = db_prepare_date( $p_from );
+               $c_cost = db_prepare_double( $p_cost );
+
                // MySQL
                $t_bug_table = config_get( 'mantis_bug_table' );
                $t_user_table = config_get( 'mantis_user_table' );
                $t_bugnote_table = config_get( 'mantis_bugnote_table' );
 
-               if ( "" != $p_from ) {
-                       $t_ar = explode( "-", $p_from ); # Expecting yyyy-mm-dd
-                       $t_from = (int)$t_ar[0] ."-". (int)$t_ar[1] ."-". 
(int)$t_ar[2];
-                       $c_from = " AND bn.date_submitted > '$t_from' ";
+               if ( !is_blank( $c_from ) ) {
+                       $t_from_where = " AND bn.date_submitted >= '$c_from 
00:00:00'";
+               } else {
+                       $t_from_where = '';
                }
-               if ( "" != $p_to ) {
-                       $t_ar = explode( "-", $p_to ); # Expecting yyyy-mm-dd
-                       $t_to = (int)$t_ar[0] ."-". (int)$t_ar[1] ."-". 
(int)$t_ar[2];
-                       $c_to = " AND bn.date_submitted < '$t_to' ";
+
+               if ( !is_blank( $c_to ) ) {
+                       $t_to_where = " AND bn.date_submitted <= '$c_to 
23:59:59'";
+               } else {
+                       $t_to_where = '';
                }
-               if ( ALL_PROJECTS != $p_project_id ) {
-                       $c_project = " AND b.project_id = '$p_project_id' AND 
bn.bug_id = b.id ";
+
+               if ( ALL_PROJECTS != $c_project_id ) {
+                       $t_project_where = " AND b.project_id = '$c_project_id' 
AND bn.bug_id = b.id ";
+               } else {
+                       $t_project_where = '';
                }
+
                $t_results = array();
 
                $query = "SELECT username, summary, bn.bug_id, 
SUM(time_tracking) sum_time_tracking
                        FROM $t_user_table u, $t_bugnote_table bn, $t_bug_table 
b
                        WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 
AND bn.bug_id = b.id
-                       $c_project $c_from $c_to
+                       $t_project_where $t_from_where $t_to_where
                        GROUP BY bn.bug_id, u.id";
-               $result = db_query($query);
-               $t_cost_min = $p_cost / 60;
-               while ($row = db_fetch_array($result)) {
-                       $t_total_cost = $t_cost_min * $row[sum_time_tracking];
-                       $row['cost'] = number_format($t_total_cost, 2);
+               $result = db_query( $query );
+
+               $t_cost_min = $c_cost / 60;
+
+               while ( $row = db_fetch_array( $result ) ) {
+                       $t_total_cost = $t_cost_min * $row['sum_time_tracking'];
+                       $row['cost'] = $t_total_cost;
                        $t_results[] = $row;
                }
 
                return $t_results;
        }
-
 ?>

Index: database_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/database_api.php,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- database_api.php    13 Mar 2007 03:42:20 -0000      1.54
+++ database_api.php    22 Apr 2007 07:45:34 -0000      1.55
@@ -405,9 +405,10 @@
                }
 
                // Format
-               $t_formatted = $t_a[0] . "-";
-               $t_formatted .= ($t_a[1] < 10 ? "0" . $t_a[1] : $t_a[1]);
+               $t_formatted = $t_a[0] . '-';
+               $t_formatted .= ($t_a[1] < 10 ? "0" . $t_a[1] : $t_a[1]) . '-';
                $t_formatted .= ($t_a[2] < 10 ? "0" . $t_a[2] : $t_a[2]);
+
                return $t_formatted;
        }
 
@@ -416,6 +417,12 @@
        function db_prepare_int( $p_int ) {
                return (int)$p_int;
        }
+       
+       # --------------------
+       # prepare a double before DB insertion
+       function db_prepare_double( $p_double ) {
+               return (double)$p_double;
+       }       
 
        # --------------------
        # prepare a boolean before DB insertion


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe