16 import(
'lib.pkp.controllers.grid.settings.SetupGridHandler');
17 import(
'controllers.grid.settings.sections.SectionGridRow');
24 parent::__construct();
26 array(ROLE_ID_MANAGER),
27 array(
'fetchGrid',
'fetchRow',
'addSection',
'editSection',
'updateSection',
'deleteSection',
'saveSequence',
'deactivateSection',
'activateSection')
39 parent::initialize($request, $args);
40 $journal = $request->getJournal();
44 LOCALE_COMPONENT_APP_MANAGER,
45 LOCALE_COMPONENT_PKP_COMMON,
46 LOCALE_COMPONENT_PKP_USER,
47 LOCALE_COMPONENT_APP_COMMON
56 $sectionIterator = $sectionDao->getByJournalId($journal->getId());
59 while ($section = $sectionIterator->next()) {
61 $assignedSubEditors = $subEditorsDao->getBySubmissionGroupId($section->getId(), ASSOC_TYPE_SECTION, $journal->getId());
62 if(empty($assignedSubEditors)) {
63 $editorsString = __(
'common.none');
66 foreach ($assignedSubEditors as $subEditor) {
67 $editors[] = $subEditor->getFullName();
69 $editorsString = implode(
', ', $editors);
72 $sectionId = $section->getId();
73 $gridData[$sectionId] = array(
74 'title' => $section->getLocalizedTitle(),
75 'editors' => $editorsString,
76 'inactive' => $section->getIsInactive(),
77 'seq' => $section->getSequence()
80 uasort($gridData,
function($a,$b) {
81 return $a[
'seq']-$b[
'seq'];
87 $router = $request->getRouter();
88 import(
'lib.pkp.classes.linkAction.request.AjaxModal');
93 $router->url($request,
null,
null,
'addSection',
null, array(
'gridId' => $this->
getId())),
94 __(
'manager.sections.create'),
97 __(
'manager.sections.create'),
105 import(
'controllers.grid.settings.sections.SectionGridCellProvider');
123 'controllers/grid/common/cell/selectStatusCell.tpl',
124 $sectionGridCellProvider,
125 array(
'alignment' => COLUMN_ALIGNMENT_CENTER,
138 import(
'lib.pkp.classes.controllers.grid.feature.OrderGridItemsFeature');
162 $journal = $request->getJournal();
163 $section = $sectionDao->getById($rowId, $journal->getId());
164 $section->setSequence($newSequence);
165 $sectionDao->updateObject($section);
190 $sectionId = isset($args[
'sectionId']) ? $args[
'sectionId'] :
null;
193 import(
'controllers.grid.settings.sections.form.SectionForm');
194 $sectionForm =
new SectionForm($request, $sectionId);
195 $sectionForm->initData();
196 return new JSONMessage(
true, $sectionForm->fetch($request));
206 $sectionId = $request->getUserVar(
'sectionId');
208 import(
'controllers.grid.settings.sections.form.SectionForm');
209 $sectionForm =
new SectionForm($request, $sectionId);
210 $sectionForm->readInputData();
212 if ($sectionForm->validate()) {
213 $sectionForm->execute();
215 $notificationManager->createTrivialNotification($request->getUser()->getId());
228 $journal = $request->getJournal();
231 $section = $sectionDao->getById(
232 $request->getUserVar(
'sectionId'),
236 if (!$request->checkCSRF()) {
237 return new JSONMessage(
false, __(
'form.csrfInvalid'));
241 return new JSONMessage(
false, __(
'manager.setup.errorDeletingItem'));
246 $checkSubmissions = $submissionDao->retrieve(
'SELECT p.publication_id FROM publications p JOIN submissions s ON (s.submission_id = p.submission_id) WHERE p.section_id = ? AND s.context_id = ?', array((
int) $request->getUserVar(
'sectionId'), (
int) $journal->getId()));
248 if ($checkSubmissions->numRows() > 0) {
249 return new JSONMessage(
false, __(
'manager.sections.alertDelete'));
253 $sectionsIterator = $sectionDao->getByContextId($journal->getId(),
null,
false);
254 $activeSectionsCount = (!$section->getIsInactive()) ? -1 : 0;
255 while ($checkSection = $sectionsIterator->next()) {
256 if (!$checkSection->getIsInactive()) {
257 $activeSectionsCount++;
261 if ($activeSectionsCount < 1) {
262 return new JSONMessage(
false, __(
'manager.sections.confirmDeactivateSection.error'));
266 if ($checkSubmissions->numRows() > 0) {
267 return new JSONMessage(
false, __(
'manager.sections.alertDelete'));
270 $sectionDao->deleteObject($section);
283 $sectionId = (int) $request->getUserVar(
'sectionKey');
286 $context = $request->getContext();
291 $sectionsIterator = $sectionDao->getByContextId($context->getId(),
null,
false);
292 $activeSectionsCount = 0;
293 while ($section = $sectionsIterator->next()) {
294 if (!$section->getIsInactive()) {
295 $activeSectionsCount++;
298 if ($activeSectionsCount > 1) {
299 $section = $sectionDao->getById($sectionId, $context->getId());
301 if ($request->checkCSRF() && isset($section) && !$section->getIsInactive()) {
302 $section->setIsInactive(1);
303 $sectionDao->updateObject($section);
307 $user = $request->getUser();
308 $notificationMgr->createTrivialNotification($user->getId());
315 $user = $request->getUser();
316 $notificationMgr->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array(
'contents' => __(
'manager.sections.confirmDeactivateSection.error')));
332 $sectionId = (int) $request->getUserVar(
'sectionKey');
335 $context = $request->getContext();
339 $section = $sectionDao->getById($sectionId, $context->getId());
341 if ($request->checkCSRF() && isset($section) && $section->getIsInactive()) {
342 $section->setIsInactive(0);
343 $sectionDao->updateObject($section);
347 $user = $request->getUser();
348 $notificationMgr->createTrivialNotification($user->getId());