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_std_comments";
69 const INSERT_COMMENT_PARAM_NAME =
"insertStdLicComments";
83 function __construct()
85 parent::__construct(self::NAME,
87 self::TITLE =>
"Admin Standard License Comments",
88 self::MENU_LIST =>
"Admin::License Admin::Standard Comments",
89 self::REQUIRES_LOGIN =>
true,
92 $this->licenseCommentDao = $this->
getObject(
'dao.license.stdc');
99 protected function handle(Request $request)
101 if ($request->get(self::UPDATE_PARAM_NAME, 0) == 1) {
103 JsonResponse::HTTP_OK);
113 $vars[
'commentArray'] = $this->licenseCommentDao->getAllComments();
114 return $this->
render(
'admin_license_std_comments.html.twig',
115 $this->mergeWithDefault($vars));
132 $commentStrings = $request->get(self::COMMENT_PARAM_NAME);
133 $commentNames = $request->get(self::COMMENT_NAME_PARAM_NAME);
134 $insertNames = $request->get(self::INSERT_NAME_PARAM_NAME);
135 $insertComments = $request->get(self::INSERT_COMMENT_PARAM_NAME);
136 if ($commentStrings !==
null && !empty($commentStrings)) {
137 foreach ($commentStrings as $commentPk => $comment) {
138 $comments[$commentPk][
'comment'] = $comment;
141 if ($commentNames !==
null && !empty($commentNames)) {
142 foreach ($commentNames as $commentPk => $name) {
143 $comments[$commentPk][
'name'] = $name;
146 if (! empty($comments)) {
148 $update[
'updated'] = $this->licenseCommentDao->updateCommentFromArray(
150 }
catch (\UnexpectedValueException $e) {
151 $update[
'updated'] = $e->getMessage();
154 $update[
"inserted"] = $this->
insertComments($insertNames, $insertComments);
168 if (($namesArray !==
null && $commentsArray !==
null) &&
169 (! empty($namesArray) && !empty($commentsArray))) {
170 for ($i = 0; $i < count($namesArray); $i++) {
171 $returnVal[] = $this->licenseCommentDao->insertComment($namesArray[$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 AdminLicenseStdComments());
Contains the constants and helpers for authentication of user.
render($templateName, $vars=null, $headers=null)