@@ -22,24 +22,21 @@ discard block |
||
22 | 22 | define("LABEL_POSITION_BOTTOM" , 880004); |
23 | 23 | |
24 | 24 | /* pStock class definition */ |
25 | - class pSurface |
|
26 | - { |
|
25 | + class pSurface { |
|
27 | 26 | var $pChartObject; |
28 | 27 | var $GridSizeX; |
29 | 28 | var $GridSizeY; |
30 | 29 | var $Points; |
31 | 30 | |
32 | 31 | /* Class creator */ |
33 | - function pSurface($pChartObject) |
|
34 | - { |
|
32 | + function pSurface($pChartObject) { |
|
35 | 33 | $this->pChartObject = $pChartObject; |
36 | 34 | $this->GridSize = 10; |
37 | 35 | $this->Points = ""; |
38 | 36 | } |
39 | 37 | |
40 | 38 | /* Define the grid size and initialise the 2D matrix */ |
41 | - function setGrid($XSize=10,$YSize=10) |
|
42 | - { |
|
39 | + function setGrid($XSize=10,$YSize=10) { |
|
43 | 40 | for($X=0; $X<=$XSize; $X++) { for($Y=0; $Y<=$YSize; $Y++) { $this->Points[$X][$Y]=UNKNOWN; } } |
44 | 41 | |
45 | 42 | $this->GridSizeX = $XSize; |
@@ -47,8 +44,7 @@ discard block |
||
47 | 44 | } |
48 | 45 | |
49 | 46 | /* Add a point on the grid */ |
50 | - function addPoint($X,$Y,$Value,$Force=TRUE) |
|
51 | - { |
|
47 | + function addPoint($X,$Y,$Value,$Force=TRUE) { |
|
52 | 48 | if ( $X < 0 || $X >$this->GridSizeX ) { return(0); } |
53 | 49 | if ( $Y < 0 || $Y >$this->GridSizeY ) { return(0); } |
54 | 50 | |
@@ -61,8 +57,7 @@ discard block |
||
61 | 57 | } |
62 | 58 | |
63 | 59 | /* Write the X labels */ |
64 | - function writeXLabels($Format="") |
|
65 | - { |
|
60 | + function writeXLabels($Format="") { |
|
66 | 61 | $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR; |
67 | 62 | $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG; |
68 | 63 | $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB; |
@@ -79,23 +74,18 @@ discard block |
||
79 | 74 | $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
80 | 75 | |
81 | 76 | $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
82 | - if ( $Position == LABEL_POSITION_TOP ) |
|
83 | - { |
|
77 | + if ( $Position == LABEL_POSITION_TOP ) { |
|
84 | 78 | $YPos = $this->pChartObject->GraphAreaY1 - $Padding; |
85 | 79 | if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; } |
86 | 80 | if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
87 | - } |
|
88 | - elseif ( $Position == LABEL_POSITION_BOTTOM ) |
|
89 | - { |
|
81 | + } elseif ( $Position == LABEL_POSITION_BOTTOM ) { |
|
90 | 82 | $YPos = $this->pChartObject->GraphAreaY2 + $Padding; |
91 | 83 | if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_TOPMIDDLE; } |
92 | 84 | if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
93 | - } |
|
94 | - else |
|
85 | + } else |
|
95 | 86 | return(-1); |
96 | 87 | |
97 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
98 | - { |
|
88 | + for($X=0;$X<=$this->GridSizeX;$X++) { |
|
99 | 89 | $XPos = floor($X0+$X*$XSize + $XSize/2); |
100 | 90 | |
101 | 91 | if( $Labels == NULL || !isset($Labels[$X]) ) |
@@ -108,8 +98,7 @@ discard block |
||
108 | 98 | } |
109 | 99 | |
110 | 100 | /* Write the Y labels */ |
111 | - function writeYLabels($Format="") |
|
112 | - { |
|
101 | + function writeYLabels($Format="") { |
|
113 | 102 | $R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR; |
114 | 103 | $G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG; |
115 | 104 | $B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB; |
@@ -127,14 +116,11 @@ discard block |
||
127 | 116 | |
128 | 117 | $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
129 | 118 | if ( $Position == LABEL_POSITION_LEFT ) |
130 | - { $XPos = $this->pChartObject->GraphAreaX1 - $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } |
|
131 | - elseif ( $Position == LABEL_POSITION_RIGHT ) |
|
132 | - { $XPos = $this->pChartObject->GraphAreaX2 + $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } |
|
133 | - else |
|
119 | + { $XPos = $this->pChartObject->GraphAreaX1 - $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; } elseif ( $Position == LABEL_POSITION_RIGHT ) |
|
120 | + { $XPos = $this->pChartObject->GraphAreaX2 + $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; } else |
|
134 | 121 | return(-1); |
135 | 122 | |
136 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
137 | - { |
|
123 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) { |
|
138 | 124 | $YPos = floor($Y0+$Y*$YSize + $YSize/2); |
139 | 125 | |
140 | 126 | if( $Labels == NULL || !isset($Labels[$Y]) ) |
@@ -147,8 +133,7 @@ discard block |
||
147 | 133 | } |
148 | 134 | |
149 | 135 | /* Draw the area arround the specified Threshold */ |
150 | - function drawContour($Threshold,$Format="") |
|
151 | - { |
|
136 | + function drawContour($Threshold,$Format="") { |
|
152 | 137 | $R = isset($Format["R"]) ? $Format["R"] : 0; |
153 | 138 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
154 | 139 | $B = isset($Format["B"]) ? $Format["B"] : 0; |
@@ -163,14 +148,11 @@ discard block |
||
163 | 148 | |
164 | 149 | $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks); |
165 | 150 | |
166 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
167 | - { |
|
168 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
169 | - { |
|
151 | + for($X=0;$X<=$this->GridSizeX;$X++) { |
|
152 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) { |
|
170 | 153 | $Value = $this->Points[$X][$Y]; |
171 | 154 | |
172 | - if ( $Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold) |
|
173 | - { |
|
155 | + if ( $Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold) { |
|
174 | 156 | $X1 = floor($X0+$X*$XSize)+$Padding; |
175 | 157 | $Y1 = floor($Y0+$Y*$YSize)+$Padding; |
176 | 158 | $X2 = floor($X0+$X*$XSize+$XSize); |
@@ -190,8 +172,7 @@ discard block |
||
190 | 172 | } |
191 | 173 | |
192 | 174 | /* Draw the surface chart */ |
193 | - function drawSurface($Format="") |
|
194 | - { |
|
175 | + function drawSurface($Format="") { |
|
195 | 176 | $Palette = isset($Format["Palette"]) ? $Format["Palette"] : NULL; |
196 | 177 | $ShadeR1 = isset($Format["ShadeR1"]) ? $Format["ShadeR1"] : 77; |
197 | 178 | $ShadeG1 = isset($Format["ShadeG1"]) ? $Format["ShadeG1"] : 205; |
@@ -213,28 +194,22 @@ discard block |
||
213 | 194 | $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1); |
214 | 195 | $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1); |
215 | 196 | |
216 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
217 | - { |
|
218 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
219 | - { |
|
197 | + for($X=0;$X<=$this->GridSizeX;$X++) { |
|
198 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) { |
|
220 | 199 | $Value = $this->Points[$X][$Y]; |
221 | 200 | |
222 | - if ( $Value != UNKNOWN && $Value != IGNORED ) |
|
223 | - { |
|
201 | + if ( $Value != UNKNOWN && $Value != IGNORED ) { |
|
224 | 202 | $X1 = floor($X0+$X*$XSize)+$Padding; |
225 | 203 | $Y1 = floor($Y0+$Y*$YSize)+$Padding; |
226 | 204 | $X2 = floor($X0+$X*$XSize+$XSize); |
227 | 205 | $Y2 = floor($Y0+$Y*$YSize+$YSize); |
228 | 206 | |
229 | - if ( $Palette != NULL ) |
|
230 | - { |
|
207 | + if ( $Palette != NULL ) { |
|
231 | 208 | if ( isset($Palette[$Value]) && isset($Palette[$Value]["R"]) ) { $R = $Palette[$Value]["R"]; } else { $R = 0; } |
232 | 209 | if ( isset($Palette[$Value]) && isset($Palette[$Value]["G"]) ) { $G = $Palette[$Value]["G"]; } else { $G = 0; } |
233 | 210 | if ( isset($Palette[$Value]) && isset($Palette[$Value]["B"]) ) { $B = $Palette[$Value]["B"]; } else { $B = 0; } |
234 | 211 | if ( isset($Palette[$Value]) && isset($Palette[$Value]["Alpha"]) ) { $Alpha = $Palette[$Value]["Alpha"]; } else { $Alpha = 1000; } |
235 | - } |
|
236 | - else |
|
237 | - { |
|
212 | + } else { |
|
238 | 213 | $R = (($ShadeR2-$ShadeR1)/100)*$Value + $ShadeR1; |
239 | 214 | $G = (($ShadeG2-$ShadeG1)/100)*$Value + $ShadeG1; |
240 | 215 | $B = (($ShadeB2-$ShadeB1)/100)*$Value + $ShadeB1; |
@@ -252,36 +227,28 @@ discard block |
||
252 | 227 | } |
253 | 228 | |
254 | 229 | /* Compute the missing points */ |
255 | - function computeMissing() |
|
256 | - { |
|
230 | + function computeMissing() { |
|
257 | 231 | $Missing = ""; |
258 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
259 | - { |
|
260 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
261 | - { |
|
232 | + for($X=0;$X<=$this->GridSizeX;$X++) { |
|
233 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) { |
|
262 | 234 | if ( $this->Points[$X][$Y] == UNKNOWN ) |
263 | 235 | $Missing[] = $X.",".$Y; |
264 | 236 | } |
265 | 237 | } |
266 | 238 | shuffle($Missing); |
267 | 239 | |
268 | - foreach($Missing as $Key => $Pos) |
|
269 | - { |
|
240 | + foreach($Missing as $Key => $Pos) { |
|
270 | 241 | $Pos = preg_split("/,/",$Pos); |
271 | 242 | $X = $Pos[0]; |
272 | 243 | $Y = $Pos[1]; |
273 | 244 | |
274 | - if ( $this->Points[$X][$Y] == UNKNOWN ) |
|
275 | - { |
|
245 | + if ( $this->Points[$X][$Y] == UNKNOWN ) { |
|
276 | 246 | $NearestNeighbor = $this->getNearestNeighbor($X,$Y); |
277 | 247 | |
278 | 248 | $Value = 0; $Points = 0; |
279 | - for($Xi=$X-$NearestNeighbor;$Xi<=$X+$NearestNeighbor;$Xi++) |
|
280 | - { |
|
281 | - for($Yi=$Y-$NearestNeighbor;$Yi<=$Y+$NearestNeighbor;$Yi++) |
|
282 | - { |
|
283 | - if ($Xi >=0 && $Yi >= 0 && $Xi <= $this->GridSizeX && $Yi <= $this->GridSizeY && $this->Points[$Xi][$Yi] != UNKNOWN && $this->Points[$Xi][$Yi] != IGNORED) |
|
284 | - { |
|
249 | + for($Xi=$X-$NearestNeighbor;$Xi<=$X+$NearestNeighbor;$Xi++) { |
|
250 | + for($Yi=$Y-$NearestNeighbor;$Yi<=$Y+$NearestNeighbor;$Yi++) { |
|
251 | + if ($Xi >=0 && $Yi >= 0 && $Xi <= $this->GridSizeX && $Yi <= $this->GridSizeY && $this->Points[$Xi][$Yi] != UNKNOWN && $this->Points[$Xi][$Yi] != IGNORED) { |
|
285 | 252 | $Value = $Value + $this->Points[$Xi][$Yi]; $Points++; |
286 | 253 | } |
287 | 254 | } |
@@ -293,15 +260,11 @@ discard block |
||
293 | 260 | } |
294 | 261 | |
295 | 262 | /* Return the nearest Neighbor distance of a point */ |
296 | - function getNearestNeighbor($Xp,$Yp) |
|
297 | - { |
|
263 | + function getNearestNeighbor($Xp,$Yp) { |
|
298 | 264 | $Nearest = UNKNOWN; |
299 | - for($X=0;$X<=$this->GridSizeX;$X++) |
|
300 | - { |
|
301 | - for($Y=0;$Y<=$this->GridSizeY;$Y++) |
|
302 | - { |
|
303 | - if ( $this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED ) |
|
304 | - { |
|
265 | + for($X=0;$X<=$this->GridSizeX;$X++) { |
|
266 | + for($Y=0;$Y<=$this->GridSizeY;$Y++) { |
|
267 | + if ( $this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED ) { |
|
305 | 268 | $DistanceX = max($Xp,$X)-min($Xp,$X); |
306 | 269 | $DistanceY = max($Yp,$Y)-min($Yp,$Y); |
307 | 270 | $Distance = max($DistanceX,$DistanceY); |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | /* pData class definition */ |
17 | - class pBarcode128 |
|
18 | - { |
|
17 | + class pBarcode128 { |
|
19 | 18 | var $Codes; |
20 | 19 | var $Reverse; |
21 | 20 | var $Result; |
@@ -23,8 +22,7 @@ discard block |
||
23 | 22 | var $CRC; |
24 | 23 | |
25 | 24 | /* Class creator */ |
26 | - function pBarcode128($BasePath="") |
|
27 | - { |
|
25 | + function pBarcode128($BasePath="") { |
|
28 | 26 | $this->Codes = ""; |
29 | 27 | $this->Reverse = ""; |
30 | 28 | |
@@ -32,8 +30,7 @@ discard block |
||
32 | 30 | |
33 | 31 | if (!$FileHandle) { die("Cannot find barcode database (".$BasePath."128B.db)."); } |
34 | 32 | |
35 | - while (!feof($FileHandle)) |
|
36 | - { |
|
33 | + while (!feof($FileHandle)) { |
|
37 | 34 | $Buffer = fgets($FileHandle,4096); |
38 | 35 | $Buffer = str_replace(chr(10),"",$Buffer); |
39 | 36 | $Buffer = str_replace(chr(13),"",$Buffer); |
@@ -48,8 +45,7 @@ discard block |
||
48 | 45 | } |
49 | 46 | |
50 | 47 | /* Return the projected size of a barcode */ |
51 | - function getSize($TextString,$Format="") |
|
52 | - { |
|
48 | + function getSize($TextString,$Format="") { |
|
53 | 49 | $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
54 | 50 | $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
55 | 51 | $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
@@ -76,17 +72,14 @@ discard block |
||
76 | 72 | return(array("Width"=>$AreaWidth,"Height"=>$AreaHeight)); |
77 | 73 | } |
78 | 74 | |
79 | - function encode128($Value,$Format="") |
|
80 | - { |
|
75 | + function encode128($Value,$Format="") { |
|
81 | 76 | $this->Result = "11010010000"; |
82 | 77 | $this->CRC = 104; |
83 | 78 | $TextString = ""; |
84 | 79 | |
85 | - for($i=1;$i<=strlen($Value);$i++) |
|
86 | - { |
|
80 | + for($i=1;$i<=strlen($Value);$i++) { |
|
87 | 81 | $CharCode = ord($this->mid($Value,$i,1)); |
88 | - if ( isset($this->Codes[$CharCode]) ) |
|
89 | - { |
|
82 | + if ( isset($this->Codes[$CharCode]) ) { |
|
90 | 83 | $this->Result = $this->Result.$this->Codes[$CharCode]["Code"]; |
91 | 84 | $this->CRC = $this->CRC + $i*$this->Codes[$CharCode]["ID"]; |
92 | 85 | $TextString = $TextString.chr($CharCode); |
@@ -101,8 +94,7 @@ discard block |
||
101 | 94 | } |
102 | 95 | |
103 | 96 | /* Create the encoded string */ |
104 | - function draw($Object,$Value,$X,$Y,$Format="") |
|
105 | - { |
|
97 | + function draw($Object,$Value,$X,$Y,$Format="") { |
|
106 | 98 | $this->pChartObject = $Object; |
107 | 99 | |
108 | 100 | $R = isset($Format["R"]) ? $Format["R"] : 0; |
@@ -123,21 +115,17 @@ discard block |
||
123 | 115 | |
124 | 116 | $TextString = $this->encode128($Value); |
125 | 117 | |
126 | - if ( $DrawArea ) |
|
127 | - { |
|
118 | + if ( $DrawArea ) { |
|
128 | 119 | $X1 = $X + cos(($Angle-135) * PI / 180) * 10; |
129 | 120 | $Y1 = $Y + sin(($Angle-135) * PI / 180) * 10; |
130 | 121 | |
131 | 122 | $X2 = $X1 + cos($Angle * PI / 180) * (strlen($this->Result)+20); |
132 | 123 | $Y2 = $Y1 + sin($Angle * PI / 180) * (strlen($this->Result)+20); |
133 | 124 | |
134 | - if ( $ShowLegend ) |
|
135 | - { |
|
125 | + if ( $ShowLegend ) { |
|
136 | 126 | $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
137 | 127 | $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
138 | - } |
|
139 | - else |
|
140 | - { |
|
128 | + } else { |
|
141 | 129 | $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+20); |
142 | 130 | $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+20); |
143 | 131 | } |
@@ -150,10 +138,8 @@ discard block |
||
150 | 138 | $this->pChartObject->drawPolygon($Polygon,$Settings); |
151 | 139 | } |
152 | 140 | |
153 | - for($i=1;$i<=strlen($this->Result);$i++) |
|
154 | - { |
|
155 | - if ( $this->mid($this->Result,$i,1) == 1 ) |
|
156 | - { |
|
141 | + for($i=1;$i<=strlen($this->Result);$i++) { |
|
142 | + if ( $this->mid($this->Result,$i,1) == 1 ) { |
|
157 | 143 | $X1 = $X + cos($Angle * PI / 180) * $i; |
158 | 144 | $Y1 = $Y + sin($Angle * PI / 180) * $i; |
159 | 145 | $X2 = $X1 + cos(($Angle+90) * PI / 180) * $Height; |
@@ -164,8 +150,7 @@ discard block |
||
164 | 150 | } |
165 | 151 | } |
166 | 152 | |
167 | - if ( $ShowLegend ) |
|
168 | - { |
|
153 | + if ( $ShowLegend ) { |
|
169 | 154 | $X1 = $X + cos($Angle * PI / 180) * (strlen($this->Result)/2); |
170 | 155 | $Y1 = $Y + sin($Angle * PI / 180) * (strlen($this->Result)/2); |
171 | 156 |
@@ -20,11 +20,12 @@ discard block |
||
20 | 20 | } |
21 | 21 | |
22 | 22 | $roles = user_roles(); |
23 | - if (isset($tid)) { // edit |
|
23 | + if (isset($tid)) { |
|
24 | +// edit |
|
24 | 25 | $template_tid = variable_get('forum_access_default_template_tid', 0); |
25 | 26 | $settings = _forum_access_get_settings($tid); |
26 | - } |
|
27 | - else { // create |
|
27 | + } else { |
|
28 | +// create |
|
28 | 29 | $template_tid = variable_get('forum_access_new_template_tid', NULL); |
29 | 30 | $settings = _forum_access_get_settings($template_tid); |
30 | 31 | } |
@@ -208,9 +209,11 @@ discard block |
||
208 | 209 | drupal_add_css(drupal_get_path('module', 'forum_access') .'/forum_access.css'); |
209 | 210 | |
210 | 211 | // Find our moderator ACL: |
211 | - if (isset($tid)) { // edit, not new |
|
212 | + if (isset($tid)) { |
|
213 | +// edit, not new |
|
212 | 214 | $acl_id = acl_get_id_by_number('forum_access', $tid); |
213 | - if (!$acl_id) { // create one |
|
215 | + if (!$acl_id) { |
|
216 | +// create one |
|
214 | 217 | $acl_id = acl_create_new_acl('forum_access', NULL, $tid); |
215 | 218 | // update every existing node in this forum to use this acl. |
216 | 219 | $result = db_query("SELECT nid FROM {term_node} WHERE tid = %d", $tid); |
@@ -288,8 +291,7 @@ discard block |
||
288 | 291 | $form['forum_access']['interference']['by_content_access'][] = array( |
289 | 292 | '#value' => '<div>'. t("Unless you really know what you're doing, we recommend that you go to the !link page and clear all checkboxes. This will instruct @Content_Access to leave the %content_type nodes alone. However, if you put nodes of other content types into forums as well, then these content types will continue to have this problem.", $variables) .'</div>', |
290 | 293 | ); |
291 | - } |
|
292 | - else { |
|
294 | + } else { |
|
293 | 295 | $form['forum_access']['interference']['by_content_access'][] = array( |
294 | 296 | '#value' => '<div>'. t("The priority of @Content_Access ($ca_priority) is higher than the priority of !Forum_Access ($fa_priority), which means the latter is <strong>completely disabled</strong> for the %content_type type! Unless you really know what you're doing, we recommend that you go to the !link page, change the priority (under %Advanced) to 0, and clear all checkboxes.", $variables) .'</div>', |
295 | 297 | ); |
@@ -297,8 +299,7 @@ discard block |
||
297 | 299 | $form['forum_access']['interference']['by_content_access'][] = array( |
298 | 300 | '#value' => '<div>'. t("Alternatively, you can give !Forum_Access priority over @Content_Access by either raising the priority of !Forum_Access in every forum above the priority of @Content_Access, or by lowering the priority of @Content_Access for the content types in question below the priority of !Forum_Access.", $variables) .'</div>', |
299 | 301 | ); |
300 | - } |
|
301 | - else { |
|
302 | + } else { |
|
302 | 303 | $form['forum_access']['interference'][] = array( |
303 | 304 | '#value' => '<p>'. t('Note: You have installed the !Content_Access module, which has the capability to grant access to content that would otherwise be protected by !Forum_Access. Be careful when configuring @Content_Access!', $variables) .'</p>', |
304 | 305 | ); |
@@ -445,21 +446,17 @@ discard block |
||
445 | 446 | $element[$rid]['#suffix'] = "</span>"; |
446 | 447 | $element[$rid]['#default_value'] = TRUE; |
447 | 448 | $element[$rid]['#disabled'] = TRUE; |
448 | - } |
|
449 | - elseif ($element['#parents'][1] == 'create') { |
|
449 | + } elseif ($element['#parents'][1] == 'create') { |
|
450 | 450 | // Do nothing (Post is always mutable). |
451 | - } |
|
452 | - elseif ($element['#parents'][1] == 'comment_create') { |
|
453 | - } |
|
454 | - elseif ($element['#parents'][1] == 'view' && isset($permissions[$rid]['administer forums'])) { |
|
451 | + } elseif ($element['#parents'][1] == 'comment_create') { |
|
452 | + } elseif ($element['#parents'][1] == 'view' && isset($permissions[$rid]['administer forums'])) { |
|
455 | 453 | $element[$rid]['#title'] = '<em>'. $element[$rid]['#title'] .'</em>'; |
456 | 454 | $element[$rid]['#prefix'] = '<span title="'. t("This role has the '@administer_forums' permission, and granting '@View' enables the role holders to change the settings on this page, including @Access_control!", array('@administer_forums' => $tr('administer forums'), '@View' => t('View'), '@Access_control' => t('Access control'))) .'">'; |
457 | 455 | if (isset($permissions[$rid]['administer nodes'])) { |
458 | 456 | $element[$rid]['#prefix'] = str_replace('">', ' '. t("Because the role also has the '@administer_nodes' permission, it has full access to all nodes either way.", array('@administer_nodes' => $tr('administer nodes'))) .'">', $element[$rid]['#prefix']); |
459 | 457 | } |
460 | 458 | $element[$rid]['#suffix'] = "</span>"; |
461 | - } |
|
462 | - elseif (isset($permissions[$rid]['administer nodes'])) { |
|
459 | + } elseif (isset($permissions[$rid]['administer nodes'])) { |
|
463 | 460 | $element[$rid]['#disabled'] = TRUE; |
464 | 461 | $element[$rid]['#default_value'] = TRUE; |
465 | 462 | $element[$rid]['#prefix'] = '<span title="'. ($rid != $moderator_rid |
@@ -515,8 +512,7 @@ discard block |
||
515 | 512 | if ($settings['priority'] != 0) { |
516 | 513 | $form['interference']['advanced']['#collapsed'] = FALSE; |
517 | 514 | } |
518 | - } |
|
519 | - elseif (is_array(reset($form_state['values']['forum_access']['template']['taxonomy']))) { |
|
515 | + } elseif (is_array(reset($form_state['values']['forum_access']['template']['taxonomy']))) { |
|
520 | 516 | $imv = reset($form_state['values']['forum_access']['template']['taxonomy']); |
521 | 517 | $template_tid = reset($imv); |
522 | 518 | } |
@@ -549,14 +545,12 @@ discard block |
||
549 | 545 | $template_tid = reset(array_values($access['template']['taxonomy'])); |
550 | 546 | if ($access['template']['select_by_default']) { |
551 | 547 | variable_set('forum_access_default_template_tid', $template_tid); |
552 | - } |
|
553 | - elseif (variable_get('forum_access_default_template_tid', 0) == $template_tid) { |
|
548 | + } elseif (variable_get('forum_access_default_template_tid', 0) == $template_tid) { |
|
554 | 549 | variable_del('forum_access_default_template_tid'); |
555 | 550 | } |
556 | 551 | if ($access['template']['load_for_new']) { |
557 | 552 | variable_set('forum_access_new_template_tid', $template_tid); |
558 | - } |
|
559 | - elseif (variable_get('forum_access_new_template_tid', 0) == $template_tid) { |
|
553 | + } elseif (variable_get('forum_access_new_template_tid', 0) == $template_tid) { |
|
560 | 554 | variable_del('forum_access_new_template_tid'); |
561 | 555 | } |
562 | 556 | module_load_include('node.inc', 'forum_access'); |
@@ -598,8 +592,7 @@ discard block |
||
598 | 592 | // We prefer not to save records for node administrators, because these have access anyway. |
599 | 593 | if (isset($permissions[$rid]['administer forums']) && $access['view'][$rid]) { |
600 | 594 | // For forum administrators, View needs to be saved, ... |
601 | - } |
|
602 | - else { |
|
595 | + } else { |
|
603 | 596 | // ... otherwise forget View. |
604 | 597 | $access['view'][$rid] = FALSE; |
605 | 598 | } |
@@ -607,8 +600,7 @@ discard block |
||
607 | 600 | db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", |
608 | 601 | $tid, $rid, !empty($access['view'][$rid]), 0, 0, !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority); |
609 | 602 | } |
610 | - } |
|
611 | - else { |
|
603 | + } else { |
|
612 | 604 | db_query("INSERT INTO {forum_access} (tid, rid, grant_view, grant_update, grant_delete, grant_create, grant_comment_create, priority) VALUES (%d, %d, %d, %d, %d, %d, %d, %d)", |
613 | 605 | $tid, $rid, (bool) $checked, !empty($access['update'][$rid]), !empty($access['delete'][$rid]), !empty($access['create'][$rid]), !empty($access['comment_create'][$rid]), $fa_priority); |
614 | 606 | } |
@@ -620,8 +612,7 @@ discard block |
||
620 | 612 | if (!$is_new && $form_state['values']['form_id'] != 'forum_form_container') { |
621 | 613 | if (!isset($access['update_choice']) || $access['update_choice'] == 2) { |
622 | 614 | node_access_needs_rebuild(TRUE); |
623 | - } |
|
624 | - elseif ($access['update_choice'] == 0) { |
|
615 | + } elseif ($access['update_choice'] == 0) { |
|
625 | 616 | // update immediately (but use the batch functions anyway |
626 | 617 | $save_redirect = $form_state['redirect']; |
627 | 618 | $form_state['redirect'] = $_GET['q']; |
@@ -632,13 +623,13 @@ discard block |
||
632 | 623 | _forum_access_update_batch_operation($tid, 999999, 1, $context); |
633 | 624 | $pending_error_messages = drupal_get_messages('error', TRUE); // still alive, get and clear all 'error' messages |
634 | 625 | unset($pending_error_messages['error'][$our_error_message_index]); // remove our error message |
635 | - foreach ($pending_error_messages['error'] as $message) { // replay any others |
|
626 | + foreach ($pending_error_messages['error'] as $message) { |
|
627 | +// replay any others |
|
636 | 628 | drupal_set_message($message, 'error'); |
637 | 629 | } |
638 | 630 | _forum_access_update_batch_finished(TRUE, array(), array()); |
639 | 631 | $form_state['redirect'] = $save_redirect; |
640 | - } |
|
641 | - else { |
|
632 | + } else { |
|
642 | 633 | // mass update in batch mode, modeled after node.module |
643 | 634 | $limit = $access['update_limit']; |
644 | 635 | $count = db_result(db_query("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid WHERE tn.tid = %d", $tid)); |
@@ -698,8 +689,7 @@ discard block |
||
698 | 689 | if ($success) { |
699 | 690 | drupal_set_message(t('The content access permissions have been updated.')); |
700 | 691 | cache_clear_all(); |
701 | - } |
|
702 | - else { |
|
692 | + } else { |
|
703 | 693 | drupal_set_message(t('The content access permissions have not been properly updated.'), 'error'); |
704 | 694 | } |
705 | 695 | } |
@@ -744,8 +734,7 @@ discard block |
||
744 | 734 | $return['view'] = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID); |
745 | 735 | $return['create'] = array(DRUPAL_AUTHENTICATED_RID); |
746 | 736 | $return['comment_create'] = array(DRUPAL_AUTHENTICATED_RID); |
747 | - } |
|
748 | - else { |
|
737 | + } else { |
|
749 | 738 | $result = db_query("SELECT * FROM {forum_access} where tid = %d", $tid); |
750 | 739 | while ($access = db_fetch_object($result)) { |
751 | 740 | if ($access->grant_view) { |
@@ -763,7 +752,8 @@ discard block |
||
763 | 752 | if ($access->grant_comment_create) { |
764 | 753 | $return['comment_create'][] = $access->rid; |
765 | 754 | } |
766 | - if ($access->rid == DRUPAL_AUTHENTICATED_RID) { // this is our reference |
|
755 | + if ($access->rid == DRUPAL_AUTHENTICATED_RID) { |
|
756 | +// this is our reference |
|
767 | 757 | $return['priority'] = $access->priority; |
768 | 758 | } |
769 | 759 | } |
@@ -831,8 +821,7 @@ discard block |
||
831 | 821 | drupal_set_message(t('Note: In Drupal, access can only be granted, not taken away. Whatever access you grant here will not be reflected in the !Forum_Access_link settings, but !Forum_Access can only allow <i>more</i> access, not less.', $variables) |
832 | 822 | .'<br /><span class="error">'. t('Specifically, any rights granted to the %anonymous_user and/or the %authenticated_user will <b>override</b> the settings of !Forum_Access!', $variables) .'</span>' |
833 | 823 | .'<br />'. t('To avoid conflicts with !Forum_Access settings, you may want to lower the priority of !Content_Access (under %Advanced below) below the priority of !Forum_Access for the content types that you want to be controlled by !Forum_Access.', $variables), 'warning'); |
834 | - } |
|
835 | - else { |
|
824 | + } else { |
|
836 | 825 | $vid = _forum_access_get_vid(); |
837 | 826 | $vocabulary = taxonomy_vocabulary_load($vid); |
838 | 827 | if (isset($vocabulary->nodes[arg(3)])) { |
@@ -926,8 +915,7 @@ discard block |
||
926 | 915 | } |
927 | 916 | watchdog('user', $msg, NULL, WATCHDOG_NOTICE); |
928 | 917 | return $rid; |
929 | - } |
|
930 | - else { |
|
918 | + } else { |
|
931 | 919 | $msg = t('!Forum_Access cannot create the %role role!', $variables); |
932 | 920 | watchdog('user', $msg, NULL, WATCHDOG_WARNING); |
933 | 921 | drupal_set_message($msg .' '. t('Is it already in use?'), 'error'); |
@@ -38,8 +38,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -22,8 +22,7 @@ discard block |
||
22 | 22 | // Strip preformatted code blocks from text during line break processing, replaced below |
23 | 23 | $body = str_replace($code_tag[0], "***pRe_sTrInG$i***", $body); |
24 | 24 | $pre[$i++] = '<pre class="bb-code-block">'. $code_tag[1] .'</pre>'; |
25 | - } |
|
26 | - else |
|
25 | + } else |
|
27 | 26 | $body = str_replace($code_tag[0], '<pre class="bb-code-block">'. $code_tag[1] .'</pre>', $body); |
28 | 27 | } |
29 | 28 | } |
@@ -34,7 +33,8 @@ discard block |
||
34 | 33 | if ($mode == 1) // Line breaks only (starting with PHP 4.0.5, nl2br() is XHTML compliant) |
35 | 34 | $body = nl2br($body); |
36 | 35 | |
37 | - if ($mode == 2) { // Line and paragraph breaks (may not always be XHTML compliant) |
|
36 | + if ($mode == 2) { |
|
37 | +// Line and paragraph breaks (may not always be XHTML compliant) |
|
38 | 38 | $body = preg_replace("/(\r\n|\n|\r)/", "\n", $body); |
39 | 39 | $body = preg_replace("/\n\n+/", "\n\n", $body); |
40 | 40 | $parts = explode("\n\n", $body); |
@@ -51,8 +51,9 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | // Reinsert preformatted code blocks |
54 | - foreach ($pre as $i => $code_tag) |
|
55 | - $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body); |
|
54 | + foreach ($pre as $i => $code_tag) { |
|
55 | + $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body); |
|
56 | + } |
|
56 | 57 | } |
57 | 58 | |
58 | 59 | // Replace any improper quote tags with proper quote tags |
@@ -83,7 +84,8 @@ discard block |
||
83 | 84 | } |
84 | 85 | |
85 | 86 | // begin processing for [size] |
86 | - if (stristr($body, '[size=') !== FALSE) { // prevent useless processing |
|
87 | + if (stristr($body, '[size=') !== FALSE) { |
|
88 | +// prevent useless processing |
|
87 | 89 | $arr = array( |
88 | 90 | 'tag' => 'size', |
89 | 91 | 'pattern' => '#\[\x07=([\d]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi', |
@@ -93,7 +95,8 @@ discard block |
||
93 | 95 | } // end processing for [size] |
94 | 96 | |
95 | 97 | // begin processing for [color] |
96 | - if (stristr($body, '[color=') !== FALSE) { // prevent useless processing |
|
98 | + if (stristr($body, '[color=') !== FALSE) { |
|
99 | +// prevent useless processing |
|
97 | 100 | $arr = array( |
98 | 101 | 'tag' => 'color', |
99 | 102 | 'pattern' => '#\[\x07=([\#\w]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si', |
@@ -103,7 +106,8 @@ discard block |
||
103 | 106 | } // end processing for [color] |
104 | 107 | |
105 | 108 | // begin processing for [font] |
106 | - if (stristr($body, '[font=') !== FALSE) { // prevent useless processing |
|
109 | + if (stristr($body, '[font=') !== FALSE) { |
|
110 | +// prevent useless processing |
|
107 | 111 | $arr = array( |
108 | 112 | 'tag' => 'font', |
109 | 113 | 'pattern' => '#\[\x07=([\w\s]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si', |
@@ -113,7 +117,8 @@ discard block |
||
113 | 117 | } // end processing for [font] |
114 | 118 | |
115 | 119 | // begin processing for [list] and [*] |
116 | - if (stristr($body, '[list') !== FALSE) { // prevent useless processing |
|
120 | + if (stristr($body, '[list') !== FALSE) { |
|
121 | +// prevent useless processing |
|
117 | 122 | $l_type = array( |
118 | 123 | NULL => array('style' => 'circle', 'tag' => 'ul'), |
119 | 124 | 'c' => array('style' => 'circle', 'tag' => 'ul'), |
@@ -235,8 +240,7 @@ discard block |
||
235 | 240 | // Replacing email addresses with encoded html |
236 | 241 | $body = preg_replace_callback('#\[email(?::\w+)?\]([\w\.\-\+~@]+)\[/email(?::\w+)?\]#si', '_bbcode_encode_mailto', $body); |
237 | 242 | $body = preg_replace_callback('#\[email=(.*?)(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si', '_bbcode_encode_mailto', $body); |
238 | - } |
|
239 | - else { |
|
243 | + } else { |
|
240 | 244 | $body = preg_replace( |
241 | 245 | array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si','#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'), |
242 | 246 | array('<a href="mailto:\\1" class="bb-email">\\1</a>', '<a href="mailto:\\1" class="bb-email">\\2</a>'), |
@@ -330,8 +334,9 @@ discard block |
||
330 | 334 | $link = 'document.write(\'<a href="mailto:' . $matches[1] . '" class="bb-email">' . (isset($matches[2]) ? $matches[2] : $matches[1]) . '</a>\');'; |
331 | 335 | |
332 | 336 | $js_encode = ''; |
333 | - for ($x = 0; $x < strlen($link); $x++) |
|
334 | - $js_encode .= '%' . bin2hex($link{$x}); |
|
337 | + for ($x = 0; $x < strlen($link); $x++) { |
|
338 | + $js_encode .= '%' . bin2hex($link{$x}); |
|
339 | + } |
|
335 | 340 | |
336 | 341 | $link = '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>'; |
337 | 342 | if (isset($matches[3])) |
@@ -10,8 +10,7 @@ discard block |
||
10 | 10 | if ($long) { |
11 | 11 | include_once(drupal_get_path('module', 'bbcode') .'/bbcode-help.inc'); |
12 | 12 | return _bbcode_filter_tip(); |
13 | - } |
|
14 | - else { |
|
13 | + } else { |
|
15 | 14 | # D5: $output = t('You can use !BBCode tags in the text.', array('!BBCode' => l(t('BBCode'), "filter/tips/$format", NULL, NULL, 'filter-bbcode-' . $delta))); |
16 | 15 | $output = t('You can use !BBCode (opens in new window) tags in the text.', |
17 | 16 | array( |
@@ -50,8 +49,7 @@ discard block |
||
50 | 49 | $elapsed += $timing_stop[0] - $timing_start[0]; |
51 | 50 | $ret .= '<hr />'. l('BBCode', "filter/tips/$format") .' parsed on '.date('r').'<br />Execution time: '.$elapsed.' seconds.<hr />'; |
52 | 51 | return $ret; |
53 | - } |
|
54 | - else |
|
52 | + } else |
|
55 | 53 | return _bbcode_filter_process($text, $format); |
56 | 54 | |
57 | 55 | case 'settings': |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // Else user may view the page when they are going to create their own profile |
92 | 92 | // or have permission to create it for others. |
93 | 93 | global $user; |
94 | - if ($user->uid == $account->uid || user_access('administer nodes') ){ |
|
94 | + if ($user->uid == $account->uid || user_access('administer nodes') ) { |
|
95 | 95 | return node_access('create', $type); |
96 | 96 | } |
97 | 97 | return FALSE; |
@@ -270,8 +270,7 @@ discard block |
||
270 | 270 | '#title' => t('Use this content type as a content profile for users'), |
271 | 271 | '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE), |
272 | 272 | ); |
273 | - } |
|
274 | - elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) { |
|
273 | + } elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) { |
|
275 | 274 | // Customize the redirect target and buttons of our own node forms. |
276 | 275 | if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' || arg(2) == 'profile') { |
277 | 276 | $form['buttons']['preview']['#access'] = FALSE; |
@@ -382,8 +381,7 @@ discard block |
||
382 | 381 | // This node already exists, redirect to edit page |
383 | 382 | drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid); |
384 | 383 | } |
385 | - } |
|
386 | - elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) { |
|
384 | + } elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) { |
|
387 | 385 | $form = $a3; |
388 | 386 | // Only validate if the user-name changed or we add a new node |
389 | 387 | if (!empty($node->nid) && $form['author']['name']['#default_value'] == $node->name) { |
@@ -394,8 +392,7 @@ discard block |
||
394 | 392 | if ($uid && content_profile_profile_exists($node, $uid)) { |
395 | 393 | form_set_error('name', t('This user already has a content profile of this type. You can only create one profile per user.')); |
396 | 394 | } |
397 | - } |
|
398 | - elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) { |
|
395 | + } elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) { |
|
399 | 396 | // Make sure the translated profile belongs to the same user. |
400 | 397 | $node->uid = $node->translation_source->uid; |
401 | 398 | $node->name = $node->translation_source->name; |
@@ -504,8 +501,7 @@ discard block |
||
504 | 501 | $node = content_profile_load($type, $arg[1]); |
505 | 502 | if ($node) { |
506 | 503 | return node_help('node/%/edit', array(1 => $node->nid)); |
507 | - } |
|
508 | - else { |
|
504 | + } else { |
|
509 | 505 | return node_help('node/add/'. $type, array('node', 'add', $type)); |
510 | 506 | } |
511 | 507 | } |
@@ -537,8 +533,7 @@ discard block |
||
537 | 533 | |
538 | 534 | // Working around the bug described at http://drupal.org/node/302873 |
539 | 535 | module_load_include('inc', 'content_profile', 'content_profile.theme'); |
540 | - } |
|
541 | - elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) { |
|
536 | + } elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) { |
|
542 | 537 | $content['content_profile_'. $type] = array( |
543 | 538 | '#admin' => $uid != $user->uid, |
544 | 539 | '#theme' => 'content_profile_display_add_link', |
@@ -21,8 +21,7 @@ discard block |
||
21 | 21 | foreach ($form['#content_profile_registration_use_types'] as $type => $typename) { |
22 | 22 | content_profile_registration_add_profile_form($type, $form, $form_state); |
23 | 23 | } |
24 | - } |
|
25 | - elseif ($form_id == 'content_profile_admin_settings') { |
|
24 | + } elseif ($form_id == 'content_profile_admin_settings') { |
|
26 | 25 | $type = $form_state['type']; |
27 | 26 | // Let other modules add registration child elements before us! |
28 | 27 | $form += array('registration' => array()); |
@@ -133,8 +132,7 @@ discard block |
||
133 | 132 | // Set this to the values of one node, as it might be need by some #ahah callbacks |
134 | 133 | $form_add['#node'] = $node_form['#node']; |
135 | 134 | $form_add['type'] = $node_form['type']; |
136 | - } |
|
137 | - else { |
|
135 | + } else { |
|
138 | 136 | foreach (array('uid', 'name', 'author', 'buttons', 'language', '#theme', 'options') as $key) { |
139 | 137 | unset($node_form[$key]); |
140 | 138 | } |
@@ -148,8 +146,7 @@ discard block |
||
148 | 146 | if (count(element_children($form_add[$group_name])) == 0) { |
149 | 147 | unset($form_add[$group_name]); |
150 | 148 | } |
151 | - } |
|
152 | - else { |
|
149 | + } else { |
|
153 | 150 | unset($form_add[$field_name]); |
154 | 151 | } |
155 | 152 | } |
@@ -175,7 +172,7 @@ discard block |
||
175 | 172 | } |
176 | 173 | |
177 | 174 | // Set the enctype, if necessary. |
178 | - if (isset($node_form['#attributes']['enctype'])){ |
|
175 | + if (isset($node_form['#attributes']['enctype'])) { |
|
179 | 176 | $form['#attributes']['enctype'] = $node_form['#attributes']['enctype']; |
180 | 177 | } |
181 | 178 | } |
@@ -213,8 +210,7 @@ discard block |
||
213 | 210 | |
214 | 211 | if (!in_array('other', content_profile_get_settings($type, 'registration_hide'))) { |
215 | 212 | node_validate($node, $form); |
216 | - } |
|
217 | - elseif (module_exists('content')) { |
|
213 | + } elseif (module_exists('content')) { |
|
218 | 214 | content_validate($node); |
219 | 215 | } |
220 | 216 | |
@@ -232,8 +228,7 @@ discard block |
||
232 | 228 | function _content_profile_registration_remove_values($key, $element, &$form_state) { |
233 | 229 | if ((isset($element['#input']) || !empty($element['#tree'])) && isset($form_state['values'][$key])) { |
234 | 230 | unset($form_state['values'][$key]); |
235 | - } |
|
236 | - elseif (empty($element['#input']) && empty($element['#tree'])) { |
|
231 | + } elseif (empty($element['#input']) && empty($element['#tree'])) { |
|
237 | 232 | foreach (element_children($element) as $key) { |
238 | 233 | _content_profile_registration_remove_values($key, $element[$key], $form_state); |
239 | 234 | } |
@@ -96,8 +96,7 @@ discard block |
||
96 | 96 | if ($view->base_table == 'node' && !empty($view->display['default']->display_options['fields'])) { |
97 | 97 | if ($view->type == 'Default') { |
98 | 98 | $views[t('Default Views')][$view->name] = $view->name; |
99 | - } |
|
100 | - else { |
|
99 | + } else { |
|
101 | 100 | $views[t('Existing Views')][$view->name] = $view->name; |
102 | 101 | } |
103 | 102 | } |
@@ -125,8 +124,7 @@ discard block |
||
125 | 124 | '#required' => FALSE, |
126 | 125 | '#description' => t('Provide a comma separated list of arguments to pass to the view.'), |
127 | 126 | ); |
128 | - } |
|
129 | - else { |
|
127 | + } else { |
|
130 | 128 | $form['advanced']['no_view_help'] = array( |
131 | 129 | '#value' => t('<p>The list of nodes that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') . |
132 | 130 | t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Content types" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate nodes on node creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate nodes will be displayed.</li></ul>'), |
@@ -212,8 +210,7 @@ discard block |
||
212 | 210 | if (is_array($item) && !empty($item['nid'])) { |
213 | 211 | if (is_numeric($item['nid'])) { |
214 | 212 | $ids[] = $item['nid']; |
215 | - } |
|
216 | - else { |
|
213 | + } else { |
|
217 | 214 | $error_element = isset($item['_error_element']) ? $item['_error_element'] : ''; |
218 | 215 | if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']); |
219 | 216 | form_set_error($error_element, t("%name: invalid input.", array('%name' => t($field['widget']['label'])))); |
@@ -487,8 +484,7 @@ discard block |
||
487 | 484 | '#element_validate' => array('_element_validate_integer_positive'), |
488 | 485 | '#required' => TRUE, |
489 | 486 | ); |
490 | - } |
|
491 | - else { |
|
487 | + } else { |
|
492 | 488 | $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match); |
493 | 489 | $form['size'] = array('#type' => 'hidden', '#value' => $size); |
494 | 490 | } |
@@ -736,14 +732,12 @@ discard block |
||
736 | 732 | if (!empty($title) && ($n = node_load($nid)) && trim($title) != trim($n->title)) { |
737 | 733 | form_error($element[$field_key], t('%name: title mismatch. Please check your selection.', array('%name' => t($field['widget']['label'])))); |
738 | 734 | } |
739 | - } |
|
740 | - else { |
|
735 | + } else { |
|
741 | 736 | // No explicit nid. |
742 | 737 | $reference = _nodereference_potential_references($field, $value, 'equals', NULL, 1); |
743 | 738 | if (empty($reference)) { |
744 | 739 | form_error($element[$field_key], t('%name: found no valid post with that title.', array('%name' => t($field['widget']['label'])))); |
745 | - } |
|
746 | - else { |
|
740 | + } else { |
|
747 | 741 | // TODO: |
748 | 742 | // the best thing would be to present the user with an additional form, |
749 | 743 | // allowing the user to choose between valid candidates with the same title |
@@ -868,8 +862,7 @@ discard block |
||
868 | 862 | if (!empty($field['advanced_view_args'])) { |
869 | 863 | // TODO: Support Tokens using token.module ? |
870 | 864 | $view_args = array_map('trim', explode(',', $field['advanced_view_args'])); |
871 | - } |
|
872 | - else { |
|
865 | + } else { |
|
873 | 866 | $view_args = array(); |
874 | 867 | } |
875 | 868 | |
@@ -894,8 +887,7 @@ discard block |
||
894 | 887 | |
895 | 888 | // Get the results. |
896 | 889 | $result = $view->execute_display($display, $view_args); |
897 | - } |
|
898 | - else { |
|
890 | + } else { |
|
899 | 891 | $result = FALSE; |
900 | 892 | } |
901 | 893 | |
@@ -933,8 +925,7 @@ discard block |
||
933 | 925 | ); |
934 | 926 | $where[] = 'n.title '. (isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']); |
935 | 927 | $args[] = $string; |
936 | - } |
|
937 | - elseif ($ids) { |
|
928 | + } elseif ($ids) { |
|
938 | 929 | $where[] = 'n.nid IN (' . db_placeholders($ids) . ')'; |
939 | 930 | $args = array_merge($args, $ids); |
940 | 931 | } |