From 72a250b2b062e49eb1e5d5bfff22f11f71db53df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Wed, 19 Sep 2007 20:12:37 +0200 Subject: [PATCH] Use objectManager to add and edit notes --- admin/addAppNote.php | 61 --------------------------------------- admin/editAppNote.php | 61 --------------------------------------- include/note.php | 32 ++++++++++++++++---- include/objectManager.php | 18 ++++++------ include/version.php | 10 +++---- objectManager.php | 4 +-- 6 files changed, 42 insertions(+), 144 deletions(-) delete mode 100644 admin/addAppNote.php delete mode 100644 admin/editAppNote.php diff --git a/admin/addAppNote.php b/admin/addAppNote.php deleted file mode 100644 index ae1f96c..0000000 --- a/admin/addAppNote.php +++ /dev/null @@ -1,61 +0,0 @@ -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 "
\n"; - - $oNote->outputEditor(); - - echo '
'; - echo ' ',"\n"; - echo '',"\n"; - echo '
'; - - echo html_back_link(1,$sVersionLink); - apidb_footer(); -} -?> diff --git a/admin/editAppNote.php b/admin/editAppNote.php deleted file mode 100644 index e643ad8..0000000 --- a/admin/editAppNote.php +++ /dev/null @@ -1,61 +0,0 @@ -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 "\n"; - - /* display the editor for this note */ - $oNote->outputEditor(); - - echo '
'; - echo ' ',"\n"; - echo ' ',"\n"; - echo '',"\n"; - echo '
'; - - echo html_back_link(1,$oVersion->objectMakeUrl()); -} - -apidb_footer(); -?> diff --git a/include/note.php b/include/note.php index c8d7246..3cf1157 100644 --- a/include/note.php +++ b/include/note.php @@ -205,7 +205,9 @@ class Note { $sColor = 'blue'; } - + + $oVersion = new version($this->iVersionId); + $shOutput = html_frame_start("","98%",'',0); $shOutput .= "\n"; @@ -219,7 +221,7 @@ class Note { if ($this->canEdit()) { $shOutput .= "'; } @@ -231,11 +233,31 @@ 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); echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'"); diff --git a/include/objectManager.php b/include/objectManager.php index 7473998..c52d36a 100644 --- a/include/objectManager.php +++ b/include/objectManager.php @@ -241,13 +241,7 @@ class ObjectManager echo 'iId). '" method="post" enctype="multipart/form-data">',"\n"; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo $this->makeUrlFormData(); $oObject->outputEditor(); @@ -317,6 +311,7 @@ class ObjectManager echo '\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,7 +656,12 @@ class ObjectManager echo "\n"; - $oObject->outputEditor(); + $aVars = $this->get_custom_vars($aClean, "add"); + + if($aVars) + $oObject->outputEditor($aVars); + else + $oObject->outputEditor(); echo "\n"; echo "sTitle\" />\n"; diff --git a/include/version.php b/include/version.php index 85c723b..6d74736 100644 --- a/include/version.php +++ b/include/version.php @@ -901,6 +901,7 @@ class version { if ($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isMaintainer($this->iVersionId) || $_SESSION['current']->isSuperMaintainer($this->iAppId)) { + $shAdd = ''."\n"; echo ''."\n"; echo "\t".''."\n"; @@ -911,16 +912,13 @@ class version { echo "\n"; echo "\t".''."\n"; echo ''."\n"; - echo ''."\n"; - echo "\t".''."\n"; + echo $shAdd.'" />'; echo "\t".''."\n"; echo ''."\n"; - echo 'iVersionId.'>'."\n"; - echo "\t".''."\n"; + echo $shAdd.'&sNoteTitle=HOWTO" />'; echo "\t".''."\n"; echo ''."\n"; - echo 'iVersionId.'>'."\n"; - echo "\t".''."\n"; + echo $shAdd.'&sNoteTitle=WARNING" />'; echo "\t".''."\n"; echo ''; echo ""; diff --git a/objectManager.php b/objectManager.php index e880a68..983726e 100644 --- a/objectManager.php +++ b/objectManager.php @@ -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
"; - $shOutput .= "iNoteId}\">"; + $shOutput .= "iNoteId."&sReturnTo=".urlencode($oVersion->objectMakeUrl())."\">"; $shOutput .= ''; $shOutput .= '
',"\n"; echo ''. ' ',"\n"; + echo ''."\n"; echo "