spaces_site.module in Spaces 6
File
spaces_site/spaces_site.module
View source
<?php
define('SPACES_SITE_ENABLED', 1);
if (function_exists('spaces_menu')) {
class space_site implements space {
var $account = NULL;
var $title = NULL;
function __construct($type, $sid = NULL, $is_active = FALSE) {
if ($sid) {
$this->title = variable_get('site_name', '');
$this->prefix = '';
}
}
function save() {
return;
}
function delete() {
return;
}
function feature_access($feature = NULL) {
if (!empty($this->features[$feature]) && $this->features[$feature] == SPACES_SITE_ENABLED) {
return true;
}
return false;
}
function admin_access() {
if (user_access('administer site configuration')) {
return true;
}
return false;
}
function feature_options() {
return array(
SPACES_FEATURE_DISABLED => t('Disabled'),
SPACES_SITE_ENABLED => t('Enabled'),
);
}
function links(&$links) {
if ($this
->admin_access()) {
$links['settings'] = array(
'title' => t('Site settings'),
'href' => 'spaces',
'attributes' => array(
'class' => 'settings',
),
);
}
}
function form() {
return;
}
function validate($values) {
return;
}
function submit($values) {
return array();
}
function preset_enforce($preset) {
}
function redirect($op = 'home') {
switch ($op) {
case 'home':
if ($home = $this->settings['home']) {
$features = spaces_features();
if (is_array($features[$home]->spaces['menu'])) {
reset($features[$home]->spaces['menu']);
$item = current($features[$home]->spaces['menu']);
$home_path = $item['href'];
drupal_goto($home_path);
}
}
else {
drupal_goto('<front>');
}
break;
case 'features':
drupal_goto('spaces/features');
break;
}
}
function router($op, $object = NULL, $is_active = TRUE) {
return true;
}
function views_filter($is_active, &$query) {
}
}
}
function spaces_site_init() {
$space = spaces_get_space();
if (!$space) {
context_set('spaces', 'sid', 1);
$space = spaces_load('site', 1, TRUE);
if (!$space) {
$space = spaces_load('site', NULL, TRUE);
}
$space->sid = '1';
spaces_set_space($space);
}
}
function spaces_site_menu() {
$items = array();
$items = spaces_active_space_menu('site', FALSE);
return $items;
}
function spaces_site_spaces_types() {
return array(
'site' => array(
'class' => 'space_site',
'title' => t('Site space'),
'custom prefixes' => FALSE,
),
);
}