From ae87133905d183987eb75369fe94bb739a2b1cb9 Mon Sep 17 00:00:00 2001 From: rohieb Date: Thu, 7 Aug 2008 03:21:56 +0200 Subject: [PATCH] Imported sources --- .hgignore | 4 + .project | 22 + .settings/org.eclipse.core.resources.prefs | 3 + .settings/org.eclipse.core.runtime.prefs | 3 + .../org.eclipse.php.core.projectOptions.prefs | 6 + Doxyfile | 173 ++++++++ Makefile | 129 ++++++ debian/changelog | 18 + debian/compat | 1 + debian/conffiles | 1 + debian/control | 14 + debian/copyright | 43 ++ debian/dirs | 4 + debian/files | 1 + debian/postinst | 10 + debian/postrm | 13 + debian/prerm | 6 + debian/rules | 61 +++ doc/TODO | 6 + doc/changelog.old.html | 56 +++ img/16/mod_error-reporter.png | Bin 0 -> 860 bytes img/32/mod_error-reporter.png | Bin 0 -> 2268 bytes inc/class_erConfig.inc | 208 +++++++++ inc/class_erErrorReport.inc | 178 ++++++++ inc/class_erErrorReportManager.inc | 414 ++++++++++++++++++ inc/class_erErrorReportView.inc | 247 +++++++++++ inc/functions.inc | 169 +++++++ inc/init.inc | 39 ++ lang/mod_error-reporter.po | 180 ++++++++ maint/update-config.sh | 24 + maint/update.php | 94 ++++ nav/79mod_error-reporter.mod | 32 ++ nav/admin/99mod_error-reporter-cfg.mod | 29 ++ priv/mod_error-reporter | 7 + sql/log_module/mod_error-reporter | 1 + sql/mod_error-reporter.sql | 42 ++ src/config.php | 135 ++++++ src/detail.php | 124 ++++++ src/index.php | 159 +++++++ 39 files changed, 2656 insertions(+) create mode 100644 .hgignore create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.core.runtime.prefs create mode 100644 .settings/org.eclipse.php.core.projectOptions.prefs create mode 100644 Doxyfile create mode 100644 Makefile create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/conffiles create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/files create mode 100755 debian/postinst create mode 100755 debian/postrm create mode 100755 debian/prerm create mode 100755 debian/rules create mode 100644 doc/TODO create mode 100644 doc/changelog.old.html create mode 100644 img/16/mod_error-reporter.png create mode 100644 img/32/mod_error-reporter.png create mode 100644 inc/class_erConfig.inc create mode 100644 inc/class_erErrorReport.inc create mode 100644 inc/class_erErrorReportManager.inc create mode 100644 inc/class_erErrorReportView.inc create mode 100644 inc/functions.inc create mode 100644 inc/init.inc create mode 100644 lang/mod_error-reporter.po create mode 100755 maint/update-config.sh create mode 100644 maint/update.php create mode 100644 nav/79mod_error-reporter.mod create mode 100644 nav/admin/99mod_error-reporter-cfg.mod create mode 100644 priv/mod_error-reporter create mode 100644 sql/log_module/mod_error-reporter create mode 100644 sql/mod_error-reporter.sql create mode 100644 src/config.php create mode 100644 src/detail.php create mode 100644 src/index.php diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..aa24134 --- /dev/null +++ b/.hgignore @@ -0,0 +1,4 @@ +.cache +doc/source +src/newfile.php +inc/config.inc diff --git a/.project b/.project new file mode 100644 index 0000000..b054eb7 --- /dev/null +++ b/.project @@ -0,0 +1,22 @@ + + + iserv-mod-error-reporter + + + + + + org.eclipse.php.core.PhpIncrementalProjectBuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.php.core.PHPNature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..9cc46de --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Tue Oct 23 22:47:09 CEST 2007 +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.core.runtime.prefs b/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000..513e138 --- /dev/null +++ b/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,3 @@ +#Tue Oct 23 22:47:09 CEST 2007 +eclipse.preferences.version=1 +line.separator=\n diff --git a/.settings/org.eclipse.php.core.projectOptions.prefs b/.settings/org.eclipse.php.core.projectOptions.prefs new file mode 100644 index 0000000..db7054a --- /dev/null +++ b/.settings/org.eclipse.php.core.projectOptions.prefs @@ -0,0 +1,6 @@ +#Tue Jul 29 00:16:47 GMT 2008 +eclipse.preferences.version=1 +instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true +org.eclipse.php.core.contextRoot= +org.eclipse.php.core.defaultEncoding= +org.eclipse.php.core.includePath=\n\n\t\n\n\n diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..e000bde --- /dev/null +++ b/Doxyfile @@ -0,0 +1,173 @@ +# Doxyfile 1.5.5 +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +PROJECT_NAME = iserv-mod-error-reporter +PROJECT_NUMBER = 8.08.05 +OUTPUT_DIRECTORY = doc/source +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = YES +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = YES +JAVADOC_AUTOBRIEF = YES +MULTILINE_CPP_IS_BRIEF = +DETAILS_AT_TOP = YES +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = YES +TAB_SIZE = 4 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = YES +SUBGROUPING = +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = +HIDE_IN_BODY_DOCS = +INTERNAL_DOCS = +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = +SHOW_INCLUDE_FILES = YES +INLINE_INFO = +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = YES +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST = YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = NO +FILE_VERSION_FILTER = +QUIET = YES +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = YES +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +INPUT = inc +FILE_PATTERNS = +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = NO +USE_HTAGS = NO +VERBATIM_HEADERS = YES +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = +TOC_EXPAND = +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = YES +USE_PDFLATEX = YES +LATEX_BATCHMODE = YES +LATEX_HIDE_INDICES = NO +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +GENERATE_AUTOGEN_DEF = NO +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +ENABLE_PREPROCESSING = +MACRO_EXPANSION = +EXPAND_ONLY_PREDEF = +SEARCH_INCLUDES = +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +CLASS_DIAGRAMS = NO +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = YES +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = YES +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +SEARCHENGINE = NO diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a4bf949 --- /dev/null +++ b/Makefile @@ -0,0 +1,129 @@ +# +# @file Makefile +# Makefile for installing, creating documentation etc. +# @author Roland Hieber (roland.hieber@wilhelm-gym.net) +# @date 06.10.2007 +# @package iserv_errorreporter +# +# Copyright © 2007 Roland Hieber +# +# Permission is hereby granted, free of charge, to any person obtaining +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +INSTALLDIR=/opt/iserv +LN=ln -f +RM=rm -rf +CHOWN=chown -f +MKDIR=mkdir -p + +# hardlink the files to their destinations +links: sourcedoc + # documentation + $(MKDIR) $(DESTDIR)/usr/share/doc/iserv-mod-error-reporter/source/ + if [ ! -d $(DESTDIR)/usr/share/doc/iserv/mod/ ]; then $(MKDIR) $(DESTDIR)/usr/share/doc/iserv/mod/; fi + $(LN) doc/{TODO,changelog.old.html} debian/copyright $(DESTDIR)/usr/share/doc/iserv-mod-error-reporter + $(LN) doc/source/* $(DESTDIR)/usr/share/doc/iserv-mod-error-reporter/source/ + $(RM) $(DESTDIR)/usr/share/doc/iserv/mod/error-reporter # remove old link + $(LN) -s ../../iserv-mod-error-reporter $(DESTDIR)/usr/share/doc/iserv/mod/error-reporter + + # images + if [ ! -d $(DESTDIR)/usr/share/iserv/www/img/default/16 ] ; then $(MKDIR) $(DESTDIR)/usr/share/iserv/www/img/default/16; fi + if [ ! -d $(DESTDIR)/usr/share/iserv/www/img/default/32 ] ; then $(MKDIR) $(DESTDIR)/usr/share/iserv/www/img/default/32; fi + $(LN) img/16/*.png $(DESTDIR)/usr/share/iserv/www/img/default/16 + $(LN) img/32/*.png $(DESTDIR)/usr/share/iserv/www/img/default/32 + + # localization + if [ ! -d $(DESTDIR)/usr/share/iserv/locale/de ] ; then $(MKDIR) $(DESTDIR)/usr/share/iserv/locale/de; fi + $(LN) lang/mod_error-reporter.po $(DESTDIR)/usr/share/iserv/locale/de + + # SQL data + if [ ! -d $(DESTDIR)/usr/share/iserv/db/log_module ] ; then $(MKDIR) $(DESTDIR)/usr/share/iserv/db/log_module; fi + $(LN) sql/mod_error-reporter.sql $(DESTDIR)/usr/share/iserv/db/ + $(LN) sql/log_module/mod_error-reporter $(DESTDIR)/usr/share/iserv/db/log_module + + # privileges + if [ ! -d $(DESTDIR)/usr/share/iserv/priv ] ; then $(MKDIR) $(DESTDIR)/usr/share/iserv/priv; fi + $(LN) priv/mod_error-reporter $(DESTDIR)/usr/share/iserv/priv + + # includes + $(MKDIR) $(DESTDIR)/usr/share/iserv/www/inc/mod_error-reporter + $(LN) inc/{class*,init,functions}.inc $(DESTDIR)/usr/share/iserv/www/inc/mod_error-reporter + if [ ! -e $(DESTDIR)/usr/share/iserv/www/inc/mod_error-reporter/config.inc ] ; then touch $(DESTDIR)/usr/share/iserv/www/inc/mod_error-reporter/config.inc; fi +ifeq ($(USER),root) + chmod u+rw $(DESTDIR)/usr/share/iserv/www/inc/mod_error-reporter/config.inc + chown www-data $(DESTDIR)/usr/share/iserv/www/inc/mod_error-reporter/config.inc +endif + + # navigation + if [ ! -d $(DESTDIR)/usr/share/iserv/www/nav/admin ] ; then $(MKDIR) $(DESTDIR)/usr/share/iserv/www/nav/admin; fi + $(LN) nav/*.mod $(DESTDIR)/usr/share/iserv/www/nav + $(LN) nav/admin/*.mod $(DESTDIR)/usr/share/iserv/www/nav/admin + + # web pages + $(MKDIR) $(DESTDIR)/usr/share/iserv/www/mod_error-reporter + $(LN) src/{config,detail,index}.php $(DESTDIR)/usr/share/iserv/www/mod_error-reporter + + # maintenance files + $(MKDIR) $(DESTDIR)/usr/share/iserv/modules/error-reporter + $(LN) maint/update.php $(DESTDIR)/usr/share/iserv/modules/error-reporter + +# build doxygen documentation from source +sourcedoc: + doxygen + mv doc/source/html/* doc/source/ && rm -rf doc/source/html + +install: links +ifeq ($(USER),root) + chklocale + chkpriv + chkdb -r +endif + +# uninstalling +uninstall: + $(RM) $(DESTDIR)/usr/share/doc/iserv/mod/error-reporter + $(RM) $(DESTDIR)/usr/share/doc/iserv-mod-error-reporter + $(RM) $(DESTDIR)/usr/share/iserv/www/img/{16,32}/mod_error-reporter.png + $(RM) $(DESTDIR)/usr/share/iserv/sql/mod_error-reporter.sql + $(RM) $(DESTDIR)/usr/share/iserv/sql/log_module/mod_error-reporter + $(RM) $(DESTDIR)/usr/share/iserv/priv/mod_error-reporter + $(RM) $(DESTDIR)/usr/share/iserv/www/inc/mod_error-reporter + $(RM) $(DESTDIR)/usr/share/iserv/www/nav/79mod_error-reporter.mod + $(RM) $(DESTDIR)/usr/share/iserv/www/nav/admin/99mod_error-reporter.mod + $(RM) $(DESTDIR)/usr/share/iserv/www/mod_error-reporter + +ifeq ($(USER),root) + chklocale + chkpriv + psql -c "DELETE FROM log_module WHERE module='Error Report Wizard';" +endif + + @echo + @echo If you do not need the SQL tables anymore, remove them by running + @echo ' psql -c "DROP TABLE mod_errorreports;"' + @echo After that, all reported errors are unrecoverably deleted! + @echo + +# clean up +clean: distclean + +distclean: + $(RM) doc/source + +.PHONY: clean distclean install diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..45b3758 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,18 @@ +iserv-mod-error-reporter (8.08.07-0) unstable; urgency=low + + * Initial release for IServ2 + * ability to specify groups who should be the only ones to report errors and + see the existing messages + * added link to http://www.chiark.greenend.org.uk/~sgtatham/bugs.html + before submission form + * trying to delete a non-existing error message via URL does no longer + produce an error message + * notification mails are only sent if the report is new, not when the report + was edited + * log messages contain more information (machine name, text) + * changes to IServ1: + - user rights can be configured via group privileges (Administration -> + Groups -> select a group -> Privileges) + - logging is always enabled + + -- Roland Hieber (Package Signing Key) Wed, 6 Aug 2008 17:17:04 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/conffiles b/debian/conffiles new file mode 100644 index 0000000..4bafda8 --- /dev/null +++ b/debian/conffiles @@ -0,0 +1 @@ +/usr/share/iserv/www/inc/mod_error-reporter/config.inc diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..1e8a328 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: iserv-mod-error-reporter +Section: non-free/web +Priority: optional +Maintainer: Roland Hieber (Package Signing Key) +Build-Depends: debhelper (>= 5) +Standards-Version: 3.7.2 + +Package: iserv-mod-error-reporter +Architecture: all +Depends: iserv-portal (>= 8.07.11) +Description: Fehlermeldungsassistent für IServ + Dieses Modul ermöglicht es Benutzern, Fehler über ein Formular im IDesk + zu melden. Administratoren können diese Fehlermeldungen einsehen und + löschen. \ No newline at end of file diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..411363f --- /dev/null +++ b/debian/copyright @@ -0,0 +1,43 @@ +== License == + +The module has been released under the terms of the MIT License, as printed +following in its original version. Some images which have been used have been +released under the terms of the GNU Lesser General Public License (see +http://www.fsf.org/licensing/licenses/lgpl.html). These are in particular: + * /opt/iserv/idesk/img/16/mod_error-reporter.png + * /opt/iserv/idesk/img/32/mod_error-reporter.png + +If you enjoy this software, you are free to support his author with a small +donation: + + Roland Hieber + IBAN: DE98 250 500 000 150 2141 79 + BIC: NOLADE2HXXX (Norddeutsche Landesbank Hannover) + +You can also send material donations to + Roland Hieber + Großer Hilligenhof 7 + 38154 Königslutter + GERMANY + + +=== License terms === +Copyright (c) 2007 Roland Hieber + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..2f93f02 --- /dev/null +++ b/debian/dirs @@ -0,0 +1,4 @@ +usr/share/iserv/www/inc/mod_error-reporter/ +usr/share/iserv/www/mod_error-reporter/ +usr/share/iserv/modules/ +usr/share/iserv/modules/error-reporter/ diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..02ae300 --- /dev/null +++ b/debian/files @@ -0,0 +1 @@ +iserv-mod-error-reporter_8.08.07-0_all.deb non-free/web optional diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..9d55bf5 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,10 @@ +#!/bin/sh +touch /usr/share/iserv/www/inc/mod_error-reporter/config.inc +chmod g+w /usr/share/iserv/www/inc/mod_error-reporter/config.inc +chgrp www-data /usr/share/iserv/www/inc/mod_error-reporter/config.inc +chkdb -r +chkpriv +chklocale +# run update script +php /usr/share/iserv/modules/error-reporter/update.php +#DEBHELPER# diff --git a/debian/postrm b/debian/postrm new file mode 100755 index 0000000..4fdf0ba --- /dev/null +++ b/debian/postrm @@ -0,0 +1,13 @@ +#!/bin/sh +psql -c "DELETE FROM log_module WHERE module='Error Report Assistant';" +chklocale + +#DEBHELPER# + +if [ "$1" = "purge" ]; then + echo + echo If you do not need the SQL tables anymore, remove them by running + echo ' psql -c "DROP TABLE mod_errorreporter;"' + echo After that, all error reports are unrecoverably deleted! + echo +fi; diff --git a/debian/prerm b/debian/prerm new file mode 100755 index 0000000..e912711 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,6 @@ +#!/bin/sh +if [ "$1" = "purge" ]; then + rm -f /usr/share/iserv/www/inc/mod_error-reporter/config.inc +fi; + +#DEBHELPER# diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..46f3010 --- /dev/null +++ b/debian/rules @@ -0,0 +1,61 @@ +#!/usr/bin/make -f +# rules for debuild + +# needed for lintian +build: + dh_testdir + +binary-indep: + -$(MAKE) clean + dh_clean + + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(MAKE) DESTDIR=$(CURDIR)/debian/iserv-mod-error-reporter install + + # we rather install the documentation via dh_installdocs + rm -rf $(CURDIR)/debian/iserv-mod-error-reporter/usr/share/doc/iserv-mod-error-reporter + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs doc/{changelog.old.html,TODO} doc/source/ + #dh_installexamples + ##dh_install + ##dh_installmenu + ##dh_installdebconf + ##dh_installlogrotate + ##dh_installemacsen + ##dh_installpam + ##dh_installmime + ##dh_python + #dh_installinit + #dh_installcron + #dh_installinfo + #dh_installman + #dh_link + #dh_strip + dh_compress + dh_fixperms + ##dh_perl + ##dh_makeshlibs + dh_installdeb + #dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +# needed for lintian +binary-arch: + +binary: binary-indep + +clean: + dh_testdir + dh_testroot + -$(MAKE) clean + dh_clean + +.PHONY: build clean binary-indep binary install + diff --git a/doc/TODO b/doc/TODO new file mode 100644 index 0000000..6f0c06b --- /dev/null +++ b/doc/TODO @@ -0,0 +1,6 @@ +== TODO == + +* documentation: SQL table schema +* list view + - add a nice toolbar for admins with button for deletion +* board-like discussion for admins, moer than one comment per error message diff --git a/doc/changelog.old.html b/doc/changelog.old.html new file mode 100644 index 0000000..41e4e6f --- /dev/null +++ b/doc/changelog.old.html @@ -0,0 +1,56 @@ + + + IServ – Fehlermeldungs-Assistent – Changelog + + + + + +

