function mobile_tools_form_alter in Mobile Tools 6
Same name and namespace in other branches
- 5 mobile_tools.module \mobile_tools_form_alter()
- 6.3 mobile_tools.module \mobile_tools_form_alter()
- 7.2 mobile_tools.module \mobile_tools_form_alter()
Alteration to global setting form
File
- ./
mobile_tools.module, line 555 - Mobile Tools provides a range of functionality assisting in creating a mobile Drupal site . this functionality contains:
Code
function mobile_tools_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'user_admin_role':
if (variable_get('mobile_tools_enable_roles', 0)) {
$query = "SELECT COUNT(*) as count FROM {mobile_tools_roles_relations} WHERE mrid = %d";
$result = db_query($query, arg(4));
$item = db_fetch_object($result);
if (isset($item)) {
if ($item->count == 0) {
$form['mobile_tools_configure_role_' . arg(4)] = array(
'#type' => 'checkbox',
'#title' => t('Create a mobile context for this user role'),
'#default_value' => TRUE,
'#description' => t('check if you want to add a mobile context to this role. Adding a mobile context will result in the creation of a new role that will be assigned to the user when the site is beeing mobilized. When unchecking all configurations will be lost for that role.'),
);
$form['mobile_tools_role_type'] = array(
'#type' => 'hidden',
'#value' => 'desktop',
);
}
else {
$form['mobile_tools_role_type'] = array(
'#type' => 'hidden',
'#value' => 'mobile',
);
}
$form['#submit'][] = 'mobile_tools_roles_configuration_submit';
}
}
break;
case 'user_profile_form':
if (variable_get('mobile_tools_enable_roles', 0)) {
// We make sure that the mobile roles are not being displayed
$mobile_roles = mobile_tools_mobile_user_roles();
foreach ($mobile_roles as $rid => $role) {
unset($form['account']['roles']['#options'][$rid]);
}
}
break;
case 'node_configure':
$form['default_nodes_main_mobile'] = array(
'#type' => 'select',
'#title' => t('Number of posts on main page for the mobile version'),
'#default_value' => variable_get('default_nodes_main_mobile', variable_get('default_nodes_main')),
'#options' => array(
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
7 => 7,
8 => 8,
9 => 9,
10 => 10,
15 => 15,
20 => 20,
25 => 25,
30 => 30,
),
'#description' => t('The default maximum number of posts to display per page on overview pages such as the main page (on Mobile).'),
);
break;
case 'system_site_information_settings':
$form['site_frontpage_mobile'] = array(
'#type' => 'textfield',
'#title' => t('Choose another frontpage for mobile visitors.'),
'#default_value' => variable_get('site_frontpage_mobile', variable_get('site_frontpage', 'node')),
'#description' => t('If you want a different page as the frontpage of your site for mobile users, specify it here.'),
'#weight' => 1,
);
break;
}
}