Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
NewNoteForm.inc.php
1 <?php
2 
17 import('lib.pkp.classes.form.Form');
18 
19 class NewNoteForm extends Form {
23  function NewNoteForm() {
24  parent::Form('controllers/informationCenter/notes.tpl');
25 
26  $this->addCheck(new FormValidatorPost($this));
27  }
28 
33  function getAssocType() {
34  assert(false);
35  }
36 
41  function getAssocId() {
42  assert(false);
43  }
44 
51  assert(false);
52  }
53 
60  return 'controllers/informationCenter/newNoteForm.tpl';
61  }
62 
66  function fetch($request) {
67  $templateMgr = TemplateManager::getManager($request);
68 
69  $noteDao = DAORegistry::getDAO('NoteDAO');
70  $notes = $noteDao->getByAssoc($this->getAssocType(), $this->getAssocId());
71  $templateMgr->assign('notes', $notes);
72  $templateMgr->assign('submitNoteText', $this->getSubmitNoteLocaleKey());
73  $templateMgr->assign('newNoteFormTemplate', $this->getNewNoteFormTemplate());
74 
75  return parent::fetch($request);
76  }
77 
81  function readInputData() {
82  $this->readUserVars(array(
83  'newNote'
84  ));
85 
86  }
87 
91  function execute($request) {
92  $user = $request->getUser();
93 
94  $noteDao = DAORegistry::getDAO('NoteDAO');
95  $note = $noteDao->newDataObject();
96 
97  $note->setUserId($user->getId());
98  $note->setContents($this->getData('newNote'));
99  $note->setAssocType($this->getAssocType());
100  $note->setAssocId($this->getAssocId());
101 
102  return $noteDao->insertObject($note);
103  }
104 }
105 
106 ?>
static & getDAO($name, $dbconn=null)
addCheck($formValidator)
Definition: Form.inc.php:396
Form validation check to make sure the form is POSTed.
readUserVars($vars)
Definition: Form.inc.php:364
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
getData($key)
Definition: Form.inc.php:210
Form to display and post notes on a file.
execute($request)
fetch($request)