Completed
Push — master ( bd05d8...0bd858 )
by Kevin
18:30 queued 07:14
created
html/user/team_forum.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -57,6 +57,9 @@
 block discarded – undo
57 57
     edit_form($user, $team, $forum, true);
58 58
 }
59 59
 
60
+/**
61
+ * @param boolean $first
62
+ */
60 63
 function edit_form($user, $team, $forum, $first) {
61 64
     page_head(tra("Team Message Board"));
62 65
     echo "
Please login to merge, or discard this patch.
html/user/team_search.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@
 block discarded – undo
30 30
 // list entries are of the form id => team,
31 31
 // where team includes a field "refcnt".
32 32
 // 
33
+/**
34
+ * @param integer $weight
35
+ */
33 36
 function merge_lists($list1, &$list2, $weight) {
34 37
     foreach($list1 as $team) {
35 38
         $id = $team->id;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 // where team includes a field "refcnt".
32 32
 // 
33 33
 function merge_lists($list1, &$list2, $weight) {
34
-    foreach($list1 as $team) {
34
+    foreach ($list1 as $team) {
35 35
         $id = $team->id;
36 36
         if (array_key_exists($id, $list2)) {
37 37
             $list2[$id]->refcnt += $weight;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         if (defined("SHOW_NONVALIDATED_TEAMS")) {
98 98
             $user = BoincUser::lookup_id($team->userid);
99 99
             echo "<td>";
100
-            echo $user->email_validated?"Yes":"No";
100
+            echo $user->email_validated ? "Yes" : "No";
101 101
             echo "</td>\n";
102 102
         }
103 103
         echo "
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     xml_header();
138 138
     echo "<teams>\n";
139 139
     sort_list($list);
140
-    foreach($list as $team) {
140
+    foreach ($list as $team) {
141 141
         show_team_xml($team);
142 142
     }
143 143
     echo "</teams>\n";
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
         merge_lists($list2, $list, 3);
165 165
         $tried = true;
166 166
     }
167
-    if (strlen($params->country) && $params->country!='None') {
167
+    if (strlen($params->country) && $params->country != 'None') {
168 168
         $country = BoincDb::escape_string($params->country);
169 169
         $list2 = get_teams("country = '$country'", $params->active);
170 170
         //echo "<br>country matches: ",sizeof($list2);
171 171
         merge_lists($list2, $list, 1);
172 172
         $tried = true;
173 173
     }
174
-    if ($params->type and $params->type>1) {
174
+    if ($params->type and $params->type > 1) {
175 175
         $list2 = get_teams("type=$params->type", $params->active);
176 176
         //echo "<br>type matches: ",sizeof($list2);
177 177
         merge_lists($list2, $list, 2);
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/jump/jump.views.inc 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
  * Implementation of hook_views_plugins().
10 10
  */
11 11
 function jump_views_plugins() {
12
-  return array(
12
+    return array(
13 13
     'style' => array(
14
-      'jump_views' => array(
14
+        'jump_views' => array(
15 15
         'title' => t('Jump menu'),
16 16
         'theme' => 'jump_views_plugin_style',
17 17
         'help' => t('Displays items as a select list jump menu.'),
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         'uses fields' => TRUE,
21 21
         'uses options' => TRUE,
22 22
         'type' => 'normal',
23
-      ),
23
+        ),
24 24
     ),
25
-  );
25
+    );
26 26
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
         'theme' => 'jump_views_plugin_style',
17 17
         'help' => t('Displays items as a select list jump menu.'),
18 18
         'handler' => 'jump_views_plugin_style',
19
-        'uses row plugin' => TRUE,
20
-        'uses fields' => TRUE,
21
-        'uses options' => TRUE,
19
+        'uses row plugin' => true,
20
+        'uses fields' => true,
21
+        'uses options' => true,
22 22
         'type' => 'normal',
23 23
       ),
24 24
     ),
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/jump/jump.views_default.inc 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
  * Implementation of hook_views_default_views().
10 10
  */
11 11
 function jump_views_default_views() {
12
-  $view = new view;
13
-  $view->name = 'recent_nodes_jump_menu';
14
-  $view->description = 'Recent nodes in a jump menu.';
15
-  $view->tag = '';
16
-  $view->view_php = '';
17
-  $view->base_table = 'node';
18
-  $view->is_cacheable = FALSE;
19
-  $view->api_version = 2;
20
-  $view->disabled = TRUE;
21
-  $handler = $view->new_display('default', 'Defaults', 'default');
22
-  $handler->override_option('fields', array(
12
+    $view = new view;
13
+    $view->name = 'recent_nodes_jump_menu';
14
+    $view->description = 'Recent nodes in a jump menu.';
15
+    $view->tag = '';
16
+    $view->view_php = '';
17
+    $view->base_table = 'node';
18
+    $view->is_cacheable = FALSE;
19
+    $view->api_version = 2;
20
+    $view->disabled = TRUE;
21
+    $handler = $view->new_display('default', 'Defaults', 'default');
22
+    $handler->override_option('fields', array(
23 23
     'nid' => array(
24
-      'label' => 'Nid',
25
-      'alter' => array(
24
+        'label' => 'Nid',
25
+        'alter' => array(
26 26
         'alter_text' => 1,
27 27
         'text' => 'node/[nid]',
28 28
         'make_link' => 0,
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
         'ellipsis' => 1,
39 39
         'strip_tags' => 0,
40 40
         'html' => 0,
41
-      ),
42
-      'link_to_node' => 0,
43
-      'exclude' => 1,
44
-      'id' => 'nid',
45
-      'table' => 'node',
46
-      'field' => 'nid',
47
-      'relationship' => 'none',
41
+        ),
42
+        'link_to_node' => 0,
43
+        'exclude' => 1,
44
+        'id' => 'nid',
45
+        'table' => 'node',
46
+        'field' => 'nid',
47
+        'relationship' => 'none',
48 48
     ),
49 49
     'title' => array(
50
-      'label' => '',
51
-      'alter' => array(
50
+        'label' => '',
51
+        'alter' => array(
52 52
         'alter_text' => 0,
53 53
         'text' => '',
54 54
         'make_link' => 0,
@@ -64,60 +64,60 @@  discard block
 block discarded – undo
64 64
         'ellipsis' => 1,
65 65
         'strip_tags' => 0,
66 66
         'html' => 0,
67
-      ),
68
-      'link_to_node' => 0,
69
-      'exclude' => 0,
70
-      'id' => 'title',
71
-      'table' => 'node',
72
-      'field' => 'title',
73
-      'relationship' => 'none',
67
+        ),
68
+        'link_to_node' => 0,
69
+        'exclude' => 0,
70
+        'id' => 'title',
71
+        'table' => 'node',
72
+        'field' => 'title',
73
+        'relationship' => 'none',
74 74
     ),
75
-  ));
76
-  $handler->override_option('sorts', array(
75
+    ));
76
+    $handler->override_option('sorts', array(
77 77
     'changed' => array(
78
-      'order' => 'DESC',
79
-      'granularity' => 'second',
80
-      'id' => 'changed',
81
-      'table' => 'node',
82
-      'field' => 'changed',
83
-      'relationship' => 'none',
78
+        'order' => 'DESC',
79
+        'granularity' => 'second',
80
+        'id' => 'changed',
81
+        'table' => 'node',
82
+        'field' => 'changed',
83
+        'relationship' => 'none',
84 84
     ),
85
-  ));
86
-  $handler->override_option('filters', array(
85
+    ));
86
+    $handler->override_option('filters', array(
87 87
     'status_extra' => array(
88
-      'operator' => '=',
89
-      'value' => '',
90
-      'group' => '0',
91
-      'exposed' => FALSE,
92
-      'expose' => array(
88
+        'operator' => '=',
89
+        'value' => '',
90
+        'group' => '0',
91
+        'exposed' => FALSE,
92
+        'expose' => array(
93 93
         'operator' => FALSE,
94 94
         'label' => '',
95
-      ),
96
-      'id' => 'status_extra',
97
-      'table' => 'node',
98
-      'field' => 'status_extra',
99
-      'relationship' => 'none',
95
+        ),
96
+        'id' => 'status_extra',
97
+        'table' => 'node',
98
+        'field' => 'status_extra',
99
+        'relationship' => 'none',
100 100
     ),
101
-  ));
102
-  $handler->override_option('access', array(
101
+    ));
102
+    $handler->override_option('access', array(
103 103
     'type' => 'none',
104
-  ));
105
-  $handler->override_option('cache', array(
104
+    ));
105
+    $handler->override_option('cache', array(
106 106
     'type' => 'none',
107
-  ));
108
-  $handler->override_option('style_plugin', 'jump_views');
109
-  $handler->override_option('style_options', array(
107
+    ));
108
+    $handler->override_option('style_plugin', 'jump_views');
109
+    $handler->override_option('style_options', array(
110 110
     'grouping' => '',
111 111
     'keys' => array(
112
-      'nid' => 'nid',
113
-      'title' => 0,
112
+        'nid' => 'nid',
113
+        'title' => 0,
114 114
     ),
115 115
     'first_item' => 'Recent nodes',
116
-  ));
117
-  $handler = $view->new_display('block', 'Block', 'block_1');
118
-  $handler->override_option('block_description', '');
119
-  $handler->override_option('block_caching', -1);
116
+    ));
117
+    $handler = $view->new_display('block', 'Block', 'block_1');
118
+    $handler->override_option('block_description', '');
119
+    $handler->override_option('block_caching', -1);
120 120
 
121
-  $views[$view->name] = $view;
122
-  return $views;
121
+    $views[$view->name] = $view;
122
+    return $views;
123 123
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
   $view->tag = '';
16 16
   $view->view_php = '';
17 17
   $view->base_table = 'node';
18
-  $view->is_cacheable = FALSE;
18
+  $view->is_cacheable = false;
19 19
   $view->api_version = 2;
20
-  $view->disabled = TRUE;
20
+  $view->disabled = true;
21 21
   $handler = $view->new_display('default', 'Defaults', 'default');
22 22
   $handler->override_option('fields', array(
23 23
     'nid' => array(
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
       'operator' => '=',
89 89
       'value' => '',
90 90
       'group' => '0',
91
-      'exposed' => FALSE,
91
+      'exposed' => false,
92 92
       'expose' => array(
93
-        'operator' => FALSE,
93
+        'operator' => false,
94 94
         'label' => '',
95 95
       ),
96 96
       'id' => 'status_extra',
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/jump/jump_views_plugin_style.inc 3 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
 
8 8
 class jump_views_plugin_style extends views_plugin_style {
9 9
 
10
-  function render() {
10
+    function render() {
11 11
     // Build an array of field / field_alias pairs.
12 12
     $this->field_map = array();
13 13
     foreach ($this->view->field as $field_name => $object) {
14
-      $this-> field_map[$object->field_alias] = $field_name;
14
+        $this-> field_map[$object->field_alias] = $field_name;
15 15
     }
16 16
 
17 17
     // $keys contains the fields used to build up the path.
@@ -21,116 +21,116 @@  discard block
 block discarded – undo
21 21
     // callback.
22 22
     $select = array();
23 23
     if (!empty($this->options['first_item'])) {
24
-      $select[0] = $this->options['first_item'];
24
+        $select[0] = $this->options['first_item'];
25 25
     }
26 26
 
27 27
     foreach ($this->view->result as $row) {
28
-      $select_key = array();
29
-      // For each field in the row, we first check if it's to be used
30
-      // as part of the select key, then run views token replacement
31
-      // on it. This allows for paths like node/n/revisions/6 to be built
32
-      // easily.
33
-      foreach ($row as $field => $value) {
28
+        $select_key = array();
29
+        // For each field in the row, we first check if it's to be used
30
+        // as part of the select key, then run views token replacement
31
+        // on it. This allows for paths like node/n/revisions/6 to be built
32
+        // easily.
33
+        foreach ($row as $field => $value) {
34 34
         if (in_array($this->field_map[$field], $keys)) {
35
-          $field_object = $this->view->field[$this->field_map[$field]];
36
-          // Re-implementing some of the code from views_handler_field.inc
37
-          // since we need to operate on $result, and to avoid using
38
-          // a row style or templates.
39
-          if (!empty($field_object->options['alter']['alter_text']) && !empty($field_object->options['alter']['text'])) {
35
+            $field_object = $this->view->field[$this->field_map[$field]];
36
+            // Re-implementing some of the code from views_handler_field.inc
37
+            // since we need to operate on $result, and to avoid using
38
+            // a row style or templates.
39
+            if (!empty($field_object->options['alter']['alter_text']) && !empty($field_object->options['alter']['text'])) {
40 40
             $tokens = $this->get_render_tokens($this->field_map[$field], $row);
41 41
             $value = $field_object->render_altered($tokens);
42
-          }
43
-          $select_key[] = $value;
42
+            }
43
+            $select_key[] = $value;
44 44
         }
45
-      }
46
-      // For the value of the select, just use the output of the row, but strip
47
-      // all markup first.
48
-      $select_key = implode('/', $select_key);
49
-      $raw_select_value = $this->row_plugin->render($row);
50
-      $select_value = trim(html_entity_decode(strip_tags($raw_select_value), ENT_QUOTES));
51
-      $select[$select_key] = $select_value;
45
+        }
46
+        // For the value of the select, just use the output of the row, but strip
47
+        // all markup first.
48
+        $select_key = implode('/', $select_key);
49
+        $raw_select_value = $this->row_plugin->render($row);
50
+        $select_value = trim(html_entity_decode(strip_tags($raw_select_value), ENT_QUOTES));
51
+        $select[$select_key] = $select_value;
52 52
     }
53 53
 
54 54
     return jump_quickly($select);
55
-  }
55
+    }
56 56
 
57
-  function option_definition() {
57
+    function option_definition() {
58 58
     $options = parent::option_definition();
59 59
     $options['keys'] = array('default' => array());
60 60
     $options['first_item'] = array('default' => '');
61 61
     return $options;
62
-  }
62
+    }
63 63
 
64
-  function options_form(&$form, $form_state) {
64
+    function options_form(&$form, $form_state) {
65 65
     parent::options_form($form, $form_state);
66 66
     $handlers = $this->display->handler->get_handlers('field');
67 67
     if (empty($handlers)) {
68
-      $form['error_markup'] = array(
68
+        $form['error_markup'] = array(
69 69
         '#value' => t('You need at least one field before you can configure your jump menu settings'),
70 70
         '#prefix' => '<div class="error form-item description">',
71 71
         '#suffix' => '</div>',
72
-      );
73
-      return;
72
+        );
73
+        return;
74 74
     }
75 75
     // Create an array of fields from the data we know.
76 76
     foreach ($handlers as $field => $handler) {
77
-      if ($label = $handler->label()) {
77
+        if ($label = $handler->label()) {
78 78
         $field_names[$field] = $label;
79
-      }
80
-      else {
79
+        }
80
+        else {
81 81
         $field_names[$field] = $handler->ui_name();
82
-      }
82
+        }
83 83
     }
84 84
     $form['keys'] = array(
85
-      '#type' => 'checkboxes',
86
-      '#title' => t('Select keys'),
87
-      '#default_value' => $this->options['keys'],
88
-      '#description' => t("These fields will be used to build the path for each row, used as the 'key' in the select options, and will be automatically separated by '/'"),
89
-      '#options' => $field_names,
85
+        '#type' => 'checkboxes',
86
+        '#title' => t('Select keys'),
87
+        '#default_value' => $this->options['keys'],
88
+        '#description' => t("These fields will be used to build the path for each row, used as the 'key' in the select options, and will be automatically separated by '/'"),
89
+        '#options' => $field_names,
90 90
     );
91 91
     $form['first_item'] = array(
92
-      '#type' => 'textfield',
93
-      '#title' => 'First item',
94
-      '#default_value' => $this->options['first_item'],
95
-      '#description' => t('This will be used as the first item in your select list, for example <em>Choose one</em>'),
92
+        '#type' => 'textfield',
93
+        '#title' => 'First item',
94
+        '#default_value' => $this->options['first_item'],
95
+        '#description' => t('This will be used as the first item in your select list, for example <em>Choose one</em>'),
96 96
     );
97
-  }
97
+    }
98 98
 
99
-  /**
100
-   * Get the 'render' tokens to use for advanced rendering.
101
-   *
102
-   * This runs through all of the fields and arguments that
103
-   * are available and gets their values. This will then be
104
-   * used in one giant str_replace().
105
-   * Slightly modified from views_handler_field.inc
106
-   */
107
-  function get_render_tokens($field_name, $row) {
99
+    /**
100
+     * Get the 'render' tokens to use for advanced rendering.
101
+     *
102
+     * This runs through all of the fields and arguments that
103
+     * are available and gets their values. This will then be
104
+     * used in one giant str_replace().
105
+     * Slightly modified from views_handler_field.inc
106
+     */
107
+    function get_render_tokens($field_name, $row) {
108 108
     $tokens = array();
109 109
     if (!empty($this->view->build_info['substitutions'])) {
110
-      $tokens = $this->view->build_info['substitutions'];
110
+        $tokens = $this->view->build_info['substitutions'];
111 111
     }
112 112
 
113 113
     $count = 0;
114 114
     foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
115
-      $token = '%'. ++$count;
116
-      if (!isset($tokens[$token])) {
115
+        $token = '%'. ++$count;
116
+        if (!isset($tokens[$token])) {
117 117
         $tokens[$token] = '';
118
-      }
118
+        }
119 119
     }
120 120
 
121 121
     // Now add replacements for our fields.
122 122
     $options = array();
123 123
     $map = array_flip($this->field_map);
124 124
     foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
125
-      $map = array_flip($this->field_map);
126
-      if (isset($row->$map[$field])) {
125
+        $map = array_flip($this->field_map);
126
+        if (isset($row->$map[$field])) {
127 127
         $tokens["[$field]"] = $row->$map[$field];
128
-      }
129
-      else {
128
+        }
129
+        else {
130 130
         $tokens["[$field]"] = '';
131
-      }
131
+        }
132 132
     }
133 133
 
134 134
     return $tokens;
135
-  }
135
+    }
136 136
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@
 block discarded – undo
112 112
 
113 113
     $count = 0;
114 114
     foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
115
-      $token = '%'. ++$count;
115
+      $token = '%'.++$count;
116 116
       if (!isset($tokens[$token])) {
117 117
         $tokens[$token] = '';
118 118
       }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -76,8 +76,7 @@  discard block
 block discarded – undo
76 76
     foreach ($handlers as $field => $handler) {
77 77
       if ($label = $handler->label()) {
78 78
         $field_names[$field] = $label;
79
-      }
80
-      else {
79
+      } else {
81 80
         $field_names[$field] = $handler->ui_name();
82 81
       }
83 82
     }
@@ -125,8 +124,7 @@  discard block
 block discarded – undo
125 124
       $map = array_flip($this->field_map);
126 125
       if (isset($row->$map[$field])) {
127 126
         $tokens["[$field]"] = $row->$map[$field];
128
-      }
129
-      else {
127
+      } else {
130 128
         $tokens["[$field]"] = '';
131 129
       }
132 130
     }
Please login to merge, or discard this patch.
sites/default/boinc/modules/contrib/forum_access/forum_access.node.inc 5 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -13,64 +13,64 @@  discard block
 block discarded – undo
13 13
  * Rewrite the taxonomy item on the node form.
14 14
  */
15 15
 function _forum_access_node_form(&$form, &$form_state) {
16
-  global $user;
17
-  $vid = _forum_access_get_vid();
16
+    global $user;
17
+    $vid = _forum_access_get_vid();
18 18
 
19
-  if (!isset($form['taxonomy'][$vid]['#options'])) {
19
+    if (!isset($form['taxonomy'][$vid]['#options'])) {
20 20
     return;
21
-  }
21
+    }
22 22
 
23
-  // True node administrators are all powerful and do NOT get their forms rewritten here.
24
-  if (user_access('administer nodes') && empty($user->_forum_access_moderator)) {
23
+    // True node administrators are all powerful and do NOT get their forms rewritten here.
24
+    if (user_access('administer nodes') && empty($user->_forum_access_moderator)) {
25 25
     return;
26
-  }
26
+    }
27 27
 
28
-  $roles = array_keys($user->roles);
29
-  $result = db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_create = 1", $roles);
30
-  while ($obj = db_fetch_object($result)) {
28
+    $roles = array_keys($user->roles);
29
+    $result = db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_create = 1", $roles);
30
+    while ($obj = db_fetch_object($result)) {
31 31
     $tids[$obj->tid] = $obj->tid;
32
-  }
32
+    }
33 33
 
34
-  // Also get all forums they happen to be able to moderate.
35
-  $result = db_query("SELECT a.number AS tid FROM {acl} a INNER JOIN {acl_user} u ON a.acl_id = u.acl_id WHERE a.module = 'forum_access' AND u.uid = %d", $user->uid);
36
-  while ($obj = db_fetch_object($result)) {
34
+    // Also get all forums they happen to be able to moderate.
35
+    $result = db_query("SELECT a.number AS tid FROM {acl} a INNER JOIN {acl_user} u ON a.acl_id = u.acl_id WHERE a.module = 'forum_access' AND u.uid = %d", $user->uid);
36
+    while ($obj = db_fetch_object($result)) {
37 37
     $tids[$obj->tid] = $obj->tid;
38
-  }
38
+    }
39 39
 
40
-  // Ensure the forum they're trying to post to directly is allowed, otherwise
41
-  // there will be much confusion.
42
-  $forum_tid = arg(3);
43
-  if (isset($forum_tid) && is_numeric($forum_tid) && !isset($tids[$forum_tid])) {
40
+    // Ensure the forum they're trying to post to directly is allowed, otherwise
41
+    // there will be much confusion.
42
+    $forum_tid = arg(3);
43
+    if (isset($forum_tid) && is_numeric($forum_tid) && !isset($tids[$forum_tid])) {
44 44
     drupal_access_denied();
45 45
     module_invoke_all('exit');
46 46
     exit;
47
-  }
47
+    }
48 48
 
49
-  foreach ($form['taxonomy'][$vid]['#options'] as $tid => $name) {
49
+    foreach ($form['taxonomy'][$vid]['#options'] as $tid => $name) {
50 50
     if (!is_numeric($tid)) {
51
-      $options[$tid] = $name;
51
+        $options[$tid] = $name;
52 52
     }
53 53
     elseif (is_object($name)) {
54
-      foreach ($name->option as $sub_tid => $sub_name) {
54
+        foreach ($name->option as $sub_tid => $sub_name) {
55 55
         if (!empty($tids[$sub_tid])) {
56
-          $options[$tid]->option[$sub_tid] = $sub_name;
56
+            $options[$tid]->option[$sub_tid] = $sub_name;
57
+        }
57 58
         }
58
-      }
59 59
     }
60 60
     elseif ($tids[$tid]) {
61
-      $options[$tid] = $name;
61
+        $options[$tid] = $name;
62
+    }
62 63
     }
63
-  }
64 64
 
65
-  if ($options) {
65
+    if ($options) {
66 66
     $form['taxonomy'][$vid]['#options'] = $options;
67
-  }
68
-  else {
67
+    }
68
+    else {
69 69
     unset($form['taxonomy'][$vid]);
70
-  }
70
+    }
71 71
 
72
-  // Apply modifications for Moderators (by role or uid).
73
-  if (!empty($user->_forum_access_moderator)) {
72
+    // Apply modifications for Moderators (by role or uid).
73
+    if (!empty($user->_forum_access_moderator)) {
74 74
     // We gave this user the 'administer nodes' permission, which he doesn't
75 75
     // normally have. Remove controls that should be reserved to true node
76 76
     // administrators.
@@ -78,31 +78,31 @@  discard block
 block discarded – undo
78 78
     $allowed_elements = variable_get('forum_access_allowed_node_edit_elements', array('nid', 'vid', 'uid', 'created', 'type', 'changed', 'title', 'shadow', 'body_field', 'revision_information', 'form_build_id', 'form_token', 'form_id', 'comment_settings', 'taxonomy', 'attachments'));
79 79
     $allowed_options = variable_get('forum_access_allowed_node_edit_options', array('status', 'sticky', 'subscriptions_notify'));
80 80
     foreach (element_children($form) as $key) {
81
-      switch ($key) {
81
+        switch ($key) {
82 82
         case 'options':
83 83
           foreach (element_children($form[$key]) as $key2) {
84 84
             if (array_search($key2, $allowed_options) === FALSE) {
85
-              $form[$key][$key2]['#access'] = FALSE;
85
+                $form[$key][$key2]['#access'] = FALSE;
86
+            }
86 87
             }
87
-          }
88
-          break;
88
+            break;
89 89
         case 'buttons':
90 90
           $tid = $form['taxonomy'][$vid]['#default_value'][0];
91
-          if (!forum_access_access($tid, 'update')) {
91
+            if (!forum_access_access($tid, 'update')) {
92 92
             $form['buttons']['submit']['#access'] = FALSE;
93 93
             $form['buttons']['preview']['#access'] = FALSE;
94
-          }
95
-          if (!forum_access_access($tid, 'delete')) {
94
+            }
95
+            if (!forum_access_access($tid, 'delete')) {
96 96
             $form['buttons']['delete']['#access'] = FALSE;
97
-          }
98
-          break;
97
+            }
98
+            break;
99 99
         default:
100 100
           if (array_search($key, $allowed_elements) === FALSE) {
101 101
             $form[$key]['#access'] = FALSE;
102
-          }
103
-      }
102
+            }
103
+        }
104
+    }
104 105
     }
105
-  }
106 106
 }
107 107
 
108 108
 /**
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
  * and sanitize the Administration options for users with Edit grants.
115 115
  */
116 116
 function _forum_access_comment_form(&$form, &$form_state) {
117
-  global $user;
118
-  if ($user->uid != 1 && isset($form['nid']['#value'])) {
117
+    global $user;
118
+    if ($user->uid != 1 && isset($form['nid']['#value'])) {
119 119
     $node = node_load($form['nid']['#value']);
120 120
     if ($tid = _forum_access_get_tid($node)) {
121
-      if (!forum_access_access($tid, 'comment_create')) {
121
+        if (!forum_access_access($tid, 'comment_create')) {
122 122
         switch (arg(0)) {
123
-          case 'node':
123
+            case 'node':
124 124
               // Remove the in-line comment form, replace with text message to user.
125 125
               $form = NULL;
126
-              $form['from'] = array(
127
-                  '#type'  => 'item',
128
-                  '#value' => 'You do not have permission to post comments in this forum.',);
126
+                $form['from'] = array(
127
+                    '#type'  => 'item',
128
+                    '#value' => 'You do not have permission to post comments in this forum.',);
129 129
             break;
130 130
             case 'comment':
131 131
                 if (arg(1)=='reply') {
@@ -135,38 +135,38 @@  discard block
 block discarded – undo
135 135
                 }
136 136
             break;
137 137
         }//switch arg(0)
138
-      }
139
-      else {
138
+        }
139
+        else {
140 140
         if (isset($form['admin']) && !empty($user->_forum_access_moderator)) {
141
-          foreach (element_children($form['admin']) as $key) {
141
+            foreach (element_children($form['admin']) as $key) {
142 142
             if ($key != 'status') {
143
-              $form['admin'][$key]['#access'] = FALSE;
143
+                $form['admin'][$key]['#access'] = FALSE;
144 144
             }
145
-          }
145
+            }
146
+        }
146 147
         }
147
-      }
148 148
     }
149
-  }
149
+    }
150 150
 }
151 151
 
152 152
 /*
153 153
  * Give the user the 'administer nodes' and 'administer comments' permissions for this request.
154 154
  */
155 155
 function _forum_access_enable_moderator() {
156
-  global $user;
157
-  $rid = _forum_access_get_moderator_rid();
158
-  $user->roles[$rid] = '(forum_access temporary)';
159
-  user_access('', NULL, TRUE); // clear the permissions cache to activate the new role
156
+    global $user;
157
+    $rid = _forum_access_get_moderator_rid();
158
+    $user->roles[$rid] = '(forum_access temporary)';
159
+    user_access('', NULL, TRUE); // clear the permissions cache to activate the new role
160 160
 }
161 161
 
162 162
 /*
163 163
  * Remove the moderator permissions.
164 164
  */
165 165
 function _forum_access_disable_moderator() {
166
-  global $user;
167
-  $rid = _forum_access_get_moderator_rid();
168
-  unset($user->roles[$rid]);
169
-  user_access('', NULL, TRUE); // clear the permissions cache to revert to normal
166
+    global $user;
167
+    $rid = _forum_access_get_moderator_rid();
168
+    unset($user->roles[$rid]);
169
+    user_access('', NULL, TRUE); // clear the permissions cache to revert to normal
170 170
 }
171 171
 
172 172
 /*
@@ -174,26 +174,26 @@  discard block
 block discarded – undo
174 174
  * then create it.
175 175
  */
176 176
 function _forum_access_get_moderator_rid($verbose = FALSE) {
177
-  $rid = forum_access_query_moderator_rid();
178
-  if ($rid !== NULL) {
177
+    $rid = forum_access_query_moderator_rid();
178
+    if ($rid !== NULL) {
179 179
     if (db_result(db_query("SELECT COUNT(rid) FROM {role} WHERE rid = %d", $rid)) == 1) {
180
-      return $rid;
180
+        return $rid;
181
+    }
181 182
     }
182
-  }
183
-  module_load_include('admin.inc', 'forum_access');
184
-  return _forum_access_create_moderator_rid($verbose);
183
+    module_load_include('admin.inc', 'forum_access');
184
+    return _forum_access_create_moderator_rid($verbose);
185 185
 }
186 186
 
187 187
 /*
188 188
  * Return the roles for forum_access_node_access_explain().
189 189
  */
190 190
 function _forum_access_get_all_roles() {
191
-  $roles = user_roles();
192
-  $moderator_rid = forum_access_query_moderator_rid();
193
-  if (isset($roles[$moderator_rid])) {
191
+    $roles = user_roles();
192
+    $moderator_rid = forum_access_query_moderator_rid();
193
+    if (isset($roles[$moderator_rid])) {
194 194
     $roles[$moderator_rid] .= ' '. t('(!Forum_Access temporary role, does not need any grants.)', array('!Forum_Access' => 'Forum Access'));
195
-  }
196
-  return $roles;
195
+    }
196
+    return $roles;
197 197
 }
198 198
 
199 199
 /**
@@ -201,42 +201,42 @@  discard block
 block discarded – undo
201 201
  * remove those that aren't accessible to the user (pre-D6.17).
202 202
  */
203 203
 function _forum_access_preprocess_comment(&$variables) {
204
-  global $user;
205
-  if (!empty($user->_forum_access_moderator)) {
204
+    global $user;
205
+    if (!empty($user->_forum_access_moderator)) {
206 206
     _forum_access_enable_moderator(); // this allows us to retrieve the comment links (without setting precedent!)
207
-  }
207
+    }
208 208
 
209
-  $tid = $variables['node']->tid;
210
-  $links = module_invoke_all('link', 'comment', $variables['comment'], 0);
211
-  if (!empty($user->_forum_access_moderator) && arg(0) == 'node' && arg(2) == NULL) {
209
+    $tid = $variables['node']->tid;
210
+    $links = module_invoke_all('link', 'comment', $variables['comment'], 0);
211
+    if (!empty($user->_forum_access_moderator) && arg(0) == 'node' && arg(2) == NULL) {
212 212
     _forum_access_disable_moderator();
213
-  }
213
+    }
214 214
 
215
-  if (isset($links['comment_reply']) && (!preg_match('#<li class="[^"]*comment_reply[^"]*".*</li>#U', $variables['links']) || !user_access('post comments') || !forum_access_access($tid, 'comment_create', NULL, FALSE))) {
215
+    if (isset($links['comment_reply']) && (!preg_match('#<li class="[^"]*comment_reply[^"]*".*</li>#U', $variables['links']) || !user_access('post comments') || !forum_access_access($tid, 'comment_create', NULL, FALSE))) {
216 216
     unset($links['comment_reply']);
217
-  }
218
-  if (isset($links['comment_edit']) && !forum_access_access($tid, 'update', NULL, FALSE) && !comment_access('edit', $variables['comment'])) {
217
+    }
218
+    if (isset($links['comment_edit']) && !forum_access_access($tid, 'update', NULL, FALSE) && !comment_access('edit', $variables['comment'])) {
219 219
     unset($links['comment_edit']);
220
-  }
221
-  if (isset($links['comment_delete']) && !forum_access_access($tid, 'delete', NULL, FALSE) && !user_access('administer comments')) {
220
+    }
221
+    if (isset($links['comment_delete']) && !forum_access_access($tid, 'delete', NULL, FALSE) && !user_access('administer comments')) {
222 222
     unset($links['comment_delete']);
223
-  }
224
-  foreach (array_keys($links) as $link) {
223
+    }
224
+    foreach (array_keys($links) as $link) {
225 225
     if (!in_array($link, array('comment_reply', 'comment_edit', 'comment_delete'))) {
226
-      $link_preg_quote = preg_quote($link, '#');
227
-      if (!preg_match('#<li class="[^"]*'. $link_preg_quote .'[^"]*"(.|\n)*</li>#U', $variables['links'])) {
226
+        $link_preg_quote = preg_quote($link, '#');
227
+        if (!preg_match('#<li class="[^"]*'. $link_preg_quote .'[^"]*"(.|\n)*</li>#U', $variables['links'])) {
228 228
         unset($links[$link]); // eliminate possible additional unknown links that came in for 'administer_comments'
229
-      }
229
+        }
230
+    }
230 231
     }
231
-  }
232 232
 
233
-  drupal_alter('link', $links, $variables['node'], $variables['comment']);
233
+    drupal_alter('link', $links, $variables['node'], $variables['comment']);
234 234
 
235
-  if (empty($links)) {
235
+    if (empty($links)) {
236 236
     $links['comment_forbidden'] = array(
237
-      'title' => theme('comment_post_forbidden', $variables['node']),
238
-      'html'  => TRUE,
237
+        'title' => theme('comment_post_forbidden', $variables['node']),
238
+        'html'  => TRUE,
239 239
     );
240
-  }
241
-  $variables['links'] = theme('links', $links);
240
+    }
241
+    $variables['links'] = theme('links', $links);
242 242
 }
Please login to merge, or discard this patch.
Switch Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -79,27 +79,27 @@  discard block
 block discarded – undo
79 79
     $allowed_options = variable_get('forum_access_allowed_node_edit_options', array('status', 'sticky', 'subscriptions_notify'));
80 80
     foreach (element_children($form) as $key) {
81 81
       switch ($key) {
82
-        case 'options':
83
-          foreach (element_children($form[$key]) as $key2) {
84
-            if (array_search($key2, $allowed_options) === FALSE) {
85
-              $form[$key][$key2]['#access'] = FALSE;
86
-            }
87
-          }
88
-          break;
89
-        case 'buttons':
90
-          $tid = $form['taxonomy'][$vid]['#default_value'][0];
91
-          if (!forum_access_access($tid, 'update')) {
92
-            $form['buttons']['submit']['#access'] = FALSE;
93
-            $form['buttons']['preview']['#access'] = FALSE;
94
-          }
95
-          if (!forum_access_access($tid, 'delete')) {
96
-            $form['buttons']['delete']['#access'] = FALSE;
97
-          }
98
-          break;
99
-        default:
100
-          if (array_search($key, $allowed_elements) === FALSE) {
101
-            $form[$key]['#access'] = FALSE;
82
+      case 'options':
83
+        foreach (element_children($form[$key]) as $key2) {
84
+          if (array_search($key2, $allowed_options) === FALSE) {
85
+            $form[$key][$key2]['#access'] = FALSE;
102 86
           }
87
+        }
88
+        break;
89
+      case 'buttons':
90
+        $tid = $form['taxonomy'][$vid]['#default_value'][0];
91
+        if (!forum_access_access($tid, 'update')) {
92
+          $form['buttons']['submit']['#access'] = FALSE;
93
+          $form['buttons']['preview']['#access'] = FALSE;
94
+        }
95
+        if (!forum_access_access($tid, 'delete')) {
96
+          $form['buttons']['delete']['#access'] = FALSE;
97
+        }
98
+        break;
99
+      default:
100
+        if (array_search($key, $allowed_elements) === FALSE) {
101
+          $form[$key]['#access'] = FALSE;
102
+        }
103 103
       }
104 104
     }
105 105
   }
@@ -120,20 +120,20 @@  discard block
 block discarded – undo
120 120
     if ($tid = _forum_access_get_tid($node)) {
121 121
       if (!forum_access_access($tid, 'comment_create')) {
122 122
         switch (arg(0)) {
123
-          case 'node':
124
-              // Remove the in-line comment form, replace with text message to user.
125
-              $form = NULL;
126
-              $form['from'] = array(
127
-                  '#type'  => 'item',
128
-                  '#value' => 'You do not have permission to post comments in this forum.',);
129
-            break;
130
-            case 'comment':
131
-                if (arg(1)=='reply') {
132
-                    drupal_set_message(t("ERROR: You do not have permission to post comments in this forum."), 'error');
133
-                    drupal_goto("node/$node->nid");
134
-                    exit;
135
-                }
136
-            break;
123
+        case 'node':
124
+            // Remove the in-line comment form, replace with text message to user.
125
+            $form = NULL;
126
+            $form['from'] = array(
127
+                '#type'  => 'item',
128
+                '#value' => 'You do not have permission to post comments in this forum.',);
129
+          break;
130
+        case 'comment':
131
+            if (arg(1)=='reply') {
132
+                drupal_set_message(t("ERROR: You do not have permission to post comments in this forum."), 'error');
133
+                drupal_goto("node/$node->nid");
134
+                exit;
135
+            }
136
+        break;
137 137
         }//switch arg(0)
138 138
       }
139 139
       else {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
   }
27 27
 
28 28
   $roles = array_keys($user->roles);
29
-  $result = db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_create = 1", $roles);
29
+  $result = db_query("SELECT tid FROM {forum_access} WHERE rid IN (".db_placeholders($roles).") AND grant_create = 1", $roles);
30 30
   while ($obj = db_fetch_object($result)) {
31 31
     $tids[$obj->tid] = $obj->tid;
32 32
   }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                   '#value' => 'You do not have permission to post comments in this forum.',);
129 129
             break;
130 130
             case 'comment':
131
-                if (arg(1)=='reply') {
131
+                if (arg(1) == 'reply') {
132 132
                     drupal_set_message(t("ERROR: You do not have permission to post comments in this forum."), 'error');
133 133
                     drupal_goto("node/$node->nid");
134 134
                     exit;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
   $roles = user_roles();
192 192
   $moderator_rid = forum_access_query_moderator_rid();
193 193
   if (isset($roles[$moderator_rid])) {
194
-    $roles[$moderator_rid] .= ' '. t('(!Forum_Access temporary role, does not need any grants.)', array('!Forum_Access' => 'Forum Access'));
194
+    $roles[$moderator_rid] .= ' '.t('(!Forum_Access temporary role, does not need any grants.)', array('!Forum_Access' => 'Forum Access'));
195 195
   }
196 196
   return $roles;
197 197
 }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
   foreach (array_keys($links) as $link) {
225 225
     if (!in_array($link, array('comment_reply', 'comment_edit', 'comment_delete'))) {
226 226
       $link_preg_quote = preg_quote($link, '#');
227
-      if (!preg_match('#<li class="[^"]*'. $link_preg_quote .'[^"]*"(.|\n)*</li>#U', $variables['links'])) {
227
+      if (!preg_match('#<li class="[^"]*'.$link_preg_quote.'[^"]*"(.|\n)*</li>#U', $variables['links'])) {
228 228
         unset($links[$link]); // eliminate possible additional unknown links that came in for 'administer_comments'
229 229
       }
230 230
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -49,23 +49,20 @@  discard block
 block discarded – undo
49 49
   foreach ($form['taxonomy'][$vid]['#options'] as $tid => $name) {
50 50
     if (!is_numeric($tid)) {
51 51
       $options[$tid] = $name;
52
-    }
53
-    elseif (is_object($name)) {
52
+    } elseif (is_object($name)) {
54 53
       foreach ($name->option as $sub_tid => $sub_name) {
55 54
         if (!empty($tids[$sub_tid])) {
56 55
           $options[$tid]->option[$sub_tid] = $sub_name;
57 56
         }
58 57
       }
59
-    }
60
-    elseif ($tids[$tid]) {
58
+    } elseif ($tids[$tid]) {
61 59
       $options[$tid] = $name;
62 60
     }
63 61
   }
64 62
 
65 63
   if ($options) {
66 64
     $form['taxonomy'][$vid]['#options'] = $options;
67
-  }
68
-  else {
65
+  } else {
69 66
     unset($form['taxonomy'][$vid]);
70 67
   }
71 68
 
@@ -135,8 +132,7 @@  discard block
 block discarded – undo
135 132
                 }
136 133
             break;
137 134
         }//switch arg(0)
138
-      }
139
-      else {
135
+      } else {
140 136
         if (isset($form['admin']) && !empty($user->_forum_access_moderator)) {
141 137
           foreach (element_children($form['admin']) as $key) {
142 138
             if ($key != 'status') {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -81,24 +81,24 @@  discard block
 block discarded – undo
81 81
       switch ($key) {
82 82
         case 'options':
83 83
           foreach (element_children($form[$key]) as $key2) {
84
-            if (array_search($key2, $allowed_options) === FALSE) {
85
-              $form[$key][$key2]['#access'] = FALSE;
84
+            if (array_search($key2, $allowed_options) === false) {
85
+              $form[$key][$key2]['#access'] = false;
86 86
             }
87 87
           }
88 88
           break;
89 89
         case 'buttons':
90 90
           $tid = $form['taxonomy'][$vid]['#default_value'][0];
91 91
           if (!forum_access_access($tid, 'update')) {
92
-            $form['buttons']['submit']['#access'] = FALSE;
93
-            $form['buttons']['preview']['#access'] = FALSE;
92
+            $form['buttons']['submit']['#access'] = false;
93
+            $form['buttons']['preview']['#access'] = false;
94 94
           }
95 95
           if (!forum_access_access($tid, 'delete')) {
96
-            $form['buttons']['delete']['#access'] = FALSE;
96
+            $form['buttons']['delete']['#access'] = false;
97 97
           }
98 98
           break;
99 99
         default:
100
-          if (array_search($key, $allowed_elements) === FALSE) {
101
-            $form[$key]['#access'] = FALSE;
100
+          if (array_search($key, $allowed_elements) === false) {
101
+            $form[$key]['#access'] = false;
102 102
           }
103 103
       }
104 104
     }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         switch (arg(0)) {
123 123
           case 'node':
124 124
               // Remove the in-line comment form, replace with text message to user.
125
-              $form = NULL;
125
+              $form = null;
126 126
               $form['from'] = array(
127 127
                   '#type'  => 'item',
128 128
                   '#value' => 'You do not have permission to post comments in this forum.',);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         if (isset($form['admin']) && !empty($user->_forum_access_moderator)) {
141 141
           foreach (element_children($form['admin']) as $key) {
142 142
             if ($key != 'status') {
143
-              $form['admin'][$key]['#access'] = FALSE;
143
+              $form['admin'][$key]['#access'] = false;
144 144
             }
145 145
           }
146 146
         }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
   global $user;
157 157
   $rid = _forum_access_get_moderator_rid();
158 158
   $user->roles[$rid] = '(forum_access temporary)';
159
-  user_access('', NULL, TRUE); // clear the permissions cache to activate the new role
159
+  user_access('', null, true); // clear the permissions cache to activate the new role
160 160
 }
161 161
 
162 162
 /*
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
   global $user;
167 167
   $rid = _forum_access_get_moderator_rid();
168 168
   unset($user->roles[$rid]);
169
-  user_access('', NULL, TRUE); // clear the permissions cache to revert to normal
169
+  user_access('', null, true); // clear the permissions cache to revert to normal
170 170
 }
171 171
 
172 172
 /*
173 173
  * Retrieve the rid of the Forum Moderator role; if the role does not exist,
174 174
  * then create it.
175 175
  */
176
-function _forum_access_get_moderator_rid($verbose = FALSE) {
176
+function _forum_access_get_moderator_rid($verbose = false) {
177 177
   $rid = forum_access_query_moderator_rid();
178
-  if ($rid !== NULL) {
178
+  if ($rid !== null) {
179 179
     if (db_result(db_query("SELECT COUNT(rid) FROM {role} WHERE rid = %d", $rid)) == 1) {
180 180
       return $rid;
181 181
     }
@@ -208,17 +208,17 @@  discard block
 block discarded – undo
208 208
 
209 209
   $tid = $variables['node']->tid;
210 210
   $links = module_invoke_all('link', 'comment', $variables['comment'], 0);
211
-  if (!empty($user->_forum_access_moderator) && arg(0) == 'node' && arg(2) == NULL) {
211
+  if (!empty($user->_forum_access_moderator) && arg(0) == 'node' && arg(2) == null) {
212 212
     _forum_access_disable_moderator();
213 213
   }
214 214
 
215
-  if (isset($links['comment_reply']) && (!preg_match('#<li class="[^"]*comment_reply[^"]*".*</li>#U', $variables['links']) || !user_access('post comments') || !forum_access_access($tid, 'comment_create', NULL, FALSE))) {
215
+  if (isset($links['comment_reply']) && (!preg_match('#<li class="[^"]*comment_reply[^"]*".*</li>#U', $variables['links']) || !user_access('post comments') || !forum_access_access($tid, 'comment_create', null, false))) {
216 216
     unset($links['comment_reply']);
217 217
   }
218
-  if (isset($links['comment_edit']) && !forum_access_access($tid, 'update', NULL, FALSE) && !comment_access('edit', $variables['comment'])) {
218
+  if (isset($links['comment_edit']) && !forum_access_access($tid, 'update', null, false) && !comment_access('edit', $variables['comment'])) {
219 219
     unset($links['comment_edit']);
220 220
   }
221
-  if (isset($links['comment_delete']) && !forum_access_access($tid, 'delete', NULL, FALSE) && !user_access('administer comments')) {
221
+  if (isset($links['comment_delete']) && !forum_access_access($tid, 'delete', null, false) && !user_access('administer comments')) {
222 222
     unset($links['comment_delete']);
223 223
   }
224 224
   foreach (array_keys($links) as $link) {
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
   if (empty($links)) {
236 236
     $links['comment_forbidden'] = array(
237 237
       'title' => theme('comment_post_forbidden', $variables['node']),
238
-      'html'  => TRUE,
238
+      'html'  => true,
239 239
     );
240 240
   }
241 241
   $variables['links'] = theme('links', $links);
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/forum_access/forum_access.module 5 patches
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
  * roles as ACLs, so rids translate directly to gids.
16 16
  */
17 17
 function forum_access_node_grants($user, $op) {
18
-  $grants['forum_access'] = array_keys($user->roles);
19
-  return $grants;
18
+    $grants['forum_access'] = array_keys($user->roles);
19
+    return $grants;
20 20
 }
21 21
 
22 22
 /**
@@ -26,51 +26,51 @@  discard block
 block discarded – undo
26 26
  * Checks to see if maybe we're being disabled.
27 27
  */
28 28
 function forum_access_node_access_records($node) {
29
-  if (!forum_access_enabled()) {
29
+    if (!forum_access_enabled()) {
30 30
     return;
31
-  }
31
+    }
32 32
 
33
-  static $grants = array();
34
-  static $node_admins;
35
-  $tid = _forum_access_get_tid($node);
33
+    static $grants = array();
34
+    static $node_admins;
35
+    $tid = _forum_access_get_tid($node);
36 36
 
37
-  // Set proper grants for nodecomment comment nodes.
38
-  if (isset($node->comment_target_nid)) {
37
+    // Set proper grants for nodecomment comment nodes.
38
+    if (isset($node->comment_target_nid)) {
39 39
     if ($changed_tid = _forum_access_changed_tid()) {
40
-      $tid = $changed_tid; // the topic node hasn't been saved yet!
40
+        $tid = $changed_tid; // the topic node hasn't been saved yet!
41 41
     }
42 42
     else {
43
-      $node = node_load($node->comment_target_nid);
44
-      $tid = _forum_access_get_tid($node);
43
+        $node = node_load($node->comment_target_nid);
44
+        $tid = _forum_access_get_tid($node);
45
+    }
45 46
     }
46
-  }
47 47
 
48
-  if ($tid) {
48
+    if ($tid) {
49 49
     if (!isset($grants[$tid])) {
50
-      if (!isset($node_admins)) {
50
+        if (!isset($node_admins)) {
51 51
         $node_admins = user_roles(FALSE, 'administer nodes');
52
-      }
53
-      $result = db_query('SELECT * FROM {forum_access} WHERE tid = %d', $tid);
54
-      while ($grant = db_fetch_object($result)) {
52
+        }
53
+        $result = db_query('SELECT * FROM {forum_access} WHERE tid = %d', $tid);
54
+        while ($grant = db_fetch_object($result)) {
55 55
         if (isset($node_admins[$grant->rid])) {
56
-          continue; // Don't provide any useless grants!
56
+            continue; // Don't provide any useless grants!
57 57
         }
58 58
         $grants[$tid][] = array(
59
-          'realm' => 'forum_access',
60
-          'gid' => $grant->rid,
61
-          'grant_view' => $grant->grant_view,
62
-          'grant_update' => $grant->grant_update,
63
-          'grant_delete' => $grant->grant_delete,
64
-          'grant_comment_create' => $grant->grant_comment_create,
65
-          'priority' => $grant->priority,
59
+            'realm' => 'forum_access',
60
+            'gid' => $grant->rid,
61
+            'grant_view' => $grant->grant_view,
62
+            'grant_update' => $grant->grant_update,
63
+            'grant_delete' => $grant->grant_delete,
64
+            'grant_comment_create' => $grant->grant_comment_create,
65
+            'priority' => $grant->priority,
66 66
         );
67
-      }
68
-      //drupal_set_message("forum_access_node_access_records($node->nid) (tid=$tid) returns ". var_export($grants[$tid], TRUE), 'status');
67
+        }
68
+        //drupal_set_message("forum_access_node_access_records($node->nid) (tid=$tid) returns ". var_export($grants[$tid], TRUE), 'status');
69 69
     }
70 70
     if (isset($grants[$tid])) {
71
-      return $grants[$tid];
71
+        return $grants[$tid];
72
+    }
72 73
     }
73
-  }
74 74
 }
75 75
 
76 76
 /**
@@ -80,60 +80,60 @@  discard block
 block discarded – undo
80 80
  * and comment/delete/% where needed.
81 81
  */
82 82
 function forum_access_init() {
83
-  global $user;
84
-  if ($user->uid == 1) {
83
+    global $user;
84
+    if ($user->uid == 1) {
85 85
     return;
86
-  }
86
+    }
87 87
 
88
-  switch (arg(0)) {
88
+    switch (arg(0)) {
89 89
     case 'comment':
90 90
       if (variable_get('forum_access_D5_legacy_mode', FALSE)) {
91 91
         return; // disable comment access control
92
-      }
93
-      if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) {
92
+        }
93
+        if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) {
94 94
         if (is_numeric($cid = arg(2))) { // comment/edit/%, comment/delete/%
95
-          $access[] = (arg(1) == 'edit' ? 'update' : 'delete');
96
-          $comment = _comment_load($cid);
97
-          $nid = $comment->nid;
98
-          // If the node turns out to be in a forum where we have update/delete
99
-          // access, then we need Moderator permissions now, so we can moderate
100
-          // this comment.
101
-          // We won't provide full Administrator access, though: we'll remove
102
-          // author and timestamp, for example.
103
-          $grant_normal_access = TRUE;
104
-        }
105
-      }
106
-      break;
95
+            $access[] = (arg(1) == 'edit' ? 'update' : 'delete');
96
+            $comment = _comment_load($cid);
97
+            $nid = $comment->nid;
98
+            // If the node turns out to be in a forum where we have update/delete
99
+            // access, then we need Moderator permissions now, so we can moderate
100
+            // this comment.
101
+            // We won't provide full Administrator access, though: we'll remove
102
+            // author and timestamp, for example.
103
+            $grant_normal_access = TRUE;
104
+        }
105
+        }
106
+        break;
107 107
 
108 108
     case 'node':
109 109
       if (is_numeric(arg(1))) {
110 110
         if (arg(2) == 'edit' && !user_access('administer nodes')) { // node/%/edit
111
-          $access[] = 'update';
112
-          $nid = arg(1);
113
-          // If the node turns out to be in a forum where we have update/delete
114
-          // access, then we already get limited edit capabilities from NA, but
115
-          // we need some more, e.g. publish/unpublish and comment status.
116
-          // In order to get these controls on the form, we need Moderator
117
-          // permissions now.
118
-          // We won't provide full Administrator access, though: we'll remove
119
-          // author and timestamp, for example.
111
+            $access[] = 'update';
112
+            $nid = arg(1);
113
+            // If the node turns out to be in a forum where we have update/delete
114
+            // access, then we already get limited edit capabilities from NA, but
115
+            // we need some more, e.g. publish/unpublish and comment status.
116
+            // In order to get these controls on the form, we need Moderator
117
+            // permissions now.
118
+            // We won't provide full Administrator access, though: we'll remove
119
+            // author and timestamp, for example.
120 120
         }
121 121
         if (arg(2) == 'delete' && !user_access('administer nodes')) { // node/%/delete
122
-          $access = array();
123
-          $nid = arg(1);
124
-          // This is the delete confirmation page. We don't need any
125
-          // additional permissions, but we'll assert 'view' access below.
122
+            $access = array();
123
+            $nid = arg(1);
124
+            // This is the delete confirmation page. We don't need any
125
+            // additional permissions, but we'll assert 'view' access below.
126 126
         }
127 127
         if (arg(2) == NULL && !user_access('administer comments')) { // node/%
128
-          $access[] = 'update';
129
-          $nid = arg(1);
130
-          // If the node turns out to be in a forum where we have update/delete
131
-          // access, then we'll get the 'Edit' link automatically from NA, but
132
-          // we'll need Moderator permissions, so that we can add the edit/delete
133
-          // comment links (*after* we've identified the other comment links).
128
+            $access[] = 'update';
129
+            $nid = arg(1);
130
+            // If the node turns out to be in a forum where we have update/delete
131
+            // access, then we'll get the 'Edit' link automatically from NA, but
132
+            // we'll need Moderator permissions, so that we can add the edit/delete
133
+            // comment links (*after* we've identified the other comment links).
134 134
         }
135
-      }
136
-      break;
135
+        }
136
+        break;
137 137
 
138 138
     case 'community':
139 139
         if (arg(1)=='forum') {
@@ -155,30 +155,30 @@  discard block
 block discarded – undo
155 155
             }// is_numeric(arg(2))
156 156
         }// arg(1)==forum
157 157
     break;
158
-  }// switch
159
-  if (isset($nid)) {
158
+    }// switch
159
+    if (isset($nid)) {
160 160
     $node = node_load($nid);
161 161
     if ($tid = _forum_access_get_tid($node)) {
162
-      if (!forum_access_access($tid, 'view')) {
162
+        if (!forum_access_access($tid, 'view')) {
163 163
         drupal_access_denied();
164 164
         module_invoke_all('exit');
165 165
         exit;
166
-      }
167
-      foreach ($access as $a) {
166
+        }
167
+        foreach ($access as $a) {
168 168
         $faa = forum_access_access($tid, $a);
169 169
         $grant_moderator_access = $faa > 1;
170 170
         $grant_normal_access = !empty($grant_normal_access) && $faa > 0;
171 171
         if ($grant_normal_access || $grant_moderator_access) {
172
-          $user->_forum_access_moderator = $grant_moderator_access;
173
-          if (arg(0) == 'comment' || arg(0) == 'node' && arg(2) == 'edit') {
172
+            $user->_forum_access_moderator = $grant_moderator_access;
173
+            if (arg(0) == 'comment' || arg(0) == 'node' && arg(2) == 'edit') {
174 174
             module_load_include('node.inc', 'forum_access');
175 175
             _forum_access_enable_moderator();
176 176
             break;
177
-          }
177
+            }
178 178
         }
179
-      }
179
+        }
180
+    }
180 181
     }
181
-  }
182 182
 }
183 183
 
184 184
 /**
@@ -187,50 +187,50 @@  discard block
 block discarded – undo
187 187
  * Alter the node/comment create/edit forms and various admin forms.
188 188
  */
189 189
 function forum_access_form_alter(&$form, &$form_state, $form_id) {
190
-  if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) {
190
+    if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) {
191 191
     module_load_include('node.inc', 'forum_access');
192 192
     _forum_access_node_form($form, $form_state);
193
-  }
194
-  elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', FALSE)) {
193
+    }
194
+    elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', FALSE)) {
195 195
     module_load_include('node.inc', 'forum_access');
196 196
     _forum_access_comment_form($form, $form_state);
197
-  }
198
-  elseif ($form_id == 'forum_overview') {
197
+    }
198
+    elseif ($form_id == 'forum_overview') {
199 199
     module_load_include('admin.inc', 'forum_access');
200 200
     _forum_access_forum_overview($form, $form_state);
201
-  }
202
-  elseif ($form_id == 'forum_form_container') {
201
+    }
202
+    elseif ($form_id == 'forum_form_container') {
203 203
     module_load_include('admin.inc', 'forum_access');
204 204
     _forum_access_forum_form($form, $form_state, TRUE);
205
-  }
206
-  elseif ($form_id == 'forum_form_forum') {
205
+    }
206
+    elseif ($form_id == 'forum_form_forum') {
207 207
     module_load_include('admin.inc', 'forum_access');
208 208
     _forum_access_forum_form($form, $form_state, FALSE);
209
-  }
210
-  elseif ($form_id == 'forum_admin_settings') {
209
+    }
210
+    elseif ($form_id == 'forum_admin_settings') {
211 211
     module_load_include('admin.inc', 'forum_access');
212 212
     _forum_access_forum_admin_settings_form($form, $form_state);
213
-  }
214
-  elseif ($form_id == 'user_admin_role') {
213
+    }
214
+    elseif ($form_id == 'user_admin_role') {
215 215
     module_load_include('admin.inc', 'forum_access');
216 216
     _forum_access_user_admin_role_form($form, $form_state);
217
-  }
218
-  elseif ($form_id == 'content_access_admin_settings' && empty($_POST)) {
217
+    }
218
+    elseif ($form_id == 'content_access_admin_settings' && empty($_POST)) {
219 219
     module_load_include('admin.inc', 'forum_access');
220 220
     _forum_access_content_access_admin_form();
221
-  }
222
-  elseif ($form_id == 'user_admin_perm') {
221
+    }
222
+    elseif ($form_id == 'user_admin_perm') {
223 223
     module_load_include('admin.inc', 'forum_access');
224 224
     _forum_access_user_admin_perm_form($form, $form_state);
225
-  }
226
-  elseif ($form_id == 'user_admin_account') {
225
+    }
226
+    elseif ($form_id == 'user_admin_account') {
227 227
     module_load_include('admin.inc', 'forum_access');
228 228
     _forum_access_user_admin_account_form($form, $form_state);
229
-  }
230
-  elseif ($form_id == 'user_profile_form') {
229
+    }
230
+    elseif ($form_id == 'user_profile_form') {
231 231
     module_load_include('admin.inc', 'forum_access');
232 232
     _forum_access_user_profile_form($form, $form_state);
233
-  }
233
+    }
234 234
 }
235 235
 
236 236
 /**
@@ -241,41 +241,41 @@  discard block
 block discarded – undo
241 241
  * taxonomy. There should be.
242 242
  */
243 243
 function forum_access_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
244
-  global $user;
245
-  $sql = NULL;
246
-  switch ($primary_field) {
244
+    global $user;
245
+    $sql = NULL;
246
+    switch ($primary_field) {
247 247
     case 'tid':
248 248
       if ($user->uid == 1
249 249
         || user_access('administer nodes') && strpos($_GET['q'], 'node/add/forum') === FALSE
250 250
         || user_access('administer forums') && $_GET['q'] == 'admin/content/forum') {
251 251
         break;
252
-      }
253
-      if (strpos($_GET['q'], 'node/add/forum') !== FALSE) {
252
+        }
253
+        if (strpos($_GET['q'], 'node/add/forum') !== FALSE) {
254 254
         $required_access = 'create';
255
-      }
256
-      else {
255
+        }
256
+        else {
257 257
         $required_access = 'view';
258
-      }
259
-      $roles = implode(', ', array_keys($user->roles));
260
-      $sql['join'] = "LEFT JOIN {forum_access} fa ON $primary_table.tid = fa.tid
258
+        }
259
+        $roles = implode(', ', array_keys($user->roles));
260
+        $sql['join'] = "LEFT JOIN {forum_access} fa ON $primary_table.tid = fa.tid
261 261
                       LEFT JOIN {acl} acl_fa ON acl_fa.number = $primary_table.tid AND acl_fa.module = 'forum_access'
262 262
                       LEFT JOIN {acl_user} aclu_fa ON aclu_fa.acl_id = acl_fa.acl_id AND aclu_fa.uid = $user->uid";
263
-      $sql['where'] = "(fa.grant_$required_access >= 1 AND fa.rid IN ($roles)) OR fa.tid IS NULL OR aclu_fa.uid = $user->uid";
264
-      $sql['distinct'] = 1;
265
-      break;
263
+        $sql['where'] = "(fa.grant_$required_access >= 1 AND fa.rid IN ($roles)) OR fa.tid IS NULL OR aclu_fa.uid = $user->uid";
264
+        $sql['distinct'] = 1;
265
+        break;
266 266
 
267 267
     case 'rid':
268 268
       if (strpos($query, 'FROM {role}') === FALSE
269 269
         || strpos($_GET['q'] .'/', 'admin/content/forum/') === 0) {
270 270
         break;
271
-      }
272
-      $moderator_rid = forum_access_query_moderator_rid();
273
-      if (!empty($moderator_rid)) {
271
+        }
272
+        $moderator_rid = forum_access_query_moderator_rid();
273
+        if (!empty($moderator_rid)) {
274 274
         $sql['where'] = "$primary_table.rid <> $moderator_rid";
275
-      }
276
-      break;
277
-  }
278
-  return $sql;
275
+        }
276
+        break;
277
+    }
278
+    return $sql;
279 279
 }
280 280
 
281 281
 /**
@@ -284,43 +284,43 @@  discard block
 block discarded – undo
284 284
  * Add ACL data to fresh forum posts.
285 285
  */
286 286
 function forum_access_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
287
-  static $old_tid = NULL;
288
-  // This is modeled after forum_nodeapi():
289
-  $vid = _forum_access_get_vid();
290
-  $vocabulary = taxonomy_vocabulary_load($vid);
291
-  if (empty($vocabulary) || !in_array($node->type, $vocabulary->nodes)) {
287
+    static $old_tid = NULL;
288
+    // This is modeled after forum_nodeapi():
289
+    $vid = _forum_access_get_vid();
290
+    $vocabulary = taxonomy_vocabulary_load($vid);
291
+    if (empty($vocabulary) || !in_array($node->type, $vocabulary->nodes)) {
292 292
     if ($op == 'insert' && isset($node->comment_target_nid)) {
293
-      // Set moderator on nodecomment.
294
-      $topic_node = node_load($node->comment_target_nid);
295
-      if ($topic_tid = _forum_access_get_tid($topic_node)) {
293
+        // Set moderator on nodecomment.
294
+        $topic_node = node_load($node->comment_target_nid);
295
+        if ($topic_tid = _forum_access_get_tid($topic_node)) {
296 296
         $acl_id = acl_get_id_by_number('forum_access', $topic_tid);
297 297
         acl_node_add_acl($node->nid, $acl_id, 1, 1, 1);
298
-      }
298
+        }
299 299
     }
300 300
     return;
301
-  }
301
+    }
302 302
 
303
-  switch ($op) {
303
+    switch ($op) {
304 304
     case 'presave':
305 305
       $old_tid = db_result(db_query('SELECT tid FROM {forum} WHERE nid = %d', $node->nid));
306
-      break;
306
+        break;
307 307
 
308 308
     case 'update':
309 309
       if (!empty($old_tid)) {
310 310
         if (!empty($node->tid) && $node->tid == $old_tid) {
311
-          return;
311
+            return;
312 312
         }
313 313
         acl_node_clear_acls($node->nid, 'forum_access');
314 314
 
315 315
         if (module_exists('nodecomment')) {
316
-          _forum_access_changed_tid($node->tid);
317
-          $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid);
318
-          while ($row = db_fetch_object($result)) {
316
+            _forum_access_changed_tid($node->tid);
317
+            $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid);
318
+            while ($row = db_fetch_object($result)) {
319 319
             acl_node_clear_acls($row->cid, 'forum_access');
320
-          }
320
+            }
321
+        }
321 322
         }
322
-      }
323
-      // Deliberate no break -- for changed and for previously unassigned terms we need an insert.
323
+        // Deliberate no break -- for changed and for previously unassigned terms we need an insert.
324 324
 
325 325
     case 'insert':
326 326
       if (!empty($node->tid)) {
@@ -328,27 +328,27 @@  discard block
 block discarded – undo
328 328
         acl_node_add_acl($node->nid, $acl_id, 1, 1, 1);
329 329
 
330 330
         if (isset($old_tid) && module_exists('nodecomment')) {
331
-          $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid);
332
-          while ($row = db_fetch_object($result)) {
331
+            $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid);
332
+            while ($row = db_fetch_object($result)) {
333 333
             acl_node_add_acl($row->cid, $acl_id, 1, 1, 1);
334 334
             node_access_acquire_grants(node_load($row->cid));
335
-          }
335
+            }
336 336
         }
337
-      }
338
-      $old_tid = NULL;
339
-      break;
340
-  }
337
+        }
338
+        $old_tid = NULL;
339
+        break;
340
+    }
341 341
 }
342 342
 
343 343
 /**
344 344
  * Get an array of moderator UIDs or NULL.
345 345
  */
346 346
 function forum_access_get_moderator_uids($tid) {
347
-  if ($acl_id = acl_get_id_by_number('forum_access', $tid)) {
347
+    if ($acl_id = acl_get_id_by_number('forum_access', $tid)) {
348 348
     if ($uids = acl_get_uids($acl_id)) {
349
-      return $uids;
349
+        return $uids;
350
+    }
350 351
     }
351
-  }
352 352
 }
353 353
 
354 354
 /**
@@ -361,21 +361,21 @@  discard block
 block discarded – undo
361 361
  * and thus it is disabled by default. Set the variable to TRUE to enable.
362 362
  */
363 363
 function forum_access_preprocess_forum_list(&$variables) {
364
-  if (variable_get('forum_access_provide_moderators_template_variable', FALSE)) {
364
+    if (variable_get('forum_access_provide_moderators_template_variable', FALSE)) {
365 365
     static $users;
366 366
     foreach ($variables['forums'] as $tid => $forum) {
367
-      $moderators = array();
368
-      if ($uids = forum_access_get_moderator_uids($tid)) {
367
+        $moderators = array();
368
+        if ($uids = forum_access_get_moderator_uids($tid)) {
369 369
         foreach ($uids as $uid) {
370
-          if (!isset($users[$uid])) {
370
+            if (!isset($users[$uid])) {
371 371
             $users[$uid] = user_load(array('uid' => $uid));
372
-          }
373
-          $moderators[$uid] = $users[$uid];
372
+            }
373
+            $moderators[$uid] = $users[$uid];
374
+        }
374 375
         }
375
-      }
376
-      $forum->forum_access_moderators = (empty($moderators) ? NULL : $moderators);
376
+        $forum->forum_access_moderators = (empty($moderators) ? NULL : $moderators);
377
+    }
377 378
     }
378
-  }
379 379
 }
380 380
 
381 381
 /**
@@ -385,17 +385,17 @@  discard block
 block discarded – undo
385 385
  * 'create' permission.
386 386
  */
387 387
 function forum_access_preprocess_forums(&$variables) {
388
-  if (!forum_access_access($variables['tid'], 'create') && !empty($variables['links'])) {
388
+    if (!forum_access_access($variables['tid'], 'create') && !empty($variables['links'])) {
389 389
     foreach ($variables['links'] as $key => $link) {
390
-      if (isset($link['href']) && substr($link['href'], 0, 9) == 'node/add/') {
390
+        if (isset($link['href']) && substr($link['href'], 0, 9) == 'node/add/') {
391 391
         unset($variables['links'][$key]);
392
-      }
392
+        }
393
+    }
393 394
     }
394
-  }
395 395
 }
396 396
 
397 397
 if (!variable_get('forum_access_D5_legacy_mode', FALSE)) {
398
-  // LEGACY-MODE disables these methods
398
+    // LEGACY-MODE disables these methods
399 399
 
400 400
 /**
401 401
  * Implementation of hook_link_alter().
@@ -404,42 +404,42 @@  discard block
 block discarded – undo
404 404
  * 'comment_create' permission; for comments, add any missing links (D6.17+).
405 405
  */
406 406
 function forum_access_link_alter(&$links, $node, $comment = NULL) {
407
-  global $user;
408
-  static $user1, $recursing = FALSE, $stored_links;
407
+    global $user;
408
+    static $user1, $recursing = FALSE, $stored_links;
409 409
 
410
-  // If we are being called recursively, store the $links and return.
411
-  if ($recursing) {
410
+    // If we are being called recursively, store the $links and return.
411
+    if ($recursing) {
412 412
     $stored_links = $links;
413 413
     return;
414
-  }
415
-  if ($user->uid == 1 || !($tid = _forum_access_get_tid($node))) {
414
+    }
415
+    if ($user->uid == 1 || !($tid = _forum_access_get_tid($node))) {
416 416
     return;
417
-  }
418
-  if (empty($comment)) {
417
+    }
418
+    if (empty($comment)) {
419 419
     // Check links for the node.
420 420
     if ($tid && isset($links['comment_add']) && !forum_access_access($tid, 'comment_create')) {
421
-      unset($links['comment_add']);
422
-      // Hack to manually remove quote link
423
-      if ( isset($links['quote']) ) {
424
-          unset($links['quote']);
425
-      }
426
-    }
427
-  }
428
-  else {
421
+        unset($links['comment_add']);
422
+        // Hack to manually remove quote link
423
+        if ( isset($links['quote']) ) {
424
+            unset($links['quote']);
425
+        }
426
+    }
427
+    }
428
+    else {
429 429
     // Check links for the comment.
430 430
     $required_keys = array(
431
-      'comment_create' => 'comment_reply',
432
-      'update' => 'comment_edit',
433
-      'delete' => 'comment_delete',
431
+        'comment_create' => 'comment_reply',
432
+        'update' => 'comment_edit',
433
+        'delete' => 'comment_delete',
434 434
     );
435 435
     foreach ($required_keys as $access => $key) {
436
-      if (!forum_access_access($tid, $access) && !($access == 'update' && comment_access('edit', $comment))) {
436
+        if (!forum_access_access($tid, $access) && !($access == 'update' && comment_access('edit', $comment))) {
437 437
         unset($links[$required_keys[$access]]);
438 438
         unset($required_keys[$access]);
439
-      }
440
-      elseif (!array_key_exists($key, $links)) {
439
+        }
440
+        elseif (!array_key_exists($key, $links)) {
441 441
         $link_is_missing = TRUE;
442
-      }
442
+        }
443 443
     }
444 444
 
445 445
     // Hack to manually remove quote link if comment_reply link is no longer set
@@ -448,48 +448,48 @@  discard block
 block discarded – undo
448 448
     }
449 449
     
450 450
     if (isset($required_keys['comment_create']) && !user_access('post comments')) {
451
-      unset($required_keys['comment_create']);
451
+        unset($required_keys['comment_create']);
452 452
     }
453 453
     if (!empty($link_is_missing)) {
454
-      // One of the $required_links should be present, because the current
455
-      // user has the corresponding permission, but it isn't.
456
-      // We temporarily switch to UID 1 to 'harvest' all comment links.
457
-      if (!isset($user1)) {
454
+        // One of the $required_links should be present, because the current
455
+        // user has the corresponding permission, but it isn't.
456
+        // We temporarily switch to UID 1 to 'harvest' all comment links.
457
+        if (!isset($user1)) {
458 458
         $user1 = user_load(1);
459
-      }
460
-      $saved_user = $user;
461
-      session_save_session(FALSE);
462
-      $user = $user1;
463
-
464
-      // With UID 1 we call hook_link(). This should give us the full set of
465
-      // links that the site admin sees.
466
-      $admin_links = module_invoke_all('link', 'comment', $comment, array_key_exists('comment_parent', $links));
467
-
468
-      $user = $saved_user;
469
-      session_save_session(TRUE);
470
-
471
-      // Remove the links from $admin_links that are not in the reduced
472
-      // set of $required_links AND not available to the current user anyway.
473
-      // Afterwards, $admin_links should have the same content as $links, plus
474
-      // one or more additional links from the original set in $required_links.
475
-      foreach ($admin_links as $key => $target) {
459
+        }
460
+        $saved_user = $user;
461
+        session_save_session(FALSE);
462
+        $user = $user1;
463
+
464
+        // With UID 1 we call hook_link(). This should give us the full set of
465
+        // links that the site admin sees.
466
+        $admin_links = module_invoke_all('link', 'comment', $comment, array_key_exists('comment_parent', $links));
467
+
468
+        $user = $saved_user;
469
+        session_save_session(TRUE);
470
+
471
+        // Remove the links from $admin_links that are not in the reduced
472
+        // set of $required_links AND not available to the current user anyway.
473
+        // Afterwards, $admin_links should have the same content as $links, plus
474
+        // one or more additional links from the original set in $required_links.
475
+        foreach ($admin_links as $key => $target) {
476 476
         if (!in_array($key, $required_keys) && !array_key_exists($key, $links)) {
477
-          unset($admin_links[$key]);
478
-        }
479
-      }
480
-
481
-      // As the real current user, call hook_link_alter on the admin links.
482
-      // First we set a static variable so that the next time this function is
483
-      // called it will store a copy of the links at their current state. Then
484
-      // we pull those links which have not been link_alter'ed by any modules
485
-      // that come after forum_access.
486
-      $recursing = TRUE;
487
-      drupal_alter('link', $admin_links, $node, $comment);
488
-      $recursing = FALSE;
489
-      // Now return the stored links.
490
-      $links = $stored_links;
491
-    }
492
-  }// if empty($comment)
477
+            unset($admin_links[$key]);
478
+        }
479
+        }
480
+
481
+        // As the real current user, call hook_link_alter on the admin links.
482
+        // First we set a static variable so that the next time this function is
483
+        // called it will store a copy of the links at their current state. Then
484
+        // we pull those links which have not been link_alter'ed by any modules
485
+        // that come after forum_access.
486
+        $recursing = TRUE;
487
+        drupal_alter('link', $admin_links, $node, $comment);
488
+        $recursing = FALSE;
489
+        // Now return the stored links.
490
+        $links = $stored_links;
491
+    }
492
+    }// if empty($comment)
493 493
 }
494 494
 
495 495
 /**
@@ -499,10 +499,10 @@  discard block
 block discarded – undo
499 499
  * (after _forum_access_comment_form()).
500 500
  */
501 501
 function forum_access_preprocess_box(&$variables) {
502
-  $tr = 't';
503
-  if (empty($variables['content']) && ($variables['title'] == $tr('Post new comment') || $variables['title'] == $tr('Reply'))) {
502
+    $tr = 't';
503
+    if (empty($variables['content']) && ($variables['title'] == $tr('Post new comment') || $variables['title'] == $tr('Reply'))) {
504 504
     $variables['title'] = '';
505
-  }
505
+    }
506 506
 }
507 507
 
508 508
 /**
@@ -512,10 +512,10 @@  discard block
 block discarded – undo
512 512
  * remove those that aren't accessible to the user.
513 513
  */
514 514
 function forum_access_preprocess_comment(&$variables) {
515
-  if (version_compare(VERSION, '6.17', '<') && isset($variables['node']->tid)) {
515
+    if (version_compare(VERSION, '6.17', '<') && isset($variables['node']->tid)) {
516 516
     module_load_include('node.inc', 'forum_access');
517 517
     _forum_access_preprocess_comment($variables);
518
-  }
518
+    }
519 519
 }
520 520
 
521 521
 } // End of !LEGACY-MODE
