From f6faefbedad2de5c5d4aa915f5a5f180039c055b Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Sun, 22 Feb 2009 01:26:24 +0100 Subject: [PATCH] expanded tabs, hard-wrapped lines to 80 columns, cosmetics --- Doxyfile | 4 +- inc/class_erConfig.inc | 18 +- inc/class_erErrorReport.inc | 14 +- inc/class_erErrorReportManager.inc | 252 +++++++++++++++---------- inc/class_erErrorReportView.inc | 123 ++++++------ inc/functions.inc | 47 +++-- inc/init.inc | 6 +- nav/79mod_error-reporter.mod | 3 +- nav/admin/99mod_error-reporter-cfg.mod | 5 +- sql/mod_error-reporter.sql | 72 +++---- src/config.php | 51 ++--- src/detail.php | 63 ++++--- src/index.php | 99 +++++----- 13 files changed, 433 insertions(+), 324 deletions(-) diff --git a/Doxyfile b/Doxyfile index 854734a..dedcb2a 100644 --- a/Doxyfile +++ b/Doxyfile @@ -2,8 +2,8 @@ # 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.09.13 +PROJECT_NAME = {{{MODULE}}} +PROJECT_NUMBER = 9.02.22 OUTPUT_DIRECTORY = doc/source CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English diff --git a/inc/class_erConfig.inc b/inc/class_erConfig.inc index 8cdfbf6..ee7c6df 100644 --- a/inc/class_erConfig.inc +++ b/inc/class_erConfig.inc @@ -91,8 +91,8 @@ class erConfig { /** * Write the current state of this instance to the config file. - * @return (bool) If the function fails, it returns false. Call getLastError() to get - * more information about the error. + * @return (bool) If the function fails, it returns false. Call + * getLastError() to get more information about the error. */ public function writeConfig() { // Open config file @@ -117,7 +117,8 @@ class erConfig { // Mail notification $strFile .= sprintf("\$cfgErrors->setMailNotify(%s);\n", $this->isMailNotify() ? "true" : "false"); - $strFile .= sprintf("\$cfgErrors->setMailNotifyAddr('%s');\n", $this->getMailNotifyAddr()); + $strFile .= sprintf("\$cfgErrors->setMailNotifyAddr('%s');\n", + $this->getMailNotifyAddr()); $strFile .= "?>"; @@ -146,13 +147,15 @@ class erConfig { /** * Enable or disable mail notification - * @param $b (bool) true to enable mail notification, false to disable it. + * @param $b (bool) true to enable mail notification, false + * to disable it. */ public function setMailNotify($b) { $this->bMailNotify = ($b == true); } /** * Set the mail address(es) for mail notification - * @param $str (string) The adresses to send the notofication mails to, comma-separated + * @param $str (string) The adresses to send the notofication mails to, + * comma-separated */ public function setMailNotifyAddr($str) { $this->strMailNotifyAddr = $str; } @@ -164,7 +167,8 @@ class erConfig { /** * Determine if mail notification is enabled - * @return (bool) true if mail notification is enabled, otherwise false + * @return (bool) true if mail notification is enabled, otherwise + * false */ public function isMailNotify() { return $this->bMailNotify; } @@ -205,4 +209,4 @@ class erConfig { /** @} */ } -?> \ No newline at end of file +?> diff --git a/inc/class_erErrorReport.inc b/inc/class_erErrorReport.inc index 22cfc42..827dc4d 100644 --- a/inc/class_erErrorReport.inc +++ b/inc/class_erErrorReport.inc @@ -60,7 +60,8 @@ class erErrorReport { * @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 + * @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, @@ -75,7 +76,7 @@ class erErrorReport { $this->bHidden = ($bHidden == true); } - /////////////////////////////////////////// SETTER FUNCTIONS /////////////////////////////////////////// + ////////////////////////////// SETTER FUNCTIONS ////////////////////////////// /** * @} @@ -120,11 +121,12 @@ class erErrorReport { } /** * Set the visibility of the report - * @param $value (bool) true: the report is only visible for administrators + * @param $value (bool) true: the report is only visible for + * administrators */ function setVisibility($value) { $this->bHidden = $value; } - /////////////////////////////////////////// GETTER FUNCTIONS /////////////////////////////////////////// + ////////////////////////////// GETTER FUNCTIONS ////////////////////////////// /** * @} @@ -132,7 +134,7 @@ class erErrorReport { * @{ */ - /** + /** * Get the unique ID in the database * @return (int) */ @@ -175,4 +177,4 @@ class erErrorReport { /**@}*/ } -?> \ No newline at end of file +?> diff --git a/inc/class_erErrorReportManager.inc b/inc/class_erErrorReportManager.inc index 40d0bb1..6bd8d2d 100644 --- a/inc/class_erErrorReportManager.inc +++ b/inc/class_erErrorReportManager.inc @@ -15,7 +15,7 @@ * * 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 @@ -39,10 +39,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 +53,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 +70,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 null, 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 null, + * writeErrorReport() will use the next ID which is not used in the table. * * @par * An error report that has been written to the database can be changed using - * writeErrorReport(), setting the $nUid member of the erErrorReport parameter to the UID of the - * error report to be changed. + * writeErrorReport(), setting the $nUid member of the erErrorReport parameter + * to the UID of the error report to be changed. * * @par - * To change the visibility of an error report to @e hidden, call setErrorReportDoneFlag() with - * the UID of the error report and set the second parameter to false. + * To change the visibility of an error report to @e hidden, call + * setErrorReportDoneFlag() with the UID of the error report and set the second + * parameter to false. * * @par - * To delete an error report from the database, call deleteErrorReport() with the UID of the - * error report you want to delete. + * 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 * 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 */ @@ -121,7 +125,8 @@ class erErrorReportManager { /** * Constructor - * @param $objcfg (object of type erConfig) Pointer to the configuration class for retrieving the + * @param $objcfg (object of type erConfig) Pointer to the configuration + * class for retrieving the * configuration data * @return erErrorReportManager */ @@ -129,7 +134,7 @@ class erErrorReportManager { $this->objcfg = &$objcfg; } - //////////////////////////////////////////// QUERYING /////////////////////////////////////////// + /////////////////////////////////// QUERYING ///////////////////////////////// /** * @name Quering @@ -140,18 +145,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 null. Call getLastError() to get more information. - * @param $arcSort (array of constants) Defines the sorting of the returned array. - * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * If this function fails, it returns null. Call getLastError() to + * get more information. + * @param $arcSort (array of constants) Defines the sorting of the returned + * array. See the documentation of the $arcSort parameter of + * buildOrderByClause() for more information. * @return array of objects of type erErrorReport */ - public function getErrorReports($arcSort = array(ER_ERM_SORT_UID => ER_ERM_SORT_ASC)) { + public function getErrorReports($arcSort = array(ER_ERM_SORT_UID => + ER_ERM_SORT_ASC)) { return $this->readFromSQL("", $arcSort); } @@ -172,34 +181,42 @@ class erErrorReportManager { /** * Get all error reports which have been created on the specified date. - * If this function fails, it returns null. Call getLastError() to get more information. + * If this function fails, it returns null. Call getLastError() to + * get more information. * @param $tsDate (timestamp) Date - * @param $arcSort (array of constants) Defines the sorting of the returned array. - * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @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 null. Call getLastError() to get more information. + * If this function fails, it returns null. Call getLastError() to + * get more information. * @param $strAct (string) Account name - * @param $arcSort (array of constants) Defines the sorting of the returned array. - * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @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 null. Call getLastError() to get more information. + * If this function fails, it returns null. Call getLastError() to + * get more information. * @param $strMachine (string) Machine name - * @param $arcSort (array of constants) Defines the sorting of the returned array. - * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @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 +226,12 @@ class erErrorReportManager { /** * Get all error reports which have been commented by the specified user. - * If this function fails, it returns null. Call getLastError() to get more information. + * If this function fails, it returns null. Call getLastError() to + * get more information. * @param $strAct (string) Account name - * @param $arcSort (array of constants) Defines the sorting of the returned array. - * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @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 +243,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 null. Call getLastError() to get more information. + * This function should not be called directly. Use the getBy* functions + * instead. If this function fails, it returns null. Call + * getLastError() to get more information. * @internal * @param $strWhere (string) Parameters for the SQL WHERE clause - * @param $arcSort (array of constants) Defines the sorting of the returned array. - * See the documentation of the $arcSort parameter of buildOrderByClause() for more information. + * @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 + // 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"]); + $strWhereClause = "WHERE ".((trim($strWhere) == "") ? "" : + "$strWhere AND ").sprintf("((er_act = '%s') or (er_hidden IS NULL OR ". + " 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 +289,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 +304,9 @@ class erErrorReportManager { * @endcode * The output is: ORDER BY er_hidden ASC, er_machine DESC, er_uid ASC * @internal - * @param $arcSort (array of constants) The array which declares the order of the SQL rows. Use - * @ref errorreportmanager_sorting as keys and @ref errorreportmanager_sorting_dir as values. + * @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 +315,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,9 +358,9 @@ class erErrorReportManager { /** * Insert or update an error report in the database. - * When the $nUid member of the $erErrorReport object is null, a new unique ID is - * assigned and the error report is written to the database. Otherwise, the corresponding - * record in the table is updated. + * When the $nUid member of the $erErrorReport object is null, a new + * unique ID is assigned and the error report is written to the database. + * Otherwise, the 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 @@ -336,7 +378,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 +390,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(); @@ -366,18 +409,24 @@ class erErrorReportManager { // send notification mail, but only if the message is new if($this->objcfg->isMailNotify() and $er->getUid() == null) { - $strMailText = sprintf("\nEin Benutzer hat eine Fehlermeldung mit dem ". - "Fehlermeldungs-Assistenten abgeschickt. Nachfolgend finden sich Angaben über den ". - "Fehler.\n\n\n". - "\n\n". - "\n
Fehler gemeldet von:%s
Datum:%s
Betroffener Rechner:%s
%s
\n
\nDiese Mail wurde automatisch ". - "generiert.\n", q(erGetRealUserName($er->getOwner())), - q(date("d\.m\.Y\ G\:i\:s", $er->getDate())), q($er->getMachine()), q($er->getText())); + $strMailText = sprintf("\nEin Benutzer hat eine ". + "Fehlermeldung mit dem Fehlermeldungs-Assistenten abgeschickt. ". + "Nachfolgend finden sich Angaben über den Fehler.\n". + "\n\n". + "\n". + "\n". + "\n
Fehler gemeldet von:%s
Datum:%s
Betroffener Rechner:%s
%s
\n
\n". + "Diese Mail wurde automatisch generiert.\n". + "", q(erGetRealUserName($er->getOwner())), + q(date("d\.m\.Y\ G\:i\:s", $er->getDate())), q($er->getMachine()), + q($er->getText())); $strMailSubject = sprintf("%s hat einen Fehler im System gemeldet", q(erGetRealUserName($er->getOwner()))); - $strMailHeader = sprintf("From: %s <%s>\nContent-Type: text/html; charset=utf-8", + $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($this->objcfg->getMailNotifyAddr(), $strMailSubject, $strMailText, + $strMailHeader); } return $er->getUid(); @@ -385,8 +434,9 @@ 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))) { @@ -395,9 +445,10 @@ class erErrorReportManager { } $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 +461,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 +472,4 @@ class erErrorReportManager { } } } -?> \ No newline at end of file +?> diff --git a/inc/class_erErrorReportView.inc b/inc/class_erErrorReportView.inc index 914393d..e335881 100644 --- a/inc/class_erErrorReportView.inc +++ b/inc/class_erErrorReportView.inc @@ -35,30 +35,28 @@ require_once("format.inc"); /** @todo document */ class erErrorReportView { - /** - * (object of class erConfig) pointer to the configuration class - */ + /** (erConfig) pointer to the configuration class */ protected $objcfg; - /** (object of type erErrorReportManager) pointer to a erErrorReportManager instance */ + /** (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 uid GET parameter, which contains the unique ID - * of the error report to be edited. + * The specified page must handle the uid GET parameter, which + * contains the unique ID of the error report to be edited. */ protected $strEditURL; /** * (string) URL to the page which allows deletion of an error report. - * The specified page must handle the uid GET parameter, which contains the unique ID - * of the error report to be deleted. + * The specified page must handle the uid GET parameter, which + * contains the unique ID of the error report to be deleted. */ protected $strDeleteURL; /** * Constructor - * @param $objcfg (object of type erConfig) Pointer to an instance of the erConfig class for + * @param $objcfg (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 + * @param $objemm (erErrorReportManager) Pointer to a instance of the * erErrorReportManager class for retrieving the document data * @return erErrorReportView */ @@ -66,28 +64,31 @@ class erErrorReportView { $this->objcfg = $objcfg; $this->objManager = $objemm; html_header(""); } /** * Print a single error report. - * Call this function to print a table or a compound of table rows with the information of the - * specified error report. The function determines if the current user is the owner of the - * specified report or if he has admin rights and in this case displays buttons for deletion and - * editing the error report. + * Call this function to print a table or a compound of table rows with the + * information of the specified error report. The function determines if the + * current user is the owner of the specified report or if he has admin + * rights and in this case displays buttons for deletion and editing the + * error report. * @param $objem (erErrorReport) Error report to print - * @param $bSingle (bool) Determines if you call this function once (true) or several - * times to get a compound table of reports (false). - * @param $bAdminButtons (bool) Explcitly determines whether to show the edit and delete buttons. - * This parameter overrides the userIsAdmin() and userIsOwner() functions. + * @param $bSingle (bool) Determines if you call this function once + * (true) or several times to get a compound table of reports + * (false). + * @param $bAdminButtons (bool) Explicitly determines whether to show the + * edit and delete buttons. This parameter overrides the check for owner and + * admin rights. */ public function printErrorReport(erErrorReport $objem, $bSingle = false, $bAdminButtons = true) { global $colbox_state, $invtbl; @@ -96,25 +97,29 @@ class erErrorReportView { echo "<{$GLOBALS["invtbl"]} class='errors-view-table'>"; } $nColor = bgcol_rgb(); - $sColor = sprintf("rgb(%d,%d,%d)", ($nColor >> 16) % 256, ($nColor >> 8) % 256, $nColor % 256); + $sColor = sprintf("rgb(%d,%d,%d)", ($nColor >> 16) % 256, + ($nColor >> 8) % 256, $nColor % 256); echo ""; - if($this->objcfg->userIsAdmin() or $this->objManager->userIsOwner($objem->getUid())) { + if($this->objcfg->userIsAdmin() or + $this->objManager->userIsOwner($objem->getUid())) { // user is admin or owner echo "<{$GLOBALS["invtbl"]} width='100%'>\n"; - echo sprintf("%s%s", - _c("error-reporter:Reported by:"), erMailToUserLink($objem->getOwner())); - echo sprintf("%s%s\n", - _c("error-reporter:Date:"), SmartDate($objem->getDate())); - echo sprintf("%s%s\n", - _c("error-reporter:Affected machine:"), q($objem->getMachine())); - echo sprintf("%s%s\n", - _c("error-reporter:Text:"), q($objem->getText())); - echo sprintf("%s%s\n", - _c("error-reporter:Hidden:"), $objem->isHidden() ? _c("error-reporter:yes") : _c("error-reporter:no")); + $sRow = "%s%s"; + echo sprintf("$sRow\n", _c("error-reporter:Reported by:"), + erMailToUserLink($objem->getOwner())); + echo sprintf("$sRow\n", _c("error-reporter:Date:"), + SmartDate($objem->getDate())); + echo sprintf("$sRow\n", _c("error-reporter:Affected machine:"), + q($objem->getMachine())); + echo sprintf("$sRow\n", _c("error-reporter:Text:"), q($objem->getText())); + echo sprintf("$sRow\n", _c("error-reporter:Hidden:"), $objem->isHidden() ? + _c("error-reporter:yes") : _c("error-reporter:no")); if(trim($objem->getComment()) != "") { - echo sprintf("%s". - "%s\n", - sprintf(_c("error-reporter:Comment by %s:"), erMailToUserLink($objem->getCommentOwner())), + echo sprintf("%s%s\n", + sprintf(_c("error-reporter:Comment by %s:"), + erMailToUserLink($objem->getCommentOwner())), q($objem->getComment())); } echo "\n"; @@ -122,20 +127,23 @@ class erErrorReportView { if($bAdminButtons) { echo sprintf("%s". "%s", - $this->getEditLink($objem->getUid()), $this->getDeleteLink($objem->getUid())); + $this->getEditLink($objem->getUid()), + $this->getDeleteLink($objem->getUid())); } echo "\n"; } else { // user can only read the report echo "<{$GLOBALS["invtbl"]} width='100%'>\n"; - echo sprintf("%s%s\n", - _c("error-reporter:Affected machine:"), $objem->getMachine()); - echo sprintf("%s%s\n", - _c("error-reporter:Text:"), $objem->getText()); + $sRow = "%s%s"; + echo sprintf("$sRow\n", _c("error-reporter:Affected machine:"), + $objem->getMachine()); + echo sprintf("$sRow\n", _c("error-reporter:Text:"), $objem->getText()); if(trim($objem->getComment()) != "") { - echo sprintf("%s". - "%s\n", - sprintf(_c("error-reporter:Comment by %s:"), erMailToUserLink($objem->getCommentOwner())), + echo sprintf("%s%s\n", + sprintf(_c("error-reporter:Comment by %s:"), + erMailToUserLink($objem->getCommentOwner())), q($objem->getComment())); } echo "\n"; @@ -148,7 +156,8 @@ class erErrorReportView { /** * Print a table of error reports. - * Prints a table with several error reports by calling printErrorReport() for each report. + * 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) { @@ -170,8 +179,8 @@ class erErrorReportView { /** * Set the link to the edit page. - * The specified page must handle the uid GET parameter, which contains the unique ID - * of the error report to be edited. + * The specified page must handle the uid GET parameter, which + * contains the unique ID of the error report to be edited. * @see getEditURL() * @see getEditLink() * @param $strUrl (string) @@ -202,14 +211,14 @@ class erErrorReportView { * @return string */ public function getEditLink($nUid) { - return sprintf("%s", pop($this->getEditURL($nUid), 500, 500), - _c("error-reporter:Edit this error report"), icon("write")); + return sprintf("%s", pop($this->getEditURL($nUid), + 500, 500), _c("error-reporter:Edit this error report"), icon("write")); } /** * Set the link to the delete page. - * The specified page must handle the uid GET parameter, which contains the unique ID - * of the error report to be deleted. + * The specified page must handle the uid GET parameter, which + * contains the unique ID of the error report to be deleted. * @see getDeleteURL() * @see getDeleteLink() * @param $strUrl (string) @@ -244,4 +253,4 @@ class erErrorReportView { _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 index bd1efbf..1293099 100644 --- a/inc/functions.inc +++ b/inc/functions.inc @@ -33,8 +33,12 @@ require_once("share.inc"); */ /** 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 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 */ @@ -58,7 +62,8 @@ static $ercLastError = null; 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. + * @return (constant) Error code, see @ref error-reporter_errorcodes for a list + * of constants. */ function getLastError() { return $GLOBALS["ercLastError"]; } @@ -67,7 +72,8 @@ function getLastError() { return $GLOBALS["ercLastError"]; } * @return void */ function printLastError() { - echo sprintf("

