client_applications_form()Define the client_applications form. @global object $user User-object with roles and permission
array Form elements
client_applications/client_applications.module, line 126
<?php
function client_applications_form() {
global $user;
$client_app_id = FALSE;
if (is_numeric(arg(2))) {
$client_app_id = arg(2);
}
$form = array();
if ($client_app_id !== FALSE) {
$client_app = db_fetch_array(db_query("SELECT * FROM {client_applications} WHERE caid = '%d'", $client_app_id));
$form['caid'] = array(
'#type' => 'hidden',
'#value' => $client_app_id,
);
$form['old_app_id'] = array(
'#type' => 'hidden',
'#value' => $client_app['id'],
);
}
$form['client_application'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#title' => t('Client application'),
'#description' => t('Settings for client application.')
);
$form['client_application']['name'] = array(
'#type' => 'textfield',
'#title' => t('Client application name'),
'#description' => t('Full name for client application.'),
'#default_value' => (isset($client_app['name'])) ? $client_app['name'] : '',
'#required' => TRUE,
);
$form['client_application']['id'] = array(
'#type' => 'textfield',
'#title' => t('App ID'),
'#description' => t('Unique application ID.'),
'#default_value' => (isset($client_app['id'])) ? $client_app['id'] : '',
'#required' => TRUE,
);
$form['client_application']['quota'] = array(
'#type' => 'textfield',
'#title' => t('Quota'),
'#required' => TRUE,
'#default_value' => (isset($client_app['quota'])) ? $client_app['quota'] : '',
'#description' => t('Quota for disk space usage in GB.'),
);
$form['client_application']['shared_key'] = array(
'#type' => 'textfield',
'#title' => t('Shared key'),
'#default_value' => (isset($client_app['shared_key'])) ? $client_app['shared_key'] : '',
'#required' => TRUE,
);
$form['client_application']['generate_shared_key'] = array(
'#type' => 'button',
'#value' => t('Paste generated key'),
'#attributes' => array(
'onclick' => '$("#edit-shared-key").val("'. vpx_create_hash(1, 1) .'"); return FALSE;',
),
);
$form['client_application']['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#description' => t('Description of client application'),
'#default_value' => (isset($client_app['description'])) ? $client_app['description'] : '',
'#required' => FALSE,
);
$form['client_application']['active'] = array(
'#type' => 'select',
'#title' => t('Status'),
'#description' => t('Availability of client application.'),
'#options' => array(1 => t('Enabled'), 0 => t('Disabled')),
'#default_value' => (isset($client_app['active'])) ? $client_app['active'] : 1,
);
$form['masterslave'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Master/slave settings'),
'#description' => t('Control how other clientapplications can access this application')
);
$form['masterslave']['allow_masterslave'] = array(
'#type' => 'checkbox',
'#title' => t('Allow master/slave access'),
'#description' => t('Allow other client applications to create slave or master assets in this application.'),
'#default_value' => (isset($client_app['allow_masterslave'])) ? $client_app['allow_masterslave'] : 'FALSE',
);
$form['oai'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('OAI Interface settings'),
'#description' => t('')
);
$form['oai']['is_metadata_public'] = array(
'#type' => 'select',
'#title' => t('OAI visibility metadata'),
'#description' => t('Is metadata of this client application public visible in OAI?'),
'#options' => array('TRUE' => t('Public'), 'FALSE' => t('Hidden')),
'#default_value' => (isset($client_app['is_metadata_public'])) ? $client_app['is_metadata_public'] : 'TRUE',
);
$form['oai']['show_external_assets'] = array(
'#type' => 'select',
'#title' => t('OAI external references'),
'#description' => t('Show external references in OAI (in field referenceId)?'),
'#options' => array('TRUE' => t('show'), 'FALSE' => t('hide')),
'#default_value' => (isset($client_app['show_external_assets'])) ? $client_app['show_external_assets'] : 'TRUE',
);
$form['transcoding'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Transcoding'),
'#description' => t('Transcoding settings for this client application.')
);
$transcoding_pos = array();
for ($i = -10; $i <= 10; $i++) {
$transcoding_pos[$i] = $i;
}
$form['transcoding']['transcoding_position_from'] = array(
'#type' => 'select',
'#title' => t('The transcoding position from'),
'#options' => $transcoding_pos,
'#default_value' => (isset($client_app['client_transcoding_from'])) ? $client_app['client_transcoding_from'] : '',
'#description' => t('Give server priority.'),
);
$form['transcoding']['transcoding_position_to'] = array(
'#type' => 'select',
'#title' => t('The transcoding position to'),
'#options' => $transcoding_pos,
'#default_value' => (isset($client_app['client_transcoding_to'])) ? $client_app['client_transcoding_to'] : '',
'#description' => t('Give server priority.'),
);
$form['transcoding']['transcoding_max_slots'] = array(
'#type' => 'textfield',
'#title' => t('Maximum transcoding slots allowed'),
'#default_value' => (isset($client_app['transcoding_max_slots'])) ? $client_app['transcoding_max_slots'] : JOB_MAX_SLOTS,
'#description' => t('Set the maximum number of transcoding jobs allowed for this application.'),
);
$form['transcoding']['always_hint_mp4'] = array(
'#type' => 'select',
'#title' => t('Always hint (make streamable) mp4 files'),
'#options' => array('FALSE' => t('Never'), 'TRUE' => t('Always')),
'#default_value' => (isset($client_app['always_hint_mp4'])) ? $client_app['always_hint_mp4'] : 'TRUE',
);
$form['transcoding']['always_insert_md'] = array(
'#type' => 'select',
'#title' => t('Always insert extra metadata flv files'),
'#options' => array('FALSE' => t('Never'), 'TRUE' => t('Always')),
'#default_value' => (isset($client_app['always_insert_md'])) ? $client_app['always_insert_md'] : 'TRUE',
);
$form['transcoding']['preview_profile_id'] = array(
'#type' => 'select',
'#title' => t('Preview transcode profile id'),
'#description' => t('Transcoding profile used for previewing.'),
'#options' => _client_applications_get_transcode_profiles(),
'#default_value' => (isset($client_app['preview_profile_id'])) ? $client_app['preview_profile_id'] : '',
'#required' => FALSE,
);
$form['client_application']['active_version'] = array(
'#type' => 'select',
'#title' => t('Select active version'),
'#description' => t('Version of the rest calls to execute.'),
'#options' => _client_applications_get_all_versions(),
'#default_value' => (isset($client_app['active_version'])) ? $client_app['active_version'] : 'LATEST',
);
$form['urls'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('URLs'),
'#description' => t('URLs shown in the asset settings.')
);
$form['urls']['download_url'] = array(
'#type' => 'textfield',
'#title' => t('Download url'),
'#description' => t('Shown in the asset details rest calls. Available tags: {asset_id}, {mediafile_id} and {mediafile_filename}'),
'#default_value' => (isset($client_app['download_url'])) ? $client_app['download_url'] : '',
'#required' => FALSE,
);
$form['urls']['stream_url'] = array(
'#type' => 'textfield',
'#title' => t('Stream url'),
'#description' => t('Shown in the asset details rest calls. Available tags: {asset_id}, {mediafile_id} and {mediafile_filename}.'),
'#default_value' => (isset($client_app['stream_url'])) ? $client_app['stream_url'] : '',
'#required' => FALSE,
);
$form['urls']['play_proxy_url'] = array(
'#type' => 'textfield',
'#title' => t('Play proxy url'),
'#description' => t('Shown in the result of rest calls and shown by OAI. Available tags: {asset_id}, {mediafile_id}, {mediafile_filename} and {preview_profile_id}.'),
'#default_value' => (isset($client_app['play_proxy_url'])) ? $client_app['play_proxy_url'] : '',
'#required' => FALSE,
);
$form['urls']['view_asset_url'] = array(
'#type' => 'textfield',
'#title' => t('View asset url'),
'#default_value' => (isset($client_app['view_asset_url'])) ? $client_app['view_asset_url'] : '',
'#description' => t('Shown by OAI, field \'Resource Identifier\'. Available tags: {asset_id}.'),
'#required' => FALSE,
);
$form['urls']['still_url'] = array(
'#type' => 'textfield',
'#title' => t('Still url'),
'#default_value' => (isset($client_app['still_url'])) ? $client_app['still_url'] : '',
'#description' => t('Shown by OAI for still images. Available tags: {asset_id}.'),
'#required' => FALSE,
);
$owner = array('' => t('none'), 'surfnet' => 'Surfnet', 'kennisnet' => 'Kennisnet');
if ($user->uid !== 1) { // admin
$unset = (in_array('kennisnet', (array)$user->roles)) ? 'surfnet' : 'kennisnet';
unset($owner[$unset]);
}
$form['client_application']['owner'] = array(
'#type' => 'select',
'#title' => t('Owner'),
'#description' => t('Owner of client application'),
'#options' => $owner,
'#default_value' => (isset($client_app['owner'])) ? $client_app['owner'] : '',
);
$form['webservice'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Webservices'),
'#description' => t('Availibility per web service for this client application.')
);
// Dynamicly add fields for webservice handles
if ($client_app_id) {
$result = db_query(
"SELECT wm.handle, wmc.status FROM {webservice_management} AS wm
JOIN {webservice_management_capp} AS wmc ON wm.handle = wmc.webservice_management_handle
WHERE wmc.caid = %d
ORDER BY wm.handle ASC",
$client_app_id
);
}
else {
$result = db_query("SELECT wm.handle FROM {webservice_management} AS wm ORDER BY wm.handle ASC");
}
while ($row = db_fetch_object($result)) {
$form['webservice']['webservice_'. $row->handle] = array(
'#type' => 'select',
'#title' => $row->handle,
'#description' => t('Availibility of web service \''. $row->handle .'\' for this client application.'),
'#default_value' => (isset($row->status)) ? drupal_strtoupper($row->status) : 'TRUE',
'#options' => array('TRUE' => t('Enabled'), 'FALSE' => t('Disabled')),
);
}
$form['technical'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Technical Contact'),
'#description' => t('Technical contact person for this client application.')
);
$form['technical']['technical_name'] = array(
'#type' => 'textfield',
'#default_value' => (isset($client_app['technical_name'])) ? $client_app['technical_name'] : '',
'#title' => t('Name'),
'#description' => t('Name of technical contact person for this client application.')
);
$form['technical']['technical_phone'] = array(
'#type' => 'textfield',
'#default_value' => (isset($client_app['technical_phone'])) ? $client_app['technical_phone'] : '',
'#title' => t('Phone'),
'#description' => t('Phone number of technical contact person for this client application.')
);
$form['technical']['technical_email'] = array(
'#type' => 'textfield',
'#default_value' => (isset($client_app['technical_email'])) ? $client_app['technical_email'] : '',
'#title' => t('E-mail'),
'#description' => t('Email-address of technical contact person for this client application.')
);
$form['administrative'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Administrative Contact'),
'#description' => t('Administrative contact person for this client application.')
);
$form['administrative']['administrative_name'] = array(
'#type' => 'textfield',
'#default_value' => (isset($client_app['administrative_name'])) ? $client_app['administrative_name'] : '',
'#title' => t('Name'),
'#description' => t('Name of administrative contact person for this client application.')
);
$form['administrative']['administrative_phone'] = array(
'#type' => 'textfield',
'#default_value' => (isset($client_app['administrative_phone'])) ? $client_app['administrative_phone'] : '',
'#title' => t('Phone'),
'#description' => t('Phone number of administrative contact person for this client application.')
);
$form['administrative']['administrative_email'] = array(
'#type' => 'textfield',
'#default_value' => (isset($client_app['administrative_email'])) ? $client_app['administrative_email'] : '',
'#title' => t('E-mail'),
'#description' => t('Email-address of administrative contact person for this client application.'),
'#required' => FALSE,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}
?>