config migration in source code; config page is not needed anymore
[iserv-mod-error-reporter.git] / inc / class_erErrorReportManager.inc
index b3fd64d..425f26b 100644 (file)
@@ -1,33 +1,34 @@
 <?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
+/**
+ * @file class_erErrorReportManager.inc -- management of multiple error reports
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 18.10.2007
+ * 
+ * Copyright © 2007 Roland Hieber
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
  */
 
 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("cfg.inc");
 require_once("db.inc");
 require_once("user.inc");
 
@@ -39,10 +40,12 @@ db_query("SET DATESTYLE = ISO ");
  * - @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_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_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
@@ -51,10 +54,12 @@ db_query("SET DATESTYLE = ISO ");
 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_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_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 */ 
@@ -66,37 +71,39 @@ define("ER_ERM_SORT_DESC", 1);         /*< sort descending */
  * 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.
+ * To add an error reports, simply create an instance of this class and call
+ * writeErrorReport() with an 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.
+ * 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>.
+ * 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.
+ * 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.
+ * 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.
+ * 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");
@@ -104,32 +111,14 @@ define("ER_ERM_SORT_DESC", 1);         /*< sort descending */
  * $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
- * ?>
+ * // $em->nUid is null, so writeErrorReport() calculates the UID by itself
+ * $nNewID = $obj->writeErrorReport($em);  
  * @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 ///////////////////////////////////////////
+  /////////////////////////////////// QUERYING /////////////////////////////////
 
   /**
    * @name Quering 
@@ -140,18 +129,22 @@ class erErrorReportManager {
    * @return int
    */
   public function getNumErrorReports() {
-    $ar = pg_fetch_array(db_query("SELECT COUNT(*) AS count FROM mod_errorreporter;"), 0);
+    $ar = pg_fetch_array(db_query("SELECT COUNT(*) AS count FROM ".
+      "mod_errorreporter;"), 0);
     return intval($ar["count"]);
   }
   
   /**
    * 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.
+   * 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)) {
+  public function getErrorReports($arcSort = array(ER_ERM_SORT_UID => 
+    ER_ERM_SORT_ASC)) {
     return $this->readFromSQL("", $arcSort);
   }
   
@@ -172,34 +165,42 @@ class erErrorReportManager {
   
   /**
    * 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.
+   * 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.
+   * @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)) {
+  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.
+   * 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.
+   * @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)) {
+  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.
+   * 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.
+   * @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, 
@@ -209,10 +210,12 @@ class erErrorReportManager {
   
   /**
    * 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.
+   * 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.
+   * @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,
@@ -224,36 +227,43 @@ class erErrorReportManager {
   
   /**
    * 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.
+   * 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.
+   * @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)) {
+  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()) {
+    // only allow visible reports for non-admins, but all reports for 
+    // admins and owners
+    if(erConfig::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"]);
+      $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;");
+    $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 = 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;
@@ -263,10 +273,11 @@ class erErrorReportManager {
 
   /**
    * 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 
+   * 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(
@@ -277,8 +288,9 @@ class erErrorReportManager {
    * @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.
+   * @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) {
@@ -287,27 +299,41 @@ class erErrorReportManager {
     foreach($arcSort as $cSort => $cDir) {
       switch($cSort) {
         case ER_ERM_SORT_UID:
-          $arstrSort[] = "er_uid ".($cDir == ER_ERM_SORT_DESC ? "DESC" : "ASC"); break;
+          $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;
+          $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;
+          $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;
+          $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;
+          $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;
+          $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;
+          $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;
+          $arstrSort[] = "er_hidden ".($cDir == ER_ERM_SORT_DESC ? "DESC" :
+            "ASC");
+          break;
       }
     }
     return ("ORDER BY ".join(", ", $arstrSort));
   }
   
-  //////////////////////////////////// ERROR MESSAGE MANAGEMENT ///////////////////////////////////
+  ////////////////////////// ERROR MESSAGE MANAGEMENT //////////////////////////
 
   /**
    * @name Error report management 
@@ -316,16 +342,16 @@ class erErrorReportManager {
 
   /**
    * 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.
+   * 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 record having the respective UID 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())))) {
+    if(!erConfig::userHasAccess() and (!$this->userIsOwner($er->nUid) or
+      ($er->getUid() == null and !(erConfig::userIsAdmin())))) {
       throw new Exception(ER_ERROR_ACCESS_DENIED);
     }
     
@@ -336,7 +362,7 @@ class erErrorReportManager {
     $arPut = array();
     if($er->getUid() == null) {
       // er_uid is now serial
-                       /*$hQuery = db_query("SELECT MAX(er_uid) AS id FROM mod_errorreporter;");
+      /*$hQuery = db_query("SELECT MAX(er_uid) AS id FROM mod_errorreporter;");
       if(!is_resource($hQuery)) {
         setLastError(ER_ERROR_SQL);
         return -1;
@@ -348,10 +374,11 @@ class erErrorReportManager {
     } 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)");
+      $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();
@@ -365,19 +392,25 @@ class erErrorReportManager {
     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()));
+    if(cfg("errorreportermailnotify") 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 />\n".
+        "Diese 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",
+      $strMailHeader = sprintf("From: %s <%s>\n".
+        "Content-Type: text/html; charset=utf-8",
         q(erGetRealUserName($er->getOwner())), user_mail_addr($er->getOwner()));
-      mail($this->objcfg->getMailNotifyAddr(), $strMailSubject, $strMailText, $strMailHeader);
+      mail(cfg("errorreportermailaddress"), $strMailSubject, $strMailText,
+        $strMailHeader);
     }
     
     return $er->getUid();
@@ -385,19 +418,21 @@ class erErrorReportManager {
 
   /**
    * 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.
+   * @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))) {
+    if(!(erConfig::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()));
+    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()));
   }
   
   /**
@@ -410,7 +445,8 @@ class erErrorReportManager {
     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)));
+      $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;
@@ -420,4 +456,4 @@ class erErrorReportManager {
     }
   }
 }
-?>
\ No newline at end of file
+?>
This page took 0.047522 seconds and 4 git commands to generate.