function profile_module_manager_bundle_enable in Profile Module Manager 7.2
Same name and namespace in other branches
- 7 profile_module_manager.admin.inc \profile_module_manager_bundle_enable()
Callback function for admin/settings/bundles/list/enable/%.
Parameters
$bundle:
Return value
string
1 string reference to 'profile_module_manager_bundle_enable'
- profile_module_manager_menu in ./
profile_module_manager.module - Implements hook_menu().
File
- ./
profile_module_manager.admin.inc, line 150
Code
function profile_module_manager_bundle_enable($bundle) {
if (variable_get('profile_module_manager_disable_enabling', 0) == 1) {
$output = '<p>' . variable_get('profile_module_manager_disable_enabling_text', 'The ability to enable bundles has been turned off.') . '</p>';
return $output;
}
// Start bundle enable timer.
variable_set('profile_module_manager_enable_timer', microtime(TRUE));
// Make sure this is a bundle
if (strpos($bundle, '_bundle')) {
// look up depenencies & enable those first
$path = drupal_get_path('module', $bundle) . '/' . $bundle . '.info';
$info = drupal_parse_info_file($path);
$modules_to_enable = array();
if (isset($info['dependencies'])) {
foreach ($info['dependencies'] as $module) {
if (!module_exists($module)) {
//module_enable(array($module), FALSE);
$modules_to_enable[] = $module;
}
}
}
// enable the bundle last
if (!module_exists($bundle)) {
//module_enable(array($bundle), FALSE);
$modules_to_enable[] = $bundle;
}
// Size of modules to enable in each batch.
$limit = 3;
$module_chunks = array_chunk($modules_to_enable, $limit, TRUE);
// Chunk modules into groups.
$operations = array();
foreach ($module_chunks as $chunk) {
$operations[] = array(
'profile_module_manager_process_batch',
array(
$chunk,
),
);
}
// Set batch operation and redirect to bundles list when done.
$batch = array(
'title' => t('Enabling Bundle'),
'operations' => $operations,
'finished' => 'profile_module_manager_batch_finished',
'init_message' => t('Initializing...'),
'progress_message' => t('Operation @current out of @total.'),
'error_message' => t('Bundle failed to be enabled.'),
);
batch_set($batch);
// Logout all users except currently using site if lgout flag is set.
if (isset($info['bundle_logout']) && $info['bundle_logout'] == 1) {
// Get all logged in users based on timestamp of being logged in since 900 seconds ago.
$interval = REQUEST_TIME - 900;
$items = db_query('SELECT u.uid, u.name, MAX(s.timestamp) AS max_timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= :interval AND s.uid > 0 GROUP BY u.uid, u.name ORDER BY max_timestamp DESC', array(
':interval' => $interval,
))
->fetchAll();
$uids = array();
foreach ($items as $item) {
$uids[] = $item->uid;
}
// Log out all other users.
$deleted_users = db_delete('sessions')
->condition('uid', $uids, 'NOT IN')
->execute();
}
batch_process('admin/settings/bundles/list');
}
}