Wednesday, May 18, 2011

Important functions in bootstrap.inc

1. drupal_anonymous_user()
Syntax:
drupal_anonymous_user($session = '')

Description:
Generates a default anonymous $user object.

2. drupal_set_message()
Click here

3. ip_address()
Syntax: 
ip_address()


Description:
IP address of client machine, adjusted for reverse proxy.


4. referer_uri()
Syntax: 
referer_uri()


Description:
Return the URI of the referring page.


5. variable_init()

Syntax:
variable_init($conf = array())



Description:
Load the persistent variable table.


6. variable_set()
Syntax: 
variable_set($name, $value)


Description:
Set a persistent variable.

7. variable_get()
Syntax: 
variable_get($name, $default)


Description:
Return a persistent variable.


8. variable_del()
Syntax:
variable_del($name)


Description:
Unset a persistent variable.


9. watchdog()
Syntax: 
watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL)


Description:
/**
 * Log a system message.
 *
 * @param $type
 *   The category to which this message belongs.
 * @param $message
 *   The message to store in the log. See t() for documentation
 *   on how $message and $variables interact. Keep $message
 *   translatable by not concatenating dynamic values into it!
 * @param $variables
 *   Array of variables to replace in the message on display or
 *   NULL if message is already translated or not possible to
 *   translate.
 * @param $severity
 *   The severity of the message, as per RFC 3164

define('WATCHDOG_EMERG',    0); // Emergency: system is unusable
define('WATCHDOG_ALERT',    1); // Alert: action must be taken immediately
define('WATCHDOG_CRITICAL', 2); // Critical: critical conditions
define('WATCHDOG_ERROR',    3); // Error: error conditions
define('WATCHDOG_WARNING',  4); // Warning: warning conditions
define('WATCHDOG_NOTICE',   5); // Notice: normal but significant condition
define('WATCHDOG_INFO',     6); // Informational: informational messages
define('WATCHDOG_DEBUG',    7); // Debug: debug-level messages

 * @param $link
 *   A link to associate with the message.
 *
 * @see watchdog_severity_levels()
 */


Example:
watchdog('user_levels', 'Updated user continuum levels by admin :- Start Time = %startTime Sec', array('%startTime' => $request_startTime ), WATCHDOG_INFO);

No comments:

Post a Comment

Followers