Skip to content
Snippets Groups Projects
Commit c02dc407 authored by Lily Yan's avatar Lily Yan Committed by Igor Biki
Browse files

Feature/istwcms 4183 l26yan create timeline block

parent 7ad9eef8
No related branches found
No related tags found
No related merge requests found
Showing
with 194 additions and 89 deletions
......@@ -35,7 +35,8 @@ blocks:
weight: 0
image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/fullwidthimage.svg
image_alt: ''
- block_id: 'inline_block:uw_cbl_image_gallery'
-
block_id: 'inline_block:uw_cbl_image_gallery'
weight: 0
image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/imagegallery.svg
image_alt: ''
......@@ -49,3 +50,8 @@ blocks:
weight: 0
image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/relatedlinks.svg
image_alt: ''
-
block_id: 'inline_block:uw_cbl_timeline'
weight: 0
image_path: /profiles/uw_base_profile/themes/uw_fdsu_theme_resp/images/layout_builder_browser/timeline.svg
image_alt: ''
......@@ -21,3 +21,4 @@ permissions:
- 'view paragraph content uw_para_fact_text'
- 'view paragraph content uw_para_facts_and_figures'
- 'view paragraph content uw_para_ff'
- 'view paragraph content uw_para_timeline'
......@@ -24,4 +24,5 @@ permissions:
- 'view paragraph content uw_para_fact_text'
- 'view paragraph content uw_para_facts_and_figures'
- 'view paragraph content uw_para_ff'
- 'view paragraph content uw_para_timeline'
- 'view the administration theme'
......@@ -38,6 +38,7 @@ permissions:
- 'create paragraph content uw_para_fact_text'
- 'create paragraph content uw_para_facts_and_figures'
- 'create paragraph content uw_para_ff'
- 'create paragraph content uw_para_timeline'
- 'create terms in uw_tax_event_tags'
- 'create terms in uw_tax_event_type'
- 'create terms in uw_vocab_audience'
......@@ -63,6 +64,7 @@ permissions:
- 'delete paragraph content uw_para_fact_text'
- 'delete paragraph content uw_para_facts_and_figures'
- 'delete paragraph content uw_para_ff'
- 'delete paragraph content uw_para_timeline'
- 'edit any uw_ct_blog content'
- 'edit any uw_ct_catalog_item content'
- 'edit any uw_ct_event content'
......@@ -103,6 +105,7 @@ permissions:
- 'update paragraph content uw_para_fact_text'
- 'update paragraph content uw_para_facts_and_figures'
- 'update paragraph content uw_para_ff'
- 'update paragraph content uw_para_timeline'
- 'use uw_workflow transition needs_review'
- 'use workbench access'
- 'view all media revisions'
......
......@@ -39,6 +39,7 @@ permissions:
- 'create paragraph content uw_para_fact_text'
- 'create paragraph content uw_para_facts_and_figures'
- 'create paragraph content uw_para_ff'
- 'create paragraph content uw_para_timeline'
- 'create terms in uw_tax_event_tags'
- 'create terms in uw_tax_event_type'
- 'create terms in uw_vocab_audience'
......@@ -64,6 +65,7 @@ permissions:
- 'delete paragraph content uw_para_fact_text'
- 'delete paragraph content uw_para_facts_and_figures'
- 'delete paragraph content uw_para_ff'
- 'delete paragraph content uw_para_timeline'
- 'edit any uw_ct_blog content'
- 'edit any uw_ct_catalog_item content'
- 'edit any uw_ct_event content'
......@@ -104,6 +106,7 @@ permissions:
- 'update paragraph content uw_para_fact_text'
- 'update paragraph content uw_para_facts_and_figures'
- 'update paragraph content uw_para_ff'
- 'update paragraph content uw_para_timeline'
- 'use uw_workflow transition archived'
- 'use uw_workflow transition draft'
- 'use uw_workflow transition needs_review'
......
......@@ -40,6 +40,7 @@ permissions:
- 'create paragraph content uw_para_fact_text'
- 'create paragraph content uw_para_facts_and_figures'
- 'create paragraph content uw_para_ff'
- 'create paragraph content uw_para_timeline'
- 'create terms in uw_tax_event_tags'
- 'create terms in uw_tax_event_type'
- 'create terms in uw_vocab_audience'
......@@ -83,6 +84,7 @@ permissions:
- 'delete paragraph content uw_para_fact_text'
- 'delete paragraph content uw_para_facts_and_figures'
- 'delete paragraph content uw_para_ff'
- 'delete paragraph content uw_para_timeline'
- 'delete terms in uw_tax_event_tags'
- 'delete terms in uw_tax_event_type'
- 'delete terms in uw_vocab_audience'
......@@ -134,6 +136,7 @@ permissions:
- 'update paragraph content uw_para_fact_text'
- 'update paragraph content uw_para_facts_and_figures'
- 'update paragraph content uw_para_ff'
- 'update paragraph content uw_para_timeline'
- 'use uw_workflow transition archived'
- 'use uw_workflow transition draft'
- 'use uw_workflow transition needs_review'
......
......@@ -43,4 +43,4 @@
box-shadow: none;
border: 1px solid #bfbfba;
padding: 1rem;
}
\ No newline at end of file
}
......@@ -17,7 +17,7 @@ class UwNodeAccessCheck implements AccessInterface {
* A custom access check.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
*
* Route matching.
* @param \Drupal\Core\Session\AccountInterface $account
* Run access checks for this account.
*
......@@ -29,22 +29,26 @@ class UwNodeAccessCheck implements AccessInterface {
// Get the node object, which is in the route match variable.
$node = $route_match->getParameter('node');
// Check if this is a sidebar content type and if the user has permission to edit the content type.
// We want to throw a 404 (NotFoundHttpException) if they do not have access. This is the case when
// a user is not logged in, and when they do not have permission to edit it.
// Check if this is a sidebar content type and if the user has permission
// to edit the content type. We want to throw a 404 (NotFoundHttpException)
// if they do not have access. This is the case when a user is not logged
// in, and when they do not have permission to edit it.
if ($node && $node->bundle() == 'uw_ct_sidebar' && !$account->hasPermission('edit any uw_ct_sidebar content')) {
throw new NotFoundHttpException();
}
// Check if this is a sidebar content type and if the user has permission to edit the content type.
// We want to throw a 404 (NotFoundHttpException) if they do not have access. This is the case when
// a user is not logged in, and when they do not have permission to edit it.
// Check if this is a sidebar content type and if the user has permission
// to edit the content type. We want to throw a 404 (NotFoundHttpException)
// if they do not have access. This is the case when a user is not logged
// in, and when they do not have permission to edit it.
if ($node && $node->bundle() == 'uw_ct_site_footer' && !$account->hasPermission('edit any uw_ct_site_footer content')) {
throw new NotFoundHttpException();
}
// We have to return some type of access, so we are going to return allowed, if they do not have access,
// the new exception is going to be thrown above.
// We have to return some type of access, so we are going to return
// allowed, if they do not have access, the new exception is going to be
// thrown above.
return AccessResult::allowed();
}
}
......@@ -54,7 +54,6 @@ class UwContentModerationForm extends ConfirmFormBase {
);
}
/**
* {@inheritdoc}
*/
......@@ -84,9 +83,9 @@ class UwContentModerationForm extends ConfirmFormBase {
$options = ['absolute' => TRUE];
// Return the URL back to the node.
$url = Url::fromRoute('entity.node.canonical', ['node' => $this->nid], $options);
$url = Url::fromRoute('entity.node.canonical', ['node' => $this->nid], $options);
// Adding the redirect back to the node
// Adding the redirect back to the node.
$form_state->setRedirectUrl($url);
// Set the message that the permissions have been saved.
......@@ -122,4 +121,5 @@ class UwContentModerationForm extends ConfirmFormBase {
// Return the URL back to the node.
return Url::fromRoute('entity.node.canonical', ['node' => $this->nid], $options);
}
}
......@@ -34,4 +34,5 @@ class Uw2ColumnLayout extends UwColumnLayoutBase {
return $form;
}
}
......@@ -37,4 +37,5 @@ class Uw3ColumnLayout extends UwColumnLayoutBase {
return $form;
}
}
......@@ -37,4 +37,5 @@ class Uw4ColumnLayout extends UwColumnLayoutBase {
return $form;
}
}
......@@ -17,7 +17,10 @@ class UwColumnLayoutBase extends LayoutDefault implements PluginFormInterface {
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// Set the column class in the config.
$this->configuration['column_class'] = $form_state->getValue(['layout_settings', 'column_class'], NULL);
$this->configuration['column_class'] = $form_state->getValue(
['layout_settings', 'column_class'],
NULL
);
}
/**
......
<?php
namespace Drupal\uw_cfg_common\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
/**
* Listens to the dynamic route events.
*/
class UwNodeAccessRouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
// Change the route associated with node (/node/{nid}).
if ($route = $collection->get('entity.node.canonical')) {
$route->setRequirement('_custom_access', 'Drupal\uw_cfg_common\Access\UwNodeAccessCheck::access');
}
}
}
\ No newline at end of file
<?php
namespace Drupal\uw_cfg_common\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
/**
* Listens to the dynamic route events.
*/
class UwNodeAccessRouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
// Change the route associated with node (/node/{nid}).
if ($route = $collection->get('entity.node.canonical')) {
$route->setRequirement('_custom_access', 'Drupal\uw_cfg_common\Access\UwNodeAccessCheck::access');
}
}
}
......@@ -3,11 +3,12 @@
namespace Drupal\uw_cfg_common\Service;
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
/**
* Class UWService
* Class UWService.
*
* UW Service that holds common functionality used by uw blocks.
*
* @package Drupal\uw_cfg_common\Service
*/
......
......@@ -6,9 +6,9 @@ use Drupal\Core\Entity\EntityInterface;
use Drupal\node\NodeInterface;
/**
* Interface UWServiceInterface
* Interface UWServiceInterface.
*
* Interface that is collection of common functions used throughout custom blocks.
* Interface that is collection of common functions used in custom blocks.
*
* @package Drupal\uw_cfg_common\Service
*/
......@@ -41,4 +41,5 @@ interface UWServiceInterface {
* Array of variables and their values.
*/
public function getTeaserContent(NodeInterface $node, array $variables_to_get, string $teaser_type): array;
}
......@@ -6,6 +6,8 @@ use Drupal\user\Entity\Role;
/**
* Class UwPermissions.
*
* UW Specific permissions.
*/
class UwPermissions {
......@@ -54,65 +56,135 @@ class UwPermissions {
// Blog permissions.
'Blog' => [
'Use content type' =>
UwPermissions::buildRolePermissionsListContentType('uw_ct_blog'),
UwPermissions::buildRolePermissionsListContentType(
'uw_ct_blog'
),
'Create/edit tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_blog_tags', ['create', 'edit']),
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_blog_tags',
['create', 'edit']
),
'Delete tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_blog_tags', ['delete']),
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_blog_tags',
['delete']
),
],
// Catalog permissions.
'Catalog' => [
'Use content type' => UwPermissions::buildRolePermissionsListContentType('uw_ct_catalog_item'),
'Create/edit audience' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_audience', ['create', 'edit']),
'Delete audience' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_audience', ['delete']),
'Create/edit categories' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_catalog_categories', ['create', 'edit']),
'Delete categories' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_catalog_categories', ['delete']),
'Create/edit catalogs' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_catalogs', ['create', 'edit']),
'Delete catalogs' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_catalogs', ['delete']),
'Use content type' =>
UwPermissions::buildRolePermissionsListContentType(
'uw_ct_catalog_item'
),
'Create/edit audience' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_audience',
['create', 'edit']
),
'Delete audience' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_audience',
['delete']
),
'Create/edit categories' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_catalog_categories',
['create', 'edit']
),
'Delete categories' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_catalog_categories',
['delete']
),
'Create/edit catalogs' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_catalogs',
['create', 'edit']
),
'Delete catalogs' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_catalogs',
['delete']
),
],
// Event permissions.
'Event' => [
'Use content type' => UwPermissions::buildRolePermissionsListContentType('uw_ct_event'),
'Create/edit tags' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_tax_event_tags', ['create', 'edit']),
'Delete tags' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_tax_event_tags', ['delete']),
'Create/edit types' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_tax_event_type', ['create', 'edit']),
'Delete types' => UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_tax_event_type', ['delete']),
'Use content type' =>
UwPermissions::buildRolePermissionsListContentType(
'uw_ct_event'
),
'Create/edit tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_tax_event_tags',
['create', 'edit']
),
'Delete tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_tax_event_tags',
['delete']
),
'Create/edit types' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_tax_event_type',
['create', 'edit']
),
'Delete types' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_tax_event_type',
['delete']
),
],
// News permissions.
'News' => [
'Use content type' =>
UwPermissions::buildRolePermissionsListContentType('uw_ct_news_item'),
UwPermissions::buildRolePermissionsListContentType(
'uw_ct_news_item'
),
'Create/edit tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_news_tags', ['create', 'edit']),
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_news_tags',
['create', 'edit']
),
'Delete tags' =>
UwPermissions::buildRolePermissionsListTaxonomyTerm('uw_vocab_news_tags', ['delete']),
UwPermissions::buildRolePermissionsListTaxonomyTerm(
'uw_vocab_news_tags',
['delete']
),
],
// Sidebar permissions.
'Sidebar' => [
'Use content type' =>
UwPermissions::buildRolePermissionsListContentType('uw_ct_sidebar'),
UwPermissions::buildRolePermissionsListContentType(
'uw_ct_sidebar'
),
],
// Site footer permissions.
'Site footer' => [
'Use content type' =>
UwPermissions::buildRolePermissionsListContentType('uw_ct_site_footer'),
UwPermissions::buildRolePermissionsListContentType(
'uw_ct_site_footer'
),
],
// Special alert permissions.
'Special alert' => [
'Use content type' =>
UwPermissions::buildRolePermissionsListCustom('administer special alert'),
UwPermissions::buildRolePermissionsListCustom(
'administer special alert'
),
],
// Web page permissions.
'Web page' => [
'Use content type' =>
UwPermissions::buildRolePermissionsListContentType('uw_ct_web_page'),
UwPermissions::buildRolePermissionsListContentType(
'uw_ct_web_page'
),
],
];
......
......@@ -5,6 +5,7 @@
* Install, update and uninstall for Configuration of all common WCMS.
*/
use Drupal\taxonomy\Entity\Term;
use Drupal\uw_cfg_common\UwPermissions\UwPermissions;
/**
......@@ -53,7 +54,7 @@ function uw_cfg_common_install() {
'Site manager',
'Content author',
'Content editor',
],
],
'Delete catalogs' => [
'Site manager',
],
......@@ -137,29 +138,29 @@ function uw_cfg_common_install() {
'Future undergraduate students',
'Future graduate students',
],
'Faculty',
'Staff',
'Alumni',
'Parents',
'Donors | Friends | Supporters',
'Employers',
'International',
'Media',
'Faculty' => 'Faculty',
'Staff' => 'Staff',
'Alumni' => 'Alumni',
'Parents' => 'Parents',
'Donors | Friends | Supporters' => 'Donors | Friends | Supporters',
'Employers' => 'Employers',
'International' => 'International',
'Media' => 'Media',
];
$weight = 0;
foreach ($terms as $key => $term) {
if (is_array($term)) {
$parent = _uw_cfg_common_create_term($key, 'uw_vocab_audience', $weight, []);
if (is_array($term)) {
$parent = _uw_cfg_common_create_term($key, 'uw_vocab_audience', $weight, []);
foreach ($term as $child) {
_uw_cfg_common_create_term($child, 'uw_vocab_audience', $weight, [$parent]);
}
}
else {
_uw_cfg_common_create_term($term, 'uw_vocab_audience', $weight, []);
}
$weight++;
foreach ($term as $child) {
_uw_cfg_common_create_term($child, 'uw_vocab_audience', $weight, [$parent]);
}
}
else {
_uw_cfg_common_create_term($term, 'uw_vocab_audience', $weight, []);
}
$weight++;
}
}
......@@ -179,20 +180,24 @@ function uw_cfg_common_install() {
* $term_id = _nodemaker_term_create('My Term', 'my_vocab', 0, [999]);
* @endcode
*
* @param string $term
* @param string $taxonomy_name
* - Term Name.
* @param string $vocabulary
* @param string $vocab_machine_name
* - System id of the vocabulary term will be added to.
* @param array $parent
* @param string|int $weight
* - Taxonomy term weight.
* @param array $parent_tid
* - Array of term ids to be assigned as parent.
*
* @return int|null
* - Returns the term id of the created term on success, null on failure.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
function _uw_cfg_common_create_term($taxonomy_name, $vocab_machine_name, $weight, array $parent_tid = []) {
// Create the taxonomy term.
$new_term = Drupal\taxonomy\Entity\Term::create([
$new_term = Term::create([
'name' => $taxonomy_name,
'vid' => $vocab_machine_name,
'parent' => $parent_tid,
......
......@@ -201,7 +201,7 @@ function uw_cfg_common_preprocess_node(&$variables) {
$access_result = $plugin_block->access(\Drupal::currentUser());
// Return empty render array if user doesn't have access.
// $access_result can be boolean or an AccessResult class
// $access_result can be boolean or an AccessResult class.
if (is_object($access_result) && $access_result->isForbidden() || is_bool($access_result) && !$access_result) {
return [];
}
......@@ -211,4 +211,3 @@ function uw_cfg_common_preprocess_node(&$variables) {
$variables['uw_content_moderation_form'] = $render;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment