View source
<?php
function spaces_user_init() {
if (arg(0) === 'user' && arg(1) !== 'autocomplete') {
global $user;
$uid = is_numeric(arg(1)) ? arg(1) : $user->uid;
if ($uid) {
spaces_init_space('user', $uid);
}
}
}
function spaces_user_permission() {
return array(
'configure own user space' => array(
'title' => t('configure own user space'),
'description' => t('TODO Add a description for \'configure own user space\''),
),
);
}
function spaces_user_ctools_plugin_api($module, $api) {
if ($module == 'spaces' && $api == 'plugins') {
return array(
'version' => 3,
);
}
}
function spaces_user_spaces_plugins() {
$plugins = array();
$plugins['space_user'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'spaces_user') . '/plugins',
'file' => 'space_user.inc',
'class' => 'space_user',
'parent' => 'space_type',
),
);
return $plugins;
}
function spaces_user_spaces_registry() {
return array(
'types' => array(
'user' => array(
'title' => t('User space'),
'plugin' => 'space_user',
'path' => 'user/%user',
),
),
);
}
function spaces_user_form_user_profile_form_alter(&$form, &$form_state) {
module_load_include('inc', 'spaces', 'spaces.admin');
$presets = spaces_preset_load(NULL, 'user');
if (count($presets) === 1) {
$form['spaces_preset_user'] = array(
'#type' => 'value',
'#value' => key($presets),
);
}
else {
if (count($presets) > 1) {
$form = array();
$form['spaces_preset'] = spaces_preset_form($presets, 'user');
}
}
}
function spaces_user_user_insert(&$edit, $account, $category) {
if (!empty($edit['spaces_preset_user'])) {
$space = spaces_load('user', $account->uid);
if ($space
->activate()) {
$space->controllers->variable
->set('spaces_preset_user', $edit['spaces_preset_user']);
}
}
}
function spaces_user_user_update(&$edit, $account, $category) {
if (!empty($edit['spaces_preset_user'])) {
$space = spaces_load('user', $account->uid);
if ($space
->activate()) {
$space->controllers->variable
->set('spaces_preset_user', $edit['spaces_preset_user']);
}
}
}
function spaces_user_form_spaces_features_form_alter(&$form, &$form_state) {
$space = spaces_get_space();
if ($space && $space->type === 'user' && !empty($form['site_frontpage'])) {
unset($form['site_frontpage']);
}
}