You are here

system_service.inc in Services 7

@author Services Dev Team

Link general system functionalities to services module.

File

services/system_service/system_service.inc
View source
<?php

/**
 * @author Services Dev Team
 * @file
 *  Link general system functionalities to services module.
 */

/**
 * Returns a specified node.
 */
function system_service_connect() {
  global $user;
  $return = new stdClass();
  $return->sessid = session_id();
  $return->user = $user;
  return $return;
}
function system_service_mail($mailkey, &$message, $params) {
  $language = $message['language'];
  $variables = user_mail_tokens($params['account'], $language);
  $message['subject'] = t($params['subject'], $variables, $language->language);
  $message['body'] = t($params['body'], $variables, $language->language);
  foreach ($params['headers'] as $header => $val) {
    $message['headers'][$header] = $val;
  }
}

/**
 * Send an email using the Services module.
 */
function system_service_mailprepare($mailkey, $to, $subject, $body, $from = NULL, $headers = array()) {
  $params = array();
  $params['subject'] = $subject;
  $params['body'] = $body;
  $params['headers'] = $headers;
  $status = drupal_mail('system_service', $mailkey, $to, user_preferred_language($to), $params, $from, TRUE);
  if (!$status) {
    return services_error(t('There was a problem sending your email.'));
  }
  return $status;
}

/**
 * Returns a specified variable.
 */
function system_service_getvariable($name, $default = NULL) {
  return variable_get($name, $default);
}

/**
 * Set a variable.
 */
function system_service_setvariable($name, $value) {
  variable_set($name, $value);
}

/**
 * Check if a module is enabled. If so, return its version.
 */
function system_service_module_exists($module) {
  if (module_exists($module)) {
    $modules = module_rebuild_cache();
    if (array_key_exists($module, $modules)) {
      return (string) $modules[$module]->info['version'];
    }
  }
  return "";
}

/**
 * Returns all the available services
 */
function system_service_getservices() {
  return services_get_all();
}

/**
 * Clear all caches
 */
function system_service_cache_clear_all() {
  drupal_flush_all_caches();
  watchdog('cache clear service', 'caches cleared');
}

Functions

Namesort descending Description
system_service_cache_clear_all Clear all caches
system_service_connect Returns a specified node.
system_service_getservices Returns all the available services
system_service_getvariable Returns a specified variable.
system_service_mail
system_service_mailprepare Send an email using the Services module.
system_service_module_exists Check if a module is enabled. If so, return its version.
system_service_setvariable Set a variable.