@@ -524,11 +524,11 @@  discard block
 block discarded – undo
524 524
  * This is also required by ACL module.
525 525
  */
526 526
 function forum_access_enabled($set = NULL) {
527
-  static $enabled = TRUE;
528
-  if ($set !== NULL) {
527
+    static $enabled = TRUE;
528
+    if ($set !== NULL) {
529 529
     $enabled = $set;
530
-  }
531
-  return $enabled;
530
+    }
531
+    return $enabled;
532 532
 }
533 533
 
534 534
 /**
@@ -545,63 +545,63 @@  discard block
 block discarded – undo
545 545
  *   2     - access granted for forum moderator
546 546
  */
547 547
 function forum_access_access($tid, $type, $account = NULL, $administer_nodes_sees_everything = TRUE) {
548
-  static $cache = array();
549
-  if (!$account) {
548
+    static $cache = array();
549
+    if (!$account) {
550 550
     global $user;
551 551
     $account = $user;
552
-  }
552
+    }
553 553
 
554
-  if ($account->uid == 1 ||
554
+    if ($account->uid == 1 ||
555 555
       $administer_nodes_sees_everything && user_access('administer nodes', $account) && array_search($type, array('view', 'update', 'delete')) !== FALSE) {
556 556
     return 1;
557
-  }
557
+    }
558 558
 
559
-  if (!isset($cache[$account->uid][$tid][$type])) {
559
+    if (!isset($cache[$account->uid][$tid][$type])) {
560 560
     if (!user_access('access content', $account)) {
561
-      return $cache[$account->uid][$tid][$type] = FALSE;
561
+        return $cache[$account->uid][$tid][$type] = FALSE;
562 562
     }
563 563
 
564 564
     $roles = array_keys($account->roles);
565 565
     $result = db_result(db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_". $type ." = 1 AND tid = %d", array_merge($roles, array($tid))));
566 566
 
567 567
     if ($result) {
568
-      $cache[$account->uid][$tid][$type] = 1;
568
+        $cache[$account->uid][$tid][$type] = 1;
569 569
     }
570 570
     else {
571
-      // check our moderators too
572
-      $acl_id = acl_get_id_by_number('forum_access', $tid);
573
-      $result = db_result(db_query("SELECT uid FROM {acl_user} WHERE acl_id = %d AND uid = %d", $acl_id, $account->uid));
574
-      if ($result) {
571
+        // check our moderators too
572
+        $acl_id = acl_get_id_by_number('forum_access', $tid);
573
+        $result = db_result(db_query("SELECT uid FROM {acl_user} WHERE acl_id = %d AND uid = %d", $acl_id, $account->uid));
574
+        if ($result) {
575 575
         $cache[$account->uid][$tid][$type] = 2;
576
-      }
577
-      else {
576
+        }
577
+        else {
578 578
         $cache[$account->uid][$tid][$type] = FALSE;
579
-      }
579
+        }
580 580
     }
581
-  }
582
-  return $cache[$account->uid][$tid][$type];
581
+    }
582
+    return $cache[$account->uid][$tid][$type];
583 583
 }
584 584
 
585 585
 /**
586 586
  * Implementation of hook_user().
587 587
  */
588 588
 function forum_access_user($op, &$edit, &$account, $category = NULL) {
589
-  switch ($op) {
589
+    switch ($op) {
590 590
     case 'validate':
591 591
       $rid = forum_access_query_moderator_rid();
592
-      if (!empty($rid)) {
592
+        if (!empty($rid)) {
593 593
         if (isset($edit['roles'][$rid]) && $edit['roles'][$rid]) {
594
-          $roles = user_roles();
595
-          $variables = array(
594
+            $roles = user_roles();
595
+            $variables = array(
596 596
             '@Forum_Access' => 'Forum Access',
597 597
             '%Role' => $roles[$rid],
598
-          );
599
-          drupal_set_message(t('The %Role role is reserved for internal use by the @Forum_Access module! It was not assigned.', $variables), 'warning');
600
-          unset($edit['roles'][$rid]);
598
+            );
599
+            drupal_set_message(t('The %Role role is reserved for internal use by the @Forum_Access module! It was not assigned.', $variables), 'warning');
600
+            unset($edit['roles'][$rid]);
601
+        }
601 602
         }
602
-      }
603
-      break;
604
-  }
603
+        break;
604
+    }
605 605
 }
606 606
 
607 607
 /**
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
  * Remove the 'Forum' menu item if no forums are visible.
611 611
  */
612 612
 function forum_access_menu_alter(&$items) {
613
-  if (!empty($items['forum'])) {
613
+    if (!empty($items['forum'])) {
614 614
     //dpm($items['forum'], 'hook_menu_alter($items[\'forum\'])');
615 615
     if (!empty($items['forum']['access callback']) || $items['forum']['access arguments'][0] != 'access content') {
616
-      drupal_set_message(t('Unexpected access specification for the %forum menu path; @Forum_Access cannot control its access.', array('%forum' => 'forum', '@Forum_Access' => 'Forum Access')), 'error');
617
-      return;
616
+        drupal_set_message(t('Unexpected access specification for the %forum menu path; @Forum_Access cannot control its access.', array('%forum' => 'forum', '@Forum_Access' => 'Forum Access')), 'error');
617
+        return;
618 618
     }
619 619
     $items['forum']['access callback'] = '_forum_access_forum_access_callback';
620 620
     $items['forum']['access arguments'] = array(1);
621
-  }
621
+    }
622 622
 }
623 623
 
624 624
 /**
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
  * one role that can access at least one forum.
630 630
  */
631 631
 function _forum_access_forum_access_callback($tid = NULL) {
632
-  return (!$tid && _forum_access_access_any_forum()) || forum_access_access($tid, 'view');
632
+    return (!$tid && _forum_access_access_any_forum()) || forum_access_access($tid, 'view');
633 633
 }
634 634
 
635 635
 /**
@@ -639,37 +639,37 @@  discard block
 block discarded – undo
639 639
  * at least one forum.
640 640
  */
641 641
 function _forum_access_access_any_forum($account = NULL) {
642
-  global $user;
643
-  static $return = array();
642
+    global $user;
643
+    static $return = array();
644 644
 
645
-  if (!isset($account)) {
645
+    if (!isset($account)) {
646 646
     $account = $user;
647
-  }
647
+    }
648 648
 
649
-  if (!isset($return[$account->uid])) {
649
+    if (!isset($return[$account->uid])) {
650 650
     if ($account->uid == 1) {
651
-      return $return[$account->uid] = TRUE;
651
+        return $return[$account->uid] = TRUE;
652 652
     }
653 653
     if (!user_access('access content', $account)) {
654
-      return $return[$account->uid] = FALSE;
654
+        return $return[$account->uid] = FALSE;
655 655
     }
656 656
     $rids = variable_get('forum_access_rids', NULL);
657 657
     if (!isset($rids)) {
658
-      $rids = array();
659
-      $result = db_query("SELECT fa.rid FROM {forum_access} fa WHERE fa.grant_view > 0 GROUP BY fa.rid");
660
-      while ($role = db_fetch_object($result)) {
658
+        $rids = array();
659
+        $result = db_query("SELECT fa.rid FROM {forum_access} fa WHERE fa.grant_view > 0 GROUP BY fa.rid");
660
+        while ($role = db_fetch_object($result)) {
661 661
         $rids[] = $role->rid;
662
-      }
663
-      variable_set('forum_access_rids', $rids);
662
+        }
663
+        variable_set('forum_access_rids', $rids);
664 664
     }
665 665
     foreach ($rids as $rid) {
666
-      if (isset($account->roles[$rid])) {
666
+        if (isset($account->roles[$rid])) {
667 667
         return $return[$account->uid] = TRUE;
668
-      }
668
+        }
669 669
     }
670 670
     $return[$account->uid] = FALSE;
671
-  }
672
-  return $return[$account->uid];
671
+    }
672
+    return $return[$account->uid];
673 673
 }
674 674
 
675 675
 /**
@@ -678,18 +678,18 @@  discard block
 block discarded – undo
678 678
  * Delete {forum_access} records when forums are deleted.
679 679
  */
680 680
 function forum_access_taxonomy($op, $type, $array = NULL) {
681
-  //dpm($array, "hook_taxonomy($op, $type)");
682
-  if ($type = 'term' && $op == 'delete' && $array['vid'] == _forum_access_get_vid()) {
681
+    //dpm($array, "hook_taxonomy($op, $type)");
682
+    if ($type = 'term' && $op == 'delete' && $array['vid'] == _forum_access_get_vid()) {
683 683
     db_query("DELETE FROM {forum_access} WHERE tid = %d", $array['tid']);
684 684
     variable_del('forum_access_rids'); // clear cache
685
-  }
685
+    }
686 686
 }
687 687
 
688 688
 /**
689 689
  * Return forum.module's forum vocabulary ID.
690 690
  */
691 691
 function _forum_access_get_vid() {
692
-  return variable_get('forum_nav_vocabulary', '');
692
+    return variable_get('forum_nav_vocabulary', '');
693 693
 }
694 694
 
695 695
 /**
@@ -697,51 +697,51 @@  discard block
 block discarded – undo
697 697
  * exist.
698 698
  */
699 699
 function forum_access_query_moderator_rid() {
700
-  return variable_get('forum_access_moderator_rid', NULL);
700
+    return variable_get('forum_access_moderator_rid', NULL);
701 701
 }
702 702
 
703 703
 /**
704 704
  * Return the forum tid or FALSE.
705 705
  */
706 706
 function _forum_access_get_tid($node) {
707
-  return (isset($node->forum_tid) ? $node->forum_tid : (isset($node->tid) ? $node->tid : FALSE));
707
+    return (isset($node->forum_tid) ? $node->forum_tid : (isset($node->tid) ? $node->tid : FALSE));
708 708
 }
709 709
 
710 710
 /**
711 711
  * Save and return the $tid.
712 712
  */
713 713
 function _forum_access_changed_tid($tid = NULL) {
714
-  static $saved_tid = NULL;
715
-  if (!empty($tid)) {
714
+    static $saved_tid = NULL;
715
+    if (!empty($tid)) {
716 716
     $saved_tid = $tid;
717
-  }
718
-  return $saved_tid;
717
+    }
718
+    return $saved_tid;
719 719
 }
720 720
 
721 721
 /**
722 722
  * Implementation of hook_node_access_explain().
723 723
  */
724 724
 function forum_access_node_access_explain($row) {
725
-  static $roles = NULL;
726
-  if ($row->realm == 'forum_access') {
725
+    static $roles = NULL;
726
+    if ($row->realm == 'forum_access') {
727 727
     if (!isset($roles)) {
728
-      module_load_include('node.inc', 'forum_access');
729
-      $roles = _forum_access_get_all_roles();
728
+        module_load_include('node.inc', 'forum_access');
729
+        $roles = _forum_access_get_all_roles();
730 730
     }
731 731
     if (isset($roles[$row->gid])) {
732
-      return array($roles[$row->gid]);
732
+        return array($roles[$row->gid]);
733 733
     }
734 734
     return array('(unknown gid)');
735
-  }
735
+    }
736 736
 }
737 737
 
738 738
 /**
739 739
  * Implementation of hook_acl_explain().
740 740
  */
741 741
 function forum_access_acl_explain($acl_id, $name, $number, $users = NULL) {
742
-  if (empty($users)) {
742
+    if (empty($users)) {
743 743
     return "ACL (id=$acl_id) would grant access to nodes in forum/$number.";
744
-  }
745
-  return "ACL (id=$acl_id) grants access to nodes in forum/$number to the listed user(s).";
744
+    }
745
+    return "ACL (id=$acl_id) grants access to nodes in forum/$number to the listed user(s).";
746 746
 }
747 747
 
Please login to merge, or discard this patch.
Switch Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -86,75 +86,75 @@  discard block
 block discarded – undo
86 86
   }
