'.html_radiobuttons($aIds, $aOptions, 'iVersionId', $this->iVersionId);
/* Allow the note to be shown for certain versions only */
$aIds = array();
$aOptions = array();
$aSelected = array();
foreach($oApp->getVersions(true) as $oAppVersion) // Only accepted versions
{
$aIds[] = $oAppVersion->objectGetId();
$aOptions[] = $oAppVersion->objectMakeLink();
$aSelected[] = $this->isLinkedWith($oAppVersion->objectGetId(), false);
}
echo html_checkboxes('iVersionId', $aIds, $aOptions, $aSelected);
echo '
';
} else if(!$this->iAppId)
{
echo '';
}
echo '
',"\n";
echo html_table_end();
echo html_frame_end();
}
/* retrieves values from $aValue that were output by outputEditor() */
/* $aValues can be $_REQUEST or any array with the values from outputEditor() */
function GetOutputEditorValues($aValues)
{
$this->iVersionId = getInput('iVersionId', $aValues);
if(!$this->isRealVersionId($this->iVersionId))
$this->iAppId = getInput('iAppId', $aValues);
else
$this->iAppId = 0;
if($this->iVersionId == APPNOTE_SHOW_FOR_SPECIFIC_VERSIONS)
{
$this->aNoteLinks = $this->getNoteLinksFromInput($aValues);
if(sizeof($this->aNoteLinks) == 1)
{
$oLink = $this->aNoteLinks[0];
$this->iVersionId = $oLink->objectGetParent('version');
$this->iAppId = 0;
}
}
$this->sTitle = $aValues['sNoteTitle'];
$this->shDescription = $aValues['shNoteDesc'];
}
function allowAnonymousSubmissions()
{
return false;
}
// NOTE: notes cannot be queued at this point
function mustBeQueued()
{
return false;
}
function objectGetId()
{
return $this->iNoteId;
}
// TODO: we ignore $bQueued and $bRejected as notes
// do not support queuing at this point
// TODO: we have no permissions scope on retrieving entries
// as notes are typically only added to unqueued versions
function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = '', $bAscending = true)
{
$sQuery = "select * from appNotes";
$hResult = query_parameters($sQuery);
return $hResult;
}
function objectGetEntriesCount($sState)
{
$sQuery = "SELECT COUNT(DISTINCT noteId) as count FROM appNotes";
$hResult = query_parameters($sQuery);
if(!$hResult)
return false;
if(($oRow = mysql_fetch_object($hResult)))
return $oRow->count;
return false;
}
//TODO: not sure how to best let users view a table of notes
// since the note contents could be very long we would only
// want to show a small amount of the text. Implement this
// routine when we need it
function objectGetHeader()
{
return null;
}
//TODO: implement this when we implement objectGetHeader()
function objectGetTableRow()
{
return null;
}
function objectMakeUrl()
{
$oManager = new objectManager("note", "View Note");
return $oManager->makeUrl("view", $this->objectGetId());
}
function objectGetSubmitterId()
{
return $this->iSubmitterId;
}
function objectGetMailOptions($sAction, $bMailSubmitter, $bParentAction)
{
return new mailOptions();
}
function objectGetMail($sAction, $bMailSubmitter, $bParentAction)
{
/* We don't do this at the moment */
return array(null, null, null);
}
public function objectGetParent($sClass = '')
{
if($this->hasRealVersionId())
return new version($this->iVersionId);
else
return new application($this->iAppId);
}
public function objectSetParent($iNewId, $sClass = '')
{
if($this->hasRealVersionId())
$this->iVersionId = $iNewId;
else
$this->iAppId = $iNewId;
}
function objectGetChildren($bIncludeDeleted = false)
{
$aRet = array();
if(!$this->iAppId)
return $aRet;
$hResult = query_parameters("SELECT * FROM appNotes WHERE linkedWith = '?'", $this->iNoteId);
if(!$hResult)
return $aRet;
while($oRow = mysql_fetch_object($hResult))
$aRet[] = new noteLink(null, $oRow);
return $aRet;
}
//TODO: not sure if we want to use sTitle here or what
function objectMakeLink()
{
$sLink = "objectMakeUrl()."\">".
$this->sTitle."";
return $sLink;
}
function objectGetState()
{
return 'accepted'; // We don't queue notes
}
// users can edit the note if they:
// - have "admin" privileges
// - maintain the version, or supermaintain the application that
// this version is under
function canEdit()
{
if($_SESSION['current']->hasPriv("admin"))
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;
}
}
class noteLink
{
private $iLinkId;
private $iNoteId;
private $iVersionId;
function noteLink($iLinkId = null, $oRow = null)
{
$this->iLinkId = $iLinkId;
if(!$oRow && $this->iLinkId)
{
$hResult = query_parameters("SELECT * FROM appNotes WHERE noteId = '?'", $this->iLinkId);
if(!$hResult)
return;
$oRow = mysql_fetch_object($hResult);
}
if($oRow)
{
$this->iLinkId = $oRow->noteId;
$this->iNoteId = $oRow->linkedWith;
$this->iVersionId = $oRow->versionId;
}
}
public function create()
{
$hResult = query_parameters("INSERT INTO appNotes (linkedWith,versionId) VALUES('?','?')", $this->iNoteId, $this->iVersionId);
if(!$hResult)
return false;
return true;
}
public function isDuplicate()
{
$oNote = new note($this->iNoteId);
return $oNote->isLinkedWith($this->iVersionId);
}
public function update()
{
// Query the DB so we have something to compare against
$oLink = new noteLink($this->iLinkId);
if($this->objectGetParent('version') != $oLink->objectGetParent('version') && !$this->isDuplicate())
{
$hResult = query_parameters("UPDATE appNotes SET versionId = '?' WHERE noteId = '?'", $this->iVersionId, $this->iNoteId);
if(!$hResult)
return false;
}
return true;
}
public function delete()
{
$hResult = query_parameters("DELETE FROM appNotes WHERE noteId = '?'", $this->iLinkId);
if(!$hResult)
return false;
return true;
}
public function objectSetParent($iNewId, $sClass = '')
{
if(!$sClass || $sClass == 'note')
$this->iNoteId = $iNewId;
else if($sClass == 'version')
$this->iVersionId = $iNewId;
}
public function objectGetParent($sClass = '')
{
if(!$sClass || $sClass == 'note')
return $this->iNoteId;
if($sClass == 'version')
return $this->iVersionId;
}
function display($aValues = null)
{
$oNote = new note($this->iNoteId);
$oNote->display($aValues);
}
}
?>