Révision cfceb792
Ajouté par Assos Assos il y a plus de 4 ans
drupal7/sites/all/modules/acl/CHANGELOG.txt | ||
---|---|---|
5 | 5 |
acl 7.x-1.x-dev: |
6 | 6 |
|
7 | 7 |
|
8 |
acl 7.x-1.2 (2019-09-14): |
|
9 |
Enhancement: |
|
10 |
- #3080658 by salvis: Add acl_edit_form_get_user_list() function. |
|
11 |
- #3068936 by salvis: Implement acl_get_usernames($acl_id). |
|
12 |
Fixes: |
|
13 |
- #1147226 by Sutharsan: Document hook_enabled(). |
|
14 |
- #1815158 by salvis: Fix PDO error under PostgreSQL & MS SQL Server. |
|
15 |
- #2580207 by mccrodp: Add missing acl_remove_all_users() function. |
|
16 |
- #2612464 by heykarthikwithu, salvis: Remove of unused variables in the code base. |
|
17 |
|
|
18 |
|
|
8 | 19 |
acl 7.x-1.1 (2015-08-27): |
9 | 20 |
Enhancements: |
10 | 21 |
- Improve minor coding nits (no functional changes). |
... | ... | |
14 | 25 |
- Enable the tests (no functional change). |
15 | 26 |
- #1397828: Improve documentation of acl_edit_form() (no functional change). |
16 | 27 |
|
17 |
|
|
18 | 28 |
acl 7.x-1.0 (2011-11-26): |
19 | 29 |
Enhancements: |
20 | 30 |
- Add acl_node_add_acl_record() function to support extending the {acl_node} table. |
drupal7/sites/all/modules/acl/acl.admin.inc | ||
---|---|---|
5 | 5 |
* Implementations of administration functions for the acl module. |
6 | 6 |
*/ |
7 | 7 |
|
8 |
/** |
|
9 |
* Implementation of acl_get_usernames(). |
|
10 |
*/ |
|
11 |
function _acl_get_usernames($acl_id) { |
|
12 |
$users = array(); |
|
13 |
$result = db_query("SELECT u.uid, u.name FROM {users} u LEFT JOIN {acl_user} aclu ON aclu.uid = u.uid WHERE acl_id = :acl_id", array( |
|
14 |
'acl_id' => $acl_id)); |
|
15 |
foreach ($result as $user) { |
|
16 |
$users[$user->uid] = _acl_format_username($user); |
|
17 |
} |
|
18 |
return $users; |
|
19 |
} |
|
20 |
|
|
8 | 21 |
/** |
9 | 22 |
* Implementation of acl_edit_form(). |
10 | 23 |
*/ |
... | ... | |
17 | 30 |
))->fetchAssoc())) { |
18 | 31 |
return array(); |
19 | 32 |
} |
20 |
$result = db_query("SELECT u.uid, u.name FROM {users} u LEFT JOIN {acl_user} aclu ON aclu.uid = u.uid WHERE acl_id = :acl_id", array( |
|
21 |
'acl_id' => $acl_id)); |
|
22 |
foreach ($result as $user) { |
|
23 |
$users[$user->uid] = $user->name; |
|
24 |
} |
|
33 |
$users = _acl_get_usernames($acl_id); |
|
25 | 34 |
} |
26 | 35 |
if (!isset($label)) { |
27 | 36 |
$label = (isset($record['name']) ? $record['name'] : (isset($record['number']) ? $record['number'] : $acl_id)); |
... | ... | |
81 | 90 |
// We can't use the form values because it's the entire structure |
82 | 91 |
// and we have no clue where our values actually are. That's |
83 | 92 |
// ok tho cause #value still works for us. |
84 |
$user_list = unserialize($form['user_list']['#value']); |
|
85 |
$button_name = 'acl_' . $form['acl_id']['#value']; |
|
93 |
$user_list = acl_edit_form_get_user_list($form); |
|
86 | 94 |
|
87 | 95 |
if (isset($form_state['triggering_element']) && $form_state['triggering_element']['#value'] == $form['delete_button']['#value']) { |
88 | 96 |
$deletions = $form['deletions']['#value']; |
... | ... | |
99 | 107 |
form_error($form['add'], t("Invalid user specified.")); |
100 | 108 |
} |
101 | 109 |
else { |
102 |
$user_list[$user->uid] = $user->name;
|
|
110 |
$user_list[$user->uid] = _acl_format_username($user);
|
|
103 | 111 |
$form['add']['#value'] = NULL; |
104 | 112 |
} |
105 | 113 |
} |
... | ... | |
125 | 133 |
* The module that embedded our form must call this function! |
126 | 134 |
*/ |
127 | 135 |
function acl_save_form($form, $priority = NULL) { |
128 |
$users = unserialize($form['user_list']);
|
|
136 |
$users = acl_edit_form_get_user_list($form);
|
|
129 | 137 |
db_delete('acl_user') |
130 | 138 |
->condition('acl_id', $form['acl_id']) |
131 | 139 |
->execute(); |
... | ... | |
147 | 155 |
} |
148 | 156 |
} |
149 | 157 |
|
158 |
/** |
|
159 |
* Decode and return the list of users. |
|
160 |
* |
|
161 |
* @param array $form |
|
162 |
* The ACL form or form_state array. |
|
163 |
* @param bool $get_default |
|
164 |
* (optional) In the case of a form array, whether to return the |
|
165 |
* '#default_value' (or the '#value'). |
|
166 |
* |
|
167 |
* @return array |
|
168 |
* An array of $uid => $username. |
|
169 |
*/ |
|
170 |
function acl_edit_form_get_user_list($form, $get_default = FALSE) { |
|
171 |
if (is_array($form['user_list'])) { |
|
172 |
return unserialize($form['user_list'][$get_default ? '#default_value' : '#value']); |
|
173 |
} |
|
174 |
return unserialize($form['user_list']); |
|
175 |
} |
|
176 |
|
drupal7/sites/all/modules/acl/acl.api.php | ||
---|---|---|
15 | 15 |
return "ACL (id=$acl_id) grants access to $name/$number to the listed user(s)."; |
16 | 16 |
} |
17 | 17 |
|
18 |
/** |
|
19 |
* Inform ACL module that the client module is enabled. |
|
20 |
* |
|
21 |
* ACL will not return its NA records for your module if your module does not |
|
22 |
* confirm that it's active. |
|
23 |
* |
|
24 |
* If you use the example below, you can disable ACL on hook_disable using: |
|
25 |
* @code |
|
26 |
* function MYMODULE_disable() { |
|
27 |
* MYMODULE_enabled(FALSE); |
|
28 |
* } |
|
29 |
* @endcode |
|
30 |
*/ |
|
31 |
function hook_enabled($set = NULL) { |
|
32 |
static $enabled = TRUE; // not drupal_static! |
|
33 |
|
|
34 |
if ($set !== NULL) { |
|
35 |
$enabled = $set; |
|
36 |
} |
|
37 |
return $enabled; |
|
38 |
} |
drupal7/sites/all/modules/acl/acl.info | ||
---|---|---|
5 | 5 |
|
6 | 6 |
files[] = tests/acl.test |
7 | 7 |
|
8 |
; Information added by Drupal.org packaging script on 2015-08-26
|
|
9 |
version = "7.x-1.1"
|
|
8 |
; Information added by Drupal.org packaging script on 2019-09-14
|
|
9 |
version = "7.x-1.2"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "acl" |
12 |
datestamp = "1440633240" |
|
13 |
|
|
12 |
datestamp = "1568440086" |
drupal7/sites/all/modules/acl/acl.module | ||
---|---|---|
87 | 87 |
->execute(); |
88 | 88 |
} |
89 | 89 |
|
90 |
/** |
|
91 |
* Remove all users from an ACL. |
|
92 |
*/ |
|
93 |
function acl_remove_all_users($acl_id) { |
|
94 |
db_delete('acl_user') |
|
95 |
->condition('acl_id', $acl_id) |
|
96 |
->execute(); |
|
97 |
} |
|
98 |
|
|
90 | 99 |
/** |
91 | 100 |
* Provide a form to edit the ACL that can be embedded in other forms. |
92 | 101 |
* |
... | ... | |
112 | 121 |
$subselect->addExpression((int) $update, 'grant_update'); |
113 | 122 |
$subselect->addExpression((int) $delete, 'grant_delete'); |
114 | 123 |
$subselect->addExpression($priority, 'priority'); |
115 |
db_insert('acl_node') |
|
116 |
->from($subselect) |
|
117 |
->execute(); |
|
124 |
$query = db_insert('acl_node') |
|
125 |
->fields(array('nid', 'acl_id', 'grant_view', 'grant_update', 'grant_delete', 'priority')); |
|
126 |
foreach ($subselect->execute()->fetchAll(PDO::FETCH_ASSOC) as $record) { |
|
127 |
$query->values($record); |
|
128 |
} |
|
129 |
$query->execute(); |
|
118 | 130 |
} |
119 | 131 |
|
120 | 132 |
/** |
... | ... | |
241 | 253 |
return $uids; |
242 | 254 |
} |
243 | 255 |
|
256 |
/** |
|
257 |
* Get the user names of an ACL. |
|
258 |
*/ |
|
259 |
function acl_get_usernames($acl_id) { |
|
260 |
_acl_module_load_include('admin.inc'); |
|
261 |
return _acl_get_usernames($acl_id); |
|
262 |
} |
|
263 |
|
|
244 | 264 |
/** |
245 | 265 |
* Implements hook_node_access_records(). |
246 | 266 |
*/ |
... | ... | |
308 | 328 |
static $loaded = array(); |
309 | 329 |
|
310 | 330 |
if (!isset($loaded[$type])) { |
311 |
$path = module_load_include($type, 'acl');
|
|
331 |
module_load_include($type, 'acl'); |
|
312 | 332 |
$loaded[$type] = drupal_get_path('module', 'acl') . "/acl.$type"; |
313 | 333 |
} |
314 | 334 |
return $loaded[$type]; |
... | ... | |
335 | 355 |
$acl->tag = $acl->name . '-' . $acl->number; |
336 | 356 |
} |
337 | 357 |
foreach (user_load_multiple(acl_get_uids($row->gid)) as $account) { |
338 |
$usernames[] = theme('username', array('account' => $account));
|
|
358 |
$usernames[] = _acl_format_username($account);
|
|
339 | 359 |
} |
340 | 360 |
if (isset($usernames)) { |
341 | 361 |
$usernames = implode(', ', $usernames); |
... | ... | |
373 | 393 |
return $text; |
374 | 394 |
} |
375 | 395 |
|
396 |
/** |
|
397 |
* Helper function to format a user name. |
|
398 |
*/ |
|
399 |
function _acl_format_username($account) { |
|
400 |
return check_plain(format_username($account)); |
|
401 |
} |
|
402 |
|
drupal7/sites/all/modules/acl/tests/acl_node_test.info | ||
---|---|---|
8 | 8 |
|
9 | 9 |
files[] = acl_node_test.module |
10 | 10 |
|
11 |
; Information added by Drupal.org packaging script on 2015-08-26
|
|
12 |
version = "7.x-1.1"
|
|
11 |
; Information added by Drupal.org packaging script on 2019-09-14
|
|
12 |
version = "7.x-1.2"
|
|
13 | 13 |
core = "7.x" |
14 | 14 |
project = "acl" |
15 |
datestamp = "1440633240" |
|
16 |
|
|
15 |
datestamp = "1568440086" |
Formats disponibles : Unified diff
Weekly update of contrib modules