Use objectManager to add and edit notes
This commit is contained in:
committed by
Chris Morgan
parent
a6a62a2299
commit
72a250b2b0
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
/************************/
|
||||
/* Add Application Note */
|
||||
/************************/
|
||||
|
||||
require("path.php");
|
||||
require(BASE."include/incl.php");
|
||||
require_once(BASE."include/note.php");
|
||||
|
||||
//FIXME: get rid of appId references everywhere, as version is enough.
|
||||
$sQuery = "SELECT appId FROM appVersion WHERE versionId = '?'";
|
||||
$hResult = query_parameters($sQuery, $aClean['iVersionId']);
|
||||
$oRow = query_fetch_object($hResult);
|
||||
$appId = $oRow->appId;
|
||||
|
||||
//check for admin privs
|
||||
if(!$_SESSION['current']->hasPriv("admin") &&
|
||||
!$_SESSION['current']->isMaintainer($aClean['iVersionId']) &&
|
||||
!$_SESSION['current']->isSuperMaintainer($aClean['iAppId']))
|
||||
{
|
||||
util_show_error_page_and_exit("Insufficient Privileges!");
|
||||
}
|
||||
|
||||
//set link for version
|
||||
if(is_numeric($aClean['iVersionId']) and !empty($aClean['iVersionId']))
|
||||
{
|
||||
$oVersion = new version($aClean['iVersionId']);
|
||||
$sVersionLink = $oVersion->objectMakeUrl();
|
||||
}
|
||||
else
|
||||
exit;
|
||||
|
||||
$oNote = new Note();
|
||||
$oNote->GetOutputEditorValues($aClean);
|
||||
|
||||
if($aClean['sSub'] == "Submit")
|
||||
{
|
||||
$oNote->create();
|
||||
util_redirect_and_exit($sVersionLink);
|
||||
}
|
||||
else if($aClean['sSub'] == 'Preview' OR empty($aClean['sSubmit']))
|
||||
{
|
||||
// show form
|
||||
apidb_header("Application Note");
|
||||
|
||||
if($aClean['sSub'] == 'Preview')
|
||||
$oNote->show(true);
|
||||
|
||||
echo "<form method=post action='addAppNote.php'>\n";
|
||||
|
||||
$oNote->outputEditor();
|
||||
|
||||
echo '<center>';
|
||||
echo '<input type="submit" name="sSub" value="Preview"> ',"\n";
|
||||
echo '<input type="submit" name="sSub" value="Submit"></td></tr>',"\n";
|
||||
echo '</center>';
|
||||
|
||||
echo html_back_link(1,$sVersionLink);
|
||||
apidb_footer();
|
||||
}
|
||||
?>
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
/****************/
|
||||
/* Edit AppNote */
|
||||
/****************/
|
||||
|
||||
require("path.php");
|
||||
require(BASE."include/incl.php");
|
||||
require_once(BASE."include/note.php");
|
||||
|
||||
if(!is_numeric($aClean['iNoteId']))
|
||||
util_show_error_page_and_exit('Wrong note ID');
|
||||
|
||||
/* Get note data */
|
||||
$oNote = new Note($aClean['iNoteId']);
|
||||
$oVersion = new version($oNote->iVersionId);
|
||||
|
||||
/* Check for privs */
|
||||
if(!$oNote->canEdit())
|
||||
util_show_error_page_and_exit("Insufficient Privileges!");
|
||||
|
||||
if(!empty($aClean['sSub']))
|
||||
{
|
||||
$oNote->GetOutputEditorValues($aClean); /* retrieve the updated values */
|
||||
|
||||
if ($aClean['sSub'] == 'Delete')
|
||||
{
|
||||
$oNote->delete();
|
||||
}
|
||||
else if ($aClean['sSub'] == 'Update')
|
||||
{
|
||||
$oNote->update();
|
||||
}
|
||||
util_redirect_and_exit($oVersion->objectMakeUrl());
|
||||
} else /* display note */
|
||||
{
|
||||
// show form
|
||||
apidb_header("Application Note");
|
||||
|
||||
/* if preview is set display the note for review */
|
||||
if($aClean['sPreview'])
|
||||
{
|
||||
$oNote->GetOutputEditorValues($aClean); /* retrieve the updated values */
|
||||
$oNote->display(true);
|
||||
}
|
||||
|
||||
echo "<form method=post action='editAppNote.php'>\n";
|
||||
|
||||
/* display the editor for this note */
|
||||
$oNote->outputEditor();
|
||||
|
||||
echo '<center>';
|
||||
echo '<input type="submit" name=sPreview value="Preview"> ',"\n";
|
||||
echo '<input type="submit" name=sSub value="Update"> ',"\n";
|
||||
echo '<input type="submit" name=sSub value="Delete"></td></tr>',"\n";
|
||||
echo '</center>';
|
||||
|
||||
echo html_back_link(1,$oVersion->objectMakeUrl());
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
?>
|
||||
@@ -206,6 +206,8 @@ class Note {
|
||||
$sColor = 'blue';
|
||||
}
|
||||
|
||||
$oVersion = new version($this->iVersionId);
|
||||
|
||||
$shOutput = html_frame_start("","98%",'',0);
|
||||
|
||||
$shOutput .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\">\n";
|
||||
@@ -219,7 +221,7 @@ class Note {
|
||||
if ($this->canEdit())
|
||||
{
|
||||
$shOutput .= "<tr class=\"color1\" align=\"center\" valign=\"top\"><td>";
|
||||
$shOutput .= "<form method=\"post\" name=\"message\" action=\"admin/editAppNote.php?iNoteId={$this->iNoteId}\">";
|
||||
$shOutput .= "<form method=\"post\" name=\"message\" action=\"objectManager.php?sClass=note&sAction=edit&iId=".$this->iNoteId."&sReturnTo=".urlencode($oVersion->objectMakeUrl())."\">";
|
||||
$shOutput .= '<input type="submit" value="Edit Note" class="button">';
|
||||
$shOutput .= '</form></td></tr>';
|
||||
}
|
||||
@@ -231,9 +233,29 @@ class Note {
|
||||
echo $shOutput;
|
||||
}
|
||||
|
||||
|
||||
function outputEditor()
|
||||
function objectGetCustomVars($sAction)
|
||||
{
|
||||
switch($sAction)
|
||||
{
|
||||
case "add":
|
||||
return array("iVersionId","sNoteTitle");
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function outputEditor($aValues = null)
|
||||
{
|
||||
if($aValues)
|
||||
{
|
||||
if(!$this->iVersionId)
|
||||
$this->iVersionId = $aValues['iVersionId'];
|
||||
|
||||
if(!$this->sTitle)
|
||||
$this->sTitle = $aValues['sNoteTitle'];
|
||||
}
|
||||
|
||||
HtmlAreaLoaderScript(array("editor"));
|
||||
|
||||
echo html_frame_start("Edit Application Note {$aClean['noteId']}", "90%","",0);
|
||||
|
||||
@@ -241,13 +241,7 @@ class ObjectManager
|
||||
echo '<form name="sQform" action="'.$this->makeUrl("edit", $this->iId).
|
||||
'" method="post" enctype="multipart/form-data">',"\n";
|
||||
|
||||
echo '<input type="hidden" name="sClass" value="'.$this->sClass.'" />';
|
||||
echo '<input type="hidden" name="sTitle" value="'.$this->sTitle.'" />';
|
||||
echo '<input type="hidden" name="iId" value="'.$this->iId.'" />';
|
||||
echo '<input type="hidden" name="bIsQueue" '.
|
||||
'value='.($this->bIsQueue ? "true" : "false").' />';
|
||||
echo '<input type="hidden" name="bIsRejected" '.
|
||||
'value='.($this->bIsRejected ? "true" : "false").' />';
|
||||
echo $this->makeUrlFormData();
|
||||
|
||||
$oObject->outputEditor();
|
||||
|
||||
@@ -317,6 +311,7 @@ class ObjectManager
|
||||
echo '<tr valign=top><td class=color3 align=center colspan=2>',"\n";
|
||||
echo '<input name="sSubmit" type="submit" value="Submit" class="button">'.
|
||||
' ',"\n";
|
||||
echo '<input name="sSubmit" type="submit" value="Delete" class="button" />'."\n";
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
|
||||
@@ -638,7 +633,7 @@ class ObjectManager
|
||||
}
|
||||
|
||||
/* Display screen for submitting a new entry of given type */
|
||||
function add_entry($sBackLink, $sErrors = "")
|
||||
function add_entry($aClean, $sErrors = "")
|
||||
{
|
||||
$this->checkMethods(array("outputEditor", "getOutputEditorValues",
|
||||
"update", "create"));
|
||||
@@ -661,6 +656,11 @@ class ObjectManager
|
||||
|
||||
echo "<form method=\"post\">\n";
|
||||
|
||||
$aVars = $this->get_custom_vars($aClean, "add");
|
||||
|
||||
if($aVars)
|
||||
$oObject->outputEditor($aVars);
|
||||
else
|
||||
$oObject->outputEditor();
|
||||
|
||||
echo "<input type=\"hidden\" name=\"sClass=\"distribution\" />\n";
|
||||
|
||||
@@ -901,6 +901,7 @@ class version {
|
||||
|
||||
if ($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isMaintainer($this->iVersionId) || $_SESSION['current']->isSuperMaintainer($this->iAppId))
|
||||
{
|
||||
$shAdd = '<form method="post" name="sMessage" action="objectManager.php?sClass=note&sAction=add&iVersionId='.$this->iVersionId.'&sReturnTo='.urlencode($this->objectMakeUrl());
|
||||
echo '<tr><td colspan="2" align="center">'."\n";
|
||||
echo '<form method="post" name="sMessage" action="admin/editAppVersion.php">'."\n";
|
||||
echo "\t".'<input type="hidden" name="iAppId" value="'.$oApp->iAppId.'" />'."\n";
|
||||
@@ -911,16 +912,13 @@ class version {
|
||||
echo "<form method=\"post\" name=\"sDelete\" action=\"javascript:self.location = '".$url."'\">\n";
|
||||
echo "\t".'<input type=submit value="Delete Version" class="button" />'."\n";
|
||||
echo '</form>'."\n";
|
||||
echo '<form method="post" name="message" action="admin/addAppNote.php">'."\n";
|
||||
echo "\t".'<input type="hidden" name="iVersionId" value="'.$this->iVersionId.'" />'."\n";
|
||||
echo $shAdd.'" />';
|
||||
echo "\t".'<input type="submit" value="Add Note" class="button" />'."\n";
|
||||
echo '</form>'."\n";
|
||||
echo '<form method=post name=message action=admin/addAppNote.php?iVersionId='.$this->iVersionId.'>'."\n";
|
||||
echo "\t".'<input type=hidden name="sNoteTitle" value="HOWTO" />'."\n";
|
||||
echo $shAdd.'&sNoteTitle=HOWTO" />';
|
||||
echo "\t".'<input type=submit value="Add How To" class="button" />'."\n";
|
||||
echo '</form>'."\n";
|
||||
echo '<form method=post name=message action=admin/addAppNote.php?iVersionId='.$this->iVersionId.'>'."\n";
|
||||
echo "\t".'<input type=hidden name="sNoteTitle" value="WARNING" />'."\n";
|
||||
echo $shAdd.'&sNoteTitle=WARNING" />';
|
||||
echo "\t".'<input type=submit value="Add Warning" class="button" />'."\n";
|
||||
echo '</form>';
|
||||
echo "</td></tr>";
|
||||
|
||||
@@ -91,7 +91,7 @@ if(!$sAction)
|
||||
apidb_header($oObject->get_title($sAction));
|
||||
|
||||
/* display a particular element */
|
||||
if($oObject->iId)
|
||||
if($oObject->iId && $sAction != "add")
|
||||
{
|
||||
switch($sAction)
|
||||
{
|
||||
@@ -117,7 +117,7 @@ if($oObject->iId)
|
||||
}
|
||||
} else if ($sAction == "add")
|
||||
{
|
||||
$oObject->add_entry($_SERVER['REQUEST_URI'], $sErrors);
|
||||
$oObject->add_entry($aClean, $sErrors);
|
||||
} else
|
||||
{
|
||||
// if displaying a queue display the help for the given queue
|
||||
|
||||
Reference in New Issue
Block a user