%s %s

", _c("error-reporter:An error occured:"), getLastError()); + echo sprintf("

%s %s

", _c("error-reporter:An error ". + "occured:"), getLastError()); } /** @@ -88,14 +94,16 @@ function erIsAct($strAct) { /** * Get the real user name for an account name * @param $strAct (string) Account name of the user to look up - * @return (string) The real name of the user. If the function fails, it returns null. + * @return (string) The real name of the user. If the function fails, it + * returns null. * @throws Exception */ function erGetRealUserName($strAct) { - $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", $strAct); + $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", + $strAct); if(!is_resource($hQuery)) { - throw new Exception(ER_ERROR_SQL); - return null; + throw new Exception(ER_ERROR_SQL); + return null; } if(pg_num_rows($hQuery) == 0) { return $strAct; // User not found in database, return account name @@ -111,7 +119,8 @@ function erGetRealUserName($strAct) { * @throws Exception */ function erIsGroup($strAct) { - $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", qdb($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; @@ -122,14 +131,16 @@ function erIsGroup($strAct) { /** * Look up the name of a group * @param $strAct (string) Account name of the group - * @return (string) The name of the group. If the function fails, it returns null. + * @return (string) The name of the group. If the function fails, it returns + * null. * @throws Exception */ function erGetGroupName($strAct) { - $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", qdb($strAct))); + $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", + qdb($strAct))); if(!is_resource($hQuery)) { - throw new Exception(ER_ERROR_SQL); - return null; + throw new Exception(ER_ERROR_SQL); + return null; } if(pg_num_rows($hQuery) == 0) { return $strAct; // Group not found in database, return account name @@ -140,8 +151,8 @@ function erGetGroupName($strAct) { /** * 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. + * This function returns a link if the specified account exists, otherwise it + * returns the account name. * @param $strAct (string) Account name * @return string */ @@ -159,11 +170,11 @@ function erMailToUserLink($strAct) { * @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)); + return ((preg_match("/([a-zA-Z0-9_\-\.]*(@[a-zA-Z0-9\-\.]*)?(\s*,\s*)?)+/", + $strAddr) > 0) and (preg_match("/(\s*,\s*)$/", $strAddr) == 0)); } function erInsertLog($sMsg) { log_insert($sMsg, null, "Error Report Wizard"); } -?> \ No newline at end of file +?> diff --git a/inc/init.inc b/inc/init.inc index cee8691..17aa443 100644 --- a/inc/init.inc +++ b/inc/init.inc @@ -26,7 +26,8 @@ * THE SOFTWARE. */ -require_once("mod_error-reporter/class_erErrorReportView.inc"); // this includes all the other things +// this includes all the other things +require_once("mod_error-reporter/class_erErrorReportView.inc"); $cfgErrors = new erConfig(); require_once("mod_error-reporter/config.inc"); @@ -35,5 +36,4 @@ $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/nav/79mod_error-reporter.mod b/nav/79mod_error-reporter.mod index 4be0da5..9245ad0 100644 --- a/nav/79mod_error-reporter.mod +++ b/nav/79mod_error-reporter.mod @@ -27,6 +27,7 @@ */ 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"); + 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 index 50854ce..13982d2 100644 --- a/nav/admin/99mod_error-reporter-cfg.mod +++ b/nav/admin/99mod_error-reporter-cfg.mod @@ -25,5 +25,6 @@ * THE SOFTWARE. */ -TreeNode(_c("error-reporter:Error Report Wizard"), "mod_error-reporter/config.php", "mod_error-reporter"); -?> \ No newline at end of file +TreeNode(_c("error-reporter:Error Report Wizard"), + "mod_error-reporter/config.php", "mod_error-reporter"); +?> diff --git a/sql/mod_error-reporter.sql b/sql/mod_error-reporter.sql index dde3af9..0e3ea56 100644 --- a/sql/mod_error-reporter.sql +++ b/sql/mod_error-reporter.sql @@ -1,41 +1,43 @@ --- --- @file mod_ error-reporter.sql -- Table definitions for iserv-mod-error-reporter --- @author Roland Hieber (roland.hieber@wilhelm-gym.net) --- @date 27.10.2007 --- --- Copyright © 2007 Roland Hieber --- --- Permission is hereby granted, free of charge, to any person obtaining --- copy of this software and associated documentation files (the "Software"), --- to deal in the Software without restriction, including without limitation --- the rights to use, copy, modify, merge, publish, distribute, sublicense, --- and/or sell copies of the Software, and to permit persons to whom the --- Software is furnished to do so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in --- all copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN --- THE SOFTWARE. +-- +-- @file mod_ error-reporter.sql +-- Table definitions for iserv-mod-error-reporter +-- @author Roland Hieber (roland.hieber@wilhelm-gym.net) +-- @date 27.10.2007 +-- +-- Copyright © 2007 Roland Hieber +-- +-- Permission is hereby granted, free of charge, to any person obtaining +-- copy of this software and associated documentation files (the "Software"), +-- to deal in the Software without restriction, including without limitation +-- the rights to use, copy, modify, merge, publish, distribute, sublicense, +-- and/or sell copies of the Software, and to permit persons to whom the +-- Software is furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. -- CREATE TABLE mod_errorreporter ( - er_uid SERIAL NOT NULL PRIMARY KEY, - er_date TIMESTAMP WITHOUT TIME ZONE NOT NULL, - er_act TEXT NOT NULL - REFERENCES users(act) - ON DELETE CASCADE - ON UPDATE CASCADE, - er_machine TEXT NOT NULL, - er_text TEXT NOT NULL, - er_comment TEXT, - er_commentact TEXT, - er_hidden BOOL + er_uid SERIAL NOT NULL PRIMARY KEY, + er_date TIMESTAMP WITHOUT TIME ZONE NOT NULL, + er_act TEXT NOT NULL + REFERENCES users(act) + ON DELETE CASCADE + ON UPDATE CASCADE, + er_machine TEXT NOT NULL, + er_text TEXT NOT NULL, + er_status SMALLINT NOT NULL DEFAULT 0, + er_comment TEXT, + er_commentact TEXT, + er_hidden BOOL ); GRANT SELECT, INSERT, UPDATE, DELETE ON mod_errorreporter, mod_errorreporter_er_uid_seq TO webadm; diff --git a/src/config.php b/src/config.php index 0505dae..52ba154 100644 --- a/src/config.php +++ b/src/config.php @@ -50,7 +50,8 @@ td.errors-cfg-field input { $cfgErrors = new erConfig(); require_once("mod_error-reporter/config.inc"); -PageBlue(_c("error-reporter-cfg:Error Report Wizard – Configuration"), "mod_error-reporter"); +PageBlue(_c("error-reporter-cfg:Error Report Wizard – Configuration"), + "mod_error-reporter"); if(@$_POST["submit"] == _("Save")) { $bMailNotify = (@$_POST["mailnotify"] == "true"); @@ -59,43 +60,50 @@ if(@$_POST["submit"] == _("Save")) { if($bMailNotify != $cfgErrors->isMailNotify()) { $cfgErrors->setMailNotify($bMailNotify); - echo sprintf("

%s

\n", _c("error-reporter-cfg:Set mail notification.")); + echo sprintf("

%s

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

%s

", _c("error-reporter-cfg:The specified string is not ". - "a valid e-mail address!")); + echo sprintf("

%s

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

%s

\n", _c("error-reporter-cfg:Set mail notification address.")); + echo sprintf("

%s

\n", _c("error-reporter-cfg:Set mail ". + "notification address.")); } } $cfgErrors->writeConfig(); } // two columns -echo "
\n"; +echo "". + "". "\n", _c("error-reporter:Affected machine:"), q($postMachine)); echo sprintf("\n", _c("error-reporter:Description of the error:"), q($postText)); -echo sprintf("\n", ($postHidden == "true") ? " checked='checked'" : "", - _c("error-reporter:Visible only for administrators (use this if your report is about security issues)")); -echo sprintf("\n", - _("Insert")); +echo sprintf("\n", + ($postHidden == "true") ? " checked='checked'" : "", _c("error-reporter:". + "Visible only for administrators (use this if your report is about security ". + "issues)")); +echo sprintf("\n", _("Insert")); echo "
\n"; // Mail notification GroupBox(_c("error-reporter-cfg:Mail notification"), "mail"); echo "
\n"; echo "\n"; echo sprintf("", - _c("error-reporter-cfg:Enable mail notification"), _c("error-reporter-cfg:If this option is ". - "enabled, everytime an error report is submitted, an e-mail with information about the ". - "report will be sent to the address specified below."), $cfgErrors->isMailNotify() ? + "class='errors-cfg-field-heading'>%s
%s", + _c("error-reporter-cfg:Enable mail notification"), + _c("error-reporter-cfg:If this option is enabled, everytime an error report ". + "is submitted, an e-mail with information about the report will be sent to ". + "the address specified below."), $cfgErrors->isMailNotify() ? " checked='checked'" : ""); echo sprintf("", _c("error-reporter-cfg:Mail address to send the notification mail to"), - _c("error-reporter-cfg:If mail notifications are enabled, any notification mails are sent to ". - "the address specified here. You can give more than one address by separating them with a ". - "comma."), q($cfgErrors->getMailNotifyAddr())); -echo sprintf("\n", - _("Save")); + "class='errors-cfg-field-heading'>%s
%s". + "", + _c("error-reporter-cfg:Mail address to send the notification mail to"), + _c("error-reporter-cfg:If mail notifications are enabled, any notification ". + "mails are sent to the address specified here. You can give more than one ". + "address by separating them with a comma."), + q($cfgErrors->getMailNotifyAddr())); +echo sprintf("\n", _("Save")); echo "

%s
". - "

%s
". - "". - "
<$stdbtn name='submit' value='%s' />
<$stdbtn name='submit' ". + "value='%s' />
\n
\n"; _GroupBox(); @@ -113,7 +121,8 @@ echo sprintf("

%s

\n

%s

\n

%s

", _c("error-reporter:This is ". "action. Please use the %sgroup administration%s to assign and revoke ". "privileges."), "", ""), _c("error-reporter:Please note that every group with the administration ". - "privilege can also implicitly report errors and see the reported messages.")); + "privilege can also implicitly report errors and see the reported ". + "messages.")); echo "

\n"; echo sprintf("\n", icon("keys"), _("View error reports and report errors").":", $asAccessGroups == array() ? @@ -130,4 +139,4 @@ _GroupBox(); echo "
%s%s%s
\n"; _PageBlue(); -?> \ No newline at end of file +?> diff --git a/src/detail.php b/src/detail.php index 3b59479..6561b8f 100644 --- a/src/detail.php +++ b/src/detail.php @@ -42,7 +42,7 @@ $getAction = @$_GET["action"]; $getUid = @intval($_GET["uid"]); $postSubmit = @$_POST["submit"]; -isset($getUid) or die(); +isset($getUid) or die(); // Check if the specified report exists if(!is_object($doc->getErrorReportByID($getUid))) { @@ -54,7 +54,8 @@ if(!is_object($doc->getErrorReportByID($getUid))) { // Only admins or owners can view this page if(!($cfgErrors->userIsAdmin() or $doc->userIsOwner($getUid))) { - echo sprintf("

%s", _c("error-reporter:You are not allowed to edit this report.")); + echo sprintf("

%s", _c("error-reporter:You are not ". + "allowed to edit this report.")); _PageBlue(); die(); } @@ -71,12 +72,12 @@ if($getAction == "update" and $postSubmit == _c("Change")) $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); + // 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? + // 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"]); @@ -84,41 +85,47 @@ if($getAction == "update" and $postSubmit == _c("Change")) } // write into database, reload parent and close window - if($doc->writeErrorReport($er) != -1) { + if($doc->writeErrorReport($er) != -1) { js_try("opener.location.href = 'index.php';"); js_close(500); - } else { - printLastError(); - _PageBlue(); - die(); - } + } else { + printLastError(); + _PageBlue(); + die(); + } } // output form $hidctrl = "input type='hidden'"; Title(_c("error-reporter:Change an error report")); -echo sprintf("

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

