Cleanup note class, move display of notes into the class. External code creates and calls Note::show() to display the note.
This commit is contained in:
49
appview.php
49
appview.php
@@ -82,55 +82,6 @@ function display_bundle($iAppId)
|
||||
echo html_frame_end();
|
||||
}
|
||||
|
||||
/* Show note */
|
||||
function show_note($sType,$oData)
|
||||
{
|
||||
global $oVersion;
|
||||
|
||||
switch($sType)
|
||||
{
|
||||
case 'WARNING':
|
||||
$color = 'red';
|
||||
$title = 'Warning';
|
||||
break;
|
||||
|
||||
case 'HOWTO';
|
||||
$color = 'green';
|
||||
$title = 'HOWTO';
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
if(!empty($oData->noteTitle))
|
||||
$title = $oData->noteTitle;
|
||||
else
|
||||
$title = 'Note';
|
||||
|
||||
$color = 'blue';
|
||||
}
|
||||
|
||||
$s = html_frame_start("","98%",'',0);
|
||||
|
||||
$s .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n";
|
||||
$s .= "<tr bgcolor=\"".$color."\" align=\"center\" valign=\"top\"><td><b>".$title."</b></td></tr>\n";
|
||||
$s .= "<tr><td class=\"note\">\n";
|
||||
$s .= $oData->noteDesc;
|
||||
$s .= "</td></tr>\n";
|
||||
|
||||
if ($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isMaintainer($oVersion->iVersionId) || $_SESSION['current']->isSuperMaintainer($oVersion->iAppId))
|
||||
{
|
||||
$s .= "<tr class=\"color1\" align=\"center\" valign=\"top\"><td>";
|
||||
$s .= "<form method=\"post\" name=\"message\" action=\"admin/editAppNote.php?noteId={$oData->noteId}\">";
|
||||
$s .= '<input type="submit" value="Edit Note" class="button">';
|
||||
$s .= '</form></td></tr>';
|
||||
}
|
||||
|
||||
$s .= "</table>\n";
|
||||
$s .= html_frame_end();
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
if(!is_numeric($aClean['appId']) && !is_numeric($aClean['versionId']))
|
||||
{
|
||||
util_show_error_page("Something went wrong with the application or version id");
|
||||
|
||||
@@ -158,5 +158,53 @@ class Note {
|
||||
if($sEmail)
|
||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||
}
|
||||
|
||||
/* Show note */
|
||||
function show()
|
||||
{
|
||||
switch($this->sTitle)
|
||||
{
|
||||
case 'WARNING':
|
||||
$sColor = 'red';
|
||||
$sTitle = 'Warning';
|
||||
break;
|
||||
|
||||
case 'HOWTO':
|
||||
$sColor = 'green';
|
||||
$sTitle = 'HOWTO';
|
||||
break;
|
||||
|
||||
default:
|
||||
if(!empty($this->sTitle))
|
||||
$sTitle = $this->sTitle;
|
||||
else
|
||||
$sTitle = 'Note';
|
||||
|
||||
$sColor = 'blue';
|
||||
}
|
||||
|
||||
$shOutput = html_frame_start("","98%",'',0);
|
||||
|
||||
$shOutput .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n";
|
||||
$shOutput .= "<tr bgcolor=\"".$sColor."\" align=\"center\" valign=\"top\"><td><b>".$sTitle."</b></td></tr>\n";
|
||||
$shOutput .= "<tr><td class=\"note\">\n";
|
||||
$shOutput .= $this->sDescription;
|
||||
$shOutput .= "</td></tr>\n";
|
||||
|
||||
if ($_SESSION['current']->hasPriv("admin") ||
|
||||
$_SESSION['current']->isMaintainer($this->iVersionId) ||
|
||||
$_SESSION['current']->isSuperMaintainer($this->iAppId))
|
||||
{
|
||||
$shOutput .= "<tr class=\"color1\" align=\"center\" valign=\"top\"><td>";
|
||||
$shOutput .= "<form method=\"post\" name=\"message\" action=\"admin/editAppNote.php?noteId={$this->iNoteId}\">";
|
||||
$shOutput .= '<input type="submit" value="Edit Note" class="button">';
|
||||
$shOutput .= '</form></td></tr>';
|
||||
}
|
||||
|
||||
$shOutput .= "</table>\n";
|
||||
$shOutput .= html_frame_end();
|
||||
|
||||
echo $shOutput;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -827,12 +827,14 @@ class Version {
|
||||
|
||||
view_version_bugs($this->iVersionId, $this->aBuglinkIds);
|
||||
|
||||
$rNotes = query_parameters("SELECT * FROM appNotes WHERE versionId = '?'",
|
||||
/* display the notes for the application */
|
||||
$hNotes = query_parameters("SELECT noteId FROM appNotes WHERE versionId = '?'",
|
||||
$this->iVersionId);
|
||||
|
||||
while( $oNote = mysql_fetch_object($rNotes) )
|
||||
while( $oRow = mysql_fetch_object($hNotes) )
|
||||
{
|
||||
echo show_note($oNote->noteTitle,$oNote);
|
||||
$oNote = new Note($oRow->noteId);
|
||||
$oNote->show();
|
||||
}
|
||||
|
||||
// Comments Section
|
||||
|
||||
Reference in New Issue
Block a user