/** * Process the "edit list" submission. * * @param \VuFind\Db\Row\User $user Logged in user * @param \VuFind\Db\Row\UserList $list List being created/edited * * @return object|bool Response object if redirect is * needed, false if form needs to be redisplayed. */ protected function processEditList($user, $list) { // Process form within a try..catch so we can handle errors appropriately: try { $finalId = $list->updateFromRequest($user, $this->getRequest()->getPost()); // If the user is in the process of saving a record, send them back // to the save screen; otherwise, send them back to the list they // just edited. $recordId = $this->params()->fromQuery('recordId'); $recordSource = $this->params()->fromQuery('recordSource', 'VuFind'); if (!empty($recordId)) { $details = $this->getRecordRouter()->getActionRouteDetails($recordSource . '|' . $recordId, 'Save'); return $this->lightboxAwareRedirect($details['route'], $details['params']); } // Similarly, if the user is in the process of bulk-saving records, // send them back to the appropriate place in the cart. $bulkIds = $this->params()->fromPost('ids', $this->params()->fromQuery('ids', [])); if (!empty($bulkIds)) { $params = []; foreach ($bulkIds as $id) { $params[] = urlencode('ids[]') . '=' . urlencode($id); } $saveUrl = $this->getLightboxAwareUrl('cart-save'); $saveUrl .= strpos($saveUrl, '?') === false ? '?' : '&'; return $this->redirect()->toUrl($saveUrl . implode('&', $params)); } return $this->lightboxAwareRedirect('userList', ['id' => $finalId]); } catch (\Exception $e) { switch (get_class($e)) { case 'VuFind\\Exception\\ListPermission': case 'VuFind\\Exception\\MissingField': $this->flashMessenger()->setNamespace('error')->addMessage($e->getMessage()); return false; case 'VuFind\\Exception\\LoginRequired': return $this->forceLogin(); default: throw $e; } } }