87 87
 
88 88
   switch (arg(0)) {
89
-    case 'comment':
90
-      if (variable_get('forum_access_D5_legacy_mode', FALSE)) {
91
-        return; // disable comment access control
92
-      }
93
-      if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) {
94
-        if (is_numeric($cid = arg(2))) { // comment/edit/%, comment/delete/%
95
-          $access[] = (arg(1) == 'edit' ? 'update' : 'delete');
96
-          $comment = _comment_load($cid);
97
-          $nid = $comment->nid;
98
-          // If the node turns out to be in a forum where we have update/delete
99
-          // access, then we need Moderator permissions now, so we can moderate
100
-          // this comment.
101
-          // We won't provide full Administrator access, though: we'll remove
102
-          // author and timestamp, for example.
103
-          $grant_normal_access = TRUE;
104
-        }
89
+  case 'comment':
90
+    if (variable_get('forum_access_D5_legacy_mode', FALSE)) {
91
+      return; // disable comment access control
92
+    }
93
+    if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) {
94
+      if (is_numeric($cid = arg(2))) { // comment/edit/%, comment/delete/%
95
+        $access[] = (arg(1) == 'edit' ? 'update' : 'delete');
96
+        $comment = _comment_load($cid);
97
+        $nid = $comment->nid;
98
+        // If the node turns out to be in a forum where we have update/delete
99
+        // access, then we need Moderator permissions now, so we can moderate
100
+        // this comment.
101
+        // We won't provide full Administrator access, though: we'll remove
102
+        // author and timestamp, for example.
103
+        $grant_normal_access = TRUE;
105 104
       }
106
-      break;
105
+    }
106
+    break;
107 107
 
