Switch the 'modify' code of admin/field.php to use templates
[bugdar.git] / newreport.php
index 5a2e7afa478b31a4faa4f9d46d580f0c3448bbbc..d4c9d3865c8ba5acf503175cd22891496395fc50 100755 (executable)
@@ -2,7 +2,7 @@
 /*=====================================================================*\
 || ###################################################################
 || # Bugdar
-|| # Copyright ©2002-2007 Blue Static
+|| # Copyright (c)2004-2009 Blue Static
 || #
 || # This program is free software; you can redistribute it and/or modify
 || # it under the terms of the GNU General Public License as published by
@@ -23,7 +23,6 @@ $fetchtemplates = array(
        'newreport',
 );
 
-define('SVN', '$Id$');
 
 $focus['newreport'] = 'focus';
 
@@ -33,7 +32,6 @@ require_once('./includes/class_notification.php');
 require_once('./includes/api_bug.php');
 require_once('./includes/api_comment.php');
 
-require_once('./includes/class_api_error.php');
 
 $product = explode(',', $input->in['product']);
 if (!can_perform('cansubmitbugs', $product[0]))
@@ -52,8 +50,8 @@ if (empty($_REQUEST['do']))
 
 if ($_POST['do'] == 'insert')
 {
-       $bug = new BugAPI($bugsys);
-       $comment = new CommentAPI($bugsys);
+       $bug = new BugAPI();
+       $comment = new CommentAPI();
        
        $notif = new NotificationCenter();
                
@@ -104,12 +102,10 @@ if ($_POST['do'] == 'insert')
                $comment->set('bugid',                  $bug->insertid);
                $comment->insert();
                
-               $notif->send_new_bug_notice($bug->values, $comment->values);
+               $notif->sendNewBugNotice($bug->values, $comment->values);
                
-               $bug = new BugAPI($bugsys); // need to destroy because update will think the insert fields need to be changed, too
-               $bug->dorelations = array();
+               $bug = new BugAPI(); // need to destroy because update will think the insert fields need to be changed, too
                $bug->set('bugid',                                      $comment->values['bugid']);
-               $bug->set_condition();
                $bug->fetch();
                $bug->set('dateline',                           $comment->values['dateline']);
                $bug->set('initialreport',                      $comment->insertid);
@@ -121,7 +117,7 @@ if ($_POST['do'] == 'insert')
                $bug->set('hiddenlastpostbyname',       bugdar::$userinfo['displayname']);
                $bug->update();
                
-               $notif->set_bug_data($bug->objdata);
+               $notif->setBugData($bug->record);
                
                $notif->finalize();
                
@@ -162,17 +158,20 @@ if ($_REQUEST['do'] == 'add')
        
        if (can_perform('canassign'))
        {
-               foreach (bugdar::$datastore['assignto'] AS $dev)
+               foreach (bugdar::$datastore['assignto'] as $dev)
                {
-                       $value = $dev['userid'];
-                       $label = construct_user_display($dev, false);
-                       $selected = ($input->in['assignedto'] ? ($input->in['assignedto'] == $dev['userid']) : ($dev['userid'] == bugdar::$options['defaultassign']));
-                       eval('$select[dev] .= "' . $template->fetch('selectoption') . '";');
+                       $tpl = new BSTemplate('selectoption');
+                       $tpl->vars = array(
+                               'value'         => $dev['userid'],
+                               'label'         => construct_user_display($dev, false),
+                               'selected'      => ($input->in['assignedto'] ? ($input->in['assignedto'] == $dev['userid']) : ($dev['userid'] == bugdar::$options['defaultassign']))
+                       );
+                       $select['dev'] = $tpl->evaluate()->getTemplate();
                }
        }
        
        // custom fields
-       $fields = construct_custom_fields($bugsys->in, true);           
+       $fields = construct_custom_fields($input->in, true);            
        $i = 0;
        foreach ($fields AS $field)
        {
@@ -190,17 +189,11 @@ if ($_REQUEST['do'] == 'add')
        $tpl = new BSTemplate('newreport');
        $tpl->vars = array(
                'reporter'              => construct_user_display(bugdar::$userinfo),
-               'productSelect' => ConstructProductSelect('cansubmitbugs', $input->in['product'], false),
+               'productSelect' => construct_product_select('cansubmitbugs', $input->in['product'], false),
                'select'                => $select,
                'customfields'  => $customfields
        );
        $tpl->evaluate()->flush();
 }
 
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
 ?>
\ No newline at end of file