\n"; _PageBlue(); ?> diff --git a/src/index.php b/src/index.php index bf275d5..a2a5ece 100644 --- a/src/index.php +++ b/src/index.php @@ -58,9 +58,10 @@ if(!$cfgErrors->userHasAccess()) { // Probably we have to delete an error report if($getAction == "delete" and isset($getUid)) { // Are you really sure? - if(@$_POST["surely_delete"] == _("Delete")) { + if(@$_POST["surely_delete"] == _("Delete")) { $doc->deleteErrorReport($getUid); - header("Location: {$_SERVER["PHP_SELF"]}"); // Reload to get rid of POST data + // Reload to get rid of POST data + header("Location: {$_SERVER["PHP_SELF"]}"); } elseif(@$_POST["surely_cancel"] == _("Cancel")) { header("Location: {$_SERVER["PHP_SELF"]}"); } else { @@ -73,13 +74,15 @@ if($getAction == "delete" and isset($getUid)) { Option(_("Back"), null, "href='".$_SERVER["PHP_SELF"]."'", "back"); } else { if($cfgErrors->userIsAdmin() or $doc->userIsOwner($getUid)) { - echo sprintf("

\n", $view->getDeleteURL($getUid)); - echo sprintf("

%s

", - _c("error-reporter:You are about to delete the following error report:")); + echo sprintf("\n", + $view->getDeleteURL($getUid)); + echo sprintf("

