Skip to content

Commit

Permalink
Merge pull request pkp#4897 from asmecher/i4864-fix-3_1_2
Browse files Browse the repository at this point in the history
pkp#4864 Add categories selection during submission process
  • Loading branch information
asmecher authored Jul 9, 2019
2 parents 8cdc0dc + 9ab706a commit 3076586
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions classes/submission/form/PKPSubmissionSubmitStep3Form.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,39 @@ function fetch($request, $template = null, $display = false) {
));
}

// Get assigned categories
// We need an array of IDs for the SelectListPanel, but we also need an
// array of Category objects to use when the metadata form is viewed in
// readOnly mode. This mode is invoked on the SubmissionMetadataHandler
// is not available here
$submissionDao = Application::getSubmissionDAO();
$submission = $submissionDao->getById($this->submissionId);
$categories = $submissionDao->getCategories($submission->getId(), $submission->getContextId());
$assignedCategories = array();
$selectedIds = array();
while ($category = $categories->next()) {
$assignedCategories[] = $category;
$selectedIds[] = $category->getId();
}

// Get SelectCategoryListHandler data
import('lib.pkp.controllers.list.SelectCategoryListHandler');
$selectCategoryList = new SelectCategoryListHandler(array(
'title' => 'submission.submit.placement.categories',
'inputName' => 'categories[]',
'selected' => $selectedIds,
'getParams' => array(
'contextId' => $submission->getContextId(),
),
));

$selectCategoryListData = $selectCategoryList->getConfig();

$templateMgr->assign(array(
'hasCategories' => !empty($selectCategoryListData['items']),
'selectCategoryListData' => json_encode($selectCategoryListData),
'assignedCategories' => $assignedCategories,
));
return parent::fetch($request, $template, $display);
}

Expand Down

0 comments on commit 3076586

Please sign in to comment.