r11: Basic bug reporting (new bug only) is done :-).
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 21 Dec 2004 06:43:34 +0000 (06:43 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 21 Dec 2004 06:43:34 +0000 (06:43 +0000)
newreport.php

index 1114297d681caf902989045ff171b5d8c0386255..b4b10f501811a10435ecaa4897c4743833a9f330 100755 (executable)
@@ -33,7 +33,7 @@ if ($_POST['do'] == 'insert')
                'product' => INT,
                'component' => INT,
                'version' => INT,
-               'summary' => STR,
+               'summary' => STR_NOHTML,
                'severity' => INT,
                'priority' => INT,
                'status' => INT,
@@ -43,20 +43,37 @@ if ($_POST['do'] == 'insert')
        );
        
        // check permissions on various input values
-       if (!$bugsys->userinfo['permissions'] & CANCHANGESTATUS)
+       if (!($bugsys->userinfo['permissions'] & CANCHANGESTATUS))
        {
-               unset($vars['priority'], $vars['status'], $vars['resolution']);
+               $vars['priority'] = $bugsys->options['defaultpriority'];
+               $vars['status'] = $bugsys->options['defaultstatus'];
+               $vars['resolution'] = $bugsys->options['defaultresolve'];
        }
-       if (!$bugsys->userinfo['permissions'] & CANASSIGN)
+       else
+       {
+               if (!$bugsys->datastore['priority']["$vars[priority]"])
+               {
+                       $vars['priority'] = $bugsys->options['defaultpriority'];
+               }
+               if (!$bugsys->datastore['status']["$vars[status]"])
+               {
+                       $vars['status'] = $bugsys->options['defaultstatus'];
+               }
+               if (!$bugsys->datastore['resolution']["$vars[resolution]"])
+               {
+                       $vars['resolution'] = $bugsys->options['defaultresolve'];
+               }
+       }
+       if (!($bugsys->userinfo['permissions'] & CANASSIGN))
        {
-               unset($vars['assignedto']);
+               $vars['assignedto'] = $bugsys->options['defaultassign'];
        }
        else
        {
                // assigned person is not a dev or a valid user
                if (!$bugsys->datastore['assignto']["$vars[assignedto]"]['userid'])
                {
-                       unset($vars['assignedto']);
+                       $vars['assignedto'] = $bugsys->options['defaultassign'];
                }
        }
        
@@ -75,6 +92,78 @@ if ($_POST['do'] == 'insert')
                echo 'please enter a bug description';
                exit;
        }
+       $product = $bugsys->datastore['product']["$vars[product]"];
+       if (!$product)
+       {
+               echo 'please select a valid product';
+               exit;
+       }
+       $version = $bugsys->datastore['version']["$vars[version]"];
+       if (!$version)
+       {
+               echo 'please select a valid version';
+               exit;
+       }
+       // no component
+       if ($vars['component'] == -1)
+       {
+               // not global version and version.productid != product.productid
+               if ($version['productid'] != 0 AND $version['productid'] != $product['productid'])
+               {
+                       echo 'invalid version specified';
+                       exit;
+               }
+       }
+       // using a component
+       else
+       {
+               $component = $bugsys->datastore['product']["$vars[component]"];
+               // component has the right mother
+               if ($component['componentmother'] == $product['productid'])
+               {
+                       // version.productid != {component.productid | product.productid}
+                       if ($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid'])
+                       {
+                               echo 'invalid version specified';
+                               exit;
+                       }
+               }
+               else
+               {
+                       echo 'invalid component specified';
+                       exit;
+               }
+       }
+       
+       if (!$bugsys->options['allowhtml'])
+       {
+               $vars['comment'] = htmlspecialcharslike($vars['comment']);
+       }
+       
+       // create the bug report
+       $DB_sql->query("
+               INSERT INTO " . TABLE_PREFIX . "bug
+                       (userid, productid, componentid, versionid, summary, severity, priority, status, assignedto)
+               VALUES
+                       (" . $bugsys->userinfo['userid'] . ", $vars[product], $vars[component], $vars[version],
+                       '" . addslasheslike($vars['summary']) . "', $vars[severity], $vars[priority], $vars[status], $vars[assignedto]
+               )"
+       );
+       
+       $bugid = $DB_sql->insert_id();
+       
+       // insert the comment to the database
+       $DB_sql->query("
+               INSERT INTO " . TABLE_PREFIX . "comment
+                       (bugid, userid, dateline, comment ## comment_parsed -- not using, ATM ###
+                       )
+               VALUES
+                       ($bugid, " . $bugsys->userinfo['userid'] . ",
+                       " . time() . ", '" . addslasheslike($vars['comment']) . "'
+               )"
+       );
+       
+       echo 'bug is done!';
 }
 
 // ###################################################################
@@ -217,6 +306,10 @@ if ($_REQUEST['do'] == 'add')
                }
                
                echo '<div><strong>Detailed description:</strong><div><textarea name="comment" rows="15" cols="75"></textarea></div></div>';
+               
+               echo '<input type="hidden" name="product" value="' . $vars['product'] . '" />';
+               echo '<input type="hidden" name="component" value="' . $vars['component'] . '" />';
+               echo '<input type="hidden" name="version" value="' . $vars['version'] . '" />';
        }
        
        echo '<div><input type="hidden" name="do" value="' . $do . '" /><input type="submit" name="submit" value="  Proceed  " /></div>';