17 import(
'lib.pkp.classes.controllers.grid.GridHandler');
21 import(
'controllers.grid.catalogEntry.IdentificationCodeGridCellProvider');
22 import(
'controllers.grid.catalogEntry.IdentificationCodeGridRow');
25 import(
'lib.pkp.classes.linkAction.request.AjaxModal');
41 parent::__construct();
43 array(ROLE_ID_MANAGER),
44 array(
'fetchGrid',
'fetchRow',
'addCode',
'editCode',
45 'updateCode',
'deleteCode'));
65 $this->_submission = $submission;
81 $this->_publication = $publication;
97 $this->_publicationFormat = $publicationFormat;
109 function authorize($request, &$args, $roleAssignments) {
110 import(
'lib.pkp.classes.security.authorization.PublicationAccessPolicy');
112 return parent::authorize($request, $args, $roleAssignments);
119 parent::initialize($request, $args);
125 $representationId =
null;
128 $identificationCodeId = (int) $request->getUserVar(
'identificationCodeId');
130 if ($identificationCodeId !=
'') {
132 $identificationCode = $identificationCodeDao->getById($identificationCodeId, $this->
getPublication()->
getId());
133 if ($identificationCode) {
134 $representationId = $identificationCode->getPublicationFormatId();
137 $representationId = (int) $request->getUserVar(
'representationId');
140 $publicationFormat = $publicationFormatDao->getById($representationId, $this->
getPublication()->getId());
142 if ($publicationFormat) {
145 fatalError(
'The publication format is not assigned to authorized submission!');
150 LOCALE_COMPONENT_APP_SUBMISSION,
151 LOCALE_COMPONENT_PKP_SUBMISSION,
152 LOCALE_COMPONENT_PKP_USER,
153 LOCALE_COMPONENT_APP_DEFAULT,
154 LOCALE_COMPONENT_PKP_DEFAULT
158 $this->
setTitle(
'submission.publicationFormat.productIdentifierType');
161 $router = $request->getRouter();
167 $router->url($request,
null,
null,
'addCode',
null, $actionArgs),
168 __(
'grid.action.addCode'),
171 __(
'grid.action.addCode'),
181 'grid.catalogEntry.identificationCodeValue',
185 array(
'width' => 50,
'alignment' => COLUMN_ALIGNMENT_LEFT)
191 'grid.catalogEntry.identificationCodeType',
227 function loadData($request, $filter =
null) {
230 $data = $identificationCodeDao->getByPublicationFormatId($publicationFormat->getId());
231 return $data->toArray();
244 function addCode($args, $request) {
245 return $this->
editCode($args, $request);
254 function editCode($args, $request) {
256 $identificationCodeId = (int) $request->getUserVar(
'identificationCodeId');
260 $identificationCode = $identificationCodeDao->getById($identificationCodeId, $this->
getPublication()->
getId());
263 import(
'controllers.grid.catalogEntry.form.IdentificationCodeForm');
265 $identificationCodeForm->initData();
267 return new JSONMessage(
true, $identificationCodeForm->fetch($request));
278 $identificationCodeId = $request->getUserVar(
'identificationCodeId');
282 $identificationCode = $identificationCodeDao->getById($identificationCodeId, $this->
getPublication()->
getId());
285 import(
'controllers.grid.catalogEntry.form.IdentificationCodeForm');
287 $identificationCodeForm->readInputData();
288 if ($identificationCodeForm->validate()) {
289 $identificationCodeId = $identificationCodeForm->execute();
291 if(!isset($identificationCode)) {
293 $identificationCode = $identificationCodeDao->getById($identificationCodeId, $this->
getPublication()->
getId());
295 $notificationContent = __(
'notification.addedIdentificationCode');
298 $notificationContent = __(
'notification.editedIdentificationCode');
302 $currentUser = $request->getUser();
304 $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array(
'contents' => $notificationContent));
308 $row->setGridId($this->
getId());
309 $row->setId($identificationCodeId);
310 $row->setData($identificationCode);
311 $row->initialize($request);
317 return new JSONMessage(
true, $identificationCodeForm->fetch($request));
330 $identificationCodeId = $request->getUserVar(
'identificationCodeId');
333 $identificationCode = $identificationCodeDao->getById($identificationCodeId, $this->
getPublication()->
getId());
334 if ($identificationCode !=
null) {
336 $result = $identificationCodeDao->deleteObject($identificationCode);
339 $currentUser = $request->getUser();
341 $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array(
'contents' => __(
'notification.removedIdentificationCode')));
344 return new JSONMessage(
false, __(
'manager.setup.errorDeletingItem'));