diff --git a/include/application.php b/include/application.php
index c5ef52b..ed62f46 100644
--- a/include/application.php
+++ b/include/application.php
@@ -835,6 +835,9 @@ class Application {
if($_SESSION['current']->isSuperMaintainer($this->iAppId) || $_SESSION['current']->hasPriv("admin"))
{
echo '
';
+ echo '';
}
if($_SESSION['current']->isLoggedIn())
{
@@ -877,6 +880,8 @@ class Application {
// display bundle
$this->displayBundle();
+
+ note::displayNotesForEntry(null, $this->iAppId);
}
public static function lookup_name($appId)
diff --git a/include/html.php b/include/html.php
index ac6cfa0..4cb60dc 100644
--- a/include/html.php
+++ b/include/html.php
@@ -288,4 +288,21 @@ function html_note($shTitle, $shBody)
return $shRet;
}
+function html_radiobuttons($aIds, $aOptions, $sName, $sDefault = '')
+{
+ $shRet = '';
+
+ for($i = 0; $i < sizeof($aIds); $i++)
+ {
+ if($aIds[$i] == $sDefault)
+ $shChecked = ' checked="checked"';
+ else
+ $shChecked = '';
+
+ $shRet .= ' " . $aOptions[$i].'
';
+ }
+
+ return $shRet;
+}
+
?>
diff --git a/include/note.php b/include/note.php
index 1558d66..1d8f06d 100644
--- a/include/note.php
+++ b/include/note.php
@@ -7,12 +7,17 @@ require_once(BASE."include/version.php");
/************************************/
+define('APPNOTE_SHOW_FOR_ALL', -1);
+define('APPNOTE_SHOW_FOR_VERSIONS', -2);
+define('APPNOTE_SHOW_FOR_APP', -3);
+
/**
* Note class for handling notes
*/
class Note {
var $iNoteId;
var $iVersionId;
+ var $iAppId;
var $sTitle;
var $shDescription;
var $iSubmitterId;
@@ -38,6 +43,7 @@ class Note {
{
$this->iNoteId = $oRow->noteId;
$this->iVersionId = $oRow->versionId;
+ $this->iAppId = $oRow->appId;
$this->sTitle = $oRow->noteTitle;
$this->shDescription = $oRow->noteDesc;
$this->sSubmitTime = $oRow->submitTime;
@@ -54,11 +60,11 @@ class Note {
function create()
{
$hResult = query_parameters("INSERT INTO appNotes (versionId, ".
- "noteTitle, noteDesc, submitterId, ".
+ "appId, noteTitle, noteDesc, submitterId, ".
"submitTime) ".
- "VALUES('?', '?', '?', '?', ?)",
- $this->iVersionId, $this->sTitle,
- $this->shDescription,
+ "VALUES('?', '?', '?', '?', '?', ?)",
+ $this->iVersionId, $this->iAppId,
+ $this->sTitle, $this->shDescription,
$_SESSION['current']->iUserId,
"NOW()");
@@ -152,9 +158,18 @@ class Note {
function SendNotificationMail($sAction="add",$sMsg=null)
{
- $oVersion = new version($this->iVersionId);
- $sAppName = version::fullName($this->iVersionId);
- $sMsg .= $oVersion->objectMakeUrl()."\n";
+ if(!$this->iAppId)
+ {
+ $oVersion = new version($this->iVersionId);
+ $sAppName = version::fullName($this->iVersionId);
+ $sMsg .= $oVersion->objectMakeUrl()."\n";
+ } else
+ {
+ $oApp = new application($this->iAppId);
+ $sAppName = $oApp->sName;
+ $sMsg .= $oApp->objectMakeUrl()."\n";
+ }
+
switch($sAction)
{
case "add":
@@ -219,7 +234,14 @@ class Note {
$sClass = 'defaultnote';
}
- $oVersion = new version($this->iVersionId);
+ if(!$aVars || !getInput('shReturnTo', $aVars))
+ {
+ $oVersion = new version($this->iVersionId);
+ $shReturnTo = $oVersion->objectMakeUrl();
+ } else
+ {
+ $shReturnTo = $aVars['shReturnTo'];
+ }
$shOutput = html_frame_start("","98%",'',0);
@@ -232,7 +254,7 @@ class Note {
if((!$aVars || $aVars['bEditing'] != "true") && $this->canEdit())
{
$shOutput .= "| ";
- $shOutput .= " |
';
}
@@ -243,6 +265,37 @@ class Note {
echo $shOutput;
}
+ function displayNotesForEntry($iVersionId, $iAppId = null)
+ {
+ if($iVersionId)
+ {
+ $oVersion = new version($iVersionId);
+ $oApp = $oVersion->objectGetParent();
+ $hResult = query_parameters("SELECT noteId FROM appNotes WHERE versionId = '?' OR (appId = '?' AND (versionId = '?' OR versionId = '?'))", $iVersionId, $oApp->objectGetId(), APPNOTE_SHOW_FOR_ALL, APPNOTE_SHOW_FOR_VERSIONS);
+ } else if($iAppId)
+ {
+ $hResult = query_parameters("SELECT noteId FROM appNotes WHERE appId = '?' AND versionId = '?' OR versionId = '?'", $iAppId, APPNOTE_SHOW_FOR_ALL, APPNOTE_SHOW_FOR_APP);
+ }
+
+ if(!$hResult)
+ return;
+
+ if($iVersionId)
+ $oVersion = new version($iVersionId);
+ else
+ $oApp = new application($iAppId);
+
+ while($oRow = mysql_fetch_object($hResult))
+ {
+ $oNote = new note($oRow->noteId);
+
+ $shReturnTo = $iVersionId ? $oVersion->objectMakeUrl() : $oApp->objectMakeUrl();
+
+ $aVars = array('shReturnTo' => $shReturnTo, 'bEditing' => 'false');
+ $oNote->display($aVars);
+ }
+ }
+
function objectGetCustomVars($sAction)
{
switch($sAction)
@@ -251,7 +304,7 @@ class Note {
return array("bEditing");
case "add":
- return array("iVersionId","sNoteTitle");
+ return array('iVersionId','iAppId','sNoteTitle');
default:
return null;
@@ -265,6 +318,12 @@ class Note {
if(!$this->iVersionId)
$this->iVersionId = $aValues['iVersionId'];
+ if(!$this->iAppId)
+ $this->iAppId = getInput('iAppId', $aValues);
+
+ if($this->iAppId && !$this->iVersionId)
+ $this->iVersionId = APPNOTE_SHOW_FOR_ALL;
+
if(!$this->sTitle)
$this->sTitle = $aValues['sNoteTitle'];
}
@@ -276,7 +335,9 @@ class Note {
echo '';
echo '';
- echo '';
+ if(!$this->iAppId)
+ echo '';
+ echo '';
echo '| Title | '."\n";
echo ' |
',"\n";
@@ -285,6 +346,14 @@ class Note {
echo '',"\n";
echo '';
echo ''."\n";
+ if($this->iAppId)
+ {
+ $aIds = array(APPNOTE_SHOW_FOR_ALL, APPNOTE_SHOW_FOR_VERSIONS, APPNOTE_SHOW_FOR_APP);
+ $aOptions = array('Show on both application and version pages', 'Show on version pages only', 'Show on application page only');
+ echo '| Display mode | '."\n";
+ echo ''.html_radiobuttons($aIds, $aOptions, 'iVersionId', $this->iVersionId);
+ echo ' |
';
+ }
echo '| ',"\n";
echo html_table_end();
@@ -295,7 +364,8 @@ class Note {
/* $aValues can be $_REQUEST or any array with the values from outputEditor() */
function GetOutputEditorValues($aValues)
{
- $this->iVersionId = $aValues['iVersionId'];
+ $this->iVersionId = getInput('iVersionId', $aValues);
+ $this->iAppId = getInput('iAppId', $aValues);
$this->sTitle = $aValues['sNoteTitle'];
$this->shDescription = $aValues['shNoteDesc'];
}
@@ -403,16 +473,11 @@ class Note {
function canEdit()
{
if($_SESSION['current']->hasPriv("admin"))
- {
- return true;
- } else if($this->iVersionId)
- {
- if(maintainer::isUserMaintainer($_SESSION['current'],
- $this->iVersionId))
- {
return true;
- }
- }
+ else if($this->iVersionId && !$this->iAppId)
+ return maintainer::isUserMaintainer($_SESSION['current'], $this->iVersionId);
+ else if($this->iAppId)
+ return maintainer::isUserSuperMaintainer($_SESSION['current'], $this->iAppId);
return false;
}
diff --git a/include/version.php b/include/version.php
index b1bceae..180283d 100644
--- a/include/version.php
+++ b/include/version.php
@@ -1171,15 +1171,7 @@ class version {
view_version_bugs($this->iVersionId, $this->get_buglink_ids());
- /* display the notes for the application */
- $hNotes = query_parameters("SELECT noteId FROM appNotes WHERE versionId = '?'",
- $this->iVersionId);
-
- while( $oRow = query_fetch_object($hNotes) )
- {
- $oNote = new Note($oRow->noteId);
- $oNote->display();
- }
+ echo note::displayNotesForEntry($this->iVersionId);
// Comments Section
if($this->iVersionId)
diff --git a/runonce b/runonce
new file mode 100755
index 0000000..56a6051
--- /dev/null
+++ b/runonce
@@ -0,0 +1 @@
+1
\ No newline at end of file
diff --git a/runonce.php b/runonce.php
new file mode 100644
index 0000000..c509366
--- /dev/null
+++ b/runonce.php
@@ -0,0 +1,28 @@
+
\ No newline at end of file
diff --git a/tables/appdb_tables.sql b/tables/appdb_tables.sql
index f481355..c6a12ad 100644
--- a/tables/appdb_tables.sql
+++ b/tables/appdb_tables.sql
@@ -167,6 +167,7 @@ create table appNotes (
noteTitle varchar(255),
noteDesc text,
versionId int not null,
+ appId int not null,
submitterId int not null,
submitTime datetime not null,
key(noteId)
|