コード例 #1
0
ファイル: approvepage.class.php プロジェクト: jamesmcq/elis
 /**
  * Mainline for performing the back-end request denail/approval process
  * @uses   $CFG
  * @uses   $DB
  */
 function display_approverequest()
 {
     // action_approverequest()
     global $CFG, $DB;
     // determine the action we are taking
     $approval_action = $this->required_param('approvalaction', PARAM_CLEAN);
     // make sure we have the necessary request
     $requestid = $this->required_param('request', PARAM_INT);
     if (!($request = $DB->get_record('block_courserequest', array('id' => $requestid)))) {
         $target = str_replace($CFG->wwwroot, '', $this->url);
         print_error('errorinvalidrequestid', 'block_courserequest', $target, $requestid);
     }
     // add additional information to the request that is needed by the form by default
     // and may not be part of the submitted info
     $this->add_approval_form_constants($request);
     // obtain the submitted form
     $target = $this->get_new_page(array('action' => 'approverequest'), true);
     $approveform = new pending_request_approve_form($target->url);
     $approveform->set_data($request);
     // cancel back to the base page if applicable
     if ($approveform->is_cancelled()) {
         redirect($this->url, '', 0);
     }
     // obtain the submitted data
     if ($formdata = $approveform->get_data(false)) {
         if ($approval_action == 'deny') {
             // deny the request
             $this->deny_request($request, $formdata);
         } else {
             // approve the request
             $this->approve_request($request, $formdata);
         }
         // redirect so reload won't resubmit form data
         $target = $this->get_new_page(array('action' => 'viewrequest', 'request' => $requestid), true);
         redirect($target->url);
     }
     $approveform->display();
 }