You are here

function availability_calendar_getsettings in Availability Calendars 6

Utility function to get settings related to nodes or administration.

Parameters

string $scope:

string $arg:

Return value

object When $scope is set to 'node' then the system settings are moved under $settings->system. Otherwise settings are set within the root of the object.

7 calls to availability_calendar_getsettings()
availability_calendars_admin_settings in ./availability_calendars.module
Settings page callback.
availability_calendars_form_alter in ./availability_calendars.module
Implementation of hook_form_alter(). All form alterations needed for the calendars.
availability_calendars_nodeapi in ./availability_calendars.module
Implementation hook node_nodeapi().
availability_calendars_node_edit_form in ./availability_calendars.module
Creates the node edit form.
availability_calendars_options in ./availability_calendars.module
availability_calendars status options.

... See full list

File

./availability_calendars.module, line 385
Availability Calendars Module.

Code

function availability_calendar_getsettings($scope = NULL, $arg = NULL) {
  switch ($scope) {
    case 'nodetype':
      $settings = variable_get('availability_calendars_settings_system-type_' . $arg, 0);
      break;
    case 'node':
      if ($arg) {
        $settings->startofweek = variable_get('availability_calendars_settings_node_' . $arg . '_startofweek', 1);
        $settings->showkey = variable_get('availability_calendars_settings_node_' . $arg . '_showkey', 1);
        $settings->firstletter = variable_get('availability_calendars_settings_node_' . $arg . '_firstletter', 0);
        $settings->showteaser = variable_get('availability_calendars_settings_node_' . $arg . '_showteaser', 0);
        $settings->hideold = variable_get('availability_calendars_settings_system_hideold', 0) ? 1 : variable_get('availability_calendars_settings_node_' . $arg . '_hideold', 0);
        $settings->defaultstatus = variable_get('availability_calendars_settings_node_' . $arg . '_defaultstatus', NULL) === NULL ? variable_get('availability_calendars_settings_system_defaultstatus', 'calavailable') : variable_get('availability_calendars_settings_node_' . $arg . '_defaultstatus', 'calavailable');
      }
    default:
      $types = node_get_types();
      $system->status = array();
      foreach ($types as $id => $val) {
        $system->status[$val->type] = variable_get('availability_calendars_settings_system-type_' . $val->type, 0);
      }
      $system->monthcount = variable_get('availability_calendars_settings_system_monthcount', 12);
      $system->nodeview = variable_get('availability_calendars_settings_system_nodeview', 1);
      $system->showteaser = variable_get('availability_calendars_settings_system_showteaser', 1);
      $system->splitday = variable_get('availability_calendars_settings_system_splitday', 0);
      $system->hideold = variable_get('availability_calendars_settings_system_hideold', 0);
      $system->defaultstatus = variable_get('availability_calendars_settings_system_defaultstatus', 'calavailable');
      if ($scope == 'node' && $arg) {
        $settings->system = $system;
      }
      else {
        $settings = $system;
      }
      break;
  }
  return $settings;
}