Community Documentation

Code Snippets for Customizing Telvue Integration

Last updated January 14, 2013. Created by kreynen on January 14, 2013.
Log in to edit this page.

Custom Configuration

With a custom module, you add a button on each show only staff can access...

function custom_form_alter(&$form, &$form_state, $form_id) {
 
  if($form_id == 'cm_show_node_form' && user_access('push to telvue') && $form['nid']['#value']) {
    $form['actions']['telvue_button'] = array(
      '#type' => 'submit',
      '#value' => t('Push to Telvue'),
      '#submit' => array('custom_telvue_submit'),
      '#weight' => 99,
    );
  }
   
}

That button calls a custom submit function that passes information from the node to the telvue_addprogram function.

function custom_telvue_submit($form, &$form_state) {
 
  // convert time to seconds
  $str_time = $form['#node']->field_facil_program_length[LANGUAGE_NONE][0]['value'];
  sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);
  $time_seconds = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;
 
  //prepare show fields as the program array to send to Telvue
  $program = array(
    'username' => variable_get('telvue_user', NULL),
    'title' => $form['#node']->title,
    'description' => $form['#node']->body[LANGUAGE_NONE][0]['value'],
    'expected_filename' => $form['#node']->field_expected_filename[LANGUAGE_NONE][0]['value'],
    'expected_duration' => $time_seconds,
  );
 
  $server = variable_get('telvue_uri', NULL);
  $response = telvue_addprogram($program, $server);
 
  drupal_set_message('Pushed to Telvue');
}

Page status

About this page

Drupal version
Drupal 7.x
Audience
Programmers
Level
Advanced
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.