View source
<?php
function openatrium_profile_details() {
return array(
'name' => 'Open Atrium',
'description' => 'Open Atrium by Phase2 Technology.',
'old_short_name' => 'atrium_installer',
);
}
function openatrium_profile_modules() {
$modules = array(
'block',
'comment',
'dblog',
'filter',
'help',
'menu',
'node',
'openid',
'search',
'system',
'taxonomy',
'upload',
'user',
'admin',
'views',
'og',
'og_access',
'og_views',
'ctools',
'context',
'context_ui',
'context_layouts',
'date_api',
'date_timezone',
'features',
'imageapi',
'imageapi_gd',
'imagecache',
'token',
'transliteration',
'libraries',
'messaging',
'messaging_mail',
'notifications',
'notifications_content',
'notifications_views',
'openidadmin',
'purl',
'spaces',
'spaces_user',
'spaces_og',
'ucreate',
'ucreate_og',
'jquery_update',
);
if (_openatrium_language_selected()) {
$modules[] = 'locale';
$modules[] = 'l10n_update';
}
return $modules;
}
function _openatrium_atrium_modules() {
return array(
'strongarm',
'book',
'casetracker',
'date',
'date_popup',
'litecal',
'content',
'nodereference',
'text',
'optionwidgets',
'job_scheduler',
'feeds',
'parser_ical',
'notifications_team',
'content_profile',
'atrium',
'atrium_activity',
'atrium_blog',
'atrium_book',
'atrium_calendar',
'atrium_casetracker',
'atrium_groups',
'atrium_members',
'atrium_profile',
'atrium_shoutbox',
'spaces_dashboard',
'jquery_ui',
'codefilter',
'markdown',
'boxes',
'comment_upload',
'crayon',
'diff',
'itweak_upload',
'imagecache_profiles',
'nodeformcols',
'prepopulate',
'reldate',
'xref',
'color',
'designkit',
);
}
function openatrium_profile_task_list() {
$tasks['intranet-modules-batch'] = st('Install Open Atrium modules');
if (_openatrium_language_selected()) {
$tasks['l10n-install-batch'] = st('Download and import translation');
}
$tasks['intranet-configure-batch'] = st('Configure Open Atrium');
return $tasks;
}
function openatrium_profile_tasks(&$task, $url) {
global $profile, $install_locale;
$output = '';
if ($task == 'profile') {
language_list('name', TRUE);
$task = 'intranet-modules';
}
if (in_array($task, array(
'intranet-modules-batch',
'l10n-install-batch',
'intranet-configure-batch',
))) {
include_once 'includes/batch.inc';
$output = _batch_page();
}
if ($task == 'intranet-modules') {
$modules = _openatrium_atrium_modules();
$files = module_rebuild_cache();
foreach ($modules as $module) {
$batch['operations'][] = array(
'_install_module_batch',
array(
$module,
$files[$module]->info['name'],
),
);
}
$batch['finished'] = '_openatrium_profile_batch_finished';
$batch['title'] = st('Installing @drupal', array(
'@drupal' => drupal_install_profile_name(),
));
$batch['error_message'] = st('The installation has encountered an error.');
variable_set('install_task', 'intranet-modules-batch');
batch_set($batch);
batch_process($url, $url);
return;
}
if ($task == 'l10n-install') {
if (_openatrium_language_selected()) {
$history = l10n_update_get_history();
module_load_include('check.inc', 'l10n_update');
$available = l10n_update_available_releases();
$updates = l10n_update_build_updates($history, $available);
module_load_include('batch.inc', 'l10n_update');
$updates = _l10n_update_prepare_updates($updates, NULL, array());
$batch = l10n_update_batch_multiple($updates, LOCALE_IMPORT_KEEP);
$batch['finished'] = '_openatrium_translate_batch_finished';
variable_set('install_task', 'l10n-install-batch');
batch_set($batch);
batch_process($url, $url);
return;
}
$task = 'intranet-configure';
}
if ($task == 'intranet-configure') {
$batch['title'] = st('Configuring @drupal', array(
'@drupal' => drupal_install_profile_name(),
));
$batch['operations'][] = array(
'_openatrium_intranet_configure',
array(),
);
$batch['operations'][] = array(
'_openatrium_intranet_configure_check',
array(),
);
$batch['finished'] = '_openatrium_intranet_configure_finished';
variable_set('install_task', 'intranet-configure-batch');
batch_set($batch);
batch_process($url, $url);
return;
}
return $output;
}
function _openatrium_language_selected() {
global $install_locale;
return !empty($install_locale) && $install_locale != 'en';
}
function _openatrium_intranet_configure() {
global $install_locale;
if (!empty($install_locale) && $install_locale != 'en') {
db_query("DELETE FROM {languages} WHERE language = 'en'");
}
$result = db_query("SELECT * FROM {filter_formats} WHERE name IN ('%s', '%s')", 'Filtered HTML', 'Full HTML');
while ($row = db_fetch_object($result)) {
db_query("DELETE FROM {filter_formats} WHERE format = %d", $row->format);
db_query("DELETE FROM {filters} WHERE format = %d", $row->format);
}
db_query("UPDATE {permission} set perm = '' WHERE rid = 1");
$picture_path = file_create_path(variable_get('user_picture_path', 'pictures'));
file_check_directory($picture_path, 1, 'user_picture_path');
$tz_offset = date('Z');
variable_set('date_default_timezone', $tz_offset);
variable_set('site_footer', st('Built with <a href="@oalink">Open Atrium</a>', array(
'@oalink' => 'http://www.openatrium.com',
)));
}
function _openatrium_intranet_configure_check() {
node_access_rebuild();
drupal_flush_all_caches();
_openatrium_system_theme_data();
db_query("UPDATE {blocks} SET status = 0, region = ''");
db_query("UPDATE {system} SET status = 0 WHERE type = 'theme' and name ='%s'", 'garland');
db_query("UPDATE {system} SET status = 0 WHERE type = 'theme' and name ='%s'", 'ginkgo');
variable_set('theme_default', 'ginkgo');
if (function_exists('strongarm_init')) {
strongarm_init();
}
$revert = array(
'atrium' => array(
'user_role',
'user_permission',
'variable',
'filter',
),
'atrium_blog' => array(
'user_permission',
'variable',
),
'atrium_book' => array(
'user_permission',
'variable',
),
'atrium_calendar' => array(
'user_permission',
'variable',
),
'atrium_casetracker' => array(
'user_permission',
'variable',
),
'atrium_groups' => array(
'user_permission',
'variable',
),
'atrium_members' => array(
'user_permission',
'variable',
),
'atrium_profile' => array(
'user_permission',
'variable',
),
'atrium_shoutbox' => array(
'user_permission',
'variable',
),
);
features_revert($revert);
}
function _openatrium_profile_batch_finished($success, $results) {
variable_set('install_task', 'l10n-install');
}
function _openatrium_translate_batch_finished($success, $results) {
variable_set('install_task', 'intranet-configure');
module_load_include('batch.inc', 'l10n_update');
_l10n_update_batch_finished($success, $results);
}
function _openatrium_intranet_configure_finished($success, $results) {
variable_set('atrium_install', 1);
if ($success) {
variable_set('install_task', 'profile-finished');
}
}
function system_form_install_select_profile_form_alter(&$form, $form_state) {
foreach ($form['profile'] as $key => $element) {
$form['profile'][$key]['#value'] = 'openatrium';
}
}
function system_form_install_select_locale_form_alter(&$form, $form_state) {
$form['locale']['en']['#value'] = 'en';
}
function system_form_install_configure_form_alter(&$form, $form_state) {
$form['site_information']['site_name']['#default_value'] = 'Open Atrium';
$form['site_information']['site_mail']['#default_value'] = 'admin@' . $_SERVER['HTTP_HOST'];
$form['admin_account']['account']['name']['#default_value'] = 'admin';
$form['admin_account']['account']['mail']['#default_value'] = 'admin@' . $_SERVER['HTTP_HOST'];
if (function_exists('date_timezone_names') && function_exists('date_timezone_update_site')) {
$form['server_settings']['date_default_timezone']['#access'] = FALSE;
$form['server_settings']['#element_validate'] = array(
'date_timezone_update_site',
);
$form['server_settings']['date_default_timezone_name'] = array(
'#type' => 'select',
'#title' => t('Default time zone'),
'#default_value' => NULL,
'#options' => date_timezone_names(FALSE, TRUE),
'#description' => t('Select the default site time zone. If in doubt, choose the timezone that is closest to your location which has the same rules for daylight saving time.'),
'#required' => TRUE,
);
}
}
function _openatrium_system_theme_data() {
global $profile;
$profile = 'openatrium';
$themes = drupal_system_listing('\\.info$', 'themes');
$engines = drupal_system_listing('\\.engine$', 'themes/engines');
$defaults = system_theme_default();
$sub_themes = array();
foreach ($themes as $key => $theme) {
$themes[$key]->info = drupal_parse_info_file($theme->filename) + $defaults;
if (!empty($themes[$key]->info['base theme'])) {
$sub_themes[] = $key;
}
$engine = $themes[$key]->info['engine'];
if (isset($engines[$engine])) {
$themes[$key]->owner = $engines[$engine]->filename;
$themes[$key]->prefix = $engines[$engine]->name;
$themes[$key]->template = TRUE;
}
$pathed_stylesheets = array();
foreach ($themes[$key]->info['stylesheets'] as $media => $stylesheets) {
foreach ($stylesheets as $stylesheet) {
$pathed_stylesheets[$media][$stylesheet] = dirname($themes[$key]->filename) . '/' . $stylesheet;
}
}
$themes[$key]->info['stylesheets'] = $pathed_stylesheets;
$scripts = array();
foreach ($themes[$key]->info['scripts'] as $script) {
$scripts[$script] = dirname($themes[$key]->filename) . '/' . $script;
}
$themes[$key]->info['scripts'] = $scripts;
if (!empty($themes[$key]->info['screenshot'])) {
$themes[$key]->info['screenshot'] = dirname($themes[$key]->filename) . '/' . $themes[$key]->info['screenshot'];
}
}
foreach ($sub_themes as $key) {
$themes[$key]->base_themes = system_find_base_themes($themes, $key);
if (!current($themes[$key]->base_themes)) {
continue;
}
$base_key = key($themes[$key]->base_themes);
foreach (array_keys($themes[$key]->base_themes) as $base_theme) {
$themes[$base_theme]->sub_themes[$key] = $themes[$key]->info['name'];
}
if (isset($themes[$base_key]->owner)) {
if (isset($themes[$base_key]->info['engine'])) {
$themes[$key]->info['engine'] = $themes[$base_key]->info['engine'];
$themes[$key]->owner = $themes[$base_key]->owner;
$themes[$key]->prefix = $themes[$base_key]->prefix;
}
else {
$themes[$key]->prefix = $key;
}
}
}
system_get_files_database($themes, 'theme');
db_query("DELETE FROM {system} WHERE type = 'theme'");
foreach ($themes as $theme) {
$theme->owner = !isset($theme->owner) ? '' : $theme->owner;
db_query("INSERT INTO {system} (name, owner, info, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0, 0, 0);
}
}