Initial Commit

This commit is contained in:
2019-11-21 12:25:31 +01:00
commit f4aabcb9b1
13959 changed files with 787761 additions and 0 deletions

View File

@@ -0,0 +1,119 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Comment\Form;
use Comment\Comment;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\LessThanOrEqual;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Form\BaseForm;
class AddCommentForm extends BaseForm
{
protected function trans($id, array $parameters = [])
{
return $this->translator->trans($id, $parameters, Comment::MESSAGE_DOMAIN);
}
protected function buildForm()
{
$this->formBuilder
->add('username', 'text', [
'constraints' => [
new NotBlank(['groups' => ['anonymous']])
],
'label' => $this->trans('Username'),
'label_attr' => [
'for' => 'comment_username'
]
])
->add('email', 'email', [
'constraints' => [
new NotBlank(['groups' => ['anonymous']]),
new Email(['groups' => ['anonymous']])
],
'label' => $this->trans('Email'),
'label_attr' => [
'for' => 'comment_mail'
]
])
->add('title', 'text', [
'constraints' => [
new NotBlank()
],
'label' => $this->trans('Title'),
'label_attr' => [
'for' => 'title'
]
])
->add('content', 'text', [
'constraints' => [
new NotBlank()
],
'label' => $this->trans('Content'),
'label_attr' => [
'for' => 'content'
]
])
->add('ref', 'text', [
'constraints' => [
new NotBlank()
],
'label' => $this->trans('Ref'),
'label_attr' => [
'for' => 'ref'
]
])
->add('ref_id', 'text', [
'constraints' => [
new GreaterThan(['value' => 0])
],
'label' => $this->trans('Ref Id'),
'label_attr' => [
'for' => 'ref_id'
]
])
->add('rating', 'text', [
'constraints' => [
new GreaterThanOrEqual(['value' => 0, 'groups' => ['rating']]),
new LessThanOrEqual(['value' => 5, 'groups' => ['rating']])
],
'label' => $this->trans('Rating'),
'label_attr' => [
'for' => 'rating'
]
]);
}
/*
protected function getDefinition() {
$this->form->get('success_url');
}
*/
public function getName()
{
return 'admin_add_comment';
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Comment\Form;
use Thelia\Form\BaseForm;
/**
* Class CommentAbuseForm
* @package Comment\Form
* @author Julien Chanséaume <jchanseaume@openstudio.fr>
*/
class CommentAbuseForm extends BaseForm
{
protected function trans($id, array $parameters = [])
{
return $this->translator->trans($id, $parameters, Comment::MESSAGE_DOMAIN);
}
protected function buildForm()
{
$this
->formBuilder
->add(
'id',
'comment_id'
);
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return 'comment_abuse';
}
}

View File

@@ -0,0 +1,168 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Comment\Form;
use Comment\Comment;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\LessThanOrEqual;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Form\BaseForm;
/**
* Class CommentCreationForm
* @package Comment\Form
* @author Julien Chanséaume <jchanseaume@openstudio.fr>
*/
class CommentCreationForm extends BaseForm
{
protected function trans($id, array $parameters = [])
{
return $this->translator->trans($id, $parameters, Comment::MESSAGE_DOMAIN);
}
protected function buildForm()
{
$this
->formBuilder
->add(
'customer_id',
'integer',
[
'required' => false,
'label' => $this->trans('Customer'),
'label_attr' => [
'for' => 'customer_id'
]
]
)
->add('username', 'text', [
'required' => false,
'constraints' => [
new Length(['min' => 2])
],
'label' => $this->trans('Username'),
'label_attr' => [
'for' => 'comment_username'
]
])
->add('email', 'email', [
'required' => false,
'constraints' => [
new Email()
],
'label' => $this->trans('Email'),
'label_attr' => [
'for' => 'comment_mail'
]
])
->add(
'locale',
'text',
[
'label' => $this->trans('Locale'),
'label_attr' => [
'for' => 'locale'
]
]
)
->add('title', 'text', [
'constraints' => [
new NotBlank()
],
'label' => $this->trans('Title'),
'label_attr' => [
'for' => 'title'
]
])
->add('content', 'text', [
'constraints' => [
new NotBlank()
],
'label' => $this->trans('Content'),
'label_attr' => [
'for' => 'content'
]
])
->add('ref', 'text', [
'constraints' => [
new NotBlank()
],
'label' => $this->trans('Ref'),
'label_attr' => [
'for' => 'ref'
]
])
->add('ref_id', 'integer', [
'constraints' => [
new GreaterThanOrEqual(['value' => 0])
],
'label' => $this->trans('Ref Id'),
'label_attr' => [
'for' => 'ref_id'
]
])
->add('rating', 'integer', [
'required' => false,
'constraints' => [
new GreaterThanOrEqual(['value' => 0]),
new LessThanOrEqual(['value' => 5])
],
'label' => $this->trans('Rating'),
'label_attr' => [
'for' => 'rating'
]
])
->add(
'status',
'integer',
[
'label' => $this->trans('Status'),
'label_attr' => [
'for' => 'status'
]
]
)
->add(
'verified',
'integer',
[
'label' => $this->trans('Verified'),
'label_attr' => [
'for' => 'verified'
]
]
)
->add(
'abuse',
'integer',
[
'label' => $this->trans('Abuse'),
'label_attr' => [
'for' => 'abuse'
]
]
);
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return 'admin_comment_creation';
}
}

View File

@@ -0,0 +1,60 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Comment\Form;
use Comment\Comment;
use Symfony\Component\Validator\Constraints\NotBlank;
/**
* Class CommentModificationForm
* @package Comment\Form
* @author Julien Chanséaume <jchanseaume@openstudio.fr>
*/
class CommentModificationForm extends CommentCreationForm
{
protected function trans($id, array $parameters = [])
{
return $this->translator->trans($id, $parameters, Comment::MESSAGE_DOMAIN);
}
protected function buildForm()
{
parent::buildForm();
$this
->formBuilder
->add(
'id',
'integer',
[
'constraints' => [
new NotBlank()
],
'label' => $this->trans('Id'),
'label_attr' => [
'for' => 'id'
]
]
);
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return 'admin_comment_modification';
}
}

View File

@@ -0,0 +1,143 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Comment\Form;
use Comment\Comment;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Form\BaseForm;
/**
* Class ConfigurationForm
* @package Comment\Form
* @author Julien Chanséaume <jchanseaume@openstudio.fr>
*/
class ConfigurationForm extends BaseForm
{
protected function trans($id, array $parameters = [])
{
return $this->translator->trans($id, $parameters, Comment::MESSAGE_DOMAIN);
}
protected function buildForm()
{
$form = $this->formBuilder;
$config = Comment::getConfig();
$form
->add(
"activated",
"checkbox",
[
'data' => $config['activated'],
'label' => $this->trans("Activated"),
'label_attr' => [
'for' => "activated",
'help' => $this->trans(
"Global activation of comments. You can control activation by product, content."
)
],
]
)
->add(
"moderate",
"checkbox",
[
'data' => $config['moderate'],
'label' => $this->trans("Moderate"),
'label_attr' => [
'for' => "moderate",
'help' => $this->trans("Comments are not validated automatically.")
],
]
)
->add(
"ref_allowed",
"text",
[
'constraints' => [
new NotBlank()
],
'data' => implode(',', $config['ref_allowed']),
'label' => $this->trans("Allowed references"),
'label_attr' => [
'for' => "back_office_path",
'help' => $this->trans("which elements could use comments")
],
]
)
->add(
"only_customer",
"checkbox",
[
'data' => $config['only_customer'],
'label' => $this->trans("Only customer"),
'label_attr' => [
'for' => "only_customer",
'help' => $this->trans("Only registered customers can post comments.")
],
]
)
->add(
"only_verified",
"checkbox",
[
'data' => $config['only_verified'],
'label' => $this->trans("Only verified"),
'label_attr' => [
'for' => "only_verified",
'help' => $this->trans(
"For product comments. Only customers that bought the product can post comments."
)
],
]
)
->add(
"request_customer_ttl",
"number",
[
'data' => $config['request_customer_ttl'],
'label' => $this->trans("Request customer"),
'label_attr' => [
'for' => "request_customer_ttl",
'help' => $this->trans(
"Send an email to request customer comments, x days after a paid order (0 = no request sent)."
)
],
]
)
->add(
"notify_admin_new_comment",
"checkbox",
[
'data' => $config['notify_admin_new_comment'],
'label' => $this->trans("Notify store managers on new comment"),
'label_attr' => [
'for' => "notify_admin_new_comment",
'help' => $this->trans(
"Send an email to the store managers when a new comment is posted."
)
],
]
);
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return "comment-configuration-form";
}
}

View File

@@ -0,0 +1,45 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Comment\Form\Field;
use Comment\Model\CommentQuery;
use Thelia\Core\Form\Type\Field\AbstractIdType;
/**
* Class CommentIdType
* @package Comment\Form\Field
* @author Julien Chanséaume <jchanseaume@openstudio.fr>
*/
class CommentIdType extends AbstractIdType
{
/**
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
*
* Get the model query to check
*/
protected function getQuery()
{
return new CommentQuery();
}
/**
* Returns the name of this type.
*
* @return string The name of this type
*/
public function getName()
{
return "comment_id";
}
}