-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_recur.api.php
More file actions
94 lines (89 loc) · 2.93 KB
/
node_recur.api.php
File metadata and controls
94 lines (89 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* Implements hook_node_recur_access_alter().
*
* Alter the access control for the node recur form
*
* @param &$access
* Boolean status of access for the current user.
* @param $node
* The node being recurred.
*/
function hook_node_recur_access_alter(&$access, $node) {
if ($node->getType() == 'story') {
$access = TRUE;
}
}
/**
* Implements hook_node_recur_batch_redirect_alter().
*
* Alter redirect path after a batch operation. This is only invoked
* when recurring existing nodes, not new nodes.
*
* @param &$path
* The path that the user will be redirected to after recurring a node.
* @param $nid
* The nid of the node being recurred.
*/
function hook_node_recur_batch_redirect_alter(&$path, $nid = NULL) {
$path = 'node/' . $nid . '/edit';
}
/**
* Implements hook_node_recur_validate_dates().
*
* This hook is invoked when validating the node recur date form. It will
* only be called if there are no recorded validation errors found by
* this module.
*
* @param $node
* The node being recurred.
* @param $form_state
* The form's form state array.
* @return
* An array of errors to be printed to the screen. Each error is an
* array with the keys 'field' (the name of the field) and 'error'
* (the message to print to the screen).
*/
function hook_node_recur_validate_dates($node, $form_state) {
$errors = array();
if ($node->getType() == 'class') {
if ($form_state->getValues('option') == 'days') {
if (isset($form_state->getValues('days')['monday'])) {
$errors[] = array(
'field' => 'days',
'message' => t('Classes cannot occur on Monday.'),
);
}
if (isset($form_state->getValues('days')['tuesday'])) {
$errors[] = array(
'field' => 'days',
'message' => t('Classes cannot occur on Tuesday.'),
);
}
}
}
return $errors;
}
/**
* Implements hook_node_recur_dates_alter().
*
* Modify the recurring dates before they are used to recur nodes.
*
* @param &$dates
* An array of start and end dates, keyed by 'start' and 'end'. The
* dates are in timestamp format.
* @param $variables
* An array of variables supplied by and generated by the node recur
* form. The possible available values are:
* node: The node being recurred.
* start_date: The initial starting date of the node (ie, '2012-10-22 15:45:00').
* end_date: The initial ending date of the node, if one exists (ie, '2012-10-22 16:45:00').
* option: The recurring option selected.
* until: The date (timestamp) to recur until.
* days: An array of days selected, if the 'days' option was used.
* frequency: The selected frequency, if the 'rules' option was used.
* period: The selected period, if the 'rules' option was used.
* weekends: TRUE if weekends should be included, otherwise FALSE, if the 'rules' option was used.
*/
function hook_node_recur_dates_alter(&$dates, $variables) {
}