You are here

function mediafront_get_playlist in MediaFront 6.2

Same name and namespace in other branches
  1. 6 mediafront.module \mediafront_get_playlist()
  2. 7.2 mediafront.module \mediafront_get_playlist()
  3. 7 mediafront.module \mediafront_get_playlist()

Gets a playlist

1 call to mediafront_get_playlist()
mediafront_get_playlist_json in ./mediafront.module
Gets a playlist in JSON format.
1 string reference to 'mediafront_get_playlist'
mediafront_service in ./mediafront.module
Implementation of hook_service()

File

./mediafront.module, line 352

Code

function mediafront_get_playlist($playlist, $limit = 10, $page = 0, $args = array()) {

  // Get the views object.
  $view = views_get_view($playlist);
  if (is_null($view)) {
    return services_error($playlist . ' does not exist.');
  }

  // Check access
  if (!$view
    ->access('default')) {
    return services_error('You do not have access to ' . $playlist . '.');
  }

  // Setup our view for query.
  if (method_exists($view, 'set_use_pager')) {
    $view
      ->set_use_pager(FALSE);
  }
  $view
    ->set_items_per_page($limit);
  $view
    ->set_offset($page * $limit);
  $view
    ->set_arguments($args);
  $view->get_total_rows = TRUE;
  $view
    ->execute();

  // Return our playlist...
  return mediafront_get_playlist_from_view($view, $args);
}