mediafront_user.module in MediaFront 7.2
File
modules/mediafront_user/mediafront_user.module
View source
<?php
function mediafront_user_menu() {
$items['user/%user/mediafront_settings'] = array(
'title' => 'Media Player Settings',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'mediafront_user_settings',
1,
),
'access callback' => 'user_access',
'access arguments' => array(
'access content',
),
'weight' => 10,
'type' => MENU_LOCAL_TASK,
);
return $items;
}
function mediafront_user_settings($form, $form_state, $account) {
$form['account'] = array(
'#type' => 'value',
'#value' => $account->uid,
);
$settings = mediafront_get_settings('osmplayer', $account->data['mediafront']);
$preset = array(
'player' => 'osmplayer',
'settings' => $settings,
);
$settings_form = mediafront_player_settings_form($preset);
$form['autoplay'] = $settings_form['media_settings']['autoplay'];
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Save Settings',
);
return $form;
}
function mediafront_user_settings_submit($form, &$form_state) {
$account = user_load($form_state['values']['account']);
if ($account && $account->uid) {
user_save($account, array(
'data' => array(
'mediafront' => array(
'autoplay' => $form_state['values']['autoplay'],
),
),
));
drupal_set_message('Your custom media player settings have been saved.');
}
}
function mediafront_user_mediafront_settings_alter(&$settings) {
global $user;
if (isset($user->data['mediafront'])) {
$settings = array_merge($settings, $user->data['mediafront']);
}
}