108
-    case 'node':
109
-      if (is_numeric(arg(1))) {
110
-        if (arg(2) == 'edit' && !user_access('administer nodes')) { // node/%/edit
111
-          $access[] = 'update';
112
-          $nid = arg(1);
113
-          // If the node turns out to be in a forum where we have update/delete
114
-          // access, then we already get limited edit capabilities from NA, but
115
-          // we need some more, e.g. publish/unpublish and comment status.
116
-          // In order to get these controls on the form, we need Moderator
117
-          // permissions now.
118
-          // We won't provide full Administrator access, though: we'll remove
119
-          // author and timestamp, for example.
120
-        }
121
-        if (arg(2) == 'delete' && !user_access('administer nodes')) { // node/%/delete
122
-          $access = array();
123
-          $nid = arg(1);
124
-          // This is the delete confirmation page. We don't need any
125
-          // additional permissions, but we'll assert 'view' access below.
126
-        }
127
-        if (arg(2) == NULL && !user_access('administer comments')) { // node/%
128
-          $access[] = 'update';
129
-          $nid = arg(1);
130
-          // If the node turns out to be in a forum where we have update/delete
131
-          // access, then we'll get the 'Edit' link automatically from NA, but
132
-          // we'll need Moderator permissions, so that we can add the edit/delete
133
-          // comment links (*after* we've identified the other comment links).
134
-        }
108
+  case 'node':
109
+    if (is_numeric(arg(1))) {
110
+      if (arg(2) == 'edit' && !user_access('administer nodes')) { // node/%/edit
111
+        $access[] = 'update';
112
+        $nid = arg(1);
113
+        // If the node turns out to be in a forum where we have update/delete
114
+        // access, then we already get limited edit capabilities from NA, but
115
+        // we need some more, e.g. publish/unpublish and comment status.
116
+        // In order to get these controls on the form, we need Moderator
117
+        // permissions now.
118
+        // We won't provide full Administrator access, though: we'll remove
119
+        // author and timestamp, for example.
135 120
       }
136
-      break;
137
-
138
-    case 'community':
139
-        if (arg(1)=='forum') {
140
-            if (is_numeric(arg(2))) {
141
-                $tid=arg(2);
142
-                // Obtain the tid from a URL path containing
143
-                // community/forum/%tid, this will prevent users from
144
-                // loading forums they are not allowed to access.
145
-                // However, only tid>1 are terms we care about. (This
146
-                // allows forum_tweaks mark-read functionality to
147
-                // work.)
148
-                if (isset($tid) and ($tid>1)) {
149
-                    if (!forum_access_access($tid, 'view')) {
150
-                        drupal_access_denied();
151
-                        module_invoke_all('exit');
152
-                        exit;
153
-                    }
154
-                }// isset($tid)
155
-            }// is_numeric(arg(2))
156
-        }// arg(1)==forum
121
+      if (arg(2) == 'delete' && !user_access('administer nodes')) { // node/%/delete
122
+        $access = array();
123
+        $nid = arg(1);
124
+        // This is the delete confirmation page. We don't need any
125
+        // additional permissions, but we'll assert 'view' access below.
126
+      }
127
+      if (arg(2) == NULL && !user_access('administer comments')) { // node/%
128
+        $access[] = 'update';
129
+        $nid = arg(1);
130
+        // If the node turns out to be in a forum where we have update/delete
131
+        // access, then we'll get the 'Edit' link automatically from NA, but
132
+        // we'll need Moderator permissions, so that we can add the edit/delete
133
+        // comment links (*after* we've identified the other comment links).
134
+      }
135
+    }
157 136
     break;
137
+
138
+  case 'community':
139
+      if (arg(1)=='forum') {
140
+          if (is_numeric(arg(2))) {
141
+              $tid=arg(2);
142
+              // Obtain the tid from a URL path containing
143
+              // community/forum/%tid, this will prevent users from
144
+              // loading forums they are not allowed to access.
145
+              // However, only tid>1 are terms we care about. (This
146
+              // allows forum_tweaks mark-read functionality to
147
+              // work.)
148
+              if (isset($tid) and ($tid>1)) {
149
+                  if (!forum_access_access($tid, 'view')) {
150
+                      drupal_access_denied();
151
+                      module_invoke_all('exit');
152
+                      exit;
153
+                  }
154
+              }// isset($tid)
155
+          }// is_numeric(arg(2))
156
+      }// arg(1)==forum
157
+  break;
158 158
   }// switch
