Organic groups time frame
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
Put a time frame on posting and editing content in organic groups.
This module restricts access to group content within a time frame (or time window) specified in date fields attached to the group entity. Depending on how the date field is configured, the date field behaves either as a simple due date or a 'from – to' window.
Usage
Enable the module "Organic groups time frame date field support", add a date field to the group type and set what group content type it should serve as a time frame for. By enabling "Collect end date" the date field serves as a 'from – to' window, and without enabling it, it serves as a simle 'due' date.
Edit your group node/entity and set the date the group content should be allowed access within. Group content of selected type are now only editable in the time frame specified in the group's date field.
date.module's granularity is also honored, which means that if you collect the attributes 'year', 'month' and 'day', the due date will be valid up to and including your selected day, i.e. expire 00:00:00 the next day.
Developers
This package is split into an API module (og_timeframe.module
) and an implementation (og_timeframe_datefield.module
) which works as described above. Implement your own OgTimeframeHandlerInterface
to use different date sources as time frame, and point to your implementation in hook_og_timeframe_handler_info()
.
By extending OgTimeframeDatefieldHandler
in og_timeframe_datefield.module
its easy to point to date fields in other entities. If you have the time frame set up as a date field in a content type referenced from your group entity, you can do something like this:
/**
* Implements hook_og_timeframe_handler_info().
*/
function example_og_timeframe_handler_info() {
// Provide a time frame handler for your content type 'example_content'
// used in groups of type 'example_group'
$handlers['node']['example_group']['node']['example_content'] = array(
'class' => 'ExampleTimeframeHandler',
'date_field_name' => 'field_application_due',
);
return $handlers;
}
class ExampleTimeframeHandler extends OgTimeframeDateFieldHandler {
public function __construct($info) {
// What entity type and bundle is the date field attached to
$this->setFieldInstance('node', 'example_referenced', $info['date_field_name']);
}
/**
* Overrides OgTimeframeHandler::setGroup()
*
* This method lets us have some context to work with.
*/
public function setGroup($group_type, $group) {
parent::setGroup($group_type, $group);
$referenced_node = field_get_items('node', $group, 'field_referenced');
// What entity (content) shall we retrieve the date from.
$target_id = empty($referenced_node) ? null : $referenced_node[0]['target_id'];
$this->setEntityId($target_id);
}
}
See og_timeframe.api.php
for more info.