Revision e9734207
Added by Assos Assos almost 5 years ago
drupal7/sites/all/modules/forum_access/CHANGELOG.txt | ||
---|---|---|
5 | 5 |
forum_access 7.x-1.x-dev: |
6 | 6 |
|
7 | 7 |
|
8 |
forum_access 7.x-1.4 (2019-09-25): |
|
9 |
Bugs fixed: |
|
10 |
- #3003279 by salvis, ron_s: Forum node migration generates warning errors. |
|
11 |
- #3002918 by ron_s: Define primary key for the {forum_access} table. |
|
12 |
- #3068844 by salvis: Fix PhpStorm red flags (no functional change). |
|
13 |
- #3068829 by salvis: Fix Warning: count(): Parameter must be an array or an object that implements Countable in form_process_radios() (line 3183 of includes\form.inc). |
|
14 |
- Avoid notices in a test. |
|
15 |
Enhancement: |
|
16 |
- #3083683 by salvis: Hide inaccessible forums from the forum list. |
|
17 |
- #2958547 by salvis: Support non-forum nodes with optional forum_taxonomy field. |
|
18 |
|
|
19 |
|
|
8 | 20 |
forum_access 7.x-1.3 (2016-08-16): |
9 |
Bug fixed: |
|
21 |
Bugs fixed:
|
|
10 | 22 |
- #2783863: Remove call to non-existent _forum_access_preprocess_comment() function. |
11 | 23 |
- #2463055 by DrCord: Fix 'Use of undefined constant uids' notice. |
12 | 24 |
- #2276445 by Bastlynn: Avoid a notice when a comment pending for notification has been deleted. |
... | ... | |
16 | 28 |
- Avoid a notice on admin/index. |
17 | 29 |
- #1793504 by RedRat: Fix non-translatable string. |
18 | 30 |
|
19 |
|
|
20 | 31 |
forum_access 7.x-1.2 (2012-09-15): |
21 | 32 |
Bug fixed: |
22 | 33 |
- #1775204: Avoid crashing the site if FA encounters CMA 1.x (when the upgrade instructions aren't being followed). |
drupal7/sites/all/modules/forum_access/forum_access.admin.inc | ||
---|---|---|
64 | 64 |
'#type' => 'radios', |
65 | 65 |
'#title' => t('Update the permissions'), |
66 | 66 |
'#description' => t('<em>If</em> you make any node access changes, then each node in this forum needs to be updated. Hover over the radiobuttons for details.'), |
67 |
'#options' => NULL,
|
|
67 |
'#options' => array(0, 1, 2),
|
|
68 | 68 |
0 => array( |
69 | 69 |
'#type' => 'radio', |
70 | 70 |
'#title' => t('for all %count nodes immediately', array('%count' => $count)), |
... | ... | |
401 | 401 |
} |
402 | 402 |
} |
403 | 403 |
$ca_priority = content_access_get_settings('priority', 'forum'); |
404 |
$is_conflict = ($ca_priority >= $fa_priority && !empty($ca_interferes) || $ca_priority > $fa_priority);
|
|
404 |
$is_conflict = (($ca_priority >= $fa_priority && !empty($ca_interferes)) || $ca_priority > $fa_priority);
|
|
405 | 405 |
$variables += array( |
406 | 406 |
'!link' => l(t('@Content_Access configuration for the %content_type type', $variables), 'admin/structure/types/manage/forum/access', array('html' => TRUE)), |
407 | 407 |
'%Advanced' => $tr('Advanced'), |
drupal7/sites/all/modules/forum_access/forum_access.info | ||
---|---|---|
10 | 10 |
|
11 | 11 |
files[] = tests/forum_access.test |
12 | 12 |
|
13 |
; Information added by Drupal.org packaging script on 2016-08-16
|
|
14 |
version = "7.x-1.3"
|
|
13 |
; Information added by Drupal.org packaging script on 2019-09-25
|
|
14 |
version = "7.x-1.4"
|
|
15 | 15 |
core = "7.x" |
16 | 16 |
project = "forum_access" |
17 |
datestamp = "1471309440" |
|
18 |
|
|
17 |
datestamp = "1569441788" |
drupal7/sites/all/modules/forum_access/forum_access.install | ||
---|---|---|
86 | 86 |
'unsigned' => TRUE, |
87 | 87 |
'not null' => TRUE, |
88 | 88 |
'default' => 0), |
89 |
'priority' => array( |
|
89 |
'priority' => array(
|
|
90 | 90 |
'description' => 'The priority of this grant.', |
91 | 91 |
'type' => 'int', |
92 | 92 |
'size' => 'small', |
93 | 93 |
'not null' => TRUE, |
94 | 94 |
'default' => 0)), |
95 |
'indexes' => array( |
|
96 |
'tid' => array('tid'), |
|
97 |
'rid' => array('rid')), |
|
95 |
'primary key' => array('tid', 'rid'), |
|
96 |
'indexes' => array('rid' => array('rid')), |
|
98 | 97 |
'foreign keys' => array( |
99 | 98 |
'tid' => array('taxonomy_term_data' => 'tid'), |
100 | 99 |
'rid' => array('role' => 'rid')), |
... | ... | |
184 | 183 |
function forum_access_update_7002() { |
185 | 184 |
variable_del('forum_access_D5_legacy_mode'); |
186 | 185 |
} |
186 |
|
|
187 |
/** |
|
188 |
* Drop tid index and add primary key to forum_access table. |
|
189 |
*/ |
|
190 |
function forum_access_update_7003() { |
|
191 |
db_drop_index('forum_access', 'tid'); |
|
192 |
db_add_primary_key('forum_access', array('tid', 'rid')); |
|
193 |
} |
drupal7/sites/all/modules/forum_access/forum_access.module | ||
---|---|---|
26 | 26 |
$info = drupal_parse_info_file($path); |
27 | 27 |
$version = (isset($info['version']) ? $info['version'] : $t('Unknown')); |
28 | 28 |
$found = preg_match('/7\.x-([0-9]*)\./', $version, $matches); |
29 |
if ($found && $matches[1] == 1 || !$found) {
|
|
29 |
if (($found && $matches[1] == 1) || !$found) {
|
|
30 | 30 |
$cma = 'Chain Menu Access API'; |
31 | 31 |
$variables = array('@Chain_Menu_Access_API' => $cma, '@module' => url('admin/modules')); |
32 | 32 |
$result[] = array( |
... | ... | |
115 | 115 |
return FALSE; |
116 | 116 |
} |
117 | 117 |
} |
118 |
elseif (is_string($comment)) { |
|
119 |
return FALSE; |
|
120 |
} |
|
118 | 121 |
$node = node_load($comment->nid); |
119 | 122 |
|
120 | 123 |
// The remaining $ops are governed by OR, return FALSE by default. |
... | ... | |
283 | 286 |
} |
284 | 287 |
} |
285 | 288 |
|
289 |
/** |
|
290 |
* Implements hook_form_node_form_alter(). |
|
291 |
* |
|
292 |
* Allows the forum field to be optional on non-forum nodes. |
|
293 |
*/ |
|
294 |
function forum_access_form_node_form_alter(&$form, &$form_state, $form_id) { |
|
295 |
if (isset($form['taxonomy_forums'])) { |
|
296 |
$field = field_info_instance('node', 'taxonomy_forums', $form['type']['#value']); |
|
297 |
// Make the vocabulary required for 'real' forum-nodes. |
|
298 |
if (!$field['required']) { |
|
299 |
$langcode = $form['taxonomy_forums']['#language']; |
|
300 |
$form['taxonomy_forums'][$langcode]['#required'] = FALSE; |
|
301 |
} |
|
302 |
} |
|
303 |
} |
|
304 |
|
|
305 |
/** |
|
306 |
* Implement hook_node_load(). |
|
307 |
* |
|
308 |
* Sets $node->forum_tid to avoid confusing forum_node_view(). |
|
309 |
*/ |
|
310 |
function forum_access_node_load($nodes, $types) { |
|
311 |
foreach ($nodes as $node) { |
|
312 |
if (isset($node->taxonomy_forums) && empty($node->taxonomy_forums) && !isset($node->forum_tid)) { |
|
313 |
$node->forum_tid = NULL; |
|
314 |
} |
|
315 |
} |
|
316 |
} |
|
317 |
|
|
286 | 318 |
/** |
287 | 319 |
* Implements hook_comment_load(). |
288 | 320 |
*/ |
... | ... | |
299 | 331 |
return; |
300 | 332 |
} |
301 | 333 |
|
334 |
/** |
|
335 |
* Implements hook_query_term_access_alter(). |
|
336 |
* |
|
337 |
* @param QueryAlterableInterface $query |
|
338 |
*/ |
|
302 | 339 |
function forum_access_query_term_access_alter(QueryAlterableInterface $query) { |
303 | 340 |
global $user; |
304 | 341 |
|
... | ... | |
310 | 347 |
$op = 'view'; |
311 | 348 |
} |
312 | 349 |
|
313 |
// If $account can bypass node access, or there are no node access
|
|
314 |
// modules, we don't need to alter the query.
|
|
315 |
if (user_access('bypass node access', $account)) { |
|
350 |
// If $account can bypass node access, we let them administer the full forum
|
|
351 |
// structure and see the nodes, i.e. we don't restrict the query.
|
|
352 |
if (user_access('bypass node access', $account) && (strpos(current_path(), 'admin/structure/forum') === 0 || strpos(current_path(), 'node/') === 0)) {
|
|
316 | 353 |
return; |
317 | 354 |
} |
318 | 355 |
|
... | ... | |
331 | 368 |
// The node_access table has the access grants for any given node. |
332 | 369 |
$access_alias = $query->leftJoin('forum_access', 'fa', '%alias.tid = ' . $talias . '.tid'); |
333 | 370 |
$acl_alias = $query->leftJoin('acl', 'acl', "%alias.number = $talias.tid AND %alias.module = 'forum_access'"); |
334 |
$aclu_alias = $query->leftJoin('acl_user', 'aclu', "%alias.acl_id = $acl_alias.acl_id AND %alias.uid = $account->uid"); |
|
335 |
$query->condition(db_or() |
|
336 |
->isNull("$access_alias.rid") |
|
337 |
->condition(db_and() |
|
338 |
->condition("$access_alias.rid", $rids, 'IN') |
|
339 |
->condition("$access_alias.grant_$op", 1, '>=')) |
|
340 |
->condition("$aclu_alias.uid", $account->uid)); |
|
371 |
if (user_access('bypass node access', $account)) { |
|
372 |
// If $account can bypass node access, we allow access if any role or |
|
373 |
// account has access. |
|
374 |
$aclu_alias = $query->leftJoin('acl_user', 'aclu', "%alias.acl_id = $acl_alias.acl_id"); |
|
375 |
$query->condition(db_or() |
|
376 |
->isNull("$access_alias.rid") |
|
377 |
->condition("$access_alias.grant_$op", 1, '>=') |
|
378 |
->isNotNull("$aclu_alias.uid") |
|
379 |
); |
|
380 |
} |
|
381 |
else { |
|
382 |
$aclu_alias = $query->leftJoin('acl_user', 'aclu', "%alias.acl_id = $acl_alias.acl_id AND %alias.uid = $account->uid"); |
|
383 |
$query->condition(db_or() |
|
384 |
->isNull("$access_alias.rid") |
|
385 |
->condition(db_and() |
|
386 |
->condition("$access_alias.rid", $rids, 'IN') |
|
387 |
->condition("$access_alias.grant_$op", 1, '>=')) |
|
388 |
->condition("$aclu_alias.uid", $account->uid)); |
|
389 |
} |
|
341 | 390 |
} |
342 | 391 |
} |
343 | 392 |
} |
... | ... | |
348 | 397 |
function forum_access_node_presave($node, $return_old_tid = FALSE) { |
349 | 398 |
$old_tid = &drupal_static('forum_access_node_presave'); |
350 | 399 |
if (_forum_node_check_node_type($node)) { |
351 |
$old_tid = db_query('SELECT tid FROM {forum} WHERE nid = :nid', array( |
|
352 |
':nid' => $node->nid, |
|
353 |
))->fetchField(); |
|
400 |
if (empty($node->nid)) { |
|
401 |
// Added for migrations, which log errors due to no nid during presave, see #3003279. |
|
402 |
$old_tid = NULL; |
|
403 |
} |
|
404 |
else { |
|
405 |
$old_tid = db_query('SELECT tid FROM {forum} WHERE nid = :nid', array( |
|
406 |
':nid' => $node->nid, |
|
407 |
))->fetchField(); |
|
408 |
} |
|
409 |
} |
|
410 |
if (!empty($old_tid) && empty($node->taxonomy_forums['und'])) { |
|
411 |
$node->forum_tid = null; |
|
354 | 412 |
} |
355 | 413 |
} |
356 | 414 |
|
... | ... | |
423 | 481 |
function forum_access_enable_moderator($enable = TRUE) { |
424 | 482 |
global $user; |
425 | 483 |
|
426 |
if (!$enable || $enable && !user_access('administer comments')) {
|
|
484 |
if (!$enable || !user_access('administer comments')) { |
|
427 | 485 |
$perm = &drupal_static('user_access'); |
428 | 486 |
if ($enable) { |
429 | 487 |
$perm[$user->uid]['administer comments'] = $enable; |
... | ... | |
508 | 566 |
/** |
509 | 567 |
* Implements hook_node_view_alter(). |
510 | 568 |
* |
511 |
* Remove 'Add new comment' link if it shouldn't be there.
|
|
569 |
* Remove 'Add new comment' link and breadcrumb if they shouldn't be there.
|
|
512 | 570 |
*/ |
513 | 571 |
function forum_access_node_view_alter(&$build) { |
514 | 572 |
if ($tid = _forum_access_get_tid($build['#node'])) { |
515 | 573 |
_forum_access_module_load_include('node.inc'); |
516 | 574 |
_forum_access_node_view_alter($build, $tid); |
517 | 575 |
} |
576 |
|
|
577 |
$breadcrumb = drupal_get_breadcrumb(); |
|
578 |
if (!$tid && count($breadcrumb) == 2 && strpos($breadcrumb[0], '<a href="/">') === 0 && strpos($breadcrumb[1], '<a href="/forum">') === 0) { |
|
579 |
// We must hack away the bogus breadcrumb set by forum module |
|
580 |
// (empty taxonomy_forums). |
|
581 |
$stored_breadcrumb = &drupal_static('drupal_set_breadcrumb'); |
|
582 |
$stored_breadcrumb = NULL; |
|
583 |
} |
|
518 | 584 |
} |
519 | 585 |
|
520 | 586 |
/** |
... | ... | |
564 | 630 |
if (!forum_access_access('view', $tid, $account)) { |
565 | 631 |
return $cache[$account->uid][$op][$nid] = NODE_ACCESS_DENY; |
566 | 632 |
} |
567 |
if ($op == 'update' && (user_access('edit any forum content', $account) || ($node->uid == $account->uid && user_access('edit own forum content', $account)))
|
|
568 |
|| $op == 'delete' && (user_access('delete any forum content', $account) || ($node->uid == $account->uid && user_access('delete own forum content', $account)))) {
|
|
633 |
if (($op == 'update' && (user_access('edit any forum content', $account) || ($node->uid == $account->uid && user_access('edit own forum content', $account))))
|
|
634 |
|| ($op == 'delete' && (user_access('delete any forum content', $account) || ($node->uid == $account->uid && user_access('delete own forum content', $account))))) {
|
|
569 | 635 |
return $cache[$account->uid][$op][$nid] = forum_access_node_access($node, 'view', $account); |
570 | 636 |
} |
571 | 637 |
$access = forum_access_access($op, $tid, $account); |
drupal7/sites/all/modules/forum_access/forum_access.node.inc | ||
---|---|---|
75 | 75 |
} |
76 | 76 |
} |
77 | 77 |
if (is_array($old_links)) { |
78 |
/** @noinspection SlowArrayOperationsInLoopInspection */ |
|
78 | 79 |
$links = array_merge($links, $old_links); |
79 | 80 |
} |
80 | 81 |
} |
... | ... | |
207 | 208 |
global $user; |
208 | 209 |
|
209 | 210 |
$comment = $form_state['comment']; |
210 |
if ($cid = $form['cid']['#value'] && isset($form['author']) && !empty($user->_forum_access_moderator)) {
|
|
211 |
if ($form['cid']['#value'] && isset($form['author']) && !empty($user->_forum_access_moderator)) { |
|
211 | 212 |
$editable_administration_elements = variable_get('forum_access_allowed_comment_edit_administration_elements', array('homepage', 'status', 'subscriptions_notify')); |
212 | 213 |
foreach (element_children($form['author']) as $key) { |
213 | 214 |
if (array_search($key, $editable_administration_elements) === FALSE) { |
drupal7/sites/all/modules/forum_access/tests/forum_access_test_base.php | ||
---|---|---|
32 | 32 |
protected $delete_any_content_user; |
33 | 33 |
protected $delete_own_content_user; |
34 | 34 |
protected $create_content_user; |
35 |
protected $auth_user; |
|
35 | 36 |
protected $moderator; |
36 | 37 |
protected $time; |
37 | 38 |
protected $accounts; |
... | ... | |
487 | 488 |
$this->drupalGet("comment/$comment->cid/edit"); |
488 | 489 |
$this->assertResponse(200); |
489 | 490 |
$this->assertText($comment->subject); |
490 |
$comment->title .= ' (updated)';
|
|
491 |
$comment->subject .= ' (updated)';
|
|
491 | 492 |
$this->drupalPost("comment/$comment->cid/edit", array( |
492 | 493 |
'subject' => $comment->subject, |
493 | 494 |
), t('Save')); |
Also available in: Unified diff
Weekly update of contrib modules