47 const NAME =
"admin_license_std_comments";
83 const INSERT_COMMENT_PARAM_NAME =
"insertStdLicComments";
97 function __construct()
99 parent::__construct(self::NAME,
101 self::TITLE =>
"Admin Standard License Comments",
102 self::MENU_LIST =>
"Admin::License Admin::Standard Comments",
103 self::REQUIRES_LOGIN =>
true,
106 $this->licenseCommentDao = $this->
getObject(
'dao.license.stdc');
113 protected function handle(Request $request)
115 if ($request->get(self::UPDATE_PARAM_NAME, 0) == 1) {
117 JsonResponse::HTTP_OK);
121 $vars[
"updateParam"] = self::UPDATE_PARAM_NAME;
122 $vars[
"commentParam"] = self::COMMENT_PARAM_NAME;
123 $vars[
"commentIdParam"] = self::COMMENT_ID_PARAM_NAME;
124 $vars[
"commentNameParam"] = self::COMMENT_NAME_PARAM_NAME;
125 $vars[
"enableParam"] = self::ENABLE_PARAM_NAME;
127 $vars[
'commentArray'] = $this->licenseCommentDao->getAllComments();
128 return $this->
render(
'admin_license_std_comments.html.twig',
129 $this->mergeWithDefault($vars));
146 $commentStrings = $request->get(self::COMMENT_PARAM_NAME);
147 $commentNames = $request->get(self::COMMENT_NAME_PARAM_NAME);
148 $insertNames = $request->get(self::INSERT_NAME_PARAM_NAME);
149 $insertComments = $request->get(self::INSERT_COMMENT_PARAM_NAME);
150 if ($commentStrings !== null && !empty($commentStrings)) {
151 foreach ($commentStrings as $commentPk => $comment) {
152 $comments[$commentPk][
'comment'] = $comment;
155 if ($commentNames !== null && !empty($commentNames)) {
156 foreach ($commentNames as $commentPk => $name) {
157 $comments[$commentPk][
'name'] = $name;
160 if (! empty($comments)) {
162 $update[
'updated'] = $this->licenseCommentDao->updateCommentFromArray(
164 }
catch (\UnexpectedValueException $e) {
165 $update[
'updated'] = $e->getMessage();
168 $update[
"inserted"] = $this->
insertComments($insertNames, $insertComments);
182 if (($namesArray !== null && $commentsArray !== null) &&
183 (! empty($namesArray) && !empty($commentsArray))) {
184 for ($i = 0; $i < count($namesArray); $i++) {
185 $returnVal[] = $this->licenseCommentDao->insertComment($namesArray[$i],
188 $returnVal[
'status'] = 0;
190 if (count(array_filter($returnVal,
function($val) {
193 $returnVal[
'status'] |= 1;
196 if (in_array(-1, $returnVal)) {
197 $returnVal[
'status'] |= 1 << 1;
200 if (in_array(-2, $returnVal)) {
201 $returnVal[
'status'] |= 1 << 2;
render($templateName, $vars=null, $headers=null)