Open Journal Systems  3.3.0
NewNoteForm.inc.php
1 <?php
2 
17 import('lib.pkp.classes.form.Form');
18 
19 class NewNoteForm extends Form {
23  function __construct() {
24  parent::__construct('controllers/informationCenter/notes.tpl');
25 
26  $this->addCheck(new FormValidatorPost($this));
27  $this->addCheck(new FormValidatorCSRF($this));
28  }
29 
34  function getAssocType() {
35  assert(false);
36  }
37 
42  function getAssocId() {
43  assert(false);
44  }
45 
52  assert(false);
53  }
54 
61  return 'controllers/informationCenter/newNoteForm.tpl';
62  }
63 
67  function fetch($request, $template = null, $display = false) {
68  $templateMgr = TemplateManager::getManager($request);
69  $noteDao = DAORegistry::getDAO('NoteDAO'); /* @var $noteDao NoteDAO */
70  $templateMgr->assign(array(
71  'notes' => $noteDao->getByAssoc($this->getAssocType(), $this->getAssocId()),
72  'submitNoteText' => $this->getSubmitNoteLocaleKey(),
73  'newNoteFormTemplate' => $this->getNewNoteFormTemplate(),
74  ));
75  return parent::fetch($request, $template, $display);
76  }
77 
81  function readInputData() {
82  $this->readUserVars(array(
83  'newNote'
84  ));
85 
86  }
87 
91  function execute(...$functionArgs) {
92  $request = Application::get()->getRequest();
93  $user = $request->getUser();
94 
95  $noteDao = DAORegistry::getDAO('NoteDAO'); /* @var $noteDao NoteDAO */
96  $note = $noteDao->newDataObject();
97 
98  $note->setUserId($user->getId());
99  $note->setContents($this->getData('newNote'));
100  $note->setAssocType($this->getAssocType());
101  $note->setAssocId($this->getAssocId());
102 
103  parent::execute(...$functionArgs);
104  return $noteDao->insertObject($note);
105  }
106 }
107 
108 
NewNoteForm\__construct
__construct()
Definition: NewNoteForm.inc.php:23
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
Form\readUserVars
readUserVars($vars)
Definition: Form.inc.php:378
NewNoteForm\getSubmitNoteLocaleKey
getSubmitNoteLocaleKey()
Definition: NewNoteForm.inc.php:51
Form\getData
getData($key)
Definition: Form.inc.php:220
NewNoteForm\getAssocId
getAssocId()
Definition: NewNoteForm.inc.php:42
FormValidatorPost
Form validation check to make sure the form is POSTed.
Definition: FormValidatorPost.inc.php:18
NewNoteForm
Form to display and post notes on a file.
Definition: NewNoteForm.inc.php:19
NewNoteForm\fetch
fetch($request, $template=null, $display=false)
Definition: NewNoteForm.inc.php:67
NewNoteForm\getNewNoteFormTemplate
getNewNoteFormTemplate()
Definition: NewNoteForm.inc.php:60
NewNoteForm\execute
execute(... $functionArgs)
Definition: NewNoteForm.inc.php:91
PKPTemplateManager\getManager
static & getManager($request=null)
Definition: PKPTemplateManager.inc.php:1239
NewNoteForm\readInputData
readInputData()
Definition: NewNoteForm.inc.php:81
Form\addCheck
addCheck($formValidator)
Definition: Form.inc.php:395
FormValidatorCSRF
Form validation check to make sure the CSRF token is correct.
Definition: FormValidatorCSRF.inc.php:18
Form
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
PKPApplication\get
static get()
Definition: PKPApplication.inc.php:235
NewNoteForm\getAssocType
getAssocType()
Definition: NewNoteForm.inc.php:34