You are here

function KalturaHelpers::getKalturaClient in Kaltura 5

Same name and namespace in other branches
  1. 6.2 kaltura_client/kaltura_helpers.php \KalturaHelpers::getKalturaClient()
  2. 6 kaltura_client/kaltura_helpers.php \KalturaHelpers::getKalturaClient()
  3. 7.3 kaltura_client/kaltura_helpers.php \KalturaHelpers::getKalturaClient()
  4. 7.2 kaltura_client/kaltura_helpers.php \KalturaHelpers::getKalturaClient()
12 calls to KalturaHelpers::getKalturaClient()
kaltura_contribution_wizard in includes/kaltura.themeing.inc
kaltura_create_widgets_for_partner in includes/kaltura.admin.inc
kaltura_fetch_widget_html in ./kaltura.module
kaltura_get_entries in ./kaltura.module
kaltura_get_my_entries in includes/kaltura.admin.inc

... See full list

File

kaltura_client/kaltura_helpers.php, line 179

Class

KalturaHelpers

Code

function getKalturaClient($isAdmin = false, $privileges = null) {

  // get the configuration to use the kaltura client
  $kalturaConfig = KalturaHelpers::getServiceConfiguration();
  if (!$privileges) {
    $privileges = 'edit:*';
  }

  // inititialize the kaltura client using the above configurations
  $kalturaClient = new KalturaClient($kalturaConfig);

  // get the current logged in user
  $sessionUser = KalturaHelpers::getSessionUser();
  if ($isAdmin) {
    $adminSecret = variable_get("kaltura_admin_secret", "");
    $result = $kalturaClient
      ->startSession($sessionUser, $adminSecret, true, $privileges);
  }
  else {
    $secret = variable_get("kaltura_secret", "");
    $result = $kalturaClient
      ->startSession($sessionUser, $secret, false, $privileges);
  }
  if (count(@$result["error"])) {
    watchdog("kaltura", $result["error"][0]["code"] . " - " . $result["error"][0]["desc"]);
    return null;
  }
  else {

    // now lets get the session key
    $session = $result["result"]["ks"];

    // set the session so we can use other service methods
    $kalturaClient
      ->setKs($session);
  }
  return $kalturaClient;
}