uid GET parameter, which
* contains the unique ID of the error report to be edited.
*/
protected $strEditURL;
/**
* (string) URL to the page which allows deletion of an error report.
* The specified page must handle the uid GET parameter, which
* contains the unique ID of the error report to be deleted.
*/
protected $strDeleteURL;
/**
* Constructor
* @param $objemm (erErrorReportManager) Pointer to a instance of the
* erErrorReportManager class for retrieving the document data
* @return erErrorReportView
*/
public function __construct(erErrorReportManager &$objemm) {
$this->objManager = $objemm;
html_header("");
}
/**
* Print a single error report.
* Call this function to print a table or a compound of table rows with the
* information of the specified error report. The function determines if the
* current user is the owner of the specified report or if he has admin
* rights and in this case displays buttons for deletion and editing the
* error report.
* @param $objem (erErrorReport) Error report to print
* @param $bSingle (bool) Determines if you call this function once
* (true) or several times to get a compound table of reports
* (false).
* @param $bAdminButtons (bool) 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;
if($bSingle) {
bgcol("cb");
echo "<{$GLOBALS["invtbl"]} class='errors-view-table'>";
}
$nColor = bgcol_rgb();
$sColor = sprintf("rgb(%d,%d,%d)", ($nColor >> 16) % 256,
($nColor >> 8) % 256, $nColor % 256);
echo "
";
if(erConfig::userIsAdmin() or
$this->objManager->userIsOwner($objem->getUid())) {
// user is admin or owner
echo "<{$GLOBALS["invtbl"]} width='100%'>\n";
$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 |
\n",
sprintf(_c("error-reporter:Comment by %s:"),
erMailToUserLink($objem->getCommentOwner())),
q($objem->getComment()));
}
echo "\n";
// admin buttons
if($bAdminButtons) {
echo sprintf("%s | ".
"%s | ",
$this->getEditLink($objem->getUid()),
$this->getDeleteLink($objem->getUid()));
}
echo "\n";
} else {
// user can only read the report
echo "<{$GLOBALS["invtbl"]} width='100%'>\n";
$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 |
\n",
sprintf(_c("error-reporter:Comment by %s:"),
erMailToUserLink($objem->getCommentOwner())),
q($objem->getComment()));
}
echo " | | \n";
}
if($bSingle) {
echo "\n";
_bgcol();
}
}
/**
* Print a table of error reports.
* Prints a table with several error reports by calling printErrorReport()
* for each report.
* @param $arobjem (array of errorReport objects) The reports to print
*/
public public function printErrorReports($arobjem) {
echo "<{$GLOBALS["invtbl"]} class='errors-view-table'>";
bgcol("cb");
if(is_array($arobjem)) {
foreach($arobjem as $em) {
$this->printErrorReport($em);
if(_bgcol() == "bl") {
bgcol("cb");
} else {
bgcol("bl");
}
}
}
_bgcol();
echo "\n";
}
/**
* Set the link to the edit page.
* The specified page must handle the uid GET parameter, which
* contains the unique ID of the error report to be edited.
* @see getEditURL()
* @see getEditLink()
* @param $strUrl (string)
*/
public function setEditURL($strUrl) { $this->strEditURL = $strUrl; }
/**
* Get the link to the edit page.
* @param $nUid (int) Unique ID of the error report to be edited
* @see setEditURL()
* @see getEditLink()
* @return (string)
*/
public function getEditURL($nUid) {
if(preg_match("/\?/", $this->strEditURL) == 0) {
$strParam = "?uid=".intval($nUid);
} else {
$strParam = "&uid=".intval($nUid);
}
return q($this->strEditURL.$strParam);
}
/**
* Create a link to the edit page
* @param $nUid (int) Unique ID of the error report to be edited
* @see setEditURL()
* @see getEditURL()
* @return string
*/
public function getEditLink($nUid) {
return sprintf("%s", pop($this->getEditURL($nUid),
500, 500), _c("error-reporter:Edit this error report"), icon("write"));
}
/**
* Set the link to the delete page.
* The specified page must handle the uid GET parameter, which
* contains the unique ID of the error report to be deleted.
* @see getDeleteURL()
* @see getDeleteLink()
* @param $strUrl (string)
*/
public function setDeleteURL($strUrl) { $this->strDeleteURL = $strUrl; }
/**
* Get the link to the delete page.
* @param $nUid (int) Unique ID of the error report to be deleted
* @see setDeleteURL()
* @see getDeleteLink()
* @return (string)
*/
public function getDeleteURL($nUid) {
if(preg_match("/\?/", $this->strDeleteURL) == 0) {
$strParam = "?uid=".intval($nUid);
} else {
$strParam = "&uid=".intval($nUid);
}
return q($this->strDeleteURL.$strParam);
}
/**
* Create a link to the delete page
* @param $nUid (int) Unique ID of the error report to be deleted
* @see setDeleteURL()
* @see getDeleteURL()
* @return string
*/
public function getDeleteLink($nUid) {
return sprintf("%s", $this->getDeleteURL($nUid),
_c("error-reporter:Delete this error report"), icon("trash"));
}
}
?>