/**
  * Performs the fetch of attached notes
  *
  * @param $params
  *   Associative array of parameters
  *   - $params->wr: Work Request ID
  *   - $params->user: User ID making the request
  * @return
  *   An array of notes on success
  *   An empty array on failure
  */
 function run($params)
 {
     $request_id = $params['GET']['wr'];
     $access = access::getInstance();
     if ($access->permitted('wr/view', $request_id)) {
         $result = db_query('SELECT * FROM request_note WHERE request_id = %d ORDER BY note_on', $request_id);
         $response = new response('Success');
         $notes = array();
         while ($row = db_fetch_object($result)) {
             $note = new WrmsRequestNote();
             $note->populateNow($row);
             $notes[] = $note;
         }
         $response->set('notes', $notes);
         return $response;
     } else {
         return new error('Access denied', '403');
     }
 }
示例#2
0
 public function populateChildren()
 {
     $access = access::getInstance();
     if ($access->permitted('wr/timesheet/view', $this->id)) {
         $result = db_query("SELECT * FROM request_timesheet WHERE request_id='%d'", $this->id);
         while ($row = db_fetch_assoc($result)) {
             $newsheet = new WrmsTimeSheet();
             $newsheet->populate($row);
             $this->timesheets[] = $newsheet;
         }
     }
     # This possibly isn't the smallest implementation, but it will do for the moment.
     $result = db_query("SELECT * FROM request_note WHERE request_id='%d'", $this->id);
     while ($row = db_fetch_assoc($result)) {
         $newnote = new WrmsRequestNote();
         $newnote->populate($row);
         $this->notes[] = $newnote;
     }
 }