159 159
   if (isset($nid)) {
160 160
     $node = node_load($nid);
@@ -244,36 +244,36 @@  discard block
 block discarded – undo
244 244
   global $user;
245 245
   $sql = NULL;
246 246
   switch ($primary_field) {
247
-    case 'tid':
248
-      if ($user->uid == 1
249
-        || user_access('administer nodes') && strpos($_GET['q'], 'node/add/forum') === FALSE
250
-        || user_access('administer forums') && $_GET['q'] == 'admin/content/forum') {
251
-        break;
252
-      }
253
-      if (strpos($_GET['q'], 'node/add/forum') !== FALSE) {
254
-        $required_access = 'create';
255
-      }
256
-      else {
257
-        $required_access = 'view';
258
-      }
259
-      $roles = implode(', ', array_keys($user->roles));
260
-      $sql['join'] = "LEFT JOIN {forum_access} fa ON $primary_table.tid = fa.tid
247
+  case 'tid':
248
+    if ($user->uid == 1
249
+      || user_access('administer nodes') && strpos($_GET['q'], 'node/add/forum') === FALSE
250
+      || user_access('administer forums') && $_GET['q'] == 'admin/content/forum') {
251
+      break;
252
+    }
253
+    if (strpos($_GET['q'], 'node/add/forum') !== FALSE) {
254
+      $required_access = 'create';
255
+    }
256
+    else {
257
+      $required_access = 'view';
258
+    }
259
+    $roles = implode(', ', array_keys($user->roles));
260
+    $sql['join'] = "LEFT JOIN {forum_access} fa ON $primary_table.tid = fa.tid
261 261
                       LEFT JOIN {acl} acl_fa ON acl_fa.number = $primary_table.tid AND acl_fa.module = 'forum_access'
262 262
                       LEFT JOIN {acl_user} aclu_fa ON aclu_fa.acl_id = acl_fa.acl_id AND aclu_fa.uid = $user->uid";
263
-      $sql['where'] = "(fa.grant_$required_access >= 1 AND fa.rid IN ($roles)) OR fa.tid IS NULL OR aclu_fa.uid = $user->uid";
264
-      $sql['distinct'] = 1;
265
-      break;
263
+    $sql['where'] = "(fa.grant_$required_access >= 1 AND fa.rid IN ($roles)) OR fa.tid IS NULL OR aclu_fa.uid = $user->uid";
264
+    $sql['distinct'] = 1;
265
+    break;
266 266
 
267
-    case 'rid':
268
-      if (strpos($query, 'FROM {role}') === FALSE
269
-        || strpos($_GET['q'] .'/', 'admin/content/forum/') === 0) {
270
-        break;
271
-      }
272
-      $moderator_rid = forum_access_query_moderator_rid();
273
-      if (!empty($moderator_rid)) {
274
-        $sql['where'] = "$primary_table.rid <> $moderator_rid";
275
-      }
267
+  case 'rid':
268
+    if (strpos($query, 'FROM {role}') === FALSE
269
+      || strpos($_GET['q'] .'/', 'admin/content/forum/') === 0) {
276 270
       break;
271
+    }
272
+    $moderator_rid = forum_access_query_moderator_rid();
273
+    if (!empty($moderator_rid)) {
274
+      $sql['where'] = "$primary_table.rid <> $moderator_rid";
275
+    }
276
+    break;
277 277
   }
278 278
   return $sql;
279 279
 }
