Esempio n. 1
0
 /**
  * Called by the edit and report segments. 
  * 
  * @param string $title For the header
  * @param string $section For the header
  * @param Bug $bug Bug to edit or a blank bug
  * @param string $url The url to save on
  * @param boolean $save If TRUE, then attempt a save.
  */
 function _edit($title, $section, $bug, $url, $save)
 {
     if ($save) {
         // attempt to save the bug
         $bug->trans_start();
         // Use the (already-loaded) array extension to process the POSTed values.
         $rel = $bug->from_array($_POST, array('title', 'description', 'priority', 'status', 'category', 'user'));
         // We also have to specify the editor...
         $rel['editor'] = $this->login_manager->get_user();
         if (!$bug->exists()) {
             // ...and creator for new bugs
             $rel['creator'] = $this->login_manager->get_user();
         }
         $exists = $bug->exists();
         if ($bug->save($rel)) {
             // saved successfully, so commit and redirect
             $bug->trans_complete();
             // Store a message
             if ($exists) {
                 $this->session->set_flashdata('message', 'This bug was updated successfully.');
             } else {
                 $this->session->set_flashdata('message', 'This bug was created successfully.');
             }
             redirect('bugs/view/' . $bug->id);
         }
     }
     // Load the htmlform extension, so we can generate the form.
     $bug->load_extension('htmlform');
     // We want to limit the users to those who are assignable (not simply bug reporters)
     $users = new User();
     $users->get_assignable();
     // This is how are form will be rendered
     $form_fields = array('id', 'title', 'description' => array('rows' => 6, 'cols' => 40), 'priority', 'status', 'category', 'user' => array('list' => $users));
     // Send the results to the views
     $this->output->enable_profiler(TRUE);
     $this->load->view('template_header', array('title' => $title, 'section' => $section));
     $this->load->view('bugs/edit', array('bug' => $bug, 'form_fields' => $form_fields, 'url' => $url));
     $this->load->view('template_footer');
 }