class_logging.inc 4.99 KiB
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2007  Fabian Hickert
  Copyright (C) 2011-2016  FusionDirectory
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
/*!
 * \file class_logging.inc
 * Source code for the class logging
/*!
 * \brief This is the base class for the FusionDirectory logging functionality.
 * All logging should lead to this class.
 * \author  Fabian Hickert <hickert@gonicus.de>
 * \version 2.6
 * \date    11.04.2007
class logging {
  static $validActions = array('modify','create','remove','copy','snapshot','view','security','debug');
  /*!
   * \brief logging method
   * \param $action         One of these values (modify|create|remove|snapshot|copy|view|security|debug)
   * \param $objecttype     represents the current edited objecttype, like user/user
   * \param $object         represents the current edited object dn
   * \param $changes_array  An array containing names of all touched attributes
   * \param $result         A status message, containing errors or success messages
  static function log ($action, $objecttype, $object, $changes_array = array(), $result = '')
    global $config, $ui;
    if (!is_array($changes_array)) {
      trigger_error('log(string,string,string,array(),bool). Forth parameter must be an array.');
      $changes_array = array();
    /* Create data object */
    $entry = array(
      'timestamp'   => time(),
      'action'      => $action,
      'objecttype'  => $objecttype,
      'object'      => $object,
      'changes'     => $changes_array,
      'result'      => $result
    if (isset($ui->dn) && !empty($ui->dn)) {
      $entry['user']  = $ui->dn;