@@ -301,42 +301,42 @@  discard block
 block discarded – undo
301 301
   }
302 302
 
303 303
   switch ($op) {
304
-    case 'presave':
305
-      $old_tid = db_result(db_query('SELECT tid FROM {forum} WHERE nid = %d', $node->nid));
306
-      break;
304
+  case 'presave':
305
+    $old_tid = db_result(db_query('SELECT tid FROM {forum} WHERE nid = %d', $node->nid));
306
+    break;
307 307
 
308
-    case 'update':
309
-      if (!empty($old_tid)) {
310
-        if (!empty($node->tid) && $node->tid == $old_tid) {
311
-          return;
312
-        }
313
-        acl_node_clear_acls($node->nid, 'forum_access');
308
+  case 'update':
309
+    if (!empty($old_tid)) {
310
+      if (!empty($node->tid) && $node->tid == $old_tid) {
311
+        return;
312
+      }
313
+      acl_node_clear_acls($node->nid, 'forum_access');
314 314
 
315
-        if (module_exists('nodecomment')) {
316
-          _forum_access_changed_tid($node->tid);
317
-          $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid);
318
-          while ($row = db_fetch_object($result)) {
319
-            acl_node_clear_acls($row->cid, 'forum_access');
320
-          }
315
+      if (module_exists('nodecomment')) {
316
+        _forum_access_changed_tid($node->tid);
317
+        $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid);
318
+        while ($row = db_fetch_object($result)) {
319
+          acl_node_clear_acls($row->cid, 'forum_access');
321 320
         }
322 321
       }
323
-      // Deliberate no break -- for changed and for previously unassigned terms we need an insert.
324
-
325
-    case 'insert':
326
-      if (!empty($node->tid)) {
327
-        $acl_id = acl_get_id_by_number('forum_access', $node->tid);
328
-        acl_node_add_acl($node->nid, $acl_id, 1, 1, 1);
329
-
330
-        if (isset($old_tid) && module_exists('nodecomment')) {
331
-          $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid);
332
-          while ($row = db_fetch_object($result)) {
333
-            acl_node_add_acl($row->cid, $acl_id, 1, 1, 1);
334
-            node_access_acquire_grants(node_load($row->cid));
335
-          }
322
+    }
323
+    // Deliberate no break -- for changed and for previously unassigned terms we need an insert.
324
+
325
+  case 'insert':
326
+    if (!empty($node->tid)) {
327
+      $acl_id = acl_get_id_by_number('forum_access', $node->tid);
328
+      acl_node_add_acl($node->nid, $acl_id, 1, 1, 1);
329
+
330
+      if (isset($old_tid) && module_exists('nodecomment')) {
331
+        $result = db_query('SELECT cid FROM {node_comments} WHERE nid = %d', $node->nid);
332
+        while ($row = db_fetch_object($result)) {
333
+          acl_node_add_acl($row->cid, $acl_id, 1, 1, 1);
334
+          node_access_acquire_grants(node_load($row->cid));
336 335
         }
337 336
       }
338
-      $old_tid = NULL;
339
-      break;
337
+    }
338
+    $old_tid = NULL;
339
+    break;
340 340
   }
341 341
 }
