mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-26 13:54:42 +02:00
Merge branch 'master' into log_detail_page
This commit is contained in:
commit
4c6ceab8e8
291 changed files with 1994 additions and 1621 deletions
|
@ -269,7 +269,6 @@ abstract class BaseAdminController extends AbstractController
|
|||
|
||||
protected function _new(Request $request, EntityManagerInterface $em, EntityImporter $importer, ?AbstractNamedDBElement $entity = null)
|
||||
{
|
||||
$master_picture_backup = null;
|
||||
if (null === $entity) {
|
||||
/** @var AbstractStructuralDBElement|User $new_entity */
|
||||
$new_entity = new $this->entity_class();
|
||||
|
@ -390,7 +389,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
foreach ($errors as $error) {
|
||||
if ($error['entity'] instanceof AbstractStructuralDBElement) {
|
||||
$this->addFlash('error', $error['entity']->getFullPath().':'.$error['violations']);
|
||||
} else { //When we dont have a structural element, we can only show the name
|
||||
} else { //When we don't have a structural element, we can only show the name
|
||||
$this->addFlash('error', $error['entity']->getName().':'.$error['violations']);
|
||||
}
|
||||
}
|
||||
|
@ -413,11 +412,11 @@ abstract class BaseAdminController extends AbstractController
|
|||
}
|
||||
|
||||
/**
|
||||
* Performs checks if the element can be deleted safely. Otherwise an flash message is added.
|
||||
* Performs checks if the element can be deleted safely. Otherwise, a flash message is added.
|
||||
*
|
||||
* @param AbstractNamedDBElement $entity the element that should be checked
|
||||
*
|
||||
* @return bool True if the the element can be deleted, false if not
|
||||
* @return bool True if the element can be deleted, false if not
|
||||
*/
|
||||
protected function deleteCheck(AbstractNamedDBElement $entity): bool
|
||||
{
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace App\Controller\AdminPages;
|
|||
use App\Entity\Attachments\ProjectAttachment;
|
||||
use App\Entity\ProjectSystem\Project;
|
||||
use App\Entity\Parameters\ProjectParameter;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use App\Form\AdminPages\ProjectAdminForm;
|
||||
use App\Services\ImportExportSystem\EntityExporter;
|
||||
use App\Services\ImportExportSystem\EntityImporter;
|
||||
|
|
|
@ -24,12 +24,8 @@ namespace App\Controller;
|
|||
|
||||
use App\DataTables\AttachmentDataTable;
|
||||
use App\DataTables\Filters\AttachmentFilter;
|
||||
use App\DataTables\Filters\PartFilter;
|
||||
use App\DataTables\PartsDataTable;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\PartAttachment;
|
||||
use App\Form\Filters\AttachmentFilterType;
|
||||
use App\Form\Filters\PartFilterType;
|
||||
use App\Services\Attachments\AttachmentManager;
|
||||
use App\Services\Trees\NodesListBuilder;
|
||||
use Omines\DataTablesBundle\DataTableFactory;
|
||||
|
@ -106,10 +102,8 @@ class AttachmentFileController extends AbstractController
|
|||
|
||||
/**
|
||||
* @Route("/attachment/list", name="attachment_list")
|
||||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function attachmentsTable(Request $request, DataTableFactory $dataTableFactory, NodesListBuilder $nodesListBuilder)
|
||||
public function attachmentsTable(Request $request, DataTableFactory $dataTableFactory, NodesListBuilder $nodesListBuilder): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@attachments.list_attachments');
|
||||
|
||||
|
|
|
@ -74,9 +74,9 @@ class GroupController extends BaseAdminController
|
|||
|
||||
//We need to stop the execution here, or our permissions changes will be overwritten by the form values
|
||||
return $this->redirectToRoute('group_edit', ['id' => $entity->getID()]);
|
||||
} else {
|
||||
$this->addFlash('danger', 'csfr_invalid');
|
||||
}
|
||||
|
||||
$this->addFlash('danger', 'csfr_invalid');
|
||||
}
|
||||
|
||||
return $this->_edit($entity, $request, $em, $timestamp);
|
||||
|
|
|
@ -68,9 +68,9 @@ class LogController extends AbstractController
|
|||
/**
|
||||
* @Route("/", name="log_view")
|
||||
*
|
||||
* @return JsonResponse|Response
|
||||
* @return Response
|
||||
*/
|
||||
public function showLogs(Request $request, DataTableFactory $dataTable)
|
||||
public function showLogs(Request $request, DataTableFactory $dataTable): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@system.show_logs');
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ use Symfony\Component\Form\FormInterface;
|
|||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
@ -351,8 +350,10 @@ class PartController extends AbstractController
|
|||
if($partLot->getPart() !== $part) {
|
||||
throw new \RuntimeException("The origin partlot does not belong to the part!");
|
||||
}
|
||||
//Try to determine the target lot (used for move actions)
|
||||
$targetLot = $em->find(PartLot::class, $request->request->get('target_id'));
|
||||
|
||||
//Try to determine the target lot (used for move actions), if the parameter is existing
|
||||
$targetId = $request->request->get('target_id', null);
|
||||
$targetLot = $targetId ? $em->find(PartLot::class, $targetId) : null;
|
||||
if ($targetLot && $targetLot->getPart() !== $part) {
|
||||
throw new \RuntimeException("The target partlot does not belong to the part!");
|
||||
}
|
||||
|
@ -396,7 +397,7 @@ class PartController extends AbstractController
|
|||
}
|
||||
|
||||
err:
|
||||
//If an redirect was passed, then redirect there
|
||||
//If a redirect was passed, then redirect there
|
||||
if($request->request->get('_redirect')) {
|
||||
return $this->redirect($request->request->get('_redirect'));
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ use App\Services\ImportExportSystem\EntityExporter;
|
|||
use App\Services\ImportExportSystem\EntityImporter;
|
||||
use App\Services\LogSystem\EventCommentHelper;
|
||||
use App\Services\Parts\PartsTableActionHandler;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
|
@ -158,7 +158,7 @@ class PartListsController extends AbstractController
|
|||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showCategory(Category $category, Request $request)
|
||||
public function showCategory(Category $category, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@categories.read');
|
||||
|
||||
|
@ -180,7 +180,7 @@ class PartListsController extends AbstractController
|
|||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showFootprint(Footprint $footprint, Request $request)
|
||||
public function showFootprint(Footprint $footprint, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@footprints.read');
|
||||
|
||||
|
@ -202,7 +202,7 @@ class PartListsController extends AbstractController
|
|||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showManufacturer(Manufacturer $manufacturer, Request $request)
|
||||
public function showManufacturer(Manufacturer $manufacturer, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@manufacturers.read');
|
||||
|
||||
|
@ -224,7 +224,7 @@ class PartListsController extends AbstractController
|
|||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showStorelocation(Storelocation $storelocation, Request $request)
|
||||
public function showStorelocation(Storelocation $storelocation, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@storelocations.read');
|
||||
|
||||
|
@ -246,7 +246,7 @@ class PartListsController extends AbstractController
|
|||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showSupplier(Supplier $supplier, Request $request)
|
||||
public function showSupplier(Supplier $supplier, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('@suppliers.read');
|
||||
|
||||
|
@ -268,7 +268,7 @@ class PartListsController extends AbstractController
|
|||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showTag(string $tag, Request $request, DataTableFactory $dataTable)
|
||||
public function showTag(string $tag, Request $request): Response
|
||||
{
|
||||
$tag = trim($tag);
|
||||
|
||||
|
@ -291,6 +291,7 @@ class PartListsController extends AbstractController
|
|||
$filter->setName($request->query->getBoolean('name', true));
|
||||
$filter->setCategory($request->query->getBoolean('category', true));
|
||||
$filter->setDescription($request->query->getBoolean('description', true));
|
||||
$filter->setMpn($request->query->getBoolean('mpn', true));
|
||||
$filter->setTags($request->query->getBoolean('tags', true));
|
||||
$filter->setStorelocation($request->query->getBoolean('storelocation', true));
|
||||
$filter->setComment($request->query->getBoolean('comment', true));
|
||||
|
@ -300,6 +301,7 @@ class PartListsController extends AbstractController
|
|||
$filter->setManufacturer($request->query->getBoolean('manufacturer', false));
|
||||
$filter->setFootprint($request->query->getBoolean('footprint', false));
|
||||
|
||||
|
||||
$filter->setRegex($request->query->getBoolean('regex', false));
|
||||
|
||||
return $filter;
|
||||
|
@ -310,7 +312,7 @@ class PartListsController extends AbstractController
|
|||
*
|
||||
* @return JsonResponse|Response
|
||||
*/
|
||||
public function showSearch(Request $request, DataTableFactory $dataTable)
|
||||
public function showSearch(Request $request, DataTableFactory $dataTable): Response
|
||||
{
|
||||
$searchFilter = $this->searchRequestToFilter($request);
|
||||
|
||||
|
@ -331,9 +333,9 @@ class PartListsController extends AbstractController
|
|||
/**
|
||||
* @Route("/parts", name="parts_show_all")
|
||||
*
|
||||
* @return JsonResponse|Response
|
||||
* @return Response
|
||||
*/
|
||||
public function showAll(Request $request, DataTableFactory $dataTable)
|
||||
public function showAll(Request $request): Response
|
||||
{
|
||||
return $this->showListWithFilter($request,'parts/lists/all_list.html.twig');
|
||||
}
|
||||
|
|
|
@ -32,10 +32,8 @@ use App\Services\ImportExportSystem\BOMImporter;
|
|||
use App\Services\ProjectSystem\ProjectBuildHelper;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use League\Csv\Exception;
|
||||
use League\Csv\SyntaxError;
|
||||
use Omines\DataTablesBundle\DataTableFactory;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
@ -64,7 +62,7 @@ class ProjectController extends AbstractController
|
|||
/**
|
||||
* @Route("/{id}/info", name="project_info", requirements={"id"="\d+"})
|
||||
*/
|
||||
public function info(Project $project, Request $request, ProjectBuildHelper $buildHelper)
|
||||
public function info(Project $project, Request $request, ProjectBuildHelper $buildHelper): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('read', $project);
|
||||
|
||||
|
@ -114,9 +112,9 @@ class ProjectController extends AbstractController
|
|||
$request->get('_redirect',
|
||||
$this->generateUrl('project_info', ['id' => $project->getID()]
|
||||
)));
|
||||
} else {
|
||||
$this->addFlash('error', 'project.build.flash.invalid_input');
|
||||
}
|
||||
|
||||
$this->addFlash('error', 'project.build.flash.invalid_input');
|
||||
}
|
||||
|
||||
return $this->renderForm('projects/build/build.html.twig', [
|
||||
|
|
|
@ -28,20 +28,17 @@ use function in_array;
|
|||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class RedirectController extends AbstractController
|
||||
{
|
||||
protected string $default_locale;
|
||||
protected TranslatorInterface $translator;
|
||||
protected SessionInterface $session;
|
||||
protected bool $enforce_index_php;
|
||||
|
||||
public function __construct(string $default_locale, TranslatorInterface $translator, SessionInterface $session, bool $enforce_index_php)
|
||||
public function __construct(string $default_locale, TranslatorInterface $translator, bool $enforce_index_php)
|
||||
{
|
||||
$this->default_locale = $default_locale;
|
||||
$this->session = $session;
|
||||
$this->translator = $translator;
|
||||
$this->enforce_index_php = $enforce_index_php;
|
||||
}
|
||||
|
@ -52,7 +49,7 @@ class RedirectController extends AbstractController
|
|||
*/
|
||||
public function addLocalePart(Request $request): RedirectResponse
|
||||
{
|
||||
//By default we use the global default locale
|
||||
//By default, we use the global default locale
|
||||
$locale = $this->default_locale;
|
||||
|
||||
//Check if a user has set a preferred language setting:
|
||||
|
@ -61,7 +58,6 @@ class RedirectController extends AbstractController
|
|||
$locale = $user->getLanguage();
|
||||
}
|
||||
|
||||
//$new_url = str_replace($request->getPathInfo(), '/' . $locale . $request->getPathInfo(), $request->getUri());
|
||||
$new_url = $request->getUriForPath('/'.$locale.$request->getPathInfo());
|
||||
|
||||
//If either mod_rewrite is not enabled or the index.php version is enforced, add index.php to the string
|
||||
|
@ -71,6 +67,9 @@ class RedirectController extends AbstractController
|
|||
$new_url = $request->getSchemeAndHttpHost().$request->getBaseUrl().'/index.php/'.$locale.$request->getPathInfo();
|
||||
}
|
||||
|
||||
//Add the query string
|
||||
$new_url .= $request->getQueryString() ? '?'.$request->getQueryString() : '';
|
||||
|
||||
return $this->redirect($new_url);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ namespace App\Controller;
|
|||
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Entity\Contracts\NamedElementInterface;
|
||||
use App\Entity\LabelSystem\LabelProfile;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Footprint;
|
||||
|
@ -106,7 +105,7 @@ class SelectAPIController extends AbstractController
|
|||
3 => $this->translator->trans('export.level.full'),
|
||||
];
|
||||
|
||||
return $this->json(array_map(function ($key, $value) {
|
||||
return $this->json(array_map(static function ($key, $value) {
|
||||
return [
|
||||
'text' => $value,
|
||||
'value' => $key,
|
||||
|
@ -198,7 +197,7 @@ class SelectAPIController extends AbstractController
|
|||
]);
|
||||
//Remove the data-* prefix for each key
|
||||
$data = array_combine(
|
||||
array_map(function ($key) {
|
||||
array_map(static function ($key) {
|
||||
if (strpos($key, 'data-') === 0) {
|
||||
return substr($key, 5);
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class TypeaheadController extends AbstractController
|
|||
}
|
||||
|
||||
/**
|
||||
* This functions map the parameter type to the class, so we can access its repository
|
||||
* This function map the parameter type to the class, so we can access its repository
|
||||
* @param string $type
|
||||
* @return class-string
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace App\Controller;
|
|||
use App\DataTables\LogDataTable;
|
||||
use App\Entity\Attachments\UserAttachment;
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use App\Entity\Parameters\AbstractParameter;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Events\SecurityEvent;
|
||||
use App\Events\SecurityEvents;
|
||||
|
@ -62,11 +61,11 @@ class UserController extends AdminPages\BaseAdminController
|
|||
|
||||
protected function additionalActionEdit(FormInterface $form, AbstractNamedDBElement $entity): bool
|
||||
{
|
||||
//Check if we editing a user and if we need to change the password of it
|
||||
//Check if we're editing a user and if we need to change the password of it
|
||||
if ($entity instanceof User && !empty($form['new_password']->getData())) {
|
||||
$password = $this->passwordEncoder->hashPassword($entity, $form['new_password']->getData());
|
||||
$entity->setPassword($password);
|
||||
//By default the user must change the password afterwards
|
||||
//By default, the user must change the password afterward
|
||||
$entity->setNeedPwChange(true);
|
||||
|
||||
$event = new SecurityEvent($entity);
|
||||
|
@ -129,9 +128,9 @@ class UserController extends AdminPages\BaseAdminController
|
|||
|
||||
//We need to stop the execution here, or our permissions changes will be overwritten by the form values
|
||||
return $this->redirectToRoute('user_edit', ['id' => $entity->getID()]);
|
||||
} else {
|
||||
$this->addFlash('danger', 'csfr_invalid');
|
||||
}
|
||||
|
||||
$this->addFlash('danger', 'csfr_invalid');
|
||||
}
|
||||
|
||||
return $this->_edit($entity, $request, $em, $timestamp);
|
||||
|
@ -142,7 +141,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
if ($entity instanceof User && !empty($form['new_password']->getData())) {
|
||||
$password = $this->passwordEncoder->hashPassword($entity, $form['new_password']->getData());
|
||||
$entity->setPassword($password);
|
||||
//By default the user must change the password afterwards
|
||||
//By default, the user must change the password afterward
|
||||
$entity->setNeedPwChange(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ class UserSettingsController extends AbstractController
|
|||
*/
|
||||
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager, FormFactoryInterface $formFactory, UserAvatarHelper $avatarHelper)
|
||||
{
|
||||
/** @var User */
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
|
||||
$page_need_reload = false;
|
||||
|
@ -261,7 +261,7 @@ class UserSettingsController extends AbstractController
|
|||
$page_need_reload = true;
|
||||
}
|
||||
|
||||
/** @var Form $form We need an form implementation for the next calls */
|
||||
/** @var Form $form We need a form implementation for the next calls */
|
||||
if ($form->getClickedButton() && 'remove_avatar' === $form->getClickedButton()->getName()) {
|
||||
//Remove the avatar attachment from the user if requested
|
||||
if ($user->getMasterPictureAttachment() !== null) {
|
||||
|
@ -327,7 +327,7 @@ class UserSettingsController extends AbstractController
|
|||
|
||||
$pw_form->handleRequest($request);
|
||||
|
||||
//Check if password if everything was correct, then save it to User and DB
|
||||
//Check if everything was correct, then save it to User and DB
|
||||
if (!$this->demo_mode && $pw_form->isSubmitted() && $pw_form->isValid()) {
|
||||
$password = $passwordEncoder->hashPassword($user, $pw_form['new_password']->getData());
|
||||
$user->setPassword($password);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue