-
Notifications
You must be signed in to change notification settings - Fork 9
/
rooms.api.php
95 lines (89 loc) · 3.38 KB
/
rooms.api.php
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
95
<?php
/**
* @file
* This file contains no working PHP code; it exists to provide additional
* documentation for doxygen as well as to document hooks in the standard
* Drupal manner.
*/
/**
* Allows modules to deny or provide access for a user to perform a non-view
* operation on an entity before any other access check occurs.
*
* Modules implementing this hook can return FALSE to provide a blanket
* prevention for the user to perform the requested operation on the specified
* entity. If no modules implementing this hook return FALSE but at least one
* returns TRUE, then the operation will be allowed, even for a user without
* role based permission to perform the operation.
*
* If no modules return FALSE but none return TRUE either, normal permission
* based checking will apply.
*
* @param $op
* The request operation: update, create, or delete.
* @param $entity
* The entity to perform the operation on.
* @param $account
* The user account whose access should be determined.
* @param $entity_type
* The machine-name of the entity type of the given $entity.
*
* @return
* TRUE or FALSE indicating an explicit denial of permission or a grant in the
* presence of no other denials; NULL to not affect the access check at all.
*/
function hook_rooms_entity_access($op, $entity, $account, $entity_type) {
// No example.
}
/**
* Allows modules to alter the conditions used on the query to grant view access
* to a Rooms entity of the specified ENTITY TYPE.
*
* The Rooms module defines a generic implementation of hook_query_alter() to
* determine view access for its entities, rooms_entity_access_query_alter().
* This function is called by modules defining Rooms entities from their
* view access altering functions to apply a standard set of permission based
* conditions for determining a user's access to view the given entity.
*
* @param $conditions
* The OR conditions group used for the view access query.
* @param $context
* An array of contextual information including:
* - account: the account whose access to view the entity is being checked
* - entity_type: the type of entity in the query
* - base_table: the name of the table for the entity type
*
* @see rooms_entity_access_query_alter()
*/
function hook_rooms_entity_access_condition_ENTITY_TYPE_alter() {
// No example.
}
/**
* Allows modules to alter the conditions used on the query to grant view access
* to a Rooms entity.
*
* This hook uses the same parameters as the entity type specific hook but is
* invoked after it.
*
* @see hook_rooms_entity_access_condition_ENTITY_TYPE_alter()
*/
function hook_rooms_entity_access_condition_alter() {
// No example.
}
/**
* Allows modules to use contextual information about bookings
* to change what is shown to the user.
*
* @param &$string_suggestions - String suggestions, the suggestion with the
* highest index in the array will be used. The value at index 0 is the
* default value.
* @param $context - Contextual information about the string.
*
* @return mixed
*/
function hook_rooms_string_alter(&$string_suggestions, $context) {
if ($context['#purpose'] == 'rooms_create_line_item') {
// Alter the line item label to add additional information about the unit.
$string_suggestions[] = $string_suggestions[0] . ' maximum guests: ' .
$context['#data']['unit']['unit']->max_sleeps;
}
}