diff --git a/application/views/scripts/admin/terms.phtml b/application/views/scripts/admin/terms.phtml deleted file mode 100755 index e423d1a3..00000000 --- a/application/views/scripts/admin/terms.phtml +++ /dev/null @@ -1,69 +0,0 @@ -
Please Note: Any changes made here will take effect during the next synchronization with Banner
- -Term Code | -Description | -Sections | -Manual Override | -Active? | -
---|---|---|---|---|
".$term['STVTERM_CODE']." | "; - print "\n\t\t".$term['STVTERM_DESC']." | "; - print "\n\t\t".$numSections." | "; - - print "\n\t\t"; - print "\n\t\t\t"; - print "\n\t\t | "; - - print "\n\t\t"; - if ($active) { - print "Yes"; - } else { - print "No: "; - if ($manuallyDisabled) - print "Manually disabled. "; - if (!$numSections) - print "Zero sections. "; - } - print "\n\t\t | "; - - print "\n\t
".$query.""; - if ($this->_getParam('catalog') && in_array($this->_getParam('catalog'), $this->view->catalogs)) { - $catalog = $this->_getParam('catalog'); + if ($request->get('catalog') && in_array($request->get('catalog'), $data['catalogs'])) { + $catalog = $request->get('catalog'); } else { - $catalog = $this->view->catalogs[0]; + $catalog = $data['catalogs'][0]; + } + $stmt->bindValue(1, $catalog); + $stmt->bindValue(2, $catalog); + $stmt->bindValue(3, $catalog); + $result = $stmt->executeQuery(); + $data['selectedCatalog'] = $catalog; + $data['terms'] = $result->fetchAll(); + foreach ($data['terms'] as &$term) { + $term['active'] = intval($term['num_sections']) && !intval($term['manually_disabled']); + } + + return $this->render('admin/terms.html.twig', $data); + } + + /** + * Manage term visibility. + */ + #[Route('/admin/terms', name: 'admin_terms_update', methods: ['POST'])] + public function termUpdateAction(Request $request) + { + $db = $this->entityManager->getConnection(); + + if ($request->get('change_visibility')) { + // Verify our CSRF key + if (!$this->isCsrfTokenValid('admin-terms-update', $request->get('csrf_key'))) { + throw new AccessDeniedException('Invalid CSRF key.'); + } + + // Verify that this is a valid term. + $catalog = $request->get('catalog'); + $term = $request->get('term'); + $verifyStmt = $db->prepare('SELECT COUNT(*) FROM STVTERM WHERE STVTERM_CODE = ?'); + $verifyStmt->bindValue(1, $term); + $result = $verifyStmt->executeQuery(); + $valid = (int) $result->fetchOne(); + $result->free(); + if (!$valid) { + throw new \InvalidArgumentException('Invalid term-code: '.$term); + } + + // Disable the term + if ('true' == $request->get('disabled')) { + $visibilityStmt = $db->prepare('INSERT INTO catalog_term_inactive (catalog_id, term_code) VALUES (?, ?);'); + } + // Enable the term + else { + $visibilityStmt = $db->prepare('DELETE FROM catalog_term_inactive WHERE catalog_id = ? AND term_code = ?;'); + } + $visibilityStmt->bindValue(1, $catalog); + $visibilityStmt->bindValue(2, $term); + $visibilityStmt->executeQuery(); } - $stmt->execute([$catalog, $catalog, $catalog]); - $this->view->catalog = $catalog; - $this->view->terms = $stmt->fetchAll(); + return $this->redirect($this->generateUrl('admin_terms_list', ['catalog' => $catalog])); } #[Route('/admin/markup', name: 'markup')] @@ -142,7 +174,7 @@ public function masqueradeAction() } /** - * Manage archive export configurations + * Manage archive export configurations. */ #[Route('/admin/export', name: 'admin_archive_config')] public function exportAction() diff --git a/templates/admin/terms.html.twig b/templates/admin/terms.html.twig new file mode 100755 index 00000000..d46f119b --- /dev/null +++ b/templates/admin/terms.html.twig @@ -0,0 +1,63 @@ +{% extends 'base.html.twig' %} + +{% block body %} +
Please Note: Any changes made here will take effect during the next synchronization with Banner
+ +Term Code | +Description | +Sections | +Manual Override | +Active? | +
---|---|---|---|---|
{{ term.STVTERM_CODE }} | +{{ term.STVTERM_DESC }} | +{{ term.num_sections }} | + ++ + | + ++{% if term.active %} + Yes +{% else %} + No: + {{ term.manually_disabled ? 'Manually disabled. ' }} + {{ term.num_sections is empty ? 'Zero sections. ' }} +{% endif %} + | +