You are here

spaces_site.module in Spaces 6

Same filename and directory in other branches
  1. 6.2 spaces_site/spaces_site.module

File

spaces_site/spaces_site.module
View source
<?php

define('SPACES_SITE_ENABLED', 1);

/**
 * Site.
 */
if (function_exists('spaces_menu')) {
  class space_site implements space {
    var $account = NULL;
    var $title = NULL;

    /**
     * Constructor
     */
    function __construct($type, $sid = NULL, $is_active = FALSE) {
      if ($sid) {
        $this->title = variable_get('site_name', '');
        $this->prefix = '';
      }
    }

    /**
     * Implementation of space->save().
     */
    function save() {
      return;
    }

    /**
     * Implementation of space->delete().
     */
    function delete() {
      return;
    }

    /**
     * Implementation of space->feature_access().
     */
    function feature_access($feature = NULL) {
      if (!empty($this->features[$feature]) && $this->features[$feature] == SPACES_SITE_ENABLED) {
        return true;
      }
      return false;
    }

    /**
     * Implementation of space->admin_access().
     */
    function admin_access() {
      if (user_access('administer site configuration')) {
        return true;
      }
      return false;
    }

    /**
     * Implementation of space->feature_options().
     */
    function feature_options() {
      return array(
        SPACES_FEATURE_DISABLED => t('Disabled'),
        SPACES_SITE_ENABLED => t('Enabled'),
      );
    }

    /**
     * Implementation of space->links().
     */
    function links(&$links) {
      if ($this
        ->admin_access()) {

        // Add settings link for administering spaces
        $links['settings'] = array(
          'title' => t('Site settings'),
          'href' => 'spaces',
          'attributes' => array(
            'class' => 'settings',
          ),
        );
      }
    }

    /**
     * Implementation of space->form().
     */
    function form() {
      return;
    }

    /**
     * Implementation of space->preset_validate().
     */
    function validate($values) {
      return;
    }

    /**
     * Implementation of space->preset_submit().
     */
    function submit($values) {
      return array();
    }

    /**
     * Implementation of space->preset_enforce().
     */
    function preset_enforce($preset) {
    }

    /**
     * Implementation of space->redirect().
     */
    function redirect($op = 'home') {
      switch ($op) {
        case 'home':

          // use the menu path of the selected feature as homepage
          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;
      }
    }

    /**
     * Implementation of space->router().
     */
    function router($op, $object = NULL, $is_active = TRUE) {
      return true;
    }

    // Implementation of views_filter().
    function views_filter($is_active, &$query) {
    }

  }
}

/**
 * Implementation of hook_init().
 */
function spaces_site_init() {

  // Check that no space has already been initialized before
  // claiming the current space.
  $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);
  }
}

/**
 * Implementation of hook_menu().
 */
function spaces_site_menu() {
  $items = array();
  $items = spaces_active_space_menu('site', FALSE);
  return $items;
}

/**
 * Implementation of hook_spaces_types().
 */
function spaces_site_spaces_types() {
  return array(
    'site' => array(
      'class' => 'space_site',
      'title' => t('Site space'),
      'custom prefixes' => FALSE,
    ),
  );
}

Functions

Namesort descending Description
spaces_site_init Implementation of hook_init().
spaces_site_menu Implementation of hook_menu().
spaces_site_spaces_types Implementation of hook_spaces_types().

Constants