Пример #1
0
 /**
  * update log action in the database
  */
 function update_log_action($action_id, $description, $info_template, $active, $expires)
 {
     if ($description === '') {
         throw new InvalidArgumentException(_('Keine Beschreibung angegeben.'));
     } else {
         if ($info_template === '') {
             throw new InvalidArgumentException(_('Kein Info-Template angegeben.'));
         } else {
             if ($expires < 0) {
                 throw new InvalidArgumentException(_('Ablaufzeit darf nicht negativ sein.'));
             }
         }
     }
     $action = LogAction::find($action_id);
     if (!$action) {
         throw new InvalidArgumentException(_('Unbekannte Aktion.'));
     }
     $action->description = $description;
     $action->info_template = $info_template;
     $action->active = $active;
     $action->expires = $expires;
     $action->store();
 }
Пример #2
0
 /**
  * Finds all objects related to the given action by search string.
  * The search string can be either a part of the name or the id
  * of the object.
  * 
  * Calls the method Loggable::logSearch() to retrieve the result.
  * 
  * @param string $needle
  * @param type $action_id
  * @return type
  */
 public static function searchObjectByAction($needle, $action_id)
 {
     $action = LogAction::find($action_id);
     if ($action) {
         switch ($action->type) {
             case 'plugin':
                 $plugin_manager = PluginManager::getInstance();
                 $plugin_info = $plugin_manager->getPluginInfo($action->class);
                 $class_name = $plugin_info['class'];
                 $plugin = $plugin_manager->getPlugin($class_name);
                 if ($plugin instanceof Loggable) {
                     return $class_name::logSearch($needle, $action->name);
                 }
                 break;
             case 'file':
                 if (!file_exists($action->filename)) {
                     require_once $action->filename;
                     $class_name = $action->class;
                     if ($class_name instanceof Loggable) {
                         return $class_name::logSearch($needle, $action->name);
                     }
                 }
                 break;
             case 'core':
                 $class_name = $action->class;
                 if ($class_name instanceof Loggable) {
                     return $class_name::logSearch($needle, $action->name);
                 }
         }
     }
     return array();
 }