trivial fix for PHP >= 5.3, thanks to Martin von Wittich
[iserv-mod-error-reporter.git] / inc / class_erErrorReportView.inc
index 914393d..3a1b568 100644 (file)
@@ -35,59 +35,55 @@ 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 */
+  /** (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.
+   * 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.
+   * 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
+   * @param $objemm (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;
+  public function __construct(erErrorReportManager &$objemm) {
     $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;
-       }
+      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.
+   * 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.
+   * @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) 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 +92,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 "<tr style='background-color:$sColor'>";
-    if($this->objcfg->userIsAdmin() or $this->objManager->userIsOwner($objem->getUid())) {
+    if(erConfig::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"));
+      $sRow = "<tr><td class='errors-view-description'>%s</td><td>%s</td></tr>";
+      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("<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())),
+        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";
@@ -122,20 +122,23 @@ class erErrorReportView {
       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()));
+          $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());
+      $sRow = "<tr><td class='errors-view-description'>%s</td><td>%s</td></tr>";
+      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("<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())),
+        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";
@@ -148,10 +151,11 @@ 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) {
+  public function printErrorReports($arobjem) {
     echo "<{$GLOBALS["invtbl"]} class='errors-view-table'>";
     bgcol("cb");
     if(is_array($arobjem)) {
@@ -170,8 +174,8 @@ class erErrorReportView {
   
   /**
    * 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.
+   * 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)
@@ -202,14 +206,14 @@ class erErrorReportView {
    * @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"));
+    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.
+   * 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)
@@ -244,4 +248,4 @@ class erErrorReportView {
       _c("error-reporter:Delete this error report"), icon("trash"));
   }
 }
-?>
\ No newline at end of file
+?>
This page took 0.026448 seconds and 4 git commands to generate.