Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
SubmissionMetadataViewForm.inc.php
1 <?php
2 
16 import('lib.pkp.controllers.modals.submissionMetadata.form.PKPSubmissionMetadataViewForm');
17 
19 
26  function SubmissionMetadataViewForm($submissionId, $stageId = null, $formParams = null, $templateName = 'controllers/modals/submissionMetadata/form/submissionMetadataViewForm.tpl') {
27  parent::PKPSubmissionMetadataViewForm($submissionId, $stageId, $formParams, $templateName);
28  }
29 
35  function fetch($request) {
36  $submission = $this->getSubmission();
37  $templateMgr = TemplateManager::getManager($request);
38  $templateMgr->assign('isEditedVolume', $submission->getWorkType() == WORK_TYPE_EDITED_VOLUME);
39 
40  // Get series for this press
41  $seriesDao = DAORegistry::getDAO('SeriesDAO');
42  $seriesOptions = array('0' => __('submission.submit.selectSeries')) + $seriesDao->getTitlesByPressId($submission->getContextId());
43  $templateMgr->assign('seriesOptions', $seriesOptions);
44  $templateMgr->assign('seriesId', $submission->getSeriesId());
45  $templateMgr->assign('seriesPosition', $submission->getSeriesPosition());
46 
47  // If categories are configured for the press, present the LB.
48  $categoryDao = DAORegistry::getDAO('CategoryDAO');
49  $templateMgr->assign('categoriesExist', $categoryDao->getCountByPressId($submission->getContextId()) > 0);
50 
51  // also include the categories (for read only form views)
52  $submissionDao = Application::getSubmissionDAO();
53  $assignedCategories = $submissionDao->getCategories($submission->getId(), $submission->getContextId());
54  $templateMgr->assign('assignedCategories', $assignedCategories->toArray());
55 
56  return parent::fetch($request);
57  }
58 
62  function readInputData() {
63  parent::readInputData();
64  $this->readUserVars(array('categories', 'seriesId', 'seriesPosition'));
65  $application = PKPApplication::getApplication();
66  $request = $application->getRequest();
67  ListbuilderHandler::unpack($request, $this->getData('categories'));
68  }
69 
74  function execute($request) {
75  parent::execute($request);
76  $submission = $this->getSubmission();
77  $submissionDao = Application::getSubmissionDAO();
78 
79  // Clean any new release or feature object that may
80  // exist associated with the current submission series.
81  $newReleaseDao = DAORegistry::getDAO('NewReleaseDAO'); /* @var $newReleaseDao NewReleaseDAO */
82  $newReleaseDao->deleteNewRelease($submission->getId(), ASSOC_TYPE_SERIES, $submission->getSeriesId());
83 
84  $featureDao = DAORegistry::getDAO('FeatureDAO'); /* @var $featureDao FeatureDAO */
85  $featureDao->deleteFeature($submission->getId(), ASSOC_TYPE_SERIES, $submission->getSeriesId());
86 
87  $submission->setSeriesId($this->getData('seriesId'));
88  $submission->setSeriesPosition($this->getData('seriesPosition'));
89  $submissionDao->updateObject($submission);
90 
91  if ($submission->getDatePublished()) {
92  import('classes.search.MonographSearchIndex');
94  }
95  }
96 
101  function insertEntry($request, $newRowId) {
102 
103  $application = PKPApplication::getApplication();
104  $request = $application->getRequest();
105 
106  $categoryId = $newRowId['name'];
107  $categoryDao = DAORegistry::getDAO('CategoryDAO');
108  $submissionDao = Application::getSubmissionDAO();
109  $context = $request->getContext();
110  $submission = $this->getSubmission();
111 
112  $category = $categoryDao->getById($categoryId, $context->getId());
113  if (!$category) return true;
114 
115  // Associate the category with the submission
116  $submissionDao->addCategory(
117  $submission->getId(),
118  $categoryId
119  );
120  }
121 
126  function deleteEntry($request, $rowId) {
127  if ($rowId) {
128  $categoryDao = DAORegistry::getDAO('CategoryDAO');
129  $submissionDao = Application::getSubmissionDAO();
130  $category = $categoryDao->getById($rowId);
131  if (!is_a($category, 'Category')) {
132  assert(false);
133  return false;
134  }
135  $submission = $this->getSubmission();
136  $submissionDao->removeCategory($submission->getId(), $rowId);
137  }
138 
139  return true;
140  }
141 
146  function updateEntry($request, $rowId, $newRowId) {
147 
148  $this->deleteEntry($request, $rowId);
149  $this->insertEntry($request, $newRowId);
150  }
151 }
152 
153 ?>
static & getDAO($name, $dbconn=null)
readUserVars($vars)
Definition: Form.inc.php:364
getData($key)
Definition: Form.inc.php:210
SubmissionMetadataViewForm($submissionId, $stageId=null, $formParams=null, $templateName= 'controllers/modals/submissionMetadata/form/submissionMetadataViewForm.tpl')
static getSubmissionDAO()
Displays a submission&#39;s metadata view.
updateEntry($request, $rowId, $newRowId)
unpack($request, $data, $deletionCallback=null, $insertionCallback=null, $updateCallback=null)
Displays a submission&#39;s metadata view.