00001 <?php
00002
00016 import('lib.pkp.classes.form.Form');
00017
00018 class NewNoteForm extends Form {
00022 function NewNoteForm() {
00023 parent::Form('controllers/informationCenter/notes.tpl');
00024
00025 $this->addCheck(new FormValidatorPost($this));
00026 }
00027
00032 function getAssocType() {
00033 assert(false);
00034 }
00035
00040 function getAssocId() {
00041 assert(false);
00042 }
00043
00049 function getSubmitNoteLocaleKey() {
00050 assert(false);
00051 }
00052
00058 function getNewNoteFormTemplate() {
00059 return 'controllers/informationCenter/newNoteForm.tpl';
00060 }
00061
00066 function fetch(&$request) {
00067 $templateMgr =& TemplateManager::getManager();
00068
00069 $noteDao =& DAORegistry::getDAO('NoteDAO');
00070 $notes =& $noteDao->getByAssoc($this->getAssocType(), $this->getAssocId());
00071 $templateMgr->assign_by_ref('notes', $notes);
00072 $templateMgr->assign('submitNoteText', $this->getSubmitNoteLocaleKey());
00073 $templateMgr->assign('newNoteFormTemplate', $this->getNewNoteFormTemplate());
00074
00075 return parent::fetch($request);
00076 }
00077
00082 function readInputData() {
00083 $this->readUserVars(array(
00084 'newNote'
00085 ));
00086
00087 }
00088
00094 function execute(&$request) {
00095 $user =& $request->getUser();
00096
00097 $noteDao =& DAORegistry::getDAO('NoteDAO');
00098 $note = $noteDao->newDataObject();
00099
00100 $note->setUserId($user->getId());
00101 $note->setContents($this->getData('newNote'));
00102 $note->setAssocType($this->getAssocType());
00103 $note->setAssocId($this->getAssocId());
00104
00105 return $noteDao->insertObject($note);
00106 }
00107 }
00108
00109 ?>