mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/site_tools.git
synced 2026-05-05 01:40:40 -03:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 204445853d | |||
| 727c726014 | |||
| 9d63359854 | |||
| d113e932ba | |||
| f937b84c50 | |||
| 7aefb543e9 | |||
| 41378004a2 |
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"name": "imecc/site_tools",
|
||||
"description": "Módulo Drupal com ferramentas utilitárias reutilizáveis em outros módulos do site."
|
||||
"type": "drupal-module",
|
||||
"description": "Módulo Drupal com ferramentas utilitárias reutilizáveis em outros módulos do site.",
|
||||
"type": "drupal-custom-module",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"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": "*"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ name: 'Site Tools — Group Helpers'
|
||||
type: module
|
||||
description: 'Utilitários reutilizáveis para integração com o módulo Group.'
|
||||
core_version_requirement: ^10.3 || ^11
|
||||
package: Custom
|
||||
package: 'Site Tools'
|
||||
dependencies:
|
||||
- site_tools:site_tools
|
||||
- group: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": "*"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ name: 'Site Tools MSC 2020'
|
||||
type: module
|
||||
description: 'Vocabulário de taxonomia MSC 2020 (Mathematics Subject Classification).'
|
||||
core_version_requirement: ^10 || ^11
|
||||
package: Custom
|
||||
package: 'Site Tools'
|
||||
dependencies:
|
||||
- site_tools:site_tools
|
||||
- drupal:taxonomy
|
||||
|
||||
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": "*"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ name: 'Site Tools MSC 2020 Migrate'
|
||||
type: module
|
||||
description: 'Migrations para importação dos termos MSC 2020 (inglês e português).'
|
||||
core_version_requirement: ^10 || ^11
|
||||
package: Custom
|
||||
package: 'Site Tools'
|
||||
dependencies:
|
||||
- site_tools:site_tools_msc_2020
|
||||
- migrate:migrate
|
||||
|
||||
@@ -2,4 +2,4 @@ name: Site Tools
|
||||
type: module
|
||||
description: 'Ferramentas utilitárias reutilizáveis para outros módulos do site.'
|
||||
core_version_requirement: ^10.3 || ^11
|
||||
package: Custom
|
||||
package: 'Site Tools'
|
||||
|
||||
@@ -4,9 +4,11 @@ namespace Drupal\site_tools\Plugin\Condition;
|
||||
|
||||
use Drupal\Core\Condition\ConditionPluginBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Path\CurrentPathStack;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\user\UserInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
@@ -29,6 +31,7 @@ class PageUserIsCurrentUser extends ConditionPluginBase implements ContainerFact
|
||||
$plugin_definition,
|
||||
protected RouteMatchInterface $routeMatch,
|
||||
protected AccountInterface $currentUser,
|
||||
protected CurrentPathStack $currentPath,
|
||||
) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
}
|
||||
@@ -40,6 +43,7 @@ class PageUserIsCurrentUser extends ConditionPluginBase implements ContainerFact
|
||||
$plugin_definition,
|
||||
$container->get('current_route_match'),
|
||||
$container->get('current_user'),
|
||||
$container->get('path.current'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -89,7 +93,22 @@ class PageUserIsCurrentUser extends ConditionPluginBase implements ContainerFact
|
||||
$page_uid = (int) $param;
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
// 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 {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return $page_uid === (int) $this->currentUser->id();
|
||||
|
||||
Reference in New Issue
Block a user