Changelog

+

Änderungen für neuere Versionen befinden sich im Debian-Changelog.

+

iserv-error-reporter-4.1

+
    +
  • Reparierte Fehler:
      +
    • Kosmetik: Fehler beim Löschen und Bearbeiten von nicht existenten Fehlermeldungen
    • +
  • +
+ +

iserv-error-reporter-4.0

+Release: 28. Oktober 2007 +
    +
  • komplette Neuentwicklung des Codes
  • +
  • englische Übersetzung
  • +
  • Feld „Klasse” entfernt, da überflüssig
  • +
  • Anmeldung am IDesk nötig
  • +
  • Admins: Konfigurations-Seite
  • +
  • Dokumentation: Schnittstellen dokumentiert
  • +
  • Notiz: Modul umbenannt nach iserv-error-reporter
  • +
  • Reparierte Fehler:
      +
    • Ändern und Löschen von Fehlermeldungen für Nicht-Admins möglich
    • +
    • Verstecken von Fehlermeldungen ohne einen Kommentar ergab eine SQL-Fehlermeldung
    +
+ +

iserv-errors-3.0

+Release: 24. April 2007 +
    +
  • MIT-Lizenz als neue Lizenz, manche Symbole allerdings unter der GNU LGPL veröffentlicht
  • +
  • Neue Dokumentation:
      +
    • Changelog
    • +
    • TODO
    • +
    • Lizenz
    • +
    • über „IServ-Dokumentation” → „Module” erreichbar
    +
  • Admins: Verwalten der Fehlermeldungen auf der selben Seite wie das Eintragen, Seite im Verwaltungsmenü existiert nicht mehr
  • +
  • Benutzer können eigene Einträge bearbeiten und löschen
  • +
  • einige neue Bildchen
  • +
  • SQL-Tabelle wird von chkdb repariert
  • +
  • zur leichteren Installation als RPM gepackt
  • +
  • vollständige Umstellung des Quelltexte auf Englisch, kein Englisch-Deutsch-Mischmasch
  • +
  • Reparierte Fehler: +
