mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/site_tools.git
synced 2026-05-05 21:45:29 -03:00
Compare commits
6 Commits
0.0.1
...
727c726014
| Author | SHA1 | Date | |
|---|---|---|---|
| 727c726014 | |||
| 9d63359854 | |||
| d113e932ba | |||
| f937b84c50 | |||
| 7aefb543e9 | |||
| 41378004a2 |
@@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "imecc/site_tools",
|
"name": "imecc/site_tools",
|
||||||
"description": "Módulo Drupal com ferramentas utilitárias reutilizáveis em outros módulos do site."
|
"description": "Módulo Drupal com ferramentas utilitárias reutilizáveis em outros módulos do site.",
|
||||||
"type": "drupal-module",
|
"type": "drupal-custom-module",
|
||||||
"license": "GPL-2.0-or-later",
|
"license": "GPL-2.0-or-later",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.4"
|
"php": ">=8.1",
|
||||||
|
"drupal/core": "^10.3 || ^11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
modules/site_tools_group_helpers/composer.json
Normal file
12
modules/site_tools_group_helpers/composer.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "imecc/site_tools_group_helpers",
|
||||||
|
"description": "Utilitários reutilizáveis para integração com o módulo Group.",
|
||||||
|
"type": "drupal-module",
|
||||||
|
"license": "GPL-2.0-or-later",
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.1",
|
||||||
|
"drupal/core": "^10.3 || ^11",
|
||||||
|
"imecc/site_tools": "*",
|
||||||
|
"drupal/group": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
11
modules/site_tools_msc_2020/composer.json
Normal file
11
modules/site_tools_msc_2020/composer.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "imecc/site_tools_msc_2020",
|
||||||
|
"description": "Vocabulário de taxonomia MSC 2020 (Mathematics Subject Classification).",
|
||||||
|
"type": "drupal-module",
|
||||||
|
"license": "GPL-2.0-or-later",
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.1",
|
||||||
|
"drupal/core": "^10 || ^11",
|
||||||
|
"imecc/site_tools": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
13
modules/site_tools_msc_2020_migrate/composer.json
Normal file
13
modules/site_tools_msc_2020_migrate/composer.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "imecc/site_tools_msc_2020_migrate",
|
||||||
|
"description": "Migrations para importação dos termos MSC 2020 (inglês e português).",
|
||||||
|
"type": "drupal-module",
|
||||||
|
"license": "GPL-2.0-or-later",
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.1",
|
||||||
|
"drupal/core": "^10 || ^11",
|
||||||
|
"imecc/site_tools_msc_2020": "*",
|
||||||
|
"drupal/migrate_plus": "*",
|
||||||
|
"drupal/migrate_source_csv": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,9 +4,11 @@ namespace Drupal\site_tools\Plugin\Condition;
|
|||||||
|
|
||||||
use Drupal\Core\Condition\ConditionPluginBase;
|
use Drupal\Core\Condition\ConditionPluginBase;
|
||||||
use Drupal\Core\Form\FormStateInterface;
|
use Drupal\Core\Form\FormStateInterface;
|
||||||
|
use Drupal\Core\Path\CurrentPathStack;
|
||||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||||
use Drupal\Core\Routing\RouteMatchInterface;
|
use Drupal\Core\Routing\RouteMatchInterface;
|
||||||
use Drupal\Core\Session\AccountInterface;
|
use Drupal\Core\Session\AccountInterface;
|
||||||
|
use Drupal\node\NodeInterface;
|
||||||
use Drupal\user\UserInterface;
|
use Drupal\user\UserInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ class PageUserIsCurrentUser extends ConditionPluginBase implements ContainerFact
|
|||||||
$plugin_definition,
|
$plugin_definition,
|
||||||
protected RouteMatchInterface $routeMatch,
|
protected RouteMatchInterface $routeMatch,
|
||||||
protected AccountInterface $currentUser,
|
protected AccountInterface $currentUser,
|
||||||
|
protected CurrentPathStack $currentPath,
|
||||||
) {
|
) {
|
||||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||||
}
|
}
|
||||||
@@ -40,6 +43,7 @@ class PageUserIsCurrentUser extends ConditionPluginBase implements ContainerFact
|
|||||||
$plugin_definition,
|
$plugin_definition,
|
||||||
$container->get('current_route_match'),
|
$container->get('current_route_match'),
|
||||||
$container->get('current_user'),
|
$container->get('current_user'),
|
||||||
|
$container->get('path.current'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,9 +92,24 @@ class PageUserIsCurrentUser extends ConditionPluginBase implements ContainerFact
|
|||||||
elseif (is_numeric($param)) {
|
elseif (is_numeric($param)) {
|
||||||
$page_uid = (int) $param;
|
$page_uid = (int) $param;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Views pages com arg_0 numérico (ex.: /user/{uid}/blog).
|
||||||
|
$arg0 = $this->routeMatch->getParameter('arg_0');
|
||||||
|
if (is_numeric($arg0)) {
|
||||||
|
$page_uid = (int) $arg0;
|
||||||
|
}
|
||||||
|
// Nós do microsite: usa o autor como usuário da página.
|
||||||
|
elseif (($node = $this->routeMatch->getParameter('node')) instanceof NodeInterface) {
|
||||||
|
$page_uid = (int) $node->getOwnerId();
|
||||||
|
}
|
||||||
|
// Fallback: extrai o UID do path atual /user/{uid}/...
|
||||||
|
elseif (preg_match('#^/user/(\d+)(/|$)#', $this->currentPath->getPath(), $m)) {
|
||||||
|
$page_uid = (int) $m[1];
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $page_uid === (int) $this->currentUser->id();
|
return $page_uid === (int) $this->currentUser->id();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user