/**
  * Performs the fetch of the current status
  *
  * @param $params
  *   Associative array of parameters
  *   - $params->wr: Work Request ID
  *   - $params->user: User ID making the request
  * @return
  *   A character corresponding to the current status on success
  *   FALSE is permission denied
  *   NULL if no work request
  */
 function run($params)
 {
     $request_id = $params['GET']['wr'];
     $access = access::getInstance();
     if ($access->permitted('wr/view', $request_id)) {
         $result = db_query('SELECT * FROM request_status WHERE request_id = %d ORDER BY status_on DESC LIMIT 1', $request_id);
         if (db_num_rows($result) > 0) {
             $response = new response('Success');
             $object = new WrmsStatus();
             $object->populate(db_fetch_object($result));
             $response->set('status', $object);
             return $response;
         }
         return new error('No status records found for that Work Request. Please ensure the WR exists.', 400);
     } else {
         return new error('Access denied', 403);
     }
 }
 /**
  * Performs the fetch list action
  *
  * @param $params
  *   Associative array of parameters
  *   - $params->wr: Work Request ID
  *   - $params->user: User ID making the request
  * @return 
  *   An array of status changes ordered from most recent to oldest
  *   An empty array if permission is denied
  */
 function run($params)
 {
     $return = array();
     $access = access::getInstance();
     $request_id = $params['GET']['wr'];
     if ($access->permitted('wr/view', $request_id)) {
         $result = db_query('SELECT * FROM request_status WHERE request_id = %d ORDER BY status_on DESC', $request_id);
         $response = new response('Success');
         if (db_num_rows($result) > 0) {
             while ($row = db_fetch_object($result)) {
                 $obj = new WrmsStatus();
                 $obj->populate($row);
                 $return[] = $obj;
             }
         }
         $response->set('history', $return);
         return $response;
     } else {
         return new error('Access denied', 403);
     }
 }