+ +Für ältere Versionen liegen keine genauen Informationen vor. + + diff --git a/img/16/mod_error-reporter.png b/img/16/mod_error-reporter.png new file mode 100644 index 0000000000000000000000000000000000000000..b88c5844b8c671647d11f43de88a8643fe2e58d7 GIT binary patch literal 860 zcmV-i1Ec(jP)@jEM=5HZ6!0(#TD#R3bv+#3AVi=&d(Ylna;mo?Q9~ zqMUL-C~s0vk&;L#m!?uqCPG3jgdW_QIN&683pRdT?{4QYjg*n*c}Am|`Tyrd1>^Ba zU;x7yBxa0=9l!t8!b1X|X3wW9j;0rIee1;~F&hLyOMa~#L!Nj)(Za=0=|{7d9)5Xh zh`Efzxj~!JxQ*TGaP$0JL1G<=wdIeBS}Hi>%nM@r$^3VZ&W)sSDn%llIs=^s2Z2RB zF~aZV3bnyBW@?z!nNRrs?(G?2&@i$3RqWBB1jgPg;`KKqEQKT%u zsxQqgao{hW8aV;oaqWX3RNbJ(tn+d0GxJWSumYfGz2)vRE)g%mS2VsPm6mVW` z!B5v{y?jA6o}ugYsI@$r2xu5~CEkny(CG^J7t-!L*~Kcn>iE$=D~?Bhd*+yt9@2P8X!=BC(} z0*)CYfA99>2|7LLSyQHQ^}(HsjaZzm@>@!w$?0$BDIItCZT~&Tg4z(C2Zu*O8{MX+ z-qXl6nL<-E`pX|hDzdx6?q59Jy+fcBrxHUXrD)BH(w5%kNa~W)BUHX#Qz)v$5eBl3 z^Rr*z#9~78HL3J4Gcz;%xwl702I&QX%vUc*Bn(c5uI=UJ<#1tPf%WxuDQ>X1xX9}2 zD#>IL(==sWM~sb)F+Dv^KA-Pb(3jE|jj*$`L$O$-TCK9Nv7yP(?RJ@(nxb4T_x&Fd zb&|f6zO1aQC>=a8F+nz)B_`CZqjPC m$mMcuZ*R{Q3Wc4IBmV<=OeScTr=}PH0000010qNS#tmY3lIPR3lIUVBfWJ1000McNliru(g73$Ee$Q?X7>O92x&<~ zK~#7FjaO@nT~`@?*53Qh+6Y3A z-G+=4h^*%mgcubdvRU+kunz2A7}(mm7*0c}EEmi2IRitP-F)HLdk=p6yQ}@fpK*L2 zVHl#nzV?^TzWv6JxJS)-U4k`K7$&Ut?pQ$dzC&#TNT^R}Pjh0Li{)rMM_nNG`Cpy= z+%+TcNoYh|TRw7w5DwRDljJ_9{q8q!{`(t-j@sOHmke~dj!W_Q9#9K_7(~KCF94H< z#3eQ*Hcnk&Us2nt^uogvuYL6NNn~g&lQQ8s9kjX*+8q}S*Tei~6Adn%_x+jg-@5S> zjkjpD%{81@=pt%~g&4$s01|kz`xHftXQ}hlW%iW+G;!hDePg3A+8aQp3FUHQz6X!4 z?U2wG*;a*qyme<5K|0&b4OOxoF89N~{_!4y=x{AzB4Hr`5yyfsAU;n3$nNQDBTrov z055;(E7$v?5aq~4y4yh3+2k&}utOgXW2~kPIGKK|M+U6HQA|$152M_V(+@s`_ZOG& zlWQ-ZkAiN zOwmX=>>_QFEbdf|9fw}1BFmU4tktk)WL#Vtk(OP#%aQL36@xV23yMu z;L;cfLRaUYpM45?waV83Z5B+AU!}5H_$+(@=liUX+iUh}cI|D63#3;j?i!Et*6;(Z zJ%=L_)qZ&h?#4Xq`U=!$JPomZHJ?)W#Zj{Mk@btX|P(f|rBsT1Rv~(IZtAx4IIF?gohQ4==2%N8CMLJ zeT67-0kP6?h9M}!Mi2%qW%w^$`1*~qZJ|&spu1i}v%U@$7+6g8A${fyR;%*}*6TRl z_Fxr?Sgmg`;dw@xChX^b`p5%XH$R|jGd!I}SiZ+?W6$n|fn5N*F~GfXU7l*6yz;`m ztw{GZzxU(Gu9e27Wn+d8_Oyjhf8>7rXL%LNjJ}$gMy1h4ZeV}`snB9sp7v!g&^+jM zQK=|x?7AQ+!!ZDP*>;1l5RrxOZm5H`2!0*fYed?4XY!wT=>GfAR3_>Sk+r*b;l2Jk z7Usx6!0hPjL&4%PO9|6ybVH5XfmRYoMTKa92Sc4ezL?(0G_f7GgaLU;A~eb=6)drA zGI+fCPRyW62S7#SVKKi+(kh0?<4v9b8N_R=pee~fuvqt(VKQ#t<% z;w(s*j_nGfJxxFe(l>ma;x4l1p858Ap^!(O`R#PtaJpT1Oh4Ck&?0~i`%a!Z1&4j( z)UPo%DkBw~JNGF}-@1igU%q^XS+KszlbePlERF`SjYi$WO#1w{zT*@N1&kdZBjq*B z-nj$YPNCztSlxC(KA(rhZDg}KSR9+4zJ*Gqf5CU{o;Yy=A${BEbg@va!e+FKHW`HDh58@t97UfNQne zyr*xK6ZXqVDwK;z2|i$)eMd4NAH)Zf09aXBL5b-%I5@~!Wngx879KMp%Okj0EXIbL zyd6nlqMqWnVps?iEnp61;84GCvNSm<<$7MCR3;`S-WeMki$RFtnVFdwK$@{2tZZ!X z9N^JRnX6W-&+;3gr%G9+G${f`KC&Yu)R3UOdi82-xJCEW zcpI9WocsZY&r1H4u(=F4agWH>U%;Jt z4Gv4%$#pz&!J#p56a)M=c7w2xqx4aRDZ+-hB}0)kmNk-ikv}0~Ty`zg^N+;N?hnw< zu_GCfarsCBQT|@Zj^u!mKG~VX$9@3GJTWZuowY{`P+XJJMH qHDN&J3Ecut#>H)i1|Iu&+J6Djykze@$#lj50000 0; +} + +/** + * Retrieve all groups that have a privilege assigned + * @param $strPriv (string) Privilege to test + * @return array + */ +function erPrivilegedGroups($strPriv) { + $aReturn = array(); + $h = db_query("SELECT act FROM privileges_assign WHERE privilege = $1 ". + "ORDER BY act;", $strPriv); + if(pg_num_rows($h) > 0) { + while($a = pg_fetch_array($h)) { + $aReturn[] = $a["act"]; + } + } + return $aReturn; +} + +define("ER_CONFIGFILE_HEADER", "setMailNotify(true); + $this->setMailNotifyAddr("admins, win-admins"); + } + + /** + * @} + * @name Operations + * @{ + */ + + /** + * Write the current state of this instance to the config file. + * @return (bool) If the function fails, it returns false. Call getLastError() to get + * more information about the error. + */ + public function writeConfig() { + // Open config file + $hFile = fopen("mod_error-reporter/config.inc", "w", true); + if(!is_resource($hFile)) { + setLastError(ER_ERROR_OPEN_FILE); + return false; + } + // Try to lock file repeatedly + for($n = 0; !flock($hFile, LOCK_EX); $n++) { + if($n > 10) { + setLastError(ER_ERROR_LOCK_FILE); + return false; // Give up + } else { + sleep(0.1); // Retry after 100 ms + } + } + + // Create text for config file + $strFile = ER_CONFIGFILE_HEADER; + + // Mail notification + $strFile .= sprintf("\$cfgErrors->setMailNotify(%s);\n", + $this->isMailNotify() ? "true" : "false"); + $strFile .= sprintf("\$cfgErrors->setMailNotifyAddr('%s');\n", $this->getMailNotifyAddr()); + + $strFile .= "?>"; + + // Write to config file and unlock it + if(fwrite($hFile, $strFile) == false) { + setLastError(ER_ERROR_WRITE_FILE); + return false; + } + if(!flock($hFile, LOCK_UN)) { + setLastError(ER_ERROR_UNLOCK_FILE); + return false; + } + return true; + } + + public function readConfig() { + global $cfgErrors; + require("error-reporter/config.inc"); + } + + /** + * @} + * @name Setting options + * @{ + */ + + /** + * Enable or disable mail notification + * @param $b (bool) true to enable mail notification, false to disable it. + */ + public function setMailNotify($b) { $this->bMailNotify = ($b == true); } + + /** + * Set the mail address(es) for mail notification + * @param $str (string) The adresses to send the notofication mails to, comma-separated + */ + public function setMailNotifyAddr($str) { $this->strMailNotifyAddr = $str; } + + /** + * @} + * @name Retrieving options + * @{ + */ + + /** + * Determine if mail notification is enabled + * @return (bool) true if mail notification is enabled, otherwise false + */ + public function isMailNotify() { return $this->bMailNotify; } + + /** + * Get the mail adress(es) for mail notification + * @return string + */ + public function getMailNotifyAddr() { return $this->strMailNotifyAddr; } + + /** + * Determine if the current user is allowed to see and report errors. This + * function tests if the user is member of a group which has the + * mod-errorreporter_access privilege. + * @return bool + */ + public function userHasAccess() { + if($this->userIsAdmin() || + !erPrivilegeAssigned("mod_errorreporter_access")) { + // user is admin or privilege is not assigned + return true; + } else { + return secure_privilege("mod_errorreporter_access"); + } + } + + /* legacy */ + public function userIsAllowed() { return $this->userHasAccess(); } + + /** + * Determine if the current user has admin rights. This function tests if + * the user is member of a group which has the + * mod-errorreporter_access privilege + * @return bool + */ + public function userIsAdmin() { + return secure_privilege("mod_errorreporter_admin"); + } + + /** @} */ +} +?> \ No newline at end of file diff --git a/inc/class_erErrorReport.inc b/inc/class_erErrorReport.inc new file mode 100644 index 0000000..9a4da19 --- /dev/null +++ b/inc/class_erErrorReport.inc @@ -0,0 +1,178 @@ +nUid = null; + $this->tsDate = intval($tsDate); + $this->strOwner = $strOwner; + $this->strMachine = $strMachine; + $this->strText = $strText; + $this->strComment = null; + $this->strCommentOwner = null; + $this->bHidden = ($bHidden == true); + } + + /////////////////////////////////////////// SETTER FUNCTIONS /////////////////////////////////////////// + + /** + * @} + * @name Setter functions + * @{ + */ + + /** + * Set the unique ID + * @param $value (int) + */ + function setUid($value) { $this->nUid = $value; } + /** + * Set the date + * @param $value (timestamp) + */ + function setDate($value) { $this->tsDate = intval($value); } + /** + * Set the account name of the owner + * @param $value (string) + */ + function setOwner($value) { $this->strOwner = $value; } + /** + * Set the label of the machine to which the report refers + * @param $value (string) + */ + function setMachine($value) { $this->strMachine = $value; } + /** + * Set the text of the report + * @param $value (string) + */ + function setText($value) { $this->strText = $value; } + + /** + * Set the comment of an adminstrator + * @param $strComment (string) Comment + * @param $strAct (string) Account name of the person who sets the comment + */ + function setComment($strComment, $strAct) { + $this->strComment = $strComment; + $this->strCommentOwner = $strAct; + } + /** + * Set the visibility of the report + * @param $value (bool) true: the report is only visible for administrators + */ + function setVisibility($value) { $this->bHidden = $value; } + + /////////////////////////////////////////// GETTER FUNCTIONS /////////////////////////////////////////// + + /** + * @} + * @name Getter functions + * @{ + */ + + /** + * Get the unique ID in the database + * @return (int) + */ + function getUid() { return intval($this->nUid); } + /** + * Get the date when the report was created + * @return (timestamp) + */ + function getDate() { return intval($this->tsDate); } + /** + * Get the account name of the creator + * @return (string) + */ + function getOwner() { return $this->strOwner; } + /** + * Get the label of the machine to which the report refers + * @return (string) + */ + function getMachine() { return $this->strMachine; } + /** + * Get the tet of the report + * @return (string) + */ + function getText() { return $this->strText; } + /** + * Get the comment from an administrator + * @return (string) + */ + function getComment() { return $this->strComment; } + /** + * Get the account name of the one who wrote the comment + * @return (string) + */ + function getCommentOwner() { return $this->strCommentOwner; } + /** + * Determine if the report can be seen by non-administrators + * @return (bool) + */ + function isHidden() { return ($this->bHidden == true); } + + /**@}*/ +} +?> \ No newline at end of file diff --git a/inc/class_erErrorReportManager.inc b/inc/class_erErrorReportManager.inc new file mode 100644 index 0000000..1536159 --- /dev/null +++ b/inc/class_erErrorReportManager.inc @@ -0,0 +1,414 @@ +null, writeErrorReport() will use the next ID which is not used in the + * table. + * + * @par + * An error report that has been written to the database can be changed using + * writeErrorReport(), setting the $nUid member of the erErrorReport parameter to the UID of the + * error report to be changed. + * + * @par + * To change the visibility of an error report to @e hidden, call setErrorReportDoneFlag() with + * the UID of the error report and set the second parameter to false. + * + * @par + * To delete an error report from the database, call deleteErrorReport() with the UID of the + * error report you want to delete. + * + * @par + * Error reports can be retrieved by their UID (getErrorReportByID()), by creation date + * (getErrorReportsByDate()), by owner (getErrorReportsByOwner()), by machine to which the + * report refers (getErrorReportsByMachine()) and by the person who wrote the comment + * (getErrorReportsByCommentOwner()). All error reports in the database can be retrieved using + * getErrorReports(). All of these functions return a object of type erErrorReport or an array + * of erErrorReport objects. + * + * @par Example + * The following example creates a new error report “This doesn’t work”, written by the user + * “testuser” on February 5, 2007, which refers to the machine “Client-26” and is not visible for + * non-admin users. Then it adds a nice comment, makes the error report visible and writes it to + * the database. + * @code + * setComment("We know that already", "admin"); + * + * $nNewID = $obj->writeErrorReport($em); // $em->nUid is null, so writeErrorReport() + * // calculates the UID by itself + * ?> + * @endcode + */ + +class erErrorReportManager { + + + /** + * (object of type erConfig) pointer to the configuration class + */ + protected $objcfg; + + /** + * Constructor + * @param $objcfg (object of type erConfig) Pointer to the configuration class for retrieving the + * configuration data + * @return erErrorReportManager + */ + public function __construct(&$objcfg) { + $this->objcfg = &$objcfg; + } + + //////////////////////////////////////////// QUERYING /////////////////////////////////////////// + + /** + * @name Quering + * @{ */ + + /** + * Get all error reports in the database. + * If this function fails, it returns null. Call getLastError() to get more information. + * @param $arcSort (array of constants) Defines the sorting of the returned array. + * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @return array of objects of type erErrorReport + */ + public function getErrorReports($arcSort = array(ER_ERM_SORT_UID => ER_ERM_SORT_ASC)) { + return $this->readFromSQL("", $arcSort); + } + + /** + * Get an error report by its unique ID in database. + * If this function fails, it returns null. + * @param $nID (int) ID of the error report + * @return erErrorReport + */ + public function getErrorReportByID($nID) { + $arReturn = $this->readFromSQL("er_uid = ".qdb(intval($nID))); + if(is_array($arReturn) and count($arReturn) > 0) { + return $arReturn[0]; // return as scalar + } else { + return null; + } + } + + /** + * Get all error reports which have been created on the specified date. + * If this function fails, it returns null. Call getLastError() to get more information. + * @param $tsDate (timestamp) Date + * @param $arcSort (array of constants) Defines the sorting of the returned array. + * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @return array of objects of type erErrorReport + */ + public function getErrorReportsByDate($tsDate, $arcSort = array(ER_ERM_SORT_UID => ER_ERM_SORT_ASC)) { + return $this->readFromSQL("er_date = ".qdb(date("Y\-m\-d", $tsDate)), $arcSort); + } + + /** + * Get all error reports which have been created by the specified user. + * If this function fails, it returns null. Call getLastError() to get more information. + * @param $strAct (string) Account name + * @param $arcSort (array of constants) Defines the sorting of the returned array. + * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @return array of objects of type erErrorReport + */ + public function getErrorReportsByOwner($strAct, $arcSort = array(ER_ERM_SORT_UID => ER_ERM_SORT_ASC)) { + return $this->readFromSQL("er_act = ".qdb($strAct), $arcSort); + } + + /** + * Get all error reports which are related to a specified machine. + * If this function fails, it returns null. Call getLastError() to get more information. + * @param $strMachine (string) Machine name + * @param $arcSort (array of constants) Defines the sorting of the returned array. + * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @return array of objects of type erErrorReport + */ + public function getErrorReportsByMachine($strMachine, + $arcSort = array(ER_ERM_SORT_UID => ER_ERM_SORT_ASC)) { + return $this->readFromSQL("er_machine = ".qdb($strMachine), $arcSort); + } + + /** + * Get all error reports which have been commented by the specified user. + * If this function fails, it returns null. Call getLastError() to get more information. + * @param $strAct (string) Account name + * @param $arcSort (array of constants) Defines the sorting of the returned array. + * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @return array of objects of type erErrorReport + */ + public function getErrorReportsByCommentOwner($strAct, + $arcSort = array(ER_ERM_SORT_UID => ER_ERM_SORT_ASC)) { + return $this->readFromSQL("er_commentact = ".qdb($strAct), $arcSort); + } + + /*@}*/ + + /** + * Get datasets from the SQL tables. + * This function should not be called directly. Use the getBy* functions instead. + * If this function fails, it returns null. Call getLastError() to get more information. + * @internal + * @param $strWhere (string) Parameters for the SQL WHERE clause + * @param $arcSort (array of constants) Defines the sorting of the returned array. + * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @return array of objects of type erErrorReport + */ + protected function readFromSQL($strWhere = "", $arcSort = array(ER_ERM_SORT_UID => ER_ERM_SORT_ASC)) { + $arReturn = array(); + + // only allow visible reports for non-admins, but all reports for admins and owners + if($this->objcfg->userIsAdmin()) { + $strWhereClause = (trim($strWhere) == "") ? "" : "WHERE $strWhere"; + } else { + $strWhereClause = "WHERE ".((trim($strWhere) == "") ? "" : "$strWhere AND "). + sprintf("((er_act = '%s') or (er_hidden IS NULL OR NOT er_hidden))", $_SESSION["act"]); + } + + $strSortClause = $this->buildOrderByClause($arcSort); + + // fetch the error reports + $hQuery = db_query("SELECT * FROM mod_errorreporter $strWhereClause $strSortClause;"); + if(!is_resource($hQuery)) { + setLastError(ER_ERROR_SQL); + return null; + } + while($arResult = pg_fetch_array($hQuery)) { + $er = new erErrorReport(strtotime($arResult["er_date"]), $arResult["er_act"], + $arResult["er_machine"], $arResult["er_text"], $arResult["er_hidden"] == "t"); + $er->setUid($arResult["er_uid"]); + $er->setComment($arResult["er_comment"], $arResult["er_commentact"]); + $arReturn[] = $er; + } + return $arReturn; + } + + /** + * Build a ORDER BY clause from an array. + * This helper function takes an array of sorting constants as input and returns an ORDER BY + * clause. The values in the clause are in the same order as the constants in the array. + * The function in the following example returns an ORDER BY clause where the datasets are first + * sorted ascending by visibility, then descending by the machine name to which they refer and + * finally ascending by their UID: + * @code + * $strOrder = buildOrderClause(array( + * ER_ERM_SORT_VISIBILITY => ER_ERM_SORT_ASC, + * ER_ERM_SORT_MACHINE => ER_ERM_SORT_DESC, + * ER_ERM_SORT_UID => ER_ERM_SORT_ASC)); + * echo $strOrder; + * @endcode + * The output is: ORDER BY er_hidden ASC, er_machine DESC, er_uid ASC + * @internal + * @param $arcSort (array of constants) The array which declares the order of the SQL rows. Use + * @ref errorreportmanager_sorting as keys and @ref errorreportmanager_sorting_dir as values. + * @return string + */ + protected function buildOrderByClause($arcSort) { + // build the sorting clause + $arstrSort = array(); + foreach($arcSort as $cSort => $cDir) { + switch($cSort) { + case ER_ERM_SORT_UID: + $arstrSort[] = "er_uid ".($cDir == ER_ERM_SORT_DESC ? "DESC" : "ASC"); break; + case ER_ERM_SORT_DATE: + $arstrSort[] = "er_date ".($cDir == ER_ERM_SORT_DESC ? "DESC" : "ASC"); break; + case ER_ERM_SORT_OWNER: + $arstrSort[] = "er_act ".($cDir == ER_ERM_SORT_DESC ? "DESC" : "ASC"); break; + case ER_ERM_SORT_MACHINE: + $arstrSort[] = "er_machine ".($cDir == ER_ERM_SORT_DESC ? "DESC" : "ASC"); break; + case ER_ERM_SORT_TEXT: + $arstrSort[] = "er_text ".($cDir == ER_ERM_SORT_DESC ? "DESC" : "ASC"); break; + case ER_ERM_SORT_COMMENT: + $arstrSort[] = "er_comment ".($cDir == ER_ERM_SORT_DESC ? "DESC" : "ASC"); break; + case ER_ERM_SORT_COMMENTOWNER: + $arstrSort[] = "er_commentact ".($cDir == ER_ERM_SORT_DESC ? "DESC" : "ASC"); break; + case ER_ERM_SORT_VISIBILITY: + $arstrSort[] = "er_hidden ".($cDir == ER_ERM_SORT_DESC ? "DESC" : "ASC"); break; + } + } + return ("ORDER BY ".join(", ", $arstrSort)); + } + + //////////////////////////////////// ERROR MESSAGE MANAGEMENT /////////////////////////////////// + + /** + * @name Error report management + * @{ + */ + + /** + * Insert or update an error report in the database. + * When the $nUid member of the $erErrorReport object is null, a new unique ID is + * assigned and the error report is written to the database. Otherwise, the corresponding + * record in the table is updated. + * @param $er (erErrorReport) + * @return (int) The unique ID of the inserted or updated record. + * @throws Exception + */ + public function writeErrorReport(erErrorReport $er) { + if(!$this->objcfg->userHasAccess() and (!$this->userIsOwner($er->nUid) or + ($er->getUid() == null and !($this->objcfg->userIsAdmin())))) { + throw new Exception(ER_ERROR_ACCESS_DENIED); + } + + $strWhere = null; + $strLog = ""; + + // Update or insert? + $arPut = array(); + if($er->getUid() == null) { + // er_uid is now serial + /*$hQuery = db_query("SELECT MAX(er_uid) AS id FROM mod_errorreporter;"); + if(!is_resource($hQuery)) { + setLastError(ER_ERROR_SQL); + return -1; + } + $arResult = pg_fetch_array($hQuery); + $er->setUid(intval($arResult["id"]) + 1);*/ + $strLog = sprintf("Fehlermeldung für Rechner „%s“ eingetragen.", + $er->getMachine()); + } else { + $strWhere = "er_uid = ".qdb(intval($er->getUid())); + $oOldReport = $this->getErrorReportByID($er->getUid()); + $strLog = sprintf("Fehlermeldung geändert, Rechner war „%s“, Text war „%s“. ". + "Neuer Rechner: „%s“, neuer Text: „%s“, Kommentar: %s", + $oOldReport->getMachine(), $oOldReport->getText(), $er->getMachine(), + $er->getText(), (strlen($er->getComment()) > 0) ? "„".$er->getComment()."“" : "(leer)"); + } + $arPut["er_date"] = date("Y\-m\-d\ G\:i\:s", $er->getDate()); + $arPut["er_act"] = $er->getOwner(); + $arPut["er_machine"] = $er->getMachine(); + $arPut["er_text"] = $er->getText(); + $arPut["er_comment"] = $er->getComment(); + $arPut["er_commentact"] = $er->getCommentOwner(); + $arPut["er_hidden"] = $er->isHidden() ? "true" : "false"; + db_store("mod_errorreporter", $arPut, $strWhere); + + erInsertLog($strLog); + + // send notification mail, but only if the message is new + if($this->objcfg->isMailNotify() and $er->getUid() == null) { + $strMailText = sprintf("\nEin Benutzer hat eine Fehlermeldung mit dem ". + "Fehlermeldungs-Assistenten abgeschickt. Nachfolgend finden sich Angaben über den ". + "Fehler.\n\n\n". + "\n\n". + "\n
Fehler gemeldet von:%s
Datum:%s
Betroffener Rechner:%s
%s
\n
\nDiese Mail wurde automatisch ". + "generiert.\n", q(erGetRealUserName($er->getOwner())), + q(date("d\.m\.Y\ G\:i\:s", $er->getDate())), q($er->getMachine()), q($er->getText())); + $strMailSubject = sprintf("%s hat einen Fehler im System gemeldet", + q(erGetRealUserName($er->getOwner()))); + $strMailHeader = sprintf("From: %s <%s>\nContent-Type: text/html; charset=utf-8", + q(erGetRealUserName($er->getOwner())), user_mail_addr($er->getOwner())); + mail($this->objcfg->getMailNotifyAddr(), $strMailSubject, $strMailText, $strMailHeader); + } + + return $er->getUid(); + } + + /** + * Delete an error report from the database. + * @param $nErrorReportID (int) Unique ID of the error report to delete or -1 if an error + * occured. In this case, call getLastError() to get more information. + */ + public function deleteErrorReport($nErrorReportID) { + if(!($this->objcfg->userIsAdmin() or $this->userIsOwner($nErrorReportID))) { + setLastError(ER_ERROR_ACCESS_DENIED); + return -1; + } + + $oOldReport = $this->getErrorReportByID($nErrorReportID); + db_query(sprintf("DELETE FROM mod_errorreporter WHERE er_uid = '%d';", intval($nErrorReportID))); + erInsertLog(sprintf("Fehlermeldung gelöscht, Rechner war „%s“, Text war „%s“", + $oOldReport->getMachine(), $oOldReport->getText())); + } + + /** + * Determine if the current user is the owner of a specified error report. + * If this function fails, call getLastError() to get more information. + * @param $nID (int) Unique ID of the error report + * @return bool + */ + public function userIsOwner($nID) { + if(!$_SESSION["act"]) { + return false; // user is not logged in + } else { + $hQuery = db_query(sprintf("SELECT er_act FROM mod_errorreporter WHERE er_uid = %d;", intval($nID))); + if(!is_resource($hQuery)) { + setLastError(ER_ERROR_SQL); + return false; + } + $arResult = pg_fetch_array($hQuery); + return ($arResult["er_act"] == $_SESSION["act"]); + } + } +} +?> \ No newline at end of file diff --git a/inc/class_erErrorReportView.inc b/inc/class_erErrorReportView.inc new file mode 100644 index 0000000..5a2cc7b --- /dev/null +++ b/inc/class_erErrorReportView.inc @@ -0,0 +1,247 @@ +uid GET parameter, which contains the unique ID + * of the error report to be edited. + */ + protected $strEditURL; + /** + * (string) URL to the page which allows deletion of an error report. + * The specified page must handle the uid GET parameter, which contains the unique ID + * of the error report to be deleted. + */ + protected $strDeleteURL; + + /** + * Constructor + * @param $objcfg (object of type erConfig) Pointer to an instance of the erConfig class for + * retrieving the configuration data + * @param $objemm (object of type erErrorReportManager) Pointer to a instance of the + * erErrorReportManager class for retrieving the document data + * @return erErrorReportView + */ + public function __construct(erConfig &$objcfg, erErrorReportManager &$objemm) { + $this->objcfg = $objcfg; + $this->objManager = $objemm; + html_header(""); + } + + /** + * Print a single error report. + * Call this function to print a table or a compound of table rows with the information of the + * specified error report. The function determines if the current user is the owner of the + * specified report or if he has admin rights and in this case displays buttons for deletion and + * editing the error report. + * @param $objem (erErrorReport) Error report to print + * @param $bSingle (bool) Determines if you call this function once (true) or several + * times to get a compound table of reports (false). + * @param $bAdminButtons (bool) Explcitly determines whether to show the edit and delete buttons. + * This parameter overrides the userIsAdmin() and userIsOwner() functions. + */ + public function printErrorReport(erErrorReport $objem, $bSingle = false, $bAdminButtons = true) { + global $colbox_state, $invtbl; + if($bSingle) { + bgcol("cb"); + echo "<{$GLOBALS["invtbl"]} class='errors-view-table'>"; + } + $nColor = bgcol_rgb(); + $sColor = sprintf("rgb(%d,%d,%d)", ($nColor >> 16) % 256, ($nColor >> 8) % 256, $nColor % 256); + echo ""; + if($this->objcfg->userIsAdmin() or $this->objManager->userIsOwner($objem->getUid())) { + // user is admin or owner + echo "<{$GLOBALS["invtbl"]} width='100%'>\n"; + echo sprintf("%s%s", + _c("error-reporter:Reported by:"), erMailToUserLink($objem->getOwner())); + echo sprintf("%s%s\n", + _c("error-reporter:Date:"), SmartDate($objem->getDate())); + echo sprintf("%s%s\n", + _c("error-reporter:Affected machine:"), q($objem->getMachine())); + echo sprintf("%s%s\n", + _c("error-reporter:Text:"), q($objem->getText())); + echo sprintf("%s%s\n", + _c("error-reporter:Hidden:"), $objem->isHidden() ? _c("error-reporter:yes") : _c("error-reporter:no")); + if(trim($objem->getComment()) != "") { + echo sprintf("%s". + "%s\n", + sprintf(_c("error-reporter:Comment by %s:"), erMailToUserLink($objem->getCommentOwner())), + q($objem->getComment())); + } + echo "\n"; + // admin buttons + if($bAdminButtons) { + echo sprintf("%s". + "%s", + $this->getEditLink($objem->getUid()), $this->getDeleteLink($objem->getUid())); + } + echo "\n"; + } else { + // user can only read the report + echo "<{$GLOBALS["invtbl"]} width='100%'>\n"; + echo sprintf("%s%s\n", + _c("error-reporter:Affected machine:"), $objem->getMachine()); + echo sprintf("%s%s\n", + _c("error-reporter:Text:"), $objem->getText()); + if(trim($objem->getComment()) != "") { + echo sprintf("%s". + "%s\n", + sprintf(_c("error-reporter:Comment by %s:"), erMailToUserLink($objem->getCommentOwner())), + q($objem->getComment())); + } + echo "\n"; + } + if($bSingle) { + echo "\n"; + _bgcol(); + } + } + + /** + * Print a table of error reports. + * Prints a table with several error reports by calling printErrorReport() for each report. + * @param $arobjem (array of errorReport objects) The reports to print + */ + public public function printErrorReports($arobjem) { + echo "<{$GLOBALS["invtbl"]} class='errors-view-table'>"; + bgcol("cb"); + if(is_array($arobjem)) { + foreach($arobjem as $em) { + $this->printErrorReport($em); + if(_bgcol() == "bl") { + bgcol("cb"); + } else { + bgcol("bl"); + } + } + } + _bgcol(); + echo "\n"; + } + + /** + * Set the link to the edit page. + * The specified page must handle the uid GET parameter, which contains the unique ID + * of the error report to be edited. + * @see getEditURL() + * @see getEditLink() + * @param $strUrl (string) + */ + public function setEditURL($strUrl) { $this->strEditURL = $strUrl; } + + /** + * Get the link to the edit page. + * @param $nUid (int) Unique ID of the error report to be edited + * @see setEditURL() + * @see getEditLink() + * @return (string) + */ + public function getEditURL($nUid) { + if(preg_match("/\?/", $this->strEditURL) == 0) { + $strParam = "?uid=".intval($nUid); + } else { + $strParam = "&uid=".intval($nUid); + } + return q($this->strEditURL.$strParam); + } + + /** + * Create a link to the edit page + * @param $nUid (int) Unique ID of the error report to be edited + * @see setEditURL() + * @see getEditURL() + * @return string + */ + public function getEditLink($nUid) { + return sprintf("%s", pop($this->getEditURL($nUid), 500, 500), + _c("error-reporter:Edit this error report"), icon("write")); + } + + /** + * Set the link to the delete page. + * The specified page must handle the uid GET parameter, which contains the unique ID + * of the error report to be deleted. + * @see getDeleteURL() + * @see getDeleteLink() + * @param $strUrl (string) + */ + public function setDeleteURL($strUrl) { $this->strDeleteURL = $strUrl; } + + /** + * Get the link to the delete page. + * @param $nUid (int) Unique ID of the error report to be deleted + * @see setDeleteURL() + * @see getDeleteLink() + * @return (string) + */ + public function getDeleteURL($nUid) { + if(preg_match("/\?/", $this->strDeleteURL) == 0) { + $strParam = "?uid=".intval($nUid); + } else { + $strParam = "&uid=".intval($nUid); + } + return q($this->strDeleteURL.$strParam); + } + + /** + * Create a link to the delete page + * @param $nUid (int) Unique ID of the error report to be deleted + * @see setDeleteURL() + * @see getDeleteURL() + * @return string + */ + public function getDeleteLink($nUid) { + return sprintf("%s", $this->getDeleteURL($nUid), + _c("error-reporter:Delete this error report"), icon("trash")); + } +} +?> \ No newline at end of file diff --git a/inc/functions.inc b/inc/functions.inc new file mode 100644 index 0000000..363ce5a --- /dev/null +++ b/inc/functions.inc @@ -0,0 +1,169 @@ +%s %s

", _c("error-reporter:An error occured:"), getLastError()); +} + +/** + * Determine if the specified user exists + * @param $strAct (string) Account name of the user + * @return (bool / null) If the function fails, it returns null. + * @throws Exception + */ +function erIsAct($strAct) { + $hQuery = db_query("SELECT * FROM users WHERE act = $1;", $strAct); + if(!is_resource($hQuery)) { + throw new Exception(ER_ERROR_SQL); + return null; + } + return (pg_num_rows($hQuery) > 0); +} + +/** + * Get the real user name for an account name + * @param $strAct (string) Account name of the user to look up + * @return (string) The real name of the user. If the function fails, it returns null. + * @throws Exception + */ +function erGetRealUserName($strAct) { + $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", $strAct); + if(!is_resource($hQuery)) { + throw new Exception(ER_ERROR_SQL); + return null; + } + if(pg_num_rows($hQuery) == 0) { + return $strAct; // User not found in database, return account name + } + $arResult = pg_fetch_array($hQuery); + return user_join_name($arResult); +} + +/** + * Determine if a specified group exists + * @param $strAct (string) Account name of the group + * @return (bool / null) If the function fails, it returns null. + * @throws Exception + */ +function erIsGroup($strAct) { + $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", qdb($strAct))); + if(!is_resource($hQuery)) { + throw new Exception(ER_ERROR_SQL); + return null; + } + return (pg_num_rows($hQuery) > 0); +} + +/** + * Look up the name of a group + * @param $strAct (string) Account name of the group + * @return (string) The name of the group. If the function fails, it returns null. + * @throws Exception + */ +function erGetGroupName($strAct) { + $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", qdb($strAct))); + if(!is_resource($hQuery)) { + throw new Exception(ER_ERROR_SQL); + return null; + } + if(pg_num_rows($hQuery) == 0) { + return $strAct; // Group not found in database, return account name + } + $arResult = pg_fetch_array($hQuery); + return $arResult["name"]; +} + +/** + * Create a link to write a mail to the specified account name. + * This function returns a link if the specified account exists, otherwise it returns the + * account name. + * @param $strAct (string) Account name + * @return string + */ +function erMailToUserLink($strAct) { + if(!erIsAct($strAct)) { + return $strAct; + } + return popup(relroot("msg/write/?to=".user_mail_addr($strAct)), + 600, 400, erGetRealUserName($strAct)); +} + +/** + * Determine if a specified string is a valid mail address + * @param $strAddr string + * @return string + */ +function erIsMailAddress($strAddr) { + return ((preg_match("/([a-zA-Z0-9_\-\.]*(@[a-zA-Z0-9\-\.]*)?(\s*,\s*)?)+/", $strAddr) > 0) + and (preg_match("/(\s*,\s*)$/", $strAddr) == 0)); +} + +function erInsertLog($sMsg) { + log_insert($sMsg, null, "Error Report Wizard"); +} +?> \ No newline at end of file diff --git a/inc/init.inc b/inc/init.inc new file mode 100644 index 0000000..b780dec --- /dev/null +++ b/inc/init.inc @@ -0,0 +1,39 @@ +setDeleteURL("index.php?action=delete"); +$view->setEditURL("detail.php"); + +?> \ No newline at end of file diff --git a/lang/mod_error-reporter.po b/lang/mod_error-reporter.po new file mode 100644 index 0000000..ad43b1d --- /dev/null +++ b/lang/mod_error-reporter.po @@ -0,0 +1,180 @@ +# +# @file mod_error-reporter.po -- Translations for iserv-mod-error-reporter +# @author Roland Hieber (roland.hieber@wilhelm-gym.net) +# @date 21.10.2007 +# +# Copyright © 2007 Roland Hieber +# +# Permission is hereby granted, free of charge, to any person obtaining +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +msgid "Error Report Wizard" +msgstr "Fehlermeldungsassistent" + +msgid "Administration of the error report wizard" +msgstr "Administration des Fehlermeldungsassistenten" + +msgid "View error reports and report errors" +msgstr "Fehlermeldungen anzeigen und Fehler melden" + +msgid "error-reporter:Error Report Wizard" +msgstr "error-reporter:Fehlermeldungsassistent" + +msgid "error-reporter:Date:" +msgstr "error-reporter:Datum:" + +msgid "error-reporter:Reported by:" +msgstr "error-reporter:Gemeldet von:" + +msgid "error-reporter:Affected machine:" +msgstr "error-reporter:Betroffener Rechner:" + +msgid "error-reporter:Text:" +msgstr "error-reporter:Text:" + +msgid "error-reporter:Comment:" +msgstr "error-reporter:Kommentar:" + +msgid "error-reporter:Comment by %s:" +msgstr "error-reporter:Kommentar von %s:" + +msgid "error-reporter:Comment written by:" +msgstr "error-reporter:Kommentar verfasst von:" + +msgid "error-reporter:Hidden:" +msgstr "error-reporter:Versteckt:" + +msgid "error-reporter:yes" +msgstr "error-reporter:ja" + +msgid "error-reporter:no" +msgstr "error-reporter:nein" + +msgid "error-reporter:Report an error" +msgstr "error-reporter:Fehler melden" + +msgid "error-reporter:Delete an error report" +msgstr "error-reporter:Eine Fehlermeldung löschen" + +msgid "error-reporter:The specified error report does not exist!" +msgstr "error-reporter:Die angegebene Fehlermeldung existiert nicht!" + +msgid "error-reporter:You are about to delete the following error report:" +msgstr "error-reporter:Soll diese Fehlermeldung gelöscht werden?" + +msgid "error-reporter:You are not allowed to delete this report." +msgstr "error-reporter:Sie sind nicht berechtigt, diese Meldung zu löschen." + +msgid "error-reporter:You are not allowed to edit this report." +msgstr "error-reporter:Sie sind nicht berechtigt, diese Meldung zuView ändern." + +msgid "error-reporter:You have to fill out all the fields in the form." +msgstr "error-reporter:Sie müssen alle Felder des Formulars ausfüllen." + +msgid "error-reporter:The report was submitted. Thank you for your help." +msgstr "error-reporter:Die Fehlermeldung wurde eingetragen. Vielen Dank für Ihre Mithilfe." + +msgid "error-reporter:Reports that have already been submitted:" +msgstr "error-reporter:Fehlermeldungen, die schon eingetragen wurden:" + +msgid "error-reporter:These errors should not be resubmitted." +msgstr "error-reporter:Diese Fehler sollten nicht noch einmal eingetragen werden." + +msgid "error-reporter:Please write your report as precise as possible to help us solve the problem. " + "The more precise the report is, the faster the error can be fixed. Please include also any " + "error messages you have recieved." +msgstr "error-reporter:Verfassen Sie Ihre Meldung bitte so genau wie möglich. Je genauer Ihre Angaben " + "sind, desto schneller kann der Fehler behoben werden. Bitte erwähnen Sie auch jegliche " + "Fehlermeldungen, die Sie erhalten haben." + +msgid "error-reporter:Description of the error:" +msgstr "error-reporter:Fehlerbeschreibung:" + +msgid "error-reporter:Visible only for administrators (use this if your report is about security issues)" +msgstr "error-reporter:Nur für Administratoren sichtbar (falls es um Sicherheitslöcher geht)" + +msgid "error-reporter:Change an error report" +msgstr "error-reporter:Fehlermeldung ändern" + +msgid "error-reporter:An error occured:" +msgstr "error-reporter:Ein Fehler ist aufgetreten:" + +msgid "error-reporter:Recommened reading" +msgstr "error-reporter:Empfohlene Lektüre" + +msgid "error-reporter:“How to Report Bugs Effectively”, by Simon G. Tatham" +msgstr "error-reporter:„Wie Sie Softwarefehler melden sollten”, von Simon G. Tatham" + +msgid "error-reporter:http://www.chiark.greenend.org.uk/~sgtatham/bugs.html" +msgstr "error-reporter:http://www.chiark.greenend.org.uk/~sgtatham/bugs-de.html" + +msgid "error-reporter-cfg:Error Report Wizard – Configuration" +msgstr "error-reporter-cfg:Fehlermeldungsassistent – Konfiguration" + +msgid "error-reporter-cfg:Mail notification" +msgstr "error-reporter-cfg:Benachrichtigungen per E-Mail" + +msgid "error-reporter-cfg:Enable mail notification" +msgstr "error-reporter-cfg:Mail-Benachrichtigung aktivieren" + +msgid "error-reporter-cfg:If this option is enabled, everytime an error report is submitted, an e-mail " + "with information about the report will be sent to the address specified below." +msgstr "error-reporter-cfg:Wenn diese Option aktiviert ist, wird jedesmal, wenn ein Fehler gemeldet wird, " + "eine E-Mail mit Informationen über die Fehlermeldung an die angegebene Adresse gesendet." + +msgid "error-reporter-cfg:Mail address to send the notification mail to" +msgstr "error-reporter-cfg:E-Mail-Adresse für die Benachrichtigungs-Mails" + +msgid "error-reporter-cfg:If mail notifications are enabled, any notification mails are sent to " + "the address specified here. You can give more than one address by separating them with a comma." +msgstr "error-reporter-cfg:Wenn die E-Mail-Benachrichtigung aktiviert ist, werden alle E-Mails an " + "die hier angegebene Adresse gesendet. Sie können mehrere Adressen angeben, indem Sie sie mit " + "Kommata trennen." + +msgid "error-reporter-cfg:Set mail notification." +msgstr "error-reporter-cfg:E-Mail-Benachrichtigung gesetzt." + +msgid "error-reporter-cfg:Set mail notification address." +msgstr "error-reporter-cfg:Adresse für E-Mail-Benachrichtigung gesetzt." + +msgid "error-reporter-cfg:The specified string is not a valid e-mail address!" +msgstr "error-reporter-cfg:Die angegebene Zeichenkette ist keine gültige E-Mail-Adresse!" + +msgid "error-reporter:This is a short summary of the privileges related to the error report assistant " + "and the groups which have them assigned." +msgstr "error-reporter:Dies ist eine kurze Übersicht über die vom " + "Fehlermeldungsassistenten genutzten Sonderrechte und den Gruppen, denen sie " + "zugewiesen wurden." + +msgid "error-reporter:If one of these privileges is not assigned to " + "any group, all users on this server are allowed to perform the specified " + "action. Please use the %sgroup administration%s to assign and revoke " + "privileges." +msgstr "Falls eines dieser Sonderrechte keiner Gruppe " + "zugewiesen wurde, dürfen alle Benutzer dieses Servers die entsprechende " + "Aktion vornehmen. Sonderrechte können in der %sGruppenverwaltung%s " + "zugeteilt und entzogen werden." + +msgid "error-reporter:Please note that every group with the administration " + "privilege can also implicitly report errors and see the reported messages." +msgstr "error-reporter:Es ist zu beachten, dass jede Gruppe mit Administrations-" + "Sonderrecht implizit auch Fehler melden und alle gemeldeten Fehler einsehen kann." + +msgid "error-reporter:all users" +msgstr "error-reporter:alle Benutzer" \ No newline at end of file diff --git a/maint/update-config.sh b/maint/update-config.sh new file mode 100755 index 0000000..43e3820 --- /dev/null +++ b/maint/update-config.sh @@ -0,0 +1,24 @@ +#!/bin/bash +OLDCFG=/old/opt/iserv/idesk/inc/error-reporter/config.inc.rpmsave +NEWCFG=/usr/share/iserv/www/inc/mod_error-reporter/config.inc + +if [ ! -e "$OLDCFG" ]; then + echo "$OLDCFG does not exist." + exit 1; +fi; + +touch $NEWCFG || exit 1; +chmod u+wr $NEWCFG || exit 1; +chown www-data $NEWCFG || exit 1; + +# filter unused options +cat $OLDCFG|grep -v setAdminGroups|grep -v setLog|grep -v @package > $NEWCFG + +# convert admin groups to group privileges +ADMGROUPS=$(grep setAdminGroups $OLDCFG|sed -e 's/,//g' -e "s/.*array[^(]*(\([^)]*\)).*/\1/" -e "s/[\"\']//g") +for i in $ADMGROUPS; do + psql -c "INSERT INTO privileges_assign (act,privilege) VALUES('$i','mod_errorreporter_admin');" > /dev/null || exit 1; + echo "added adminship for group '$i'" +done; + +rm -f $OLDCFG || (echo "Error: Please remove the old config file by hand!" && exit 1); diff --git a/maint/update.php b/maint/update.php new file mode 100644 index 0000000..d9605ef --- /dev/null +++ b/maint/update.php @@ -0,0 +1,94 @@ +/dev/null 2>&1" : $cmd; + exec($cmd, $a, $i); + return ($i == 0); +} +function printSql($cmd) { echo $cmd."\n"; return doSql($cmd); } +function tableExists($table) { + return doSql("SELECT * FROM $table", tnue); +} +function columnExists($table, $col) { + return (doSql("SELECT $col FROM $table", true) and tableExists($table)); +} + +if(isset($_SERVER["REMOTE_ADDR"])) { + die("Run this script as root from the command line."); +} + +/*** Generic update tasks *****************************************************/ + +/** 8.08.07 **/ +$sOldCfg = "/old/opt/iserv/idesk/inc/error-reporter/config.inc.rpmsave"; +$sNewCfg = "/usr/share/iserv/www/inc/mod_error-reporter/config.inc"; +if(is_file($sOldCfg)) { + echo "taking over old config file... "; + exec("/usr/share/iserv/modules/error-reporter/update-config.sh", $a, $i); + if($i != 0) { + die(); + } + echo "done.\n"; +} + +/*** database schema updates***************************************************/ +echo "updating database schema... \n"; +if(!tableExists("mod_errorreporter")) { + passthru("chkdb -r"); +} + +/** table from pre-3.0 **/ +if(tableExists("errors") and !columnExists("errors", "pclabel")) { + printSql("ALTER TABLE errors RENAME COLUMN pc_number TO pclabel;"); +} + +/** table from 3.0 **/ +if(tableExists("errors") and !columnExists("errors", "pclabel")) { + printSql("INSERT INTO mod_errorreporter (er_date,er_act,er_machine,er_text,". + "er_comment,er_commentact,er_hidden) SELECT date,name,pclabel,text,". + "comment,commentby,hidden FROM errors;"); + printSql("DROP TABLE errors;"); +} + +/** table from 4.0 **/ +if(tableExists("errorreports")) { + printSql("INSERT INTO mod_errorreporter (er_date,er_act,er_machine,er_text,". + "er_comment,er_commentact,er_hidden) SELECT er_date,er_act,er_machine,". + "er_text,er_comment,er_commentact,er_hidden FROM errorreports;"); + printSql("DROP TABLE errorreports;"); +} + +echo "done.\n"; +?> diff --git a/nav/79mod_error-reporter.mod b/nav/79mod_error-reporter.mod new file mode 100644 index 0000000..f0e85a4 --- /dev/null +++ b/nav/79mod_error-reporter.mod @@ -0,0 +1,32 @@ +userHasAccess()) { + TreeNode(_c("error-reporter:Report an error"), "mod_error-reporter/index.php", "mod_error-reporter"); +} +?> diff --git a/nav/admin/99mod_error-reporter-cfg.mod b/nav/admin/99mod_error-reporter-cfg.mod new file mode 100644 index 0000000..09f515e --- /dev/null +++ b/nav/admin/99mod_error-reporter-cfg.mod @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/priv/mod_error-reporter b/priv/mod_error-reporter new file mode 100644 index 0000000..486e471 --- /dev/null +++ b/priv/mod_error-reporter @@ -0,0 +1,7 @@ +mod_errorreporter_access: +module Error Report Wizard +description View error reports and report errors + +mod_errorreporter_admin: +module Error Report Wizard +description Administration of the error report wizard diff --git a/sql/log_module/mod_error-reporter b/sql/log_module/mod_error-reporter new file mode 100644 index 0000000..4628eba --- /dev/null +++ b/sql/log_module/mod_error-reporter @@ -0,0 +1 @@ +Error Report Wizard \ No newline at end of file diff --git a/sql/mod_error-reporter.sql b/sql/mod_error-reporter.sql new file mode 100644 index 0000000..dde3af9 --- /dev/null +++ b/sql/mod_error-reporter.sql @@ -0,0 +1,42 @@ +-- +-- @file mod_ error-reporter.sql -- Table definitions for iserv-mod-error-reporter +-- @author Roland Hieber (roland.hieber@wilhelm-gym.net) +-- @date 27.10.2007 +-- +-- Copyright © 2007 Roland Hieber +-- +-- Permission is hereby granted, free of charge, to any person obtaining +-- copy of this software and associated documentation files (the "Software"), +-- to deal in the Software without restriction, including without limitation +-- the rights to use, copy, modify, merge, publish, distribute, sublicense, +-- and/or sell copies of the Software, and to permit persons to whom the +-- Software is furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. +-- + +CREATE TABLE mod_errorreporter ( + er_uid SERIAL NOT NULL PRIMARY KEY, + er_date TIMESTAMP WITHOUT TIME ZONE NOT NULL, + er_act TEXT NOT NULL + REFERENCES users(act) + ON DELETE CASCADE + ON UPDATE CASCADE, + er_machine TEXT NOT NULL, + er_text TEXT NOT NULL, + er_comment TEXT, + er_commentact TEXT, + er_hidden BOOL +); + +GRANT SELECT, INSERT, UPDATE, DELETE ON mod_errorreporter, mod_errorreporter_er_uid_seq TO webadm; +GRANT SELECT, INSERT, UPDATE, DELETE ON mod_errorreporter, mod_errorreporter_er_uid_seq TO webusr; diff --git a/src/config.php b/src/config.php new file mode 100644 index 0000000..8d0f8db --- /dev/null +++ b/src/config.php @@ -0,0 +1,135 @@ + +td.errors-cfg-field { + padding: 1em; + width: 50%; + vertical-align: top; +} +td.errors-cfg-field input { + margin: 0; +} +.errors-cfg-field-heading { + font-weight: bold; +} +"); + +$cfgErrors = new erConfig(); +require_once("mod_error-reporter/config.inc"); + +PageBlue(_c("error-reporter-cfg:Error Report Wizard – Configuration"), "mod_error-reporter"); + +if(@$_POST["submit"] == _("Save")) { + $bMailNotify = (@$_POST["mailnotify"] == "true"); + $strMailNotifyAddr = @$_POST["mailnotifyaddr"]; + $bLog = (@$_POST["log"] == "true"); + + if($bMailNotify != $cfgErrors->isMailNotify()) { + $cfgErrors->setMailNotify($bMailNotify); + echo sprintf("

%s

\n", _c("error-reporter-cfg:Set mail notification.")); + } + if($strMailNotifyAddr != $cfgErrors->getMailNotifyAddr()) { + if(!erIsMailAddress($strMailNotifyAddr)) { + echo sprintf("

%s

", _c("error-reporter-cfg:The specified string is not ". + "a valid e-mail address!")); + } else { + $cfgErrors->setMailNotifyAddr($strMailNotifyAddr); + echo sprintf("

%s

\n", _c("error-reporter-cfg:Set mail notification address.")); + } + } + $cfgErrors->writeConfig(); +} + +// two columns +echo "
\n"; + +// Mail notification +GroupBox(_c("error-reporter-cfg:Mail notification"), "mail"); +echo "
\n"; +echo "\n"; +echo sprintf("", + _c("error-reporter-cfg:Enable mail notification"), _c("error-reporter-cfg:If this option is ". + "enabled, everytime an error report is submitted, an e-mail with information about the ". + "report will be sent to the address specified below."), $cfgErrors->isMailNotify() ? + " checked='checked'" : ""); +echo sprintf("", _c("error-reporter-cfg:Mail address to send the notification mail to"), + _c("error-reporter-cfg:If mail notifications are enabled, any notification mails are sent to ". + "the address specified here. You can give more than one address by separating them with a ". + "comma."), q($cfgErrors->getMailNotifyAddr())); +echo sprintf("\n", + _("Save")); +echo "

%s
". + "

%s
". + "". + "
<$stdbtn name='submit' value='%s' />
\n
\n"; +_GroupBox(); + +echo "
\n"; + +// Privileges +GroupBox(_("Privileges"), "keys"); +$asAccessGroups = erPrivilegedGroups("mod_errorreporter_access"); +$asAdminGroups = erPrivilegedGroups("mod_errorreporter_admin"); +echo sprintf("

%s

\n

%s

\n

%s

", _c("error-reporter:This is ". + "a short summary of the privileges related to the error report assistant ". + "and the groups which have them assigned."), + sprintf(_c("error-reporter:If one of these privileges is not assigned to ". + "any group, all users on this server are allowed to perform the specified ". + "action. Please use the %sgroup administration%s to assign and revoke ". + "privileges."), "", ""), + _c("error-reporter:Please note that every group with the administration ". + "privilege can also implicitly report errors and see the reported messages.")); +echo "

\n"; +echo sprintf("\n", icon("keys"), + _("View error reports and report errors").":", $asAccessGroups == array() ? + _c("error-reporter:all users") : icon("act-group") . join(", ", + array_map("erGetGroupName", $asAccessGroups))); +echo "\n"; +echo sprintf("\n", icon("keys"), + _("Administration of the error report wizard"), + $asAdminGroups == array() ? _c("error-reporter:all users") : + icon("act-group") . join(", ", array_map("erGetGroupName", $asAdminGroups))); +echo "
%s%s%s
%s%s%s

\n"; +_GroupBox(); + +echo "
\n"; + +_PageBlue(); +?> \ No newline at end of file diff --git a/src/detail.php b/src/detail.php new file mode 100644 index 0000000..d4b1ee2 --- /dev/null +++ b/src/detail.php @@ -0,0 +1,124 @@ +userHasAccess()) { + printf("

%s

\n", ER_ERROR_ACCESS_DENIED); + _PageBlue(); + die(); +} + +$getAction = @$_GET["action"]; +$getUid = @intval($_GET["uid"]); +$postSubmit = @$_POST["submit"]; + +isset($getUid) or die(); + +// Check if the specified report exists +if(!is_object($doc->getErrorReportByID($getUid))) { + echo sprintf("

%s

", + _c("error-reporter:The specified error report does not exist!")); + _PageBlue(); + die(); +} + +// Only admins or owners can view this page +if(!($cfgErrors->userIsAdmin() or $doc->userIsOwner($getUid))) { + echo sprintf("

%s", _c("error-reporter:You are not allowed to edit this report.")); + _PageBlue(); + die(); +} + +// Load old dataset +$er = $doc->getErrorReportByID($getUid); +$strOldComment = $er->getComment(); + +// Probably we have to update an error report +if($getAction == "update" and $postSubmit == _c("Change")) +{ + if($cfgErrors->userIsAdmin()) { + $postComment = stripslashes(@$_POST["comment"]); + $postCommentOld = stripslashes(@$_POST["comment_old"]); + } + + // change the fields of the old dataset + $er->setMachine(stripslashes(@$_POST["machine"])); + $er->setText(stripslashes(@$_POST["text"])); + $er->setVisibility(isset($_POST["hidden"]) ? true : false); + + // Do we have to change the comment and his owner? + if($cfgErrors->userIsAdmin()) { + if(@$_POST["comment_old"] != @$_POST["comment"]) { + $er->setComment(stripslashes(@$_POST["comment"]), $_SESSION["act"]); + } + } + + // write into database, reload parent and close window + if($doc->writeErrorReport($er) != -1) { + js_try("opener.location.href = 'index.php';"); + js_close(500); + } else { + printLastError(); + _PageBlue(); + die(); + } +} + +// output form +$hidctrl = "input type='hidden'"; +Title(_c("error-reporter:Change an error report")); +echo sprintf("

\n", $getUid); +echo "\n"; +echo sprintf("\n", _c("error-reporter:Reported by:"), + q(erGetRealUserName($er->getOwner()))); +echo sprintf("\n", _c("error-reporter:Date:"), SmartDate($er->getDate())); +echo sprintf("\n", + _c("error-reporter:Affected machine:"), q($er->getMachine())); +echo sprintf("\n", _c("error-reporter:Text:"), $er->getText()); +echo sprintf("\n", _c("error-reporter:Hidden:"), + $er->isHidden() ? " checked='checked'" : ""); +if($cfgErrors->userIsAdmin()) { + echo sprintf("\n", $strOldComment); + echo sprintf("\n", _c("error-reporter:Comment written by:"), + erGetRealUserName($er->getCommentOwner())); + } +} +echo sprintf("\n", _("Change")); +echo "
%s%s
%s%s
%s<{$GLOBALS["stdedt"]} name='machine' value='%s' />
%s
%s", + _c("error-reporter:Comment:"), $er->getComment()); + if($er->getComment() != "") { + echo sprintf("
%s%s
<{$GLOBALS["smlbtn"]} value='%s' />

\n"; +_PageBlue(); +?> diff --git a/src/index.php b/src/index.php new file mode 100644 index 0000000..f02af6c --- /dev/null +++ b/src/index.php @@ -0,0 +1,159 @@ + +td.errors-form-description { + width: 12em; +} +"); + +$getAction = @$_GET["action"]; +$getUid = @$_GET["uid"]; + +$postMachine = @stripslashes($_POST["machine"]); +$postText = @stripslashes($_POST["text"]); +$postHidden = @$_POST["hidden"]; +$postSubmit = @$_POST["submit"]; + +$strError = ""; + +PageBlue(_c("error-reporter:Report an error"), "mod_error-reporter"); + +if(!$cfgErrors->userHasAccess()) { + printf("

%s

\n", ER_ERROR_ACCESS_DENIED); + _PageBlue(); + exit(); +} + +// Probably we have to delete an error report +if($getAction == "delete" and isset($getUid)) { + // Are you really sure? + if(@$_POST["surely_delete"] == _("Delete")) { + $doc->deleteErrorReport($getUid); + header("Location: {$_SERVER["PHP_SELF"]}"); // Reload to get rid of POST data + } elseif(@$_POST["surely_cancel"] == _("Cancel")) { + header("Location: {$_SERVER["PHP_SELF"]}"); + } else { + // Ask the user to delete the message + Title(_c("error-reporter:Delete an error report")); + // Check if the specified report exists + if(!$doc->getErrorReportByID($getUid)) { + echo sprintf("

%s

", + _c("error-reporter:The specified error report does not exist!")); + Option(_("Back"), null, "href='".$_SERVER["PHP_SELF"]."'", "back"); + } else { + if($cfgErrors->userIsAdmin() or $doc->userIsOwner($getUid)) { + echo sprintf("
\n", $view->getDeleteURL($getUid)); + echo sprintf("

%s

", + _c("error-reporter:You are about to delete the following error report:")); + $view->printErrorReport($doc->getErrorReportByID($getUid), true, false); + echo sprintf("

\n". + " \n". + "

", _("Delete"), _("Cancel")); + } else { + echo sprintf("

%s

", + _c("error-reporter:You are not allowed to delete this report.")); + Option(_("Back"), null, "href='".$_SERVER["PHP_SELF"]."'", "back"); + } + } + _PageBlue(); + exit(); + } +} + +// form for reloading the page via javascript +echo sprintf("
\n", $_SERVER["PHP_SELF"]); + +// probably we have to insert an error report +if(($getAction == "submit" and $postSubmit == _("Insert"))) +{ + // All fields must be filled out + if((trim($postMachine) == "") or (trim($postText) == "")) { + $strError = _c("error-reporter:You have to fill out all the fields in the form."); + } else { + // Write to database + $nNewUid = null; + $er = new erErrorReport(time(), $_SESSION["act"], $postMachine, $postText, $postHidden == "true"); + try { + $nNewUid = $doc->writeErrorReport($er); + } catch(Exception $e) { + echo sprintf("

%s

", $e->getMessage()); + } + + if($nNewUid !== null) { + echo sprintf("

%s

", + _c("error-reporter:The report was submitted. Thank you for your help.")); + } + + $postText = ""; + $postMachine = ""; + $postHidden = "false"; + } +} + +// Show already existent (and visible) error reports +Title(_c("error-reporter:Reports that have already been submitted:")); +echo sprintf("

%s

", _c("error-reporter:These errors should not be resubmitted.")); +$view->printErrorReports($doc->getErrorReports(array(ER_ERM_SORT_DATE => ER_ERM_SORT_DESC))); + +// Form for submitting a new error report +echo "

\n"; +Title(_c("error-reporter:Report an error")); +Option(_c("error-reporter:Recommened reading"), _c("error-reporter:“How to Report Bugs ". + "Effectively”, by Simon G. Tatham"), "target='_blank' href='". + _c("error-reporter:http://www.chiark.greenend.org.uk/~sgtatham/bugs.html")."'"); + +// Print the error here +if($strError != "") + echo "

$strError

\n"; + +echo sprintf("

%s

\n", _c("error-reporter:Please write your report as precise as possible to help ". + "us solve the problem. The more precise the report is, the faster the error can be fixed. ". + "Please include also any error messages you have recieved.")); +echo "
\n<{$GLOBALS["invtbl"]}>\n"; +echo sprintf("%s". + "\n", + _c("error-reporter:Affected machine:"), q($postMachine)); +echo sprintf("%s". + "\n", + _c("error-reporter:Description of the error:"), q($postText)); +echo sprintf("". + "\n", ($postHidden == "true") ? " checked='checked'" : "", + _c("error-reporter:Visible only for administrators (use this if your report is about security issues)")); +echo sprintf("\n", + _("Insert")); +echo "

\n"; + +_PageBlue(); +?> -- 2.20.1