Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/help: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/images: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/includes: CVS
diff -ur /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/includes/kaltura.admin.inc ./includes/kaltura.admin.inc
--- /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/includes/kaltura.admin.inc	2011-01-06 16:33:21.000000000 +1300
+++ ./includes/kaltura.admin.inc	2011-01-14 14:11:27.000000000 +1300
@@ -1,1270 +1,1499 @@
-<?php
-// $Id: kaltura.admin.inc,v 1.1.2.5.2.9 2011/01/06 03:33:21 xuriz Exp $
-
-/*
- * @file
- * contains functions for administration use of the kaltura core module
- *
- */
-
-/*
- * helper function that process the partner registration with kaltura
- *
- * if registration successful, the partner details are saved as system variables (drupal DB) and
- * the user is being redirected to the modules settings page where he should see the details inserted
- * and a configuration test which says that the configuraion works
- * TODO set up for new API
- * CMAC
- * changes:
- * removed references to categories
- * questions: this method created problems within getServiceConfiguration wrt the Logger
- */
-function kaltura_register_partner() {
-  global $base_url;
-  $partner = new KalturaPartner();
-  $partner->name =              $_REQUEST['partner_name'];
-  $partner->website =           $_REQUEST['partner_url1'];
-  $partner->notificationUrl =   $_REQUEST['partner_url2'] .'/?q=kaltura/notification_handler';
-  $partner->adminName =         $_REQUEST['partner_adminName'];
-  $partner->adminEmail =        $_REQUEST['partner_adminEmail'];
-  $partner->description =       $_REQUEST['partner_description'];
-  $partner->commercialUse =     "non-commercial_use";
-  $partner->type =              102;
-  $partner->appearInSearch =    '1';
-
-  // update relevant field with $_REQUEST['kaltura_adult_content']
-  $content_categories = new KalturaContentCategories;
-  $categories = "";
-  if (!empty($_REQUEST['kaltura_content_categories']))
-  {
-    foreach ($_REQUEST['kaltura_content_categories'] as $selected) {
-     $categories .= $content_categories->categories[$selected] .',';
-    }
-  }
-  else
-  {
-    $categories="N/A";
-  }
-  $partner->adultContent = ($_REQUEST['kaltura_adult_content'] == 1)? true: false;
-
-  $categories = rtrim($categories, ',');
-  if (empty($categories)) $categories="N/A";
-  $partner->contentCategories = $categories;
-  /** OLD API
-   $session_user = KalturaHelpers::getSessionUser();
-   $config = KalturaHelpers::getServiceConfiguration();
-   $kaltura_client = new KalturaClient($config);
-   */
-  $session_user = KalturaHelpers::getSessionUser();
-  $config = KalturaHelpers::getServiceConfiguration();
-  $kaltura_client = new KalturaClient($config);
-//  $kaltura_client->setConfig($config);
-
-  watchdog('regis', print_r($partner, TRUE));
-  $res = $kaltura_client->partner->register($partner, $_REQUEST['cms_password']);
-
-  $result = $res->id;
-  if ($result) {
-    variable_set('kaltura_partner_id',         $res->id);
-    variable_set('kaltura_subp_id',            $res->id."00");
-    variable_set('kaltura_secret',             $res->secret);
-    variable_set('kaltura_admin_secret',       $res->adminSecret);
-    variable_set('kaltura_local_registration', 1);
-    variable_set('kaltura_server_url',    KalturaHelpers::getKalturaServerUrl());
-    variable_set('kaltura_partner_cms_email', $partner->adminEmail);
-    variable_set('kaltura_partner_cms_password', $_REQUEST['cms_password']);
-    variable_set('kaltura_partner_url2', $_REQUEST['partner_url2']);
-    variable_set('kaltura_notification_type', 0);
-    variable_set('kaltura_content_categories', $categories);
-
-    kaltura_update_kaltura_partner(2, $partner->notificationUrl);
-    kaltura_create_widgets_for_partner($partner->id, $secret);
-    drupal_set_message('Congratulations!  You have successfully installed the All in One Video Module and registered for the Kaltura Partner Program.');
-    drupal_goto('admin/settings/kaltura/general');
-  }
-  else {
-//    $msg = 'The email address you entered already belongs to a registered Kaltura partner.<br />'.
-//      'Please register with another email or <a href="#" onclick="switch_to_exist_partner();return false;">click here</a> to import your existing partner details';
-    $msg = 'There was an error while trying to register new partner.<br />'. str_replace('_', ' ', $res['error'][0]['code']) .': '. $res['error'][0]['desc'];
-    drupal_set_message($msg, 'error');
-  }
-}
-
-/*
- * helper function that process the partner registration for kaltura CE
- *
- * if registration successful, the partner details are saved as system variables (drupal DB) and
- * the user is being redirected to the modules settings page where he should see the details inserted
- * and a configuration test which says that the configuraion works
- */
-
-function kaltura_import_ce()
-{
-  try
-  {
-    $url = $_REQUEST['ce_url'];
-    $email = $_REQUEST['ce_admin_email'];
-    $password = $_REQUEST['ce_cms_password'];
-    
-    $kConfig = new KalturaConfiguration(0);
-    $kConfig->serviceUrl = $url;
-    $kClient = new KalturaClient($kConfig);
-    $res = $kClient -> partner -> getSecrets(1, $email, $password);
-    
-    $partner = 1;
-    $secret = $kPartner -> secret;
-    $adminSecret = $kPartner -> adminSecret;  
-  
-    variable_set('kaltura_partner_id',         $res->id);
-    variable_set('kaltura_subp_id',            $res->id."00");
-    variable_set('kaltura_secret',             $res->secret);
-    variable_set('kaltura_admin_secret',       $res->adminSecret);
-    variable_set('kaltura_local_registration', 1);
-    variable_set('kaltura_server_url',    $url);
-    variable_set('kaltura_partner_cms_email', $res->adminEmail);
-    variable_set('kaltura_partner_cms_password', $password);
-    variable_set('kaltura_partner_url2', $_REQUEST['partner_url2']);
-    variable_set('kaltura_notification_type', 0);
-//    variable_set('kaltura_content_categories', implode(',', $_REQUEST['kaltura_content_categories']));
-
-    kaltura_update_kaltura_partner(2, $partner->notificationUrl);
-//    kaltura_create_widgets_for_partner($partner->id, $secret);
-    drupal_set_message('Congratulations!  You have successfully installed the All in One Video Module and registered for the Kaltura Partner Program.');
-    drupal_goto('admin/settings/kaltura/general');
-  }
-  catch(Exception $ex)
-  {
-    drupal_set_message(t('Kaltura client exception: @message', array('@message' => $ex->getMessage())), 'error'); 
-  }
-}
-
-/*
- * helper function to retrieve partner's details from kaltura
- * TODO: testing
- * CMAC changes:
- * kaltura client config set up to reflect changes in the API
- * getsecrets now called instead of getPartner
- * return array built using Kaltura Partner object
- *
- */
-function kaltura_get_partner_details($partner_id, $cms_email, $cms_password) {
-
-  $session_user = KalturaHelpers::getSessionUser();
-  $config = KalturaHelpers::getServiceConfiguration();
-  $config->partnerId = $partner_id;
-  $kaltura_client = new KalturaClient($config);
-//  $kaltura_client->setConfig();
-  /**
-   * here we are trying to retrieve the partner details from the kaltura server
-   *
-   */
-
-  //$result = $kaltura_client->getPartner($session_user, $cms_email, $cms_password, $partner_id);
-  $result = $kaltura_client->partner->getsecrets($partner_id, $cms_email, $cms_password);
-
-
-  // convert result to array
-
-  if ($result->id) {
-    return array(
-    $result->id,
-    $result->id."00",//subpartner id
-    $result->notificationUrl,
-    $result->secret,
-    $result->adminSecret
-    );
-  }
-  else {
-    return array(FALSE, $result['error']);
-  }
-}
-
-/*
- * helper function that uses Kaltura's getDefaultWidget service to create some default widgets for
- * the partner, in case he does not have these yet
- * TODO
- * CMAC
- * changes
- * changed client initialisation
- * changed the getDefaultWidget function call to $kaltura_client->widget->get
- * question: what do we do with the widget when we get them?
- */
-function kaltura_create_widgets_for_partner($partner_id, $secret) {
-  /*$session_user = KalturaHelpers::getSessionUser();
-   $config = KalturaHelpers::getServiceConfiguration();
-   $config->partnerId = $partner_id;
-   $kaltura_client = new KalturaClient();
-   $kaltura_client->setConfig($config);*/
-
-  $session_user = KalturaHelpers::getSessionUser();
-  $kaltura_client = KalturaHelpers::getKalturaClient(1);
-
-  $widgets = new KalturaSettings;
-
-  foreach ($widgets->kdp_widgets as $type => $uiconfs) {
-    foreach ($uiconfs as $skin => $confs) {
-    /* oferc: that doesn't work for me yet */
-//      $result = $kaltura_client->widget->get("_1_".$confs['view_uiconf']);
-//      $result = $kaltura_client->widget->get("_1_".$confs['remix_uiconf']);
-    }
-  }
-}
-
-/*
- * determine how the general settings form will look like.
- *
- * returns one of 2 states of forms:
- * 1) registration form (if variables do not exist in the DB) 
- *    - either as SaaS or Kaltura CE
- * 2) notifications settings + configuration test + settings form
- *
- */
-function kaltura_settings_form() {
-  global $base_url;
-
-  if (!module_exists('advanced_help')) {
-    $form['kaltura_help'] = array(
-      '#value' => t('For more detailed help enable the advanced help module.'),
-    );
-  }
-
-  if (variable_get('kaltura_partner_id', '') != '') {
-    $notification_settings = kaltura_notifications_settings_form();
-    $form['kaltura_notification_settings'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Kaltura to Drupal Notification Settings'),
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-    );
-    foreach ($notification_settings as $name => $form_element) {
-      $form['kaltura_notification_settings'][$name] = $form_element;
-    }
-    $form['kaltura_server_status'] = array(
-      '#type' => 'fieldset', 
-      '#title' => t('Server Status'), 
-      '#collapsible' => TRUE, 
-      '#collapsed' => FALSE
-    );
-    list($admin_session_status, $admin_session_error) = kaltura_check_server_status($admin = 1);
-    list($normal_session_status, $normal_session_error) = kaltura_check_server_status($admin = 0);
-    $status_class = ($admin_session_status && $normal_session_status)? 'ok': 'bad';
-    $session_status = ($admin_session_status && $normal_session_status)? 'OK': 'ERROR';
-
-    $error = ' kaltura_error: ';
-    if ($admin_session_error) {
-      $error .= '<br />admin session: '. $admin_session_error;
-      $error_status = TRUE;
-    }
-    if ($normal_session_error) {
-      $error .= '<br />normal session: '. $normal_session_error;
-      $error_status = TRUE;
-    }
-
-    $form['kaltura_server_status']['kaltura_Admin_test_server'] = array(
-      '#type' => 'item',
-      '#title' => t('Drupal to Kaltura Session Test'),
-      '#prefix' => '<div class="kaltura_status_'. $status_class .'">',
-      '#value' => 'Session status: '. $session_status . (($error_status)? $error: ''),
-      '#suffix' => '</div>'
-      );
-      if (kaltura_variable_get_real('kaltura_notification_type', 0) == 1) {
-        list($status, $text) = kaltura_test_notification_config();
-        $prefix = '<div class="kaltura_status_'. (($status)? 'ok': 'bad') .'">';
-        $form['kaltura_server_status']['kaltura_notification_status'] = array(
-        '#type' => 'item',
-        '#title' => t('Kaltura to Drupal Notification Status'),
-        '#prefix' => $prefix,
-        '#value' => $text,
-        '#suffix' => '</div>'
-        );
-      }
-      list($status, $text) = kaltura_test_cron_job_status();
-      $prefix = '<div class="kaltura_status_'. (($status)? 'ok': 'bad') .'">';
-      $form['kaltura_server_status']['kaltura_cron_job_status'] = array(
-      '#type' => 'item',
-      '#title' => t('Cron-Job Status'),
-      '#prefix' => $prefix,
-      '#value' => $text,
-      '#suffix' => '</div>'
-      );
-      list($status, $text) = kaltura_test_crossdomain();
-      $prefix = '<div class="kaltura_status_'. (($status)? 'ok': 'bad') .'">';
-      $form['kaltura_server_status']['kaltura_crossdomain_status'] = array(
-      '#type' => 'item',
-      '#title' => t('CrossDomain.xml Status'),
-      '#prefix' => $prefix,
-      '#value' => $text,
-      '#suffix' => '</div>'
-      );
-  }
-
-  $register_visible = FALSE;
-  if ($_REQUEST['partner_name'] && $_REQUEST['op'] == 'Complete Installation') {
-    if ($_REQUEST['kaltura_agree_terms'] == 1) {
-      // no test or error handling?
-      kaltura_register_partner();
-    }
-    else {
-      drupal_set_message('You must agree to the terms of use', 'error');
-    }
-  }
-
-  if ($_REQUEST['op'] == 'Complete Installation' && $_REQUEST['ce_url']) 
-  {
-    // TODO: If this fails, we need to display the server registration
-    // form again.
-    kaltura_import_ce();
-  }
-
-  /**
-   * if the user already has a partner id, the importing of partner details is done here
-   */
-
-  if ($_REQUEST['op'] == 'Complete Installation' && $_REQUEST['kaltura_partner_id']) {
-    list($pid, $subpid, $url2, $secret, $admin_secret) = kaltura_get_partner_details($_REQUEST['kaltura_partner_id'], $_REQUEST['cms_email'], $_REQUEST['cms_password']);
-    if ($pid) {
-      variable_set('kaltura_partner_id', $pid);
-      variable_set('kaltura_subp_id', $subpid);
-      variable_set('kaltura_secret', $secret);
-      variable_set('kaltura_admin_secret', $admin_secret);
-      variable_set('kaltura_partner_url2', str_replace('/?q=kaltura/notification_handler', '', $url2));
-      variable_set('kaltura_partner_cms_email', $_REQUEST['cms_email']);
-      variable_set('kaltura_partner_cms_password', $_REQUEST['cms_password']);
-      variable_set('kaltura_server_url',    KalturaHelpers::getKalturaServerUrl());
-      drupal_set_message('Your partner details were imported successfully. please check the '. l('notification settings', 'admin/settings/kaltura/general/notifications'));
-      drupal_set_message('You can '. l('import Kaltura Media from your existing partner', 'admin/settings/kaltura/import'));
-      kaltura_create_widgets_for_partner($pid, $secret);
-      kaltura_update_kaltura_partner(2, $url2);
-      drupal_goto('admin/settings/kaltura/general');
-    }
-    else {
-      drupal_set_message('Couldn\'t import partner details.<br />'. print_r($subpid, TRUE) . $subpid['code'] .': '. $subpid['desc'], 'error');
-    }
-  }
-  if (variable_get('kaltura_partner_id', '') == '') {
-    $register_visible = TRUE;
-      
-    if ( empty($_REQUEST['op']))
-    {
-      if ($_GET['register'] !== 'no') {
-        drupal_set_title('All in One Video Module by Kaltura Installation');
-        // registration form
-        $showing_reg = TRUE;
-      $saasText = '<b>Using Kaltura SaaS hosted solution</b><br/> Kaltura service is responsible for transcoding your content
-            to FLV, hosting it in a first grade CDN and streaming it to your viewers.<br/><br/>Kaltura Service has cost effective pricing and <b>10 GB of free trial</b>
-            <br/><a href="http://www.kaltura.com" target="_blank">To learn more about the Kaltura SaaS offering and pricing click here</a><br/><br/>';
-      $ceText ='<b>Using Kaltura Community Edition Beta</b><br/>Kaltua Comunity Edition will allow you to host, transcode and stream everything out of your own server for free.
-             <br/><br/><b>This requires download, installation and configuration of the Kaltura CE server.</b><br/><br/><br/>';
-      $form['kaltura_registration_mode'] = array(
-      '#type' => 'radios',
-      '#title' => t('Kaltura module has two modes of work'),
-      '#options' => array(1 => $saasText, 0 => $ceText),
-      '#default_value' => 1,
-        );
-      $form['kaltura_registration']['buttons']['import_partner'] = array(
-          '#type' => 'button',
-        '#title' => 'Continue >>',
-      '#value' => 'Continue >>',
-      '#default_value' => 'Continue >>',
-      '#weight' => 40,
-      );
-      }   
-        
-
-    }
-    else
-    {
-      if (!variable_get('kaltura_registration_first_load', FALSE)) {
-        variable_set('kaltura_registration_first_load', TRUE);
-      }
-      global $user;
-      if($_REQUEST['op'] == 'Continue >>' && $_REQUEST['kaltura_registration_mode'] == 0)
-      {
-        if ($_GET['register'] !== 'no') {
-          drupal_set_title('All in One Video Module by Kaltura Installation');
-          // registration form
-          $showing_reg = TRUE;
-        $information_text = 'For the Drupal module to work with your Kaltura CE installation you must fill in the following <br/>details regarding your kaltura CE server. ';
-        $notice_text = 'You must have a Kaltura Community Edition server(Kaltura CE) installed in order to continue.<br/><br/>1. Download Kaltura CE from <a href="http://www.kaltura.org/project/community_edition_video_platform" target="blank">Kaltura.org</a><br/><br/>2. Install Kaltura CE on your server based on the <a href="http://www.kaltura.org/kalturace-kaltura-community-edition-getting-started-guide" target="_blank">installation guide</a>';
-        $form['kaltura_settings_information'] = array(
-        '#prefix' => '<div class="kaltura_ce_notice">'.$notice_text.'</div>',
-        '#value' => t($information_text)
-        );
-          
-          $form['ce_url'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Kaltura CE URL'),
-        '#default_value' => '',
-        '#size' => 100,
-        '#maxlength' => 512
-          );
-
-          $form['ce_admin_email'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Kaltura CE Admin Email'),
-        '#default_value' => $user->mail,
-        '#size' => 100,
-        '#maxlength' => 100
-          );
-
-          $form['ce_cms_password'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Kaltura CE Password'),
-        '#default_value' => '',
-        '#size' => 100,
-        '#maxlength' => 100
-          );
-          $form['partner_url2'] = array(
-          '#type' => 'hidden',
-          '#title' => t('URL 2'),
-          '#default_value' => $base_url,
-          '#maxlength' => 1024
-          );
-          
-          $form_state['storage']['submit'] = 'CE Register';
-          $form['buttons']['register'] = array(
-        '#type' => 'button',
-        '#title' => 'Complete Installation',
-        '#value' => 'Complete Installation',
-        '#default_value' => 'Complete Installation',
-        '#weight' => 40,
-          );  
-            
-          $switch_to_saas = '<a style="margin-left:50px;" href="#" onclick="switch_to_saas();return false;">Switch to Kaltura SaaS</a>';
-          $form['buttons']['switch_to_saas'] = array(
-           '#value' => t($switch_to_saas),
-        '#weight' => 60,
-        );
-        }
-      }
-      else
-      {     
-        $information_text = 'Once you complete the form below and click "Complete installation", '.
-        'the All in One Video Module will be fully installed and ready to use.<br />'. PHP_EOL ;
-        $registered = '<br /><a href="#" onclick="switch_to_exist_partner();return false;">Click here if you already have a Partner ID</a>';
-        $not_registered = 'If you are not registered as a Kaltura partner, and would like to register '.
-        '<input type="button" onclick="switch_to_register();" value="Click Here" />';
-
-        $form['kaltura_settings_information'] = array(
-        '#value' => t($information_text) . $registered
-        );
-
-        if ($_GET['register'] !== 'no') {
-          drupal_set_title('All in One Video Module by Kaltura Installation');
-          // registration form
-          $showing_reg = TRUE;
-          $form['kaltura_registration'] = array(
-        '#type' => 'fieldset', 
-        '#title' => t('Registration'),
-        '#collapsible' => FALSE, 
-        '#collapsed' => FALSE
-          );
-          $form['kaltura_registration']['partner_name'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Website Name'),
-        '#default_value' => variable_get('site_name', ''),
-        '#size' => 100,
-        '#maxlength' => 256
-          );
-          $form['kaltura_registration']['partner_url1'] = array(
-          '#type' => 'hidden',
-          '#title' => t('Your Website Address'),
-          '#default_value' => $base_url,
-          '#size' => 100,
-          '#maxlength' => 1024
-          );
-          $form['kaltura_registration']['partner_url2'] = array(
-          '#type' => 'hidden',
-          '#title' => t('URL 2'),
-          '#default_value' => $base_url,
-          '#maxlength' => 1024
-          );
-          $form['kaltura_registration']['partner_adminName'] = array(
-          '#type' => 'textfield',
-          '#title' => t('Administrator Name'),
-          '#default_value' => $user->name,
-          '#size' => 100,
-          '#maxlength' => 50
-          );
-          $form['kaltura_registration']['partner_adminEmail'] = array(
-          '#type' => 'textfield',
-          '#title' => t('Administrator Email'),
-          '#default_value' => $user->mail,
-          '#size' => 100,
-          '#maxlength' => 100  
-          );
-         $categories = new KalturaContentCategories();
-
-
-          ////////////////////////////////////
-
-          $form['kaltura_registration']['kaltura_content_categories'] = array(
-           '#type' => 'select',
-           '#title' => t('Content Categories'),
-           '#multiple' => TRUE,
-           '#size' => 8,
-           '#options' => $categories->categories,
-          );
-          $form['kaltura_registration']['kaltura_adult_content'] = array(
-        '#type' => 'radios',
-        '#title' => t('Do you plan to display adult content?'),
-        '#options' => array(1 => 'Yes', 0 => 'No'),
-        '#default_value' => (variable_get('kaltura_adult_content', 0) == 0)? 0: 1,
-          );
-          $form['kaltura_registration']['partner_description'] = array(
-          //'#type' => 'textarea',
-          '#type' => 'hidden',
-          '#title' => t('Partner Description'),
-          '#default_value' => 'Drupal module|'. VERSION,
-          );
-          $form['kaltura_registration']['cms_password'] = array(
-          '#type' => 'hidden',
-          '#title' => t('CMS password'),
-          '#default_value' => kaltura_generate_cms_password(),
-          '#size' => 20,
-          '#maxlength' => 60  
-          );
-          $form['kaltura_registration']['kaltura_agree_terms'] = array(
-        '#type' => 'checkbox',
-        '#title' => 'I agree to comply with the <a href="http://www.kaltura.com/index.php/corp/tandc" target="_blank">Kaltura Terms of Use</a>',
-        '#options' => 'Agree',
-        '#required' => TRUE,
-          );
-          $form_state['storage']['submit'] = 'Register';
-          $form['kaltura_registration']['buttons']['register'] = array(
-        '#type' => 'button',
-        '#title' => 'Complete Installation',
-        '#value' => 'Complete Installation',
-        '#default_value' => 'Complete Installation',
-        '#weight' => 40,
-          );
-        }
-      }
-    }
-  }
-  if ($_GET['register'] === 'no' || (!$showing_reg && !isset($_GET['register']))) {
-    // normal settings form
-    if (variable_get('kaltura_partner_id', '') == '') {
-      drupal_set_title('All in One Video Module by Kaltura Installation');
-      $forgot_link_attributes = array(
-        'attributes' => array(
-          'target' => '_blank'
-          )
-          );
-          $information_text = 'Please enter your CMS email & password';
-          $information_text .= '<br />'. l('forgot password', 'http://www.kaltura.com/index.php/cms/login', $forgot_link_attributes);
-          $form['kaltura_settings_information']['#value'] = $information_text;
-    }
-    $form['kaltura_partner_settings'] = array(
-      '#type' => 'fieldset', 
-      '#title' => t('Partner Info'), 
-      '#collapsible' => ($_GET['register'] === 'no')? FALSE: TRUE, 
-      '#collapsed' => ($_GET['register'] === 'no')? FALSE: TRUE,
-    );
-    /*
-     $form['kaltura_partner_settings']['kaltura_exitss_switch'] = array(
-     '#value' => $not_registered,
-     );
-     */
-     $partner_exist = variable_get('kaltura_partner_id', '');
-     $readonly_attr = array();
-     if (!empty($partner_exist))
-     {
-      $readonly_attr = array('readonly' => 'readonly');
-     }
-     
-    $form['kaltura_partner_settings']['kaltura_partner_id'] = array(
-      '#type' => 'textfield', 
-      '#title' => t('Partner ID'),
-      '#default_value' => variable_get('kaltura_partner_id', ''),
-      '#size' => 20,
-      '#maxlength' => 10,
-      '#attributes' => $readonly_attr
-    );
-    $form['kaltura_partner_settings']['cms_email'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Email'),
-      '#default_value' => variable_get('kaltura_partner_cms_email', ''),
-      '#attributes' => $readonly_attr,      
-    );
-    $form['kaltura_partner_settings']['cms_password'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Password'),
-      '#default_value' => variable_get('kaltura_partner_cms_password', ''),
-        '#attributes' => $readonly_attr,    
-    );
-    if (!empty($partner_exist))
-    {
-      $form['kaltura_partner_settings']['kaltura_upd_data'] = array(
-      '#type' => 'item',
-      '#value' => t('You can update your email and password via Kaltura Management Console here: ') . l('http://www.kaltura.com/index.php/kmc', 'http://www.kaltura.com/index.php/kmc', array( 'attributes' => array( 'target' => '_blank' ) ))
-      );
-    }   
-    if (variable_get('kaltura_partner_id', '') == '') {
-      $form_state['storage']['submit'] = 'ImportPartner';
-      $form['kaltura_registration']['buttons']['import_partner'] = array(
-        '#type' => 'button',
-        '#title' => 'Complete Installation',
-        '#value' => 'Complete Installation',
-        '#default_value' => 'Complete Installation',
-        '#weight' => 40,
-      );
-    }
-    $form['kaltura_partner_settings']['kaltura_subp_id'] = array(
-      '#type' => 'hidden', 
-      '#title' => t('Kaltura Sub-Partner Id'),
-      '#default_value' => variable_get('kaltura_subp_id', ''),
-      '#size' => 20,
-      '#maxlength' => 10
-    );
-    if (variable_get('kaltura_local_registration', 0) != 1 || 1) {
-      $form['kaltura_partner_settings']['kaltura_secret'] = array(
-        '#type' => 'hidden', 
-        '#title' => t('Kaltura Secret'),
-        '#default_value' => variable_get('kaltura_secret', ''),
-        '#size' => 60,
-        '#maxlength' => 64
-      );
-
-      $form['kaltura_partner_settings']['kaltura_admin_secret'] = array(
-        '#type' => 'hidden', 
-        '#title' => t('Kaltura Admin Secret'),
-        '#default_value' => variable_get('kaltura_admin_secret', ''),
-        '#size' => 60,
-        '#maxlength' => 64
-      );
-    }
-    $form['kaltura_partner_settings']['kaltura_server_url'] = array(
-      '#type' => 'hidden', 
-      '#title' => t('Kaltura Server URL'),
-      '#default_value' => variable_get('kaltura_server_url', KalturaHelpers::getKalturaServerUrl()),
-      '#size' => 100,
-      '#maxlength' => 64
-    );
-  }
-
-  $form['kaltura_credits'] = array(
-     '#type' => 'fieldset',
-     '#title' => 'Credits',
-     '#collapsible' => TRUE,
-     '#collapsed' => TRUE,
-  );
-  $text = '<b>Open Source Video Links</b>'. PHP_EOL;
-  $text .= 'Kaltura invests a great deal of effort in the open source community, and specifically in the open source video movement.';
-  $text .= 'The following two links will be included within the video player in order to further promote Kaltura and its efforts in the open video space. ';
-  $text .= 'We hope that you will join us by including these links in the player.'. PHP_EOL;
-  $text .= l('open source video', 'http://corp.kaltura.com/download') . PHP_EOL . l('video platform', 'http://corp.kaltura.com/technology/');
-
-  $form['kaltura_credits']['kaltura_credits_text'] = array(
-    '#type' => 'item',
-    '#value' => nl2br($text),
-  );
-  $form['kaltura_credits']['kaltura_display_credits'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Include links in player'),
-    '#option' => t('Include links in player'),
-    '#default_value' => variable_get('kaltura_display_credits', 1),
-  );
-
-  $form['kaltura_help_message'] = array(
-    '#type' => 'item',
-    '#value' => t('Please feel free to ') . l('contact us', 'http://corp.kaltura.com/support/form/project/16', array( 'attributes' => array( 'target' => '_blank' ) )) . t(' with any questions.')
-  );
-  return system_settings_form($form);
-}
-
-/*
- * Implementation of hook_form_alter().
- */
-function kaltura_form_alter(&$form, &$form_state, $form_id) {
-  if (variable_get('kaltura_partner_id', '') == '') {
-    if ($form_id == 'kaltura_settings_form') {
-      unset($form['buttons']['submit']);
-      unset($form['buttons']['preview']);
-      unset($form['buttons']['reset']);
-    }
-  }
-}
-
-/*
- * callback function for url admin/settings/kaltura/import
- *CMAC
- *changes
- * KalturaEntryFilter changed to KalturaMediaEntryFilter
- * this may need some reworking
- */
-function kaltura_import_entries_page() {
-  // initialise variables
-  $foundFlag = true;      // set to false if there are no entries
-  $enabledFlag = false;     // set to true if mix or media node is enabled
-  $entries = array();     // mix entries
-  $mediaEntries = array();  // media entries
-  $entries_need_import = array();
-  $each_page=30;
-  $total = 0;
-  $mediaTotal = 0;
-  $finished = false;  
-  $current_page = 1;  
-  
-  if ($_POST['op'] == 'import selected') {
-    kaltura_import_entries($_POST['entries_to_import']);
-    drupal_goto('admin/settings/kaltura/import');
-  }
-  if (variable_get('kaltura_partner_id', '') == '') {
-    return t('You have not configured your partner details yet. Import cannot be performed until you setup your partner details');
-  }
-  $get_entries = module_exists('node_kaltura_entry');
-  $get_mixes = module_exists('node_kaltura_mix');
-  
-  if (empty($_GET['p'])) {
-    $_GET['p'] = 1;
-  }
-  else
-  {
-    $current_page = $_GET['p'];
-  }
-  
-  while (!$finished)
-  {
-    set_time_limit(30); 
-    //get the mix entries
-    if ($get_mixes) {
-      $filter = new KalturaMixEntryFilter();
-      list($total, $entries) = kaltura_get_my_entries($filter, KalturaEntryType::MIX, $each_page, $current_page);
-      if($total==0)$foundFlag = false;
-      $enabledFlag = true;
-    }
-    // get the media entries
-    if ($get_entries) {
-      $filter = new KalturaMediaEntryFilter();
-      list($mediaTotal, $mediaEntries) = kaltura_get_my_entries($filter, KalturaEntryType::MEDIA_CLIP, $each_page, $current_page);
-      if($mediaTotal==0)$foundFlag=false;
-      $enabledFlag = true;
-    }
-    if(!$enabledFlag) {
-      return t('Can\'t import entries, you did not enable the node_kaltura_entries module.');
-    }
-    
-    $entries_need_import = array_merge($entries_need_import, $entries, $mediaEntries);
-
-    //list($total, $each_page, $entries) = kaltura_get_my_entries($filter, $each_page = 30, $_GET['p']);
-    if ($entries === NULL) {
-      return t('No entries found.');
-    }
-    $entries_need_import = kaltura_remove_existing_entries($entries_need_import);
-    
-    if (count($entries_need_import) >= $each_page)
-    {
-      $finished = true;
-    }
-    
-    if (($mediaTotal < $current_page * $each_page) && ($total < $current_page * $each_page))
-    {
-      $finished = true;
-    }
-    $current_page++;
-  }
-  
-  if (!count($entries_need_import)) {
-    return t('No entries needed to be imported.');
-  }
-  
-  if (count($entries_need_import) > $each_page)
-  {
-    $multi_dim = array_chunk  ( $entries_need_import  , $each_page, true );
-    $entries_need_import = $multi_dim[0];
-  }
-/*  
-  if (count($entries_need_import) < $each_page) {
-    list($second_count, $second_page) = kaltura_get_my_entries($filter, $each_page, $_GET['p'] + 1);
-    $new_entries_need_import = kaltura_remove_existing_entries($second_page);
-    if (is_array($new_entries_need_import) && $second_page !== NULL) {
-      foreach ($new_entries_need_import as $eid => $entry) {
-        $entries_need_import[$eid] = $entry;
-        if (count($entries_need_import) == $each_page) {
-          break;
-        }
-      }
-    }
-  }
-*/
-  if (($total+$mediaTotal) > $each_page) {
-    $pages = ceil(($total+$mediaTotal)/$each_page);
-    for ($start = 1;$start <= $pages;$start++) {
-      if ($start == $_GET['p']) {
-        $pager .= '<a>'. $start .'</a>';
-      }
-      else {
-        $pager .= l($start, 'admin/settings/kaltura/import', array('query' => 'p='. $start));
-      }
-      $pager .= '&nbsp;';
-    }
-  }
-  if (is_array($entries_need_import) && count($entries_need_import)) {
-    foreach ($entries_need_import as $entry => $details) {
-      $entries_options[$details['id']] = $details['id'] .': '. $details['name'] .' ('. (($details['type'] == 2)? 'mix': 'entry') .')';
-    }
-  }
-  else {
-    $entries_options = array();
-  }
-  $output = drupal_get_form('kaltura_create_entries_form', array($entries_options));
-  return $pager . $output . $pager;
-}
-
-
-
-
-
-
-
-
-
-
-
-/*
- * helper function that uses kaltura_get_entries() to retreive a list of specific entries
- * belongs to the partner, and call kaltura_import_entry() for each of the retreived list
- */
-function kaltura_import_entries($entries) {
-  $entries_list = implode(',', $entries);
-  $my_entries = kaltura_get_entries($entries_list, count($entries), true);
-  
-  foreach ($my_entries->objects as $entry) {
-    kaltura_import_entry($entry);
-  }
-  drupal_set_message('<b>Please Note: All imported nodes are not yet published (node status 0)</b>');
-}
-
-/*
- * helper function that gets an entry retreived from Kaltura
- * builds a node object according to entry, and invokes node_insert to save the node
- */
-function kaltura_import_entry($entry_details) {
-  global $user;
-  $node = new stdClass();
-  if ($entry_details->type == 1) {
-    $type = 'entry';
-  }
-  elseif ($entry_details->type == 2) {
-    $type = 'mix';
-  }
-  else {
-    $type = '';
-  }
-  $node->type = 'kaltura_'. $type;
-  $node->title = $entry_details->name;
-  $node->kaltura_entryId = $entry_details->id;
-  $node->uid = $user->uid;
-  $node->body = '';
-  $node->status = 0;
-  $node->created = time();
-  $node->comment = FALSE;
-  $node->changed = time();
-  $node->promote = 0;
-  $node->sticky = 0;
-  $node->kstatus = $entry_details->status;
-  $node->kaltura_entry_data = serialize($entry_details);
-  $node->kaltura_tags = $entry_details->tags;
-  $node->kaltura_admin_tags = '';
-  $node->kaltura_media_type = $entry_details->mediaType;
-  $node->kaltura_duration = $entry_details->duration;
-  $node->kaltura_thumbnail_url = $entry_details->thumbnailUrl;
-  $node->kaltura_partner_data = 'imported '. $type;
-  //$node->kaltura_source = $entry_details['source'];
-  //$node->kaltura_source_id = $entry_details['sourceId'];
-  //$node->kaltura_source_link = $entry_details['sourceLink'];
-  $node->kaltura_width = $entry_details->width;
-  $node->kaltura_height = $entry_details->height;
-  $node->kaltura_download_url = $entry_details->downloadUrl;
-  //$node->kaltura_media_date = $entry_details['mediaDate'];
-  $node->kaltura_views = $entry_details->views;
-  $node->kaltura_plays = $entry_details->plays;
-  $node->kaltura_votes = $entry_details->votes;
-  $node->kaltura_rank = $entry_details->rank;
-  $node->kaltura_total_rank = $entry_details->totalRank;
-  node_save($node);
-  module_invoke('node_kaltura_'. $type, 'hook_insert', $node);
-  drupal_set_message('Kaltura item imported: '. l($node->title, 'node/'. $node->nid) .' (id: '. $node->kaltura_entryId .')');
-}
-
-/*
- * helper function to provide form fields containing all entries for import
- * each entry as checkbox option
- */
-function kaltura_create_entries_form($form) {
-  $args = func_get_args();
-  $entries_options = $args[1][0];
-  $form['entries_to_import'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Choose the entries you want to import'),
-    '#options' => $entries_options,
-  );
-  $form['import_now'] = array(
-    '#type' => 'submit',
-    '#title' => t('import selected'),
-    '#value' => t('import selected'),
-  );
-  return $form;
-}
-
-/*
- * helper functuion to get all entries of partner from Kaltura's DB
- * TODO
- * CMAC
- * changes:
- * now retrieving all media entries - needs to import mix entries as well
- */
-function kaltura_get_my_entries($filter, $type, $page_size = 30, $page = 1) {
-  $isAdmin = 1;
-  $session_user = KalturaHelpers::getSessionUser();
-  $kaltura_client = KalturaHelpers::getKalturaClient($isAdmin); // this is admin task and should be able to import all entries in the account
-  $pager_filter = new KalturaFilterPager();
-  $pager_filter->pageIndex = $page;
-  $pager_filter->pageSize = $page_size;
-  //$result = $kaltura_client->listMyEntries($session_user, $filter, 0, $page_size, $page);
-  switch($type){
-    case KalturaEntryType::MIX:
-      $result = $kaltura_client->mixing->listAction($filter,$pager_filter);
-      break;
-    case KalturaEntryType::MEDIA_CLIP:
-      $filter->mediaTypeEqual = KalturaEntryType::MEDIA_CLIP;
-      $result = $kaltura_client->media->listAction($filter,$pager_filter);
-      break;
-  }
-  
-  if ($result->totalCount > 0) {
-    $count = $result->totalCount;
-    //$each_page = $result['result']['page_size'];
-    if (is_array($result->objects) && count($result->objects)) {
-      foreach ($result->objects as $entry) {
-        $returned_entries[$entry->id] = array(
-                'id' => $entry->id,
-                'name' => $entry->name,
-                'type' => $entry->type,
-        );
-      }
-    }
-    return array($count, $returned_entries);
-  }
-  else {
-    return array(0, array());
-  }
-}
-
-/*
- * helper function that recieves a list of entries, and returns a new list
- * which does not contain entries that are already represented as nodes
- */
-function kaltura_remove_existing_entries($entries) {
-  $count = 0;
-  $new_entries = array();
-  if (is_array($entries) && count($entries)) {
-    foreach ($entries as $entry) {
-      $sel = 'SELECT COUNT(nid) n FROM {node_kaltura} WHERE kaltura_entryId = \'%s\'';
-      $result = db_fetch_object(db_query($sel, $entry['id']));
-      if ($result->n == 0) {
-        $new_entries[] = $entry;
-      }
-      else {
-        $count++;
-      }
-    }
-  }
-  return $new_entries;
-}
-
-
-/*
- * helper function that checks the drupal cron job status
- * cron job is required to collect statictics about kaltura items
- */
-function kaltura_test_cron_job_status() {
-  $cron_last = variable_get('cron_last', NULL);
-  if (!$cron_last) {
-    return array(
-    FALSE,
-      'cron has not run. If you don\'t configure cron job, statistics about kaltura items will not be updated.'
-      );
-  }
-  else {
-    return array(
-    TRUE,
-      'cron has run. Be sure that you have a cron job configured, so you don\'t need to run it manually.<br />'.
-      'Statistics about kaltura items will only be updated at cron run.'
-      );
-  }
-}
-
-/*
- * helper function that tests the notification status of the module
- *
- * this function tries to close a loop with the kaltura sevrer in a "real-time" test.
- * The notification handler sets a variable in the DB before the this function run ends
- * therefore we need to use the kaltura_variable_get_real() function to check the variable status in the DB
- * and not in the $_GLOBALS which are set before this function even start
- * TODO
- * CMAC
- * not yet implemented
- */
-function kaltura_test_notification_config() {
-  return array(TRUE, 'Test call not yet implemented, sorry');
-  if (kaltura_variable_get_real('kaltura_notification_status', 0) == 0) {
-    $session_user = KalturaHelpers::getSessionUser();
-    $kaltura_client = KalturaHelpers::getKalturaClient();
-    $result = $kaltura_client->testNotification($session_user);
-    sleep(3);
-  }
-  if (kaltura_variable_get_real('kaltura_notification_status', 0) === 1) {
-    return array(TRUE, 'Drupal server receives notification from Kaltura server.');
-  }
-
-  return array(FALSE, 'Drupal server fails to receive notifications from Kaltura. Please fix your configuration or disable server notifications.');
-}
-
-/*
- * replace default Drupal's variable_get() function with a "real-time" one
- *
- * This function checks a variable status in the DB and not in the $_GLOBALS
- *
- */
-function kaltura_variable_get_real($var, $default) {
-  $sql = 'SELECT * FROM {variable} WHERE name = \'%s\'';
-  $result = db_fetch_object(db_query($sql, $var));
-  if (!$result) {
-    return $default;
-  }
-
-  return unserialize($result->value);
-}
-
-/**
- * Used when SimpleXML is not available; just assume everything looks OK and hope for the best.
- */
-function kaltura_alternate_xml_verification($filename) {
-  return array(
-    TRUE,
-    t('crossdomain.xml is in place and seems to be OK')
-  );
-}
-
-/**
- * helper function that checks if crossdomain.xml is in the right place
- */
-function kaltura_test_crossdomain() {
-  global $base_url ;
-  $cd_req = drupal_http_request($base_url .'/crossdomain.xml');
-  if ( $cd_req->code == '200' ) {
-    return kaltura_parse_crossdomain($cd_req->data);
-  }
-  else {
-    // fall back to fetching and retrieving file contents (should we
-    // succeed if HTTP request has failed, though?
-    $filename = $_SERVER['DOCUMENT_ROOT'] .'/crossdomain.xml';
-    if ( $cd_xml = file_get_contents($filename) ) {
-      return kaltura_parse_crossdomain($cd_xml) ;
-    }
-    else {
-      return array(
-        FALSE,
-        t('crossdomain.xml file could not be found in your site\'s root directory') .' ['. $filename .']' .
-        t('Please read ') . l('here', 'admin/help/kaltura')
-      );
-    }
-  }
-}
-
-/**
- * helper function that checks if crossdomain.xml says the right things
- */
-function kaltura_parse_crossdomain($crossdomain_xml) {
-  if (!function_exists('simplexml_load_string')) {
-    return kaltura_alternate_xml_verification($filename);
-  }
-  $cd_xml_content = simplexml_load_string($crossdomain_xml);
-  foreach ($cd_xml_content->children() as $child) {
-    $atts = $child->attributes();
-    if ($atts['domain'] == '*' || $atts['domain'] == '*.kaltura.com') {
-      $kaltura_ok = TRUE;
-    }
-    if ($atts['headers'] == '*' && ($atts['domain'] == '*' || $atts['domain'] == '*.kaltura.com')) {
-      $headers_ok = TRUE;
-    }
-  }
-  if ($kaltura_ok && $headers_ok) {
-    return array(
-      TRUE,
-      t('crossdomain.xml is in place and seems to be OK')
-    );
-  }
-  else {
-    return array(
-      FALSE,
-      t('crossdomain.xml is in place, but it is probably not configured properly') .'<br />'.
-      t('Please read ') . l('here', 'admin/help/kaltura')
-    );
-  }
-}
-
-/*
- * helper function that updates partner notification settings in kaltura's server
- *
- * CMAC
- * changes
- */
-function kaltura_update_kaltura_partner($notifications_config = 2, $notification_url = '') {
-  $partner = new KalturaPartner();
-  $partner->allowMultiNotification = '1';
-  $partner->notify = 1;
-  $partner->notificationsConfig = '*='. $notifications_config;
-//  $partner->id = variable_get('kaltura_partner_id', '');
-  
-  $url = url('kaltura/notification_handler', array('absolute' => TRUE));
-  $notification_url = ($notification_url == '')? $url: $notification_url;
-  $partner->notificationUrl = $notification_url;
-  $session_user = KalturaHelpers::getSessionUser();
-  $kaltura_client = KalturaHelpers::getKalturaClient(1);
-   $cms_pass = variable_get('kaltura_partner_cms_password', '');
-
-  if ($kaltura_client) {
-    $result = $kaltura_client->partner->update($partner, $cms_pass);
-    //$result = $kaltura_client->updatePartner($session_user, $partner);
-  }
-  return $result;
-}
-
-/*
- * TODO
- * Settings form in URL admin/settings/kaltura/general/notifications
- */
-function kaltura_notifications_settings_form() {
-  global $base_url;
-  $notification_types = array(
-  //'1' => 'only server side notifications',
-    '2' => 'only client side notifications',
-    '3' => 'both server & client notifications'
-    );
-    if (isset($_REQUEST['kaltura_notification_type']) && $_REQUEST['kaltura_partner_url2']) {
-      // TODO: update partner settings with notification type
-      $url2 = $_REQUEST['kaltura_partner_url2'] .'/?q=kaltura/notification_handler';
-      if ($_REQUEST['kaltura_notification_type'] == 1) {
-      $not_type = 3;
-      }
-      else {
-      $not_type = 2;
-      }
-      $result = kaltura_update_kaltura_partner($not_type, $url2);
-      if ($_REQUEST['last_notification_url'] != $_REQUEST['kaltura_partner_url2'] || $not_type == 3) {
-      variable_set('kaltura_notification_status', 0);
-      list($status, $text) = kaltura_test_notification_config();
-      if ($status == FALSE) {
-        drupal_set_message(t('Notification test failed. The URL you specified is not valid. Please make sure it is correct and save the settings again.'), 'error');
-      }
-      else {
-        drupal_set_message(t('Notification test was successful.'));
-      }
-      }
-      if (!$result->id) {
-      drupal_set_message('Updating kaltura\'s server faild.<br />'. $result['error']['code'] .': '. $result['error']['desc'], 'error');
-      }
-      else {
-      drupal_set_message('Updating kaltura\'s server was successful '. l($url2, $url2));
-      }
-    }
-    $notification_type_description = t('Enabling server notifications allows the Kaltura video platform to update your Drupal server about the status of '.
-    'the media content. This is especially useful when uploading content in various formats that needs to be transcoded. '.
-    'In order to support server side notifications, your server must be publicly available on the internet.');
-    $form['kaltura_notification_type'] = array(
-    '#type' => 'checkbox',
-    '#options' => 'Enable server side notifications',
-    '#description' => $notification_type_description,
-    '#title' => t('Enable server side notifications'),
-    '#default_value' => variable_get('kaltura_notification_type', 0),
-    );
-
-    $not_url = (variable_get('kaltura_partner_url2', '') != '')? variable_get('kaltura_partner_url2', ''): $base_url;
-    $form['kaltura_partner_url2'] = array(
-    '#type' => 'textfield',
-    '#title' => 'Notification URL',
-    '#description' => t('Your drupal base URL.') .' /?q=kaltura/notification_handler '. t('will be added to this base URL.'),
-    '#default_value' => $not_url,
-    );
-
-    $form['last_notification_url'] = array(
-    '#type' => 'hidden',
-    '#value' => variable_get('kaltura_partner_url2', ''),
-    );
-    return $form;
-    return system_settings_form($form);
-}
-
-/*
- * helper function that tries to open session with the kaltura server
- *
- * used to verify partner details, and display errors if there are
- *
- * CMAC
- * changed
- * added new variable_get statements required for the api calls
- * updated KalturaClient creation process
- * changed API calls
- *
- * TODO check correct format for error checking of result
- */
-function kaltura_check_server_status($admin) {
-  //get the variables we will need to start the session
-/*  $partner_id = variable_get('kaltura_partner_id', '');
-  $secret = variable_get('kaltura_secret', '');
-  $admin_secret = variable_get('kaltura_admin_secret', '');
-
-
-
-  $session_user = KalturaHelpers::getSessionUser();
-  $config = KalturaHelpers::getServiceConfiguration();
-  $config->partnerId = $partner_id;
-  $kaltura_client = new KalturaClient();
-  $kaltura_client->setConfig($config);
-
-
-
-
-  if ($admin == 1) {
-    $result = $kaltura_client->session->start($partner_id, $secret, $session_user->screenName);
-  }
-  else {
-    $result = $kaltura_client->session->start($partner_id, $admin_secret, $session_user->screenName, KalturaSessionType::ADMIN);
-  }
-*/  
-  
-  try
-  {
-    $result = KalturaHelpers::getKalturaClient($admin);
-    $kaltura_status = TRUE;
-    $kaltura_error = "";
-  }
-  catch(Exception $ex)
-  {
-    $kaltura_status = FALSE;
-    $kaltura_error = $ex->getMessage();
-  }
-  
-  /*if ($result[]) {
-    $kaltura_status = FALSE;
-    $kaltura_error = $result['error'][0]["code"] .' '. $result['error'][0]["desc"];
-    }
-    else {*/
-  //  }
-  return array($kaltura_status, $kaltura_error);
-}
-
-/*
- * helper function to generate a cms password
- *
- * cms is the "administration panel" for kaltura's partners in kaltura's website
- */
-function kaltura_generate_cms_password() {
-  $pass = '';
-  $pass = md5(time() . $_SERVER['REMOTE_ADDR']);
-  $pass = drupal_substr($pass, 0, 8);
-  return $pass;
-}
+<?php
+// $Id: kaltura.admin.inc,v 1.1.2.5.2.5 2010/11/17 01:14:57 xuriz Exp $
+
+define('KALTURA_DEFAULT_URL', 'http://www.kaltura.com/');
+define('KALTURA_INSTALL_BACKBUTTON', 'Back');
+define('KALTURA_INSTALL_FWDBUTTON', 'Continue');
+define('KALTURA_INSTALL_SKIPREGBUTTON', 'Skip Registration');
+define('KALTURACE_ACCEPTS_REGISTRATION', FALSE);
+
+/*
+ * @file
+ * contains functions for administration use of the kaltura core module
+ *
+ */
+
+/*
+ * helper function to retrieve partner's details from kaltura
+ * TODO: testing
+ * CMAC changes:
+ * kaltura client config set up to reflect changes in the API
+ * getsecrets now called instead of getPartner
+ * return array built using Kaltura Partner object
+ *
+ */
+function kaltura_get_partner_details($partner_id, $cms_email, $cms_password) {
+  // $session_user is not actually used below. Remove?
+  $session_user = KalturaHelpers::getSessionUser();
+  
+  $config = KalturaHelpers::getServiceConfiguration();
+  $config->partnerId = $partner_id;
+  $kaltura_client = new KalturaClient($config);
+  /**
+   * here we are trying to retrieve the partner details from the kaltura server
+   *
+   */
+
+  //$result = $kaltura_client->getPartner($session_user, $cms_email, $cms_password, $partner_id);
+  try {
+    $result = $kaltura_client->partner->getsecrets($partner_id, $cms_email, $cms_password);
+  }
+  catch ( Exception $ex ) {
+    drupal_set_message(t('Kaltura client exception: @message', array('@message' => $ex->getMessage())), 'error'); 
+    //if ( module_exists('devel') ) {
+    //  dpm( $ex->getTrace(), 'Exception stack trace' );
+    //}
+    $result['error'] = $ex->getMessage();
+  }
+
+  // convert result to array
+  
+  if ($result->id) {
+    return array(
+      $result->id,
+      $result->id."00",//subpartner id
+      $result->notificationUrl,
+      $result->secret,
+      $result->adminSecret
+    );
+  }
+  else {
+    return array(FALSE, $result['error']);
+  }
+}
+
+/*
+ * helper function that uses Kaltura's getDefaultWidget service to create some default widgets for
+ * the partner, in case he does not have these yet
+ * TODO
+ * CMAC
+ * changes
+ * changed client initialisation
+ * changed the getDefaultWidget function call to $kaltura_client->widget->get
+ * question: what do we do with the widget when we get them?
+ */
+function kaltura_create_widgets_for_partner($partner_id, $secret) {
+  /*$session_user = KalturaHelpers::getSessionUser();
+   $config = KalturaHelpers::getServiceConfiguration();
+   $config->partnerId = $partner_id;
+   $kaltura_client = new KalturaClient();
+   $kaltura_client->setConfig($config);*/
+
+  $session_user = KalturaHelpers::getSessionUser();
+  $kaltura_client = KalturaHelpers::getKalturaClient(1);
+
+  $widgets = new KalturaSettings;
+
+  foreach ($widgets->kdp_widgets as $type => $uiconfs) {
+    foreach ($uiconfs as $skin => $confs) {
+    /* oferc: that doesn't work for me yet */
+//      $result = $kaltura_client->widget->get("_1_".$confs['view_uiconf']);
+//      $result = $kaltura_client->widget->get("_1_".$confs['remix_uiconf']);
+    }
+  }
+}
+
+/**
+ * Form builder function. Used when site has not yet been initialised.
+ */
+function kaltura_installation_form($form_state = NULL) {
+  //dpm($form_state, 'form (build)');
+  global $user ;
+
+  $steps = 3 ;
+
+  drupal_add_js(drupal_get_path('module', 'kaltura') . '/js/admin.js');
+  $form_state['storage']['step'] = isset($form_state['values']) ? (int)$form_state['storage']['step'] : 0 ;
+  if ( $form_state['storage']['step'] < 0 ) {
+    $form_state['storage']['step'] = 0 ;
+  }
+
+  switch ( $form_state['storage']['step'] ) {
+    case '0' :
+      drupal_set_title(t('Kaltura Installation - Select your Kaltura Server host'));
+
+      /* Initial form. Allows user to select the Kaltura service they will be using, which allows us to decide whether
+       * we need to display Kaltura TOS and allow remote registration, or request existing partner details.
+       */
+      $saasText = "<b>Kaltura SaaS (hosted by Kaltura.com)</b><br/>" .
+        "Kaltura will be responsible for transcoding your content to FLV, " .
+        "hosting it in a first grade CDN and streaming it to your viewers. " . 
+        "<br />" .
+        "Kaltura SaaS has cost effective pricing and <b>10 GB of free trial</b>." . 
+        "<br />" .
+        l('To learn more about Kaltura SaaS offering and pricing, click here.', 
+          'http://www.kaltura.com', 
+          array( 'target' => '_blank' ));
+
+      /** 
+       * At http://corp.kaltura.com/solutions/kaltura_platform_editions
+       * there is a third option, Kaltura Commercial Edition, which
+       * also reduces to Kaltura CE.
+       *
+       * In order to connect to a Commercial Edition server here, the
+       * user would need to select Community Edition, which is a
+       * source of potential confusion.
+       */
+      $ceText = "<b>Kaltura CE (Community or Commercial Editions)</b>" .
+        "<br/>Kaltura Commercial and Comunity Editions will allow you to host, " .
+        "transcode and stream everything on your own server." .
+        "<br />" .
+        "<b>This requires an installed and configured Kaltura CE server before continuing.</b>" . 
+        "<br/>" .
+        l('To learn more or download Kaltura CE, click here.', 
+          'http://www.kaltura.org/project/community_edition_video_platform', 
+          array('target' => '_blank' )) ;
+
+      $form['saas_or_ce'] = array(
+        '#type' => 'radios',
+        '#title' => t('Select Kaltura platform'),
+        '#options' => array(
+          'saas' => $saasText, 
+          'ce' => $ceText
+        ),
+        '#default_value' => ( isset($form_state['storage']['saas_or_ce']) ? $form_state['storage']['saas_or_ce'] : 'saas' ),
+        // workaround to set id for saas-or-ce radios element
+        '#prefix' => '<div id="saas-or-ce-wrapper">',
+        '#suffix' => '</div>',
+      );
+
+      $example_url = 'http://kaltura.example.org/' ;
+      $form['kaltura_url'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Kaltura CE URL'),
+        '#default_value' => ( isset($form_state['storage']['kaltura_url']) ) ? $form_state['storage']['kaltura_url'] : $example_url,
+        '#description' => t('The base URL of your Kaltura CE server (eg !example_url).', array( '!example_url' => $example_url )),
+        '#size' => 40,
+      ) ;
+
+      break ;
+
+    case '1' :
+      $targs = array('!kaltura_url' => parse_url($form_state['values']['kaltura_url'], PHP_URL_HOST));
+      drupal_set_title(t('Kaltura Installation - Register with Kaltura server at !kaltura_url', $targs));
+
+      $form['skip_registration'] = array( 
+        '#prefix' => '<p>'. t('If you already have a login, click "!skip_reg" to enter your existing access details: ', array('!skip_reg' => KALTURA_INSTALL_SKIPREGBUTTON)),
+        '#suffix' => t('</p><p>Otherwise, please enter details below to register a new account on the Kaltura server at !kaltura_url</p>', $targs),
+        '#type' => 'submit',
+        '#value' => t(KALTURA_INSTALL_SKIPREGBUTTON),
+      ) ;
+
+      $form['partner_site_name'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Website Name'),
+        '#default_value' => ( isset($form_state['storage']['partner_site_name']) ? $form_state['storage']['partner_site_name'] : variable_get('site_name', '') ),
+        '#size' => 60,
+        '#maxlength' => 256
+      );
+
+      global $base_url ;
+      $form['partner_url1'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Your Website Address'),
+        '#default_value' =>  ( isset($form_state['storage']['partner_url1']) ? $form_state['storage']['partner_url1'] : $base_url ),
+        '#size' => 60,
+      );
+
+      $form['partner_url2'] = array(
+        '#type' => 'value',
+        '#title' => t('URL 2'),
+        '#default_value' =>  ( isset($form_state['storage']['partner_url2']) ? $form_state['storage']['partner_url2'] : $base_url ),
+        '#maxlength' => 1024
+      );
+
+      $form['partner_administrator_name'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Administrator Name'),
+        '#default_value' => ( isset($form_state['storage']['partner_administrator_name']) ? $form_state['storage']['partner_administrator_name'] : $user->name  ),
+        '#size' => 40,
+        '#maxlength' => 50
+      );
+
+      $form['partner_administrator_email'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Administrator Email'),
+        '#default_value' => ( isset($form_state['storage']['partner_administrator_email']) ? $form_state['storage']['partner_administrator_email'] : $user->mail ),
+        '#size' => 40,
+        '#maxlength' => 100  
+      );
+
+      $categories = new KalturaContentCategories();
+      $form['kaltura_content_categories'] = array(
+        '#type' => 'select',
+        '#title' => t('Content Categories'),
+        '#multiple' => TRUE,
+        '#size' => 8,
+        '#options' => $categories->categories,
+        '#default_value' => ( isset($form_state['storage']['kaltura_content_categories']) ? $form_state['storage']['kaltura_content_categories'] : array() ),
+      );
+
+      $form['kaltura_adult_content'] = array(
+        '#type' => 'radios',
+        '#title' => t('Do you plan to display adult content?'),
+        '#options' => array(
+          1 => 'Yes',
+          0 => 'No'
+        ),
+        '#default_value' => ( isset($form_state['storage']['kaltura_adult_content']) ? $form_state['storage']['kaltura_adult_content'] : 0 ),
+      );
+
+      // Use update.module to extract kaltura module version info if
+      // available. 
+      // 
+      // @TODO: move to separate function and report this version info
+      // elsewhere for improved debugging / error reports
+      if ( module_exists('update') ) {
+        module_load_include('inc', 'update', 'update.compare');
+        $projects = update_project_cache('update_project_projects');
+        _update_process_info_list($projects, module_rebuild_cache(), 'module');
+      }
+      else {
+        $projects = array() ;
+      }
+      $dargs = array(
+        '!drupal_version' => VERSION,
+        '!kaltura_version' => ( isset($projects['Kaltura']['info']['version']) ) ? $projects['Kaltura']['info']['version'] : 'unknown',
+        '!datestamp' => ( isset($projects['Kaltura']['info']['datestamp']) ) ? $projects['Kaltura']['info']['datestamp'] : 'unknown',
+      ) ;
+      // Drupal module|6.20|6.x-2.0-dev|1274334388
+      $partner_description = t('Drupal module|!drupal_version|!kaltura_version|!datestamp', $dargs);
+
+      $form['partner_description'] = array(
+        '#type' => 'value',
+        '#title' => t('Partner Description'),
+        '#default_value' => $partner_description,
+      );
+
+      $form['cms_password'] = array(
+        '#type' => 'value',
+        '#title' => t('CMS password'),
+        '#default_value' => kaltura_generate_cms_password(),
+        '#size' => 20,
+        '#maxlength' => 60  
+      );
+
+      if ( $form_state['storage']['saas_or_ce'] == 'saas' ) {
+        $form['kaltura_agree_terms'] = array(
+          '#type' => 'checkbox',
+          '#title' => 'I agree to comply with the <a href="http://www.kaltura.com/index.php/corp/tandc" target="_blank">Kaltura Terms of Use</a>',
+          '#options' => 'Agree',
+          '#required' => TRUE,
+          '#default_value' => ( isset($form_state['storage']['kaltura_agree_terms']) ? $form_state['storage']['kaltura_agree_terms'] : FALSE ),
+        );
+      }
+
+      $form_state['storage']['submit'] = 'Register';
+
+      break ;
+
+    case '2' :
+      $targs = array('!kaltura_url' => parse_url($form_state['storage']['kaltura_url'], PHP_URL_HOST));
+      drupal_set_title(t('Kaltura Installation - Login details for !kaltura_url', $targs));
+      $form['kaltura_partner_id'] = array(
+        '#type' => 'textfield',
+        '#size' => 8,
+        '#title' => 'Kaltura Partner ID',
+        '#description' => t('Visible under Account » Server Settings » Partner Info in Kaltura console.'),
+        '#default_value' => $form_state['storage']['kaltura_partner_id'],
+      ) ;
+      
+      $form['kaltura_login_email'] = array(
+        '#type' => 'textfield',
+        '#size' => 32,
+        '#title' => 'Kaltura Partner Login',
+        '#description' => 'The email address you use to log into Kaltura, visible under Account » Account Overview » Login Info in Kaltura console.',
+        '#default_value' => $form_state['storage']['kaltura_login_email'],
+      );
+
+      $form['kaltura_login_password'] = array(
+        '#type' => 'password',
+        '#size' => 24,
+        '#title' => 'Kaltura Password',
+        '#default_value' => $form_state['storage']['kaltura_login_password'],
+      ) ;
+  }
+
+  if ( $form_state['storage']['step'] != 0 ) {
+    $form['back'] = array(
+      '#type' => 'submit',
+      '#value' => KALTURA_INSTALL_BACKBUTTON,
+    ) ;
+  }
+  
+  if ( $form_state['storage']['step'] < $steps ) {
+    $form['continue'] = array(
+      '#type' => 'submit',
+      '#value' => 'Continue',
+    ) ;    
+  }
+
+  return $form ;
+}
+
+/**
+ * Validation handler for kaltura_installation_form()
+ *
+ * @TODO validate that the supplied kaltura_url actually looks like a
+ * Kaltura server before proceeding. We need to stop them if the
+ * supplied URL isn't going to work.
+ */
+function kaltura_installation_form_validate($form, &$form_state) {
+  //dpm($form_state, 'form state (validate)');
+  // BACK goes in validate because we ALWAYS need to be able to go
+  // back a step, even if we don't pass validation.
+  $step_from = $form_state['storage']['step'] ;
+  if ( $form_state['clicked_button']['#value'] == KALTURA_INSTALL_SKIPREGBUTTON ) {
+    // we don't validate - just move on in _submit()
+    return ; // don't validate further
+  }
+  if ( $form_state['clicked_button']['#value'] == KALTURA_INSTALL_BACKBUTTON ) {
+    switch ( $form_state['storage']['step'] ) {
+      case 2 : 
+        if ( !KALTURACE_ACCEPTS_REGISTRATION ) {
+          /* skip step 1 if CE selected and going back from 2 */
+          if ( $form_state['storage']['saas_or_ce'] == 'ce' ) {
+            //drupal_set_message('CE detected, skipping step 1 going back.');
+            $form_state['storage']['step']-- ;
+          }
+        }
+      default :
+        $form_state['storage']['step']-- ;
+    }
+    // drupal_set_message(t('Back (!from » !to)', array('!from' => $step_from, '!to' => $form_state['storage']['step'])));
+    return ; // don't validate further
+  }
+
+  /* actual form validation */
+  //  drupal_set_message('Validating step '. $form_state['storage']['step']);
+  switch ( $form_state['storage']['step'] ) {
+    case 0 :
+      // nothing to validate, move on
+      break ;
+    case 1 :
+      // website name, admin name must not be empty
+      if ( empty($form_state['values']['partner_site_name']) ) {
+        form_set_error('partner_site_name', t('Website Name is a required field.'));
+      }
+      if ( !valid_url($form_state['values']['partner_url1'], TRUE) ) {
+        form_set_error('partner_url1', t('Website address must be a valid URL.'));
+      }
+      if ( empty($form_state['values']['partner_administrator_name']) ) {
+        form_set_error('partner_administrator_name', t('Administrator name is required.'));
+      }
+      if ( !valid_email_address($form_state['values']['partner_administrator_email']) ) {
+        form_set_error('partner_administrator_email', t('Administrator email must be a valid email address.'));
+      }
+
+      if ( $form_state['storage']['saas_or_ce'] == 'saas' ) { /* if SaaS, check T&C requirement too */
+        if ( !$form_state['values']['kaltura_agree_terms'] ) { 
+          form_set_error('kaltura_agree_terms', t("You must agree to Kaltura's Terms and Conditions in order to use the service."));
+        }
+      }
+      break ;
+    case 2 :
+      $vc = TRUE ; // whether to attempt client validation as well
+      /* Kaltura client will prepend slash, so let's trim it here */
+      $form['storage']['kaltura_url'] = trim($form_state['storage']['kaltura_url'], ' /');
+      /* throws exceptions if trailing slash is missing from kaltura_url */
+      //if ( substr($form_state['storage']['kaltura_url'], -1) != '/' ) {
+      //$form_state['storage']['kaltura_url'] .= '/' ;
+      //}
+      if ( !valid_url( $form_state['storage']['kaltura_url'], TRUE) ) {
+        form_set_error('kaltura_url', t('Kaltura URL must be a valid URL.'));
+        $vc = FALSE ;
+      }
+      
+      if ( empty( $form_state['values']['kaltura_partner_id']) ) {
+        form_set_error('kaltura_partner_id', t('Kaltura Partner ID must be provided.'));
+        $vc = FALSE ;
+      }
+
+      if ( !valid_email_address($form_state['values']['kaltura_login_email']) ) {
+        form_set_error('kaltura_login_password', t('You must provide a valid Kaltura login email.'));
+        $vc = FALSE ;
+      }
+
+      if ( empty($form_state['values']['kaltura_login_password']) ) {
+        form_set_error('kaltura_login_password', t('You must enter a Kaltura login password.'));
+        $vc = FALSE ;
+      }
+
+      if ( $vc ) {
+        try {
+          // test access credentials
+          $config = Kalturahelpers::getServiceConfiguration();
+          // we're still in validate, so the changed values aren't
+          // committed to $form_state['storage'] yet
+          $config->partnerId =  $form_state['values']['kaltura_partner_id'] ;
+          $config->serviceUrl = $form_state['storage']['kaltura_url'] ;
+          $client = new KalturaClient($config);
+          $result = $client->partner->getSecrets(
+            $form_state['values']['kaltura_partner_id'], 
+            $form_state['values']['kaltura_login_email'], 
+            $form_state['values']['kaltura_login_password']
+          );
+          drupal_set_message(t('Kaltura credentials verified against !kaltura_url.', array('!kaltura_url' => $form_state['storage']['kaltura_url'])));
+          // do we want to store these details and re-use them?
+          $form['storage']['secret'] = $result->secret ;
+          $form['storage']['adminSecret'] = $result->adminSecret ;
+        }
+        catch ( Exception $ex ) {          
+          form_set_error('', t('Kaltura credentials failed login: %message', array('%message' => $ex->getMessage(), '%file' => $ex->getFile(), '%line' => $ex->getLine(), '%code' => $ex->getCode() ) ));
+          //if ( module_exists('devel') ) {
+          //  dpm( $ex->getTrace(), 'Exception stack trace' );
+          //}
+        }
+      }
+  }
+}
+
+/**
+ * Submit handler for kaltura_installation_form()
+ */
+function kaltura_installation_form_submit($form, &$form_state) {
+  //dpm($form_state, 'form state (submit)');
+  $form_state['storage'] = array_merge($form_state['storage'], $form_state['values']);
+  $step_from = $form_state['storage']['step'] ;
+  if ( $form_state['clicked_button']['#value'] == KALTURA_INSTALL_FWDBUTTON || $form_state['clicked_button']['#value'] == KALTURA_INSTALL_SKIPREGBUTTON ) {
+    switch ( $form_state['storage']['step'] ) {
+      case 0 :
+        /* ignore submitted kaltura_url if SaaS selected */
+        if ( $form_state['storage']['saas_or_ce'] == 'saas' ) {
+          $form_state['values']['kaltura_url'] =
+            $form_state['storage']['kaltura_url'] = 
+            KALTURA_DEFAULT_URL ;
+        }
+        if ( !KALTURACE_ACCEPTS_REGISTRATION ) {
+          /* skip step 1 if CE selected on step 0 */
+          if ( $form_state['values']['saas_or_ce'] == 'ce' ) {
+            //drupal_set_message('CE detected, skipping step 1.');
+            $form_state['storage']['step']++ ;
+          }
+        }
+        break ;
+      case 1 :
+        if ( $form_state['clicked_button']['#value'] == KALTURA_INSTALL_SKIPREGBUTTON ) {
+          $form_state['storage']['step']++ ;
+          return ; // don't validate further
+        }
+        /* register a new partner (was kaltura_register_partner()) */
+        global $base_url ;
+        $partner = new KalturaPartner() ;
+        $partner->name = $form_state['storage']['partner_site_name'] ;
+        $partner->website = $form_state['storage']['partner_url1'] ;
+        // would be nice to respect clean URLs here too.
+        // $partner->notificationUrl = url($form_state['storage']['partner_url2'], array('query' => array('q' => 'kaltura/notification_handler'))) ;
+        $partner->notificationUrl = $form_state['storage']['partner_url2'] . '?q=kaltura/notification_handler' ;
+        $partner->adminName = $form_state['storage']['partner_administrator_name'] ;
+        $partner->adminEmail = $form_state['storage']['partner_administrator_email'] ;
+        $partner->description = $form_state['storage']['partner_description'] ;
+        $partner->commercialUse = 'non-commercial_use' ; // odd that this is hard-coded, must ask ZB
+        $partner->type = 102 ; // likewise, what is this?
+        $partner->appearInSearch = 1 ;
+        $content_categories = new KalturaContentCategories();
+        foreach ( $form_state['storage']['kaltura_content_categories'] as $category ) {
+          $categories[] = $content_categories->categories[$category] ;
+        }
+        $partner->contentCategories = ( !empty($categories) ) ? implode(',', $categories) : 'N/A' ;
+        // in old form this was: $partner->adultContent = ($_REQUEST['kaltura_adult_content'] == 1)? true: false;
+        // but when testing, I always found that (regardless of submitted value), the Kaltura server then
+        // listed the registered account as FALSE for this value.
+        $partner->adultContent = ( $form_state['storage']['kaltura_adult_content'] ) ? TRUE : FALSE ;
+
+        // is this needed? it's not used directly, but it's
+        // everywhere.
+        $session_user = KalturaHelpers::getSessionUser() ;
+        $config = KalturaHelpers::getServiceConfiguration() ;
+        $config->serviceUrl = $form_state['storage']['kaltura_url'] ; // also [#1018042]
+        $client = new KalturaClient($config);
+        watchdog('kaltura', 'Registering Kaltura partner: <pre>!partner</pre>', array('!partner' => print_r($partner,1)));
+        try {
+          $res = $client->partner->register($partner, $form_state['storage']['cms_password']);
+          if ( $res->id ) {
+            variable_set('kaltura_partner_id',           $res->id);
+            variable_set('kaltura_subp_id',              $res->id .'00');
+            variable_set('kaltura_secret',               $res->secret);
+            variable_set('kaltura_admin_secret',         $res->adminSecret);
+            variable_set('kaltura_local_registration',   1);
+            variable_set('kaltura_server_url',           KalturaHelpers::getKalturaServerUrl());
+            variable_set('kaltura_partner_cms_email',    $res->adminEmail);
+            variable_set('kaltura_partner_cms_password', $res->cmsPassword);
+            variable_set('kaltura_partner_url2',         $form_state['storage']['partner_url2']);
+            variable_set('kaltura_notification_type',    0);
+            variable_set('kaltura_content_categories',   $res->categories);
+            kaltura_update_kaltura_partner(2, $partner->notificationUrl);
+            drupal_set_message('Congratulations! You have successfully installed the Kaltura Video Module and registered for the Kaltura Partner Program.');
+            drupal_goto('admin/settings/kaltura/general');
+          }
+          else {
+            form_set_error('', t('Error registering for the Kaltura Partner Program: @message', array('@message' => $res['error'][0]['desc'])));
+            drupal_set_message(t('Error registering for the Kaltura Partner Program: @message', array('@message' => $res['error'][0]['desc'])), 'error');
+          }
+        }
+        catch ( Exception $ex ) {
+          form_set_error('', t('Registration error: @message', array('@message' => $ex->getMessage())), 'error'); 
+          //if ( module_exists('devel') ) {
+          //  dpm( $ex->getTrace(), 'Exception stack trace' );
+          //}
+          watchdog('kaltura', 'Registration error: @message', array('@message' => $ex->getMessage()));
+          watchdog('kaltura', 'Backtrace for failed registration: <pre>@trace</pre>', array('@trace' => $ex->getTrace()));
+          // If we re-display the form here, we will lose $form['storage'].
+          // Redirect back to step 0 to avoid confusion.
+          drupal_goto('admin/settings/kaltura/install');
+        }
+        break ;
+    case 2 :
+      // import an existing partner (was kaltura_import_ce())
+      $config = Kalturahelpers::getServiceConfiguration();
+      $config->partnerId =  $form_state['storage']['kaltura_partner_id'] ;
+      $config->serviceUrl = $form_state['storage']['kaltura_url'] ;
+      $client = new KalturaClient($config);
+      //dpm($form_state, 'fstate');
+      //dpm($config, 'config');
+      try {
+        $result = $client->partner->getSecrets(
+          $form_state['storage']['kaltura_partner_id'], 
+          $form_state['storage']['kaltura_login_email'], 
+          $form_state['storage']['kaltura_login_password']
+        );
+        variable_set('kaltura_partner_id',           $result->id);
+        variable_set('kaltura_subp_id',              $result->id."00");
+        variable_set('kaltura_secret',               $result->secret);
+        variable_set('kaltura_admin_secret',         $result->adminSecret);
+        variable_set('kaltura_local_registration',   1);
+        variable_set('kaltura_server_url',           $form_state['storage']['kaltura_url']);
+        variable_set('kaltura_partner_cms_email',    $form_state['storage']['kaltura_login_email']);
+        variable_set('kaltura_partner_cms_password', $form_state['storage']['kaltura_login_password']);
+        variable_set('kaltura_partner_url2',         $form_state['storage']['partner_url2']);
+        variable_set('kaltura_notification_type',    0);
+        kaltura_update_kaltura_partner(2, $partner->notificationUrl);
+        // kaltura_create_widgets_for_partner($partner->id, $secret);
+        drupal_set_message('Congratulations!  You have successfully installed the Kaltura Module and connected to your Kaltura server.');
+        drupal_goto('admin/settings/kaltura/general');
+      }
+      catch(Exception $ex) {
+        drupal_set_message(t('Kaltura client exception: @message', array('@message' => $ex->getMessage())), 'error'); 
+      }
+      break ;
+    default :
+      break ;
+    }
+    $form_state['storage']['step']++ ;  
+    //drupal_set_message(t('Forward (!from » !to)', array('!from' => $step_from, '!to' => $form_state['storage']['step'])));
+  }
+}
+
+/**
+ * determine how the general settings form will look like.
+ *
+ * returns one of 2 states of forms:
+ * 1) registration form (if variables do not exist in the DB) 
+ *    - either as SaaS or Kaltura CE
+ * 2) notifications settings + configuration test + settings form
+ *
+ * @TODO remove the registration form component from this now that we
+ * have a separate form.
+ *
+ * @TODO FAPI rewrite.
+ */
+function kaltura_settings_form() {
+  global $base_url;
+
+  if (variable_get('kaltura_partner_id', '') == '') {
+    drupal_goto('admin/settings/kaltura/install');
+  }
+
+  if (!module_exists('advanced_help')) {
+    $form['kaltura_help'] = array(
+      '#value' => t('For more detailed help enable the advanced help module.'),
+    );
+  }
+
+  /* status report */
+  $form['kaltura_server_status'] = array(
+    '#type' => 'fieldset', 
+    '#title' => t('Server Status'), 
+    '#collapsible' => TRUE, 
+    '#collapsed' => FALSE,
+  );
+
+  list($admin_session_status, $admin_session_error) = kaltura_check_server_status($admin = 1);
+  list($normal_session_status, $normal_session_error) = kaltura_check_server_status($admin = 0);
+  $status_class = ($admin_session_status && $normal_session_status)? 'ok': 'bad';
+  $session_status = ($admin_session_status && $normal_session_status)? 'OK': 'ERROR';
+  $error = '';
+  if ($admin_session_error) {
+    $error .= '<br />Admin Session: '. $admin_session_error;
+    $error_status = TRUE;
+  }
+  if ($normal_session_error) {
+    $error .= '<br />Normal Session: '. $normal_session_error;
+    $error_status = TRUE;
+  }
+  
+  $form['kaltura_server_status']['kaltura_Admin_test_server'] = array(
+    '#type' => 'item',
+    '#title' => t('Drupal to Kaltura Session Test'),
+    '#prefix' => '<div class="kaltura-status-'. $status_class .'">',
+    '#value' => 'Session status: '. $session_status . (($error_status) ? $error: ''),
+    '#suffix' => '</div>'
+  );
+
+  if (kaltura_variable_get_real('kaltura_notification_type', 0) == 1) {
+    list($status, $text) = kaltura_test_notification_config();
+    $prefix = '<div class="kaltura-status-'. (($status)? 'ok': 'bad') .'">';
+    $form['kaltura_server_status']['kaltura_notification_status'] = array(
+      '#type' => 'item',
+      '#title' => t('Kaltura to Drupal Notification Status'),
+      '#prefix' => $prefix,
+      '#value' => $text,
+      '#suffix' => '</div>'
+    );
+  }
+
+  list($status, $text) = kaltura_test_cron_job_status();
+  $prefix = '<div class="kaltura-status-'. (($status)? 'ok': 'bad') .'">';
+  $form['kaltura_server_status']['kaltura_cron_job_status'] = array(
+    '#type' => 'item',
+    '#title' => t('Cron-Job Status'),
+    '#prefix' => $prefix,
+    '#value' => $text,
+    '#suffix' => '</div>'
+  );
+
+  list($status, $text) = kaltura_test_crossdomain();
+  $prefix = '<div class="kaltura-status-'. (($status)? 'ok': 'bad') .'">';
+  $form['kaltura_server_status']['kaltura_crossdomain_status'] = array(
+    '#type' => 'item',
+    '#title' => t('crossdomain.xml Status'),
+    '#prefix' => $prefix,
+    '#value' => $text,
+    '#suffix' => '</div>'
+  );
+  
+  /* The normal settings form. */
+  if (variable_get('kaltura_partner_id', '') == '') {
+    drupal_set_title('All in One Video Module by Kaltura Installation');
+    $forgot_link_attributes = array(
+      'attributes' => array(
+        'target' => '_blank'
+      )
+    );
+    $information_text = 'Please enter your CMS email & password';
+    $information_text .= '<br />'. l('forgot password', 'http://www.kaltura.com/index.php/cms/login', $forgot_link_attributes);
+    $form['kaltura_settings_information']['#value'] = $information_text;
+  }
+  
+  $form['kaltura_partner_settings'] = array(
+    '#type' => 'fieldset', 
+    '#title' => t('Partner Info'), 
+    '#collapsible' => ($_GET['register'] === 'no')? FALSE: TRUE, 
+    '#collapsed' => ($_GET['register'] === 'no')? FALSE: TRUE,
+  );
+  
+  /*
+    $form['kaltura_partner_settings']['kaltura_exitss_switch'] = array(
+    '#value' => $not_registered,
+    );
+  */
+  
+  $partner_exist = variable_get('kaltura_partner_id', '');
+  $readonly_attr = array();
+
+  if (!empty($partner_exist)) {
+    $readonly_attr = array('readonly' => 'readonly');
+  }  
+  $form['kaltura_partner_settings']['kaltura_partner_id'] = array(
+    '#type' => 'textfield', 
+    '#title' => t('Partner ID'),
+    '#default_value' => variable_get('kaltura_partner_id', ''),
+    '#size' => 20,
+    '#maxlength' => 10,
+    '#attributes' => $readonly_attr
+  );
+  
+  $form['kaltura_partner_settings']['kaltura_partner_cms_email'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Email'),
+    '#default_value' => variable_get('kaltura_partner_cms_email', ''),
+//    '#attributes' => $readonly_attr,      
+    '#description' => t('This value must match your Kaltura server settings.'),
+  );
+  
+  $form['kaltura_partner_settings']['kaltura_partner_cms_password'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Password'),
+    '#default_value' => variable_get('kaltura_partner_cms_password', ''),
+//    '#attributes' => $readonly_attr,    
+    '#description' => t('This value must match your Kaltura server settings.'),
+  );
+  
+  if (!empty($partner_exist)) {
+    $kmc_url = trim(variable_get('kaltura_server_url', 'http://www.kaltura.com'), '/') .'/kmc' ;
+    $form['kaltura_partner_settings']['kaltura_upd_data'] = array(
+      '#type' => 'item',
+      '#value' => t('You can update your email and password via Kaltura Management Console here: ') . l($kmc_url, $kmc_url, array( 'attributes' => array( 'target' => '_blank' ) ))
+    );
+  }   
+  
+  if (variable_get('kaltura_partner_id', '') == '') {
+    $form_state['storage']['submit'] = 'ImportPartner';
+    $form['kaltura_registration']['buttons']['import_partner'] = array(
+      '#type' => 'button',
+      '#title' => 'Complete Installation',
+      '#value' => 'Complete Installation',
+      '#default_value' => 'Complete Installation',
+      '#weight' => 40,
+    );
+  } /* if (variable_get('kaltura_partner_id', '') == '') */
+  
+  $form['kaltura_partner_settings']['kaltura_subp_id'] = array(
+    '#type' => 'hidden', 
+    '#title' => t('Kaltura Sub-Partner Id'),
+    '#default_value' => variable_get('kaltura_subp_id', ''),
+    '#size' => 20,
+    '#maxlength' => 10
+  );
+  
+  /**
+   * This test always returns true, right?
+   */
+  if (variable_get('kaltura_local_registration', 0) != 1 || 1) {
+    $form['kaltura_partner_settings']['kaltura_secret'] = array(
+      '#type' => 'hidden', 
+      '#title' => t('Kaltura Secret'),
+      '#default_value' => variable_get('kaltura_secret', ''),
+      '#size' => 60,
+      '#maxlength' => 64
+    );
+    
+    $form['kaltura_partner_settings']['kaltura_admin_secret'] = array(
+      '#type' => 'hidden', 
+      '#title' => t('Kaltura Admin Secret'),
+      '#default_value' => variable_get('kaltura_admin_secret', ''),
+      '#size' => 60,
+      '#maxlength' => 64
+    );
+  } /* ALWAYS TRUE: if (variable_get('kaltura_local_registration', 0) != 1 || 1) */
+  
+  $form['kaltura_partner_settings']['kaltura_server_url'] = array(
+    '#type' => 'hidden', 
+    '#title' => t('Kaltura Server URL'),
+    '#default_value' => variable_get('kaltura_server_url', KalturaHelpers::getKalturaServerUrl()),
+    '#size' => 100,
+    '#maxlength' => 64
+  );
+  
+  /* notification settings fieldset */
+  $notification_settings = kaltura_notifications_settings_form();
+  $form['kaltura_notification_settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Kaltura to Drupal Notification Settings'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  foreach ($notification_settings as $name => $form_element) {
+    $form['kaltura_notification_settings'][$name] = $form_element;
+  }
+
+  /* credits / backlinks */
+  $form['kaltura_credits'] = array(
+     '#type' => 'fieldset',
+     '#title' => 'Credits',
+     '#collapsible' => TRUE,
+     '#collapsed' => TRUE,
+  );
+
+  $text = '<b>Open Source Video Links</b>'. PHP_EOL;
+  $text .= 'Kaltura invests a great deal of effort in the open source community, and specifically in the open source video movement.';
+  $text .= 'The following two links will be included within the video player in order to further promote Kaltura and its efforts in the open video space. ';
+  $text .= 'We hope that you will join us by including these links in the player.'. PHP_EOL;
+  $text .= l('open source video', 'http://corp.kaltura.com/download') . PHP_EOL . l('video platform', 'http://corp.kaltura.com/technology/');
+
+  $form['kaltura_credits']['kaltura_credits_text'] = array(
+    '#type' => 'item',
+    '#value' => nl2br($text),
+  );
+
+  $form['kaltura_credits']['kaltura_display_credits'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Include links in player'),
+    '#option' => t('Include links in player'),
+    '#default_value' => variable_get('kaltura_display_credits', 1),
+  );
+
+  $form['kaltura_help_message'] = array(
+    '#type' => 'item',
+    '#value' => t('Please feel free to ') . l('contact us', 'http://corp.kaltura.com/support/form/project/16', array( 'attributes' => array( 'target' => '_blank' ) )) . t(' with any questions.')
+  );
+  
+  $form['#submit'][] = 'kaltura_settings_form_submit' ;
+
+  return system_settings_form($form);
+}
+
+/**
+ * Validation handler for kaltura_settings_form() 
+ */
+function kaltura_settings_form_validate($form, &$form_state) {
+  if ( !valid_url($form_state['values']['kaltura_partner_url2'], TRUE) ) {
+    form_set_error('kaltura_partner_url2', t('Notification URL should be a valid URL, but %partner_url is not.', array('%partner_url' => $form_state['values']['kaltura_partner_url2'])));
+  }
+  try {
+    // test access credentials
+    $config = Kalturahelpers::getServiceConfiguration();
+    // we're still in validate, so the changed values aren't
+    // committed to $form_state['storage'] yet
+    $config->partnerId =  variable_get('kaltura_partner_id', '') ;
+    $config->serviceUrl = variable_get('kaltura_server_url', '');
+    $client = new KalturaClient($config);
+    $result = $client->partner->getSecrets(
+      $config->partnerId, 
+      $form_state['values']['kaltura_partner_cms_email'], 
+      $form_state['values']['kaltura_partner_cms_password']
+    );
+    drupal_set_message(t('Kaltura credentials verified against !kaltura_url.', array('!kaltura_url' => $config->serviceUrl)));
+  }
+  catch ( Exception $ex ) {          
+    $targs = array('%message' => $ex->getMessage(), '%file' => $ex->getFile(), '%line' => $ex->getLine(), '%code' => $ex->getCode() );
+    form_set_error('', t('Kaltura credentials failed login: %message', $targs ));
+    watchdog('kaltura', 'Unable to verify Kaltura credentials: %message', $targs, WATCHDOG_ERROR);
+  }
+}
+
+/**
+ * Submit handler for kaltura_settings_form()
+ */
+function kaltura_settings_form_submit($form, &$form_state) {
+  if ( $form_state['values']['kaltura_notification_type'] ) {
+
+  }
+  if (isset($form_state['values']['kaltura_notification_type']) && $form_state['values']['kaltura_partner_url2']) {
+    // TODO: update partner settings with notification type
+    $url2 = $form_state['values']['kaltura_partner_url2'] .'/?q=kaltura/notification_handler';
+    if ($form_state['values']['kaltura_notification_type'] == 1) {
+      $not_type = 3;
+    }
+    else {
+      $not_type = 2;
+    }
+    try {
+      $result = kaltura_update_kaltura_partner($not_type, $url2);
+      if (!$result->id) {
+        if ( isset( $result['error']['code'] ) ) {
+          throw new Exception($result['error']['desc'], $result['error']['code']);
+        }
+        else {
+          throw new Exception('Updating notification settings on Kaltura server failed.');
+        }
+      }
+      /* if notification URL has changed, or notification type is 3 */
+      if ($form_state['values']['last_notification_url'] != $form_state['values']['kaltura_partner_url2'] || $not_type == 3) {
+        variable_set('kaltura_notification_status', 0);
+        list($status, $text) = kaltura_test_notification_config();
+        if ($status == FALSE) {
+          drupal_set_message(t('Notification test failed. The URL you specified is not valid. Please make sure it is correct and save the settings again.'), 'error');
+        }
+        else {
+          // drupal_set_message(t('Notification test was successful.')); /* Uncomment when [#1025090] is resolved. */
+        }
+      }
+    }
+    catch ( Exception $ex ) {
+      drupal_set_message(t('Error: %message when updating notification settings.', array('%message' => $ex->getMessage())), 'error');
+      watchdog('kaltura', 'Error @message updating notification settings.<br />Backtrace:<pre>!trace</pre>', array('@message' => $ex->getMessage(), '!trace' => $ex->getTrace()));
+    }
+  }  
+}
+
+/*
+ * Implementation of hook_form_alter().
+ */
+function kaltura_form_alter(&$form, &$form_state, $form_id) {
+  if (variable_get('kaltura_partner_id', '') == '') {
+    if ($form_id == 'kaltura_settings_form') {
+      unset($form['buttons']['submit']);
+      unset($form['buttons']['preview']);
+      unset($form['buttons']['reset']);
+    }
+  }
+}
+
+/*
+ * callback function for url admin/settings/kaltura/import
+ *CMAC
+ *changes
+ * KalturaEntryFilter changed to KalturaMediaEntryFilter
+ * this may need some reworking
+ */
+function kaltura_import_entries_page() {
+  // initialise variables
+  $foundFlag = true;      // set to false if there are no entries
+  $enabledFlag = false;     // set to true if mix or media node is enabled
+  $entries = array();     // mix entries
+  $mediaEntries = array();  // media entries
+  $entries_need_import = array();
+  $each_page=30;
+  $total = 0;
+  $mediaTotal = 0;
+  $finished = false;  
+  $current_page = 1;  
+  
+  if ($_POST['op'] == 'import selected') {
+    kaltura_import_entries($_POST['entries_to_import']);
+    drupal_goto('admin/settings/kaltura/import');
+  }
+  if (variable_get('kaltura_partner_id', '') == '') {
+    return t('You have not configured your partner details yet. Import cannot be performed until you setup your partner details');
+  }
+  $get_entries = module_exists('node_kaltura_entry');
+  $get_mixes = module_exists('node_kaltura_mix');
+  
+  if (empty($_GET['p'])) {
+    $_GET['p'] = 1;
+  }
+  else {
+    $current_page = $_GET['p'];
+  }
+  
+  while (!$finished) {
+    set_time_limit(30); 
+    //get the mix entries
+    if ($get_mixes) {
+      $filter = new KalturaMixEntryFilter();
+      list($total, $entries) = kaltura_get_my_entries($filter, KalturaEntryType::MIX, $each_page, $current_page);
+      if($total==0) {
+        $foundFlag = false;
+      }
+      $enabledFlag = true;
+    }
+    // get the media entries
+    if ($get_entries) {
+      $filter = new KalturaMediaEntryFilter();
+      list($mediaTotal, $mediaEntries) = kaltura_get_my_entries($filter, KalturaEntryType::MEDIA_CLIP, $each_page, $current_page);
+      if($mediaTotal==0)$foundFlag=false;
+      $enabledFlag = true;
+    }
+    if(!$enabledFlag) {
+      return t('Can\'t import entries, you did not enable the node_kaltura_entries module.');
+    }
+    
+    $entries_need_import = array_merge($entries_need_import, $entries, $mediaEntries);
+
+    //list($total, $each_page, $entries) = kaltura_get_my_entries($filter, $each_page = 30, $_GET['p']);
+    if ($entries === NULL) {
+      return t('No entries found.');
+    }
+    $entries_need_import = kaltura_remove_existing_entries($entries_need_import);
+    
+    if (count($entries_need_import) >= $each_page) {
+      $finished = true;
+    }
+    
+    if (($mediaTotal < $current_page * $each_page) && ($total < $current_page * $each_page)) {
+      $finished = true;
+    }
+    $current_page++;
+  } /* while(!$finished) */
+  
+  if (!count($entries_need_import)) {
+    return t('No entries needed to be imported.');
+  }
+  
+  if (count($entries_need_import) > $each_page) {
+    $multi_dim = array_chunk  ( $entries_need_import  , $each_page, true );
+    $entries_need_import = $multi_dim[0];
+  }
+/*  
+  if (count($entries_need_import) < $each_page) {
+    list($second_count, $second_page) = kaltura_get_my_entries($filter, $each_page, $_GET['p'] + 1);
+    $new_entries_need_import = kaltura_remove_existing_entries($second_page);
+    if (is_array($new_entries_need_import) && $second_page !== NULL) {
+      foreach ($new_entries_need_import as $eid => $entry) {
+        $entries_need_import[$eid] = $entry;
+        if (count($entries_need_import) == $each_page) {
+          break;
+        }
+      }
+    }
+  }
+*/
+  if (($total+$mediaTotal) > $each_page) {
+    $pages = ceil(($total+$mediaTotal)/$each_page);
+    for ($start = 1;$start <= $pages;$start++) {
+      if ($start == $_GET['p']) {
+        $pager .= '<a>'. $start .'</a>';
+      }
+      else {
+        $pager .= l($start, 'admin/settings/kaltura/import', array('query' => 'p='. $start));
+      }
+      $pager .= '&nbsp;';
+    }
+  }
+  if (is_array($entries_need_import) && count($entries_need_import)) {
+    foreach ($entries_need_import as $entry => $details) {
+      $entries_options[$details['id']] = $details['id'] .': '. 
+        $details['name'] .' ('. (($details['type'] == 2)? 'mix': 'entry') .')';
+    }
+  }
+  else {
+    $entries_options = array();
+  }
+  $output = drupal_get_form('kaltura_create_entries_form', array($entries_options));
+  return $pager . $output . $pager;
+}
+
+/*
+ * helper function that uses kaltura_get_entries() to retreive a list of specific entries
+ * belongs to the partner, and call kaltura_import_entry() for each of the retreived list
+ */
+function kaltura_import_entries($entries) {
+  $entries_list = implode(',', $entries);
+  $my_entries = kaltura_get_entries($entries_list, count($entries), true);
+  
+  foreach ($my_entries->objects as $entry) {
+    kaltura_import_entry($entry);
+  }
+  drupal_set_message('<b>Please Note: All imported nodes are not yet published (node status 0)</b>');
+}
+
+/*
+ * helper function that gets an entry retreived from Kaltura
+ * builds a node object according to entry, and invokes node_insert to save the node
+ */
+function kaltura_import_entry($entry_details) {
+  global $user;
+  $node = new stdClass();
+  if ($entry_details->type == 1) {
+    $type = 'entry';
+  }
+  elseif ($entry_details->type == 2) {
+    $type = 'mix';
+  }
+  else {
+    $type = '';
+  }
+  $node->type = 'kaltura_'. $type;
+  $node->title = $entry_details->name;
+  $node->kaltura_entryId = $entry_details->id;
+  $node->uid = $user->uid;
+  $node->body = '';
+  $node->status = 0;
+  $node->created = time();
+  $node->comment = FALSE;
+  $node->changed = time();
+  $node->promote = 0;
+  $node->sticky = 0;
+  $node->kstatus = $entry_details->status;
+  $node->kaltura_entry_data = serialize($entry_details);
+  $node->kaltura_tags = $entry_details->tags;
+  $node->kaltura_admin_tags = '';
+  $node->kaltura_media_type = $entry_details->mediaType;
+  $node->kaltura_duration = $entry_details->duration;
+  $node->kaltura_thumbnail_url = $entry_details->thumbnailUrl;
+  $node->kaltura_partner_data = 'imported '. $type;
+  //$node->kaltura_source = $entry_details['source'];
+  //$node->kaltura_source_id = $entry_details['sourceId'];
+  //$node->kaltura_source_link = $entry_details['sourceLink'];
+  $node->kaltura_width = $entry_details->width;
+  $node->kaltura_height = $entry_details->height;
+  $node->kaltura_download_url = $entry_details->downloadUrl;
+  //$node->kaltura_media_date = $entry_details['mediaDate'];
+  $node->kaltura_views = $entry_details->views;
+  $node->kaltura_plays = $entry_details->plays;
+  $node->kaltura_votes = $entry_details->votes;
+  $node->kaltura_rank = $entry_details->rank;
+  $node->kaltura_total_rank = $entry_details->totalRank;
+  node_save($node);
+  module_invoke('node_kaltura_'. $type, 'hook_insert', $node);
+  drupal_set_message('Kaltura item imported: '. l($node->title, 'node/'. $node->nid) .' (id: '. $node->kaltura_entryId .')');
+}
+
+/*
+ * helper function to provide form fields containing all entries for import
+ * each entry as checkbox option
+ */
+function kaltura_create_entries_form($form) {
+  $args = func_get_args();
+  $entries_options = $args[1][0];
+  $form['entries_to_import'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Choose the entries you want to import'),
+    '#options' => $entries_options,
+  );
+  $form['import_now'] = array(
+    '#type' => 'submit',
+    '#title' => t('import selected'),
+    '#value' => t('import selected'),
+  );
+  return $form;
+}
+
+/*
+ * helper functuion to get all entries of partner from Kaltura's DB
+ * TODO
+ * CMAC
+ * changes:
+ * now retrieving all media entries - needs to import mix entries as well
+ */
+function kaltura_get_my_entries($filter, $type, $page_size = 30, $page = 1) {
+  $isAdmin = 1;
+  $session_user = KalturaHelpers::getSessionUser();
+  $kaltura_client = KalturaHelpers::getKalturaClient($isAdmin); // this is admin task and should be able to import all entries in the account
+  $pager_filter = new KalturaFilterPager();
+  $pager_filter->pageIndex = $page;
+  $pager_filter->pageSize = $page_size;
+  //$result = $kaltura_client->listMyEntries($session_user, $filter, 0, $page_size, $page);
+  switch($type){
+    case KalturaEntryType::MIX:
+      $result = $kaltura_client->mixing->listAction($filter,$pager_filter);
+      break;
+    case KalturaEntryType::MEDIA_CLIP:
+      $filter->mediaTypeEqual = KalturaEntryType::MEDIA_CLIP;
+      $result = $kaltura_client->media->listAction($filter,$pager_filter);
+      break;
+  }
+  
+  if ($result->totalCount > 0) {
+    $count = $result->totalCount;
+    //$each_page = $result['result']['page_size'];
+    if (is_array($result->objects) && count($result->objects)) {
+      foreach ($result->objects as $entry) {
+        $returned_entries[$entry->id] = array(
+          'id' => $entry->id,
+          'name' => $entry->name,
+          'type' => $entry->type,
+        );
+      }
+    }
+    return array($count, $returned_entries);
+  }
+  else {
+    return array(0, array());
+  }
+}
+
+/*
+ * helper function that recieves a list of entries, and returns a new list
+ * which does not contain entries that are already represented as nodes
+ */
+function kaltura_remove_existing_entries($entries) {
+  $count = 0;
+  $new_entries = array();
+  if (is_array($entries) && count($entries)) {
+    foreach ($entries as $entry) {
+      $sel = 'SELECT COUNT(nid) n FROM {node_kaltura} WHERE kaltura_entryId = \'%s\'';
+      $result = db_fetch_object(db_query($sel, $entry['id']));
+      if ($result->n == 0) {
+        $new_entries[] = $entry;
+      }
+      else {
+        $count++;
+      }
+    }
+  }
+  return $new_entries;
+}
+
+/*
+ * helper function that checks the drupal cron job status
+ * cron job is required to collect statictics about kaltura items
+ */
+function kaltura_test_cron_job_status() {
+  $cron_last = variable_get('cron_last', NULL);
+  if (!$cron_last) {
+    return array(
+      FALSE,
+      t('cron has not run.') .' '.
+      t('If you do not configure cron to run regularly, statistics about kaltura items will not be updated.')
+    );
+  }
+  else {
+    return array(
+      TRUE,
+      t('cron has run.') .' '.
+      t('Verify that you have a cron job configured, so you don\'t need to run it manually.') .'<br />'.
+      t('Statistics about kaltura items will only be updated at cron run.')
+    );
+  }
+}
+
+/**
+ * helper function that tests the notification status of the module
+ *
+ * this function tries to close a loop with the kaltura server in a
+ * "real-time" test.  The notification handler sets a variable in the
+ * DB before the this function run ends, therefore we need to use the
+ * kaltura_variable_get_real() function to check the variable status
+ * in the DB and not in the $_GLOBALS which are set before this
+ * function even start
+ *
+ * @TODO in KalturaClient we need a new method:
+ *
+ *  function testNotification($kalturaSessionUser)
+ *  {
+ *    $params = array();
+ *    $result = $this->hit("testnotification", $kalturaSessionUser, $params);
+ *    return $result;
+ *  }
+ * 
+ * @TODO http://drupal.org/node/1025090
+ */
+function kaltura_test_notification_config() {
+  return array(TRUE, t('Test call not yet implemented; see !test_call_issue', array('!test_call_issue' => l('[#1025090]', 'http://drupal.org/node/'. 1025090))));
+/*
+  if (kaltura_variable_get_real('kaltura_notification_status', 0) == 0) {
+    $session_user = KalturaHelpers::getSessionUser();
+    $kaltura_client = KalturaHelpers::getKalturaClient();
+    $result = $kaltura_client->testNotification($session_user);
+    sleep(3); // 
+  }
+  if (kaltura_variable_get_real('kaltura_notification_status', 0) === 1) {
+    return array(TRUE, 'Drupal server receives notification from Kaltura server.');
+  }
+  return array(FALSE, 'Drupal server fails to receive notifications from Kaltura. Please fix your configuration or disable server notifications.');
+*/
+}
+
+/*
+ * Replace default Drupal's variable_get() function with a "real-time" one.
+ *
+ * This function checks a variable status in the DB (not from $_GLOBALS['conf']).
+ * 
+ * TODO: This smells funny. Presumably it's here because $conf is
+ * already set when kaltura_test_notification_config() is called, and
+ * we need to allow the Kaltura server to ping us back and
+ * variable_set('kaltura_notification_status',1), then read the stored
+ * value. Check if it's used elsewhere, and why. Consider a straight
+ * SQL check against the variables table to replace this.
+ */
+function kaltura_variable_get_real($var, $default) {
+  $sql = "SELECT * FROM {variable} WHERE name = '%s'";
+  $result = db_fetch_object(db_query($sql, $var));
+  if (!$result) {
+    return $default;
+  }
+  return unserialize($result->value);
+}
+
+/**
+ * Alternate XML verification function.
+ *
+ * @TODO rename to kaltura_alternate_xml_verification()
+ */
+function alternate_xml_verification($filename) {
+  return array(
+    TRUE,
+    t('crossdomain.xml is in place and seems to be OK')
+  );
+}
+
+/**
+ * helper function that checks if crossdomain.xml is in the right place
+ */
+function kaltura_test_crossdomain() {
+  global $base_url ;
+  $cd_req = drupal_http_request($base_url .'/crossdomain.xml');
+  if ( $cd_req->code == '200' ) {
+    return kaltura_parse_crossdomain($cd_req->data);
+  }
+  else {
+    // fall back to fetching and retrieving file contents (should we
+    // succeed if HTTP request has failed, though?
+    $filename = $_SERVER['DOCUMENT_ROOT'] .'/crossdomain.xml';
+    if ( $cd_xml = file_get_contents($filename) ) {
+      return kaltura_parse_crossdomain($cd_xml) ;
+    }
+    else {
+      return array(
+        FALSE,
+        t('crossdomain.xml file could not be found in your site\'s root directory') .' ['. $filename .']' .
+        t('Please read ') . l('here', 'admin/help/kaltura')
+      );
+    }
+  }
+}
+
+/**
+ * helper function that checks if crossdomain.xml says the right things
+ */
+function kaltura_parse_crossdomain($crossdomain_xml) {
+  if (!function_exists('simplexml_load_string')) {
+    return kaltura_alternate_xml_verification($filename);
+  }
+  $cd_xml_content = simplexml_load_string($crossdomain_xml);
+  foreach ($cd_xml_content->children() as $child) {
+    $atts = $child->attributes();
+    if ($atts['domain'] == '*' || $atts['domain'] == '*.kaltura.com') {
+      $kaltura_ok = TRUE;
+    }
+    if ($atts['headers'] == '*' && ($atts['domain'] == '*' || $atts['domain'] == '*.kaltura.com')) {
+      $headers_ok = TRUE;
+    }
+  }
+  if ($kaltura_ok && $headers_ok) {
+    return array(
+      TRUE,
+      t('crossdomain.xml is in place and seems to be OK')
+    );
+  }
+  else {
+    return array(
+      FALSE,
+      t('crossdomain.xml is in place, but it is probably not configured properly') .'<br />'.
+      t('Please read ') . l('here', 'admin/help/kaltura')
+    );
+  }
+}
+
+/**
+ * Helper function that updates partner notification settings at
+ * Kaltura server.
+ */
+function kaltura_update_kaltura_partner($notifications_config = 2, $notification_url = '') {
+  $partner = new KalturaPartner();
+
+  if ( empty($notification_url) ) {
+    $partner->notificationUrl = url('kaltura/notification_handler', array('absolute' => TRUE));
+  }
+  else {
+    $partner->notificationUrl = $notification_url ;
+  }
+
+  $partner->allowMultiNotification = '1';
+  $partner->notify = 1;
+  $partner->notificationsConfig = '*='. $notifications_config;
+  //$partner->id = variable_get('kaltura_partner_id', '');
+
+  $session_user = KalturaHelpers::getSessionUser();
+  $kaltura_client = KalturaHelpers::getKalturaClient(1);
+  
+  $cms_pass = variable_get('kaltura_partner_cms_password', '');
+
+  if ($kaltura_client) {
+    try {
+      watchdog('kaltura', 'Updating Kaltura Partner settings (!partner, !password).', array('!partner' => print_r($partner, 1), '!password' => $cms_pass), WATCHDOG_NOTICE);
+      $result = $kaltura_client->partner->update($partner, $cms_pass);
+      //$result = $kaltura_client->updatePartner($session_user, $partner);
+    } catch ( Exception $ex ) {
+      drupal_set_message( t('Kaltura %code Exception: %message<br /><small>%file ln %line</small>', array('%message' => $ex->getMessage(), '%file' => $ex->getFile(), '%line' => $ex->getLine(), '%code' => $ex->getCode() ) ), 'error' );
+      //if ( module_exists('devel') ) {
+      // dpm( $ex->getTrace(), 'Exception stack trace' );
+      //}
+      watchdog('kaltura', 'Registration error: @message', array('@message' => $ex->getMessage()));
+      watchdog('kaltura', 'Backtrace for failed registration: <pre>@trace</pre>', array('@trace' => $ex->getTrace()));
+    }
+  }
+  return $result;
+}
+
+/**
+ * @TODO: Settings form in URL admin/settings/kaltura/general/notifications
+ */
+function kaltura_notifications_settings_form() {
+  global $base_url;
+
+  $notification_types = array(
+    //'1' => 'only server side notifications',
+    '2' => 'only client side notifications',
+    '3' => 'both server & client notifications'
+  );
+
+  $notification_type_description = t('Enabling server notifications allows the Kaltura video platform to update your Drupal server about the status of '.
+                                   'the media content. This is especially useful when uploading content in various formats that needs to be transcoded. '.
+                                   'In order to support server side notifications, your server must be publicly available on the internet.');
+
+  $form['kaltura_notification_type'] = array(
+    '#type' => 'checkbox',
+    '#options' => 'Enable server side notifications',
+    '#description' => $notification_type_description,
+    '#title' => t('Enable server side notifications'),
+    '#default_value' => variable_get('kaltura_notification_type', 0),
+  );
+
+  $form['kaltura_partner_url2'] = array(
+    '#type' => 'textfield',
+    '#title' => 'Notification URL',
+    '#description' => t('Your Drupal site base URL; !notification_path will be appended.', array('!notification_path' => '/?q=kaltura/notification_handler')),
+    '#default_value' => variable_get('kaltura_partner_url2', $base_url),
+  );
+
+  $form['last_notification_url'] = array(
+    '#type' => 'hidden',
+    '#value' => variable_get('kaltura_partner_url2', ''),
+  );
+  return $form;
+  return system_settings_form($form);
+}
+
+function kaltura_notifications_settings_form_submit() {
+
+}
+
+/*
+ * helper function that tries to open session with the kaltura server
+ *
+ * used to verify partner details, and display errors if there are
+ *
+ * CMAC
+ * changed
+ * added new variable_get statements required for the api calls
+ * updated KalturaClient creation process
+ * changed API calls
+ *
+ * TODO check correct format for error checking of result
+ */
+function kaltura_check_server_status($admin) {
+  //get the variables we will need to start the session
+/*
+  $partner_id = variable_get('kaltura_partner_id', '');
+  $secret = variable_get('kaltura_secret', '');
+  $admin_secret = variable_get('kaltura_admin_secret', '');
+
+  $session_user = KalturaHelpers::getSessionUser();
+  $config = KalturaHelpers::getServiceConfiguration();
+  $config->partnerId = $partner_id;
+  $kaltura_client = new KalturaClient();
+  $kaltura_client->setConfig($config);
+
+  if ($admin == 1) {
+    $result = $kaltura_client->session->start($partner_id, $secret, $session_user->screenName);
+  }
+  else {
+    $result = $kaltura_client->session->start($partner_id, $admin_secret, $session_user->screenName, KalturaSessionType::ADMIN);
+  }
+*/  
+  
+  try {
+    $result = KalturaHelpers::getKalturaClient($admin);
+    $kaltura_status = TRUE;
+    $kaltura_error = "";
+  }
+  catch(Exception $ex) {
+    $kaltura_status = FALSE;
+    $kaltura_error = $ex->getMessage();
+  }
+  
+  /*
+    if ($result[]) {
+      $kaltura_status = FALSE;
+      $kaltura_error = $result['error'][0]["code"] .' '. $result['error'][0]["desc"];
+    }
+    else {
+    }
+  */
+  return array($kaltura_status, $kaltura_error);
+}
+
+/*
+ * helper function to generate a cms password
+ *
+ * cms is the "administration panel" for kaltura's partners in kaltura's website
+ */
+function kaltura_generate_cms_password() {
+  $pass = '';
+  $pass = md5(time() . $_SERVER['REMOTE_ADDR']);
+  $pass = drupal_substr($pass, 0, 8);
+  return $pass;
+}
diff -ur /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/includes/kaltura.themeing.inc ./includes/kaltura.themeing.inc
--- /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/includes/kaltura.themeing.inc	2011-01-06 23:40:44.000000000 +1300
+++ ./includes/kaltura.themeing.inc	2011-01-14 14:11:27.000000000 +1300
@@ -1,5 +1,5 @@
 <?php
-// $Id: kaltura.themeing.inc,v 1.1.2.5.2.3 2011/01/06 10:40:44 xuriz Exp $
+// $Id: kaltura.themeing.inc,v 1.1.2.5.2.1 2010/11/17 03:04:23 xuriz Exp $
 
 /*
  * @file
@@ -672,7 +672,8 @@
           <ul id="sidemenu">
           <li id="tab-kaltura"><a class="current" href="'. url($_GET['q']) .'">Add Interactive Video</a></li>
           <li id="tab-kaltura_browse"><a href="'. url('kaltura/entries/allow-insert/'. $field_id, array( 'query' => array( 'filter' => $add_filter, 'cwurl' => url($_GET['q']) ) )) .'">Browse Interactive Videos</a></li>
-          <li class="close"><span class="close" href="#" onclick="window.top.kalturaCloseModalBox();return false;">&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
+          <li><span>xzczczczcxxz</span></li>
+          <li><span class="close" href="#" onclick="window.top.kalturaCloseModalBox();return false;">&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
           </ul>
       </div>';
   }
@@ -743,10 +744,10 @@
   exit;
 }
 
-/**
- * Theme for kaltura/simple_editor 
+/*
+ * theme for kaltura/simple_editor 
  */
-function theme_kaltura_simple_editor($theme_params, $no_refresh) {
+function theme_simple_editor($theme_params, $no_refresh) {
   $javascript =' 
   function onSimpleEditorBackClick(modified) {
     if (modified == 0) { 
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/js: CVS
Only in ./js: admin.js
diff -ur /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/kaltura.install ./kaltura.install
--- /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/kaltura.install	2011-01-10 16:04:39.000000000 +1300
+++ ./kaltura.install	2011-01-14 14:11:27.000000000 +1300
@@ -1,5 +1,5 @@
 <?php
-// $Id: kaltura.install,v 1.2.2.5.2.3 2011/01/10 03:04:39 xuriz Exp $
+// $Id: kaltura.install,v 1.2.2.5.2.2 2010/07/09 00:39:21 xuriz Exp $
 
 /*
  * @file
@@ -7,6 +7,8 @@
  *
  */
 
+$GLOBALS['_kaltura_client_folder'] = drupal_get_path('module', 'kaltura') .'/kaltura_client/';
+
 /**
  * Implementation of hook_schema().
  *
@@ -192,7 +194,7 @@
  * Implementation of hook_install().
  */
 function kaltura_install() {
-  $_kaltura_client_folder  = drupal_get_path('module', 'kaltura') .'/kaltura_client/';
+  global $_kaltura_client_folder;
   require_once($_kaltura_client_folder .'kaltura_settings.php');
   drupal_install_schema('kaltura');
   drupal_set_message('<b>To '. l('complete installation', 'admin/settings/kaltura/general') .' of the Kaltura All in One Video Module installation, '.
@@ -204,7 +206,7 @@
  */
 function kaltura_uninstall() {
   // Remove tables.
-  $_kaltura_client_folder  = drupal_get_path('module', 'kaltura') .'/kaltura_client/';
+  global $_kaltura_client_folder;
   require_once($_kaltura_client_folder .'kaltura_settings.php');
   drupal_uninstall_schema('kaltura');
   drupal_set_message('Kaltura module was uninstalled.');
diff -ur /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/kaltura.module ./kaltura.module
--- /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/kaltura.module	2011-01-06 23:07:55.000000000 +1300
+++ ./kaltura.module	2011-01-14 14:11:27.000000000 +1300
@@ -1,5 +1,5 @@
 <?php
-// $Id: kaltura.module,v 1.2.2.7.2.4 2011/01/06 10:07:55 xuriz Exp $
+// $Id: kaltura.module,v 1.2.2.7.2.3 2010/11/17 01:14:57 xuriz Exp $
 
 /**
  * @file
@@ -12,36 +12,36 @@
  */
  
 function kaltura_init() {
-	$GLOBALS['_kaltura_client_folder'] = drupal_get_path('module', 'kaltura') .'/kaltura_client/';
-	
-	module_load_include('php', 'kaltura', 'kaltura_client/KalturaClient');
-	module_load_include('php', 'kaltura', 'kaltura_client/kaltura_logger');
-	module_load_include('php', 'kaltura', 'kaltura_client/kaltura_settings');
-	module_load_include('php', 'kaltura', 'kaltura_client/kaltura_helpers');
-	module_load_include('php', 'kaltura', 'kaltura_client/kaltura_notification_client');
-	
-	drupal_add_css(drupal_get_path("module", "kaltura") ."/style/kaltura.css");
-	drupal_add_js(drupal_get_path("module", "kaltura") ."/js/kaltura.js");
-	drupal_add_js(drupal_get_path("module", "kaltura") ."/js/swfobject.js");
-	
-	
-	if (variable_get('kaltura_partner_id', '') != '') {
-		$server_url = (variable_get('kaltura_server_url', '') != '')? variable_get('kaltura_server_url', ''): KalturaSettings_SERVER_URL;
-		$GLOBALS['_kaltura_thumbnail_base_url'] = $server_url .'/p/'. variable_get('kaltura_partner_id', '') .'/sp/'. variable_get('kaltura_subp_id', '') .'/thumbnail';
-	}
-	
-	$editor_type = variable_get('kaltura_mix_roughcut_editor_type', KalturaSettings_DEFAULT_EDITOR);
-	
-	if ($editor_type == 'Advanced_Editor' || $editor_type == KalturaSettings_AE_CUSTOM || $editor_type == KalturaSettings_AE_UICONF_ID) {
-		variable_set('kaltura_editor_width',KalturaSettings_AE_WIDTH);
-		variable_set('kaltura_editor_height',KalturaSettings_AE_HEIGHT);		
-		variable_set('kaltura_editor_URL',KalturaSettings_AE_URL);
-	} else {
-		variable_set('kaltura_editor_width',KalturaSettings_SE_WIDTH);
-		variable_set('kaltura_editor_height',KalturaSettings_SE_HEIGHT);
-		variable_set('kaltura_editor_URL',KalturaSettings_SE_URL);
-	}
-	
+  $GLOBALS['_kaltura_client_folder'] = drupal_get_path('module', 'kaltura') .'/kaltura_client/';
+  
+  module_load_include('php', 'kaltura', 'kaltura_client/KalturaClient');
+  module_load_include('php', 'kaltura', 'kaltura_client/kaltura_logger');
+  module_load_include('php', 'kaltura', 'kaltura_client/kaltura_settings');
+  module_load_include('php', 'kaltura', 'kaltura_client/kaltura_helpers');
+  module_load_include('php', 'kaltura', 'kaltura_client/kaltura_notification_client');
+  
+  drupal_add_css(drupal_get_path("module", "kaltura") ."/style/kaltura.css");
+  drupal_add_js(drupal_get_path("module", "kaltura") ."/js/kaltura.js");
+  drupal_add_js(drupal_get_path("module", "kaltura") ."/js/swfobject.js");
+  
+  
+  if (variable_get('kaltura_partner_id', '') != '') {
+    $server_url = (variable_get('kaltura_server_url', '') != '')? variable_get('kaltura_server_url', ''): KalturaSettings_SERVER_URL;
+    $GLOBALS['_kaltura_thumbnail_base_url'] = $server_url .'/p/'. variable_get('kaltura_partner_id', '') .'/sp/'. variable_get('kaltura_subp_id', '') .'/thumbnail';
+  }
+  
+  $editor_type = variable_get('kaltura_mix_roughcut_editor_type', KalturaSettings_DEFAULT_EDITOR);
+  
+  if ($editor_type == 'Advanced_Editor' || $editor_type == KalturaSettings_AE_CUSTOM || $editor_type == KalturaSettings_AE_UICONF_ID) {
+    variable_set('kaltura_editor_width',KalturaSettings_AE_WIDTH);
+    variable_set('kaltura_editor_height',KalturaSettings_AE_HEIGHT);    
+    variable_set('kaltura_editor_URL',KalturaSettings_AE_URL);
+  } else {
+    variable_set('kaltura_editor_width',KalturaSettings_SE_WIDTH);
+    variable_set('kaltura_editor_height',KalturaSettings_SE_HEIGHT);
+    variable_set('kaltura_editor_URL',KalturaSettings_SE_URL);
+  }
+  
 }
 
 /*
@@ -49,12 +49,12 @@
  */
  
 function kaltura_perm() {
-	return array(
+  return array(
     'administer kaltura',
     'access kaltura widgets',
     'view Kaltura embed code',
     'clone kaltura mixes',
-	);
+  );
 }
 
 /*
@@ -96,6 +96,17 @@
     'type' => MENU_CALLBACK,
     'weight' => 0,
   );
+
+  $items['admin/settings/kaltura/install'] = array(
+    'title' => 'Kaltura',
+    'file' => 'includes/kaltura.admin.inc',
+    'description' => 'Server integration settings.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('kaltura_installation_form'),
+    'access arguments' => array('administer kaltura'),
+    'type' => MENU_CALLBACK,
+  );
+
   $items['kaltura/notification_handler'] = array(
     'title' => 'Drupal Notification Handler',
     'file' => 'includes/kaltura.notification.inc',
@@ -151,40 +162,40 @@
  * Implementation of hook_theme().
  */
 function kaltura_theme() {
-	$themes = array(
+  $themes = array(
     'kaltura_contribution_wizard' => array(
       'arguments' => array('themeParams' => NULL),
-	),
+  ),
     'kaltura_contribution_wizard_add' => array(
       'arguments' => array('themeParams' => NULL),
-	),
+  ),
     'kaltura_contribution_wizard_simple' => array(
       'arguments' => array('themeParams' => NULL),
-	),
+  ),
     'kaltura_simple_editor' => array(
       'arguments' => array('element' => NULL),
-	),
+  ),
     'kaltura_advanced_editor' => array(
       'arguments' => array('element' => NULL),
-	),
+  ),
     'kaltura_modal' => array(
       'arguments' => array('element' => NULL),
-	),
+  ),
     'kaltura_list_of_entries' => array(
       'arguments' => array('element' => NULL),
-	),
+  ),
     'kaltura_server_status' => array(
       'arguments' => array('element' => NULL),
-	),
+  ),
     'kaltura_contribution_wizard_field' => array(
       'arguments' => array('themeParams' => NULL),
-	),
+  ),
     'kaltura_maintenance_page' => array(
       'arguments' => array('text' => NULL),
-	),
-	);
+  ),
+  );
 