342 342
 
@@ -587,20 +587,20 @@  discard block
 block discarded – undo
587 587
  */
588 588
 function forum_access_user($op, &$edit, &$account, $category = NULL) {
589 589
   switch ($op) {
590
-    case 'validate':
591
-      $rid = forum_access_query_moderator_rid();
592
-      if (!empty($rid)) {
593
-        if (isset($edit['roles'][$rid]) && $edit['roles'][$rid]) {
594
-          $roles = user_roles();
595
-          $variables = array(
596
-            '@Forum_Access' => 'Forum Access',
597
-            '%Role' => $roles[$rid],
598
-          );
599
-          drupal_set_message(t('The %Role role is reserved for internal use by the @Forum_Access module! It was not assigned.', $variables), 'warning');
600
-          unset($edit['roles'][$rid]);
601
-        }
590
+  case 'validate':
591
+    $rid = forum_access_query_moderator_rid();
592
+    if (!empty($rid)) {
593
+      if (isset($edit['roles'][$rid]) && $edit['roles'][$rid]) {
594
+        $roles = user_roles();
595
+        $variables = array(
596
+          '@Forum_Access' => 'Forum Access',
597
+          '%Role' => $roles[$rid],
598
+        );
599
+        drupal_set_message(t('The %Role role is reserved for internal use by the @Forum_Access module! It was not assigned.', $variables), 'warning');
600
+        unset($edit['roles'][$rid]);
602 601
       }
603
-      break;
602
+    }
603
+    break;
604 604
   }
605 605
 }
606 606
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
       break;
137 137
 
138 138
     case 'community':
139
-        if (arg(1)=='forum') {
139
+        if (arg(1) == 'forum') {
140 140
             if (is_numeric(arg(2))) {
141
-                $tid=arg(2);
141
+                $tid = arg(2);
142 142
                 // Obtain the tid from a URL path containing
143 143
                 // community/forum/%tid, this will prevent users from
144 144
                 // loading forums they are not allowed to access.
145 145
                 // However, only tid>1 are terms we care about. (This
146 146
                 // allows forum_tweaks mark-read functionality to
147 147
                 // work.)
148
-                if (isset($tid) and ($tid>1)) {
148
+                if (isset($tid) and ($tid > 1)) {
149 149
                     if (!forum_access_access($tid, 'view')) {
150 150
                         drupal_access_denied();
151 151
                         module_invoke_all('exit');
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
  * Alter the node/comment create/edit forms and various admin forms.
188 188
  */
189 189
 function forum_access_form_alter(&$form, &$form_state, $form_id) {
190
-  if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) {
190
+  if (isset($form['type']['#value']) && $form['type']['#value'].'_node_form' == $form_id) {
191 191
     module_load_include('node.inc', 'forum_access');
192 192
     _forum_access_node_form($form, $form_state);
193 193
   }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
     case 'rid':
268 268
       if (strpos($query, 'FROM {role}') === FALSE
269
-        || strpos($_GET['q'] .'/', 'admin/content/forum/') === 0) {
269
+        || strpos($_GET['q'].'/', 'admin/content/forum/') === 0) {
270 270
         break;
271 271
       }
272 272
       $moderator_rid = forum_access_query_moderator_rid();
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
     if ($tid && isset($links['comment_add']) && !forum_access_access($tid, 'comment_create')) {
421 421
       unset($links['comment_add']);
422 422
       // Hack to manually remove quote link
423
-      if ( isset($links['quote']) ) {
423
+      if (isset($links['quote'])) {
424 424
           unset($links['quote']);
425 425
       }
426 426
     }
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
     }
444 444
 
445 445
     // Hack to manually remove quote link if comment_reply link is no longer set
446
-    if ( (!(isset($links['comment_reply']))) AND isset($links['quote']) ) {
446
+    if ((!(isset($links['comment_reply']))) AND isset($links['quote'])) {
447 447
         unset($links['quote']);
448 448
     }
449 449
     
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
     }
563 563
 
564 564
     $roles = array_keys($account->roles);
565
-    $result = db_result(db_query("SELECT tid FROM {forum_access} WHERE rid IN (". db_placeholders($roles) .") AND grant_". $type ." = 1 AND tid = %d", array_merge($roles, array($tid))));
565
+    $result = db_result(db_query("SELECT tid FROM {forum_access} WHERE rid IN (".db_placeholders($roles).") AND grant_".$type." = 1 AND tid = %d", array_merge($roles, array($tid))));
566 566
 
567 567
     if ($result) {
568 568
       $cache[$account->uid][$tid][$type] = 1;
Please login to merge, or discard this patch.
Braces   +24 added lines, -36 removed lines patch added patch discarded remove patch
@@ -38,8 +38,7 @@  discard block
 block discarded – undo
38 38
   if (isset($node->comment_target_nid)) {
39 39
     if ($changed_tid = _forum_access_changed_tid()) {
40 40
       $tid = $changed_tid; // the topic node hasn't been saved yet!
41
-    }
42
-    else {
41
+    } else {
43 42
       $node = node_load($node->comment_target_nid);
44 43
       $tid = _forum_access_get_tid($node);
45 44
     }
@@ -91,7 +90,8 @@  discard block
 block discarded – undo
91 90
         return; // disable comment access control
92 91
       }
93 92
       if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) {
94
-        if (is_numeric($cid = arg(2))) { // comment/edit/%, comment/delete/%
93
+        if (is_numeric($cid = arg(2))) {
94
+// comment/edit/%, comment/delete/%
95 95
           $access[] = (arg(1) == 'edit' ? 'update' : 'delete');
96 96
           $comment = _comment_load($cid);
97 97
           $nid = $comment->nid;
@@ -107,7 +107,8 @@  discard block
 block discarded – undo
107 107
 
108 108
     case 'node':
109 109
       if (is_numeric(arg(1))) {
110
-        if (arg(2) == 'edit' && !user_access('administer nodes')) { // node/%/edit
110
+        if (arg(2) == 'edit' && !user_access('administer nodes')) {
111
+// node/%/edit
111 112
           $access[] = 'update';
112 113
           $nid = arg(1);
113 114
           // If the node turns out to be in a forum where we have update/delete
@@ -118,13 +119,15 @@  discard block
 block discarded – undo
118 119
           // We won't provide full Administrator access, though: we'll remove
119 120
           // author and timestamp, for example.
120 121
         }
121
-        if (arg(2) == 'delete' && !user_access('administer nodes')) { // node/%/delete
122
+        if (arg(2) == 'delete' && !user_access('administer nodes')) {
123
+// node/%/delete
122 124
           $access = array();
123 125
           $nid = arg(1);
124 126
           // This is the delete confirmation page. We don't need any
125 127
           // additional permissions, but we'll assert 'view' access below.
126 128
         }
127
-        if (arg(2) == NULL && !user_access('administer comments')) { // node/%
129
+        if (arg(2) == NULL && !user_access('administer comments')) {
130
+// node/%
128 131
           $access[] = 'update';
129 132
           $nid = arg(1);
130 133
           // If the node turns out to be in a forum where we have update/delete
@@ -190,44 +193,34 @@  discard block
 block discarded – undo
190 193
   if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) {
191 194
     module_load_include('node.inc', 'forum_access');
192 195
     _forum_access_node_form($form, $form_state);
193
-  }
194
-  elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', FALSE)) {
196
+  } elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', FALSE)) {
195 197
     module_load_include('node.inc', 'forum_access');
196 198
     _forum_access_comment_form($form, $form_state);
197
-  }
198
-  elseif ($form_id == 'forum_overview') {
199
+  } elseif ($form_id == 'forum_overview') {
199 200
     module_load_include('admin.inc', 'forum_access');
200 201
     _forum_access_forum_overview($form, $form_state);
201
-  }
202
-  elseif ($form_id == 'forum_form_container') {
202
+  } elseif ($form_id == 'forum_form_container') {
203 203
     module_load_include('admin.inc', 'forum_access');
204 204
     _forum_access_forum_form($form, $form_state, TRUE);
205
-  }
206
-  elseif ($form_id == 'forum_form_forum') {
205
+  } elseif ($form_id == 'forum_form_forum') {
207 206
     module_load_include('admin.inc', 'forum_access');
208 207
     _forum_access_forum_form($form, $form_state, FALSE);
209
-  }
210
-  elseif ($form_id == 'forum_admin_settings') {
208
+  } elseif ($form_id == 'forum_admin_settings') {
211 209
     module_load_include('admin.inc', 'forum_access');
212 210
     _forum_access_forum_admin_settings_form($form, $form_state);
213
-  }
214
-  elseif ($form_id == 'user_admin_role') {
211
+  } elseif ($form_id == 'user_admin_role') {
215 212
     module_load_include('admin.inc', 'forum_access');
216 213
     _forum_access_user_admin_role_form($form, $form_state);
217
-  }
218
-  elseif ($form_id == 'content_access_admin_settings' && empty($_POST)) {
214
+  } elseif ($form_id == 'content_access_admin_settings' && empty($_POST)) {
219 215
     module_load_include('admin.inc', 'forum_access');
220 216
     _forum_access_content_access_admin_form();
221
-  }
222
-  elseif ($form_id == 'user_admin_perm') {
217
+  } elseif ($form_id == 'user_admin_perm') {
223 218
     module_load_include('admin.inc', 'forum_access');
224 219
     _forum_access_user_admin_perm_form($form, $form_state);
225
-  }
226
-  elseif ($form_id == 'user_admin_account') {
220
+  } elseif ($form_id == 'user_admin_account') {
227 221
     module_load_include('admin.inc', 'forum_access');
228 222
     _forum_access_user_admin_account_form($form, $form_state);
229
-  }
230
-  elseif ($form_id == 'user_profile_form') {
223
+  } elseif ($form_id == 'user_profile_form') {
231 224
     module_load_include('admin.inc', 'forum_access');
232 225
     _forum_access_user_profile_form($form, $form_state);
233 226
   }
@@ -252,8 +245,7 @@  discard block
 block discarded – undo
252 245
       }
253 246
       if (strpos($_GET['q'], 'node/add/forum') !== FALSE) {
254 247
         $required_access = 'create';
255
-      }
256
-      else {
248
+      } else {
257 249
         $required_access = 'view';
258 250
       }
259 251
       $roles = implode(', ', array_keys($user->roles));
@@ -424,8 +416,7 @@  discard block
 block discarded – undo
424 416
           unset($links['quote']);
425 417
       }
426 418
     }
427
-  }
428
-  else {
419
+  } else {
429 420
     // Check links for the comment.
430 421
     $required_keys = array(
431 422
       'comment_create' => 'comment_reply',
@@ -436,8 +427,7 @@  discard block
 block discarded – undo
436 427
       if (!forum_access_access($tid, $access) && !($access == 'update' && comment_access('edit', $comment))) {
437 428
         unset($links[$required_keys[$access]]);
438 429
         unset($required_keys[$access]);
439
-      }
440
-      elseif (!array_key_exists($key, $links)) {
430
+      } elseif (!array_key_exists($key, $links)) {
441 431
         $link_is_missing = TRUE;
442 432
       }
443 433
     }
@@ -566,15 +556,13 @@  discard block
 block discarded – undo
566 556
 
567 557
     if ($result) {
568 558
       $cache[$account->uid][$tid][$type] = 1;
569
-    }
570
-    else {
559
+    } else {
571 560
       // check our moderators too
572 561
       $acl_id = acl_get_id_by_number('forum_access', $tid);
573 562
       $result = db_result(db_query("SELECT uid FROM {acl_user} WHERE acl_id = %d AND uid = %d", $acl_id, $account->uid));
574 563
       if ($result) {
575 564
         $cache[$account->uid][$tid][$type] = 2;
576
-      }
577
-      else {
565
+      } else {
578 566
         $cache[$account->uid][$tid][$type] = FALSE;
579 567
       }
580 568
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
   if ($tid) {
49 49
     if (!isset($grants[$tid])) {
50 50
       if (!isset($node_admins)) {
51
-        $node_admins = user_roles(FALSE, 'administer nodes');
51
+        $node_admins = user_roles(false, 'administer nodes');
52 52
       }
53 53
       $result = db_query('SELECT * FROM {forum_access} WHERE tid = %d', $tid);
54 54
       while ($grant = db_fetch_object($result)) {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
   switch (arg(0)) {
89 89
     case 'comment':
90
-      if (variable_get('forum_access_D5_legacy_mode', FALSE)) {
90
+      if (variable_get('forum_access_D5_legacy_mode', false)) {
91 91
         return; // disable comment access control
92 92
       }
93 93
       if ((arg(1) == 'edit' || arg(1) == 'delete') && !user_access('administer comments')) {
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
           // this comment.
101 101
           // We won't provide full Administrator access, though: we'll remove
102 102
           // author and timestamp, for example.
103
-          $grant_normal_access = TRUE;
103
+          $grant_normal_access = true;
104 104
         }
105 105
       }
106 106
       break;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
           // This is the delete confirmation page. We don't need any
125 125
           // additional permissions, but we'll assert 'view' access below.
126 126
         }
127
-        if (arg(2) == NULL && !user_access('administer comments')) { // node/%
127
+        if (arg(2) == null && !user_access('administer comments')) { // node/%
128 128
           $access[] = 'update';
129 129
           $nid = arg(1);
130 130
           // If the node turns out to be in a forum where we have update/delete
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     module_load_include('node.inc', 'forum_access');
192 192
     _forum_access_node_form($form, $form_state);
193 193
   }
194
-  elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', FALSE)) {
194
+  elseif ($form_id == 'comment_form' && !variable_get('forum_access_D5_legacy_mode', false)) {
195 195
     module_load_include('node.inc', 'forum_access');
196 196
     _forum_access_comment_form($form, $form_state);
197 197
   }
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
   }
202 202
   elseif ($form_id == 'forum_form_container') {
203 203
     module_load_include('admin.inc', 'forum_access');
204
-    _forum_access_forum_form($form, $form_state, TRUE);
204
+    _forum_access_forum_form($form, $form_state, true);
205 205
   }
206 206
   elseif ($form_id == 'forum_form_forum') {
207 207
     module_load_include('admin.inc', 'forum_access');
208
-    _forum_access_forum_form($form, $form_state, FALSE);
208
+    _forum_access_forum_form($form, $form_state, false);
209 209
   }
210 210
   elseif ($form_id == 'forum_admin_settings') {
211 211
     module_load_include('admin.inc', 'forum_access');
@@ -242,15 +242,15 @@  discard block
 block discarded – undo
242 242
  */
243 243
 function forum_access_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
244 244
   global $user;
245
-  $sql = NULL;
245
+  $sql = null;
246 246
   switch ($primary_field) {
247 247
     case 'tid':
248 248
       if ($user->uid == 1
249
-        || user_access('administer nodes') && strpos($_GET['q'], 'node/add/forum') === FALSE
249
+        || user_access('administer nodes') && strpos($_GET['q'], 'node/add/forum') === false
250 250
         || user_access('administer forums') && $_GET['q'] == 'admin/content/forum') {
251 251
         break;
252 252
       }
253
-      if (strpos($_GET['q'], 'node/add/forum') !== FALSE) {
253
+      if (strpos($_GET['q'], 'node/add/forum') !== false) {
254 254
         $required_access = 'create';
255 255
       }
256 256
       else {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
       break;
266 266
 
267 267
     case 'rid':
268
-      if (strpos($query, 'FROM {role}') === FALSE
268
+      if (strpos($query, 'FROM {role}') === false
269 269
         || strpos($_GET['q'] .'/', 'admin/content/forum/') === 0) {
270 270
         break;
271 271
       }
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * Add ACL data to fresh forum posts.
285 285
  */
286
-function forum_access_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
287
-  static $old_tid = NULL;
286
+function forum_access_nodeapi(&$node, $op, $teaser = null, $page = null) {
287
+  static $old_tid = null;
288 288
   // This is modeled after forum_nodeapi():
289 289
   $vid = _forum_access_get_vid();
290 290
   $vocabulary = taxonomy_vocabulary_load($vid);
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
           }
336 336
         }
337 337
       }
338
-      $old_tid = NULL;
338
+      $old_tid = null;
339 339
       break;
340 340
   }
341 341
 }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
  * and thus it is disabled by default. Set the variable to TRUE to enable.
362 362
  */
363 363
 function forum_access_preprocess_forum_list(&$variables) {
364
-  if (variable_get('forum_access_provide_moderators_template_variable', FALSE)) {
364
+  if (variable_get('forum_access_provide_moderators_template_variable', false)) {
365 365
     static $users;
366 366
     foreach ($variables['forums'] as $tid => $forum) {
367 367
       $moderators = array();
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
           $moderators[$uid] = $users[$uid];
374 374
         }
375 375
       }
376
-      $forum->forum_access_moderators = (empty($moderators) ? NULL : $moderators);
376
+      $forum->forum_access_moderators = (empty($moderators) ? null : $moderators);
377 377
     }
378 378
   }
379 379
 }
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
   }
395 395
 }
396 396
 
397
-if (!variable_get('forum_access_D5_legacy_mode', FALSE)) {
397
+if (!variable_get('forum_access_D5_legacy_mode', false)) {
398 398
   // LEGACY-MODE disables these methods
399 399
 
400 400
 /**
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
  * For nodes, remove the 'Add new comment' link, if the user does not have the
404 404
  * 'comment_create' permission; for comments, add any missing links (D6.17+).
405 405
  */
406
-function forum_access_link_alter(&$links, $node, $comment = NULL) {
406
+function forum_access_link_alter(&$links, $node, $comment = null) {
407 407
   global $user;
408
-  static $user1, $recursing = FALSE, $stored_links;
408
+  static $user1, $recursing = false, $stored_links;
409 409
 
410 410
   // If we are being called recursively, store the $links and return.
411 411
   if ($recursing) {
@@ -438,12 +438,12 @@  discard block
 block discarded – undo
438 438
         unset($required_keys[$access]);
439 439
       }
440 440
       elseif (!array_key_exists($key, $links)) {
441
-        $link_is_missing = TRUE;
441
+        $link_is_missing = true;
442 442
       }
443 443
     }
444 444
 
445 445
     // Hack to manually remove quote link if comment_reply link is no longer set
446
-    if ( (!(isset($links['comment_reply']))) AND isset($links['quote']) ) {
446
+    if ( (!(isset($links['comment_reply']))) and isset($links['quote']) ) {
447 447
         unset($links['quote']);
448 448
     }
449 449
     
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
         $user1 = user_load(1);
459 459
       }
460 460
       $saved_user = $user;
461
-      session_save_session(FALSE);
461
+      session_save_session(false);
462 462
       $user = $user1;
463 463
 
464 464
       // With UID 1 we call hook_link(). This should give us the full set of
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
       $admin_links = module_invoke_all('link', 'comment', $comment, array_key_exists('comment_parent', $links));
467 467
 
468 468
       $user = $saved_user;
469
-      session_save_session(TRUE);
469
+      session_save_session(true);
470 470
 
471 471
       // Remove the links from $admin_links that are not in the reduced
472 472
       // set of $required_links AND not available to the current user anyway.
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
       // called it will store a copy of the links at their current state. Then
484 484
       // we pull those links which have not been link_alter'ed by any modules
485 485
       // that come after forum_access.
486
-      $recursing = TRUE;
486
+      $recursing = true;
487 487
       drupal_alter('link', $admin_links, $node, $comment);
488
-      $recursing = FALSE;
488
+      $recursing = false;
489 489
       // Now return the stored links.
490 490
       $links = $stored_links;
491 491
     }
@@ -523,9 +523,9 @@  discard block
 block discarded – undo
523 523
 /**
524 524
  * This is also required by ACL module.
525 525
  */
526
-function forum_access_enabled($set = NULL) {
527
-  static $enabled = TRUE;
528
-  if ($set !== NULL) {
526
+function forum_access_enabled($set = null) {
527
+  static $enabled = true;
528
+  if ($set !== null) {
529 529
     $enabled = $set;
530 530
   }
531 531
   return $enabled;
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
  *   1     - access granted
545 545
  *   2     - access granted for forum moderator
546 546
  */
547
-function forum_access_access($tid, $type, $account = NULL, $administer_nodes_sees_everything = TRUE) {
547
+function forum_access_access($tid, $type, $account = null, $administer_nodes_sees_everything = true) {
548 548
   static $cache = array();
549 549
   if (!$account) {
550 550
     global $user;
@@ -552,13 +552,13 @@  discard block
 block discarded – undo
552 552
   }
553 553
 
554 554
   if ($account->uid == 1 ||
555
-      $administer_nodes_sees_everything && user_access('administer nodes', $account) && array_search($type, array('view', 'update', 'delete')) !== FALSE) {
555
+      $administer_nodes_sees_everything && user_access('administer nodes', $account) && array_search($type, array('view', 'update', 'delete')) !== false) {
556 556
     return 1;
557 557
   }
558 558
 
559 559
   if (!isset($cache[$account->uid][$tid][$type])) {
560 560
     if (!user_access('access content', $account)) {
561
-      return $cache[$account->uid][$tid][$type] = FALSE;
561
+      return $cache[$account->uid][$tid][$type] = false;
562 562
     }
563 563
 
564 564
     $roles = array_keys($account->roles);
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
         $cache[$account->uid][$tid][$type] = 2;
576 576
       }
577 577
       else {
578
-        $cache[$account->uid][$tid][$type] = FALSE;
578
+        $cache[$account->uid][$tid][$type] = false;
579 579
       }
580 580
     }
581 581
   }
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 /**
586 586
  * Implementation of hook_user().
587 587
  */
588
-function forum_access_user($op, &$edit, &$account, $category = NULL) {
588
+function forum_access_user($op, &$edit, &$account, $category = null) {
589 589
   switch ($op) {
590 590
     case 'validate':
591 591
       $rid = forum_access_query_moderator_rid();
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
  * no forum or container is specified will return TRUE if the user has at least
629 629
  * one role that can access at least one forum.
630 630
  */
631
-function _forum_access_forum_access_callback($tid = NULL) {
631
+function _forum_access_forum_access_callback($tid = null) {
632 632
   return (!$tid && _forum_access_access_any_forum()) || forum_access_access($tid, 'view');
633 633
 }
634 634
 
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
  * Returns TRUE if the user has at least one role that can access
639 639
  * at least one forum.
640 640
  */
641
-function _forum_access_access_any_forum($account = NULL) {
641
+function _forum_access_access_any_forum($account = null) {
642 642
   global $user;
643 643
   static $return = array();
644 644
 
@@ -648,12 +648,12 @@  discard block
 block discarded – undo
648 648
 
649 649
   if (!isset($return[$account->uid])) {
650 650
     if ($account->uid == 1) {
651
-      return $return[$account->uid] = TRUE;
651
+      return $return[$account->uid] = true;
652 652
     }
653 653
     if (!user_access('access content', $account)) {
654
-      return $return[$account->uid] = FALSE;
654
+      return $return[$account->uid] = false;
655 655
     }
656
-    $rids = variable_get('forum_access_rids', NULL);
656
+    $rids = variable_get('forum_access_rids', null);
657 657
     if (!isset($rids)) {
658 658
       $rids = array();
659 659
       $result = db_query("SELECT fa.rid FROM {forum_access} fa WHERE fa.grant_view > 0 GROUP BY fa.rid");
@@ -664,10 +664,10 @@  discard block
 block discarded – undo
664 664
     }
665 665
     foreach ($rids as $rid) {
666 666
       if (isset($account->roles[$rid])) {
667
-        return $return[$account->uid] = TRUE;
667
+        return $return[$account->uid] = true;
668 668
       }
669 669
     }
670
-    $return[$account->uid] = FALSE;
670
+    $return[$account->uid] = false;
671 671
   }
672 672
   return $return[$account->uid];
673 673
 }
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
  *
678 678
  * Delete {forum_access} records when forums are deleted.
679 679
  */
680
-function forum_access_taxonomy($op, $type, $array = NULL) {
680
+function forum_access_taxonomy($op, $type, $array = null) {
681 681
   //dpm($array, "hook_taxonomy($op, $type)");
682 682
   if ($type = 'term' && $op == 'delete' && $array['vid'] == _forum_access_get_vid()) {
683 683
     db_query("DELETE FROM {forum_access} WHERE tid = %d", $array['tid']);
@@ -697,21 +697,21 @@  discard block
 block discarded – undo
697 697
  * exist.
698 698
  */
699 699
 function forum_access_query_moderator_rid() {
700
-  return variable_get('forum_access_moderator_rid', NULL);
700
+  return variable_get('forum_access_moderator_rid', null);
701 701
 }
702 702
 
703 703
 /**
704 704
  * Return the forum tid or FALSE.
705 705
  */
706 706
 function _forum_access_get_tid($node) {
707
-  return (isset($node->forum_tid) ? $node->forum_tid : (isset($node->tid) ? $node->tid : FALSE));
707
+  return (isset($node->forum_tid) ? $node->forum_tid : (isset($node->tid) ? $node->tid : false));
708 708
 }
709 709
 
710 710
 /**
711 711
  * Save and return the $tid.
712 712
  */
713
-function _forum_access_changed_tid($tid = NULL) {
714
-  static $saved_tid = NULL;
713
+function _forum_access_changed_tid($tid = null) {
714
+  static $saved_tid = null;
715 715
   if (!empty($tid)) {
716 716
     $saved_tid = $tid;
717 717
   }
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
  * Implementation of hook_node_access_explain().
723 723
  */
724 724
 function forum_access_node_access_explain($row) {
725
-  static $roles = NULL;
725
+  static $roles = null;
726 726
   if ($row->realm == 'forum_access') {
727 727
     if (!isset($roles)) {
728 728
       module_load_include('node.inc', 'forum_access');
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 /**
739 739
  * Implementation of hook_acl_explain().
740 740
  */
741
-function forum_access_acl_explain($acl_id, $name, $number, $users = NULL) {
741
+function forum_access_acl_explain($acl_id, $name, $number, $users = null) {
742 742
   if (empty($users)) {
743 743
     return "ACL (id=$acl_id) would grant access to nodes in forum/$number.";
744 744
   }
Please login to merge, or discard this patch.
sites/default/boinc/modules/contrib/i18nviews/includes/i18nviews.views.inc 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 function i18nviews_views_data() {
4
-  $data['node']['content_negotiation'] = array(
4
+    $data['node']['content_negotiation'] = array(
5 5
     'group' => t('Node translation'),
6 6
     'title' => t('Content negotiation'),
7 7
     'help' => t('Removes the nodes that are not valid according to the content selection mode.'),
8 8
     'filter' => array(
9
-      'handler' => 'content_negotiation_filter_handler',
9
+        'handler' => 'content_negotiation_filter_handler',
10 10
     ),
11
-  );
12
-  return $data;
11
+    );
12
+    return $data;
13 13
 }
14 14
 
15 15
 /**
16 16
  * Implementation of hook_views_handlers
17 17
  */
18 18
 function i18nviews_views_handlers() {
19
-  return array(
19
+    return array(
20 20
     'info' => array(
21
-      'path' => drupal_get_path('module', 'i18nviews') . '/includes',
21
+        'path' => drupal_get_path('module', 'i18nviews') . '/includes',
22 22
     ),
23 23
     'handlers' => array(
24
-      'content_negotiation_filter_handler' => array(
24
+        'content_negotiation_filter_handler' => array(
25 25
         'parent' => 'views_handler_filter',
26
-      ),
26
+        ),
27 27
     ),
28
-  );
28
+    );
29 29
 }
30 30
 
31 31
 /**
32 32
  * Implementation of hook_views_plugins().
33 33
  */
34 34
 function i18nviews_views_plugins() {
35
-  $path = drupal_get_path('module', 'i18nviews') . '/includes';
36
-  return array(
35
+    $path = drupal_get_path('module', 'i18nviews') . '/includes';
36
+    return array(
37 37
     'module' => 'i18nviews',
38 38
     'localization' => array(
39
-      'i18nstrings' => array(
39
+        'i18nstrings' => array(
40 40
         'title' => t('Views translation module'),
41 41
         'help' => t("Use the locale system as implemented by the Views translation module."),
42 42
         'handler' => 'views_plugin_localization_i18nstrings',
43 43
         'path' => $path,
44
-      ),
44
+        ),
45 45
     ),
46
-  );
46
+    );
47 47
 }
48 48
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 function i18nviews_views_handlers() {
19 19
   return array(
20 20
     'info' => array(
21
-      'path' => drupal_get_path('module', 'i18nviews') . '/includes',
21
+      'path' => drupal_get_path('module', 'i18nviews').'/includes',
22 22
     ),
23 23
     'handlers' => array(
24 24
       'content_negotiation_filter_handler' => array(
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  * Implementation of hook_views_plugins().
33 33
  */
34 34
 function i18nviews_views_plugins() {
35
-  $path = drupal_get_path('module', 'i18nviews') . '/includes';
35
+  $path = drupal_get_path('module', 'i18nviews').'/includes';
36 36
   return array(
37 37
     'module' => 'i18nviews',
38 38
     'localization' => array(
Please login to merge, or discard this patch.
modules/contrib/i18nviews/includes/content_negotiation_filter_handler.inc 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class content_negotiation_filter_handler extends views_handler_filter {
4
-  function query() {
4
+    function query() {
5 5
     $this->ensure_my_table();
6 6
     $where = i18n_db_rewrite_where($this->table_alias, 'node');
7 7
     if (!empty($where)) {
8
-      $this->query->add_where($this->options['group'], $where);
8
+        $this->query->add_where($this->options['group'], $where);
9
+    }
9 10
     }
10
-  }
11 11
 
12
-  function option_definition() {
12
+    function option_definition() {
13 13
     $options = parent::option_definition();
14 14
     $options['operator']['default'] = '';
15 15
     $options['value']['default'] = '';
16 16
     return $options;
17
-  }
17
+    }
18 18
 }
Please login to merge, or discard this patch.