You are here

function kaltura_import in Kaltura 7.3

Page callback: Constructs a form for importing entries from Kaltura.

See also

kaltura_import_submit()

1 string reference to 'kaltura_import'
kaltura_menu in ./kaltura.module
Implements hook_menu().

File

includes/kaltura.admin.inc, line 641
Contains functions for administration use of the kaltura core module.

Code

function kaltura_import($form, &$form_state) {
  try {
    $helpers = new KalturaHelpers();
    $client = $helpers
      ->getKalturaClient(TRUE);
    if ($last_imported = variable_get('kaltura_last_imported')) {
      $filter = new KalturaMediaEntryFilter();
      $filter->updatedAtGreaterThanOrEqual = $last_imported + 1;
      $count = $client->media
        ->count($filter) + count($helpers
        ->filterOutUpToDateEntries($last_imported));
    }
    else {
      $count = $client->media
        ->count();
    }
    if ($count) {
      $form['count']['#markup'] = format_plural($count, 'There is <strong>1</strong> media entry to be imported.', 'There are <strong>@count</strong> media entries to be imported.');
      $form['actions'] = array(
        '#type' => 'actions',
      );
      $form['actions']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Import'),
      );
    }
    else {
      $form['count']['#markup'] = t('The are no media entries that need to be imported.');
    }
  } catch (Exception $e) {
    watchdog_exception('kaltura', $e);
    if (module_exists('dblog')) {
      $message = t('The website encountered an unexpected error. More info in <a href="!url">logs</a>.', array(
        '!url' => url('admin/reports/dblog'),
      ));
    }
    else {
      $message = t('The website encountered an unexpected error. More info in logs.');
    }
    drupal_set_message($message, 'error');
  }
  return $form;
}