-	return $themes;
+  return $themes;
 }
 
 /*
@@ -193,29 +204,29 @@
  * used to call hooks exxposed by kaltura which other module implements
  */
 function kaltura_invoke($hook, $data = NULL) {
-	$hook = 'kaltura_'. $hook;
-	$return = module_invoke_all($hook, $data);
-	return $return;
+  $hook = 'kaltura_'. $hook;
+  $return = module_invoke_all($hook, $data);
+  return $return;
 }
 
 /*
  * Implementation of hook_search().
  */
 function kaltura_search($op, $keys = NULL) {
-	switch ($op) {
-		case 'search':
-			$query = kaltura_build_search();
-			$results = db_query($query, $keys);
-			while ($result = db_fetch_object($results)) {
-				$kaltura_results[] = array(
+  switch ($op) {
+    case 'search':
+      $query = kaltura_build_search();
+      $results = db_query($query, $keys);
+      while ($result = db_fetch_object($results)) {
+        $kaltura_results[] = array(
           'link' => l($result->nid, 'node/'. $result->nid),
           'title' => $result->nid,
-				);
-			}
-			return $kaltura_results;
-			break;
-		default:
-	}
+        );
+      }
+      return $kaltura_results;
+      break;
+    default:
+  }
 }
 
 /*
@@ -225,8 +236,8 @@
  * If we ever need to enhance the query, this is the place.
  */
 function kaltura_build_search() {
-	$q = 'SELECT nid FROM {node_kaltura} WHERE tags LIKE %\'%s\'% OR admin_tags LIKE %\'%s\'%';
-	return $q;
+  $q = 'SELECT nid FROM {node_kaltura} WHERE tags LIKE %\'%s\'% OR admin_tags LIKE %\'%s\'%';
+  return $q;
 }
 
 /**
@@ -237,23 +248,23 @@
  *
  */
 function kaltura_nodeapi(&$node, $op, $teaser) {
-	
-	$node_update_access = node_access('update', $node);
-	$show_embed = user_access('view Kaltura embed code');
-	switch ($op) {
-		case "load":
-			break;
-		case "view":
-			break;
-		case 'search result':
-			$node->body = kaltura_replace_tags($node->body, FALSE, TRUE);
-			break;
-		case "alter":
-			$node->body = kaltura_replace_tags($node->body, FALSE, FALSE, $node_update_access, $show_embed, $node->type);
-			$node->teaser = kaltura_replace_tags($node->teaser);
-			break;
-		default:
-	}
+  
+  $node_update_access = node_access('update', $node);
+  $show_embed = user_access('view Kaltura embed code');
+  switch ($op) {
+    case "load":
+      break;
+    case "view":
+      break;
+    case 'search result':
+      $node->body = kaltura_replace_tags($node->body, FALSE, TRUE);
+      break;
+    case "alter":
+      $node->body = kaltura_replace_tags($node->body, FALSE, FALSE, $node_update_access, $show_embed, $node->type);
+      $node->teaser = kaltura_replace_tags($node->teaser);
+      break;
+    default:
+  }
 }
 
 /*
@@ -265,51 +276,51 @@
  * wins and the theme widget is ignored
  */
 function kaltura_use_uiconf($default_uicid, $node_type, $theme_uicid, $media_type = 'roughcut') {
-	// invoke hook use_widget
-	$new_uicid = kaltura_invoke('use_uiconf', array($node_type, $media_type));
+  // invoke hook use_widget
+  $new_uicid = kaltura_invoke('use_uiconf', array($node_type, $media_type));
+
+  // if returned $wid from hooks, use it
+  if ($new_uicid) {
+    return $new_uicid[0];
+  }
+
+  // if no module implements the hook, and a theme widget was specified, return theme widget
+  if ($theme_uicid) {
+    return $theme_uicid;
+  }
+
+/*  if ($media_type == 'viewplaylist')
+  {
+    return KalturaSettings_DEFAULT_VIEWPLAYLIST_UICONF;
+  }
+*/  
+  // if no $wid from hooks or theme, check for widgets in settings, for specific type (entry, kshow, mix)
+  $widgets = new KalturaSettings;
+  if ($node_type == 'mix' || $node_type == 'roughcut') {
+    $uiconf_type = (user_access('edit own kaltura mixes'))? 'remix': 'view';
+  }
+  else {
+    //$uiconf_type = (user_access('edit kaltura items'))? 'remix': 'view';
+    $uiconf_type = 'view';
+  }
+  $default = kaltura_default_uiconf_by_type($media_type);
+  $widget = variable_get('kaltura_'. $media_type .'_'. $node_type .'_widget', $default);
 
-	// if returned $wid from hooks, use it
-	if ($new_uicid) {
-		return $new_uicid[0];
-	}
-
-	// if no module implements the hook, and a theme widget was specified, return theme widget
-	if ($theme_uicid) {
-		return $theme_uicid;
-	}
-
-/*	if ($media_type == 'viewplaylist')
-	{
-		return KalturaSettings_DEFAULT_VIEWPLAYLIST_UICONF;
-	}
-*/	
-	// if no $wid from hooks or theme, check for widgets in settings, for specific type (entry, kshow, mix)
-	$widgets = new KalturaSettings;
-	if ($node_type == 'mix' || $node_type == 'roughcut') {
-		$uiconf_type = (user_access('edit own kaltura mixes'))? 'remix': 'view';
-	}
-	else {
-		//$uiconf_type = (user_access('edit kaltura items'))? 'remix': 'view';
-		$uiconf_type = 'view';
-	}
-	$default = kaltura_default_uiconf_by_type($media_type);
-	$widget = variable_get('kaltura_'. $media_type .'_'. $node_type .'_widget', $default);
-
-
-	if (is_numeric($widget)) //we currently support names (to be fetched from static settings or numbers (real uiconf)
-	{
-		return $widget;
-	}
-	
-	if ($widgets->kdp_widgets[$media_type][$widget][$uiconf_type .'_uiconf'] != 'XXX') {
-		$ui_conf = $widgets->kdp_widgets[$media_type][$widget][$uiconf_type .'_uiconf'];
-	}
-	if ($ui_conf) {
-		return $ui_conf;
-	}
 
-	// if settings widget for specified type is XXX => not defined, use default
-	return $default_uicid;
+  if (is_numeric($widget)) //we currently support names (to be fetched from static settings or numbers (real uiconf)
+  {
+    return $widget;
+  }
+  
+  if ($widgets->kdp_widgets[$media_type][$widget][$uiconf_type .'_uiconf'] != 'XXX') {
+    $ui_conf = $widgets->kdp_widgets[$media_type][$widget][$uiconf_type .'_uiconf'];
+  }
+  if ($ui_conf) {
+    return $ui_conf;
+  }
+
+  // if settings widget for specified type is XXX => not defined, use default
+  return $default_uicid;
 }
 
 /*
@@ -317,73 +328,74 @@
  *
  */
 function kaltura_default_uiconf_by_type($media_type) {
-	switch ($media_type) {
-		case 'audio': $default = KalturaSettings_DEFAULT_AUDIO_PLAYER_UICONF; break;
-		case 'viewplaylist': $default = KalturaSettings_DEFAULT_VIEWPLAYLIST_UICONF; break;
-		case 'video': $default = KalturaSettings_DEFAULT_VIDEO_PLAYER_UICONF; break;
-		case 'roughcut': $default = KalturaSettings_DEFAULT_RC_PLAYER_UICONF; break;
-		case 'comment': $default = KalturaSettings_DEFAULT_COMMENT_PLAYER_UICONF; break;
-	}
-	return $default;
+  switch ($media_type) {
+    case 'audio': $default = KalturaSettings_DEFAULT_AUDIO_PLAYER_UICONF; break;
+    case 'viewplaylist': $default = KalturaSettings_DEFAULT_VIEWPLAYLIST_UICONF; break;
+    case 'video': $default = KalturaSettings_DEFAULT_VIDEO_PLAYER_UICONF; break;
+    case 'roughcut': $default = KalturaSettings_DEFAULT_RC_PLAYER_UICONF; break;
+    case 'comment': $default = KalturaSettings_DEFAULT_COMMENT_PLAYER_UICONF; break;
+  }
+  return $default;
 }
 
 /*
  * callback function for the kaltura/entries URL
  */
 function kaltura_list_entries() {
-	global $pager_page_array, $pager_total;
-	$args = func_get_args();
-	if ($args[0] == 'allow-insert' && $args[1]) {
-		drupal_add_css(drupal_get_path('module', 'kaltura') .'/style/kaltura.css', 'all');
-		$allow_insert = TRUE;
-		$field_name = $args[1];
-	}
-	$media_types = new KalturaSettings;
-	$title = 'Kaltura Content';
-	$filter_media = '';
-	if ($_GET['filter']) {
-		$filter_media = 'AND knode.kaltura_media_type = '. db_escape_string($_GET['filter']);
-		$title .= ' (filter by - '. $media_types->media_types_map[$_GET['filter']] .')' ;
-	}
-	drupal_set_title($title);
-	$node_count = db_fetch_object(db_query(db_rewrite_sql('SELECT COUNT(node.nid) c FROM {node} node LEFT JOIN {node_kaltura} knode on node.nid = knode.nid WHERE type like \'kaltura%\' AND status > 0 '. $filter_media, 'node', 'nid')));
-	$pager_total[0] = ceil($node_count->c/20);
-	if ($_GET['page']) {
-		$start = 20 * (int)$_GET['page'];
-		$pager_page_array[0] = $_GET['page'];
-	}
-	else {
-		$start = 0;
-	}
-	$get_all = 'SELECT node.nid,node.title,node.type,knode.kaltura_entryId,knode.kaltura_thumbnail_url FROM {node} node '.
+  global $pager_page_array, $pager_total;
+  $args = func_get_args();
+  if ($args[0] == 'allow-insert' && $args[1]) {
+    drupal_add_css(drupal_get_path('module', 'kaltura') .'/style/kaltura.css', 'all');
+    $allow_insert = TRUE;
+    $field_name = $args[1];
+  }
+  $media_types = new KalturaSettings;
+  $title = 'Kaltura Content';
+  $filter_media = '';
+  if ($_GET['filter']) {
+    $filter_media = 'AND knode.kaltura_media_type = '. db_escape_string($_GET['filter']);
+    $title .= ' (filter by - '. $media_types->media_types_map[$_GET['filter']] .')' ;
+  }
+  drupal_set_title($title);
+  $node_count = db_fetch_object(db_query(db_rewrite_sql('SELECT COUNT(node.nid) c FROM {node} node LEFT JOIN {node_kaltura} knode on node.nid = knode.nid WHERE type like \'kaltura%\' AND status > 0 '. $filter_media, 'node', 'nid')));
+  $pager_total[0] = ceil($node_count->c/20);
+  if ($_GET['page']) {
+    $start = 20 * (int)$_GET['page'];
+    $pager_page_array[0] = $_GET['page'];
+  }
+  else {
+    $start = 0;
+  }
+  $get_all = 'SELECT node.nid,node.title,node.type,knode.kaltura_entryId,knode.kaltura_thumbnail_url FROM {node} node '.
     'LEFT JOIN {node_kaltura} knode on node.nid = knode.nid WHERE (node.type = \'kaltura_entry\' OR node.type = \'kaltura_mix\') '. $filter_media .' AND status > 0 ORDER BY nid DESC LIMIT '. $start .', 20';
-	$result = db_query(db_rewrite_sql($get_all, 'node', 'nid'));
-	while ($node_nid = db_fetch_object($result)) {
-		$nodes[$node_nid->nid] = $node_nid;
+  $result = db_query(db_rewrite_sql($get_all, 'node', 'nid'));
+  while ($node_nid = db_fetch_object($result)) {
+    $nodes[$node_nid->nid] = $node_nid;
 
-	}
+  }
   $html = theme("kaltura_list_of_entries", $nodes, $allow_insert, $field_name);
-	$pager = '';
-	if (ceil($node_count->c/20) > 1) {
-		$pager = theme('pager', NULL, 20, 0, array(), ceil($node_count->c/20));
-	}
-	if ($allow_insert && $field_name) {
-		$html =     '<div> </div><div id="media-upload-header">
-	<ul id="sidemenu">
-	<li id="tab-kaltura"><a href="'. $_GET['cwurl'] .'">Add Interactive Video</a></li>
-	<li id="tab-kaltura_browse"><a class="current" href="'. url('kaltura/entries/allow-insert/'. $field_id) .'">Browse Interactive Videos</a></li>
-          <li class="close"><span class="close" href="#" onclick="window.top.kalturaCloseModalBox();return false;">&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
+  $pager = '';
+  if (ceil($node_count->c/20) > 1) {
+    $pager = theme('pager', NULL, 20, 0, array(), ceil($node_count->c/20));
+  }
+  if ($allow_insert && $field_name) {
+    $html =     '<div> </div><div id="media-upload-header">
+  <ul id="sidemenu">
+  <li id="tab-kaltura"><a href="'. $_GET['cwurl'] .'">Add Interactive Video</a></li>
+  <li id="tab-kaltura_browse"><a class="current" href="'. url('kaltura/entries/allow-insert/'. $field_id) .'">Browse Interactive Videos</a></li>
+          <li><span>xzczczczcxxz</span></li>
+          <li><span class="close" href="#" onclick="window.top.kalturaCloseModalBox();return false;">&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
         </ul>
     </div><div class="ktitle"><h3>'. $title .'</h3></div>'. $html;
-		$js = '$(document).ready(function() { '. PHP_EOL .'window.top.document.getElementById("kaltura_modal_iframe").className += " remove_overflow"; ';
-		$js .= PHP_EOL .'window.top.document.getElementById("kaltura_modal_iframe").scrolling = "";';
-		$js .= PHP_EOL .'window.top.document.getElementById("modalbox").style.height = "500px";';
-		$js .= PHP_EOL .'window.top.document.getElementById("kaltura_modal_iframe").height = "500";';
-		$js .= PHP_EOL .'window.top.document.getElementById("modalbox").className += " white_bg"; });';
-		echo theme('kaltura_modal', array('flashEmbed' => $html .'<div class="kaltura_pager">'. $pager .'</div>', 'javascript' => $js));
-		exit();
-	}
-	return $html . $pager;
+    $js = '$(document).ready(function() { '. PHP_EOL .'window.top.document.getElementById("kaltura_modal_iframe").className += " remove_overflow"; ';
+    $js .= PHP_EOL .'window.top.document.getElementById("kaltura_modal_iframe").scrolling = "";';
+    $js .= PHP_EOL .'window.top.document.getElementById("modalbox").style.height = "500px";';
+    $js .= PHP_EOL .'window.top.document.getElementById("kaltura_modal_iframe").height = "500";';
+    $js .= PHP_EOL .'window.top.document.getElementById("modalbox").className += " white_bg"; });';
+    echo theme('kaltura_modal', array('flashEmbed' => $html .'<div class="kaltura_pager">'. $pager .'</div>', 'javascript' => $js));
+    exit();
+  }
+  return $html . $pager;
 }
 
 /*
@@ -392,33 +404,33 @@
  * @TODO move to theme file
  */
 function theme_kaltura_list_of_entries($arr_nodes_nids, $allow_insert = FALSE, $field_name = '') {
-	$url_option = array('query' => array('cwurl' => $_GET['cwurl']));
-	$filter = 'Show only: '. l('All', $_GET['q'], $url_option) .' | '. l('Videos', $_GET['q'], array('query' => array('filter' => '1', 'cwurl' => $_GET['cwurl']))) .' | ';
-	$filter .= l('Photos', $_GET['q'], array('query' => array('filter' => '2', 'cwurl' => $_GET['cwurl']))) .' | '.
-	l('Remixes', $_GET['q'], array('query' => array('filter' => '6', 'cwurl' => $_GET['cwurl'])));
-	$filter .= ' | '. l('Audio', $_GET['q'], array('query' => array('filter' => '5', 'cwurl' => $_GET['cwurl'])));
+  $url_option = array('query' => array('cwurl' => $_GET['cwurl']));
+  $filter = 'Show only: '. l('All', $_GET['q'], $url_option) .' | '. l('Videos', $_GET['q'], array('query' => array('filter' => '1', 'cwurl' => $_GET['cwurl']))) .' | ';
+  $filter .= l('Photos', $_GET['q'], array('query' => array('filter' => '2', 'cwurl' => $_GET['cwurl']))) .' | '.
+  l('Remixes', $_GET['q'], array('query' => array('filter' => '6', 'cwurl' => $_GET['cwurl'])));
+  $filter .= ' | '. l('Audio', $_GET['q'], array('query' => array('filter' => '5', 'cwurl' => $_GET['cwurl'])));
   $str = '<div id="kaltura_entries_page" class="'. (($allow_insert)? 'minimal_mode': '') .'">';
   if (user_access('administer kaltura')) {
     $str .= l('Import entries from Kaltura', 'admin/settings/kaltura/entries/import');
   }
   $str .= '<div class="kfilter">'. $filter .'</div><ul>';
-	if (is_array($arr_nodes_nids) && count($arr_nodes_nids)) {
-		foreach ($arr_nodes_nids as $nid => $dets) {
-			$str .= '<li class="kentry"><div class="kentry_title">'. l($dets->title, 'node/'. $nid, array('attributes' => array('target' => '_blank'))) .'</div>'. PHP_EOL;
-			$str .= '<div class="kentry_thumb">'. theme('node_'. $dets->type .'_thumbnail_url', $dets, 0, $nosize = TRUE) .'</div>';
-			if ($allow_insert) {
-				$str .= '<input type="button" class="kentry_add" value="" title="Insert" onclick="add_existing_media(\''. $field_name .'\', \''. $dets->kaltura_entryId .'\');" />';
-			}
-			$str .= '</li>';
-		}
-	}
-	else {
-		$str .= '<div>None</div>'. PHP_EOL;
-	}
-	$str .= '</div><div class="clear-block"></div>';
-	global $_kaltura_thumbnail_base_url;
-	if ($allow_insert) {
-		$str .= '<script>
+  if (is_array($arr_nodes_nids) && count($arr_nodes_nids)) {
+    foreach ($arr_nodes_nids as $nid => $dets) {
+      $str .= '<li class="kentry"><div class="kentry_title">'. l($dets->title, 'node/'. $nid, array('attributes' => array('target' => '_blank'))) .'</div>'. PHP_EOL;
+      $str .= '<div class="kentry_thumb">'. theme('node_'. $dets->type .'_thumbnail_url', $dets, 0, $nosize = TRUE) .'</div>';
+      if ($allow_insert) {
+        $str .= '<input type="button" class="kentry_add" value="" title="Insert" onclick="add_existing_media(\''. $field_name .'\', \''. $dets->kaltura_entryId .'\');" />';
+      }
+      $str .= '</li>';
+    }
+  }
+  else {
+    $str .= '<div>None</div>'. PHP_EOL;
+  }
+  $str .= '</div><div class="clear-block"></div>';
+  global $_kaltura_thumbnail_base_url;
+  if ($allow_insert) {
+    $str .= '<script>
               function add_existing_media(field_id, entry) {
                 field = window.top.document.getElementById(field_id);
                 field.value = entry;
@@ -426,66 +438,66 @@
                 window.top.kalturaCloseModalBox();
               }
               </script>';
-	}
+  }
 
-	return $str;
+  return $str;
 }
 
 /*
  * helper function to add the result from a notification or API call to the entry_data field
  */
 function kaltura_add_result_to_entry_data($eid, $result, $replace = TRUE) {
-	if (!$replace) {
-		$get_current_data = 'SELECT kaltura_entry_data FROM {node_kaltura} WHERE kaltura_entryId = \'%s\'';
-		$row = db_query($get_current_data, $eid);
-		$data = db_fetch_object($row);
-		$real_data = unserialize($data->kaltura_entry_data);
-	}
-	$real_data[] = $result;
-	$set_new_data = 'UPDATE {node_kaltura} SET kaltura_entry_data = \'%s\' WHERE kaltura_entryId = \'%s\'';
-	$row = db_query($set_new_data, serialize($real_data), $eid);
+  if (!$replace) {
+    $get_current_data = 'SELECT kaltura_entry_data FROM {node_kaltura} WHERE kaltura_entryId = \'%s\'';
+    $row = db_query($get_current_data, $eid);
+    $data = db_fetch_object($row);
+    $real_data = unserialize($data->kaltura_entry_data);
+  }
+  $real_data[] = $result;
+  $set_new_data = 'UPDATE {node_kaltura} SET kaltura_entry_data = \'%s\' WHERE kaltura_entryId = \'%s\'';
+  $row = db_query($set_new_data, serialize($real_data), $eid);
 }
 
 /*
  * Implementation of hook_cron().
  */
 function kaltura_cron() {
-	// get all entries from node_kaltura table,
-	// use the getEntries service to retrieve the data of entries
-	try
-	{
-	$get_entries = 'SELECT kaltura_entryId FROM {node_kaltura} node_kaltura LEFT JOIN {node} node ON node.nid = node_kaltura.nid WHERE node.status = 1';
-	$entries = db_query($get_entries);
-	while ($entry = db_fetch_object($entries)) {
-		$all_entries[] = $entry->kaltura_entryId;
-	}
-	if (is_array($all_entries) && count($all_entries)) {
-		$my_entries = implode(',', $all_entries);
-		$result = kaltura_get_entries($my_entries, count($all_entries), true);
-	}
-	else {
-		$result = FALSE;
-	}
-	// if we got a good result, we update the entry data in the DB
-	if ($result !== FALSE) {
-		foreach ($result->objects as $resultObject) {
-			$update_entry = 'UPDATE {node_kaltura} SET kstatus = '.$resultObject->status.', kaltura_views = '
-			.$resultObject->views.', kaltura_plays = '.$resultObject->plays.', kaltura_rank = '.$resultObject->rank.
+  // get all entries from node_kaltura table,
+  // use the getEntries service to retrieve the data of entries
+  try
+  {
+  $get_entries = 'SELECT kaltura_entryId FROM {node_kaltura} node_kaltura LEFT JOIN {node} node ON node.nid = node_kaltura.nid WHERE node.status = 1';
+  $entries = db_query($get_entries);
+  while ($entry = db_fetch_object($entries)) {
+    $all_entries[] = $entry->kaltura_entryId;
+  }
+  if (is_array($all_entries) && count($all_entries)) {
+    $my_entries = implode(',', $all_entries);
+    $result = kaltura_get_entries($my_entries, count($all_entries), true);
+  }
+  else {
+    $result = FALSE;
+  }
+  // if we got a good result, we update the entry data in the DB
+  if ($result !== FALSE) {
+    foreach ($result->objects as $resultObject) {
+      $update_entry = 'UPDATE {node_kaltura} SET kstatus = '.$resultObject->status.', kaltura_views = '
+      .$resultObject->views.', kaltura_plays = '.$resultObject->plays.', kaltura_rank = '.$resultObject->rank.
       ', kaltura_total_rank = '.$resultObject->totalRank.',kaltura_duration = '.$resultObject->duration.', 
       kaltura_votes = '.$resultObject->votes.', kaltura_thumbnail_url = \''.$resultObject->thumbnailUrl.
       '\' WHERE kaltura_entryId = \''.$resultObject->id.'\'';
-			if ($resultObject->duration) {
-				$duration = $entry['duration'];
-			}
-
-			$updated = db_query($update_entry, $resultObject->status, $resultObject->views, $resultObject->plays, $resultObject->rank, $resultObject->totalRank, $duration,
-			$resultObject->votes, $resultObject->thumbnailUrl, $resultObject->id);
-		}
-	}
-	}
-	catch(Exception $ex)
-	{
-	}
+      if ($resultObject->duration) {
+        $duration = $entry['duration'];
+      }
+
+      $updated = db_query($update_entry, $resultObject->status, $resultObject->views, $resultObject->plays, $resultObject->rank, $resultObject->totalRank, $duration,
+      $resultObject->votes, $resultObject->thumbnailUrl, $resultObject->id);
+    }
+  }
+  }
+  catch(Exception $ex)
+  {
+  }
 }
 
 /*
@@ -495,31 +507,31 @@
  * returns an array made up of Mix and media entries
  */
 function kaltura_get_entries($entries, $totalEntries, $isAdmin = false) {
-	$kaltura_client = KalturaHelpers::getKalturaClient($isAdmin);
-	$session_user = KalturaHelpers::getSessionUser();
-	$kmf = new KalturaBaseEntryFilter();
-	$kmf->idIn = $entries;
-	$result = $kaltura_client->baseEntry->listAction($kmf);
-	//$result = $kaltura_client->getEntries($session_user, $entries, ',', 1);
-	//check if all entries accounted for
-	if ($result->totalCount<$totalEntries) {
-		//get the remaining mix entries
-		$kmf = new KalturaMixEntryFilter();
-		$kmf->idIn = $entries;
-		$mixResult = $kaltura_client->mixing->listAction($kmf);
-		//merge mix and media entries
-		if($result)
-		{
-			$fullResult = new KalturaBaseEntryListResponse();
-			$fullResult->objects = array_merge($result->objects, $mixResult->objects); 
-			$fullResult->totalCount = $result->totalCount + $mixResult->totalCount;
-		}
-		else $fullResult = $mixResult; 
-	}
-	if($fullResult)return $fullResult;
-	if($result) return $result;
+  $kaltura_client = KalturaHelpers::getKalturaClient($isAdmin);
+  $session_user = KalturaHelpers::getSessionUser();
+  $kmf = new KalturaBaseEntryFilter();
+  $kmf->idIn = $entries;
+  $result = $kaltura_client->baseEntry->listAction($kmf);
+  //$result = $kaltura_client->getEntries($session_user, $entries, ',', 1);
+  //check if all entries accounted for
+  if ($result->totalCount<$totalEntries) {
+    //get the remaining mix entries
+    $kmf = new KalturaMixEntryFilter();
+    $kmf->idIn = $entries;
+    $mixResult = $kaltura_client->mixing->listAction($kmf);
+    //merge mix and media entries
+    if($result)
+    {
+      $fullResult = new KalturaBaseEntryListResponse();
+      $fullResult->objects = array_merge($result->objects, $mixResult->objects); 
+      $fullResult->totalCount = $result->totalCount + $mixResult->totalCount;
+    }
+    else $fullResult = $mixResult; 
+  }
+  if($fullResult)return $fullResult;
+  if($result) return $result;
 
-	return FALSE;
+  return FALSE;
 }
 
 /**
@@ -527,29 +539,29 @@
    */
 function kaltura_get_entry_description($type, $entryId)
 {
-	$kaltura_client = KalturaHelpers::getKalturaClient(true);
+  $kaltura_client = KalturaHelpers::getKalturaClient(true);
 
-	if ($type == 6)
-	{
-		$result = $kaltura_client->mixing->get($entryId);
-		return $result->description;
-	}
-	else
-	{
-		$result = $kaltura_client->baseEntry->get($entryId);
-		return $result->description;
-	}
+  if ($type == 6)
+  {
+    $result = $kaltura_client->mixing->get($entryId);
+    return $result->description;
+  }
+  else
+  {
+    $result = $kaltura_client->baseEntry->get($entryId);
+    return $result->description;
+  }
 }
 
 /*
  * helper function that gets a widgetId, calls Kaltura's getWidget service and returns the embed code of the widget
  */
 function kaltura_fetch_widget_html($widget_id) {
-	$session_user = KalturaHelpers::getSessionUser();
-	$kaltura_client = KalturaHelpers::getKalturaClient();
-	$result = $kaltura_client->getWidget($session_user, $widget_id, 1);
-	$embbed = $result['result']['widget']['widgetHtml'];
-	return $embbed;
+  $session_user = KalturaHelpers::getSessionUser();
+  $kaltura_client = KalturaHelpers::getKalturaClient();
+  $result = $kaltura_client->getWidget($session_user, $widget_id, 1);
+  $embbed = $result['result']['widget']['widgetHtml'];
+  return $embbed;
 }
 
 /*
@@ -558,16 +570,16 @@
 
 function kaltura_choose_cw($cw_var, $cw_custom, $override_cw = 0)
 {
-	global $base_path;
+  global $base_path;
 
 $return_array = array();
   if ($override_cw == 0)
   {
-	  $default_cw = variable_get($cw_var, KalturaSettings_CW_UICONF_ID);
+    $default_cw = variable_get($cw_var, KalturaSettings_CW_UICONF_ID);
   }
   else
   {
-	$default_cw = $override_cw;
+  $default_cw = $override_cw;
   }
 
   $return_array[] = array(
@@ -580,36 +592,36 @@
   );
   
   $pre_custom = '<script type="text/javascript">
-				function get_image(val)
-				{
-					if (val == ' . KalturaSettings_CW_UICONF_ID_VIDEO . ') return "<img src=\''. $base_path . drupal_get_path('module', 'kaltura') .'/images/'. 'video-cw.jpg\' />";
-					if (val == ' . KalturaSettings_CW_UICONF_ID_IMAGE . ') return "<img src=\''. $base_path . drupal_get_path('module', 'kaltura') .'/images/'. 'image-cw.jpg\' />";
-					if (val == ' . KalturaSettings_CW_UICONF_ID_AUDIO . ') return "<img src=\''. $base_path . drupal_get_path('module', 'kaltura') .'/images/'. 'audio-cw.jpg\' />";
-					if (val == ' . KalturaSettings_CW_UICONF_ID . ') return "<img src=\''. $base_path . drupal_get_path('module', 'kaltura') .'/images/'. 'all-cw.jpg\' />";
-					
-					return "";
-				}
-				
-				function change_cw(val) 
-				{
-					div = document.getElementById("entry_custom");
-					div_image = document.getElementById("entry_image");
-					if (val == 1) 
-					{
-						div.style.display="block";
-						div_image.style.display="none";
-					}
-					else
-					{
-					  div.style.display="none";
-					  div_image.innerHTML = get_image(val);
-					  div_image.style.display="block";
-					}
-				}
-				$(document).ready(function() {try{change_cw('.$default_cw.');}catch(ex){}});
-				</script>';
-	
-  $custom_display = ($default_cw != '1' ? 'style="display:none"' : '');					
+        function get_image(val)
+        {
+          if (val == ' . KalturaSettings_CW_UICONF_ID_VIDEO . ') return "<img src=\''. $base_path . drupal_get_path('module', 'kaltura') .'/images/'. 'video-cw.jpg\' />";
+          if (val == ' . KalturaSettings_CW_UICONF_ID_IMAGE . ') return "<img src=\''. $base_path . drupal_get_path('module', 'kaltura') .'/images/'. 'image-cw.jpg\' />";
+          if (val == ' . KalturaSettings_CW_UICONF_ID_AUDIO . ') return "<img src=\''. $base_path . drupal_get_path('module', 'kaltura') .'/images/'. 'audio-cw.jpg\' />";
+          if (val == ' . KalturaSettings_CW_UICONF_ID . ') return "<img src=\''. $base_path . drupal_get_path('module', 'kaltura') .'/images/'. 'all-cw.jpg\' />";
+          
+          return "";
+        }
+        
+        function change_cw(val) 
+        {
+          div = document.getElementById("entry_custom");
+          div_image = document.getElementById("entry_image");
+          if (val == 1) 
+          {
+            div.style.display="block";
+            div_image.style.display="none";
+          }
+          else
+          {
+            div.style.display="none";
+            div_image.innerHTML = get_image(val);
+            div_image.style.display="block";
+          }
+        }
+        $(document).ready(function() {try{change_cw('.$default_cw.');}catch(ex){}});
+        </script>';
+  
+  $custom_display = ($default_cw != '1' ? 'style="display:none"' : '');         
   $return_array[] = array(
     '#type' => 'textfield',
     '#size' => 10,
@@ -628,97 +640,97 @@
  * define the settings form for choosing a default player
  */
 function kaltura_choose_player($as_single_form, $type, $node_type, $return_widget_html = FALSE, $saved_player=48501) {
-	global $base_path;
-	if (variable_get('kaltura_partner_id', '') == '') {
-		drupal_set_message(t('You must configure partner\'s details first.'), 'error');
-		return $form;
-	}
-	if ($as_single_form) {
-		$form['kaltura_widgets_information'] = array(
+  global $base_path;
+  if (variable_get('kaltura_partner_id', '') == '') {
+    drupal_set_message(t('You must configure partner\'s details first.'), 'error');
+    return $form;
+  }
+  if ($as_single_form) {
+    $form['kaltura_widgets_information'] = array(
       '#value' => t('Select which player you want to use in default view for kaltura items'),
-		);
-	}
-	
-	if ($node_type == 'entry')
-	{
-	    $variable_width = variable_get('kaltura_'.$type.'_'.$node_type.'_width', '410');
-		$variable_height = variable_get('kaltura_'.$type.'_'.$node_type.'_height', '364');
-	}
-	else
-	{
-	    $variable_width = variable_get('kaltura_'.$type.'_width', '410');
-		$variable_height = variable_get('kaltura_'.$type.'_height', '364');
-	}
-		$wid = '_'. variable_get('kaltura_partner_id', '');
-		if (!is_numeric($saved_player)) $saved_player = 48501;
-	//	$saved_player = variable_get('kaltura_'.$type.'_'.$node_type.'_widget', KalturaSettings_DEFAULT_VIDEO_PLAYER_UICONF);
-
-		$site_players = array();
-		if ( $type == 'viewplaylist')
-		{
-			KalturaHelpers::getSitePlaylistPlayers($site_players);
-		}
-		else
-		{
-			KalturaHelpers::getSitePlayers($site_players);
-		}
-		reset($site_players);
-		$first_uiconf = key($site_players);
-		$players_name = array();
-		foreach($site_players as $one_player_id => $one_layer_props)
-		{
-			$players_name[$one_player_id] = $one_layer_props['name'];
-		}
-		
-		$replace_url = KalturaHelpers::getSwfUrlForWidget($wid  .'/entry_id/_KMCLOGO1/uiconf_id/##uiconf##');
-		$suffix = '<table><tr><td><span id="'.$type.'_ph"></span></td><td valign="middle"><span><a href="http://www.kaltura.com/index.php/kmc/kmc2#appstudio|players_list" target="_blank">Create new player</a></span></td></tr></table>
-				<script type="text/javascript">
-			  function get_'.$type.'_defualt_width()
-			  {
-				return "' . $variable_width . '";
-			  }
-			  
-			  function get_'.$type.'_defualt_height()
-			  {
-				return "' . $variable_height . '";
-			  }
-			  
-			  function get_'.$type.'_player_width(uiconf)
-			  {
-				var width;
-				switch (uiconf)
-				{';
-					foreach($site_players as $one_player_id => $one_layer_props)
-					{
-						$suffix .= '
-					case "' . $one_player_id . '": width = "' . $one_layer_props['width'] . '"; break;';					
-					}				
-		$suffix .= '				
-					default: width =  "0";
-				}
-				return (width != "0" ? width : get_'.$type.'_defualt_width());
-			  }
-
-			  function get_'.$type.'_player_height(uiconf)
-			  {
-				var height;
-				switch (uiconf)
-				{';
-					foreach($site_players as $one_player_id => $one_layer_props)
-					{
-						$suffix .= '
-					case "' . $one_player_id . '": height = "' . $one_layer_props['height'] . '"; break;';					
-					}				
-		$suffix .= '				
-					default: height = "0"; break;
-				}
-				return (height != "0" ? height : get_'.$type.'_defualt_height());
-			  }
-			  
-			  function change_'.$type.'_player(uiconf, change_dim)
-			  { 
-			  var url = "' . $replace_url. '";
-			  url=url.replace("##uiconf##", uiconf);
+    );
+  }
+  
+  if ($node_type == 'entry')
+  {
+      $variable_width = variable_get('kaltura_'.$type.'_'.$node_type.'_width', '410');
+    $variable_height = variable_get('kaltura_'.$type.'_'.$node_type.'_height', '364');
+  }
+  else
+  {
+      $variable_width = variable_get('kaltura_'.$type.'_width', '410');
+    $variable_height = variable_get('kaltura_'.$type.'_height', '364');
+  }
+    $wid = '_'. variable_get('kaltura_partner_id', '');
+    if (!is_numeric($saved_player)) $saved_player = 48501;
+  //  $saved_player = variable_get('kaltura_'.$type.'_'.$node_type.'_widget', KalturaSettings_DEFAULT_VIDEO_PLAYER_UICONF);
+
+    $site_players = array();
+    if ( $type == 'viewplaylist')
+    {
+      KalturaHelpers::getSitePlaylistPlayers($site_players);
+    }
+    else
+    {
+      KalturaHelpers::getSitePlayers($site_players);
+    }
+    reset($site_players);
+    $first_uiconf = key($site_players);
+    $players_name = array();
+    foreach($site_players as $one_player_id => $one_layer_props)
+    {
+      $players_name[$one_player_id] = $one_layer_props['name'];
+    }
+    
+    $replace_url = KalturaHelpers::getSwfUrlForWidget($wid  .'/entry_id/_KMCLOGO1/uiconf_id/##uiconf##');
+    $suffix = '<table><tr><td><span id="'.$type.'_ph"></span></td><td valign="middle"><span><a href="http://www.kaltura.com/index.php/kmc/kmc2#appstudio|players_list" target="_blank">Create new player</a></span></td></tr></table>
+        <script type="text/javascript">
+        function get_'.$type.'_defualt_width()
+        {
+        return "' . $variable_width . '";
+        }
+        
+        function get_'.$type.'_defualt_height()
+        {
+        return "' . $variable_height . '";
+        }
+        
+        function get_'.$type.'_player_width(uiconf)
+        {
+        var width;
+        switch (uiconf)
+        {';
+          foreach($site_players as $one_player_id => $one_layer_props)
+          {
+            $suffix .= '
+          case "' . $one_player_id . '": width = "' . $one_layer_props['width'] . '"; break;';          
+          }       
+    $suffix .= '        
+          default: width =  "0";
+        }
+        return (width != "0" ? width : get_'.$type.'_defualt_width());
+        }
+
+        function get_'.$type.'_player_height(uiconf)
+        {
+        var height;
+        switch (uiconf)
+        {';
+          foreach($site_players as $one_player_id => $one_layer_props)
+          {
+            $suffix .= '
+          case "' . $one_player_id . '": height = "' . $one_layer_props['height'] . '"; break;';          
+          }       
+    $suffix .= '        
+          default: height = "0"; break;
+        }
+        return (height != "0" ? height : get_'.$type.'_defualt_height());
+        }
+        
+        function change_'.$type.'_player(uiconf, change_dim)
+        { 
+        var url = "' . $replace_url. '";
+        url=url.replace("##uiconf##", uiconf);
               var kaltura_swf = new SWFObject(url, "'. $type.'_ph_player", '. 'get_'.$type.'_player_width(uiconf)' .', '. 'get_'.$type.'_player_height(uiconf)' .', "9", "#000000");
               kaltura_swf.addParam("wmode", "opaque");
               kaltura_swf.addParam("flashVars", "");
@@ -728,47 +740,47 @@
               kaltura_swf.write("'.$type.'_ph");
               try{if (change_dim == 1) set_'.$type.'_player_dimension(uiconf);}catch(ex){}
               }$(document).ready(function() {try{change_'.$type.'_player("'.$saved_player.'", 0);}catch(ex){}});</script>';
-	  $form['default_widget'] = array(
-		'#type' => 'select',
-		'#title' => t('Video Player for Node'),
-		'#options' => $players_name,
-		'#suffix' => $suffix,
-		'#attributes' => array('onChange' => 'change_'.$type.'_player(this.options[this.selectedIndex].value, 1)'),
-		'#default_value' => $saved_player,
-	  );
-		if ($as_single_form) {
-			return system_settings_form($form);
-		}
-		else {
-			return $form;
-		}
-//	}
-	
-	$widgets = new KalturaSettings;
-	$pid = variable_get('kaltura_partner_id', '');
+    $form['default_widget'] = array(
+    '#type' => 'select',
+    '#title' => t('Video Player for Node'),
+    '#options' => $players_name,
+    '#suffix' => $suffix,
+    '#attributes' => array('onChange' => 'change_'.$type.'_player(this.options[this.selectedIndex].value, 1)'),
+    '#default_value' => $saved_player,
+    );
+    if ($as_single_form) {
+      return system_settings_form($form);
+    }
+    else {
+      return $form;
+    }
+//  }
+  
+  $widgets = new KalturaSettings;
+  $pid = variable_get('kaltura_partner_id', '');
 
-	foreach ($widgets->kdp_widgets[$type] as $skins => $confs) {
-		if ($return_widget_html) {
+  foreach ($widgets->kdp_widgets[$type] as $skins => $confs) {
+    if ($return_widget_html) {
       $embbed = kaltura_fetch_widget_html('_'. $pid .'_'. $confs['remix_uiconf']);
-		}
-		$options[$skins] = $skins .': '. (($return_widget_html)? $embbed: '<br /><img src="'. $base_path . drupal_get_path('module', 'kaltura') .'/images/'. $confs['preview_image'] .'" />');
-	}
+    }
+    $options[$skins] = $skins .': '. (($return_widget_html)? $embbed: '<br /><img src="'. $base_path . drupal_get_path('module', 'kaltura') .'/images/'. $confs['preview_image'] .'" />');
+  }
 
-	$default = kaltura_default_uiconf_by_type($type);
+  $default = kaltura_default_uiconf_by_type($type);
 
-	$form['default_widget'] = array(
+  $form['default_widget'] = array(
     '#title' => t('available widgets'),
     '#type' => 'radios',
     '#options' => $options,
     '#attributes' => array("class" => "player-preview-option"),
     '#default_value' => variable_get('kaltura_'. $type .'_'. $node_type .'_widget', $default),
-	);
-	if ($as_single_form) {
-		return system_settings_form($form);
-	}
-	else {
-		return $form;
-	}
+  );
+  if ($as_single_form) {
+    return system_settings_form($form);
+  }
+  else {
+    return $form;
+  }
 }
 
 /*
@@ -777,13 +789,13 @@
  * This function exposes a hook_cw_destination()
  */
 function kaltura_cw_destination() {
-	$url = kaltura_invoke('cw_destination', $data = NULL);
-	if ($url) {
-		return $url[0];
-	}
+  $url = kaltura_invoke('cw_destination', $data = NULL);
+  if ($url) {
+    return $url[0];
+  }
 
-	$url = url('kaltura/entries');
-	return $url;
+  $url = url('kaltura/entries');
+  return $url;
 }
 
 /*
@@ -795,104 +807,104 @@
  * Implementation of hook_block().
  */
 function kaltura_block($op = 'list', $delta = 0, $edit = array()) {
-	if ($op == 'list') {
-		$blocks[0] = array('info' => t('Upload media block'),
+  if ($op == 'list') {
+    $blocks[0] = array('info' => t('Upload media block'),
       'weight' => 0, 'status' => 0);
-		$blocks[1] = array('info' => t('Upload audio block'),
+    $blocks[1] = array('info' => t('Upload audio block'),
       'weight' => 0, 'status' => 0, 'delta' => 1);
-		$blocks[2] = array('info' => t('Upload image block'),
+    $blocks[2] = array('info' => t('Upload image block'),
       'weight' => 0, 'status' => 0, 'delta' => 2);
-		$blocks[3] = array('info' => t('Upload video block'),
+    $blocks[3] = array('info' => t('Upload video block'),
       'weight' => 0, 'status' => 0, 'delta' => 3);
-		$blocks[4] = array('info' => t('Simple uploader block'),
+    $blocks[4] = array('info' => t('Simple uploader block'),
       'weight' => 0, 'status' => 0, 'delta' => 4);
-		return $blocks;
-	}
-	elseif ($op == 'configure' && $delta == 0) {
-	}
-	elseif ($op == 'save' && $delta == 0) {
-	}
-	elseif ($op == 'view') {
-		switch ($delta) {
-			case 0:
-				if (user_access('create kaltura items')) {
-					$block = array('subject' => t('Upload Media'),
+    return $blocks;
+  }
+  elseif ($op == 'configure' && $delta == 0) {
+  }
+  elseif ($op == 'save' && $delta == 0) {
+  }
+  elseif ($op == 'view') {
+    switch ($delta) {
+      case 0:
+        if (user_access('create kaltura items')) {
+          $block = array('subject' => t('Upload Media'),
             'content' => kaltura_upload_block());
-				}
-				break;
-			case 1:
-				if (user_access('create kaltura items')) {
-					$block = array('subject' => t('Upload Audio'),
+        }
+        break;
+      case 1:
+        if (user_access('create kaltura items')) {
+          $block = array('subject' => t('Upload Audio'),
             'content' => kaltura_upload_block(KalturaSettings_CW_UICONF_ID_AUDIO, 'Click to Upload Audio'));
             }
-			 break;
-			case 2:
-				if (user_access('create kaltura items')) {
-					$block = array('subject' => t('Upload Image'),
+       break;
+      case 2:
+        if (user_access('create kaltura items')) {
+          $block = array('subject' => t('Upload Image'),
             'content' => kaltura_upload_block(KalturaSettings_CW_UICONF_ID_IMAGE, 'Click to Upload Image'));
             }
-			 break;
-			case 3:
-				if (user_access('create kaltura items')) {
-					$block = array('subject' => t('Upload Video'),
+       break;
+      case 3:
+        if (user_access('create kaltura items')) {
+          $block = array('subject' => t('Upload Video'),
             'content' => kaltura_upload_block(KalturaSettings_CW_UICONF_ID_VIDEO, 'Click to Upload Video'));
             }
-			 break;
-			case 4:
-				if (user_access('create kaltura items')) {
-					$block = array('subject' => t('Simple Uploader'),
+       break;
+      case 4:
+        if (user_access('create kaltura items')) {
+          $block = array('subject' => t('Simple Uploader'),
             'content' => kaltura_upload_block(KalturaSettings_CW_UICONF_ID_SIMPLE, 'Click to Upload'));
             }
-			 break;
-			 
-			 
-			 
-		}
-		return $block;
-	}
+       break;
+       
+       
+       
+    }
+    return $block;
+  }
 }
 
 /*
  * returns the upload block content
  */
 function kaltura_upload_block($uiConf = 0, $title = 'Click to Upload Media') {
-	$cw_vars = array(
+  $cw_vars = array(
     'kshow_id' => -2,
     'navigate_back' => 0,
     'ui_conf' => $uiConf,
     'write_output' => $uiConf == KalturaSettings_CW_UICONF_ID_SIMPLE ? 0 : 1
-	);
-	
-	$vars = kaltura_format_cw_vars($cw_vars);
-	if ($uiConf == KalturaSettings_CW_UICONF_ID_SIMPLE)
-	{
-		return kaltura_contribution_wizard($vars);
-	}
-	else
-	{
-		return '<input type="button" onclick="kalturaInitModalBox(\''. url("kaltura/contribution_wizard/". $vars) .'\');" value="'.$title.'" />';
-	}
+  );
+  
+  $vars = kaltura_format_cw_vars($cw_vars);
+  if ($uiConf == KalturaSettings_CW_UICONF_ID_SIMPLE)
+  {
+    return kaltura_contribution_wizard($vars);
+  }
+  else
+  {
+    return '<input type="button" onclick="kalturaInitModalBox(\''. url("kaltura/contribution_wizard/". $vars) .'\');" value="'.$title.'" />';
+  }
 }
 
 function kaltura_format_cw_vars($vars = array()) {
-	$str = urlencode(serialize($vars));
-	return $str;
+  $str = urlencode(serialize($vars));
+  return $str;
 }
 
 /*
  * helper function to get a node id for a given entryId/kshowId
  */
 function kaltura_get_node_for_mix($entry_id) {
-	$get_q = 'SELECT nid FROM {node_kaltura} WHERE kaltura_entryId = \'%s\'';
-	$result = db_query($get_q, $entry_id);
-	$obj = db_fetch_object($result);
-	return $obj->nid;
+  $get_q = 'SELECT nid FROM {node_kaltura} WHERE kaltura_entryId = \'%s\'';
+  $result = db_query($get_q, $entry_id);
+  $obj = db_fetch_object($result);
+  return $obj->nid;
 }
 
 function kaltura_get_metadata_for_mix($entry_id) {
-	$get_q = 'SELECT vid, nid, kaltura_thumbnail_url FROM {node_kaltura} WHERE kaltura_entryId = \'%s\'';
+  $get_q = 'SELECT vid, nid, kaltura_thumbnail_url FROM {node_kaltura} WHERE kaltura_entryId = \'%s\'';
 
-	$result = db_query($get_q, $entry_id);
-	$obj = db_fetch_object($result);
-	return $obj;
+  $result = db_query($get_q, $entry_id);
+  $obj = db_fetch_object($result);
+  return $obj;
 }
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/kaltura_client: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/plugins: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/plugins/field_kaltura: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/plugins/kaltura_comments: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/plugins/kaltura_playlist: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/plugins/kaltura_views: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/plugins/node_kaltura_entry: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/plugins/node_kaltura_mix: CVS
Only in /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/style: CVS
diff -ur /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/style/kaltura.css ./style/kaltura.css
--- /Users/chris/Documents/Clients/Drupal/DRUPAL-6/contributions/modules/kaltura-DRUPAL-6--2/style/kaltura.css	2011-01-06 23:07:55.000000000 +1300
+++ ./style/kaltura.css	2011-01-14 14:11:27.000000000 +1300
@@ -20,8 +20,15 @@
 
 */
 
+#kaltura-installation-form div#saas-or-ce-wrapper div.form-item {
+    margin-bottom: 0 ;
+}
+
+#kaltura-installation-form #edit-kaltura-url-wrapper {
+    margin-top: 0 ;
+}
 
-#modalbox{ position: fixed; left: 50%; top:50%; margin:-180px 0 0 -340px; border:3px solid #666; width: 680px; z-index: 100; }
+#modalbox{ position: fixed; left: 50%; top:50%; margin:-180px 0 0 -340px; background:#262626; border:3px solid #666; width: 680px; z-index: 100; }
 
 #kaltura_overlay{ position: fixed; top: 0; left: 0; z-index: 99; width: 100%; height: 100%; background:url('../images/transBG.png') 0 0 repeat; cursor: wait; }
 
@@ -101,11 +108,25 @@
 
 
 
-.kaltura_status_ok { border:1px solid #88FF99; margin:5px; padding-left:50px; background:url('../images/ok.png') no-repeat left 50%; }
-
-.kaltura_status_bad { border:1px solid #FF8899; margin:5px; padding-left:50px; background:url('../images/no.png') no-repeat left 50%;  }
-
-.kaltura_ce_notice { border:2px solid #FF1515;   padding-left:20px; background-color:#FFAEAE;}
+.kaltura-status-ok { 
+    border:1px solid #88FF99; 
+    margin:5px; 
+    padding-left:50px;
+    background:url('../images/ok.png') no-repeat 10px 50%; 
+}
+
+.kaltura-status-bad { 
+    border:1px solid #FF8899; 
+    margin:5px; 
+    padding-left:50px; 
+    background:url('../images/no.png') no-repeat 10px 50%;  
+}
+
+.kaltura-ce-notice { 
+    border:2px solid #FF1515;   
+    padding-left:20px; 
+    background-color:#FFAEAE;
+}
 
 
 .kaltura_tags label.field_title,
@@ -160,10 +181,9 @@
 #sidemenu { bottom:-1px; font-weight:normal; left:0; margin:0 0px; padding:0px; position:relative;}
 
 #sidemenu li { background:#787878; display:inline; border-bottom-style:none; line-height:200%; list-style-image:none; list-style-position:outside; list-style-type:none; margin:0; padding:0px; text-align:center; white-space:nowrap;}
-#sidemenu li.close {position:absolute; right:10px; top:-2px;}
 #sidemenu span {background:#787878; color:#787878; display:inline; border-bottom-style:none; line-height:200%; list-style-image:none; list-style-position:outside; list-style-type:none; margin:0; padding-left:200px; text-align:center; white-space:nowrap;}
-#sidemenu span.close {background:#787878; color:#787878; display:inline; border-bottom-style:none; line-height:200%; list-style-image:none; list-style-position:outside; list-style-type:none; margin:0; padding-left:20px; text-align:center; white-space:nowrap; background-image: url('../images/close_up.png'); background-position:right 0; background-repeat:no-repeat; cursor:pointer}
-#sidemenu span.close:hover {background:#787878; color:#787878; display:inline; border-bottom-style:none; line-height:200%; list-style-image:none; list-style-position:outside; list-style-type:none; margin:0; padding-left:20px; text-align:center; white-space:nowrap; background-image: url('../images/close_over.png'); background-position:right 0; background-repeat:no-repeat; cursor:pointer}
+#sidemenu span.close {background:#787878; color:#787878; display:inline; border-bottom-style:none; line-height:200%; list-style-image:none; list-style-position:outside; list-style-type:none; margin:0; padding-left:20px; text-align:center; white-space:nowrap; background-image: url('../images/close_up.png'); background-position:right; background-repeat:no-repeat; cursor:pointer}
+#sidemenu span.close:hover {background:#787878; color:#787878; display:inline; border-bottom-style:none; line-height:200%; list-style-image:none; list-style-position:outside; list-style-type:none; margin:0; padding-left:20px; text-align:center; white-space:nowrap; background-image: url('../images/close_over.png'); background-position:right; background-repeat:no-repeat; cursor:pointer}
 
 #sidemenu a { padding:6px; color:#D8D8D8; text-decoration:none; background:#787878 none repeat scroll 0 0; }
 
@@ -218,4 +238,5 @@
 .kaltura_embed_title {color:#efefef;}
 .kaltura_embed_code {color: #333; }
 .kaltura_embed_code textarea { color: #555; border-color: #ccc; border-style: solid; border-width: 1px; background-color: #efefef; overflow: hidden; height: 50px; width: 405px;}
-}
\ No newline at end of file
+}
+
