13 namespace Fossology\UI\Page;
18 use Symfony\Component\HttpFoundation\JsonResponse;
19 use Symfony\Component\HttpFoundation\Request;
20 use Symfony\Component\HttpFoundation\Response;
33 const NAME =
"admin_license_acknowledgements";
83 function __construct()
85 parent::__construct(self::NAME,
87 self::TITLE =>
"Admin License Acknowledgements",
88 self::MENU_LIST =>
"Admin::License Admin::Acknowledgements",
89 self::REQUIRES_LOGIN =>
true,
92 $this->licenseAcknowledgementDao = $this->
getObject(
'dao.license.acknowledgement');
99 protected function handle(Request $request)
101 if ($request->get(self::ACKNOWLEDGEMENT_UPDATE_PARAM_NAME, 0) == 1) {
103 JsonResponse::HTTP_OK);
113 $vars[
'acknowledgementArray'] = $this->licenseAcknowledgementDao->getAllAcknowledgements();
114 return $this->
render(
'admin_license_acknowledgements.html.twig',
115 $this->mergeWithDefault($vars));
127 $acknowledgements = [];
132 $acknowledgementStrings = $request->get(self::ACKNOWLEDGEMENT_PARAM_NAME);
133 $acknowledgementNames = $request->get(self::ACKNOWLEDGEMENT_NAME_PARAM_NAME);
134 $insertNames = $request->get(self::INSERT_ACKNOWLEDGEMENT_NAME_PARAM);
135 $insertAcknowledgements = $request->get(self::ACKNOWLEDGEMENT_INSERT_PARAM_NAME);
136 if ($acknowledgementStrings !==
null && !empty($acknowledgementStrings)) {
137 foreach ($acknowledgementStrings as $acknowledgementPk => $acknowledgement) {
138 $acknowledgements[$acknowledgementPk][
'acknowledgement'] = $acknowledgement;
141 if ($acknowledgementNames !==
null && !empty($acknowledgementNames)) {
142 foreach ($acknowledgementNames as $acknowledgementPk => $name) {
143 $acknowledgements[$acknowledgementPk][
'name'] = $name;
146 if (! empty($acknowledgements)) {
148 $update[
'updated'] = $this->licenseAcknowledgementDao->updateAcknowledgementFromArray(
150 }
catch (\UnexpectedValueException $e) {
151 $update[
'updated'] = $e->getMessage();
168 if (($namesArray !==
null && $acknowledgementsArray !==
null) &&
169 (! empty($namesArray) && !empty($acknowledgementsArray))) {
170 for ($i = 0; $i < count($namesArray); $i++) {
171 $returnVal[] = $this->licenseAcknowledgementDao->insertAcknowledgement($namesArray[$i],
172 $acknowledgementsArray[$i]);
174 $returnVal[
'status'] = 0;
176 if (count(array_filter($returnVal,
function($val) {
179 $returnVal[
'status'] |= 1;
182 if (in_array(-1, $returnVal)) {
183 $returnVal[
'status'] |= 1 << 1;
186 if (in_array(-2, $returnVal)) {
187 $returnVal[
'status'] |= 1 << 2;
194 register_plugin(
new AdminLicenseAcknowledgements());
Contains the constants and helpers for authentication of user.
render($templateName, $vars=null, $headers=null)
const ACKNOWLEDGEMENT_NAME_PARAM_NAME
insertAcknowledgements($namesArray, $acknowledgementsArray)
const INSERT_ACKNOWLEDGEMENT_NAME_PARAM
const ACKNOWLEDGEMENT_ENABLE_PARAM_NAME
const ACKNOWLEDGEMENT_INSERT_PARAM_NAME
$licenseAcknowledgementDao
const ACKNOWLEDGEMENT_UPDATE_PARAM_NAME
const ACKNOWLEDGEMENT_ID_PARAM_NAME
const ACKNOWLEDGEMENT_PARAM_NAME
updateAcknowledgements(Request $request)