示例#1
0
 /**
  * get log events (max. 50) for selected action, starting at offset
  */
 function get_log_events($action_id, $object_id, $offset)
 {
     $offset = (int) $offset;
     $filter = $this->sql_event_filter($action_id, $object_id, $parameters) ?: '1';
     $log_events = LogEvent::findBySQL($filter . " ORDER BY mkdate DESC LIMIT {$offset}, 50", $parameters);
     foreach ($log_events as $log_event) {
         $events[] = array('time' => $log_event->mkdate, 'info' => $log_event->formatEvent(), 'detail' => $log_event->info, 'debug' => $log_event->dbg_info);
     }
     return $events;
 }
示例#2
0
 /**
  * Finds all users by given search string. Searches for the users id,
  * part of the name or the username.
  * 
  * @param type $needle The needle to search for.
  * @return array
  */
 public static function searchUser($needle)
 {
     $result = array();
     $users = User::findBySQL("Nachname LIKE CONCAT('%', :needle, '%')\n                     OR Vorname LIKE CONCAT('%', :needle, '%')\n                     OR CONCAT(Nachname, ', ', Vorname) LIKE CONCAT('%', :needle, '%')\n                     OR CONCAT(Vorname, ' ', Nachname) LIKE CONCAT('%', :needle, '%')\n                     OR username LIKE CONCAT('%', :needle, '%')", array(':needle' => $needle));
     foreach ($users as $user) {
         $name = sprintf('%s (%s)', my_substr($user->getFullname(), 0, 20), $user->username);
         $result[] = array($user->getId(), $name);
     }
     // search for deleted users
     //
     // The name of the user is part of info field,
     // old id (still in DB) is in affected column.
     //
     // The log action "USER_DEL" was removed from the list of initially
     // registered log actions in the past.
     // Search for the user if it is still in database. If not, the search
     // for deleted users is not possible.
     $log_action_deleted_user = SimpleORMapCollection::createFromArray(LogAction::findByName('USER_DEL'))->first();
     if ($log_action_deleted_user) {
         $log_events_deleted_user = LogEvent::findBySQL("action_id = ? AND info LIKE CONCAT('%', ?, '%')", array($log_action_deleted_user->getId(), $needle));
         foreach ($log_events_deleted_user as $log_event) {
             $name = sprintf('%s (%s)', $log_event->info, _('gelöscht'));
             $result[] = array($log_event->affected_range_id, $name);
         }
     }
     return $result;
 }