Imported sources
authorrohieb <devnull@localhost>
Thu, 7 Aug 2008 01:21:56 +0000 (03:21 +0200)
committerrohieb <devnull@localhost>
Thu, 7 Aug 2008 01:21:56 +0000 (03:21 +0200)
39 files changed:
.hgignore [new file with mode: 0644]
.project [new file with mode: 0644]
.settings/org.eclipse.core.resources.prefs [new file with mode: 0644]
.settings/org.eclipse.core.runtime.prefs [new file with mode: 0644]
.settings/org.eclipse.php.core.projectOptions.prefs [new file with mode: 0644]
Doxyfile [new file with mode: 0644]
Makefile [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/conffiles [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/dirs [new file with mode: 0644]
debian/files [new file with mode: 0644]
debian/postinst [new file with mode: 0755]
debian/postrm [new file with mode: 0755]
debian/prerm [new file with mode: 0755]
debian/rules [new file with mode: 0755]
doc/TODO [new file with mode: 0644]
doc/changelog.old.html [new file with mode: 0644]
img/16/mod_error-reporter.png [new file with mode: 0644]
img/32/mod_error-reporter.png [new file with mode: 0644]
inc/class_erConfig.inc [new file with mode: 0644]
inc/class_erErrorReport.inc [new file with mode: 0644]
inc/class_erErrorReportManager.inc [new file with mode: 0644]
inc/class_erErrorReportView.inc [new file with mode: 0644]
inc/functions.inc [new file with mode: 0644]
inc/init.inc [new file with mode: 0644]
lang/mod_error-reporter.po [new file with mode: 0644]
maint/update-config.sh [new file with mode: 0755]
maint/update.php [new file with mode: 0644]
nav/79mod_error-reporter.mod [new file with mode: 0644]
nav/admin/99mod_error-reporter-cfg.mod [new file with mode: 0644]
priv/mod_error-reporter [new file with mode: 0644]
sql/log_module/mod_error-reporter [new file with mode: 0644]
sql/mod_error-reporter.sql [new file with mode: 0644]
src/config.php [new file with mode: 0644]
src/detail.php [new file with mode: 0644]
src/index.php [new file with mode: 0644]

diff --git a/.hgignore b/.hgignore
new file mode 100644 (file)
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 (file)
index 0000000..b054eb7
--- /dev/null
+++ b/.project
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>iserv-mod-error-reporter</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.php.core.PhpIncrementalProjectBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.wst.validation.validationbuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.php.core.PHPNature</nature>
+       </natures>
+</projectDescription>
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644 (file)
index 0000000..9cc46de
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Oct 23 22:47:09 CEST 2007\r
+eclipse.preferences.version=1\r
+encoding/<project>=UTF-8\r
diff --git a/.settings/org.eclipse.core.runtime.prefs b/.settings/org.eclipse.core.runtime.prefs
new file mode 100644 (file)
index 0000000..513e138
--- /dev/null
@@ -0,0 +1,3 @@
+#Tue Oct 23 22:47:09 CEST 2007\r
+eclipse.preferences.version=1\r
+line.separator=\n\r
diff --git a/.settings/org.eclipse.php.core.projectOptions.prefs b/.settings/org.eclipse.php.core.projectOptions.prefs
new file mode 100644 (file)
index 0000000..db7054a
--- /dev/null
@@ -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=<?xml version\="1.0" encoding\="UTF-8"?>\n<includepath>\n\t<includepathentry createdReference\="false" path\="IDesk" contentKind\="source" kind\="var">\n</includepathentry>\n</includepath>\n
diff --git a/Doxyfile b/Doxyfile
new file mode 100644 (file)
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 (file)
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 (file)
index 0000000..45b3758
--- /dev/null
@@ -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) <roland.hieber@wilhelm-gym.net>  Wed,  6 Aug 2008 17:17:04 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/conffiles b/debian/conffiles
new file mode 100644 (file)
index 0000000..4bafda8
--- /dev/null
@@ -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 (file)
index 0000000..1e8a328
--- /dev/null
@@ -0,0 +1,14 @@
+Source: iserv-mod-error-reporter
+Section: non-free/web
+Priority: optional
+Maintainer: Roland Hieber (Package Signing Key) <roland.hieber@wilhelm-gym.net>
+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 (file)
index 0000000..411363f
--- /dev/null
@@ -0,0 +1,43 @@
+== License ==\r
+\r
+The module has been released under the terms of the MIT License, as printed \r
+following in its original version. Some images which have been used have been\r
+released under the terms of the GNU Lesser General Public License (see\r
+http://www.fsf.org/licensing/licenses/lgpl.html). These are in particular:\r
+   * /opt/iserv/idesk/img/16/mod_error-reporter.png\r
+   * /opt/iserv/idesk/img/32/mod_error-reporter.png\r
+\r
+If you enjoy this software, you are free to support his author with a small\r
+donation:\r
+\r
+   Roland Hieber\r
+   IBAN: DE98 250 500 000 150 2141 79\r
+   BIC: NOLADE2HXXX (Norddeutsche Landesbank Hannover)\r
+\r
+You can also send material donations to\r
+   Roland Hieber\r
+   Großer Hilligenhof 7\r
+   38154 Königslutter\r
+   GERMANY\r
+\r
+\r
+=== License terms ===\r
+Copyright (c) 2007 Roland Hieber\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining\r
+a copy of this software and associated documentation files (the "Software"),\r
+to deal in the Software without restriction, including without limitation\r
+the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+and/or sell copies of the Software, and to permit persons to whom the\r
+Software is furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in\r
+all copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+THE SOFTWARE.\r
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..2f93f02
--- /dev/null
@@ -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 (file)
index 0000000..02ae300
--- /dev/null
@@ -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 (executable)
index 0000000..9d55bf5
--- /dev/null
@@ -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 (executable)
index 0000000..4fdf0ba
--- /dev/null
@@ -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 (executable)
index 0000000..e912711
--- /dev/null
@@ -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 (executable)
index 0000000..46f3010
--- /dev/null
@@ -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 (file)
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 (file)
index 0000000..41e4e6f
--- /dev/null
@@ -0,0 +1,56 @@
+<html>
+<head>
+       <title>IServ &ndash; Fehlermeldungs-Assistent &ndash; Changelog</title>
+       <link rel='stylesheet' type='text/css' href='../../format.css'>
+       <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+</head>
+
+<body>
+<h1>Changelog</h1>
+<p>Änderungen für neuere Versionen befinden sich im <a href='/doc/iserv-mod-error-reporter/changelog.Debian.gz'>Debian-Changelog</a>.</p>
+<h2>iserv-error-reporter-4.1</h2>
+<ul>
+<li>Reparierte Fehler:<ul>
+  <li>Kosmetik: Fehler beim Löschen und Bearbeiten von nicht existenten Fehlermeldungen</li>
+</ul></li>
+</ul>
+
+<h2>iserv-error-reporter-4.0</h2>
+<i>Release: 28. Oktober 2007</i>
+<ul>
+<li>komplette Neuentwicklung des Codes</li>
+<li>englische Übersetzung</li>
+<li>Feld &bdquo;Klasse&rdquo; entfernt, da überflüssig</li>
+<li>Anmeldung am IDesk nötig</li>
+<li>Admins: Konfigurations-Seite</li>
+<li>Dokumentation: Schnittstellen <a href='source/'>dokumentiert</a></li>
+<li>Notiz: Modul umbenannt nach <i>iserv-error-reporter</i></li>
+<li>Reparierte Fehler:<ul>
+  <li>Ändern und Löschen von Fehlermeldungen für Nicht-Admins möglich</li>
+  <li>Verstecken von Fehlermeldungen ohne einen Kommentar ergab eine SQL-Fehlermeldung</li></ul>
+</ul>
+
+<h2>iserv-errors-3.0</h2>
+<i>Release: 24. April 2007</i>
+<ul>
+<li>MIT-Lizenz als neue Lizenz, manche Symbole allerdings unter der <a href="http://www.fsf.org/licensing/licenses/lgpl.html">GNU LGPL</a> veröffentlicht</li>
+<li>Neue Dokumentation:<ul>
+  <li>Changelog</li>
+  <li>TODO</li>
+  <li>Lizenz</li>
+  <li>über &bdquo;IServ-Dokumentation&rdquo; &rarr; &bdquo;Module&rdquo; erreichbar</li></ul>
+<li>Admins: Verwalten der Fehlermeldungen auf der selben Seite wie das Eintragen, Seite im Verwaltungsmenü existiert nicht mehr</li>
+<li>Benutzer können eigene Einträge bearbeiten und löschen</li>
+<li>einige neue Bildchen</li>
+<li>SQL-Tabelle wird von chkdb repariert</li>
+<li>zur leichteren Installation als RPM gepackt</li>
+<li>vollständige Umstellung des Quelltexte auf Englisch, kein Englisch-Deutsch-Mischmasch</li>
+<li>Reparierte Fehler:<ul>
+  <li>Beim Bearbeiten kann der Rechnernamen nicht geändert werden</li>    
+       <li><a href="http://wiki.mzbs.eu/w/index.php?title=Fehlermeldungsmodul#Bearbeiten-Icon_wird_nicht_im_Admin-Bereich_angezeigt">Bearbeiten-Icon wird nicht im Admin-Bereich angezeigt</a></li>
+       <li>Code gegen unerwünschtes HTML, <a href="http://de.wikipedia.org/wiki/Cross-Site_Scripting">Cross-Site Scripting</a> und <a href="http://de.wikipedia.org/wiki/SQL-Injektion">SQL-Injections</a> abgesichert</li></ul>
+</ul>
+
+Für ältere Versionen liegen keine genauen Informationen vor.
+</body>
+</html>
diff --git a/img/16/mod_error-reporter.png b/img/16/mod_error-reporter.png
new file mode 100644 (file)
index 0000000..b88c584
Binary files /dev/null and b/img/16/mod_error-reporter.png differ
diff --git a/img/32/mod_error-reporter.png b/img/32/mod_error-reporter.png
new file mode 100644 (file)
index 0000000..e050ec8
Binary files /dev/null and b/img/32/mod_error-reporter.png differ
diff --git a/inc/class_erConfig.inc b/inc/class_erConfig.inc
new file mode 100644 (file)
index 0000000..c183623
--- /dev/null
@@ -0,0 +1,208 @@
+<?php
+/**\r
+ * @file class_erConfig.inc 
+ * Class that handles the configuration\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 21.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+require_once("sec/secure.inc");
+require_once("mod_error-reporter/functions.inc");
+
+/**
+ * Determines if a privilege has been assigned
+ * @param $sPriv (string) Privilege to test
+ * @return bool
+ */
+function erPrivilegeAssigned($sPriv) {
+  $h = db_query("SELECT act FROM privileges_assign WHERE privilege = $1;",
+    $sPriv);
+  return pg_num_rows($h) > 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", "<?php
+/**
+ * config.inc -- configuration file for iserv-mod-error-reporter
+ * This file is written by the configuration script.
+ */\n");
+
+/** @todo document */
+class erConfig {
+  /** (bool) Status of mail notification */
+  protected $bMailNotify;
+  /** (string) Address to send the notification mails to */
+  protected $strMailNotifyAddr;
+  
+  /**
+   * @name Constructor
+   * @{
+   */
+  /**
+   * Constructor. Sets default values.
+   * @return erConfig
+   */
+  public function __construct() {
+    $this->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 <tt>false</tt>. 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) <tt>true</tt> to enable mail notification, <tt>false</tt> 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) <tt>true</tt> if mail notification is enabled, otherwise <tt>false</tt>
+   */
+  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
+   * <tt>mod-errorreporter_access</tt> 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 
+   * <tt>mod-errorreporter_access</tt> 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 (file)
index 0000000..9a4da19
--- /dev/null
@@ -0,0 +1,178 @@
+<?php
+/**\r
+ * @file class_erErrorReport.inc
+ * A container class for an error report\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 18.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+/** This class represents a dataset stored in the SQL table */
+class erErrorReport {
+
+  /**
+   * @privatesection
+   * (int) Unique ID in the database
+   */
+  var $nUid;
+  /** (timestamp) Date when the report was created */
+  var $tsDate;
+  /** (string) Account name of the owner */
+  var $strOwner;
+  /** (string) Machine to which the report refers */
+  var $strMachine;
+  /** (string) Text of the report */
+  var $strText;
+  /** (string) Comments of an administrator */
+  var $strComment;
+  /** (string) Account name of the one who wrote the comment */
+  var $strCommentOwner;
+  /** (bool) Indicate if the report can be seen by non-administrators */
+  var $bHidden;
+  
+  /**
+   * @publicsection
+   * @name Constructor
+   * @{
+   */
+  /**
+   * Constructor. Used to set the data.
+   * @param $tsDate (timestamp) Date when the report was created
+   * @param $strOwner (string) Account name of the creator
+   * @param $strMachine (string) Machine to which the report refers
+   * @param $strText (string) Text of the report
+   * @param $bHidden (bool) Indicate if the report can be seen by non-administrators
+   * @return erError
+   */
+  function erErrorReport($tsDate = null, $strOwner = null, $strMachine = null, $strText = null,
+    $bHidden = false) {
+    $this->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) <tt>true</tt>: 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 (file)
index 0000000..1536159
--- /dev/null
@@ -0,0 +1,414 @@
+<?php
+/**\r
+ * @file class_erErrorReportManager.inc -- management of multiple error reports\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 18.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+require_once("mod_error-reporter/class_erErrorReport.inc");
+require_once("mod_error-reporter/class_erConfig.inc");
+require_once("mod_error-reporter/functions.inc");
+require_once("db.inc");
+require_once("user.inc");
+
+db_query("SET DATESTYLE = ISO ");
+
+/**
+ * @page errorreportmanager_constants erErrorReportManager Constants
+ * @section errorreportmanager_sorting Sorting constants
+ * - @b ER_ERM_SORT_UID: Array is sorted by unique ID
+ * - @b ER_ERM_SORT_DATE: Array is sorted by the creation date
+ * - @b ER_ERM_SORT_OWNER: Array is sorted by owner of the error report
+ * - @b ER_ERM_SORT_MACHINE: Array is sorted by the machine to which the report refers
+ * - @b ER_ERM_SORT_TEXT: Array is sorted by text / notes
+ * - @b ER_ERM_SORT_COMMENT: Array is sorted by comment
+ * - @b ER_ERM_SORT_COMMENTOWNER: Array is sorted by the account name of the person who wrote the comment
+ * - @b ER_ERM_SORT_VISIBILITY: Array is sorted by hide status 
+ * @section errorreportmanager_sorting_dir Sorting direction constants
+ * - @b ER_ERM_SORT_ASC: Array is sorted in ascending order
+ * - @b ER_ERM_SORT_DESC: Array is sorted in descending order
+ */
+define("ER_ERM_SORT_UID", 0);          /*< sort by unique ID */
+define("ER_ERM_SORT_DATE", 1);         /*< sort by date */
+define("ER_ERM_SORT_OWNER", 2);        /*< sort by owner */
+define("ER_ERM_SORT_MACHINE", 3);      /*< sort by machine to which the report refers */
+define("ER_ERM_SORT_TEXT", 4);         /*< sort by text*/
+define("ER_ERM_SORT_COMMENT", 5);      /*< sort by comment */
+define("ER_ERM_SORT_COMMENTOWNER", 6); /*< sort by account name of the person who wrote the comment */
+define("ER_ERM_SORT_VISIBILITY", 6);   /*< sort by visibility */
+
+define("ER_ERM_SORT_ASC", 0);          /*< sort ascending */ 
+define("ER_ERM_SORT_DESC", 1);         /*< sort descending */ 
+
+/**
+ * Management of error reports
+ * 
+ * This class allows a comprehensive management of error reports.
+ * 
+ * @par Error reports management
+ * To add an error reports, simply create an instance of this class and call writeErrorReport()
+ * with a erErrorReport object as the only parameter. If the $nUid member of the erErrorReport 
+ * object is <tt>null</tt>, 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 <tt>false</tt>.
+ * 
+ * @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
+ * <?php
+ * require_once("class_erErrorReportManager.inc");
+ * $obj = new erErrorReportManager;
+ * $em = new erErrorReport(strtotime("2007-02-05"), "testuser", "Client-26", 
+ *   "This doesn’t work", false);
+ * $em->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 <tt>null</tt>. 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 <tt>null</tt>.
+   * @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 <tt>null</tt>. 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 <tt>null</tt>. 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 <tt>null</tt>. 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 <tt>null</tt>. 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 <tt>null</tt>. 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: <tt>ORDER BY er_hidden ASC, er_machine DESC, er_uid ASC</tt>
+   * @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 <tt>null</tt>, 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("<html><body>\nEin Benutzer hat eine Fehlermeldung mit dem ".
+        "Fehlermeldungs-Assistenten abgeschickt. Nachfolgend finden sich Angaben über den ".
+        "Fehler.\n<table>\n<tr><td>Fehler gemeldet von:</td><td>%s</td></tr>\n".
+        "<tr><td>Datum:</td><td>%s</td></tr>\n<tr><td>Betroffener Rechner:</td><td>%s</td></tr>\n".
+        "<tr><td colspan='2'>%s</td></tr>\n</table>\n<hr />\nDiese Mail wurde automatisch ".
+        "generiert.\n</body></html>", 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 (file)
index 0000000..5a2cc7b
--- /dev/null
@@ -0,0 +1,247 @@
+<?php
+/**\r
+ * @file class_erErrorReportView.inc 
+ * Class for viewing error reports\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 21.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+require_once("mod_error-reporter/class_erConfig.inc");
+require_once("mod_error-reporter/class_erErrorReport.inc");
+require_once("mod_error-reporter/class_erErrorReportManager.inc");
+require_once("share.inc");
+require_once("ctrl.inc");
+require_once("format.inc");
+
+/** @todo document */
+class erErrorReportView {
+  /**
+   * (object of class erConfig) pointer to the configuration class
+   */
+  protected $objcfg;
+  /** (object of type erErrorReportManager) pointer to a erErrorReportManager instance */
+  protected $objManager;
+  /**
+   * (string) URL to the page which allows editing of an error report.
+   * The specified page must handle the <tt>uid</tt> 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 <tt>uid</tt> 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("<style type='text/css'>
+       table.errors-view-table { width:100%; border:2px solid #5276AB; }
+       td.errors-view-description { width:12em; }
+       td.errors-view-comment-row { font-style:italic; }
+       td.errors-view-action-edit, td.errors-view-action-delete {
+         width: 16px;
+         padding:0 1em;
+         vertical-align:middle;
+       }
+    </style>");
+  }
+  
+  /**
+   * 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 (<tt>true</tt>) or several
+   *  times to get a compound table of reports (<tt>false</tt>).
+   * @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 "<tr style='background-color:$sColor'>";
+    if($this->objcfg->userIsAdmin() or $this->objManager->userIsOwner($objem->getUid())) {
+      // user is admin or owner
+      echo "<td style='padding:3px'><{$GLOBALS["invtbl"]} width='100%'>\n";
+      echo sprintf("<tr><td class='errors-view-description'>%s</td><td>%s</td></tr>",
+        _c("error-reporter:Reported by:"), erMailToUserLink($objem->getOwner()));
+      echo sprintf("<tr><td class='errors-view-description'>%s</td><td>%s</td></tr>\n", 
+        _c("error-reporter:Date:"), SmartDate($objem->getDate()));
+      echo sprintf("<tr><td class='errors-view-description'>%s</td><td>%s</td></tr>\n", 
+        _c("error-reporter:Affected machine:"), q($objem->getMachine()));
+      echo sprintf("<tr><td class='errors-view-description'>%s</td><td>%s</td></tr>\n", 
+        _c("error-reporter:Text:"), q($objem->getText()));
+      echo sprintf("<tr><td class='errors-view-description'>%s</td><td>%s</td></tr>\n", 
+        _c("error-reporter:Hidden:"), $objem->isHidden() ? _c("error-reporter:yes") : _c("error-reporter:no"));
+      if(trim($objem->getComment()) != "") {
+        echo sprintf("<tr><td class='errors-view-description errors-view-comment-row'>%s".
+          "</td><td class='errors-view-comment-row'>%s</td></tr>\n", 
+          sprintf(_c("error-reporter:Comment by %s:"), erMailToUserLink($objem->getCommentOwner())),
+          q($objem->getComment()));
+      }
+      echo "</table></td>\n";
+      // admin buttons
+      if($bAdminButtons) {
+        echo sprintf("<td class='errors-view-action-edit'>%s</td>".
+          "<td class='errors-view-action-delete'>%s</td>",
+          $this->getEditLink($objem->getUid()), $this->getDeleteLink($objem->getUid()));
+      }
+      echo "</tr>\n";
+    } else {
+      // user can only read the report
+      echo "<td><{$GLOBALS["invtbl"]} width='100%'>\n";
+      echo sprintf("<tr><td class='errors-view-description'>%s</td><td>%s</td></tr>\n", 
+        _c("error-reporter:Affected machine:"), $objem->getMachine());
+      echo sprintf("<tr><td class='errors-view-description'>%s</td><td>%s</td></tr>\n", 
+        _c("error-reporter:Text:"), $objem->getText());
+      if(trim($objem->getComment()) != "") {
+        echo sprintf("<tr><td class='errors-view-description errors-view-comment-row'>%s".
+          "</td><td class='errors-view-comment-row'>%s</td></tr>\n", 
+          sprintf(_c("error-reporter:Comment by %s:"), erMailToUserLink($objem->getCommentOwner())),
+          q($objem->getComment()));
+      }
+      echo "</td></table><td /><td /></tr>\n";
+    }
+    if($bSingle) {
+      echo "</table>\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 "</table>\n";
+  }
+  
+  /**
+   * Set the link to the edit page.
+   * The specified page must handle the <tt>uid</tt> 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("<a %s title='%s'>%s</a>", 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 <tt>uid</tt> 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("<a href='%s' title='%s'>%s</a>", $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 (file)
index 0000000..363ce5a
--- /dev/null
@@ -0,0 +1,169 @@
+<?php
+/**\r
+ * functions.php
+ * Additional functions for iserv-moderror-reporter\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 20.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+require_once("share.inc");
+/**
+ * @page error-reporter_errorcodes Error Codes
+ * @{ 
+ */
+/** Access denied. This can be due to missing access rights. */
+define("ER_ERROR_ACCESS_DENIED", _c("error-reporter:Access denied"));
+/** Error while querying the database, maybe due to a lost connection to the server */
+define("ER_ERROR_SQL", _c("error-reporter:Error while trying to query the database"));
+/** Error while trying to open a file */
+define("ER_ERROR_OPEN_FILE", _c("error-reporter:Could not open file"));
+/** Error while trying to write a file */
+define("ER_ERROR_WRITE_FILE", _c("error-reporter:Could not write to file"));
+/** Error while trying to lock a file */
+define("ER_ERROR_LOCK_FILE", _c("error-reporter:Could not lock file"));
+/** Error while trying to unlock a file */
+define("ER_ERROR_UNLOCK_FILE", _c("error-reporter:Could not unlock file"));
+/**
+ * @}
+ */
+
+static $ercLastError = null;
+/**
+ * @todo use exceptions
+ * Set the last error.
+ * Call this function to set the error that occured last. 
+ * @param $cError (constant) Error code, see @ref error-reporter_errorcodes
+ *  for a list of constants.
+ */
+function setLastError($cError) { $GLOBALS["ercLastError"] = $cError; }
+/**
+ * Get the error that occured last.
+ * @return (constant) Error code, see @ref error-reporter_errorcodes for a list of constants.
+ */
+function getLastError() { return $GLOBALS["ercLastError"]; }
+
+/**
+ * Print the error that occured last
+ * @return void
+ */
+function printLastError() {
+  echo sprintf("<p class='err'>%s %s</p>", _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 <tt>null</tt>.
+ * @throws Exception
+ */
+function erIsAct($strAct) {
+  $hQuery = db_query("SELECT * FROM users WHERE act = $1;", $strAct);\r
+  if(!is_resource($hQuery)) {\r
+    throw new Exception(ER_ERROR_SQL);
+    return null;\r
+  }\r
+  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 <tt>null</tt>.
+ * @throws Exception
+ */
+function erGetRealUserName($strAct) {
+  $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", $strAct);\r
+  if(!is_resource($hQuery)) {\r
+       throw new Exception(ER_ERROR_SQL);\r
+       return null;\r
+  }
+  if(pg_num_rows($hQuery) == 0) {
+    return $strAct;     // User not found in database, return account name
+  }\r
+  $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 <tt>null</tt>.
+ * @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 <tt>null</tt>.
+ * @throws Exception
+ */
+function erGetGroupName($strAct) {
+  $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", qdb($strAct)));\r
+  if(!is_resource($hQuery)) {\r
+       throw new Exception(ER_ERROR_SQL);\r
+       return null;\r
+  }\r
+  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");
+}\r
+?>
\ No newline at end of file
diff --git a/inc/init.inc b/inc/init.inc
new file mode 100644 (file)
index 0000000..b780dec
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+/**\r
+ * @file init.inc
+ * Initialisation stuff\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 21.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+require_once("mod_error-reporter/class_erErrorReportView.inc"); // this includes all the other things
+
+$cfgErrors = new erConfig();
+require_once("mod_error-reporter/config.inc");
+
+$doc = new erErrorReportManager($cfgErrors);
+$view = new erErrorReportView($cfgErrors, $doc);
+$view->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 (file)
index 0000000..ad43b1d
--- /dev/null
@@ -0,0 +1,180 @@
+#\r
+# @file mod_error-reporter.po -- Translations for iserv-mod-error-reporter\r
+# @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+# @date 21.10.2007\r
+# \r
+# Copyright © 2007 Roland Hieber\r
+# \r
+# Permission is hereby granted, free of charge, to any person obtaining\r
+# copy of this software and associated documentation files (the "Software"),\r
+# to deal in the Software without restriction, including without limitation\r
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+# and/or sell copies of the Software, and to permit persons to whom the\r
+# Software is furnished to do so, subject to the following conditions:\r
+# \r
+# The above copyright notice and this permission notice shall be included in\r
+# all copies or substantial portions of the Software.\r
+#  \r
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+# THE SOFTWARE.\r
+#\r
+\r
+msgid "Error Report Wizard"\r
+msgstr "Fehlermeldungsassistent"\r
+\r
+msgid "Administration of the error report wizard"\r
+msgstr "Administration des Fehlermeldungsassistenten"\r
+\r
+msgid "View error reports and report errors"\r
+msgstr "Fehlermeldungen anzeigen und Fehler melden"\r
+\r
+msgid "error-reporter:Error Report Wizard"\r
+msgstr "error-reporter:Fehlermeldungsassistent"\r
+\r
+msgid "error-reporter:Date:"\r
+msgstr "error-reporter:Datum:"\r
+\r
+msgid "error-reporter:Reported by:"\r
+msgstr "error-reporter:Gemeldet von:"\r
+\r
+msgid "error-reporter:Affected machine:"\r
+msgstr "error-reporter:Betroffener Rechner:"\r
+\r
+msgid "error-reporter:Text:"\r
+msgstr "error-reporter:Text:"\r
+\r
+msgid "error-reporter:Comment:"\r
+msgstr "error-reporter:Kommentar:"\r
+\r
+msgid "error-reporter:Comment by %s:"\r
+msgstr "error-reporter:Kommentar von %s:"\r
+\r
+msgid "error-reporter:Comment written by:"\r
+msgstr "error-reporter:Kommentar verfasst von:"\r
+\r
+msgid "error-reporter:Hidden:"\r
+msgstr "error-reporter:Versteckt:"\r
+\r
+msgid "error-reporter:yes"\r
+msgstr "error-reporter:ja"\r
+\r
+msgid "error-reporter:no"\r
+msgstr "error-reporter:nein"\r
+\r
+msgid "error-reporter:Report an error"\r
+msgstr "error-reporter:Fehler melden"\r
+\r
+msgid "error-reporter:Delete an error report"\r
+msgstr "error-reporter:Eine Fehlermeldung löschen"\r
+\r
+msgid "error-reporter:The specified error report does not exist!"\r
+msgstr "error-reporter:Die angegebene Fehlermeldung existiert nicht!"\r
+\r
+msgid "error-reporter:You are about to delete the following error report:"\r
+msgstr "error-reporter:Soll diese Fehlermeldung gelöscht werden?"\r
+\r
+msgid "error-reporter:You are not allowed to delete this report."\r
+msgstr "error-reporter:Sie sind nicht berechtigt, diese Meldung zu löschen."\r
+\r
+msgid "error-reporter:You are not allowed to edit this report."\r
+msgstr "error-reporter:Sie sind nicht berechtigt, diese Meldung zuView  ändern."\r
+\r
+msgid "error-reporter:You have to fill out all the fields in the form."\r
+msgstr "error-reporter:Sie müssen alle Felder des Formulars ausfüllen."\r
+\r
+msgid "error-reporter:The report was submitted. Thank you for your help."\r
+msgstr "error-reporter:Die Fehlermeldung wurde eingetragen. Vielen Dank für Ihre Mithilfe."\r
+\r
+msgid "error-reporter:Reports that have already been submitted:"\r
+msgstr "error-reporter:Fehlermeldungen, die schon eingetragen wurden:"\r
+\r
+msgid "error-reporter:These errors should not be resubmitted."\r
+msgstr "error-reporter:Diese Fehler sollten nicht noch einmal eingetragen werden."\r
+\r
+msgid "error-reporter:Please write your report as precise as possible to help us solve the problem. "\r
+  "The more precise the report is, the faster the error can be fixed. Please include also any "\r
+  "error messages you have recieved."\r
+msgstr "error-reporter:Verfassen Sie Ihre Meldung bitte so genau wie möglich. Je genauer Ihre Angaben "\r
+  "sind, desto schneller kann der Fehler behoben werden. Bitte erwähnen Sie auch jegliche "\r
+  "Fehlermeldungen, die Sie erhalten haben."\r
+\r
+msgid "error-reporter:Description of the error:"\r
+msgstr "error-reporter:Fehlerbeschreibung:"\r
+\r
+msgid "error-reporter:Visible only for administrators (use this if your report is about security issues)"\r
+msgstr "error-reporter:Nur für Administratoren sichtbar (falls es um Sicherheitslöcher geht)"\r
+\r
+msgid "error-reporter:Change an error report"\r
+msgstr "error-reporter:Fehlermeldung ändern"\r
+\r
+msgid "error-reporter:An error occured:"\r
+msgstr "error-reporter:Ein Fehler ist aufgetreten:"\r
+\r
+msgid "error-reporter:Recommened reading"\r
+msgstr "error-reporter:Empfohlene Lektüre"\r
+\r
+msgid "error-reporter:“How to Report Bugs Effectively”, by Simon G. Tatham"\r
+msgstr "error-reporter:„Wie Sie Softwarefehler melden sollten”, von Simon G. Tatham"\r
+\r
+msgid "error-reporter:http://www.chiark.greenend.org.uk/~sgtatham/bugs.html"\r
+msgstr "error-reporter:http://www.chiark.greenend.org.uk/~sgtatham/bugs-de.html"\r
+\r
+msgid "error-reporter-cfg:Error Report Wizard – Configuration"\r
+msgstr "error-reporter-cfg:Fehlermeldungsassistent – Konfiguration"\r
+\r
+msgid "error-reporter-cfg:Mail notification"\r
+msgstr "error-reporter-cfg:Benachrichtigungen per E-Mail"\r
+\r
+msgid "error-reporter-cfg:Enable mail notification"\r
+msgstr "error-reporter-cfg:Mail-Benachrichtigung aktivieren"\r
+\r
+msgid "error-reporter-cfg:If this option is enabled, everytime an error report is submitted, an e-mail "\r
+  "with information about the report will be sent to the address specified below."\r
+msgstr "error-reporter-cfg:Wenn diese Option aktiviert ist, wird jedesmal, wenn ein Fehler gemeldet wird, "\r
+  "eine E-Mail mit Informationen über die Fehlermeldung an die angegebene Adresse gesendet."\r
+\r
+msgid "error-reporter-cfg:Mail address to send the notification mail to"\r
+msgstr "error-reporter-cfg:E-Mail-Adresse für die Benachrichtigungs-Mails"\r
+\r
+msgid "error-reporter-cfg:If mail notifications are enabled, any notification mails are sent to "\r
+  "the address specified here. You can give more than one address by separating them with a comma."\r
+msgstr "error-reporter-cfg:Wenn die E-Mail-Benachrichtigung aktiviert ist, werden alle E-Mails an "\r
+  "die hier angegebene Adresse gesendet. Sie können mehrere Adressen angeben, indem Sie sie mit "\r
+  "Kommata trennen."\r
+\r
+msgid "error-reporter-cfg:Set mail notification."\r
+msgstr "error-reporter-cfg:E-Mail-Benachrichtigung gesetzt."\r
+\r
+msgid "error-reporter-cfg:Set mail notification address."\r
+msgstr "error-reporter-cfg:Adresse für E-Mail-Benachrichtigung gesetzt."\r
+\r
+msgid "error-reporter-cfg:The specified string is not a valid e-mail address!"\r
+msgstr "error-reporter-cfg:Die angegebene Zeichenkette ist keine gültige E-Mail-Adresse!"\r
+\r
+msgid "error-reporter:This is a short summary of the privileges related to the error report assistant "\r
+  "and the groups which have them assigned."\r
+msgstr "error-reporter:Dies ist eine kurze Übersicht über die vom "\r
+  "Fehlermeldungsassistenten genutzten Sonderrechte und den Gruppen, denen sie "\r
+  "zugewiesen wurden."\r
+\r
+msgid "error-reporter:If one of these privileges is not assigned to "\r
+  "any group, all users on this server are allowed to perform the specified "\r
+  "action. Please use the %sgroup administration%s to assign and revoke "\r
+  "privileges."\r
+msgstr "Falls eines dieser Sonderrechte keiner Gruppe "\r
+  "zugewiesen wurde, dürfen alle Benutzer dieses Servers die entsprechende "\r
+  "Aktion vornehmen. Sonderrechte können in der %sGruppenverwaltung%s "\r
+  "zugeteilt und entzogen werden."\r
+  \r
+msgid "error-reporter:Please note that every group with the administration "\r
+  "privilege can also implicitly report errors and see the reported messages."\r
+msgstr "error-reporter:Es ist zu beachten, dass jede Gruppe mit Administrations-"\r
+       "Sonderrecht implizit auch Fehler melden und alle gemeldeten Fehler einsehen kann."\r
+\r
+msgid "error-reporter:all users"\r
+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 (executable)
index 0000000..43e3820
--- /dev/null
@@ -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 (file)
index 0000000..d9605ef
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+/**
+ * @file update.php
+ * Perform the update operations like renaming SQL tables\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 23.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+require_once("/usr/share/iserv/www/inc/quote.inc");
+require_once("/usr/share/iserv/www/inc/db.inc");
+
+function doSql($cmd, $quiet = false) {
+  $i = 0;
+  $a = array();
+  $cmd = "psql -c ".qs($cmd);
+  $cmd = ($quiet) ? $cmd . ">/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 (file)
index 0000000..f0e85a4
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+/**\r
+ * @file 79error-reporter.mod
+ * Menu item for users\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 27.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+require_once("mod_error-reporter/init.inc");
+if($cfgErrors->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 (file)
index 0000000..09f515e
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+/**\r
+ * @file 99error-reporter-cfg.mod -- menu item for configuration\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 27.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+TreeNode(_c("error-reporter:Error Report Wizard"), "mod_error-reporter/config.php", "mod_error-reporter");
+?>
\ No newline at end of file
diff --git a/priv/mod_error-reporter b/priv/mod_error-reporter
new file mode 100644 (file)
index 0000000..486e471
--- /dev/null
@@ -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 (file)
index 0000000..4628eba
--- /dev/null
@@ -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 (file)
index 0000000..dde3af9
--- /dev/null
@@ -0,0 +1,42 @@
+--\r
+-- @file mod_ error-reporter.sql -- Table definitions for iserv-mod-error-reporter\r
+-- @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+-- @date 27.10.2007\r
+-- \r
+-- Copyright © 2007 Roland Hieber\r
+-- \r
+-- Permission is hereby granted, free of charge, to any person obtaining\r
+-- copy of this software and associated documentation files (the "Software"),\r
+-- to deal in the Software without restriction, including without limitation\r
+-- the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+-- and/or sell copies of the Software, and to permit persons to whom the\r
+-- Software is furnished to do so, subject to the following conditions:\r
+-- \r
+-- The above copyright notice and this permission notice shall be included in\r
+-- all copies or substantial portions of the Software.\r
+--  \r
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+-- THE SOFTWARE.\r
+--
+
+CREATE TABLE mod_errorreporter (
+    er_uid          SERIAL                      NOT NULL PRIMARY KEY,
+    er_date         TIMESTAMP WITHOUT TIME ZONE NOT NULL,
+    er_act          TEXT                        NOT NULL\r
+                                                                                               REFERENCES users(act)\r
+                                                                                               ON DELETE CASCADE\r
+                                                                                               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 (file)
index 0000000..8d0f8db
--- /dev/null
@@ -0,0 +1,135 @@
+<?php
+/**\r
+ * @file config.php
+ * Configuration page\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 22.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+/** @todo add configuration for allowed groups */
+
+require_once("mod_error-reporter/class_erConfig.inc");
+require_once("mod_error-reporter/functions.inc");
+require_once("share.inc");
+require_once("ctrl.inc");
+require_once("db.inc");
+require_once("sec/admsecure.inc");
+
+html_header("<style type='text/css'>
+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;
+}
+</style>");
+
+$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("<p>%s</p>\n", _c("error-reporter-cfg:Set mail notification."));
+  }
+  if($strMailNotifyAddr != $cfgErrors->getMailNotifyAddr()) {
+    if(!erIsMailAddress($strMailNotifyAddr)) {
+      echo sprintf("<p class='err'>%s</p>", _c("error-reporter-cfg:The specified string is not ".
+        "a valid e-mail address!"));
+    } else {
+      $cfgErrors->setMailNotifyAddr($strMailNotifyAddr);
+      echo sprintf("<p>%s</p>\n", _c("error-reporter-cfg:Set mail notification address."));
+    }
+  }
+  $cfgErrors->writeConfig();
+}
+
+// two columns
+echo "<table border='0' cellspacing='10' cellpadding='0'><tr><td width='50%'>\n";
+
+// Mail notification
+GroupBox(_c("error-reporter-cfg:Mail notification"), "mail");
+echo "<form method='post'>\n";
+echo "<table class='errors-cfg-table'>\n";
+echo sprintf("<tr><td class='errors-cfg-field'><label for='mailnotify' ".
+  "class='errors-cfg-field-heading'>%s</label><br />%s</td><td class='errors-cfg-field'>".
+  "<input type='checkbox' name='mailnotify' id='mailnotify' value='true'%s /></td></tr>",
+  _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("<tr><td class='errors-cfg-field'><label for='mailnotifyaddr'".
+  "class='errors-cfg-field-heading'>%s</label><br />%s</td><td class='errors-cfg-field'>".
+  "<input type='text' name='mailnotifyaddr' id='mailnotifyaddr' size='30' value='%s' />".
+  "</td></tr>", _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("<tr><td class='errors-cfg-field'><$stdbtn name='submit' value='%s' /></td></tr>\n",
+  _("Save"));
+echo "</table>\n</form>\n";
+_GroupBox();
+
+echo "</td><td>\n";
+
+// Privileges
+GroupBox(_("Privileges"), "keys");
+$asAccessGroups = erPrivilegedGroups("mod_errorreporter_access");
+$asAdminGroups = erPrivilegedGroups("mod_errorreporter_admin");
+echo sprintf("<p>%s</p>\n<p>%s</p>\n<p>%s</p>", _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."), "<a href='/idesk/admin/act/groups.php'>", "</a>"),
+  _c("error-reporter:Please note that every group with the administration ".
+  "privilege can also implicitly report errors and see the reported messages."));
+echo "<p><table style='width:100%'><tr>\n";
+echo sprintf("<td>%s%s</td><td>%s</td>\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 "</tr><tr>\n";
+echo sprintf("<td>%s%s</td><td>%s</td>\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 "</tr></table></p>\n";
+_GroupBox();
+
+echo "</td></tr></table>\n";
+
+_PageBlue();
+?>
\ No newline at end of file
diff --git a/src/detail.php b/src/detail.php
new file mode 100644 (file)
index 0000000..d4b1ee2
--- /dev/null
@@ -0,0 +1,124 @@
+<?php
+/**\r
+ * @file detail.php
+ * Page to edit an error report\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 22.10.2007\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+require_once("mod_error-reporter/init.inc");
+require_once("sec/secure.inc");
+require_once("js.inc");
+
+PageBlue(_c("error-reporter:Change an error report"), "mod_error-reporter");
+
+if(!$cfgErrors->userHasAccess()) {
+  printf("<p class='err'>%s</p>\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("<p class='err'>%s</p>",
+    _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("<p class='err'>%s</div>", _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("<form action='?action=update&amp;uid=%d' method='post'>\n", $getUid);
+echo "<table>\n";
+echo sprintf("<tr><td>%s</td><td>%s</td></tr>\n", _c("error-reporter:Reported by:"),  
+  q(erGetRealUserName($er->getOwner())));
+echo sprintf("<tr><td>%s</td><td>%s</td></tr>\n", _c("error-reporter:Date:"), SmartDate($er->getDate()));
+echo sprintf("<tr><td>%s</td><td><{$GLOBALS["stdedt"]} name='machine' value='%s' /></td></tr>\n",
+  _c("error-reporter:Affected machine:"), q($er->getMachine()));
+echo sprintf("<tr><td>%s</td><td><textarea name='text' cols='40' rows='7'>%s".
+  "</textarea></td></tr>\n", _c("error-reporter:Text:"), $er->getText());
+echo sprintf("<tr><td><label for='hidden'>%s</label></td><td><input type='checkbox' id='hidden' ".
+  "name='hidden' value='true'%s /></td></tr>\n", _c("error-reporter:Hidden:"),
+  $er->isHidden() ? " checked='checked'" : "");
+if($cfgErrors->userIsAdmin()) {
+  echo sprintf("<tr><td>%s</td><td><textarea name='comment' cols='40' rows='3'>%s</textarea>",
+    _c("error-reporter:Comment:"), $er->getComment());
+  if($er->getComment() != "") {
+    echo sprintf("<input type='hidden' name='comment_old' value='%s' /></td></tr>\n", $strOldComment);
+    echo sprintf("<tr><td>%s</td><td>%s</td></tr>\n", _c("error-reporter:Comment written by:"), 
+      erGetRealUserName($er->getCommentOwner()));
+  }
+}
+echo sprintf("<tr><td /><td><{$GLOBALS["smlbtn"]} value='%s' /></td></tr>\n", _("Change"));
+echo "</table></form><p />\n";
+_PageBlue();
+?>
diff --git a/src/index.php b/src/index.php
new file mode 100644 (file)
index 0000000..f02af6c
--- /dev/null
@@ -0,0 +1,159 @@
+<?php
+/**\r
+ * @file index.php
+ * Main page to show the error reports\r
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
+ * @date 21.10.2007\r
+ * @package iserv_errorreporter\r
+ * \r
+ * Copyright © 2007 Roland Hieber\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ * \r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ *  \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ */
+
+/** @todo turn this into a class */
+require_once("mod_error-reporter/init.inc");
+require_once("sec/secure.inc");
+
+html_header("<style type='text/css'>
+td.errors-form-description {
+  width: 12em;
+}
+</style>");
+
+$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("<p class='err'>%s</p>\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("<p class='err'>%s</p>",
+        _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("<form action='%s' method='post'>\n", $view->getDeleteURL($getUid));
+        echo sprintf("<p>%s</p>", 
+          _c("error-reporter:You are about to delete the following error report:"));
+        $view->printErrorReport($doc->getErrorReportByID($getUid), true, false);
+        echo sprintf("<p><input type='submit' class='submit' name='surely_delete' value='%s' />\n".
+          "&nbsp;<input type='submit' class='submit' name='surely_cancel' value='%s' />\n".
+          "</p></form>", _("Delete"), _("Cancel"));
+      } else {
+        echo sprintf("<p class='err'>%s</p>", 
+          _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("<form action='%s' method='get'></form>\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("<p class='err'>%s</p>", $e->getMessage());
+         }
+         
+         if($nNewUid !== null) {
+      echo sprintf("<p class='err'>%s</p>",
+        _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("<p>%s</p>", _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 "<p />\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 "<p class='err'>$strError</p>\n";
+
+echo sprintf("<p>%s</p>\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 "<form name='form' id='form' method='post' action='?action=submit'>\n<{$GLOBALS["invtbl"]}>\n";
+echo sprintf("<tr><td class='errors-form-description'>%s</td>".
+  "<td><input type='text' name='machine' size='55' value='%s' /></td></tr>\n",
+  _c("error-reporter:Affected machine:"), q($postMachine));
+echo sprintf("<tr><td class='errors-form-description'>%s</td><td>".
+  "<textarea name='text' cols='40' rows='5'>%s</textarea></td></tr>\n",
+  _c("error-reporter:Description of the error:"), q($postText));
+echo sprintf("<tr><td /><td><input type='hidden' name='hidden' value='false' />".
+  "<input type='checkbox' id='hidden' name='hidden' value='true'%s><label for='hidden'>%s".
+  "</label></td></tr>\n", ($postHidden == "true") ? " checked='checked'" : "",
+  _c("error-reporter:Visible only for administrators (use this if your report is about security issues)"));
+echo sprintf("<tr><td /><td><input type='submit' name='submit' value='%s' /></td></tr>\n", 
+  _("Insert"));
+echo "</table></form><p />\n";
+
+_PageBlue();
+?>
This page took 0.094994 seconds and 4 git commands to generate.