-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: RSVP List | ||
description: Allows users to RSVP for Events and provides a contact list for Administrators. | ||
package: FZ | ||
configure: rsvplist.admin_settings | ||
|
||
type: module | ||
core_version_requirement: ^8.8.0 || ^9.0 | ||
version: 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
function rsvplist_schema() { | ||
$schema['rsvplist'] = [ | ||
'description' => 'Stores email, timestamp, nid and uid for an rsvp', | ||
'fields' => [ | ||
'id' => [ | ||
'description' => 'The primary identifer for the record.', | ||
'type' => 'serial', | ||
'unsigned' => TRUE, | ||
'not null' => TRUE, | ||
], | ||
'uid' => [ | ||
'description' => 'The {users}.uid that added this rsvp.', | ||
'type' => 'int', | ||
'not null' => TRUE, | ||
'default' => 0, | ||
], | ||
'nid' => [ | ||
'description' => 'The {node}.nid for this rsvp.', | ||
'type' => 'varchar', | ||
'length' => 64, | ||
'not null' => FALSE, | ||
'default' => 0, | ||
], | ||
'mail' => [ | ||
'description' => 'User\'s email address.', | ||
'type' => 'varchar', | ||
'length' => 64, | ||
'not null' => FALSE, | ||
'default' => '', | ||
], | ||
'created' => [ | ||
'description' => 'Timestamp for when rsvp was created.', | ||
'type' => 'int', | ||
'not null' => TRUE, | ||
'default' => 0, | ||
], | ||
], | ||
'primary key' => ['id'], | ||
'indexes' => [ | ||
'node' => ['nid'], | ||
'node_user' => ['nid', 'uid'], | ||
], | ||
]; | ||
|
||
$schema['rsvplist_enabled'] = [ | ||
'description' => 'Tracks wheter rsvplist is enabled for a node.', | ||
'fields' => [ | ||
'nid' => [ | ||
'description' => 'The {node}.id that has rsvplist enabled.', | ||
'type' => 'int', | ||
'not null' => TRUE, | ||
'default' => 0, | ||
], | ||
], | ||
'primary key' => ['nid'], | ||
]; | ||
return $schema; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
rsvplist.admin_settings: | ||
title: 'RSVP List Settings' | ||
description: 'Control the display of RSVP Form' | ||
route_name: rsvplist.admin_settings | ||
parent: system.admin_config_content | ||
weight: 10 | ||
|
||
rsvplist.report: | ||
title: 'List of RSVP Submissions' | ||
description: 'View Listing of RSVPs' | ||
route_name: rsvplist.report | ||
parent: system.admin_reports | ||
weight: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Implements hook_form_alter() | ||
* Alter the form Add/Edit form to include admin setting for displaying | ||
* RSVPBlock with content | ||
*/ | ||
|
||
function rsvplist_form_node_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $formState, $form_id) { | ||
$node = $formState->getFormObject()->getEntity(); | ||
$current_node_type = $node->getType(); | ||
$config = \Drupal::config('rsvplist.settings'); | ||
$types = $config->get('allowed_types', []); | ||
// RSVP options for administrators | ||
if (in_array($current_node_type, $types)) { | ||
$form['rsvplist'] = [ | ||
'#type' => 'details', | ||
'#title' => t('RSVP Collections'), | ||
'#access' => \Drupal::currentUser()->hasPermission('administer rsvplist'), | ||
'#group' => 'advanced', | ||
'#weight' => 100, | ||
]; | ||
/** @var \Drupal\rsvplist\EnablerService $enabler */ | ||
$enabler = Drupal::service('rsvplist.enabler'); | ||
$form['rsvplist']['rsvplist_enabled'] = [ | ||
'#type' => 'checkbox', | ||
'#title' => t('Collect RSVP e-mail addresses for this node.'), | ||
'#default_value' => $enabler->isEnabled($node), | ||
]; | ||
foreach (array_keys($form['actions']) as $action) { | ||
if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') { | ||
$form['actions'][$action]['#submit'][] = 'rsvplist_form_node_form_submit'; | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Form submission handler for RSVP item field on the node form. | ||
* | ||
* @see \rsvplist_form_node_form_alter() | ||
*/ | ||
function rsvplist_form_node_form_submit(&$form, \Drupal\Core\Form\FormStateInterface $formState) { | ||
/** @var \Drupal\rsvplist\EnablerService $enabler */ | ||
$enabler = Drupal::service('rsvplist.enabler'); | ||
$node = $formState->getFormObject()->getEntity(); | ||
if ($enabled = $formState->getValue('rsvplist_enabled')) { | ||
$enabler->setEnabled($node); | ||
} | ||
else { | ||
$enabler->delEnabled($node); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
view rsvplist: | ||
title: 'View RSVP Form' | ||
description: 'View and Submit the RSVP Form' | ||
access rsvplist report: | ||
title: 'Acess List of RSVPs' | ||
description: 'View the report listing all RSVPs Submitted.' | ||
administer rsvplist: | ||
title: 'Administer RSVP Settings' | ||
description: 'Access the RSVP Administrative settings page.' | ||
restrict access: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# We moved this to a block | ||
#rsvplist.form: | ||
# path: '/rsvplist' | ||
# defaults: | ||
# _form: '\Drupal\rsvplist\Form\RSVPForm' | ||
# _title: 'RSVP to this Event' | ||
# requirements: | ||
# _permission: 'view rsvplist' | ||
rsvplist.admin_settings: | ||
path: '/admin/config/content/rsvplist' | ||
defaults: | ||
_form: '\Drupal\rsvplist\Form\RSVPSettingsForm' | ||
_title: 'RSVP List Settings' | ||
requirements: | ||
_permission: 'administer rsvplist' | ||
|
||
rsvplist.report: | ||
path: '/admin/reports/rsvplist' | ||
defaults: | ||
_controller: '\Drupal\rsvplist\Controller\ReportController::report' | ||
_title: 'List of RSVPs' | ||
requirements: | ||
_permission: 'view rsvplist' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
services: | ||
rsvplist.enabler: | ||
class: \Drupal\rsvplist\EnablerService | ||
arguments: [] |