public function saved($username = NULL, $sid=NULL) {
  $current = $this->current($sid);
  if ($username) {
   $user = $this->get($username, 'username');
   if ($current['id'] != $user['id']) throw new \Exception('This users saved images are not publicly shared');
  } else {
   $user = $current;
  }
  $query = new \Peyote\Select('resources');
  $query->where('user_id', '=', $user['id'])
        ->where('type', '=', 'save');
  $results = $this->db->fetch($query);
  $image = new Image();
  $return = [];
  foreach ($results as $result) {
   try {
    $return[] = $image->get_slim($result['image']);
   }
   catch(\Exception $e) {
    if ($e->getCode() != 403) {
     throw new \Exception($e);
    }
   }
  }
  return $return;
 }
public function saved($username = NULL, $sid=NULL) {
  $current = $this->current($sid);
  if ($username) {
   $user = $this->get($username, 'username');
   if ($current['id'] != $user['id']) throw new \Exception('This users saved images are not publicly shared');
  } else {
   $user = $current;
  }
  $query = new \Peyote\Select('resources');
  $query->where('user_id', '=', $user['id'])
        ->where('type', '=', 'save');
  $results = $this->db->fetch($query);
  $image = new Image();
  $return = [];
  foreach ($results as $result) {
   try {
    $return[] = $image->get_slim($result['image']);
   }
   catch(\Exception $e) {
    if ($e->getCode() != 403) {
     throw new \Exception($e);
    }
   }
  }
  return $return;
 }
public function saved ( $ username = NULL , $ sid = NULL ) { $ current = $ this -> current ( $ sid ) ; if ( $ username ) { $ user = $ this -> get ( $ username , 'username' ) ; if ( $ current [ 'id' ] != $ user [ 'id' ] ) throw new \ Exception ( 'This users saved images are not publicly shared' ) ; } else { $ user = $ current ; } $ query = new \ Peyote \ Select ( 'resources' ) ; $ query -> where ( 'user_id' , '=' , $ user [ 'id' ] ) -> where ( 'type' , '=' , 'save' ) ; $ results = $ this -> db -> fetch ( $ query ) ; $ image = new Image ( ) ; $ return = [ ] ; foreach ( $ results as $ result ) { try { $ return [ ] = $ image -> get_slim ( $ result [ 'image' ] ) ; } catch ( \ Exception $ e ) { if ( $ e -> getCode ( ) != 403 ) { throw new \ Exception ( $ e ) ; } } } return $ return ; }
User's saved images

Load all saved images for a user account.

@api

@param string $username Provide the username of the user to view their saved images. Currently can only view your own saved images when logged in. If not set, the currently logged in user will be used.
@param string $sid Session ID that is provided when logged in. This is also set as a cookie. Only required if the cookie sid header is not sent.
User s saved images