%s

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

\n". - " \n". - "

", _("Delete"), _("Cancel")); + echo sprintf("

\n \n

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

%s

", _c("error-reporter:You are not allowed to delete this report.")); @@ -98,63 +101,71 @@ echo sprintf("
\n", $_SERVER["PHP_SELF"]); 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) { + if((trim($postMachine) == "") or (trim($postText) == "")) { + $strError = _c("error-reporter:You have to fill out all the fields in ". + "the form."); + } else { + // Write to database + $nNewUid = null; + $er = new erErrorReport(time(), $_SESSION["act"], $postMachine, $postText, $postHidden == "true"); + try { + $nNewUid = $doc->writeErrorReport($er); + } catch(Exception $e) { echo sprintf("

%s

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

%s

", - _c("error-reporter:The report was submitted. Thank you for your help.")); - } - - $postText = ""; - $postMachine = ""; - $postHidden = "false"; - } + } + + if($nNewUid !== null) { + echo sprintf("

%s

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

%s

", _c("error-reporter:These errors should not be resubmitted.")); - $view->printErrorReports($doc->getErrorReports(array(ER_ERM_SORT_DATE => ER_ERM_SORT_DESC))); + echo sprintf("

%s

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

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

$strError

\n"; + echo "

$strError

\n"; -echo sprintf("

%s

\n", _c("error-reporter:Please write your report as precise as possible to help ". - "us solve the problem. The more precise the report is, the faster the error can be fixed. ". - "Please include also any error messages you have recieved.")); -echo "
\n<{$GLOBALS["invtbl"]}>\n"; +echo sprintf("

%s

\n", _c("error-reporter:Please write your report as ". + "precise as possible to help us solve the problem. The more precise the ". + "report is, the faster the error can be fixed. Please include also any ". + "error messages you have recieved.")); +echo "\n". + "<{$GLOBALS["invtbl"]}>\n"; echo sprintf("
%s
%s". "
". - "
". + "d>

\n"; _PageBlue(); -- 2.20.1