You are here

object_log.module in Object Log 7

Same filename and directory in other branches
  1. 8 object_log.module

File

object_log.module
View source
<?php

/**
 * Implements hook_menu().
 */
function object_log_menu() {
  $items = array();
  $items['admin/reports/object_log'] = array(
    'title' => 'Object log',
    'description' => 'View objects saved in the object log.',
    'page callback' => 'object_log_overview_page',
    'access arguments' => array(
      'access devel information',
    ),
    'type' => MENU_NORMAL_ITEM,
    'file' => 'object_log.admin.inc',
  );
  $items['admin/reports/object_log/%'] = array(
    'title' => 'Object log',
    'description' => 'View objects saved in the object log.',
    'page callback' => 'object_log_object_page',
    'page arguments' => array(
      3,
    ),
    'access arguments' => array(
      'access devel information',
    ),
    'type' => MENU_NORMAL_ITEM,
    'file' => 'object_log.admin.inc',
  );
  return $items;
}

/**
 * Store a variable in the object log.
 *
 * @param $label
 *   A name to use for this object when storing in the log table. Using an
 *   already existing label will overwrite that object in the log.
 * @param $data
 *   The variable to store.
 */
function object_log($label, $data) {
  $fields = array(
    'data' => serialize($data),
    'created' => REQUEST_TIME,
  );
  db_merge('object_log')
    ->key(array(
    'label' => $label,
  ))
    ->fields($fields)
    ->execute();
}

/**
 * Retrieve an object row from the object log.
 *
 * @param $label
 *   The label of an object to be retrieved.
 * @return
 *   The database row as a fetched object. $log->data contains the actual
 *   stored object.
 */
function object_log_retrieve($label) {
  $result = db_query('SELECT label, data, created FROM {object_log} WHERE label = :label', array(
    ':label' => $label,
  ));
  $log = $result
    ->fetchObject();
  if (empty($log->data)) {
    return FALSE;
  }
  $log->data = unserialize($log->data);
  return $log;
}

/**
 * Clear the object log.
 */
function object_log_clear_log() {
  db_delete('object_log')
    ->execute();
}

Functions

Namesort descending Description
object_log Store a variable in the object log.
object_log_clear_log Clear the object log.
object_log_menu Implements hook_menu().
object_log_retrieve Retrieve an object row from the object log.