Completed
Pull Request — master (#2592)
by Kevin
11:52
created
default/boinc/modules/boincstats/includes/pchart/class/pSpring.class.php 5 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -258,6 +258,11 @@  discard block
 block discarded – undo
258 258
      $this->Data[$SourceID]["Connections"][] = $TargetID;
259 259
     }
260 260
    /* Get the median linked nodes position */
261
+
262
+   /**
263
+    * @param double $X
264
+    * @param double $Y
265
+    */
261 266
    function getMedianOffset($Key,$X,$Y)
262 267
     {
263 268
      $Cpt = 1;
@@ -277,6 +282,10 @@  discard block
 block discarded – undo
277 282
     }
278 283
 
279 284
    /* Return the ID of the attached partner with the biggest weight */
285
+
286
+   /**
287
+    * @return double
288
+    */
280 289
    function getBiggestPartner($Key)
281 290
     {
282 291
      if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
Please login to merge, or discard this patch.
Indentation   +665 added lines, -665 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- /*
2
+    /*
3 3
      pSpring - class to draw spring graphs
4 4
 
5 5
      Version     : 2.1.3
@@ -13,856 +13,856 @@  discard block
 block discarded – undo
13 13
      You can find the whole class documentation on the pChart web site.
14 14
  */
15 15
 
16
- define("NODE_TYPE_FREE"	, 690001);
17
- define("NODE_TYPE_CENTRAL"	, 690002);
18
-
19
- define("NODE_SHAPE_CIRCLE"	, 690011);
20
- define("NODE_SHAPE_TRIANGLE"	, 690012);
21
- define("NODE_SHAPE_SQUARE"	, 690013);
22
-
23
- define("ALGORITHM_RANDOM"	, 690021);
24
- define("ALGORITHM_WEIGHTED"	, 690022);
25
- define("ALGORITHM_CIRCULAR"	, 690023);
26
- define("ALGORITHM_CENTRAL"	, 690024);
27
-
28
- define("LABEL_CLASSIC"		, 690031);
29
- define("LABEL_LIGHT"		, 690032);
30
-
31
- /* pSpring class definition */
32
- class pSpring
33
-  {
34
-   var $History;
35
-   var $pChartObject;
36
-   var $Data;
37
-   var $Links;
38
-   var $X1;
39
-   var $Y1;
40
-   var $X2;
41
-   var $Y2;
42
-   var $AutoComputeFreeZone;
43
-   var $Labels;
44
-
45
-   /* Class creator */
46
-   function pSpring()
16
+    define("NODE_TYPE_FREE"	, 690001);
17
+    define("NODE_TYPE_CENTRAL"	, 690002);
18
+
19
+    define("NODE_SHAPE_CIRCLE"	, 690011);
20
+    define("NODE_SHAPE_TRIANGLE"	, 690012);
21
+    define("NODE_SHAPE_SQUARE"	, 690013);
22
+
23
+    define("ALGORITHM_RANDOM"	, 690021);
24
+    define("ALGORITHM_WEIGHTED"	, 690022);
25
+    define("ALGORITHM_CIRCULAR"	, 690023);
26
+    define("ALGORITHM_CENTRAL"	, 690024);
27
+
28
+    define("LABEL_CLASSIC"		, 690031);
29
+    define("LABEL_LIGHT"		, 690032);
30
+
31
+    /* pSpring class definition */
32
+    class pSpring
47 33
     {
48
-     /* Initialise data arrays */
49
-     $this->Data = "";
50
-     $this->Links = "";
51
-
52
-     /* Set nodes defaults */
53
-     $this->Default["R"]		= 255;
54
-     $this->Default["G"]		= 255;
55
-     $this->Default["B"]		= 255;
56
-     $this->Default["Alpha"]		= 100;
57
-     $this->Default["BorderR"]		= 0;
58
-     $this->Default["BorderG"]		= 0;
59
-     $this->Default["BorderB"]		= 0;
60
-     $this->Default["BorderAlpha"]	= 100;
61
-     $this->Default["Surrounding"]	= NULL;
62
-     $this->Default["BackgroundR"]	= 255;
63
-     $this->Default["BackgroundG"]	= 255;
64
-     $this->Default["BackgroundB"]	= 255;
65
-     $this->Default["BackgroundAlpha"]	= 0;
66
-     $this->Default["Force"]		= 1;
67
-     $this->Default["NodeType"]		= NODE_TYPE_FREE;
68
-     $this->Default["Size"]		= 5;
69
-     $this->Default["Shape"]		= NODE_SHAPE_CIRCLE;
70
-     $this->Default["FreeZone"]		= 40;
71
-     $this->Default["LinkR"]		= 0;
72
-     $this->Default["LinkG"]		= 0;
73
-     $this->Default["LinkB"]		= 0;
74
-     $this->Default["LinkAlpha"]	= 0;
75
-
76
-     $this->Labels["Type"]		= LABEL_CLASSIC;
77
-     $this->Labels["R"]			= 0;
78
-     $this->Labels["G"]			= 0;
79
-     $this->Labels["B"]			= 0;
80
-     $this->Labels["Alpha"]		= 100;
81
-
82
-     $this->AutoComputeFreeZone         = FALSE;
34
+    var $History;
35
+    var $pChartObject;
36
+    var $Data;
37
+    var $Links;
38
+    var $X1;
39
+    var $Y1;
40
+    var $X2;
41
+    var $Y2;
42
+    var $AutoComputeFreeZone;
43
+    var $Labels;
44
+
45
+    /* Class creator */
46
+    function pSpring()
47
+    {
48
+        /* Initialise data arrays */
49
+        $this->Data = "";
50
+        $this->Links = "";
51
+
52
+        /* Set nodes defaults */
53
+        $this->Default["R"]		= 255;
54
+        $this->Default["G"]		= 255;
55
+        $this->Default["B"]		= 255;
56
+        $this->Default["Alpha"]		= 100;
57
+        $this->Default["BorderR"]		= 0;
58
+        $this->Default["BorderG"]		= 0;
59
+        $this->Default["BorderB"]		= 0;
60
+        $this->Default["BorderAlpha"]	= 100;
61
+        $this->Default["Surrounding"]	= NULL;
62
+        $this->Default["BackgroundR"]	= 255;
63
+        $this->Default["BackgroundG"]	= 255;
64
+        $this->Default["BackgroundB"]	= 255;
65
+        $this->Default["BackgroundAlpha"]	= 0;
66
+        $this->Default["Force"]		= 1;
67
+        $this->Default["NodeType"]		= NODE_TYPE_FREE;
68
+        $this->Default["Size"]		= 5;
69
+        $this->Default["Shape"]		= NODE_SHAPE_CIRCLE;
70
+        $this->Default["FreeZone"]		= 40;
71
+        $this->Default["LinkR"]		= 0;
72
+        $this->Default["LinkG"]		= 0;
73
+        $this->Default["LinkB"]		= 0;
74
+        $this->Default["LinkAlpha"]	= 0;
75
+
76
+        $this->Labels["Type"]		= LABEL_CLASSIC;
77
+        $this->Labels["R"]			= 0;
78
+        $this->Labels["G"]			= 0;
79
+        $this->Labels["B"]			= 0;
80
+        $this->Labels["Alpha"]		= 100;
81
+
82
+        $this->AutoComputeFreeZone         = FALSE;
83 83
     }
84 84
 
85
-   /* Set default links options */
86
-   function setLinkDefaults($Settings="")
85
+    /* Set default links options */
86
+    function setLinkDefaults($Settings="")
87 87
     {
88
-     if ( isset($Settings["R"]) )     { $this->Default["LinkR"] = $Settings["R"]; }
89
-     if ( isset($Settings["G"]) )     { $this->Default["LinkG"] = $Settings["G"]; }
90
-     if ( isset($Settings["B"]) )     { $this->Default["LinkB"] = $Settings["B"]; }
91
-     if ( isset($Settings["Alpha"]) ) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; }
88
+        if ( isset($Settings["R"]) )     { $this->Default["LinkR"] = $Settings["R"]; }
89
+        if ( isset($Settings["G"]) )     { $this->Default["LinkG"] = $Settings["G"]; }
90
+        if ( isset($Settings["B"]) )     { $this->Default["LinkB"] = $Settings["B"]; }
91
+        if ( isset($Settings["Alpha"]) ) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; }
92 92
     }
93 93
 
94
-   /* Set default links options */
95
-   function setLabelsSettings($Settings="")
94
+    /* Set default links options */
95
+    function setLabelsSettings($Settings="")
96 96
     {
97
-     if ( isset($Settings["Type"]) )  { $this->Labels["Type"] = $Settings["Type"]; }
98
-     if ( isset($Settings["R"]) )     { $this->Labels["R"] = $Settings["R"]; }
99
-     if ( isset($Settings["G"]) )     { $this->Labels["G"] = $Settings["G"]; }
100
-     if ( isset($Settings["B"]) )     { $this->Labels["B"] = $Settings["B"]; }
101
-     if ( isset($Settings["Alpha"]) ) { $this->Labels["Alpha"] = $Settings["Alpha"]; }
97
+        if ( isset($Settings["Type"]) )  { $this->Labels["Type"] = $Settings["Type"]; }
98
+        if ( isset($Settings["R"]) )     { $this->Labels["R"] = $Settings["R"]; }
99
+        if ( isset($Settings["G"]) )     { $this->Labels["G"] = $Settings["G"]; }
100
+        if ( isset($Settings["B"]) )     { $this->Labels["B"] = $Settings["B"]; }
101
+        if ( isset($Settings["Alpha"]) ) { $this->Labels["Alpha"] = $Settings["Alpha"]; }
102 102
     }
103 103
 
104
-   /* Auto compute the FreeZone size based on the number of connections */
105
-   function autoFreeZone()
104
+    /* Auto compute the FreeZone size based on the number of connections */
105
+    function autoFreeZone()
106 106
     {
107
-     /* Check connections reciprocity */
108
-     foreach($this->Data as $Key => $Settings)
109
-      {
110
-       if ( isset($Settings["Connections"]) )
107
+        /* Check connections reciprocity */
108
+        foreach($this->Data as $Key => $Settings)
109
+        {
110
+        if ( isset($Settings["Connections"]) )
111 111
         { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; }
112
-       else
112
+        else
113 113
         { $this->Data[$Key]["FreeZone"] = 20; }
114
-      }
114
+        }
115 115
 
116 116
     }
117 117
 
118
-   /* Set link properties */
119
-   function linkProperties($FromNode,$ToNode,$Settings)
118
+    /* Set link properties */
119
+    function linkProperties($FromNode,$ToNode,$Settings)
120 120
     {
121
-     if ( !isset($this->Data[$FromNode]) ) { return(0); }
122
-     if ( !isset($this->Data[$ToNode]) )   { return(0); }
123
-
124
-     $R			= isset($Settings["R"]) ? $Settings["R"] : 0;
125
-     $G			= isset($Settings["G"]) ? $Settings["G"] : 0;
126
-     $B			= isset($Settings["B"]) ? $Settings["B"] : 0;
127
-     $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100;
128
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : NULL;
129
-     $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL;
130
-
131
-     $this->Links[$FromNode][$ToNode]["R"] = $R;         $this->Links[$ToNode][$FromNode]["R"] = $R;
132
-     $this->Links[$FromNode][$ToNode]["G"] = $G;         $this->Links[$ToNode][$FromNode]["G"] = $G;
133
-     $this->Links[$FromNode][$ToNode]["B"] = $B;         $this->Links[$ToNode][$FromNode]["B"] = $B;
134
-     $this->Links[$FromNode][$ToNode]["Alpha"] = $Alpha; $this->Links[$ToNode][$FromNode]["Alpha"] = $Alpha;
135
-     $this->Links[$FromNode][$ToNode]["Name"] = $Name;   $this->Links[$ToNode][$FromNode]["Name"] = $Name;
136
-     $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks;
121
+        if ( !isset($this->Data[$FromNode]) ) { return(0); }
122
+        if ( !isset($this->Data[$ToNode]) )   { return(0); }
123
+
124
+        $R			= isset($Settings["R"]) ? $Settings["R"] : 0;
125
+        $G			= isset($Settings["G"]) ? $Settings["G"] : 0;
126
+        $B			= isset($Settings["B"]) ? $Settings["B"] : 0;
127
+        $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100;
128
+        $Name		= isset($Settings["Name"]) ? $Settings["Name"] : NULL;
129
+        $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL;
130
+
131
+        $this->Links[$FromNode][$ToNode]["R"] = $R;         $this->Links[$ToNode][$FromNode]["R"] = $R;
132
+        $this->Links[$FromNode][$ToNode]["G"] = $G;         $this->Links[$ToNode][$FromNode]["G"] = $G;
133
+        $this->Links[$FromNode][$ToNode]["B"] = $B;         $this->Links[$ToNode][$FromNode]["B"] = $B;
134
+        $this->Links[$FromNode][$ToNode]["Alpha"] = $Alpha; $this->Links[$ToNode][$FromNode]["Alpha"] = $Alpha;
135
+        $this->Links[$FromNode][$ToNode]["Name"] = $Name;   $this->Links[$ToNode][$FromNode]["Name"] = $Name;
136
+        $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks;
137 137
     }
138 138
 
139
-   function setNodeDefaults($Settings="")
139
+    function setNodeDefaults($Settings="")
140 140
     {
141
-     if ( isset($Settings["R"]) ) { $this->Default["R"]					= $Settings["R"]; }
142
-     if ( isset($Settings["G"]) ) { $this->Default["G"]					= $Settings["G"]; }
143
-     if ( isset($Settings["B"]) ) { $this->Default["B"]					= $Settings["B"]; }
144
-     if ( isset($Settings["Alpha"]) ) { $this->Default["Alpha"]				= $Settings["Alpha"]; }
145
-     if ( isset($Settings["BorderR"]) ) { $this->Default["BorderR"]			= $Settings["BorderR"]; }
146
-     if ( isset($Settings["BorderG"]) ) { $this->Default["BorderG"]			= $Settings["BorderG"]; }
147
-     if ( isset($Settings["BorderB"]) ) { $this->Default["BorderB"]			= $Settings["BorderB"]; }
148
-     if ( isset($Settings["BorderAlpha"]) ) { $this->Default["BorderAlpha"]		= $Settings["BorderAlpha"]; }
149
-     if ( isset($Settings["Surrounding"]) ) { $this->Default["Surrounding"]		= $Settings["Surrounding"]; }
150
-     if ( isset($Settings["BackgroundR"]) ) { $this->Default["BackgroundR"]		= $Settings["BackgroundR"]; }
151
-     if ( isset($Settings["BackgroundG"]) ) { $this->Default["BackgroundG"]		= $Settings["BackgroundG"]; }
152
-     if ( isset($Settings["BackgroundB"]) ) { $this->Default["BackgroundB"]		= $Settings["BackgroundB"]; }
153
-     if ( isset($Settings["BackgroundAlpha"]) ) { $this->Default["BackgroundAlpha"]	= $Settings["BackgroundAlpha"]; }
154
-     if ( isset($Settings["NodeType"]) ) { $this->Default["NodeType"]			= $Settings["NodeType"]; }
155
-     if ( isset($Settings["Size"]) ) { $this->Default["Size"]				= $Settings["Size"]; }
156
-     if ( isset($Settings["Shape"]) ) { $this->Default["Shape"]				= $Settings["Shape"]; }
157
-     if ( isset($Settings["FreeZone"]) ) { $this->Default["FreeZone"]			= $Settings["FreeZone"]; }
141
+        if ( isset($Settings["R"]) ) { $this->Default["R"]					= $Settings["R"]; }
142
+        if ( isset($Settings["G"]) ) { $this->Default["G"]					= $Settings["G"]; }
143
+        if ( isset($Settings["B"]) ) { $this->Default["B"]					= $Settings["B"]; }
144
+        if ( isset($Settings["Alpha"]) ) { $this->Default["Alpha"]				= $Settings["Alpha"]; }
145
+        if ( isset($Settings["BorderR"]) ) { $this->Default["BorderR"]			= $Settings["BorderR"]; }
146
+        if ( isset($Settings["BorderG"]) ) { $this->Default["BorderG"]			= $Settings["BorderG"]; }
147
+        if ( isset($Settings["BorderB"]) ) { $this->Default["BorderB"]			= $Settings["BorderB"]; }
148
+        if ( isset($Settings["BorderAlpha"]) ) { $this->Default["BorderAlpha"]		= $Settings["BorderAlpha"]; }
149
+        if ( isset($Settings["Surrounding"]) ) { $this->Default["Surrounding"]		= $Settings["Surrounding"]; }
150
+        if ( isset($Settings["BackgroundR"]) ) { $this->Default["BackgroundR"]		= $Settings["BackgroundR"]; }
151
+        if ( isset($Settings["BackgroundG"]) ) { $this->Default["BackgroundG"]		= $Settings["BackgroundG"]; }
152
+        if ( isset($Settings["BackgroundB"]) ) { $this->Default["BackgroundB"]		= $Settings["BackgroundB"]; }
153
+        if ( isset($Settings["BackgroundAlpha"]) ) { $this->Default["BackgroundAlpha"]	= $Settings["BackgroundAlpha"]; }
154
+        if ( isset($Settings["NodeType"]) ) { $this->Default["NodeType"]			= $Settings["NodeType"]; }
155
+        if ( isset($Settings["Size"]) ) { $this->Default["Size"]				= $Settings["Size"]; }
156
+        if ( isset($Settings["Shape"]) ) { $this->Default["Shape"]				= $Settings["Shape"]; }
157
+        if ( isset($Settings["FreeZone"]) ) { $this->Default["FreeZone"]			= $Settings["FreeZone"]; }
158 158
     }
159 159
 
160
-   /* Add a node */
161
-   function addNode($NodeID,$Settings="")
160
+    /* Add a node */
161
+    function addNode($NodeID,$Settings="")
162 162
     {
163
-     /* if the node already exists, ignore */
164
-     if (isset($this->Data[$NodeID])) { return(0); }
165
-
166
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
-     $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
168
-
169
-     $R			= isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
170
-     $G			= isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
171
-     $B			= isset($Settings["B"]) ? $Settings["B"] : $this->Default["B"];
172
-     $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
173
-     $BorderR		= isset($Settings["BorderR"]) ? $Settings["BorderR"] : $this->Default["BorderR"];
174
-     $BorderG		= isset($Settings["BorderG"]) ? $Settings["BorderG"] : $this->Default["BorderG"];
175
-     $BorderB		= isset($Settings["BorderB"]) ? $Settings["BorderB"] : $this->Default["BorderB"];
176
-     $BorderAlpha	= isset($Settings["BorderAlpha"]) ? $Settings["BorderAlpha"] : $this->Default["BorderAlpha"];
177
-     $Surrounding	= isset($Settings["Surrounding"]) ? $Settings["Surrounding"] : $this->Default["Surrounding"];
178
-     $BackgroundR	= isset($Settings["BackgroundR"]) ? $Settings["BackgroundR"] : $this->Default["BackgroundR"];
179
-     $BackgroundG	= isset($Settings["BackgroundG"]) ? $Settings["BackgroundG"] : $this->Default["BackgroundG"];
180
-     $BackgroundB	= isset($Settings["BackgroundB"]) ? $Settings["BackgroundB"] : $this->Default["BackgroundB"];
181
-     $BackgroundAlpha	= isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
182
-     $Force		= isset($Settings["Force"]) ? $Settings["Force"] :  $this->Default["Force"];
183
-     $NodeType		= isset($Settings["NodeType"]) ? $Settings["NodeType"] : $this->Default["NodeType"];
184
-     $Size		= isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
185
-     $Shape		= isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
186
-     $FreeZone		= isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
187
-
188
-     if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
189
-
190
-     $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha;
191
-     $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
192
-     $this->Data[$NodeID]["BackgroundR"]	= $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
193
-     $this->Data[$NodeID]["Name"]		= $Name;
194
-     $this->Data[$NodeID]["Force"]		= $Force;
195
-     $this->Data[$NodeID]["Type"]		= $NodeType;
196
-     $this->Data[$NodeID]["Size"]		= $Size;
197
-     $this->Data[$NodeID]["Shape"]		= $Shape;
198
-     $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
-     if ( $Connections != NULL )
200
-      {
201
-       if ( is_array($Connections ) )
202
-        {
203
-         foreach($Connections as $Key => $Value)
204
-          $this->Data[$NodeID]["Connections"][] = $Value;
205
-        }
206
-       else
163
+        /* if the node already exists, ignore */
164
+        if (isset($this->Data[$NodeID])) { return(0); }
165
+
166
+        $Name		= isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
+        $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
168
+
169
+        $R			= isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
170
+        $G			= isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
171
+        $B			= isset($Settings["B"]) ? $Settings["B"] : $this->Default["B"];
172
+        $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
173
+        $BorderR		= isset($Settings["BorderR"]) ? $Settings["BorderR"] : $this->Default["BorderR"];
174
+        $BorderG		= isset($Settings["BorderG"]) ? $Settings["BorderG"] : $this->Default["BorderG"];
175
+        $BorderB		= isset($Settings["BorderB"]) ? $Settings["BorderB"] : $this->Default["BorderB"];
176
+        $BorderAlpha	= isset($Settings["BorderAlpha"]) ? $Settings["BorderAlpha"] : $this->Default["BorderAlpha"];
177
+        $Surrounding	= isset($Settings["Surrounding"]) ? $Settings["Surrounding"] : $this->Default["Surrounding"];
178
+        $BackgroundR	= isset($Settings["BackgroundR"]) ? $Settings["BackgroundR"] : $this->Default["BackgroundR"];
179
+        $BackgroundG	= isset($Settings["BackgroundG"]) ? $Settings["BackgroundG"] : $this->Default["BackgroundG"];
180
+        $BackgroundB	= isset($Settings["BackgroundB"]) ? $Settings["BackgroundB"] : $this->Default["BackgroundB"];
181
+        $BackgroundAlpha	= isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
182
+        $Force		= isset($Settings["Force"]) ? $Settings["Force"] :  $this->Default["Force"];
183
+        $NodeType		= isset($Settings["NodeType"]) ? $Settings["NodeType"] : $this->Default["NodeType"];
184
+        $Size		= isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
185
+        $Shape		= isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
186
+        $FreeZone		= isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
187
+
188
+        if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
189
+
190
+        $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha;
191
+        $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
192
+        $this->Data[$NodeID]["BackgroundR"]	= $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
193
+        $this->Data[$NodeID]["Name"]		= $Name;
194
+        $this->Data[$NodeID]["Force"]		= $Force;
195
+        $this->Data[$NodeID]["Type"]		= $NodeType;
196
+        $this->Data[$NodeID]["Size"]		= $Size;
197
+        $this->Data[$NodeID]["Shape"]		= $Shape;
198
+        $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
+        if ( $Connections != NULL )
200
+        {
201
+        if ( is_array($Connections ) )
202
+        {
203
+            foreach($Connections as $Key => $Value)
204
+            $this->Data[$NodeID]["Connections"][] = $Value;
205
+        }
206
+        else
207 207
         $this->Data[$NodeID]["Connections"][] = $Connections;
208
-      }
208
+        }
209 209
     }
210 210
 
211
-   /* Set color attribute for a list of nodes */
212
-   function setNodesColor($Nodes,$Settings="")
211
+    /* Set color attribute for a list of nodes */
212
+    function setNodesColor($Nodes,$Settings="")
213 213
     {
214
-     if ( is_array($Nodes) )
215
-      {
216
-       foreach ($Nodes as $Key => $NodeID)
217
-        {
218
-         if (isset($this->Data[$NodeID]) )
219
-          {
220
-           if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221
-           if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222
-           if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
223
-           if ( isset($Settings["Alpha"]) ) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; }
224
-           if ( isset($Settings["BorderR"]) ) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; }
225
-           if ( isset($Settings["BorderG"]) ) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; }
226
-           if ( isset($Settings["BorderB"]) ) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; }
227
-           if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; }
228
-           if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
229
-          }
230
-        }
231
-      }
232
-     else
233
-      {
234
-       if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235
-       if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236
-       if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
237
-       if ( isset($Settings["Alpha"]) ) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; }
238
-       if ( isset($Settings["BorderR"]) ) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; }
239
-       if ( isset($Settings["BorderG"]) ) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; }
240
-       if ( isset($Settings["BorderB"]) ) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; }
241
-       if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; }
242
-       if ( isset($Settings["Surrounding"]) ) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
243
-      }
214
+        if ( is_array($Nodes) )
215
+        {
216
+        foreach ($Nodes as $Key => $NodeID)
217
+        {
218
+            if (isset($this->Data[$NodeID]) )
219
+            {
220
+            if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221
+            if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222
+            if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
223
+            if ( isset($Settings["Alpha"]) ) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; }
224
+            if ( isset($Settings["BorderR"]) ) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; }
225
+            if ( isset($Settings["BorderG"]) ) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; }
226
+            if ( isset($Settings["BorderB"]) ) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; }
227
+            if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; }
228
+            if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
229
+            }
230
+        }
231
+        }
232
+        else
233
+        {
234
+        if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235
+        if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236
+        if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
237
+        if ( isset($Settings["Alpha"]) ) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; }
238
+        if ( isset($Settings["BorderR"]) ) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; }
239
+        if ( isset($Settings["BorderG"]) ) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; }
240
+        if ( isset($Settings["BorderB"]) ) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; }
241
+        if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; }
242
+        if ( isset($Settings["Surrounding"]) ) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
243
+        }
244 244
     }
245 245
 
246
-   /* Returns all the nodes details */
247
-   function dumpNodes()
246
+    /* Returns all the nodes details */
247
+    function dumpNodes()
248 248
     { return($this->Data); }
249 249
 
250
-   /* Check if a connection exists and create it if required */
251
-   function checkConnection($SourceID, $TargetID)
250
+    /* Check if a connection exists and create it if required */
251
+    function checkConnection($SourceID, $TargetID)
252 252
     {
253
-     if ( isset($this->Data[$SourceID]["Connections"]) )
254
-      {
255
-       foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
253
+        if ( isset($this->Data[$SourceID]["Connections"]) )
254
+        {
255
+        foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
256 256
         { if ( $TargetID == $ConnectionID ) { return(TRUE); } }
257
-      }
258
-     $this->Data[$SourceID]["Connections"][] = $TargetID;
257
+        }
258
+        $this->Data[$SourceID]["Connections"][] = $TargetID;
259 259
     }
260
-   /* Get the median linked nodes position */
261
-   function getMedianOffset($Key,$X,$Y)
260
+    /* Get the median linked nodes position */
261
+    function getMedianOffset($Key,$X,$Y)
262 262
     {
263
-     $Cpt = 1;
264
-     if ( isset($this->Data[$Key]["Connections"]) )
265
-      {
266
-       foreach($this->Data[$Key]["Connections"] as $ID => $NodeID)
267
-        {
268
-         if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) )
269
-          {
270
-           $X = $X + $this->Data[$NodeID]["X"];
271
-           $Y = $Y + $this->Data[$NodeID]["Y"];
272
-           $Cpt++;
273
-          }
274
-        }
275
-      }
276
-     return(array("X"=>$X/$Cpt,"Y"=>$Y/$Cpt));
263
+        $Cpt = 1;
264
+        if ( isset($this->Data[$Key]["Connections"]) )
265
+        {
266
+        foreach($this->Data[$Key]["Connections"] as $ID => $NodeID)
267
+        {
268
+            if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) )
269
+            {
270
+            $X = $X + $this->Data[$NodeID]["X"];
271
+            $Y = $Y + $this->Data[$NodeID]["Y"];
272
+            $Cpt++;
273
+            }
274
+        }
275
+        }
276
+        return(array("X"=>$X/$Cpt,"Y"=>$Y/$Cpt));
277 277
     }
278 278
 
279
-   /* Return the ID of the attached partner with the biggest weight */
280
-   function getBiggestPartner($Key)
279
+    /* Return the ID of the attached partner with the biggest weight */
280
+    function getBiggestPartner($Key)
281 281
     {
282
-     if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
282
+        if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
283 283
 
284
-     $MaxWeight = 0; $Result = "";
285
-     foreach($this->Data[$Key]["Connections"] as $Key => $PeerID)
286
-      {
287
-       if ( $this->Data[$PeerID]["Weight"] > $MaxWeight )
284
+        $MaxWeight = 0; $Result = "";
285
+        foreach($this->Data[$Key]["Connections"] as $Key => $PeerID)
286
+        {
287
+        if ( $this->Data[$PeerID]["Weight"] > $MaxWeight )
288 288
         { $MaxWeight = $this->Data[$PeerID]["Weight"]; $Result = $PeerID; }
289
-      }
290
-     return($Result);
289
+        }
290
+        return($Result);
291 291
     }
292 292
 
293
-   /* Do the initial node positions computing pass */
294
-   function firstPass($Algorithm)
293
+    /* Do the initial node positions computing pass */
294
+    function firstPass($Algorithm)
295 295
     {
296
-     $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
297
-     $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
296
+        $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
297
+        $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
298 298
 
299
-     /* Check connections reciprocity */
300
-     foreach($this->Data as $Key => $Settings)
301
-      {
302
-       if ( isset($Settings["Connections"]) )
299
+        /* Check connections reciprocity */
300
+        foreach($this->Data as $Key => $Settings)
301
+        {
302
+        if ( isset($Settings["Connections"]) )
303 303
         {
304
-         foreach($Settings["Connections"] as $ID => $ConnectionID)
305
-          $this->checkConnection($ConnectionID,$Key);
304
+            foreach($Settings["Connections"] as $ID => $ConnectionID)
305
+            $this->checkConnection($ConnectionID,$Key);
306
+        }
306 307
         }
307
-      }
308 308
 
309
-     if ( $this->AutoComputeFreeZone ) { $this->autoFreeZone(); }
309
+        if ( $this->AutoComputeFreeZone ) { $this->autoFreeZone(); }
310 310
 
311
-     /* Get the max number of connections */
312
-     $MaxConnections = 0;
313
-     foreach($this->Data as $Key => $Settings)
314
-      { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } }
311
+        /* Get the max number of connections */
312
+        $MaxConnections = 0;
313
+        foreach($this->Data as $Key => $Settings)
314
+        { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } }
315 315
 
316
-     if ( $Algorithm == ALGORITHM_WEIGHTED )
317
-      {
318
-       foreach($this->Data as $Key => $Settings)
316
+        if ( $Algorithm == ALGORITHM_WEIGHTED )
317
+        {
318
+        foreach($this->Data as $Key => $Settings)
319 319
         {
320
-         if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
322
-          {
323
-           if ( isset($Settings["Connections"]) )
320
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
322
+            {
323
+            if ( isset($Settings["Connections"]) )
324 324
             { $Connections = count($Settings["Connections"]); }
325
-           else
325
+            else
326 326
             { $Connections = 0; }
327 327
 
328
-           $Ring  = $MaxConnections - $Connections;
329
-           $Angle = rand(0,360);
328
+            $Ring  = $MaxConnections - $Connections;
329
+            $Angle = rand(0,360);
330 330
            
331
-           $this->Data[$Key]["X"] = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
332
-           $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
333
-          }
331
+            $this->Data[$Key]["X"] = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
332
+            $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
333
+            }
334 334
         }
335
-      }
336
-     elseif ( $Algorithm == ALGORITHM_CENTRAL )
337
-      {
338
-       /* Put a weight on each nodes */
339
-       foreach($this->Data as $Key => $Settings)
335
+        }
336
+        elseif ( $Algorithm == ALGORITHM_CENTRAL )
337
+        {
338
+        /* Put a weight on each nodes */
339
+        foreach($this->Data as $Key => $Settings)
340 340
         {
341
-         if ( isset($Settings["Connections"]) )
342
-          $this->Data[$Key]["Weight"] = count($Settings["Connections"]);
343
-         else
344
-          $this->Data[$Key]["Weight"] = 0;
341
+            if ( isset($Settings["Connections"]) )
342
+            $this->Data[$Key]["Weight"] = count($Settings["Connections"]);
343
+            else
344
+            $this->Data[$Key]["Weight"] = 0;
345 345
         }
346 346
 
347
-       $MaxConnections = $MaxConnections + 1;
348
-       for($i=$MaxConnections;$i>=0;$i--)
347
+        $MaxConnections = $MaxConnections + 1;
348
+        for($i=$MaxConnections;$i>=0;$i--)
349 349
         {
350
-         foreach($this->Data as $Key => $Settings)
351
-          {
352
-           if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
350
+            foreach($this->Data as $Key => $Settings)
354 351
             {
355
-             if ( isset($Settings["Connections"]) )
356
-              { $Connections = count($Settings["Connections"]); }
357
-             else
358
-              { $Connections = 0; }
359
-
360
-             if ( $Connections == $i )
361
-              {
362
-               $BiggestPartner = $this->getBiggestPartner($Key);
363
-               if ( $BiggestPartner != "" )
352
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
354
+            {
355
+                if ( isset($Settings["Connections"]) )
356
+                { $Connections = count($Settings["Connections"]); }
357
+                else
358
+                { $Connections = 0; }
359
+
360
+                if ( $Connections == $i )
364 361
                 {
365
-                 $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366
-                 $Weight        = $this->Data[$BiggestPartner]["Weight"];
367
-                 $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
368
-                 $Done          = FALSE; $Tries = 0;
369
-                 while (!$Done && $Tries <= $Weight*2)
370
-                  {
371
-                   $Tries++;
372
-                   $Angle = floor(rand(0,$Weight)*$AngleDivision);
373
-                   if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
362
+                $BiggestPartner = $this->getBiggestPartner($Key);
363
+                if ( $BiggestPartner != "" )
364
+                {
365
+                    $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366
+                    $Weight        = $this->Data[$BiggestPartner]["Weight"];
367
+                    $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
368
+                    $Done          = FALSE; $Tries = 0;
369
+                    while (!$Done && $Tries <= $Weight*2)
370
+                    {
371
+                    $Tries++;
372
+                    $Angle = floor(rand(0,$Weight)*$AngleDivision);
373
+                    if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
374 374
                     {
375
-                     $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376
-                     $Done = TRUE; 
375
+                        $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376
+                        $Done = TRUE; 
377 377
                     }
378
-                  }
379
-                 if ( !$Done )
380
-                  { $Angle = rand(0,360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; }
378
+                    }
379
+                    if ( !$Done )
380
+                    { $Angle = rand(0,360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; }
381 381
 
382
-                 $X = cos(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["X"];
383
-                 $Y = sin(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["Y"];
382
+                    $X = cos(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["X"];
383
+                    $Y = sin(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["Y"];
384 384
 
385
-                 $this->Data[$Key]["X"] = $X;
386
-                 $this->Data[$Key]["Y"] = $Y;
385
+                    $this->Data[$Key]["X"] = $X;
386
+                    $this->Data[$Key]["Y"] = $Y;
387
+                }
387 388
                 }
388
-              }
389 389
             }
390
-          }
391
-        }
392
-      }
393
-     elseif ( $Algorithm == ALGORITHM_CIRCULAR )
394
-      {
395
-       $MaxConnections = $MaxConnections + 1;
396
-       for($i=$MaxConnections;$i>=0;$i--)
397
-        {
398
-         foreach($this->Data as $Key => $Settings)
399
-          {
400
-           if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
390
+            }
391
+        }
392
+        }
393
+        elseif ( $Algorithm == ALGORITHM_CIRCULAR )
394
+        {
395
+        $MaxConnections = $MaxConnections + 1;
396
+        for($i=$MaxConnections;$i>=0;$i--)
397
+        {
398
+            foreach($this->Data as $Key => $Settings)
399
+            {
400
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
402 402
             {
403
-             if ( isset($Settings["Connections"]) )
404
-              { $Connections = count($Settings["Connections"]); }
405
-             else
406
-              { $Connections = 0; }
403
+                if ( isset($Settings["Connections"]) )
404
+                { $Connections = count($Settings["Connections"]); }
405
+                else
406
+                { $Connections = 0; }
407 407
 
408
-             if ( $Connections == $i )
409
-              {
410
-               $Ring  = $MaxConnections - $Connections;
411
-               $Angle = rand(0,360);
408
+                if ( $Connections == $i )
409
+                {
410
+                $Ring  = $MaxConnections - $Connections;
411
+                $Angle = rand(0,360);
412 412
 
413
-               $X = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
414
-               $Y = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
413
+                $X = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
414
+                $Y = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
415 415
 
416
-               $MedianOffset = $this->getMedianOffset($Key,$X,$Y);
416
+                $MedianOffset = $this->getMedianOffset($Key,$X,$Y);
417 417
 
418
-               $this->Data[$Key]["X"] = $MedianOffset["X"];
419
-               $this->Data[$Key]["Y"] = $MedianOffset["Y"];
420
-              }
418
+                $this->Data[$Key]["X"] = $MedianOffset["X"];
419
+                $this->Data[$Key]["Y"] = $MedianOffset["Y"];
420
+                }
421 421
             }
422
-          }
422
+            }
423
+        }
423 424
         }
424
-      }
425
-     elseif ( $Algorithm == ALGORITHM_RANDOM )
426
-      {
427
-       foreach($this->Data as $Key => $Settings)
425
+        elseif ( $Algorithm == ALGORITHM_RANDOM )
428 426
         {
429
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
430
-          {
431
-           $this->Data[$Key]["X"] = $CenterX + rand(-20,20);
432
-           $this->Data[$Key]["Y"] = $CenterY + rand(-20,20);
433
-          }
434
-         if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
427
+        foreach($this->Data as $Key => $Settings)
428
+        {
429
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
430
+            {
431
+            $this->Data[$Key]["X"] = $CenterX + rand(-20,20);
432
+            $this->Data[$Key]["Y"] = $CenterY + rand(-20,20);
433
+            }
434
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
435
+        }
435 436
         }
436
-      }
437 437
     }
438 438
 
439
-   /* Compute one pass */
440
-   function doPass()
439
+    /* Compute one pass */
440
+    function doPass()
441 441
     {
442
-     /* Compute vectors */
443
-     foreach($this->Data as $Key => $Settings)
444
-      {
445
-       if ( $Settings["Type"] != NODE_TYPE_CENTRAL )
442
+        /* Compute vectors */
443
+        foreach($this->Data as $Key => $Settings)
446 444
         {
447
-         unset($this->Data[$Key]["Vectors"]);
445
+        if ( $Settings["Type"] != NODE_TYPE_CENTRAL )
446
+        {
447
+            unset($this->Data[$Key]["Vectors"]);
448 448
 
449
-         $X1 = $Settings["X"];
450
-         $Y1 = $Settings["Y"];
449
+            $X1 = $Settings["X"];
450
+            $Y1 = $Settings["Y"];
451 451
 
452
-         /* Repulsion vectors */
453
-         foreach($this->Data as $Key2 => $Settings2)
454
-          {
455
-           if ( $Key != $Key2 )
452
+            /* Repulsion vectors */
453
+            foreach($this->Data as $Key2 => $Settings2)
454
+            {
455
+            if ( $Key != $Key2 )
456 456
             {
457
-             $X2 = $this->Data[$Key2]["X"];
458
-             $Y2 = $this->Data[$Key2]["Y"];
459
-             $FreeZone = $this->Data[$Key2]["FreeZone"];
460
-
461
-             $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
462
-             $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2) + 180;
463
-
464
-             /* Nodes too close, repulsion occurs */
465
-             if ( $Distance < $FreeZone )
466
-              {
467
-               $Force = log(pow(2,$FreeZone-$Distance));
468
-               if ( $Force > 1 )
457
+                $X2 = $this->Data[$Key2]["X"];
458
+                $Y2 = $this->Data[$Key2]["Y"];
459
+                $FreeZone = $this->Data[$Key2]["FreeZone"];
460
+
461
+                $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
462
+                $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2) + 180;
463
+
464
+                /* Nodes too close, repulsion occurs */
465
+                if ( $Distance < $FreeZone )
466
+                {
467
+                $Force = log(pow(2,$FreeZone-$Distance));
468
+                if ( $Force > 1 )
469 469
                 { $this->Data[$Key]["Vectors"][] = array("Type"=>"R","Angle"=>$Angle % 360,"Force"=>$Force); }
470
-              }
470
+                }
471
+            }
471 472
             }
472
-          }
473 473
 
474
-         /* Attraction vectors */
475
-         if ( isset($Settings["Connections"]) )
476
-          {
477
-           foreach($Settings["Connections"] as $ID => $NodeID)
474
+            /* Attraction vectors */
475
+            if ( isset($Settings["Connections"]) )
478 476
             {
479
-             if ( isset($this->Data[$NodeID]) )
480
-              {
481
-               $X2 = $this->Data[$NodeID]["X"];
482
-               $Y2 = $this->Data[$NodeID]["Y"];
483
-               $FreeZone = $this->Data[$Key2]["FreeZone"];
477
+            foreach($Settings["Connections"] as $ID => $NodeID)
478
+            {
479
+                if ( isset($this->Data[$NodeID]) )
480
+                {
481
+                $X2 = $this->Data[$NodeID]["X"];
482
+                $Y2 = $this->Data[$NodeID]["Y"];
483
+                $FreeZone = $this->Data[$Key2]["FreeZone"];
484 484
 
485
-               $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
486
-               $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2);
485
+                $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
486
+                $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2);
487 487
 
488
-               if ( $Distance > $FreeZone )
488
+                if ( $Distance > $FreeZone )
489 489
                 $Force = log(($Distance-$FreeZone)+1);
490
-               else
490
+                else
491 491
                 { $Force = log(($FreeZone-$Distance)+1); ($Angle = $Angle + 180); }
492 492
 
493
-               if ( $Force > 1 )
493
+                if ( $Force > 1 )
494 494
                 $this->Data[$Key]["Vectors"][] = array("Type"=>"A","Angle"=>$Angle % 360,"Force"=>$Force);
495
-              }
495
+                }
496
+            }
496 497
             }
497
-          }
498 498
         }
499
-      }
499
+        }
500 500
 
501
-     /* Move the nodes accoding to the vectors */
502
-     foreach($this->Data as $Key => $Settings)
503
-      {
504
-       $X = $Settings["X"];
505
-       $Y = $Settings["Y"];
501
+        /* Move the nodes accoding to the vectors */
502
+        foreach($this->Data as $Key => $Settings)
503
+        {
504
+        $X = $Settings["X"];
505
+        $Y = $Settings["Y"];
506 506
 
507
-       if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
507
+        if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
508 508
         {
509
-         foreach($Settings["Vectors"] as $ID => $Vector)
510
-          {
511
-           $Type  = $Vector["Type"];
512
-           $Force = $Vector["Force"];
513
-           $Angle = $Vector["Angle"];
514
-           $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
509
+            foreach($Settings["Vectors"] as $ID => $Vector)
510
+            {
511
+            $Type  = $Vector["Type"];
512
+            $Force = $Vector["Force"];
513
+            $Angle = $Vector["Angle"];
514
+            $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
515 515
 
516
-           $X = cos(deg2rad($Angle)) * $Force * $Factor + $X;
517
-           $Y = sin(deg2rad($Angle)) * $Force * $Factor + $Y;
518
-          }
516
+            $X = cos(deg2rad($Angle)) * $Force * $Factor + $X;
517
+            $Y = sin(deg2rad($Angle)) * $Force * $Factor + $Y;
518
+            }
519 519
         }
520 520
 
521
-       $this->Data[$Key]["X"] = $X;
522
-       $this->Data[$Key]["Y"] = $Y;
523
-      }
521
+        $this->Data[$Key]["X"] = $X;
522
+        $this->Data[$Key]["Y"] = $Y;
523
+        }
524 524
     }
525 525
 
526
-   function lastPass()
526
+    function lastPass()
527 527
     {
528
-     /* Put everything inside the graph area */
529
-     foreach($this->Data as $Key => $Settings)
530
-      {
531
-       $X = $Settings["X"];
532
-       $Y = $Settings["Y"];
533
-
534
-       if ( $X < $this->X1 ) { $X = $this->X1; }
535
-       if ( $X > $this->X2 ) { $X = $this->X2; }
536
-       if ( $Y < $this->Y1 ) { $Y = $this->Y1; }
537
-       if ( $Y > $this->Y2 ) { $Y = $this->Y2; }
538
-
539
-       $this->Data[$Key]["X"] = $X;
540
-       $this->Data[$Key]["Y"] = $Y;
541
-      }
542
-
543
-     /* Dump all links */
544
-     $Links = "";
545
-     foreach($this->Data as $Key => $Settings)
546
-      {
547
-       $X1 = $Settings["X"];
548
-       $Y1 = $Settings["Y"];
549
-
550
-       if ( isset($Settings["Connections"]) )
551
-        {
552
-         foreach ($Settings["Connections"] as $ID => $NodeID)
553
-          {
554
-           if ( isset($this->Data[$NodeID]) )
528
+        /* Put everything inside the graph area */
529
+        foreach($this->Data as $Key => $Settings)
530
+        {
531
+        $X = $Settings["X"];
532
+        $Y = $Settings["Y"];
533
+
534
+        if ( $X < $this->X1 ) { $X = $this->X1; }
535
+        if ( $X > $this->X2 ) { $X = $this->X2; }
536
+        if ( $Y < $this->Y1 ) { $Y = $this->Y1; }
537
+        if ( $Y > $this->Y2 ) { $Y = $this->Y2; }
538
+
539
+        $this->Data[$Key]["X"] = $X;
540
+        $this->Data[$Key]["Y"] = $Y;
541
+        }
542
+
543
+        /* Dump all links */
544
+        $Links = "";
545
+        foreach($this->Data as $Key => $Settings)
546
+        {
547
+        $X1 = $Settings["X"];
548
+        $Y1 = $Settings["Y"];
549
+
550
+        if ( isset($Settings["Connections"]) )
551
+        {
552
+            foreach ($Settings["Connections"] as $ID => $NodeID)
553
+            {
554
+            if ( isset($this->Data[$NodeID]) )
555 555
             {
556
-             $X2 = $this->Data[$NodeID]["X"];
557
-             $Y2 = $this->Data[$NodeID]["Y"];
556
+                $X2 = $this->Data[$NodeID]["X"];
557
+                $Y2 = $this->Data[$NodeID]["Y"];
558 558
 
559
-             $Links[] = array("X1"=>$X1,"Y1"=>$Y1,"X2"=>$X2,"Y2"=>$Y2,"Source"=>$Settings["Name"],"Destination"=>$this->Data[$NodeID]["Name"]);
559
+                $Links[] = array("X1"=>$X1,"Y1"=>$Y1,"X2"=>$X2,"Y2"=>$Y2,"Source"=>$Settings["Name"],"Destination"=>$this->Data[$NodeID]["Name"]);
560 560
             }
561
-          }
561
+            }
562
+        }
562 563
         }
563
-      }
564 564
 
565
-     /* Check collisions */
566
-     $Conflicts = 0;
567
-     foreach($this->Data as $Key => $Settings)
568
-      {
569
-       $X1 = $Settings["X"];
570
-       $Y1 = $Settings["Y"];
565
+        /* Check collisions */
566
+        $Conflicts = 0;
567
+        foreach($this->Data as $Key => $Settings)
568
+        {
569
+        $X1 = $Settings["X"];
570
+        $Y1 = $Settings["Y"];
571 571
 
572
-       if ( isset($Settings["Connections"]) )
572
+        if ( isset($Settings["Connections"]) )
573 573
         {
574
-         foreach ($Settings["Connections"] as $ID => $NodeID)
575
-          {
576
-           if ( isset($this->Data[$NodeID]) )
574
+            foreach ($Settings["Connections"] as $ID => $NodeID)
575
+            {
576
+            if ( isset($this->Data[$NodeID]) )
577 577
             {
578
-             $X2 = $this->Data[$NodeID]["X"];
579
-             $Y2 = $this->Data[$NodeID]["Y"];
578
+                $X2 = $this->Data[$NodeID]["X"];
579
+                $Y2 = $this->Data[$NodeID]["Y"];
580 580
 
581
-             foreach($Links as $IDLinks => $Link)
582
-              {
583
-               $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"];
581
+                foreach($Links as $IDLinks => $Link)
582
+                {
583
+                $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"];
584 584
 
585
-               if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) )
585
+                if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) )
586 586
                 {
587
-                 if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) )
588
-                  {
589
-                   if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] )
587
+                    if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) )
588
+                    {
589
+                    if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] )
590 590
                     { $Conflicts++; }
591
-                  }
591
+                    }
592
+                }
592 593
                 }
593
-              }
594 594
             }
595
-          }
595
+            }
596
+        }
596 597
         }
597
-      }
598
-     return($Conflicts/2);
598
+        return($Conflicts/2);
599 599
     }
600 600
 
601
-   /* Center the graph */
602
-   function center()
601
+    /* Center the graph */
602
+    function center()
603 603
     {
604
-     /* Determine the real center */
605
-     $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
606
-     $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
607
-
608
-     /* Get current boundaries */
609
-     $XMin = $this->X2; $XMax = $this->X1;
610
-     $YMin = $this->Y2; $YMax = $this->Y1;
611
-     foreach($this->Data as $Key => $Settings)
612
-      {
613
-       $X = $Settings["X"];
614
-       $Y = $Settings["Y"];
615
-
616
-       if ( $X < $XMin) { $XMin = $X; }
617
-       if ( $X > $XMax) { $XMax = $X; }
618
-       if ( $Y < $YMin) { $YMin = $Y; }
619
-       if ( $Y > $YMax) { $YMax = $Y; }
620
-      }
621
-     $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
622
-     $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;
623
-
624
-     /* Compute the offset to apply */
625
-     $XOffset = $TargetCenterX - $CurrentCenterX;
626
-     $YOffset = $TargetCenterY - $CurrentCenterY;
627
-
628
-     /* Correct the points position */
629
-     foreach($this->Data as $Key => $Settings)
630
-      {
631
-       $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
632
-       $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
633
-      }
634
-    }
604
+        /* Determine the real center */
605
+        $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
606
+        $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
607
+
608
+        /* Get current boundaries */
609
+        $XMin = $this->X2; $XMax = $this->X1;
610
+        $YMin = $this->Y2; $YMax = $this->Y1;
611
+        foreach($this->Data as $Key => $Settings)
612
+        {
613
+        $X = $Settings["X"];
614
+        $Y = $Settings["Y"];
635 615
 
636
-   /* Create the encoded string */
637
-   function drawSpring($Object,$Settings="")
638
-    {
639
-     $this->pChartObject = $Object;
616
+        if ( $X < $XMin) { $XMin = $X; }
617
+        if ( $X > $XMax) { $XMax = $X; }
618
+        if ( $Y < $YMin) { $YMin = $Y; }
619
+        if ( $Y > $YMax) { $YMax = $Y; }
620
+        }
621
+        $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
622
+        $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;
640 623
 
641
-     $Pass			= isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
642
-     $Retries			= isset($Settings["Retry"]) ? $Settings["Retry"] : 10;
643
-     $this->MagneticForceA	= isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5;
644
-     $this->MagneticForceR	= isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2;
645
-     $this->RingSize		= isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
646
-     $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE;
647
-     $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
648
-     $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE;
649
-     $TextPadding		= isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4;
650
-     $Algorithm			= isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
624
+        /* Compute the offset to apply */
625
+        $XOffset = $TargetCenterX - $CurrentCenterX;
626
+        $YOffset = $TargetCenterY - $CurrentCenterY;
651 627
 
652
-     $FontSize		= $Object->FontSize;
653
-     $this->X1		= $Object->GraphAreaX1;
654
-     $this->Y1		= $Object->GraphAreaY1;
655
-     $this->X2		= $Object->GraphAreaX2;
656
-     $this->Y2		= $Object->GraphAreaY2;
628
+        /* Correct the points position */
629
+        foreach($this->Data as $Key => $Settings)
630
+        {
631
+        $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
632
+        $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
633
+        }
634
+    }
657 635
 
658
-     $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1;
659
-     while ($Conflicts != 0 && $Jobs < $Retries )
660
-      {
661
-       $Jobs++;
636
+    /* Create the encoded string */
637
+    function drawSpring($Object,$Settings="")
638
+    {
639
+        $this->pChartObject = $Object;
640
+
641
+        $Pass			= isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
642
+        $Retries			= isset($Settings["Retry"]) ? $Settings["Retry"] : 10;
643
+        $this->MagneticForceA	= isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5;
644
+        $this->MagneticForceR	= isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2;
645
+        $this->RingSize		= isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
646
+        $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE;
647
+        $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
648
+        $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE;
649
+        $TextPadding		= isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4;
650
+        $Algorithm			= isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
651
+
652
+        $FontSize		= $Object->FontSize;
653
+        $this->X1		= $Object->GraphAreaX1;
654
+        $this->Y1		= $Object->GraphAreaY1;
655
+        $this->X2		= $Object->GraphAreaX2;
656
+        $this->Y2		= $Object->GraphAreaY2;
657
+
658
+        $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1;
659
+        while ($Conflicts != 0 && $Jobs < $Retries )
660
+        {
661
+        $Jobs++;
662 662
 
663
-       /* Compute the initial settings */
664
-       $this->firstPass($Algorithm);
663
+        /* Compute the initial settings */
664
+        $this->firstPass($Algorithm);
665 665
 
666
-       /* Apply the vectors */
667
-       if ( $Pass > 0 ) 
666
+        /* Apply the vectors */
667
+        if ( $Pass > 0 ) 
668 668
         {
669
-         for ($i=0; $i<=$Pass; $i++) { $this->doPass(); }
669
+            for ($i=0; $i<=$Pass; $i++) { $this->doPass(); }
670 670
         }
671 671
 
672
-       $Conflicts = $this->lastPass();
673
-       if ( $this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"] )
672
+        $Conflicts = $this->lastPass();
673
+        if ( $this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"] )
674 674
         { $this->History["MinimumConflicts"] = $Conflicts; $this->History["Result"] = $this->Data; }
675
-      }
675
+        }
676 676
 
677
-     $Conflicts  = $this->History["MinimumConflicts"];
678
-     $this->Data = $this->History["Result"];
677
+        $Conflicts  = $this->History["MinimumConflicts"];
678
+        $this->Data = $this->History["Result"];
679 679
 
680
-     if ( $CenterGraph ) { $this->center(); }
680
+        if ( $CenterGraph ) { $this->center(); }
681 681
 
682
-     /* Draw the connections */
683
-     $Drawn = "";
684
-     foreach($this->Data as $Key => $Settings)
685
-      {
686
-       $X	= $Settings["X"];
687
-       $Y	= $Settings["Y"];
682
+        /* Draw the connections */
683
+        $Drawn = "";
684
+        foreach($this->Data as $Key => $Settings)
685
+        {
686
+        $X	= $Settings["X"];
687
+        $Y	= $Settings["Y"];
688 688
 
689
-       if ( isset($Settings["Connections"]) )
689
+        if ( isset($Settings["Connections"]) )
690 690
         {
691
-         foreach ($Settings["Connections"] as $ID => $NodeID)
692
-          {
693
-           if ( !isset($Drawn[$Key]) )    { $Drawn[$Key] = ""; }
694
-           if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; }
691
+            foreach ($Settings["Connections"] as $ID => $NodeID)
692
+            {
693
+            if ( !isset($Drawn[$Key]) )    { $Drawn[$Key] = ""; }
694
+            if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; }
695 695
 
696
-           if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) )
696
+            if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) )
697 697
             {
698
-             $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]);
698
+                $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]);
699 699
 
700
-             if ( $this->Links != "" )
701
-              {
702
-               if ( isset($this->Links[$Key][$NodeID]["R"]) )
700
+                if ( $this->Links != "" )
701
+                {
702
+                if ( isset($this->Links[$Key][$NodeID]["R"]) )
703 703
                 { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"],"G"=>$this->Links[$Key][$NodeID]["G"],"B"=>$this->Links[$Key][$NodeID]["B"],"Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); }
704 704
 
705
-               if ( isset($this->Links[$Key][$NodeID]["Ticks"]) )
706
-                 { $Color["Ticks"] = $this->Links[$Key][$NodeID]["Ticks"]; }
707
-              }
705
+                if ( isset($this->Links[$Key][$NodeID]["Ticks"]) )
706
+                    { $Color["Ticks"] = $this->Links[$Key][$NodeID]["Ticks"]; }
707
+                }
708 708
 
709
-             $X2 = $this->Data[$NodeID]["X"];
710
-             $Y2 = $this->Data[$NodeID]["Y"];
711
-             $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
712
-             $Drawn[$Key][$NodeID] = TRUE;
709
+                $X2 = $this->Data[$NodeID]["X"];
710
+                $Y2 = $this->Data[$NodeID]["Y"];
711
+                $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
712
+                $Drawn[$Key][$NodeID] = TRUE;
713 713
 
714
-             if ( isset($this->Links) && $this->Links != "" )
715
-              {
716
-               if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) )
714
+                if ( isset($this->Links) && $this->Links != "" )
715
+                {
716
+                if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) )
717 717
                 {
718
-                 $Name  = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"];
719
-                 $TxtX  = ($X2 - $X)/2 + $X;
720
-                 $TxtY  = ($Y2 - $Y)/2 + $Y;
721
-
722
-                 if ( $X <= $X2 )
723
-                  $Angle = (360-$this->getAngle($X,$Y,$X2,$Y2)) % 360;
724
-                 else
725
-                  $Angle = (360-$this->getAngle($X2,$Y2,$X,$Y)) % 360;
726
-
727
-                 $Settings          = $Color;
728
-                 $Settings["Angle"] = $Angle;
729
-                 $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
730
-                 $this->pChartObject->drawText($TxtX,$TxtY,$Name,$Settings);
718
+                    $Name  = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"];
719
+                    $TxtX  = ($X2 - $X)/2 + $X;
720
+                    $TxtY  = ($Y2 - $Y)/2 + $Y;
721
+
722
+                    if ( $X <= $X2 )
723
+                    $Angle = (360-$this->getAngle($X,$Y,$X2,$Y2)) % 360;
724
+                    else
725
+                    $Angle = (360-$this->getAngle($X2,$Y2,$X,$Y)) % 360;
726
+
727
+                    $Settings          = $Color;
728
+                    $Settings["Angle"] = $Angle;
729
+                    $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
730
+                    $this->pChartObject->drawText($TxtX,$TxtY,$Name,$Settings);
731 731
                 }
732
-              }
732
+                }
733
+            }
733 734
             }
734
-          }
735 735
         }
736
-      }
736
+        }
737 737
 
738
-     /* Draw the quiet zones */
739
-     if ( $DrawQuietZone )
740
-      {
741
-       foreach($this->Data as $Key => $Settings)
738
+        /* Draw the quiet zones */
739
+        if ( $DrawQuietZone )
740
+        {
741
+        foreach($this->Data as $Key => $Settings)
742 742
         {
743
-         $X	 = $Settings["X"];
744
-         $Y	 = $Settings["Y"];
745
-         $FreeZone = $Settings["FreeZone"];
743
+            $X	 = $Settings["X"];
744
+            $Y	 = $Settings["Y"];
745
+            $FreeZone = $Settings["FreeZone"];
746 746
 
747
-         $this->pChartObject->drawFilledCircle($X,$Y,$FreeZone,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>2));
747
+            $this->pChartObject->drawFilledCircle($X,$Y,$FreeZone,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>2));
748
+        }
748 749
         }
749
-      }
750 750
 
751 751
 
752
-     /* Draw the nodes */
753
-     foreach($this->Data as $Key => $Settings)
754
-      {
755
-       $X	 = $Settings["X"];
756
-       $Y	 = $Settings["Y"];
757
-       $Name	 = $Settings["Name"];
758
-       $FreeZone = $Settings["FreeZone"];
759
-       $Shape    = $Settings["Shape"];
760
-       $Size     = $Settings["Size"];
752
+        /* Draw the nodes */
753
+        foreach($this->Data as $Key => $Settings)
754
+        {
755
+        $X	 = $Settings["X"];
756
+        $Y	 = $Settings["Y"];
757
+        $Name	 = $Settings["Name"];
758
+        $FreeZone = $Settings["FreeZone"];
759
+        $Shape    = $Settings["Shape"];
760
+        $Size     = $Settings["Size"];
761 761
 
762
-       $Color	 = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]);
762
+        $Color	 = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]);
763 763
 
764
-       if ( $Shape == NODE_SHAPE_CIRCLE )
764
+        if ( $Shape == NODE_SHAPE_CIRCLE )
765 765
         {
766
-         $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color);
766
+            $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color);
767 767
         }
768
-       elseif ( $Shape == NODE_SHAPE_TRIANGLE )
768
+        elseif ( $Shape == NODE_SHAPE_TRIANGLE )
769 769
         {
770
-         $Points = "";
771
-         $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y;
772
-         $Points[] = cos(deg2rad(45)) * $Size + $X;  $Points[] = sin(deg2rad(45)) * $Size + $Y;
773
-         $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y;
774
-         $this->pChartObject->drawPolygon($Points,$Color);
770
+            $Points = "";
771
+            $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y;
772
+            $Points[] = cos(deg2rad(45)) * $Size + $X;  $Points[] = sin(deg2rad(45)) * $Size + $Y;
773
+            $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y;
774
+            $this->pChartObject->drawPolygon($Points,$Color);
775 775
         }
776
-       elseif ( $Shape == NODE_SHAPE_SQUARE )
776
+        elseif ( $Shape == NODE_SHAPE_SQUARE )
777 777
         {
778
-         $Offset = $Size/2; $Size = $Size / 2;
779
-         $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color);
778
+            $Offset = $Size/2; $Size = $Size / 2;
779
+            $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color);
780 780
         }
781 781
 
782
-       if ( $Name != "" )
782
+        if ( $Name != "" )
783 783
         {
784
-         $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]);
784
+            $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]);
785 785
 
786
-         if ( $this->Labels["Type"] == LABEL_LIGHT )
787
-          {
788
-           $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT;
789
-           $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions);
790
-          }
791
-         elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
792
-          {
793
-           $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794
-           $LabelOptions["DrawBox"]       = TRUE;
795
-           $LabelOptions["BoxAlpha"]      = 50;
796
-           $LabelOptions["BorderOffset"]  = 4;
797
-           $LabelOptions["RoundedRadius"] = 3;
798
-           $LabelOptions["BoxRounded"]    = TRUE;
799
-           $LabelOptions["NoShadow"]      = TRUE;
800
-
801
-           $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions);
802
-          }
786
+            if ( $this->Labels["Type"] == LABEL_LIGHT )
787
+            {
788
+            $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT;
789
+            $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions);
790
+            }
791
+            elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
792
+            {
793
+            $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794
+            $LabelOptions["DrawBox"]       = TRUE;
795
+            $LabelOptions["BoxAlpha"]      = 50;
796
+            $LabelOptions["BorderOffset"]  = 4;
797
+            $LabelOptions["RoundedRadius"] = 3;
798
+            $LabelOptions["BoxRounded"]    = TRUE;
799
+            $LabelOptions["NoShadow"]      = TRUE;
800
+
801
+            $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions);
802
+            }
803
+        }
803 804
         }
804
-      }
805 805
 
806
-     /* Draw the vectors */
807
-     if ( $DrawVectors )
808
-      {
809
-       foreach($this->Data as $Key => $Settings)
806
+        /* Draw the vectors */
807
+        if ( $DrawVectors )
810 808
         {
811
-         $X1 = $Settings["X"];
812
-         $Y1 = $Settings["Y"];
809
+        foreach($this->Data as $Key => $Settings)
810
+        {
811
+            $X1 = $Settings["X"];
812
+            $Y1 = $Settings["Y"];
813 813
 
814
-         if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
815
-          {
816
-           foreach($Settings["Vectors"] as $ID => $Vector)
814
+            if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
815
+            {
816
+            foreach($Settings["Vectors"] as $ID => $Vector)
817 817
             {
818
-             $Type  = $Vector["Type"];
819
-             $Force = $Vector["Force"];
820
-             $Angle = $Vector["Angle"];
821
-             $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
822
-             $Color  = $Type == "A" ? array("FillR"=>255,"FillG"=>0,"FillB"=>0) : array("FillR"=>0,"FillG"=>255,"FillB"=>0);
818
+                $Type  = $Vector["Type"];
819
+                $Force = $Vector["Force"];
820
+                $Angle = $Vector["Angle"];
821
+                $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
822
+                $Color  = $Type == "A" ? array("FillR"=>255,"FillG"=>0,"FillB"=>0) : array("FillR"=>0,"FillG"=>255,"FillB"=>0);
823 823
 
824
-             $X2 = cos(deg2rad($Angle)) * $Force * $Factor + $X1;
825
-             $Y2 = sin(deg2rad($Angle)) * $Force * $Factor + $Y1;
824
+                $X2 = cos(deg2rad($Angle)) * $Force * $Factor + $X1;
825
+                $Y2 = sin(deg2rad($Angle)) * $Force * $Factor + $Y1;
826 826
 
827
-             $this->pChartObject->drawArrow($X1,$Y1,$X2,$Y2,$Color);
827
+                $this->pChartObject->drawArrow($X1,$Y1,$X2,$Y2,$Color);
828 828
             }
829
-          }
829
+            }
830
+        }
830 831
         }
831
-      }
832 832
 
833
-     return(array("Pass"=>$Jobs,"Conflicts"=>$Conflicts));
833
+        return(array("Pass"=>$Jobs,"Conflicts"=>$Conflicts));
834 834
     }
835 835
 
836
-   /* Return the distance between two points */
837
-   function getDistance($X1,$Y1,$X2,$Y2)
836
+    /* Return the distance between two points */
837
+    function getDistance($X1,$Y1,$X2,$Y2)
838 838
     { return (sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1))); }
839 839
 
840
-   /* Return the angle made by a line and the X axis */
841
-   function getAngle($X1,$Y1,$X2,$Y2)
840
+    /* Return the angle made by a line and the X axis */
841
+    function getAngle($X1,$Y1,$X2,$Y2)
842 842
     {
843
-     $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent));
844
-     if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); }
843
+        $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent));
844
+        if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); }
845 845
     }
846 846
 
847
-   function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4)
847
+    function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4)
848 848
     {
849
-     $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850
-     $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
849
+        $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850
+        $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
851 851
 
852
-     if ( $B == 0 ) { return(FALSE); }
853
-     $Xi = $A / $B;
852
+        if ( $B == 0 ) { return(FALSE); }
853
+        $Xi = $A / $B;
854 854
 
855
-     $C = ($X1 - $X2);
856
-     if ( $C == 0 ) { return(FALSE); }
857
-     $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
855
+        $C = ($X1 - $X2);
856
+        if ( $C == 0 ) { return(FALSE); }
857
+        $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
858 858
 
859
-     if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
860
-      {
861
-       if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
859
+        if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
860
+        {
861
+        if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
862 862
         { return(TRUE); }
863
-      }
863
+        }
864 864
 
865
-      return(FALSE);   
865
+        return(FALSE);   
866
+    }
866 867
     }
867
-  }
868 868
 ?>
869 869
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@  discard block
 block discarded – undo
13 13
      You can find the whole class documentation on the pChart web site.
14 14
  */
15 15
 
16
- define("NODE_TYPE_FREE"	, 690001);
17
- define("NODE_TYPE_CENTRAL"	, 690002);
16
+ define("NODE_TYPE_FREE", 690001);
17
+ define("NODE_TYPE_CENTRAL", 690002);
18 18
 
19
- define("NODE_SHAPE_CIRCLE"	, 690011);
20
- define("NODE_SHAPE_TRIANGLE"	, 690012);
21
- define("NODE_SHAPE_SQUARE"	, 690013);
19
+ define("NODE_SHAPE_CIRCLE", 690011);
20
+ define("NODE_SHAPE_TRIANGLE", 690012);
21
+ define("NODE_SHAPE_SQUARE", 690013);
22 22
 
23
- define("ALGORITHM_RANDOM"	, 690021);
24
- define("ALGORITHM_WEIGHTED"	, 690022);
25
- define("ALGORITHM_CIRCULAR"	, 690023);
26
- define("ALGORITHM_CENTRAL"	, 690024);
23
+ define("ALGORITHM_RANDOM", 690021);
24
+ define("ALGORITHM_WEIGHTED", 690022);
25
+ define("ALGORITHM_CIRCULAR", 690023);
26
+ define("ALGORITHM_CENTRAL", 690024);
27 27
 
28
- define("LABEL_CLASSIC"		, 690031);
29
- define("LABEL_LIGHT"		, 690032);
28
+ define("LABEL_CLASSIC", 690031);
29
+ define("LABEL_LIGHT", 690032);
30 30
 
31 31
  /* pSpring class definition */
32 32
  class pSpring
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      $this->Default["R"]		= 255;
54 54
      $this->Default["G"]		= 255;
55 55
      $this->Default["B"]		= 255;
56
-     $this->Default["Alpha"]		= 100;
56
+     $this->Default["Alpha"] = 100;
57 57
      $this->Default["BorderR"]		= 0;
58 58
      $this->Default["BorderG"]		= 0;
59 59
      $this->Default["BorderB"]		= 0;
@@ -62,52 +62,52 @@  discard block
 block discarded – undo
62 62
      $this->Default["BackgroundR"]	= 255;
63 63
      $this->Default["BackgroundG"]	= 255;
64 64
      $this->Default["BackgroundB"]	= 255;
65
-     $this->Default["BackgroundAlpha"]	= 0;
65
+     $this->Default["BackgroundAlpha"] = 0;
66 66
      $this->Default["Force"]		= 1;
67 67
      $this->Default["NodeType"]		= NODE_TYPE_FREE;
68
-     $this->Default["Size"]		= 5;
68
+     $this->Default["Size"] = 5;
69 69
      $this->Default["Shape"]		= NODE_SHAPE_CIRCLE;
70 70
      $this->Default["FreeZone"]		= 40;
71 71
      $this->Default["LinkR"]		= 0;
72 72
      $this->Default["LinkG"]		= 0;
73 73
      $this->Default["LinkB"]		= 0;
74
-     $this->Default["LinkAlpha"]	= 0;
74
+     $this->Default["LinkAlpha"] = 0;
75 75
 
76
-     $this->Labels["Type"]		= LABEL_CLASSIC;
76
+     $this->Labels["Type"] = LABEL_CLASSIC;
77 77
      $this->Labels["R"]			= 0;
78 78
      $this->Labels["G"]			= 0;
79 79
      $this->Labels["B"]			= 0;
80
-     $this->Labels["Alpha"]		= 100;
80
+     $this->Labels["Alpha"] = 100;
81 81
 
82
-     $this->AutoComputeFreeZone         = FALSE;
82
+     $this->AutoComputeFreeZone = FALSE;
83 83
     }
84 84
 
85 85
    /* Set default links options */
86
-   function setLinkDefaults($Settings="")
86
+   function setLinkDefaults($Settings = "")
87 87
     {
88
-     if ( isset($Settings["R"]) )     { $this->Default["LinkR"] = $Settings["R"]; }
89
-     if ( isset($Settings["G"]) )     { $this->Default["LinkG"] = $Settings["G"]; }
90
-     if ( isset($Settings["B"]) )     { $this->Default["LinkB"] = $Settings["B"]; }
91
-     if ( isset($Settings["Alpha"]) ) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; }
88
+     if (isset($Settings["R"])) { $this->Default["LinkR"] = $Settings["R"]; }
89
+     if (isset($Settings["G"])) { $this->Default["LinkG"] = $Settings["G"]; }
90
+     if (isset($Settings["B"])) { $this->Default["LinkB"] = $Settings["B"]; }
91
+     if (isset($Settings["Alpha"])) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; }
92 92
     }
93 93
 
94 94
    /* Set default links options */
95
-   function setLabelsSettings($Settings="")
95
+   function setLabelsSettings($Settings = "")
96 96
     {
97
-     if ( isset($Settings["Type"]) )  { $this->Labels["Type"] = $Settings["Type"]; }
98
-     if ( isset($Settings["R"]) )     { $this->Labels["R"] = $Settings["R"]; }
99
-     if ( isset($Settings["G"]) )     { $this->Labels["G"] = $Settings["G"]; }
100
-     if ( isset($Settings["B"]) )     { $this->Labels["B"] = $Settings["B"]; }
101
-     if ( isset($Settings["Alpha"]) ) { $this->Labels["Alpha"] = $Settings["Alpha"]; }
97
+     if (isset($Settings["Type"])) { $this->Labels["Type"] = $Settings["Type"]; }
98
+     if (isset($Settings["R"])) { $this->Labels["R"] = $Settings["R"]; }
99
+     if (isset($Settings["G"])) { $this->Labels["G"] = $Settings["G"]; }
100
+     if (isset($Settings["B"])) { $this->Labels["B"] = $Settings["B"]; }
101
+     if (isset($Settings["Alpha"])) { $this->Labels["Alpha"] = $Settings["Alpha"]; }
102 102
     }
103 103
 
104 104
    /* Auto compute the FreeZone size based on the number of connections */
105 105
    function autoFreeZone()
106 106
     {
107 107
      /* Check connections reciprocity */
108
-     foreach($this->Data as $Key => $Settings)
108
+     foreach ($this->Data as $Key => $Settings)
109 109
       {
110
-       if ( isset($Settings["Connections"]) )
110
+       if (isset($Settings["Connections"]))
111 111
         { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; }
112 112
        else
113 113
         { $this->Data[$Key]["FreeZone"] = 20; }
@@ -116,60 +116,60 @@  discard block
 block discarded – undo
116 116
     }
117 117
 
118 118
    /* Set link properties */
119
-   function linkProperties($FromNode,$ToNode,$Settings)
119
+   function linkProperties($FromNode, $ToNode, $Settings)
120 120
     {
121
-     if ( !isset($this->Data[$FromNode]) ) { return(0); }
122
-     if ( !isset($this->Data[$ToNode]) )   { return(0); }
121
+     if (!isset($this->Data[$FromNode])) { return(0); }
122
+     if (!isset($this->Data[$ToNode])) { return(0); }
123 123
 
124 124
      $R			= isset($Settings["R"]) ? $Settings["R"] : 0;
125 125
      $G			= isset($Settings["G"]) ? $Settings["G"] : 0;
126 126
      $B			= isset($Settings["B"]) ? $Settings["B"] : 0;
127 127
      $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100;
128
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : NULL;
128
+     $Name = isset($Settings["Name"]) ? $Settings["Name"] : NULL;
129 129
      $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL;
130 130
 
131
-     $this->Links[$FromNode][$ToNode]["R"] = $R;         $this->Links[$ToNode][$FromNode]["R"] = $R;
132
-     $this->Links[$FromNode][$ToNode]["G"] = $G;         $this->Links[$ToNode][$FromNode]["G"] = $G;
133
-     $this->Links[$FromNode][$ToNode]["B"] = $B;         $this->Links[$ToNode][$FromNode]["B"] = $B;
131
+     $this->Links[$FromNode][$ToNode]["R"] = $R; $this->Links[$ToNode][$FromNode]["R"] = $R;
132
+     $this->Links[$FromNode][$ToNode]["G"] = $G; $this->Links[$ToNode][$FromNode]["G"] = $G;
133
+     $this->Links[$FromNode][$ToNode]["B"] = $B; $this->Links[$ToNode][$FromNode]["B"] = $B;
134 134
      $this->Links[$FromNode][$ToNode]["Alpha"] = $Alpha; $this->Links[$ToNode][$FromNode]["Alpha"] = $Alpha;
135
-     $this->Links[$FromNode][$ToNode]["Name"] = $Name;   $this->Links[$ToNode][$FromNode]["Name"] = $Name;
135
+     $this->Links[$FromNode][$ToNode]["Name"] = $Name; $this->Links[$ToNode][$FromNode]["Name"] = $Name;
136 136
      $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks;
137 137
     }
138 138
 
139
-   function setNodeDefaults($Settings="")
139
+   function setNodeDefaults($Settings = "")
140 140
     {
141
-     if ( isset($Settings["R"]) ) { $this->Default["R"]					= $Settings["R"]; }
142
-     if ( isset($Settings["G"]) ) { $this->Default["G"]					= $Settings["G"]; }
143
-     if ( isset($Settings["B"]) ) { $this->Default["B"]					= $Settings["B"]; }
144
-     if ( isset($Settings["Alpha"]) ) { $this->Default["Alpha"]				= $Settings["Alpha"]; }
145
-     if ( isset($Settings["BorderR"]) ) { $this->Default["BorderR"]			= $Settings["BorderR"]; }
146
-     if ( isset($Settings["BorderG"]) ) { $this->Default["BorderG"]			= $Settings["BorderG"]; }
147
-     if ( isset($Settings["BorderB"]) ) { $this->Default["BorderB"]			= $Settings["BorderB"]; }
148
-     if ( isset($Settings["BorderAlpha"]) ) { $this->Default["BorderAlpha"]		= $Settings["BorderAlpha"]; }
149
-     if ( isset($Settings["Surrounding"]) ) { $this->Default["Surrounding"]		= $Settings["Surrounding"]; }
150
-     if ( isset($Settings["BackgroundR"]) ) { $this->Default["BackgroundR"]		= $Settings["BackgroundR"]; }
151
-     if ( isset($Settings["BackgroundG"]) ) { $this->Default["BackgroundG"]		= $Settings["BackgroundG"]; }
152
-     if ( isset($Settings["BackgroundB"]) ) { $this->Default["BackgroundB"]		= $Settings["BackgroundB"]; }
153
-     if ( isset($Settings["BackgroundAlpha"]) ) { $this->Default["BackgroundAlpha"]	= $Settings["BackgroundAlpha"]; }
154
-     if ( isset($Settings["NodeType"]) ) { $this->Default["NodeType"]			= $Settings["NodeType"]; }
155
-     if ( isset($Settings["Size"]) ) { $this->Default["Size"]				= $Settings["Size"]; }
156
-     if ( isset($Settings["Shape"]) ) { $this->Default["Shape"]				= $Settings["Shape"]; }
157
-     if ( isset($Settings["FreeZone"]) ) { $this->Default["FreeZone"]			= $Settings["FreeZone"]; }
141
+     if (isset($Settings["R"])) { $this->Default["R"]					= $Settings["R"]; }
142
+     if (isset($Settings["G"])) { $this->Default["G"]					= $Settings["G"]; }
143
+     if (isset($Settings["B"])) { $this->Default["B"]					= $Settings["B"]; }
144
+     if (isset($Settings["Alpha"])) { $this->Default["Alpha"] = $Settings["Alpha"]; }
145
+     if (isset($Settings["BorderR"])) { $this->Default["BorderR"]			= $Settings["BorderR"]; }
146
+     if (isset($Settings["BorderG"])) { $this->Default["BorderG"]			= $Settings["BorderG"]; }
147
+     if (isset($Settings["BorderB"])) { $this->Default["BorderB"]			= $Settings["BorderB"]; }
148
+     if (isset($Settings["BorderAlpha"])) { $this->Default["BorderAlpha"]		= $Settings["BorderAlpha"]; }
149
+     if (isset($Settings["Surrounding"])) { $this->Default["Surrounding"]		= $Settings["Surrounding"]; }
150
+     if (isset($Settings["BackgroundR"])) { $this->Default["BackgroundR"]		= $Settings["BackgroundR"]; }
151
+     if (isset($Settings["BackgroundG"])) { $this->Default["BackgroundG"]		= $Settings["BackgroundG"]; }
152
+     if (isset($Settings["BackgroundB"])) { $this->Default["BackgroundB"]		= $Settings["BackgroundB"]; }
153
+     if (isset($Settings["BackgroundAlpha"])) { $this->Default["BackgroundAlpha"] = $Settings["BackgroundAlpha"]; }
154
+     if (isset($Settings["NodeType"])) { $this->Default["NodeType"]			= $Settings["NodeType"]; }
155
+     if (isset($Settings["Size"])) { $this->Default["Size"] = $Settings["Size"]; }
156
+     if (isset($Settings["Shape"])) { $this->Default["Shape"] = $Settings["Shape"]; }
157
+     if (isset($Settings["FreeZone"])) { $this->Default["FreeZone"]			= $Settings["FreeZone"]; }
158 158
     }
159 159
 
160 160
    /* Add a node */
161
-   function addNode($NodeID,$Settings="")
161
+   function addNode($NodeID, $Settings = "")
162 162
     {
163 163
      /* if the node already exists, ignore */
164 164
      if (isset($this->Data[$NodeID])) { return(0); }
165 165
 
166
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
-     $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
166
+     $Name = isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
+     $Connections = isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
168 168
 
169 169
      $R			= isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
170 170
      $G			= isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
171 171
      $B			= isset($Settings["B"]) ? $Settings["B"] : $this->Default["B"];
172
-     $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
172
+     $Alpha = isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
173 173
      $BorderR		= isset($Settings["BorderR"]) ? $Settings["BorderR"] : $this->Default["BorderR"];
174 174
      $BorderG		= isset($Settings["BorderG"]) ? $Settings["BorderG"] : $this->Default["BorderG"];
175 175
      $BorderB		= isset($Settings["BorderB"]) ? $Settings["BorderB"] : $this->Default["BorderB"];
@@ -178,29 +178,29 @@  discard block
 block discarded – undo
178 178
      $BackgroundR	= isset($Settings["BackgroundR"]) ? $Settings["BackgroundR"] : $this->Default["BackgroundR"];
179 179
      $BackgroundG	= isset($Settings["BackgroundG"]) ? $Settings["BackgroundG"] : $this->Default["BackgroundG"];
180 180
      $BackgroundB	= isset($Settings["BackgroundB"]) ? $Settings["BackgroundB"] : $this->Default["BackgroundB"];
181
-     $BackgroundAlpha	= isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
182
-     $Force		= isset($Settings["Force"]) ? $Settings["Force"] :  $this->Default["Force"];
181
+     $BackgroundAlpha = isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
182
+     $Force		= isset($Settings["Force"]) ? $Settings["Force"] : $this->Default["Force"];
183 183
      $NodeType		= isset($Settings["NodeType"]) ? $Settings["NodeType"] : $this->Default["NodeType"];
184
-     $Size		= isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
184
+     $Size = isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
185 185
      $Shape		= isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
186 186
      $FreeZone		= isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
187 187
 
188
-     if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
188
+     if ($Surrounding != NULL) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
189 189
 
190 190
      $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha;
191 191
      $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
192
-     $this->Data[$NodeID]["BackgroundR"]	= $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
192
+     $this->Data[$NodeID]["BackgroundR"] = $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
193 193
      $this->Data[$NodeID]["Name"]		= $Name;
194 194
      $this->Data[$NodeID]["Force"]		= $Force;
195 195
      $this->Data[$NodeID]["Type"]		= $NodeType;
196 196
      $this->Data[$NodeID]["Size"]		= $Size;
197 197
      $this->Data[$NodeID]["Shape"]		= $Shape;
198
-     $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
-     if ( $Connections != NULL )
198
+     $this->Data[$NodeID]["FreeZone"] = $FreeZone;
199
+     if ($Connections != NULL)
200 200
       {
201
-       if ( is_array($Connections ) )
201
+       if (is_array($Connections))
202 202
         {
203
-         foreach($Connections as $Key => $Value)
203
+         foreach ($Connections as $Key => $Value)
204 204
           $this->Data[$NodeID]["Connections"][] = $Value;
205 205
         }
206 206
        else
@@ -209,37 +209,37 @@  discard block
 block discarded – undo
209 209
     }
210 210
 
211 211
    /* Set color attribute for a list of nodes */
212
-   function setNodesColor($Nodes,$Settings="")
212
+   function setNodesColor($Nodes, $Settings = "")
213 213
     {
214
-     if ( is_array($Nodes) )
214
+     if (is_array($Nodes))
215 215
       {
216 216
        foreach ($Nodes as $Key => $NodeID)
217 217
         {
218
-         if (isset($this->Data[$NodeID]) )
218
+         if (isset($this->Data[$NodeID]))
219 219
           {
220
-           if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221
-           if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222
-           if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
223
-           if ( isset($Settings["Alpha"]) ) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; }
224
-           if ( isset($Settings["BorderR"]) ) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; }
225
-           if ( isset($Settings["BorderG"]) ) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; }
226
-           if ( isset($Settings["BorderB"]) ) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; }
227
-           if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; }
228
-           if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
220
+           if (isset($Settings["R"])) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221
+           if (isset($Settings["G"])) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222
+           if (isset($Settings["B"])) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
223
+           if (isset($Settings["Alpha"])) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; }
224
+           if (isset($Settings["BorderR"])) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; }
225
+           if (isset($Settings["BorderG"])) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; }
226
+           if (isset($Settings["BorderB"])) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; }
227
+           if (isset($Settings["BorderAlpha"])) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; }
228
+           if (isset($Settings["Surrounding"])) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
229 229
           }
230 230
         }
231 231
       }
232 232
      else
233 233
       {
234
-       if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235
-       if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236
-       if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
237
-       if ( isset($Settings["Alpha"]) ) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; }
238
-       if ( isset($Settings["BorderR"]) ) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; }
239
-       if ( isset($Settings["BorderG"]) ) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; }
240
-       if ( isset($Settings["BorderB"]) ) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; }
241
-       if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; }
242
-       if ( isset($Settings["Surrounding"]) ) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
234
+       if (isset($Settings["R"])) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235
+       if (isset($Settings["G"])) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236
+       if (isset($Settings["B"])) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
237
+       if (isset($Settings["Alpha"])) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; }
238
+       if (isset($Settings["BorderR"])) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; }
239
+       if (isset($Settings["BorderG"])) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; }
240
+       if (isset($Settings["BorderB"])) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; }
241
+       if (isset($Settings["BorderAlpha"])) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; }
242
+       if (isset($Settings["Surrounding"])) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
243 243
       }
244 244
     }
245 245
 
@@ -250,22 +250,22 @@  discard block
 block discarded – undo
250 250
    /* Check if a connection exists and create it if required */
251 251
    function checkConnection($SourceID, $TargetID)
252 252
     {
253
-     if ( isset($this->Data[$SourceID]["Connections"]) )
253
+     if (isset($this->Data[$SourceID]["Connections"]))
254 254
       {
255 255
        foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
256
-        { if ( $TargetID == $ConnectionID ) { return(TRUE); } }
256
+        { if ($TargetID == $ConnectionID) { return(TRUE); } }
257 257
       }
258 258
      $this->Data[$SourceID]["Connections"][] = $TargetID;
259 259
     }
260 260
    /* Get the median linked nodes position */
261
-   function getMedianOffset($Key,$X,$Y)
261
+   function getMedianOffset($Key, $X, $Y)
262 262
     {
263 263
      $Cpt = 1;
264
-     if ( isset($this->Data[$Key]["Connections"]) )
264
+     if (isset($this->Data[$Key]["Connections"]))
265 265
       {
266
-       foreach($this->Data[$Key]["Connections"] as $ID => $NodeID)
266
+       foreach ($this->Data[$Key]["Connections"] as $ID => $NodeID)
267 267
         {
268
-         if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) )
268
+         if (isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]))
269 269
           {
270 270
            $X = $X + $this->Data[$NodeID]["X"];
271 271
            $Y = $Y + $this->Data[$NodeID]["Y"];
@@ -273,18 +273,18 @@  discard block
 block discarded – undo
273 273
           }
274 274
         }
275 275
       }
276
-     return(array("X"=>$X/$Cpt,"Y"=>$Y/$Cpt));
276
+     return(array("X"=>$X/$Cpt, "Y"=>$Y/$Cpt));
277 277
     }
278 278
 
279 279
    /* Return the ID of the attached partner with the biggest weight */
280 280
    function getBiggestPartner($Key)
281 281
     {
282
-     if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
282
+     if (!isset($this->Data[$Key]["Connections"])) { return(""); }
283 283
 
284 284
      $MaxWeight = 0; $Result = "";
285
-     foreach($this->Data[$Key]["Connections"] as $Key => $PeerID)
285
+     foreach ($this->Data[$Key]["Connections"] as $Key => $PeerID)
286 286
       {
287
-       if ( $this->Data[$PeerID]["Weight"] > $MaxWeight )
287
+       if ($this->Data[$PeerID]["Weight"] > $MaxWeight)
288 288
         { $MaxWeight = $this->Data[$PeerID]["Weight"]; $Result = $PeerID; }
289 289
       }
290 290
      return($Result);
@@ -293,94 +293,94 @@  discard block
 block discarded – undo
293 293
    /* Do the initial node positions computing pass */
294 294
    function firstPass($Algorithm)
295 295
     {
296
-     $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
297
-     $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
296
+     $CenterX = ($this->X2 - $this->X1)/2 + $this->X1;
297
+     $CenterY = ($this->Y2 - $this->Y1)/2 + $this->Y1;
298 298
 
299 299
      /* Check connections reciprocity */
300
-     foreach($this->Data as $Key => $Settings)
300
+     foreach ($this->Data as $Key => $Settings)
301 301
       {
302
-       if ( isset($Settings["Connections"]) )
302
+       if (isset($Settings["Connections"]))
303 303
         {
304
-         foreach($Settings["Connections"] as $ID => $ConnectionID)
305
-          $this->checkConnection($ConnectionID,$Key);
304
+         foreach ($Settings["Connections"] as $ID => $ConnectionID)
305
+          $this->checkConnection($ConnectionID, $Key);
306 306
         }
307 307
       }
308 308
 
309
-     if ( $this->AutoComputeFreeZone ) { $this->autoFreeZone(); }
309
+     if ($this->AutoComputeFreeZone) { $this->autoFreeZone(); }
310 310
 
311 311
      /* Get the max number of connections */
312 312
      $MaxConnections = 0;
313
-     foreach($this->Data as $Key => $Settings)
314
-      { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } }
313
+     foreach ($this->Data as $Key => $Settings)
314
+      { if (isset($Settings["Connections"])) { if ($MaxConnections < count($Settings["Connections"])) { $MaxConnections = count($Settings["Connections"]); } } }
315 315
 
316
-     if ( $Algorithm == ALGORITHM_WEIGHTED )
316
+     if ($Algorithm == ALGORITHM_WEIGHTED)
317 317
       {
318
-       foreach($this->Data as $Key => $Settings)
318
+       foreach ($this->Data as $Key => $Settings)
319 319
         {
320
-         if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
320
+         if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
+         if ($Settings["Type"] == NODE_TYPE_FREE)
322 322
           {
323
-           if ( isset($Settings["Connections"]) )
323
+           if (isset($Settings["Connections"]))
324 324
             { $Connections = count($Settings["Connections"]); }
325 325
            else
326 326
             { $Connections = 0; }
327 327
 
328 328
            $Ring  = $MaxConnections - $Connections;
329
-           $Angle = rand(0,360);
329
+           $Angle = rand(0, 360);
330 330
            
331
-           $this->Data[$Key]["X"] = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
332
-           $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
331
+           $this->Data[$Key]["X"] = cos(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterX;
332
+           $this->Data[$Key]["Y"] = sin(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterY;
333 333
           }
334 334
         }
335 335
       }
336
-     elseif ( $Algorithm == ALGORITHM_CENTRAL )
336
+     elseif ($Algorithm == ALGORITHM_CENTRAL)
337 337
       {
338 338
        /* Put a weight on each nodes */
339
-       foreach($this->Data as $Key => $Settings)
339
+       foreach ($this->Data as $Key => $Settings)
340 340
         {
341
-         if ( isset($Settings["Connections"]) )
341
+         if (isset($Settings["Connections"]))
342 342
           $this->Data[$Key]["Weight"] = count($Settings["Connections"]);
343 343
          else
344 344
           $this->Data[$Key]["Weight"] = 0;
345 345
         }
346 346
 
347 347
        $MaxConnections = $MaxConnections + 1;
348
-       for($i=$MaxConnections;$i>=0;$i--)
348
+       for ($i = $MaxConnections; $i >= 0; $i--)
349 349
         {
350
-         foreach($this->Data as $Key => $Settings)
350
+         foreach ($this->Data as $Key => $Settings)
351 351
           {
352
-           if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
352
+           if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
+           if ($Settings["Type"] == NODE_TYPE_FREE)
354 354
             {
355
-             if ( isset($Settings["Connections"]) )
355
+             if (isset($Settings["Connections"]))
356 356
               { $Connections = count($Settings["Connections"]); }
357 357
              else
358 358
               { $Connections = 0; }
359 359
 
360
-             if ( $Connections == $i )
360
+             if ($Connections == $i)
361 361
               {
362 362
                $BiggestPartner = $this->getBiggestPartner($Key);
363
-               if ( $BiggestPartner != "" )
363
+               if ($BiggestPartner != "")
364 364
                 {
365 365
                  $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366 366
                  $Weight        = $this->Data[$BiggestPartner]["Weight"];
367
-                 $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
367
+                 $AngleDivision = 360/$this->Data[$BiggestPartner]["Weight"];
368 368
                  $Done          = FALSE; $Tries = 0;
369 369
                  while (!$Done && $Tries <= $Weight*2)
370 370
                   {
371 371
                    $Tries++;
372
-                   $Angle = floor(rand(0,$Weight)*$AngleDivision);
373
-                   if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
372
+                   $Angle = floor(rand(0, $Weight)*$AngleDivision);
373
+                   if (!isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]))
374 374
                     {
375 375
                      $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376 376
                      $Done = TRUE; 
377 377
                     }
378 378
                   }
379
-                 if ( !$Done )
380
-                  { $Angle = rand(0,360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; }
379
+                 if (!$Done)
380
+                  { $Angle = rand(0, 360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; }
381 381
 
382
-                 $X = cos(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["X"];
383
-                 $Y = sin(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["Y"];
382
+                 $X = cos(deg2rad($Angle))*($Ring) + $this->Data[$BiggestPartner]["X"];
383
+                 $Y = sin(deg2rad($Angle))*($Ring) + $this->Data[$BiggestPartner]["Y"];
384 384
 
385 385
                  $this->Data[$Key]["X"] = $X;
386 386
                  $this->Data[$Key]["Y"] = $Y;
@@ -390,30 +390,30 @@  discard block
 block discarded – undo
390 390
           }
391 391
         }
392 392
       }
393
-     elseif ( $Algorithm == ALGORITHM_CIRCULAR )
393
+     elseif ($Algorithm == ALGORITHM_CIRCULAR)
394 394
       {
395 395
        $MaxConnections = $MaxConnections + 1;
396
-       for($i=$MaxConnections;$i>=0;$i--)
396
+       for ($i = $MaxConnections; $i >= 0; $i--)
397 397
         {
398
-         foreach($this->Data as $Key => $Settings)
398
+         foreach ($this->Data as $Key => $Settings)
399 399
           {
400
-           if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
400
+           if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
+           if ($Settings["Type"] == NODE_TYPE_FREE)
402 402
             {
403
-             if ( isset($Settings["Connections"]) )
403
+             if (isset($Settings["Connections"]))
404 404
               { $Connections = count($Settings["Connections"]); }
405 405
              else
406 406
               { $Connections = 0; }
407 407
 
408
-             if ( $Connections == $i )
408
+             if ($Connections == $i)
409 409
               {
410 410
                $Ring  = $MaxConnections - $Connections;
411
-               $Angle = rand(0,360);
411
+               $Angle = rand(0, 360);
412 412
 
413
-               $X = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
414
-               $Y = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
413
+               $X = cos(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterX;
414
+               $Y = sin(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterY;
415 415
 
416
-               $MedianOffset = $this->getMedianOffset($Key,$X,$Y);
416
+               $MedianOffset = $this->getMedianOffset($Key, $X, $Y);
417 417
 
418 418
                $this->Data[$Key]["X"] = $MedianOffset["X"];
419 419
                $this->Data[$Key]["Y"] = $MedianOffset["Y"];
@@ -422,16 +422,16 @@  discard block
 block discarded – undo
422 422
           }
423 423
         }
424 424
       }
425
-     elseif ( $Algorithm == ALGORITHM_RANDOM )
425
+     elseif ($Algorithm == ALGORITHM_RANDOM)
426 426
       {
427
-       foreach($this->Data as $Key => $Settings)
427
+       foreach ($this->Data as $Key => $Settings)
428 428
         {
429
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
429
+         if ($Settings["Type"] == NODE_TYPE_FREE)
430 430
           {
431
-           $this->Data[$Key]["X"] = $CenterX + rand(-20,20);
432
-           $this->Data[$Key]["Y"] = $CenterY + rand(-20,20);
431
+           $this->Data[$Key]["X"] = $CenterX + rand(-20, 20);
432
+           $this->Data[$Key]["Y"] = $CenterY + rand(-20, 20);
433 433
           }
434
-         if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
434
+         if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
435 435
         }
436 436
       }
437 437
     }
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
    function doPass()
441 441
     {
442 442
      /* Compute vectors */
443
-     foreach($this->Data as $Key => $Settings)
443
+     foreach ($this->Data as $Key => $Settings)
444 444
       {
445
-       if ( $Settings["Type"] != NODE_TYPE_CENTRAL )
445
+       if ($Settings["Type"] != NODE_TYPE_CENTRAL)
446 446
         {
447 447
          unset($this->Data[$Key]["Vectors"]);
448 448
 
@@ -450,48 +450,48 @@  discard block
 block discarded – undo
450 450
          $Y1 = $Settings["Y"];
451 451
 
452 452
          /* Repulsion vectors */
453
-         foreach($this->Data as $Key2 => $Settings2)
453
+         foreach ($this->Data as $Key2 => $Settings2)
454 454
           {
455
-           if ( $Key != $Key2 )
455
+           if ($Key != $Key2)
456 456
             {
457 457
              $X2 = $this->Data[$Key2]["X"];
458 458
              $Y2 = $this->Data[$Key2]["Y"];
459 459
              $FreeZone = $this->Data[$Key2]["FreeZone"];
460 460
 
461
-             $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
462
-             $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2) + 180;
461
+             $Distance = $this->getDistance($X1, $Y1, $X2, $Y2);
462
+             $Angle    = $this->getAngle($X1, $Y1, $X2, $Y2) + 180;
463 463
 
464 464
              /* Nodes too close, repulsion occurs */
465
-             if ( $Distance < $FreeZone )
465
+             if ($Distance < $FreeZone)
466 466
               {
467
-               $Force = log(pow(2,$FreeZone-$Distance));
468
-               if ( $Force > 1 )
469
-                { $this->Data[$Key]["Vectors"][] = array("Type"=>"R","Angle"=>$Angle % 360,"Force"=>$Force); }
467
+               $Force = log(pow(2, $FreeZone - $Distance));
468
+               if ($Force > 1)
469
+                { $this->Data[$Key]["Vectors"][] = array("Type"=>"R", "Angle"=>$Angle%360, "Force"=>$Force); }
470 470
               }
471 471
             }
472 472
           }
473 473
 
474 474
          /* Attraction vectors */
475
-         if ( isset($Settings["Connections"]) )
475
+         if (isset($Settings["Connections"]))
476 476
           {
477
-           foreach($Settings["Connections"] as $ID => $NodeID)
477
+           foreach ($Settings["Connections"] as $ID => $NodeID)
478 478
             {
479
-             if ( isset($this->Data[$NodeID]) )
479
+             if (isset($this->Data[$NodeID]))
480 480
               {
481 481
                $X2 = $this->Data[$NodeID]["X"];
482 482
                $Y2 = $this->Data[$NodeID]["Y"];
483 483
                $FreeZone = $this->Data[$Key2]["FreeZone"];
484 484
 
485
-               $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
486
-               $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2);
485
+               $Distance = $this->getDistance($X1, $Y1, $X2, $Y2);
486
+               $Angle    = $this->getAngle($X1, $Y1, $X2, $Y2);
487 487
 
488
-               if ( $Distance > $FreeZone )
489
-                $Force = log(($Distance-$FreeZone)+1);
488
+               if ($Distance > $FreeZone)
489
+                $Force = log(($Distance - $FreeZone) + 1);
490 490
                else
491
-                { $Force = log(($FreeZone-$Distance)+1); ($Angle = $Angle + 180); }
491
+                { $Force = log(($FreeZone - $Distance) + 1); ($Angle = $Angle + 180); }
492 492
 
493
-               if ( $Force > 1 )
494
-                $this->Data[$Key]["Vectors"][] = array("Type"=>"A","Angle"=>$Angle % 360,"Force"=>$Force);
493
+               if ($Force > 1)
494
+                $this->Data[$Key]["Vectors"][] = array("Type"=>"A", "Angle"=>$Angle%360, "Force"=>$Force);
495 495
               }
496 496
             }
497 497
           }
@@ -499,22 +499,22 @@  discard block
 block discarded – undo
499 499
       }
500 500
 
501 501
      /* Move the nodes accoding to the vectors */
502
-     foreach($this->Data as $Key => $Settings)
502
+     foreach ($this->Data as $Key => $Settings)
503 503
       {
504 504
        $X = $Settings["X"];
505 505
        $Y = $Settings["Y"];
506 506
 
507
-       if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
507
+       if (isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL)
508 508
         {
509
-         foreach($Settings["Vectors"] as $ID => $Vector)
509
+         foreach ($Settings["Vectors"] as $ID => $Vector)
510 510
           {
511 511
            $Type  = $Vector["Type"];
512 512
            $Force = $Vector["Force"];
513 513
            $Angle = $Vector["Angle"];
514 514
            $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
515 515
 
516
-           $X = cos(deg2rad($Angle)) * $Force * $Factor + $X;
517
-           $Y = sin(deg2rad($Angle)) * $Force * $Factor + $Y;
516
+           $X = cos(deg2rad($Angle))*$Force*$Factor + $X;
517
+           $Y = sin(deg2rad($Angle))*$Force*$Factor + $Y;
518 518
           }
519 519
         }
520 520
 
@@ -526,15 +526,15 @@  discard block
 block discarded – undo
526 526
    function lastPass()
527 527
     {
528 528
      /* Put everything inside the graph area */
529
-     foreach($this->Data as $Key => $Settings)
529
+     foreach ($this->Data as $Key => $Settings)
530 530
       {
531 531
        $X = $Settings["X"];
532 532
        $Y = $Settings["Y"];
533 533
 
534
-       if ( $X < $this->X1 ) { $X = $this->X1; }
535
-       if ( $X > $this->X2 ) { $X = $this->X2; }
536
-       if ( $Y < $this->Y1 ) { $Y = $this->Y1; }
537
-       if ( $Y > $this->Y2 ) { $Y = $this->Y2; }
534
+       if ($X < $this->X1) { $X = $this->X1; }
535
+       if ($X > $this->X2) { $X = $this->X2; }
536
+       if ($Y < $this->Y1) { $Y = $this->Y1; }
537
+       if ($Y > $this->Y2) { $Y = $this->Y2; }
538 538
 
539 539
        $this->Data[$Key]["X"] = $X;
540 540
        $this->Data[$Key]["Y"] = $Y;
@@ -542,21 +542,21 @@  discard block
 block discarded – undo
542 542
 
543 543
      /* Dump all links */
544 544
      $Links = "";
545
-     foreach($this->Data as $Key => $Settings)
545
+     foreach ($this->Data as $Key => $Settings)
546 546
       {
547 547
        $X1 = $Settings["X"];
548 548
        $Y1 = $Settings["Y"];
549 549
 
550
-       if ( isset($Settings["Connections"]) )
550
+       if (isset($Settings["Connections"]))
551 551
         {
552 552
          foreach ($Settings["Connections"] as $ID => $NodeID)
553 553
           {
554
-           if ( isset($this->Data[$NodeID]) )
554
+           if (isset($this->Data[$NodeID]))
555 555
             {
556 556
              $X2 = $this->Data[$NodeID]["X"];
557 557
              $Y2 = $this->Data[$NodeID]["Y"];
558 558
 
559
-             $Links[] = array("X1"=>$X1,"Y1"=>$Y1,"X2"=>$X2,"Y2"=>$Y2,"Source"=>$Settings["Name"],"Destination"=>$this->Data[$NodeID]["Name"]);
559
+             $Links[] = array("X1"=>$X1, "Y1"=>$Y1, "X2"=>$X2, "Y2"=>$Y2, "Source"=>$Settings["Name"], "Destination"=>$this->Data[$NodeID]["Name"]);
560 560
             }
561 561
           }
562 562
         }
@@ -564,29 +564,29 @@  discard block
 block discarded – undo
564 564
 
565 565
      /* Check collisions */
566 566
      $Conflicts = 0;
567
-     foreach($this->Data as $Key => $Settings)
567
+     foreach ($this->Data as $Key => $Settings)
568 568
       {
569 569
        $X1 = $Settings["X"];
570 570
        $Y1 = $Settings["Y"];
571 571
 
572
-       if ( isset($Settings["Connections"]) )
572
+       if (isset($Settings["Connections"]))
573 573
         {
574 574
          foreach ($Settings["Connections"] as $ID => $NodeID)
575 575
           {
576
-           if ( isset($this->Data[$NodeID]) )
576
+           if (isset($this->Data[$NodeID]))
577 577
             {
578 578
              $X2 = $this->Data[$NodeID]["X"];
579 579
              $Y2 = $this->Data[$NodeID]["Y"];
580 580
 
581
-             foreach($Links as $IDLinks => $Link)
581
+             foreach ($Links as $IDLinks => $Link)
582 582
               {
583 583
                $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"];
584 584
 
585
-               if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) )
585
+               if (!($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4))
586 586
                 {
587
-                 if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) )
587
+                 if ($this->intersect($X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4))
588 588
                   {
589
-                   if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] )
589
+                   if ($Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"])
590 590
                     { $Conflicts++; }
591 591
                   }
592 592
                 }
@@ -602,31 +602,31 @@  discard block
 block discarded – undo
602 602
    function center()
603 603
     {
604 604
      /* Determine the real center */
605
-     $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
606
-     $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
605
+     $TargetCenterX = ($this->X2 - $this->X1)/2 + $this->X1;
606
+     $TargetCenterY = ($this->Y2 - $this->Y1)/2 + $this->Y1;
607 607
 
608 608
      /* Get current boundaries */
609 609
      $XMin = $this->X2; $XMax = $this->X1;
610 610
      $YMin = $this->Y2; $YMax = $this->Y1;
611
-     foreach($this->Data as $Key => $Settings)
611
+     foreach ($this->Data as $Key => $Settings)
612 612
       {
613 613
        $X = $Settings["X"];
614 614
        $Y = $Settings["Y"];
615 615
 
616
-       if ( $X < $XMin) { $XMin = $X; }
617
-       if ( $X > $XMax) { $XMax = $X; }
618
-       if ( $Y < $YMin) { $YMin = $Y; }
619
-       if ( $Y > $YMax) { $YMax = $Y; }
616
+       if ($X < $XMin) { $XMin = $X; }
617
+       if ($X > $XMax) { $XMax = $X; }
618
+       if ($Y < $YMin) { $YMin = $Y; }
619
+       if ($Y > $YMax) { $YMax = $Y; }
620 620
       }
621
-     $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
622
-     $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;
621
+     $CurrentCenterX = ($XMax - $XMin)/2 + $XMin;
622
+     $CurrentCenterY = ($YMax - $YMin)/2 + $YMin;
623 623
 
624 624
      /* Compute the offset to apply */
625 625
      $XOffset = $TargetCenterX - $CurrentCenterX;
626 626
      $YOffset = $TargetCenterY - $CurrentCenterY;
627 627
 
628 628
      /* Correct the points position */
629
-     foreach($this->Data as $Key => $Settings)
629
+     foreach ($this->Data as $Key => $Settings)
630 630
       {
631 631
        $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
632 632
        $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
@@ -634,20 +634,20 @@  discard block
 block discarded – undo
634 634
     }
635 635
 
636 636
    /* Create the encoded string */
637
-   function drawSpring($Object,$Settings="")
637
+   function drawSpring($Object, $Settings = "")
638 638
     {
639 639
      $this->pChartObject = $Object;
640 640
 
641
-     $Pass			= isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
642
-     $Retries			= isset($Settings["Retry"]) ? $Settings["Retry"] : 10;
641
+     $Pass = isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
642
+     $Retries = isset($Settings["Retry"]) ? $Settings["Retry"] : 10;
643 643
      $this->MagneticForceA	= isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5;
644 644
      $this->MagneticForceR	= isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2;
645
-     $this->RingSize		= isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
645
+     $this->RingSize = isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
646 646
      $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE;
647
-     $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
647
+     $DrawQuietZone = isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
648 648
      $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE;
649 649
      $TextPadding		= isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4;
650
-     $Algorithm			= isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
650
+     $Algorithm = isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
651 651
 
652 652
      $FontSize		= $Object->FontSize;
653 653
      $this->X1		= $Object->GraphAreaX1;
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
      $this->Y2		= $Object->GraphAreaY2;
657 657
 
658 658
      $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1;
659
-     while ($Conflicts != 0 && $Jobs < $Retries )
659
+     while ($Conflicts != 0 && $Jobs < $Retries)
660 660
       {
661 661
        $Jobs++;
662 662
 
@@ -664,70 +664,70 @@  discard block
 block discarded – undo
664 664
        $this->firstPass($Algorithm);
665 665
 
666 666
        /* Apply the vectors */
667
-       if ( $Pass > 0 ) 
667
+       if ($Pass > 0) 
668 668
         {
669
-         for ($i=0; $i<=$Pass; $i++) { $this->doPass(); }
669
+         for ($i = 0; $i <= $Pass; $i++) { $this->doPass(); }
670 670
         }
671 671
 
672 672
        $Conflicts = $this->lastPass();
673
-       if ( $this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"] )
673
+       if ($this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"])
674 674
         { $this->History["MinimumConflicts"] = $Conflicts; $this->History["Result"] = $this->Data; }
675 675
       }
676 676
 
677 677
      $Conflicts  = $this->History["MinimumConflicts"];
678 678
      $this->Data = $this->History["Result"];
679 679
 
680
-     if ( $CenterGraph ) { $this->center(); }
680
+     if ($CenterGraph) { $this->center(); }
681 681
 
682 682
      /* Draw the connections */
683 683
      $Drawn = "";
684
-     foreach($this->Data as $Key => $Settings)
684
+     foreach ($this->Data as $Key => $Settings)
685 685
       {
686 686
        $X	= $Settings["X"];
687 687
        $Y	= $Settings["Y"];
688 688
 
689
-       if ( isset($Settings["Connections"]) )
689
+       if (isset($Settings["Connections"]))
690 690
         {
691 691
          foreach ($Settings["Connections"] as $ID => $NodeID)
692 692
           {
693
-           if ( !isset($Drawn[$Key]) )    { $Drawn[$Key] = ""; }
694
-           if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; }
693
+           if (!isset($Drawn[$Key])) { $Drawn[$Key] = ""; }
694
+           if (!isset($Drawn[$NodeID])) { $Drawn[$NodeID] = ""; }
695 695
 
696
-           if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) )
696
+           if (isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]))
697 697
             {
698
-             $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]);
698
+             $Color = array("R"=>$this->Default["LinkR"], "G"=>$this->Default["LinkG"], "B"=>$this->Default["LinkB"], "Alpha"=>$this->Default["Alpha"]);
699 699
 
700
-             if ( $this->Links != "" )
700
+             if ($this->Links != "")
701 701
               {
702
-               if ( isset($this->Links[$Key][$NodeID]["R"]) )
703
-                { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"],"G"=>$this->Links[$Key][$NodeID]["G"],"B"=>$this->Links[$Key][$NodeID]["B"],"Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); }
702
+               if (isset($this->Links[$Key][$NodeID]["R"]))
703
+                { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"], "G"=>$this->Links[$Key][$NodeID]["G"], "B"=>$this->Links[$Key][$NodeID]["B"], "Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); }
704 704
 
705
-               if ( isset($this->Links[$Key][$NodeID]["Ticks"]) )
705
+               if (isset($this->Links[$Key][$NodeID]["Ticks"]))
706 706
                  { $Color["Ticks"] = $this->Links[$Key][$NodeID]["Ticks"]; }
707 707
               }
708 708
 
709 709
              $X2 = $this->Data[$NodeID]["X"];
710 710
              $Y2 = $this->Data[$NodeID]["Y"];
711
-             $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
711
+             $this->pChartObject->drawLine($X, $Y, $X2, $Y2, $Color);
712 712
              $Drawn[$Key][$NodeID] = TRUE;
713 713
 
714
-             if ( isset($this->Links) && $this->Links != "" )
714
+             if (isset($this->Links) && $this->Links != "")
715 715
               {
716
-               if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) )
716
+               if (isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]))
717 717
                 {
718 718
                  $Name  = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"];
719 719
                  $TxtX  = ($X2 - $X)/2 + $X;
720 720
                  $TxtY  = ($Y2 - $Y)/2 + $Y;
721 721
 
722
-                 if ( $X <= $X2 )
723
-                  $Angle = (360-$this->getAngle($X,$Y,$X2,$Y2)) % 360;
722
+                 if ($X <= $X2)
723
+                  $Angle = (360 - $this->getAngle($X, $Y, $X2, $Y2))%360;
724 724
                  else
725
-                  $Angle = (360-$this->getAngle($X2,$Y2,$X,$Y)) % 360;
725
+                  $Angle = (360 - $this->getAngle($X2, $Y2, $X, $Y))%360;
726 726
 
727 727
                  $Settings          = $Color;
728 728
                  $Settings["Angle"] = $Angle;
729 729
                  $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
730
-                 $this->pChartObject->drawText($TxtX,$TxtY,$Name,$Settings);
730
+                 $this->pChartObject->drawText($TxtX, $TxtY, $Name, $Settings);
731 731
                 }
732 732
               }
733 733
             }
@@ -736,59 +736,59 @@  discard block
 block discarded – undo
736 736
       }
737 737
 
738 738
      /* Draw the quiet zones */
739
-     if ( $DrawQuietZone )
739
+     if ($DrawQuietZone)
740 740
       {
741
-       foreach($this->Data as $Key => $Settings)
741
+       foreach ($this->Data as $Key => $Settings)
742 742
         {
743 743
          $X	 = $Settings["X"];
744 744
          $Y	 = $Settings["Y"];
745 745
          $FreeZone = $Settings["FreeZone"];
746 746
 
747
-         $this->pChartObject->drawFilledCircle($X,$Y,$FreeZone,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>2));
747
+         $this->pChartObject->drawFilledCircle($X, $Y, $FreeZone, array("R"=>0, "G"=>0, "B"=>0, "Alpha"=>2));
748 748
         }
749 749
       }
750 750
 
751 751
 
752 752
      /* Draw the nodes */
753
-     foreach($this->Data as $Key => $Settings)
753
+     foreach ($this->Data as $Key => $Settings)
754 754
       {
755 755
        $X	 = $Settings["X"];
756 756
        $Y	 = $Settings["Y"];
757
-       $Name	 = $Settings["Name"];
757
+       $Name = $Settings["Name"];
758 758
        $FreeZone = $Settings["FreeZone"];
759 759
        $Shape    = $Settings["Shape"];
760 760
        $Size     = $Settings["Size"];
761 761
 
762
-       $Color	 = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]);
762
+       $Color = array("R"=>$Settings["R"], "G"=>$Settings["G"], "B"=>$Settings["B"], "Alpha"=>$Settings["Alpha"], "BorderR"=>$Settings["BorderR"], "BorderG"=>$Settings["BorderG"], "BorderB"=>$Settings["BorderB"], "BorderApha"=>$Settings["BorderAlpha"]);
763 763
 
764
-       if ( $Shape == NODE_SHAPE_CIRCLE )
764
+       if ($Shape == NODE_SHAPE_CIRCLE)
765 765
         {
766
-         $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color);
766
+         $this->pChartObject->drawFilledCircle($X, $Y, $Size, $Color);
767 767
         }
768
-       elseif ( $Shape == NODE_SHAPE_TRIANGLE )
768
+       elseif ($Shape == NODE_SHAPE_TRIANGLE)
769 769
         {
770 770
          $Points = "";
771
-         $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y;
772
-         $Points[] = cos(deg2rad(45)) * $Size + $X;  $Points[] = sin(deg2rad(45)) * $Size + $Y;
773
-         $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y;
774
-         $this->pChartObject->drawPolygon($Points,$Color);
771
+         $Points[] = cos(deg2rad(270))*$Size + $X; $Points[] = sin(deg2rad(270))*$Size + $Y;
772
+         $Points[] = cos(deg2rad(45))*$Size + $X; $Points[] = sin(deg2rad(45))*$Size + $Y;
773
+         $Points[] = cos(deg2rad(135))*$Size + $X; $Points[] = sin(deg2rad(135))*$Size + $Y;
774
+         $this->pChartObject->drawPolygon($Points, $Color);
775 775
         }
776
-       elseif ( $Shape == NODE_SHAPE_SQUARE )
776
+       elseif ($Shape == NODE_SHAPE_SQUARE)
777 777
         {
778
-         $Offset = $Size/2; $Size = $Size / 2;
779
-         $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color);
778
+         $Offset = $Size/2; $Size = $Size/2;
779
+         $this->pChartObject->drawFilledRectangle($X - $Offset, $Y - $Offset, $X + $Offset, $Y + $Offset, $Color);
780 780
         }
781 781
 
782
-       if ( $Name != "" )
782
+       if ($Name != "")
783 783
         {
784
-         $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]);
784
+         $LabelOptions = array("R"=>$this->Labels["R"], "G"=>$this->Labels["G"], "B"=>$this->Labels["B"], "Alpha"=>$this->Labels["Alpha"]);
785 785
 
786
-         if ( $this->Labels["Type"] == LABEL_LIGHT )
786
+         if ($this->Labels["Type"] == LABEL_LIGHT)
787 787
           {
788 788
            $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT;
789
-           $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions);
789
+           $this->pChartObject->drawText($X, $Y, $Name, $LabelOptions);
790 790
           }
791
-         elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
791
+         elseif ($this->Labels["Type"] == LABEL_CLASSIC)
792 792
           {
793 793
            $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794 794
            $LabelOptions["DrawBox"]       = TRUE;
@@ -798,67 +798,67 @@  discard block
 block discarded – undo
798 798
            $LabelOptions["BoxRounded"]    = TRUE;
799 799
            $LabelOptions["NoShadow"]      = TRUE;
800 800
 
801
-           $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions);
801
+           $this->pChartObject->drawText($X, $Y + $Size + $TextPadding, $Name, $LabelOptions);
802 802
           }
803 803
         }
804 804
       }
805 805
 
806 806
      /* Draw the vectors */
807
-     if ( $DrawVectors )
807
+     if ($DrawVectors)
808 808
       {
809
-       foreach($this->Data as $Key => $Settings)
809
+       foreach ($this->Data as $Key => $Settings)
810 810
         {
811 811
          $X1 = $Settings["X"];
812 812
          $Y1 = $Settings["Y"];
813 813
 
814
-         if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
814
+         if (isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL)
815 815
           {
816
-           foreach($Settings["Vectors"] as $ID => $Vector)
816
+           foreach ($Settings["Vectors"] as $ID => $Vector)
817 817
             {
818 818
              $Type  = $Vector["Type"];
819 819
              $Force = $Vector["Force"];
820 820
              $Angle = $Vector["Angle"];
821 821
              $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
822
-             $Color  = $Type == "A" ? array("FillR"=>255,"FillG"=>0,"FillB"=>0) : array("FillR"=>0,"FillG"=>255,"FillB"=>0);
822
+             $Color  = $Type == "A" ? array("FillR"=>255, "FillG"=>0, "FillB"=>0) : array("FillR"=>0, "FillG"=>255, "FillB"=>0);
823 823
 
824
-             $X2 = cos(deg2rad($Angle)) * $Force * $Factor + $X1;
825
-             $Y2 = sin(deg2rad($Angle)) * $Force * $Factor + $Y1;
824
+             $X2 = cos(deg2rad($Angle))*$Force*$Factor + $X1;
825
+             $Y2 = sin(deg2rad($Angle))*$Force*$Factor + $Y1;
826 826
 
827
-             $this->pChartObject->drawArrow($X1,$Y1,$X2,$Y2,$Color);
827
+             $this->pChartObject->drawArrow($X1, $Y1, $X2, $Y2, $Color);
828 828
             }
829 829
           }
830 830
         }
831 831
       }
832 832
 
833
-     return(array("Pass"=>$Jobs,"Conflicts"=>$Conflicts));
833
+     return(array("Pass"=>$Jobs, "Conflicts"=>$Conflicts));
834 834
     }
835 835
 
836 836
    /* Return the distance between two points */
837
-   function getDistance($X1,$Y1,$X2,$Y2)
838
-    { return (sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1))); }
837
+   function getDistance($X1, $Y1, $X2, $Y2)
838
+    { return (sqrt(($X2 - $X1)*($X2 - $X1) + ($Y2 - $Y1)*($Y2 - $Y1))); }
839 839
 
840 840
    /* Return the angle made by a line and the X axis */
841
-   function getAngle($X1,$Y1,$X2,$Y2)
841
+   function getAngle($X1, $Y1, $X2, $Y2)
842 842
     {
843
-     $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent));
844
-     if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); }
843
+     $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1; $Angle = rad2deg(atan2($Opposite, $Adjacent));
844
+     if ($Angle > 0) { return($Angle); } else { return(360 - abs($Angle)); }
845 845
     }
846 846
 
847
-   function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4)
847
+   function intersect($X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4)
848 848
     {
849
-     $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850
-     $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
849
+     $A = (($X3*$Y4 - $X4*$Y3)*($X1 - $X2) - ($X1*$Y2 - $X2*$Y1)*($X3 - $X4));
850
+     $B = (($Y1 - $Y2)*($X3 - $X4) - ($Y3 - $Y4)*($X1 - $X2));
851 851
 
852
-     if ( $B == 0 ) { return(FALSE); }
853
-     $Xi = $A / $B;
852
+     if ($B == 0) { return(FALSE); }
853
+     $Xi = $A/$B;
854 854
 
855 855
      $C = ($X1 - $X2);
856
-     if ( $C == 0 ) { return(FALSE); }
857
-     $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
856
+     if ($C == 0) { return(FALSE); }
857
+     $Yi = $Xi*(($Y1 - $Y2)/$C) + (($X1*$Y2 - $X2*$Y1)/$C);
858 858
 
859
-     if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
859
+     if ($Xi >= min($X1, $X2) && $Xi >= min($X3, $X4) && $Xi <= max($X1, $X2) && $Xi <= max($X3, $X4))
860 860
       {
861
-       if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
861
+       if ($Yi >= min($Y1, $Y2) && $Yi >= min($Y3, $Y4) && $Yi <= max($Y1, $Y2) && $Yi <= max($Y3, $Y4))
862 862
         { return(TRUE); }
863 863
       }
864 864
 
Please login to merge, or discard this patch.
Braces   +112 added lines, -223 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
  define("LABEL_LIGHT"		, 690032);
30 30
 
31 31
  /* pSpring class definition */
32
- class pSpring
33
-  {
32
+ class pSpring {
34 33
    var $History;
35 34
    var $pChartObject;
36 35
    var $Data;
@@ -43,8 +42,7 @@  discard block
 block discarded – undo
43 42
    var $Labels;
44 43
 
45 44
    /* Class creator */
46
-   function pSpring()
47
-    {
45
+   function pSpring() {
48 46
      /* Initialise data arrays */
49 47
      $this->Data = "";
50 48
      $this->Links = "";
@@ -83,8 +81,7 @@  discard block
 block discarded – undo
83 81
     }
84 82
 
85 83
    /* Set default links options */
86
-   function setLinkDefaults($Settings="")
87
-    {
84
+   function setLinkDefaults($Settings="") {
88 85
      if ( isset($Settings["R"]) )     { $this->Default["LinkR"] = $Settings["R"]; }
89 86
      if ( isset($Settings["G"]) )     { $this->Default["LinkG"] = $Settings["G"]; }
90 87
      if ( isset($Settings["B"]) )     { $this->Default["LinkB"] = $Settings["B"]; }
@@ -92,8 +89,7 @@  discard block
 block discarded – undo
92 89
     }
93 90
 
94 91
    /* Set default links options */
95
-   function setLabelsSettings($Settings="")
96
-    {
92
+   function setLabelsSettings($Settings="") {
97 93
      if ( isset($Settings["Type"]) )  { $this->Labels["Type"] = $Settings["Type"]; }
98 94
      if ( isset($Settings["R"]) )     { $this->Labels["R"] = $Settings["R"]; }
99 95
      if ( isset($Settings["G"]) )     { $this->Labels["G"] = $Settings["G"]; }
@@ -102,22 +98,18 @@  discard block
 block discarded – undo
102 98
     }
103 99
 
104 100
    /* Auto compute the FreeZone size based on the number of connections */
105
-   function autoFreeZone()
106
-    {
101
+   function autoFreeZone() {
107 102
      /* Check connections reciprocity */
108
-     foreach($this->Data as $Key => $Settings)
109
-      {
103
+     foreach($this->Data as $Key => $Settings) {
110 104
        if ( isset($Settings["Connections"]) )
111
-        { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; }
112
-       else
105
+        { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; } else
113 106
         { $this->Data[$Key]["FreeZone"] = 20; }
114 107
       }
115 108
 
116 109
     }
117 110
 
118 111
    /* Set link properties */
119
-   function linkProperties($FromNode,$ToNode,$Settings)
120
-    {
112
+   function linkProperties($FromNode,$ToNode,$Settings) {
121 113
      if ( !isset($this->Data[$FromNode]) ) { return(0); }
122 114
      if ( !isset($this->Data[$ToNode]) )   { return(0); }
123 115
 
@@ -136,8 +128,7 @@  discard block
 block discarded – undo
136 128
      $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks;
137 129
     }
138 130
 
139
-   function setNodeDefaults($Settings="")
140
-    {
131
+   function setNodeDefaults($Settings="") {
141 132
      if ( isset($Settings["R"]) ) { $this->Default["R"]					= $Settings["R"]; }
142 133
      if ( isset($Settings["G"]) ) { $this->Default["G"]					= $Settings["G"]; }
143 134
      if ( isset($Settings["B"]) ) { $this->Default["B"]					= $Settings["B"]; }
@@ -158,8 +149,7 @@  discard block
 block discarded – undo
158 149
     }
159 150
 
160 151
    /* Add a node */
161
-   function addNode($NodeID,$Settings="")
162
-    {
152
+   function addNode($NodeID,$Settings="") {
163 153
      /* if the node already exists, ignore */
164 154
      if (isset($this->Data[$NodeID])) { return(0); }
165 155
 
@@ -196,27 +186,21 @@  discard block
 block discarded – undo
196 186
      $this->Data[$NodeID]["Size"]		= $Size;
197 187
      $this->Data[$NodeID]["Shape"]		= $Shape;
198 188
      $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
-     if ( $Connections != NULL )
200
-      {
201
-       if ( is_array($Connections ) )
202
-        {
203
-         foreach($Connections as $Key => $Value)
204
-          $this->Data[$NodeID]["Connections"][] = $Value;
205
-        }
206
-       else
189
+     if ( $Connections != NULL ) {
190
+       if ( is_array($Connections ) ) {
191
+         foreach($Connections as $Key => $Value) {
192
+                   $this->Data[$NodeID]["Connections"][] = $Value;
193
+         }
194
+        } else
207 195
         $this->Data[$NodeID]["Connections"][] = $Connections;
208 196
       }
209 197
     }
210 198
 
211 199
    /* Set color attribute for a list of nodes */
212
-   function setNodesColor($Nodes,$Settings="")
213
-    {
214
-     if ( is_array($Nodes) )
215
-      {
216
-       foreach ($Nodes as $Key => $NodeID)
217
-        {
218
-         if (isset($this->Data[$NodeID]) )
219
-          {
200
+   function setNodesColor($Nodes,$Settings="") {
201
+     if ( is_array($Nodes) ) {
202
+       foreach ($Nodes as $Key => $NodeID) {
203
+         if (isset($this->Data[$NodeID]) ) {
220 204
            if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221 205
            if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222 206
            if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
@@ -228,9 +212,7 @@  discard block
 block discarded – undo
228 212
            if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
229 213
           }
230 214
         }
231
-      }
232
-     else
233
-      {
215
+      } else {
234 216
        if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235 217
        if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236 218
        if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
@@ -248,25 +230,19 @@  discard block
 block discarded – undo
248 230
     { return($this->Data); }
249 231
 
250 232
    /* Check if a connection exists and create it if required */
251
-   function checkConnection($SourceID, $TargetID)
252
-    {
253
-     if ( isset($this->Data[$SourceID]["Connections"]) )
254
-      {
233
+   function checkConnection($SourceID, $TargetID) {
234
+     if ( isset($this->Data[$SourceID]["Connections"]) ) {
255 235
        foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
256 236
         { if ( $TargetID == $ConnectionID ) { return(TRUE); } }
257 237
       }
258 238
      $this->Data[$SourceID]["Connections"][] = $TargetID;
259 239
     }
260 240
    /* Get the median linked nodes position */
261
-   function getMedianOffset($Key,$X,$Y)
262
-    {
241
+   function getMedianOffset($Key,$X,$Y) {
263 242
      $Cpt = 1;
264
-     if ( isset($this->Data[$Key]["Connections"]) )
265
-      {
266
-       foreach($this->Data[$Key]["Connections"] as $ID => $NodeID)
267
-        {
268
-         if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) )
269
-          {
243
+     if ( isset($this->Data[$Key]["Connections"]) ) {
244
+       foreach($this->Data[$Key]["Connections"] as $ID => $NodeID) {
245
+         if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) ) {
270 246
            $X = $X + $this->Data[$NodeID]["X"];
271 247
            $Y = $Y + $this->Data[$NodeID]["Y"];
272 248
            $Cpt++;
@@ -277,13 +253,11 @@  discard block
 block discarded – undo
277 253
     }
278 254
 
279 255
    /* Return the ID of the attached partner with the biggest weight */
280
-   function getBiggestPartner($Key)
281
-    {
256
+   function getBiggestPartner($Key) {
282 257
      if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
283 258
 
284 259
      $MaxWeight = 0; $Result = "";
285
-     foreach($this->Data[$Key]["Connections"] as $Key => $PeerID)
286
-      {
260
+     foreach($this->Data[$Key]["Connections"] as $Key => $PeerID) {
287 261
        if ( $this->Data[$PeerID]["Weight"] > $MaxWeight )
288 262
         { $MaxWeight = $this->Data[$PeerID]["Weight"]; $Result = $PeerID; }
289 263
       }
@@ -291,18 +265,16 @@  discard block
 block discarded – undo
291 265
     }
292 266
 
293 267
    /* Do the initial node positions computing pass */
294
-   function firstPass($Algorithm)
295
-    {
268
+   function firstPass($Algorithm) {
296 269
      $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
297 270
      $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
298 271
 
299 272
      /* Check connections reciprocity */
300
-     foreach($this->Data as $Key => $Settings)
301
-      {
302
-       if ( isset($Settings["Connections"]) )
303
-        {
304
-         foreach($Settings["Connections"] as $ID => $ConnectionID)
305
-          $this->checkConnection($ConnectionID,$Key);
273
+     foreach($this->Data as $Key => $Settings) {
274
+       if ( isset($Settings["Connections"]) ) {
275
+         foreach($Settings["Connections"] as $ID => $ConnectionID) {
276
+                   $this->checkConnection($ConnectionID,$Key);
277
+         }
306 278
         }
307 279
       }
308 280
 
@@ -313,16 +285,12 @@  discard block
 block discarded – undo
313 285
      foreach($this->Data as $Key => $Settings)
314 286
       { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } }
315 287
 
316
-     if ( $Algorithm == ALGORITHM_WEIGHTED )
317
-      {
318
-       foreach($this->Data as $Key => $Settings)
319
-        {
288
+     if ( $Algorithm == ALGORITHM_WEIGHTED ) {
289
+       foreach($this->Data as $Key => $Settings) {
320 290
          if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
322
-          {
291
+         if ( $Settings["Type"] == NODE_TYPE_FREE ) {
323 292
            if ( isset($Settings["Connections"]) )
324
-            { $Connections = count($Settings["Connections"]); }
325
-           else
293
+            { $Connections = count($Settings["Connections"]); } else
326 294
             { $Connections = 0; }
327 295
 
328 296
            $Ring  = $MaxConnections - $Connections;
@@ -332,12 +300,9 @@  discard block
 block discarded – undo
332 300
            $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
333 301
           }
334 302
         }
335
-      }
336
-     elseif ( $Algorithm == ALGORITHM_CENTRAL )
337
-      {
303
+      } elseif ( $Algorithm == ALGORITHM_CENTRAL ) {
338 304
        /* Put a weight on each nodes */
339
-       foreach($this->Data as $Key => $Settings)
340
-        {
305
+       foreach($this->Data as $Key => $Settings) {
341 306
          if ( isset($Settings["Connections"]) )
342 307
           $this->Data[$Key]["Weight"] = count($Settings["Connections"]);
343 308
          else
@@ -345,33 +310,25 @@  discard block
 block discarded – undo
345 310
         }
346 311
 
347 312
        $MaxConnections = $MaxConnections + 1;
348
-       for($i=$MaxConnections;$i>=0;$i--)
349
-        {
350
-         foreach($this->Data as $Key => $Settings)
351
-          {
313
+       for($i=$MaxConnections;$i>=0;$i--) {
314
+         foreach($this->Data as $Key => $Settings) {
352 315
            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
354
-            {
316
+           if ( $Settings["Type"] == NODE_TYPE_FREE ) {
355 317
              if ( isset($Settings["Connections"]) )
356
-              { $Connections = count($Settings["Connections"]); }
357
-             else
318
+              { $Connections = count($Settings["Connections"]); } else
358 319
               { $Connections = 0; }
359 320
 
360
-             if ( $Connections == $i )
361
-              {
321
+             if ( $Connections == $i ) {
362 322
                $BiggestPartner = $this->getBiggestPartner($Key);
363
-               if ( $BiggestPartner != "" )
364
-                {
323
+               if ( $BiggestPartner != "" ) {
365 324
                  $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366 325
                  $Weight        = $this->Data[$BiggestPartner]["Weight"];
367 326
                  $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
368 327
                  $Done          = FALSE; $Tries = 0;
369
-                 while (!$Done && $Tries <= $Weight*2)
370
-                  {
328
+                 while (!$Done && $Tries <= $Weight*2) {
371 329
                    $Tries++;
372 330
                    $Angle = floor(rand(0,$Weight)*$AngleDivision);
373
-                   if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
374
-                    {
331
+                   if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) ) {
375 332
                      $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376 333
                      $Done = TRUE; 
377 334
                     }
@@ -389,24 +346,17 @@  discard block
 block discarded – undo
389 346
             }
390 347
           }
391 348
         }
392
-      }
393
-     elseif ( $Algorithm == ALGORITHM_CIRCULAR )
394
-      {
349
+      } elseif ( $Algorithm == ALGORITHM_CIRCULAR ) {
395 350
        $MaxConnections = $MaxConnections + 1;
396
-       for($i=$MaxConnections;$i>=0;$i--)
397
-        {
398
-         foreach($this->Data as $Key => $Settings)
399
-          {
351
+       for($i=$MaxConnections;$i>=0;$i--) {
352
+         foreach($this->Data as $Key => $Settings) {
400 353
            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
402
-            {
354
+           if ( $Settings["Type"] == NODE_TYPE_FREE ) {
403 355
              if ( isset($Settings["Connections"]) )
404
-              { $Connections = count($Settings["Connections"]); }
405
-             else
356
+              { $Connections = count($Settings["Connections"]); } else
406 357
               { $Connections = 0; }
407 358
 
408
-             if ( $Connections == $i )
409
-              {
359
+             if ( $Connections == $i ) {
410 360
                $Ring  = $MaxConnections - $Connections;
411 361
                $Angle = rand(0,360);
412 362
 
@@ -421,13 +371,9 @@  discard block
 block discarded – undo
421 371
             }
422 372
           }
423 373
         }
424
-      }
425
-     elseif ( $Algorithm == ALGORITHM_RANDOM )
426
-      {
427
-       foreach($this->Data as $Key => $Settings)
428
-        {
429
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
430
-          {
374
+      } elseif ( $Algorithm == ALGORITHM_RANDOM ) {
375
+       foreach($this->Data as $Key => $Settings) {
376
+         if ( $Settings["Type"] == NODE_TYPE_FREE ) {
431 377
            $this->Data[$Key]["X"] = $CenterX + rand(-20,20);
432 378
            $this->Data[$Key]["Y"] = $CenterY + rand(-20,20);
433 379
           }
@@ -437,23 +383,18 @@  discard block
 block discarded – undo
437 383
     }
438 384
 
439 385
    /* Compute one pass */
440
-   function doPass()
441
-    {
386
+   function doPass() {
442 387
      /* Compute vectors */
443
-     foreach($this->Data as $Key => $Settings)
444
-      {
445
-       if ( $Settings["Type"] != NODE_TYPE_CENTRAL )
446
-        {
388
+     foreach($this->Data as $Key => $Settings) {
389
+       if ( $Settings["Type"] != NODE_TYPE_CENTRAL ) {
447 390
          unset($this->Data[$Key]["Vectors"]);
448 391
 
449 392
          $X1 = $Settings["X"];
450 393
          $Y1 = $Settings["Y"];
451 394
 
452 395
          /* Repulsion vectors */
453
-         foreach($this->Data as $Key2 => $Settings2)
454
-          {
455
-           if ( $Key != $Key2 )
456
-            {
396
+         foreach($this->Data as $Key2 => $Settings2) {
397
+           if ( $Key != $Key2 ) {
457 398
              $X2 = $this->Data[$Key2]["X"];
458 399
              $Y2 = $this->Data[$Key2]["Y"];
459 400
              $FreeZone = $this->Data[$Key2]["FreeZone"];
@@ -462,8 +403,7 @@  discard block
 block discarded – undo
462 403
              $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2) + 180;
463 404
 
464 405
              /* Nodes too close, repulsion occurs */
465
-             if ( $Distance < $FreeZone )
466
-              {
406
+             if ( $Distance < $FreeZone ) {
467 407
                $Force = log(pow(2,$FreeZone-$Distance));
468 408
                if ( $Force > 1 )
469 409
                 { $this->Data[$Key]["Vectors"][] = array("Type"=>"R","Angle"=>$Angle % 360,"Force"=>$Force); }
@@ -472,12 +412,9 @@  discard block
 block discarded – undo
472 412
           }
473 413
 
474 414
          /* Attraction vectors */
475
-         if ( isset($Settings["Connections"]) )
476
-          {
477
-           foreach($Settings["Connections"] as $ID => $NodeID)
478
-            {
479
-             if ( isset($this->Data[$NodeID]) )
480
-              {
415
+         if ( isset($Settings["Connections"]) ) {
416
+           foreach($Settings["Connections"] as $ID => $NodeID) {
417
+             if ( isset($this->Data[$NodeID]) ) {
481 418
                $X2 = $this->Data[$NodeID]["X"];
482 419
                $Y2 = $this->Data[$NodeID]["Y"];
483 420
                $FreeZone = $this->Data[$Key2]["FreeZone"];
@@ -499,15 +436,12 @@  discard block
 block discarded – undo
499 436
       }
500 437
 
501 438
      /* Move the nodes accoding to the vectors */
502
-     foreach($this->Data as $Key => $Settings)
503
-      {
439
+     foreach($this->Data as $Key => $Settings) {
504 440
        $X = $Settings["X"];
505 441
        $Y = $Settings["Y"];
506 442
 
507
-       if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
508
-        {
509
-         foreach($Settings["Vectors"] as $ID => $Vector)
510
-          {
443
+       if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL ) {
444
+         foreach($Settings["Vectors"] as $ID => $Vector) {
511 445
            $Type  = $Vector["Type"];
512 446
            $Force = $Vector["Force"];
513 447
            $Angle = $Vector["Angle"];
@@ -523,11 +457,9 @@  discard block
 block discarded – undo
523 457
       }
524 458
     }
525 459
 
526
-   function lastPass()
527
-    {
460
+   function lastPass() {
528 461
      /* Put everything inside the graph area */
529
-     foreach($this->Data as $Key => $Settings)
530
-      {
462
+     foreach($this->Data as $Key => $Settings) {
531 463
        $X = $Settings["X"];
532 464
        $Y = $Settings["Y"];
533 465
 
@@ -542,17 +474,13 @@  discard block
 block discarded – undo
542 474
 
543 475
      /* Dump all links */
544 476
      $Links = "";
545
-     foreach($this->Data as $Key => $Settings)
546
-      {
477
+     foreach($this->Data as $Key => $Settings) {
547 478
        $X1 = $Settings["X"];
548 479
        $Y1 = $Settings["Y"];
549 480
 
550
-       if ( isset($Settings["Connections"]) )
551
-        {
552
-         foreach ($Settings["Connections"] as $ID => $NodeID)
553
-          {
554
-           if ( isset($this->Data[$NodeID]) )
555
-            {
481
+       if ( isset($Settings["Connections"]) ) {
482
+         foreach ($Settings["Connections"] as $ID => $NodeID) {
483
+           if ( isset($this->Data[$NodeID]) ) {
556 484
              $X2 = $this->Data[$NodeID]["X"];
557 485
              $Y2 = $this->Data[$NodeID]["Y"];
558 486
 
@@ -564,28 +492,21 @@  discard block
 block discarded – undo
564 492
 
565 493
      /* Check collisions */
566 494
      $Conflicts = 0;
567
-     foreach($this->Data as $Key => $Settings)
568
-      {
495
+     foreach($this->Data as $Key => $Settings) {
569 496
        $X1 = $Settings["X"];
570 497
        $Y1 = $Settings["Y"];
571 498
 
572
-       if ( isset($Settings["Connections"]) )
573
-        {
574
-         foreach ($Settings["Connections"] as $ID => $NodeID)
575
-          {
576
-           if ( isset($this->Data[$NodeID]) )
577
-            {
499
+       if ( isset($Settings["Connections"]) ) {
500
+         foreach ($Settings["Connections"] as $ID => $NodeID) {
501
+           if ( isset($this->Data[$NodeID]) ) {
578 502
              $X2 = $this->Data[$NodeID]["X"];
579 503
              $Y2 = $this->Data[$NodeID]["Y"];
580 504
 
581
-             foreach($Links as $IDLinks => $Link)
582
-              {
505
+             foreach($Links as $IDLinks => $Link) {
583 506
                $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"];
584 507
 
585
-               if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) )
586
-                {
587
-                 if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) )
588
-                  {
508
+               if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) ) {
509
+                 if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) ) {
589 510
                    if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] )
590 511
                     { $Conflicts++; }
591 512
                   }
@@ -599,8 +520,7 @@  discard block
 block discarded – undo
599 520
     }
600 521
 
601 522
    /* Center the graph */
602
-   function center()
603
-    {
523
+   function center() {
604 524
      /* Determine the real center */
605 525
      $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
606 526
      $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
@@ -608,8 +528,7 @@  discard block
 block discarded – undo
608 528
      /* Get current boundaries */
609 529
      $XMin = $this->X2; $XMax = $this->X1;
610 530
      $YMin = $this->Y2; $YMax = $this->Y1;
611
-     foreach($this->Data as $Key => $Settings)
612
-      {
531
+     foreach($this->Data as $Key => $Settings) {
613 532
        $X = $Settings["X"];
614 533
        $Y = $Settings["Y"];
615 534
 
@@ -626,16 +545,14 @@  discard block
 block discarded – undo
626 545
      $YOffset = $TargetCenterY - $CurrentCenterY;
627 546
 
628 547
      /* Correct the points position */
629
-     foreach($this->Data as $Key => $Settings)
630
-      {
548
+     foreach($this->Data as $Key => $Settings) {
631 549
        $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
632 550
        $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
633 551
       }
634 552
     }
635 553
 
636 554
    /* Create the encoded string */
637
-   function drawSpring($Object,$Settings="")
638
-    {
555
+   function drawSpring($Object,$Settings="") {
639 556
      $this->pChartObject = $Object;
640 557
 
641 558
      $Pass			= isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
@@ -656,16 +573,14 @@  discard block
 block discarded – undo
656 573
      $this->Y2		= $Object->GraphAreaY2;
657 574
 
658 575
      $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1;
659
-     while ($Conflicts != 0 && $Jobs < $Retries )
660
-      {
576
+     while ($Conflicts != 0 && $Jobs < $Retries ) {
661 577
        $Jobs++;
662 578
 
663 579
        /* Compute the initial settings */
664 580
        $this->firstPass($Algorithm);
665 581
 
666 582
        /* Apply the vectors */
667
-       if ( $Pass > 0 ) 
668
-        {
583
+       if ( $Pass > 0 ) {
669 584
          for ($i=0; $i<=$Pass; $i++) { $this->doPass(); }
670 585
         }
671 586
 
@@ -681,24 +596,19 @@  discard block
 block discarded – undo
681 596
 
682 597
      /* Draw the connections */
683 598
      $Drawn = "";
684
-     foreach($this->Data as $Key => $Settings)
685
-      {
599
+     foreach($this->Data as $Key => $Settings) {
686 600
        $X	= $Settings["X"];
687 601
        $Y	= $Settings["Y"];
688 602
 
689
-       if ( isset($Settings["Connections"]) )
690
-        {
691
-         foreach ($Settings["Connections"] as $ID => $NodeID)
692
-          {
603
+       if ( isset($Settings["Connections"]) ) {
604
+         foreach ($Settings["Connections"] as $ID => $NodeID) {
693 605
            if ( !isset($Drawn[$Key]) )    { $Drawn[$Key] = ""; }
694 606
            if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; }
695 607
 
696
-           if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) )
697
-            {
608
+           if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) ) {
698 609
              $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]);
699 610
 
700
-             if ( $this->Links != "" )
701
-              {
611
+             if ( $this->Links != "" ) {
702 612
                if ( isset($this->Links[$Key][$NodeID]["R"]) )
703 613
                 { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"],"G"=>$this->Links[$Key][$NodeID]["G"],"B"=>$this->Links[$Key][$NodeID]["B"],"Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); }
704 614
 
@@ -711,10 +621,8 @@  discard block
 block discarded – undo
711 621
              $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
712 622
              $Drawn[$Key][$NodeID] = TRUE;
713 623
 
714
-             if ( isset($this->Links) && $this->Links != "" )
715
-              {
716
-               if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) )
717
-                {
624
+             if ( isset($this->Links) && $this->Links != "" ) {
625
+               if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) ) {
718 626
                  $Name  = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"];
719 627
                  $TxtX  = ($X2 - $X)/2 + $X;
720 628
                  $TxtY  = ($Y2 - $Y)/2 + $Y;
@@ -736,10 +644,8 @@  discard block
 block discarded – undo
736 644
       }
737 645
 
738 646
      /* Draw the quiet zones */
739
-     if ( $DrawQuietZone )
740
-      {
741
-       foreach($this->Data as $Key => $Settings)
742
-        {
647
+     if ( $DrawQuietZone ) {
648
+       foreach($this->Data as $Key => $Settings) {
743 649
          $X	 = $Settings["X"];
744 650
          $Y	 = $Settings["Y"];
745 651
          $FreeZone = $Settings["FreeZone"];
@@ -750,8 +656,7 @@  discard block
 block discarded – undo
750 656
 
751 657
 
752 658
      /* Draw the nodes */
753
-     foreach($this->Data as $Key => $Settings)
754
-      {
659
+     foreach($this->Data as $Key => $Settings) {
755 660
        $X	 = $Settings["X"];
756 661
        $Y	 = $Settings["Y"];
757 662
        $Name	 = $Settings["Name"];
@@ -761,35 +666,26 @@  discard block
 block discarded – undo
761 666
 
762 667
        $Color	 = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]);
763 668
 
764
-       if ( $Shape == NODE_SHAPE_CIRCLE )
765
-        {
669
+       if ( $Shape == NODE_SHAPE_CIRCLE ) {
766 670
          $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color);
767
-        }
768
-       elseif ( $Shape == NODE_SHAPE_TRIANGLE )
769
-        {
671
+        } elseif ( $Shape == NODE_SHAPE_TRIANGLE ) {
770 672
          $Points = "";
771 673
          $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y;
772 674
          $Points[] = cos(deg2rad(45)) * $Size + $X;  $Points[] = sin(deg2rad(45)) * $Size + $Y;
773 675
          $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y;
774 676
          $this->pChartObject->drawPolygon($Points,$Color);
775
-        }
776
-       elseif ( $Shape == NODE_SHAPE_SQUARE )
777
-        {
677
+        } elseif ( $Shape == NODE_SHAPE_SQUARE ) {
778 678
          $Offset = $Size/2; $Size = $Size / 2;
779 679
          $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color);
780 680
         }
781 681
 
782
-       if ( $Name != "" )
783
-        {
682
+       if ( $Name != "" ) {
784 683
          $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]);
785 684
 
786
-         if ( $this->Labels["Type"] == LABEL_LIGHT )
787
-          {
685
+         if ( $this->Labels["Type"] == LABEL_LIGHT ) {
788 686
            $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT;
789 687
            $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions);
790
-          }
791
-         elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
792
-          {
688
+          } elseif ( $this->Labels["Type"] == LABEL_CLASSIC ) {
793 689
            $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794 690
            $LabelOptions["DrawBox"]       = TRUE;
795 691
            $LabelOptions["BoxAlpha"]      = 50;
@@ -804,17 +700,13 @@  discard block
 block discarded – undo
804 700
       }
805 701
 
806 702
      /* Draw the vectors */
807
-     if ( $DrawVectors )
808
-      {
809
-       foreach($this->Data as $Key => $Settings)
810
-        {
703
+     if ( $DrawVectors ) {
704
+       foreach($this->Data as $Key => $Settings) {
811 705
          $X1 = $Settings["X"];
812 706
          $Y1 = $Settings["Y"];
813 707
 
814
-         if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
815
-          {
816
-           foreach($Settings["Vectors"] as $ID => $Vector)
817
-            {
708
+         if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL ) {
709
+           foreach($Settings["Vectors"] as $ID => $Vector) {
818 710
              $Type  = $Vector["Type"];
819 711
              $Force = $Vector["Force"];
820 712
              $Angle = $Vector["Angle"];
@@ -838,14 +730,12 @@  discard block
 block discarded – undo
838 730
     { return (sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1))); }
839 731
 
840 732
    /* Return the angle made by a line and the X axis */
841
-   function getAngle($X1,$Y1,$X2,$Y2)
842
-    {
733
+   function getAngle($X1,$Y1,$X2,$Y2) {
843 734
      $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent));
844 735
      if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); }
845 736
     }
846 737
 
847
-   function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4)
848
-    {
738
+   function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) {
849 739
      $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850 740
      $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
851 741
 
@@ -856,8 +746,7 @@  discard block
 block discarded – undo
856 746
      if ( $C == 0 ) { return(FALSE); }
857 747
      $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
858 748
 
859
-     if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
860
-      {
749
+     if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4)) {
861 750
        if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
862 751
         { return(TRUE); }
863 752
       }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      $this->Default["BorderG"]		= 0;
59 59
      $this->Default["BorderB"]		= 0;
60 60
      $this->Default["BorderAlpha"]	= 100;
61
-     $this->Default["Surrounding"]	= NULL;
61
+     $this->Default["Surrounding"]	= null;
62 62
      $this->Default["BackgroundR"]	= 255;
63 63
      $this->Default["BackgroundG"]	= 255;
64 64
      $this->Default["BackgroundB"]	= 255;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      $this->Labels["B"]			= 0;
80 80
      $this->Labels["Alpha"]		= 100;
81 81
 
82
-     $this->AutoComputeFreeZone         = FALSE;
82
+     $this->AutoComputeFreeZone         = false;
83 83
     }
84 84
 
85 85
    /* Set default links options */
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
      $G			= isset($Settings["G"]) ? $Settings["G"] : 0;
126 126
      $B			= isset($Settings["B"]) ? $Settings["B"] : 0;
127 127
      $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100;
128
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : NULL;
129
-     $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL;
128
+     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : null;
129
+     $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : null;
130 130
 
131 131
      $this->Links[$FromNode][$ToNode]["R"] = $R;         $this->Links[$ToNode][$FromNode]["R"] = $R;
132 132
      $this->Links[$FromNode][$ToNode]["G"] = $G;         $this->Links[$ToNode][$FromNode]["G"] = $G;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      if (isset($this->Data[$NodeID])) { return(0); }
165 165
 
166 166
      $Name		= isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
-     $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
167
+     $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : null;
168 168
 
169 169
      $R			= isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
170 170
      $G			= isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      $Shape		= isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
186 186
      $FreeZone		= isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
187 187
 
188
-     if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
188
+     if ( $Surrounding != null ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
189 189
 
190 190
      $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha;
191 191
      $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      $this->Data[$NodeID]["Size"]		= $Size;
197 197
      $this->Data[$NodeID]["Shape"]		= $Shape;
198 198
      $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
-     if ( $Connections != NULL )
199
+     if ( $Connections != null )
200 200
       {
201 201
        if ( is_array($Connections ) )
202 202
         {
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
      if ( isset($this->Data[$SourceID]["Connections"]) )
254 254
       {
255 255
        foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
256
-        { if ( $TargetID == $ConnectionID ) { return(TRUE); } }
256
+        { if ( $TargetID == $ConnectionID ) { return(true); } }
257 257
       }
258 258
      $this->Data[$SourceID]["Connections"][] = $TargetID;
259 259
     }
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                  $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366 366
                  $Weight        = $this->Data[$BiggestPartner]["Weight"];
367 367
                  $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
368
-                 $Done          = FALSE; $Tries = 0;
368
+                 $Done          = false; $Tries = 0;
369 369
                  while (!$Done && $Tries <= $Weight*2)
370 370
                   {
371 371
                    $Tries++;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
                    if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
374 374
                     {
375 375
                      $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376
-                     $Done = TRUE; 
376
+                     $Done = true; 
377 377
                     }
378 378
                   }
379 379
                  if ( !$Done )
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
      $this->MagneticForceA	= isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5;
644 644
      $this->MagneticForceR	= isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2;
645 645
      $this->RingSize		= isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
646
-     $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE;
647
-     $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
648
-     $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE;
646
+     $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : false;
647
+     $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : false;
648
+     $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : true;
649 649
      $TextPadding		= isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4;
650 650
      $Algorithm			= isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
651 651
 
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
              $X2 = $this->Data[$NodeID]["X"];
710 710
              $Y2 = $this->Data[$NodeID]["Y"];
711 711
              $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
712
-             $Drawn[$Key][$NodeID] = TRUE;
712
+             $Drawn[$Key][$NodeID] = true;
713 713
 
714 714
              if ( isset($this->Links) && $this->Links != "" )
715 715
               {
@@ -791,12 +791,12 @@  discard block
 block discarded – undo
791 791
          elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
792 792
           {
793 793
            $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794
-           $LabelOptions["DrawBox"]       = TRUE;
794
+           $LabelOptions["DrawBox"]       = true;
795 795
            $LabelOptions["BoxAlpha"]      = 50;
796 796
            $LabelOptions["BorderOffset"]  = 4;
797 797
            $LabelOptions["RoundedRadius"] = 3;
798
-           $LabelOptions["BoxRounded"]    = TRUE;
799
-           $LabelOptions["NoShadow"]      = TRUE;
798
+           $LabelOptions["BoxRounded"]    = true;
799
+           $LabelOptions["NoShadow"]      = true;
800 800
 
801 801
            $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions);
802 802
           }
@@ -849,20 +849,20 @@  discard block
 block discarded – undo
849 849
      $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850 850
      $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
851 851
 
852
-     if ( $B == 0 ) { return(FALSE); }
852
+     if ( $B == 0 ) { return(false); }
853 853
      $Xi = $A / $B;
854 854
 
855 855
      $C = ($X1 - $X2);
856
-     if ( $C == 0 ) { return(FALSE); }
856
+     if ( $C == 0 ) { return(false); }
857 857
      $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
858 858
 
859 859
      if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
860 860
       {
861 861
        if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
862
-        { return(TRUE); }
862
+        { return(true); }
863 863
       }
864 864
 
865
-      return(FALSE);   
865
+      return(false);   
866 866
     }
867 867
   }
868 868
 ?>
869 869
\ No newline at end of file
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc 5 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -13,6 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 /**
15 15
  * The structure of the general preferences form
16
+ * @param string $prefs_preset
16 17
  */
17 18
 function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) {
18 19
   $form = array();
@@ -754,6 +755,7 @@  discard block
 block discarded – undo
754 755
 
755 756
 /**
756 757
  * Perform the database updates to merge the old host into the new host
758
+ * @param string $message
757 759
  */
758 760
 function boincwork_host_merge($old_host, $new_host, &$message = NULL) {
759 761
   // Decay the average credit of the two hosts
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
       }// switch
72 72
   } else {
73 73
       $form_state['storage']['wip'] = TRUE;
74
-      if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
74
+      if (!in_array($prefs_preset, array('standard', 'maximum', 'green', 'minimum', 'custom'))) {
75 75
           if ($established) {
76 76
               $prefs_preset = 'custom';
77 77
           } else {
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
   );
142 142
   $form['hour_options'] = array(
143 143
     '#type' => 'value',
144
-    '#value' => array('0:00','1:00','2:00','3:00','4:00', 
145
-     '5:00','6:00','7:00','8:00','9:00','10:00','11:00', 
146
-     '12:00','13:00','14:00','15:00','16:00','17:00',
147
-     '18:00','19:00','20:00','21:00','22:00','23:00')
144
+    '#value' => array('0:00', '1:00', '2:00', '3:00', '4:00', 
145
+     '5:00', '6:00', '7:00', '8:00', '9:00', '10:00', '11:00', 
146
+     '12:00', '13:00', '14:00', '15:00', '16:00', '17:00',
147
+     '18:00', '19:00', '20:00', '21:00', '22:00', '23:00')
148 148
   );
149 149
   
150 150
   // Identify preference sets that are established to distinguish what has been
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), NULL, 'boinc:account-preferences-computing'),
282 282
   );
283 283
   $form['prefs']['advanced']['processor']['hour_label'] = array(
284
-    '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
284
+    '#value' => '<div class="form-item"><label>'.bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing').'</label></div>'
285 285
   );
286 286
   $form['prefs']['advanced']['processor']['start_hour'] = array(
287 287
     '#type' => 'select',
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     '#default_value' => $default['start_hour']
290 290
   );
291 291
   $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
292
-    '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
292
+    '#value' => '<span>'.bts('and', array(), NULL, 'boinc:account-preference').'</span>'
293 293
   );
294 294
   $form['prefs']['advanced']['processor']['end_hour'] = array(
295 295
     '#type' => 'select',
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     '#default_value' => $default['end_hour']
298 298
   );
299 299
   $form['prefs']['advanced']['processor']['hour_description'] = array(
300
-    '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
300
+    '#value' => '<div class="form-item slim"><div class="description">'.bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing').'</div></div>'
301 301
   );
302 302
   $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
303 303
     '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), NULL, 'boinc:account-preferences-computing'),
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     '#description' => bts('Limit the upload rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing')
455 455
   );
456 456
   $form['prefs']['advanced']['network']['hour_label'] = array(
457
-    '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
457
+    '#value' => '<div class="form-item"><label>'.bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing').'</label></div>'
458 458
   );
459 459
   $form['prefs']['advanced']['network']['net_start_hour'] = array(
460 460
     '#type' => 'select',
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
     '#default_value' => $default['net_start_hour']
463 463
   );
464 464
   $form['prefs']['advanced']['network']['hour_delimiter'] = array(
465
-    '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
465
+    '#value' => '<span>'.bts('and', array(), NULL, 'boinc:account-preference').'</span>'
466 466
   );
467 467
   $form['prefs']['advanced']['network']['net_end_hour'] = array(
468 468
     '#type' => 'select',
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     '#default_value' => $default['net_end_hour']
471 471
   );
472 472
   $form['prefs']['advanced']['network']['hour_description'] = array(
473
-    '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
473
+    '#value' => '<div class="form-item slim"><div class="description">'.bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing').'</div></div>'
474 474
   ); 
475 475
   $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
476 476
     '#title' => bts('Limit usage to', array(), NULL, 'boinc:account-preferences-computing'),
@@ -530,23 +530,23 @@  discard block
 block discarded – undo
530 530
     '#suffix' => '</li>'
531 531
   );
532 532
   $form['prefs']['form control tabs'] = array(
533
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
533
+    '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")).'</li>'
534 534
   );
535 535
   if ($venue AND $venue != 'generic') {
536 536
     global $base_path;
537
-    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
537
+    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">'. 
538 538
       l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
539 539
         array(
540
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
540
+          'query' => 'destination='.urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541 541
           'attributes' => array(
542
-            'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
-              array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
542
+            'onclick' => 'return confirm(\''.bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
+              array('@name' => $venue), NULL, 'boinc:account-preferences').'\')'
544 544
           )
545 545
         )
546
-      ) . '</li>';
546
+      ).'</li>';
547 547
   }
548 548
   $form['prefs']['view control'] = array(
549
-    '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>'
549
+    '#value' => '<li class="first alt tab">'.l('('.bts('Show comparison view', array(), NULL, 'boinc:account-preferences').')', 'account/prefs/computing/combined').'</li>'
550 550
   );
551 551
   $form['prefs']['form control tabs suffix'] = array(
552 552
     '#value' => '</ul>'
@@ -852,9 +852,9 @@  discard block
 block discarded – undo
852 852
   }
853 853
   
854 854
   $form['overview'] = array(
855
-    '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to'
855
+    '#value' => '<p>'.bts('Sometimes BOINC assigns separate identities to'
856 856
       . ' the same computer by mistake. You can correct this by merging old'
857
-      . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>'
857
+      . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge').'</p>'
858 858
       . '<p>'
859 859
       . bts('Check the computers that are the same as @name'
860 860
       . ' (created on @date at @time with computer ID @id)',
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
           '@time' => date('G:i:s T', $current_host->create_time),
865 865
           '@id' => $current_host->id,
866 866
         ),
867
-        NULL, 'boinc:account-host-merge') . '</p>',
867
+        NULL, 'boinc:account-host-merge').'</p>',
868 868
   );
869 869
   
870 870
   $options = array();
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
     '#suffix' => '</li>'
899 899
   );
900 900
   $form['prefs']['form control tabs'] = array(
901
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>'
901
+    '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}").'</li>'
902 902
   );
903 903
   
904 904
   return $form;
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
       if (count($merged) == 2) {
944 944
         $oxford_comma = '';
945 945
       }
946
-      $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
946
+      $list = implode(', ', $list).$oxford_comma.' '.$conjunction.' '.$last;
947 947
     }
948 948
     else {
949 949
       $list = $last;
@@ -1192,23 +1192,23 @@  discard block
 block discarded – undo
1192 1192
     '#suffix' => '</li>'
1193 1193
   );
1194 1194
   $form['prefs']['form control tabs'] = array(
1195
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1195
+    '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>'
1196 1196
   );
1197 1197
   if ($venue AND $venue != 'generic') {
1198 1198
     global $base_path;
1199
-    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
1199
+    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">'. 
1200 1200
       l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1201 1201
         array(
1202
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1202
+          'query' => 'destination='.urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1203 1203
           'attributes' => array(
1204
-            'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
1205
-              array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
1204
+            'onclick' => 'return confirm(\''.bts('This will remove all of your settings from the @name preference set. Are you sure?',
1205
+              array('@name' => $venue), NULL, 'boinc:account-preferences').'\')'
1206 1206
           )
1207 1207
         )
1208
-      ) . '</li>';
1208
+      ).'</li>';
1209 1209
   }
1210 1210
   $form['prefs']['view control'] = array(
1211
-      '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1211
+      '#value' => '<li class="first alt tab">'.l('('.bts('Show comparison view', array(), NULL, 'boinc:account-preferences').')', 'account/prefs/project/combined').'</li>'
1212 1212
   );
1213 1213
   $form['prefs']['form control tabs suffix'] = array(
1214 1214
     '#value' => '</ul>'
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
     
1252 1252
   foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1253 1253
     $type = key($wrapped_element);
1254
-    $element= reset($wrapped_element);
1254
+    $element = reset($wrapped_element);
1255 1255
     boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']);
1256 1256
   }
1257 1257
 }
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
     $names = array();
1478 1478
     foreach ($languages as $langcode => $item) {
1479 1479
       $name = t($item->name);
1480
-      $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1480
+      $names[check_plain($langcode)] = check_plain($name.($item->native != $name ? ' ('.$item->native.')' : ''));
1481 1481
     }
1482 1482
     $form['locale'] = array(
1483 1483
       '#type' => 'fieldset',
@@ -1502,20 +1502,20 @@  discard block
 block discarded – undo
1502 1502
   // Avatar options
1503 1503
   $form['gravatar'] = array(
1504 1504
     '#type' => 'item',
1505
-    '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'),
1505
+    '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/'.$account->mail), NULL, 'boinc:account-preferences-community'),
1506 1506
     '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'),
1507 1507
   );
1508 1508
   if (user_access('disable own gravatar', $account)) {
1509 1509
     $form['gravatar'] = array(
1510 1510
       '#type' => 'checkbox',
1511
-      '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'),
1511
+      '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/'.$account->mail), NULL, 'boinc:account-preferences-community'),
1512 1512
       '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'),
1513 1513
       '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1514 1514
       '#disabled' => !empty($account->picture),
1515 1515
     );
1516 1516
   }
1517 1517
   $form['gravatar']['#weight'] = 15;
1518
-  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>';
1518
+  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">'.bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community').'</a></legend>';
1519 1519
   // Upload an avatar (pulled from profile_node_form):
1520 1520
   if (!empty($profile_form['field_image'])) {
1521 1521
     $form['field_image'] = $profile_form['field_image'];
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
   );
1551 1551
   // Can't have a typical Drupal form suffix on a select box?
1552 1552
   $form['forums']['comments_per_page_suffix'] = array(
1553
-    '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>'
1553
+    '#value' => '<span>'.bts('comments per page', array(), NULL, 'boinc:account-preferences-community').'</span>'
1554 1554
   );
1555 1555
   $form['forums']['comments_order'] = array(
1556 1556
     '#type' => 'select',
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
     '#weight' => 1002,
1604 1604
   );
1605 1605
   $form['form control tabs'] = array(
1606
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1606
+    '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>',
1607 1607
     '#weight' => 1003,
1608 1608
   );
1609 1609
   $form['form control tabs suffix'] = array(
@@ -1659,10 +1659,10 @@  discard block
 block discarded – undo
1659 1659
     if ($user->language != $edit['language']) {
1660 1660
       global $base_url;
1661 1661
       if ($edit['language'] != language_default('language')) {
1662
-        $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q'];
1662
+        $form_state['redirect'] = $base_url.'/'.$edit['language'].'/'.$_GET['q'];
1663 1663
       }
1664 1664
       else {
1665
-        $form_state['redirect'] = $base_url . '/' . $_GET['q'];
1665
+        $form_state['redirect'] = $base_url.'/'.$_GET['q'];
1666 1666
       }
1667 1667
     }
1668 1668
   }
@@ -1752,7 +1752,7 @@  discard block
 block discarded – undo
1752 1752
       $form['ignoreblock']['delete'][$ignored_user['iuid']] = array(
1753 1753
         '#value' => l(
1754 1754
           bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'),
1755
-          'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'],
1755
+          'account/prefs/privacy/ignore_user/remove/'.$ignored_user['iuid'],
1756 1756
           array()
1757 1757
         ),
1758 1758
       );
@@ -1803,7 +1803,7 @@  discard block
 block discarded – undo
1803 1803
     '#suffix' => '</li>'
1804 1804
   );
1805 1805
   $form['prefs']['form control tabs'] = array(
1806
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1806
+    '#value' => '<li class="tab">'.l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']).'</li>'
1807 1807
   );
1808 1808
   $form['prefs']['form control tabs suffix'] = array(
1809 1809
     '#value' => '</ul>'
@@ -1940,7 +1940,7 @@  discard block
 block discarded – undo
1940 1940
 function boincwork_selectapp_form_submit($form, &$form_state) {
1941 1941
   $myargs = arg();
1942 1942
   array_pop($myargs);
1943
-  $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value'];
1943
+  $newpath = implode('/', $myargs).'/'.$form['selectapp']['#value'];
1944 1944
   $form_state['redirect'] = $newpath;
1945 1945
 }
1946 1946
 
Please login to merge, or discard this patch.
Braces   +17 added lines, -34 removed lines patch added patch discarded remove patch
@@ -127,8 +127,7 @@  discard block
 block discarded – undo
127 127
         if (isset($prefs[$name]['@value'])) {
128 128
           $default[$name] = $prefs[$name]['@value'];
129 129
         }
130
-      }
131
-      else {
130
+      } else {
132 131
         $default[$name] = $prefs[$name];
133 132
       }
134 133
     }
@@ -655,8 +654,7 @@  discard block
 block discarded – undo
655 654
   // Save the preset selection (or lack thereof)
656 655
   if (!$preset OR $preset == 'custom') {
657 656
     $prefs['preset'] = 'custom';
658
-  }
659
-  else {
657
+  } else {
660 658
     $prefs['preset'] = $preset;
661 659
   }
662 660
   
@@ -671,8 +669,7 @@  discard block
 block discarded – undo
671 669
   if (!$result) {
672 670
     watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysql_error()), WATCHDOG_ERROR);
673 671
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
674
-  }
675
-  elseif (!drupal_get_messages('status', FALSE)) {
672
+  } elseif (!drupal_get_messages('status', FALSE)) {
676 673
     // Show this message if the set wasn't created automatically (in which case
677 674
     // there is a message tailored to that) {
678 675
     drupal_set_message(t('Your preferences have been updated.
@@ -927,8 +924,7 @@  discard block
 block discarded – undo
927 924
     if (boincwork_host_merge($old_host, $current_host, $message)) {
928 925
       $merged[$old_host->id] = $old_host->id;
929 926
       $current_host = boincwork_host_get_info($current_host_id);
930
-    }
931
-    else {
927
+    } else {
932 928
       $errors[$old_host->id] = $message;
933 929
     }
934 930
   }
@@ -944,8 +940,7 @@  discard block
 block discarded – undo
944 940
         $oxford_comma = '';
945 941
       }
946 942
       $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
947
-    }
948
-    else {
943
+    } else {
949 944
       $list = $last;
950 945
     }
951 946
     if (count($merged) == 1) {
@@ -956,8 +951,7 @@  discard block
 block discarded – undo
956 951
           '@id' => $current_host_id
957 952
         ),
958 953
         NULL, 'boinc:account-host-merge'));
959
-    }
960
-    else {
954
+    } else {
961 955
       drupal_set_message(bts(
962 956
         'Computers @old_ids have been merged successfully into @id.',
963 957
         array(
@@ -1023,11 +1017,9 @@  discard block
 block discarded – undo
1023 1017
     if ($account->boincuser_default_pref_set == $venue) {
1024 1018
       $venue_is_default = TRUE;
1025 1019
     }
1026
-  }
1027
-  elseif (!$venue OR $venue == 'generic') {
1020
+  } elseif (!$venue OR $venue == 'generic') {
1028 1021
     $venue_is_default = TRUE;
1029
-  }
1030
-  else {
1022
+  } else {
1031 1023
     $venue_is_default = FALSE;
1032 1024
   }
1033 1025
   
@@ -1047,8 +1039,7 @@  discard block
 block discarded – undo
1047 1039
         if (isset($prefs[$name]['@value'])) {
1048 1040
           $default[$name] = $prefs[$name]['@value'];
1049 1041
         }
1050
-      }
1051
-      else {
1042
+      } else {
1052 1043
         $default[$name] = $prefs[$name];
1053 1044
       }
1054 1045
     }
@@ -1232,16 +1223,13 @@  discard block
 block discarded – undo
1232 1223
       foreach ($element as $ordered_element) {
1233 1224
         if (isset($ordered_element['@position'])) {
1234 1225
           $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
1235
-        }
1236
-        else {
1226
+        } else {
1237 1227
           $unordered_array[] = array($type => $ordered_element);
1238 1228
         }
1239 1229
       }
1240
-    }
1241
-    elseif (isset($element['@position'])) {
1230
+    } elseif (isset($element['@position'])) {
1242 1231
       $ordered_array[$element['@position']] = array($type => $element);
1243
-    }
1244
-    else {
1232
+    } else {
1245 1233
       $unordered_array[] = array($type => $element);
1246 1234
     }
1247 1235
   }
@@ -1356,8 +1344,7 @@  discard block
 block discarded – undo
1356 1344
   // Update the user's default preference set
1357 1345
   if ($edit['default_set']['default_venue']) {
1358 1346
     boincwork_set_default_venue($venue);
1359
-  }
1360
-  elseif ($venue == $account->boincuser_default_pref_set) {
1347
+  } elseif ($venue == $account->boincuser_default_pref_set) {
1361 1348
     // User has cleared out the default venue setting
1362 1349
     boincwork_set_default_venue();
1363 1350
   }
@@ -1365,8 +1352,7 @@  discard block
 block discarded – undo
1365 1352
   if (!$result) {
1366 1353
     watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysql_error()), WATCHDOG_ERROR);
1367 1354
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
1368
-  }
1369
-  elseif (!drupal_get_messages('status', FALSE)) {
1355
+  } elseif (!drupal_get_messages('status', FALSE)) {
1370 1356
     // Show this message if the set wasn't created automatically (in which case
1371 1357
     // there is a message tailored to that)
1372 1358
     drupal_set_message(t('Your preferences have been updated.
@@ -1519,8 +1505,7 @@  discard block
 block discarded – undo
1519 1505
   // Upload an avatar (pulled from profile_node_form):
1520 1506
   if (!empty($profile_form['field_image'])) {
1521 1507
     $form['field_image'] = $profile_form['field_image'];
1522
-  }
1523
-  else {
1508
+  } else {
1524 1509
     $form['field_image'] = array(
1525 1510
       '#value' => '<div class="form-item">'
1526 1511
         . '<label class="placeholder">'
@@ -1660,8 +1645,7 @@  discard block
 block discarded – undo
1660 1645
       global $base_url;
1661 1646
       if ($edit['language'] != language_default('language')) {
1662 1647
         $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q'];
1663
-      }
1664
-      else {
1648
+      } else {
1665 1649
         $form_state['redirect'] = $base_url . '/' . $_GET['q'];
1666 1650
       }
1667 1651
     }
@@ -1832,8 +1816,7 @@  discard block
 block discarded – undo
1832 1816
       $row[] = drupal_render($form['ignoreblock']['delete'][$key]);
1833 1817
       $rows[] = $row;
1834 1818
     }
1835
-  }
1836
-  else {
1819
+  } else {
1837 1820
     $rows[] = array(
1838 1821
       array(
1839 1822
         'data' => bts('You have not added any users to your Ignore List.', array(), NULL, 'boinc:ignore-user-list'),
Please login to merge, or discard this patch.
Indentation   +917 added lines, -917 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
  * The structure of the general preferences form
16 16
  */
17 17
 function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) {
18
-  $form = array();
19
-  $prefs = null;
20
-  $established = TRUE;
18
+    $form = array();
19
+    $prefs = null;
20
+    $established = TRUE;
21 21
   
22
-  // Enable AHAH form support for dynamically updating content based on preset
23
-  ahah_helper_register($form, $form_state);
22
+    // Enable AHAH form support for dynamically updating content based on preset
23
+    ahah_helper_register($form, $form_state);
24 24
   
25
-  if (!$prefs_preset) {
25
+    if (!$prefs_preset) {
26 26
     if (isset($form_state['storage']['prefs']['preset'])) {
27
-      $prefs_preset = $form_state['storage']['prefs']['preset'];
27
+        $prefs_preset = $form_state['storage']['prefs']['preset'];
28 28
     }
29 29
     
30 30
     // Load preferences from BOINC account
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     
33 33
     // Take note if this is not an established preference set on the account
34 34
     if (isset($prefs['@attributes']['cleared'])) {
35
-      $established = FALSE;
35
+        $established = FALSE;
36 36
     }
37 37
     
38 38
     // Determine if a preset is selected or if these are custom settings
@@ -47,45 +47,45 @@  discard block
 block discarded – undo
47 47
             $prefs_preset = $prefs['preset']['@value'];
48 48
         }
49 49
     }// if !$prefs_preset
50
-  }
51
-  // Extract mod_time tag if present, because it will be erased with
52
-  // boincwork_get_preset_prefs() below.
53
-  $mod_time = null;
54
-  if (isset($prefs['mod_time']['@value'])) {
55
-      $mod_time = $prefs['mod_time']['@value'];
56
-  }
50
+    }
51
+    // Extract mod_time tag if present, because it will be erased with
52
+    // boincwork_get_preset_prefs() below.
53
+    $mod_time = null;
54
+    if (isset($prefs['mod_time']['@value'])) {
55
+        $mod_time = $prefs['mod_time']['@value'];
56
+    }
57 57
 
58
-  if (isset($form_state['storage']['wip'])) {
59
-      switch ($prefs_preset) {
60
-      case 'standard':
58
+    if (isset($form_state['storage']['wip'])) {
59
+        switch ($prefs_preset) {
60
+        case 'standard':
61 61
       case 'maximum':
62 62
       case 'green':
63 63
       case 'minimum':
64 64
           $prefs = boincwork_get_preset_prefs($prefs_preset);
65
-          break;
66
-      case 'custom':
65
+            break;
66
+        case 'custom':
67 67
       default:
68 68
           // Just keeps prefs as they are
69 69
           unset($prefs['preset']);
70
-          break;
71
-      }// switch
72
-  } else {
73
-      $form_state['storage']['wip'] = TRUE;
74
-      if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75
-          if ($established) {
76
-              $prefs_preset = 'custom';
77
-          } else {
78
-              $prefs_preset = 'standard';
79
-              $prefs = boincwork_get_preset_prefs($prefs_preset);
80
-          }// if $established
81
-      }// if $prefs_preset
82
-  }// if WIP
83
-  
84
-  // This set of preferences is used in the form if no preferences
85
-  // have been set above, in variable $prefs.
86
-  require_boinc(array('db', 'prefs'));
87
-  $disk_space_config = get_disk_space_config();
88
-  $default = array(
70
+            break;
71
+        }// switch
72
+    } else {
73
+        $form_state['storage']['wip'] = TRUE;
74
+        if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75
+            if ($established) {
76
+                $prefs_preset = 'custom';
77
+            } else {
78
+                $prefs_preset = 'standard';
79
+                $prefs = boincwork_get_preset_prefs($prefs_preset);
80
+            }// if $established
81
+        }// if $prefs_preset
82
+    }// if WIP
83
+  
84
+    // This set of preferences is used in the form if no preferences
85
+    // have been set above, in variable $prefs.
86
+    require_boinc(array('db', 'prefs'));
87
+    $disk_space_config = get_disk_space_config();
88
+    $default = array(
89 89
     'preset' => $prefs_preset,
90 90
     // Processing...
91 91
     'run_on_batteries' => 0,
@@ -120,385 +120,385 @@  discard block
 block discarded – undo
120 120
     'daily_xfer_limit_mb' => 0,
121 121
     'daily_xfer_period_days' => 0,
122 122
     'dont_verify_images' => 0
123
-  );
124
-  foreach ($default as $name => $value) {
123
+    );
124
+    foreach ($default as $name => $value) {
125 125
     if (isset($prefs[$name])) {
126
-      if (is_array($prefs[$name])) {
126
+        if (is_array($prefs[$name])) {
127 127
         if (isset($prefs[$name]['@value'])) {
128
-          $default[$name] = $prefs[$name]['@value'];
128
+            $default[$name] = $prefs[$name]['@value'];
129 129
         }
130
-      }
131
-      else {
130
+        }
131
+        else {
132 132
         $default[$name] = $prefs[$name];
133
-      }
133
+        }
134
+    }
134 135
     }
135
-  }
136 136
 
137
-  // Standard option sets
138
-  $form['boolean_options'] = array(
137
+    // Standard option sets
138
+    $form['boolean_options'] = array(
139 139
     '#type' => 'value',
140 140
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
141
-  );
142
-  $form['hour_options'] = array(
141
+    );
142
+    $form['hour_options'] = array(
143 143
     '#type' => 'value',
144 144
     '#value' => array('0:00','1:00','2:00','3:00','4:00', 
145
-     '5:00','6:00','7:00','8:00','9:00','10:00','11:00', 
146
-     '12:00','13:00','14:00','15:00','16:00','17:00',
147
-     '18:00','19:00','20:00','21:00','22:00','23:00')
148
-  );
149
-  
150
-  // Identify preference sets that are established to distinguish what has been
151
-  // saved to the database from what is just showing default values
152
-  $form['#established'] = $established;
145
+        '5:00','6:00','7:00','8:00','9:00','10:00','11:00', 
146
+        '12:00','13:00','14:00','15:00','16:00','17:00',
147
+        '18:00','19:00','20:00','21:00','22:00','23:00')
148
+    );
149
+  
150
+    // Identify preference sets that are established to distinguish what has been
151
+    // saved to the database from what is just showing default values
152
+    $form['#established'] = $established;
153 153
    
154
-  // Set up the preference container for AHAH
155
-  $form['prefs'] = array(
154
+    // Set up the preference container for AHAH
155
+    $form['prefs'] = array(
156 156
     '#title' => '',
157 157
     '#type' => 'fieldset',
158 158
     '#prefix' => '<div id="prefs-wrapper">', // This is our wrapper div.
159 159
     '#attributes' => array('class' => 'ahah-container'),
160 160
     '#suffix' => '</div>',
161 161
     '#tree'   => TRUE
162
-  );
163
-  //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
162
+    );
163
+    //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
164 164
   
165
-  // Hidden elements
166
-  $form['prefs']['modified'] = array(
165
+    // Hidden elements
166
+    $form['prefs']['modified'] = array(
167 167
     '#type' => 'hidden',
168 168
     '#value' => $mod_time
169
-  );
170
-  $form['prefs']['venue'] = array(
169
+    );
170
+    $form['prefs']['venue'] = array(
171 171
     '#type' => 'hidden',
172 172
     '#value' => $venue
173
-  );
173
+    );
174 174
   
175
-  $form['prefs']['separator_top'] = array(
175
+    $form['prefs']['separator_top'] = array(
176 176
     '#value' => '<div class="separator"></div>'
177
-  );
177
+    );
178 178
   
179
-  // Simplified selectors
180
-  $form['prefs']['preset'] = array(
181
-      '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'),
179
+    // Simplified selectors
180
+    $form['prefs']['preset'] = array(
181
+        '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'),
182 182
     '#type' => 'radios',
183 183
     '#description' => ' ',
184 184
     '#options' => array(
185
-      'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'),
186
-      'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'),
187
-      'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'),
188
-      'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'),
189
-      'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset')
185
+        'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'),
186
+        'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'),
187
+        'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'),
188
+        'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'),
189
+        'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset')
190 190
     ),
191 191
     '#prefix' => '<div class="simple-form-controls">',
192 192
     '#suffix' => '</div>',
193 193
     '#default_value' => $default['preset'],
194 194
     '#ahah' => array(
195
-      'event' => 'change',
196
-      'path' => ahah_helper_path(array('prefs')),
197
-      'wrapper' => 'prefs-wrapper'
195
+        'event' => 'change',
196
+        'path' => ahah_helper_path(array('prefs')),
197
+        'wrapper' => 'prefs-wrapper'
198 198
     )
199
-  );
200
-  $form['prefs']['select preset'] = array(
199
+    );
200
+    $form['prefs']['select preset'] = array(
201 201
     '#type'  => 'submit',
202 202
     '#value' => bts('Update preset', array(), NULL, 'boinc:account-preferences-preset'),
203 203
     '#submit' => array('ahah_helper_generic_submit'),
204 204
     // The 'no-js' class only displays this button if javascript is disabled
205 205
     '#attributes' => array('class' => 'no-js'),
206
-  );
206
+    );
207 207
   
208
-  // Advanced preferences
209
-  $form['prefs']['advanced'] = array(
208
+    // Advanced preferences
209
+    $form['prefs']['advanced'] = array(
210 210
     '#title' => bts('Advanced settings', array(), NULL, 'boinc:account-preferences-option'),
211 211
     '#type' => 'fieldset',
212 212
     '#description' => '',
213 213
     '#collapsible' => TRUE,
214 214
     '#collapsed' => !$advanced,
215 215
     '#attributes' => array('class' => 'advanced-settings'),
216
-  );
216
+    );
217 217
   
218
-  // Processing preferences
218
+    // Processing preferences
219 219
   
220
-  $form['prefs']['advanced']['anchor'] = array(
220
+    $form['prefs']['advanced']['anchor'] = array(
221 221
     '#value' => '<a name="advanced"></a>'
222
-  );
222
+    );
223 223
   
224
-  $form['prefs']['advanced']['separator_top'] = array(
224
+    $form['prefs']['advanced']['separator_top'] = array(
225 225
     '#value' => '<div class="separator"></div>'
226
-  );
226
+    );
227 227
   
228
-  $form['prefs']['advanced']['processor'] = array(
228
+    $form['prefs']['advanced']['processor'] = array(
229 229
     '#title' => bts('Processor usage', array(), NULL, 'boinc:account-preferences-computing'),
230 230
     '#type' => 'fieldset',
231 231
     '#description' => '',
232 232
     '#collapsible' => FALSE,
233 233
     '#collapsed' => FALSE
234
-  );
235
-  $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
234
+    );
235
+    $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
236 236
     '#title' => bts('Suspend when computer is on battery?', array(), NULL, 'boinc:account-preferences-computing'),
237 237
     '#type' => 'radios',
238 238
     '#description' => bts('Suspends computing on portables when running on battery power.', array(), NULL, 'boinc:account-preferences-computing'),
239 239
     '#options' => $form['boolean_options']['#value'],
240 240
     '#attributes' => array('class' => 'fancy'),
241 241
     '#default_value' => ($default['run_on_batteries']) ? 0 : 1 // intentional inversion of setting
242
-  );
243
-  $form['prefs']['advanced']['processor']['run_if_user_active'] = array(
242
+    );
243
+    $form['prefs']['advanced']['processor']['run_if_user_active'] = array(
244 244
     '#title' => bts('Suspend when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'),
245 245
     '#type' => 'radios',
246 246
     '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'),
247 247
     '#options' => $form['boolean_options']['#value'],
248 248
     '#attributes' => array('class' => 'fancy'),
249 249
     '#default_value' => ($default['run_if_user_active']) ? 0 : 1 // intentional inversion of setting
250
-  );
251
-  $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array(
250
+    );
251
+    $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array(
252 252
     '#title' => bts('Suspend GPU computing when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'),
253 253
     '#type' => 'radios',
254 254
     '#description' => bts("Suspends GPU computing when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'),
255 255
     '#options' => $form['boolean_options']['#value'],
256 256
     '#attributes' => array('class' => 'fancy'),
257 257
     '#default_value' => ($default['run_gpu_if_user_active']) ? 0 : 1 // intentional inversion of setting
258
-  );
259
-  $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
260
-      '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
258
+    );
259
+    $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
260
+        '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
261 261
     '#type' => 'textfield',
262 262
     '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
263 263
     '#default_value' => $default['idle_time_to_run'],
264 264
     '#size' => 1,
265 265
     '#description' => bts('This determines when the computer is considered "in use".', array(), NULL, 'boinc:account-preferences-computing')
266
-  );
267
-  $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array(
266
+    );
267
+    $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array(
268 268
     '#title' => bts('Suspend when no mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
269 269
     '#type' => 'textfield',
270 270
     '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
271 271
     '#default_value' => $default['suspend_if_no_recent_input'],
272 272
     '#size' => 1,
273 273
     '#description' => bts('This allows some computers to enter low-power mode when not in use.', array(), NULL, 'boinc:account-preferences-computing')
274
-  );
275
-  $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array(
274
+    );
275
+    $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array(
276 276
     '#title' => bts('Suspend when non-BOINC CPU usage is above', array(), NULL, 'boinc:account-preferences-computing'),
277 277
     '#type' => 'textfield',
278 278
     '#field_suffix' => '%',
279 279
     '#default_value' => $default['suspend_cpu_usage'],
280 280
     '#size' => 1,
281 281
     '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), NULL, 'boinc:account-preferences-computing'),
282
-  );
283
-  $form['prefs']['advanced']['processor']['hour_label'] = array(
282
+    );
283
+    $form['prefs']['advanced']['processor']['hour_label'] = array(
284 284
     '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
285
-  );
286
-  $form['prefs']['advanced']['processor']['start_hour'] = array(
285
+    );
286
+    $form['prefs']['advanced']['processor']['start_hour'] = array(
287 287
     '#type' => 'select',
288 288
     '#options' => $form['hour_options']['#value'],
289 289
     '#default_value' => $default['start_hour']
290
-  );
291
-  $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
290
+    );
291
+    $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
292 292
     '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
293
-  );
294
-  $form['prefs']['advanced']['processor']['end_hour'] = array(
293
+    );
294
+    $form['prefs']['advanced']['processor']['end_hour'] = array(
295 295
     '#type' => 'select',
296 296
     '#options' => $form['hour_options']['#value'],
297 297
     '#default_value' => $default['end_hour']
298
-  );
299
-  $form['prefs']['advanced']['processor']['hour_description'] = array(
298
+    );
299
+    $form['prefs']['advanced']['processor']['hour_description'] = array(
300 300
     '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
301
-  );
302
-  $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
301
+    );
302
+    $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
303 303
     '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), NULL, 'boinc:account-preferences-computing'),
304 304
     '#type' => 'radios',
305 305
     '#options' => $form['boolean_options']['#value'],
306 306
     '#attributes' => array('class' => 'fancy'),
307 307
     '#default_value' => $default['leave_apps_in_memory'],
308 308
     '#description' => bts('If "Yes", suspended tasks stay in memory, and resume with no work lost. If "No", suspended tasks are removed from memory, and resume from their last checkpoint.', array(), NULL, 'boinc:account-preferences-computing')
309
-  );
310
-  $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array(
309
+    );
310
+    $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array(
311 311
     '#title' => bts('Switch between tasks every', array(), NULL, 'boinc:account-preferences-computing'),
312 312
     '#type' => 'textfield',
313 313
     '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
314 314
     '#default_value' => $default['cpu_scheduling_period_minutes'],
315 315
     '#size' => 1,
316 316
     '#description' => bts('If you run several projects, BOINC may switch between them this often.', array(), NULL, 'boinc:account-preferences-computing')
317
-  );
318
-  $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array(
317
+    );
318
+    $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array(
319 319
     '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'),
320 320
     '#type' => 'textfield',
321 321
     '#field_suffix' => bts('% of the processors', array(), NULL, 'boinc:account-preferences-computing'),
322 322
     '#default_value' => $default['max_ncpus_pct'],
323 323
     '#size' => 1,
324 324
     '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.', array(), NULL, 'boinc:account-preferences-computing'),
325
-  );
326
-  $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array(
325
+    );
326
+    $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array(
327 327
     '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'),
328 328
     '#type' => 'textfield',
329 329
     '#field_suffix' => bts('% of the CPU time', array(), NULL, 'boinc:account-preferences-computing'),
330 330
     '#default_value' => $default['cpu_usage_limit'],
331 331
     '#size' => 1,
332 332
     '#description' => bts('Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.', array(), NULL, 'boinc:account-preferences-computing')
333
-  );
333
+    );
334 334
   
335
-  // Disk and memory preferences
336
-  $form['prefs']['advanced']['storage'] = array(
335
+    // Disk and memory preferences
336
+    $form['prefs']['advanced']['storage'] = array(
337 337
     '#title' => bts('Disk and memory usage', array(), NULL, 'boinc:account-preferences-computing'),
338 338
     '#type' => 'fieldset',
339 339
     '#description' => '',
340 340
     '#collapsible' => FALSE,
341 341
     '#collapsed' => FALSE
342
-  );
343
-  $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
342
+    );
343
+    $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
344 344
     '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'),
345 345
     '#type' => 'textfield',
346 346
     '#field_suffix' => 'GB',
347 347
     '#default_value' => $default['disk_max_used_gb'],
348 348
     '#size' => 1,
349 349
     '#description' => bts('Limit the total amount of disk space used by BOINC.', array(), NULL, 'boinc:account-preferences-computing'),
350
-  ); 
351
-  $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array(
350
+    ); 
351
+    $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array(
352 352
     '#title' => bts('Disk: leave at least', array(), NULL, 'boinc:account-preferences-computing'),
353 353
     '#type' => 'textfield',
354 354
     '#field_suffix' => 'GB free',
355 355
     '#default_value' => $default['disk_min_free_gb'],
356 356
     '#size' => 1,
357 357
     '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.', array(), NULL, 'boinc:account-preferences-computing'),
358
-  );
359
-  $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array(
358
+    );
359
+    $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array(
360 360
     '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'),
361 361
     '#type' => 'textfield',
362 362
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
363 363
     '#default_value' => $default['disk_max_used_pct'],
364 364
     '#size' => 1,
365 365
     '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.', array(), NULL, 'boinc:account-preferences-computing')
366
-  ); 
367
-  $form['prefs']['advanced']['storage']['disk_interval'] = array(
366
+    ); 
367
+    $form['prefs']['advanced']['storage']['disk_interval'] = array(
368 368
     '#title' => bts('Request tasks to checkpoint at most every', array(), NULL, 'boinc:account-preferences-computing'),
369 369
     '#type' => 'textfield',
370 370
     '#field_suffix' => bts('seconds', array(), NULL, 'boinc:unit-of-time'),
371 371
     '#default_value' => $default['disk_interval'],
372 372
     '#size' => 1,
373 373
     '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.', array(), NULL, 'boinc:account-preferences-computing')
374
-  );
375
-  $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array(
374
+    );
375
+    $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array(
376 376
     '#title' => bts('Page/swap file: use at most', array(), NULL, 'boinc:account-preferences-computing'),
377 377
     '#type' => 'textfield',
378 378
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
379 379
     '#default_value' => $default['vm_max_used_pct'],
380 380
     '#size' => 1,
381 381
     '#description' => bts('Limit the swap space (page file) used by BOINC.', array(), NULL, 'boinc:account-preferences-computing')
382
-  );
383
-  $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array(
382
+    );
383
+    $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array(
384 384
     '#title' => bts('Memory: when computer is in use, use at most', array(), NULL, 'boinc:account-preferences-computing'),
385 385
     '#type' => 'textfield',
386 386
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
387 387
     '#default_value' => $default['ram_max_used_busy_pct'],
388 388
     '#size' => 1,
389 389
     '#description' => bts("Limit the memory used by BOINC when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing')
390
-  );
391
-  $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array(
390
+    );
391
+    $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array(
392 392
     '#title' => bts('Memory: when computer is not in use, use at most', array(), NULL, 'boinc:account-preferences-computing'),
393 393
     '#type' => 'textfield',
394 394
     '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
395 395
     '#default_value' => $default['ram_max_used_idle_pct'],
396 396
     '#size' => 1,
397 397
     '#description' => bts("Limit the memory used by BOINC when you're not using the computer.", array(), NULL, 'boinc:account-preferences-computing')
398
-  );
398
+    );
399 399
   
400
-  // Network preferences
401
-  $form['prefs']['advanced']['network'] = array(
400
+    // Network preferences
401
+    $form['prefs']['advanced']['network'] = array(
402 402
     '#title' => bts('Network usage', array(), NULL, 'boinc:account-preferences-computing'),
403 403
     '#type' => 'fieldset',
404 404
     '#description' => '',
405 405
     '#collapsible' => FALSE,
406 406
     '#collapsed' => FALSE
407
-  );
408
-  $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
407
+    );
408
+    $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
409 409
     '#title' => bts('Store at least', array(), NULL, 'boinc:account-preferences-computing'),
410 410
     '#type' => 'textfield',
411 411
     '#field_suffix' => bts('days of work', array(), NULL, 'boinc:account-preferences-computing'),
412 412
     '#default_value' => $default['work_buf_min_days'],
413 413
     '#size' => 1,
414 414
     '#description' => bts('Store at least enough tasks to keep the computer busy for this long.', array(), NULL, 'boinc:account-preferences-computing')
415
-  ); 
416
-  $form['prefs']['advanced']['network']['work_buf_additional_days'] = array(
415
+    ); 
416
+    $form['prefs']['advanced']['network']['work_buf_additional_days'] = array(
417 417
     '#title' => bts('Store up to an additional', array(), NULL, 'boinc:account-preferences-computing'),
418 418
     '#type' => 'textfield',
419 419
     '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'),
420 420
     '#default_value' => $default['work_buf_additional_days'],
421 421
     '#size' => 1,
422 422
     '#description' => bts('Store additional tasks above the minimum level.  Determines how much work is requested when contacting a project.', array(), NULL, 'boinc:account-preferences-computing')
423
-  ); 
424
-  $form['prefs']['advanced']['network']['confirm_before_connecting'] = array(
423
+    ); 
424
+    $form['prefs']['advanced']['network']['confirm_before_connecting'] = array(
425 425
     '#title' => bts('Confirm before connecting to Internet?', array(), NULL, 'boinc:account-preferences-computing'),
426 426
     '#type' => 'radios',
427 427
     '#options' => $form['boolean_options']['#value'],
428 428
     '#attributes' => array('class' => 'fancy'),
429 429
     '#default_value' => $default['confirm_before_connecting'],
430 430
     '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing')
431
-  ); 
432
-  $form['prefs']['advanced']['network']['hangup_if_dialed'] = array(
431
+    ); 
432
+    $form['prefs']['advanced']['network']['hangup_if_dialed'] = array(
433 433
     '#title' => bts('Disconnect when done?', array(), NULL, 'boinc:account-preferences-computing'),
434 434
     '#type' => 'radios',
435 435
     '#options' => $form['boolean_options']['#value'],
436 436
     '#attributes' => array('class' => 'fancy'),
437 437
     '#default_value' => $default['hangup_if_dialed'],
438 438
     '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing')
439
-  );
440
-  $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array(
439
+    );
440
+    $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array(
441 441
     '#title' => bts('Limit download rate to', array(), NULL, 'boinc:account-preferences-computing'),
442 442
     '#type' => 'textfield',
443 443
     '#field_suffix' => 'Kbytes/sec',
444 444
     '#default_value' => $default['max_bytes_sec_down']/1000,
445 445
     '#size' => 1,
446 446
     '#description' => bts('Limit the download rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing')
447
-  ); 
448
-  $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array(
447
+    ); 
448
+    $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array(
449 449
     '#title' => bts('Limit upload rate to', array(), NULL, 'boinc:account-preferences-computing'),
450 450
     '#type' => 'textfield',
451 451
     '#field_suffix' => 'Kbytes/sec',
452 452
     '#default_value' => $default['max_bytes_sec_up']/1000,
453 453
     '#size' => 1,
454 454
     '#description' => bts('Limit the upload rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing')
455
-  );
456
-  $form['prefs']['advanced']['network']['hour_label'] = array(
455
+    );
456
+    $form['prefs']['advanced']['network']['hour_label'] = array(
457 457
     '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
458
-  );
459
-  $form['prefs']['advanced']['network']['net_start_hour'] = array(
458
+    );
459
+    $form['prefs']['advanced']['network']['net_start_hour'] = array(
460 460
     '#type' => 'select',
461 461
     '#options' => $form['hour_options']['#value'],
462 462
     '#default_value' => $default['net_start_hour']
463
-  );
464
-  $form['prefs']['advanced']['network']['hour_delimiter'] = array(
463
+    );
464
+    $form['prefs']['advanced']['network']['hour_delimiter'] = array(
465 465
     '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
466
-  );
467
-  $form['prefs']['advanced']['network']['net_end_hour'] = array(
466
+    );
467
+    $form['prefs']['advanced']['network']['net_end_hour'] = array(
468 468
     '#type' => 'select',
469 469
     '#options' => $form['hour_options']['#value'],
470 470
     '#default_value' => $default['net_end_hour']
471
-  );
472
-  $form['prefs']['advanced']['network']['hour_description'] = array(
471
+    );
472
+    $form['prefs']['advanced']['network']['hour_description'] = array(
473 473
     '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
474
-  ); 
475
-  $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
474
+    ); 
475
+    $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
476 476
     '#title' => bts('Limit usage to', array(), NULL, 'boinc:account-preferences-computing'),
477 477
     '#type' => 'textfield',
478 478
     '#field_suffix' => 'Mbytes',
479 479
     '#default_value' => $default['daily_xfer_limit_mb'],
480 480
     '#size' => 1
481
-  ); 
482
-  $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array(
481
+    ); 
482
+    $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array(
483 483
     '#field_prefix' => 'every',
484 484
     '#type' => 'textfield',
485 485
     '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'),
486 486
     '#default_value' => $default['daily_xfer_period_days'],
487 487
     '#size' => 1,
488 488
     '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.', array(), NULL, 'boinc:account-preferences-computing'),
489
-  ); 
490
-  $form['prefs']['advanced']['network']['dont_verify_images'] = array(
489
+    ); 
490
+    $form['prefs']['advanced']['network']['dont_verify_images'] = array(
491 491
     '#title' => bts('Skip data verification for image files?', array(), NULL, 'boinc:account-preferences-computing'),
492 492
     '#type' => 'radios',
493 493
     '#options' => $form['boolean_options']['#value'],
494 494
     '#attributes' => array('class' => 'fancy'),
495 495
     '#default_value' => $default['dont_verify_images'],
496 496
     '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.', array(), NULL, 'boinc:account-preferences-computing')
497
-  );
497
+    );
498 498
   
499
-  // The "fancy radios" are made via javascript on document load. In order for
500
-  // these to work with AHAH, we need this crazy setTimeout() call.
501
-  $form['prefs']['fancy-radios'] = array(
499
+    // The "fancy radios" are made via javascript on document load. In order for
500
+    // these to work with AHAH, we need this crazy setTimeout() call.
501
+    $form['prefs']['fancy-radios'] = array(
502 502
     '#value' => '
503 503
       <script>
504 504
         setTimeout(
@@ -509,177 +509,177 @@  discard block
 block discarded – undo
509 509
           300
510 510
         )
511 511
       </script>'
512
-  );
513
-  $form['prefs']['view advanced'] = array(
512
+    );
513
+    $form['prefs']['view advanced'] = array(
514 514
     '#type' => 'hidden',
515 515
     '#value' => 1
516
-  );
516
+    );
517 517
   
518
-  $form['prefs']['separator_bottom'] = array(
518
+    $form['prefs']['separator_bottom'] = array(
519 519
     '#value' => '<div class="separator buttons"></div>'
520
-  );
520
+    );
521 521
   
522
-  // Form control
523
-  $form['prefs']['form control tabs prefix'] = array(
522
+    // Form control
523
+    $form['prefs']['form control tabs prefix'] = array(
524 524
     '#value' => '<ul class="form-control tab-list">'
525
-  );
526
-  $form['prefs']['submit'] = array(
525
+    );
526
+    $form['prefs']['submit'] = array(
527 527
     '#prefix' => '<li class="first tab">',
528 528
     '#type' => 'submit',
529 529
     '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
530 530
     '#suffix' => '</li>'
531
-  );
532
-  $form['prefs']['form control tabs'] = array(
531
+    );
532
+    $form['prefs']['form control tabs'] = array(
533 533
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
534
-  );
535
-  if ($venue AND $venue != 'generic') {
534
+    );
535
+    if ($venue AND $venue != 'generic') {
536 536
     global $base_path;
537 537
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
538
-      l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
538
+        l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
539 539
         array(
540
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541
-          'attributes' => array(
540
+            'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541
+            'attributes' => array(
542 542
             'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
-              array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
544
-          )
543
+                array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
544
+            )
545 545
         )
546
-      ) . '</li>';
547
-  }
548
-  $form['prefs']['view control'] = array(
546
+        ) . '</li>';
547
+    }
548
+    $form['prefs']['view control'] = array(
549 549
     '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>'
550
-  );
551
-  $form['prefs']['form control tabs suffix'] = array(
550
+    );
551
+    $form['prefs']['form control tabs suffix'] = array(
552 552
     '#value' => '</ul>'
553
-  );
554
-  $form['#submit'][] = 'boincwork_generalprefs_form_submit';
553
+    );
554
+    $form['#submit'][] = 'boincwork_generalprefs_form_submit';
555 555
   
556
-  return $form;
556
+    return $form;
557 557
 }
558 558
 
559 559
 /**
560
-  * Validate the general preferences form.
561
-  */
560
+ * Validate the general preferences form.
561
+ */
562 562
 function boincwork_generalprefs_form_validate($form, &$form_state) {
563
-  require_boinc('util');
564
-  $values = $form_state['values']['prefs']['advanced'];
565
-  
566
-  //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>');
567
-  // Verify all non-boolean user input values and notify form API of failures
568
-  
569
-  // Processing preferences
570
-  if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
571
-  if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
572
-  if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
573
-  if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
574
-  if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
575
-  if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
576
-  if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
577
-  if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
563
+    require_boinc('util');
564
+    $values = $form_state['values']['prefs']['advanced'];
565
+  
566
+    //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>');
567
+    // Verify all non-boolean user input values and notify form API of failures
568
+  
569
+    // Processing preferences
570
+    if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
571
+    if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
572
+    if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
573
+    if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
574
+    if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
575
+    if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
576
+    if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
577
+    if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
578 578
 
579
-  // Storage preferences
580
-  if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
581
-  if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
582
-  if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
583
-  if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
584
-  if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
585
-  if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
586
-  if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
579
+    // Storage preferences
580
+    if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
581
+    if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
582
+    if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
583
+    if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
584
+    if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
585
+    if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
586
+    if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
587 587
 
588
-  // Network preferences
589
-  if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
590
-  if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
591
-  if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
592
-  if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
593
-  if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), NULL, 'boinc:account-prefrences-computing'));
594
-  if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
595
-  if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
596
-  if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
588
+    // Network preferences
589
+    if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
590
+    if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
591
+    if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
592
+    if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
593
+    if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), NULL, 'boinc:account-prefrences-computing'));
594
+    if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
595
+    if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
596
+    if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
597 597
 }
598 598
 
599 599
 /**
600
-  * Handle post-validation submission of general preferences form.
601
-  */
600
+ * Handle post-validation submission of general preferences form.
601
+ */
602 602
 function boincwork_generalprefs_form_submit($form, &$form_state) {
603
-  global $user;
604
-  $account = user_load($user->uid);
605
-  
606
-  $values = $form_state['values']['prefs']['advanced'];
607
-  $venue = $form_state['values']['prefs']['venue'];
608
-  $preset = $form_state['values']['prefs']['preset'];
609
-  
610
-  // Load preferences from BOINC account
611
-  $prefs = boincwork_load_prefs('general', $venue);
612
-  
613
-  // Processing preferences
614
-  $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
615
-  $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
616
-  $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1;
617
-  $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
618
-  $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
619
-  $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
620
-  $prefs['start_hour'] = $values['processor']['start_hour'];
621
-  $prefs['end_hour'] = $values['processor']['end_hour'];
622
-  $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
623
-  $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
624
-  $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
625
-  $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
626
-  
627
-  // Storage preferences
628
-  $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
629
-  $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
630
-  $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
631
-  $prefs['disk_interval'] = $values['storage']['disk_interval'];
632
-  $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
633
-  $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
634
-  $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
635
-  
636
-  // Network preferences
637
-  $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
638
-  $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
639
-  $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
640
-  $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
641
-  $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
642
-  $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
643
-  $prefs['net_start_hour'] = $values['network']['net_start_hour'];
644
-  $prefs['net_end_hour'] = $values['network']['net_end_hour'];
645
-  $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
646
-  $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
647
-  $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
603
+    global $user;
604
+    $account = user_load($user->uid);
605
+  
606
+    $values = $form_state['values']['prefs']['advanced'];
607
+    $venue = $form_state['values']['prefs']['venue'];
608
+    $preset = $form_state['values']['prefs']['preset'];
609
+  
610
+    // Load preferences from BOINC account
611
+    $prefs = boincwork_load_prefs('general', $venue);
612
+  
613
+    // Processing preferences
614
+    $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
615
+    $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
616
+    $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1;
617
+    $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
618
+    $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
619
+    $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
620
+    $prefs['start_hour'] = $values['processor']['start_hour'];
621
+    $prefs['end_hour'] = $values['processor']['end_hour'];
622
+    $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
623
+    $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
624
+    $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
625
+    $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
626
+  
627
+    // Storage preferences
628
+    $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
629
+    $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
630
+    $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
631
+    $prefs['disk_interval'] = $values['storage']['disk_interval'];
632
+    $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
633
+    $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
634
+    $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
635
+  
636
+    // Network preferences
637
+    $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
638
+    $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
639
+    $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
640
+    $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
641
+    $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
642
+    $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
643
+    $prefs['net_start_hour'] = $values['network']['net_start_hour'];
644
+    $prefs['net_end_hour'] = $values['network']['net_end_hour'];
645
+    $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
646
+    $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
647
+    $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
648 648
 
649
-  // transform old way to store the preset into new way
650
-  // ideally this should already have happened in boincwork_generalprefs_form()
651
-  if (isset($prefs['@attributes']['preset'])) {
649
+    // transform old way to store the preset into new way
650
+    // ideally this should already have happened in boincwork_generalprefs_form()
651
+    if (isset($prefs['@attributes']['preset'])) {
652 652
     $prefs['preset'] = $prefs['@attributes']['preset'];
653 653
     unset($prefs['@attributes']['preset']);
654
-  }
655
-  // Save the preset selection (or lack thereof)
656
-  if (!$preset OR $preset == 'custom') {
654
+    }
655
+    // Save the preset selection (or lack thereof)
656
+    if (!$preset OR $preset == 'custom') {
657 657
     $prefs['preset'] = 'custom';
658
-  }
659
-  else {
658
+    }
659
+    else {
660 660
     $prefs['preset'] = $preset;
661
-  }
661
+    }
662 662
   
663
-  // If this is a new preference set, be sure to unset the "cleared" attribute
664
-  if (isset($prefs['@attributes']['cleared'])) {
663
+    // If this is a new preference set, be sure to unset the "cleared" attribute
664
+    if (isset($prefs['@attributes']['cleared'])) {
665 665
     unset($prefs['@attributes']['cleared']);
666
-  }
666
+    }
667 667
   
668
-  // Update database
669
-  $result = boincwork_save_prefs($prefs, 'general', $venue);
668
+    // Update database
669
+    $result = boincwork_save_prefs($prefs, 'general', $venue);
670 670
   
671
-  if (!$result) {
671
+    if (!$result) {
672 672
     watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysql_error()), WATCHDOG_ERROR);
673 673
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
674
-  }
675
-  elseif (!drupal_get_messages('status', FALSE)) {
674
+    }
675
+    elseif (!drupal_get_messages('status', FALSE)) {
676 676
     // Show this message if the set wasn't created automatically (in which case
677 677
     // there is a message tailored to that) {
678 678
     drupal_set_message(t('Your preferences have been updated.
679 679
       Client-related preferences will take effect when your computer 
680 680
       communicates with @project or you issue the "Update"
681 681
       command from the BOINC client.', array('@project' => PROJECT)));
682
-  }
682
+    }
683 683
 }
684 684
 
685 685
 
@@ -691,88 +691,88 @@  discard block
 block discarded – undo
691 691
  * Find compatible hosts for merging
692 692
  */
693 693
 function boincwork_host_get_compatible_hosts($host_id) {
694
-  require_boinc('host');
695
-  global $user;
696
-  $account = user_load($user->uid);
697
-  $compatible_hosts = array();
698
-  $host_count = 0;
699
-  db_set_active('boinc_ro');
700
-  $current_host = db_fetch_object(db_query("
694
+    require_boinc('host');
695
+    global $user;
696
+    $account = user_load($user->uid);
697
+    $compatible_hosts = array();
698
+    $host_count = 0;
699
+    db_set_active('boinc_ro');
700
+    $current_host = db_fetch_object(db_query("
701 701
     SELECT id, domain_name, create_time, total_credit, rpc_time, os_name,
702 702
       p_vendor, p_model
703 703
     FROM {host}
704 704
     WHERE userid = '%d' AND id = '%d'",
705 705
     $account->boincuser_id, $host_id
706
-  ));
707
-  db_set_active('default');
708
-  $current_host->task_count = boincwork_host_get_task_count($current_host->id);
709
-  $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count;
710
-  // Get the list of all other hosts owned by this user for comparison
711
-  db_set_active('boinc_ro');
712
-  $all_other_hosts = db_query("
706
+    ));
707
+    db_set_active('default');
708
+    $current_host->task_count = boincwork_host_get_task_count($current_host->id);
709
+    $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count;
710
+    // Get the list of all other hosts owned by this user for comparison
711
+    db_set_active('boinc_ro');
712
+    $all_other_hosts = db_query("
713 713
     SELECT id, domain_name, create_time, total_credit, rpc_time, os_name,
714 714
       p_vendor, p_model
715 715
     FROM {host}
716 716
     WHERE userid = '%d' AND id <> '%d'",
717 717
     $account->boincuser_id, $host_id
718
-  );
719
-  db_set_active('default');
720
-  // Compare all hosts to see if any are plausible duplicates
721
-  while ($other_host = db_fetch_object($all_other_hosts)) {
718
+    );
719
+    db_set_active('default');
720
+    // Compare all hosts to see if any are plausible duplicates
721
+    while ($other_host = db_fetch_object($all_other_hosts)) {
722 722
     // First, disqualify if hosts were active at the same time
723 723
     if (!$current_host->is_new) {
724
-      $other_host->task_count = boincwork_host_get_task_count($other_host->id);
725
-      $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count;
726
-      if (!$other_host->is_new) {
724
+        $other_host->task_count = boincwork_host_get_task_count($other_host->id);
725
+        $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count;
726
+        if (!$other_host->is_new) {
727 727
         // If both hosts being compared are not new, see if times overlap
728 728
         if (!times_disjoint($current_host, $other_host)) {
729
-          // Hosts were active at the same time; can't be a duplicate
730
-          continue;
729
+            // Hosts were active at the same time; can't be a duplicate
730
+            continue;
731
+        }
731 732
         }
732
-      }
733 733
     }
734 734
     // Next, disqualify if hosts have different OS platforms
735 735
     if (!os_compatible($current_host, $other_host)) {
736
-      // Hosts have different OS platforms; not really a duplicate
737
-      continue;
736
+        // Hosts have different OS platforms; not really a duplicate
737
+        continue;
738 738
     }
739 739
     // Finally, disqualify if hosts have different CPUs
740 740
     if (!cpus_compatible($current_host, $other_host)) {
741
-      // CPUs don't match; not a duplicate
742
-      continue;
741
+        // CPUs don't match; not a duplicate
742
+        continue;
743 743
     }
744 744
     // If not disqualified, this host is available for merging
745 745
     $hosts[] = $other_host;
746 746
     $host_count++;
747 747
     if ($host_count == 500) {
748
-      // This is enough!
749
-      break;
748
+        // This is enough!
749
+        break;
750
+    }
750 751
     }
751
-  }
752
-  return $hosts;
752
+    return $hosts;
753 753
 }
754 754
 
755 755
 /**
756 756
  * Perform the database updates to merge the old host into the new host
757 757
  */
758 758
 function boincwork_host_merge($old_host, $new_host, &$message = NULL) {
759
-  // Decay the average credit of the two hosts
760
-  require_boinc('credit');
761
-  $now = time();
762
-  update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time);
763
-  update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time);
764
-  
765
-  // Update the database:
766
-  // - add credit from old host to new host
767
-  // - change results to refer to the new host
768
-  // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id])
769
-  
770
-  $total_credit = $old_host->total_credit + $new_host->total_credit;
771
-  $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit;
772
-  
773
-  // Move credit from the old host to the new host
774
-  db_set_active('boinc_rw');
775
-  $credit_updated = db_query("
759
+    // Decay the average credit of the two hosts
760
+    require_boinc('credit');
761
+    $now = time();
762
+    update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time);
763
+    update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time);
764
+  
765
+    // Update the database:
766
+    // - add credit from old host to new host
767
+    // - change results to refer to the new host
768
+    // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id])
769
+  
770
+    $total_credit = $old_host->total_credit + $new_host->total_credit;
771
+    $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit;
772
+  
773
+    // Move credit from the old host to the new host
774
+    db_set_active('boinc_rw');
775
+    $credit_updated = db_query("
776 776
     UPDATE {host}
777 777
     SET
778 778
       total_credit = '%d',
@@ -780,34 +780,34 @@  discard block
 block discarded – undo
780 780
       expavg_time = '%d'
781 781
     WHERE id = '%d'",
782 782
     $total_credit, $recent_credit, $now, $new_host->id
783
-  );
784
-  db_set_active('default');
785
-  if (!$credit_updated) {
783
+    );
784
+    db_set_active('default');
785
+    if (!$credit_updated) {
786 786
     if ($message !== NULL) {
787
-      $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge');
787
+        $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge');
788 788
     }
789 789
     return FALSE;
790
-  }
790
+    }
791 791
   
792
-  // Move results from the old host to the new host
793
-  db_set_active('boinc_rw');
794
-  $results_updated = db_query("
792
+    // Move results from the old host to the new host
793
+    db_set_active('boinc_rw');
794
+    $results_updated = db_query("
795 795
     UPDATE {result}
796 796
     SET hostid = '%d'
797 797
     WHERE hostid = '%d'",
798 798
     $new_host->id, $old_host->id
799
-  );
800
-  db_set_active('default');
801
-  if (!$results_updated) {
799
+    );
800
+    db_set_active('default');
801
+    if (!$results_updated) {
802 802
     if ($message !== NULL) {
803
-      $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge');
803
+        $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge');
804 804
     }
805 805
     return FALSE;
806
-  }
806
+    }
807 807
   
808
-  // Retire the old host
809
-  db_set_active('boinc_rw');
810
-  $old_host_retired = db_query("
808
+    // Retire the old host
809
+    db_set_active('boinc_rw');
810
+    $old_host_retired = db_query("
811 811
     UPDATE {host}
812 812
     SET
813 813
       total_credit = '0',
@@ -816,16 +816,16 @@  discard block
 block discarded – undo
816 816
       rpc_seqno = '%d'
817 817
     WHERE id = '%d'",
818 818
     $new_host->id, $old_host->id
819
-  );
820
-  db_set_active('default');
821
-  if (!$old_host_retired) {
819
+    );
820
+    db_set_active('default');
821
+    if (!$old_host_retired) {
822 822
     if ($message !== NULL) {
823
-      $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge');
823
+        $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge');
824 824
     }
825 825
     return FALSE;
826
-  }
826
+    }
827 827
   
828
-  return TRUE;
828
+    return TRUE;
829 829
 }
830 830
 
831 831
 /**
@@ -833,75 +833,75 @@  discard block
 block discarded – undo
833 833
  */
834 834
 function boincwork_host_merge_form(&$form_state, $host_id) {
835 835
 
836
-  if (!boincwork_host_user_is_owner($host_id)) {
836
+    if (!boincwork_host_user_is_owner($host_id)) {
837 837
     drupal_goto("host/{$host_id}");
838
-  }
838
+    }
839 839
   
840
-  $form = array();
841
-  $form_state['storage']['current_host_id'] = $host_id;
842
-  $current_host = boincwork_host_get_info($host_id);
840
+    $form = array();
841
+    $form_state['storage']['current_host_id'] = $host_id;
842
+    $current_host = boincwork_host_get_info($host_id);
843 843
   
844
-  // Get hosts that could be merged with this one
845
-  $hosts = boincwork_host_get_compatible_hosts($host_id);
844
+    // Get hosts that could be merged with this one
845
+    $hosts = boincwork_host_get_compatible_hosts($host_id);
846 846
   
847
-  if (!$hosts) {
847
+    if (!$hosts) {
848 848
     drupal_set_message(t('There are no computers eligible for merging with this
849 849
       one'), 'warning'
850 850
     );
851 851
     drupal_goto("host/{$host_id}");
852
-  }
852
+    }
853 853
   
854
-  $form['overview'] = array(
854
+    $form['overview'] = array(
855 855
     '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to'
856
-      . ' the same computer by mistake. You can correct this by merging old'
857
-      . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>'
858
-      . '<p>'
859
-      . bts('Check the computers that are the same as @name'
860
-      . ' (created on @date at @time with computer ID @id)',
856
+        . ' the same computer by mistake. You can correct this by merging old'
857
+        . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>'
858
+        . '<p>'
859
+        . bts('Check the computers that are the same as @name'
860
+        . ' (created on @date at @time with computer ID @id)',
861 861
         array(
862
-          '@name' => $current_host->domain_name,
863
-          '@date' => date('j M Y', $current_host->create_time),
864
-          '@time' => date('G:i:s T', $current_host->create_time),
865
-          '@id' => $current_host->id,
862
+            '@name' => $current_host->domain_name,
863
+            '@date' => date('j M Y', $current_host->create_time),
864
+            '@time' => date('G:i:s T', $current_host->create_time),
865
+            '@id' => $current_host->id,
866 866
         ),
867 867
         NULL, 'boinc:account-host-merge') . '</p>',
868
-  );
868
+    );
869 869
   
870
-  $options = array();
871
-  foreach ($hosts as $host) {
870
+    $options = array();
871
+    foreach ($hosts as $host) {
872 872
     $options[$host->id] = array(
873
-      $host->domain_name,
874
-      date('j M Y G:i:s T', $host->create_time),
875
-      $host->id,
873
+        $host->domain_name,
874
+        date('j M Y G:i:s T', $host->create_time),
875
+        $host->id,
876 876
     );
877
-  }
877
+    }
878 878
   
879
-  $form['merge'] = array(
879
+    $form['merge'] = array(
880 880
     '#title' => '',
881 881
     '#type' => 'tableselect',
882 882
     '#header' => array(bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), NULL, 'boinc:host-details'), bts('Computer ID', array(), NULL, 'boinc:host-list')),
883 883
     '#options' => $options,
884
-  );
884
+    );
885 885
   
886
-  $form['prefs']['separator_bottom'] = array(
887
-  //  '#value' => '<div class="separator buttons"></div>'
888
-  );
886
+    $form['prefs']['separator_bottom'] = array(
887
+    //  '#value' => '<div class="separator buttons"></div>'
888
+    );
889 889
   
890
-  // Form control
891
-  $form['prefs']['form control tabs prefix'] = array(
890
+    // Form control
891
+    $form['prefs']['form control tabs prefix'] = array(
892 892
     '#value' => '<ul class="form-control tab-list">'
893
-  );
894
-  $form['prefs']['submit'] = array(
893
+    );
894
+    $form['prefs']['submit'] = array(
895 895
     '#prefix' => '<li class="first tab">',
896 896
     '#type' => 'submit',
897 897
     '#value' => bts('Merge', array(), NULL, 'boinc:form-merge'),
898 898
     '#suffix' => '</li>'
899
-  );
900
-  $form['prefs']['form control tabs'] = array(
899
+    );
900
+    $form['prefs']['form control tabs'] = array(
901 901
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>'
902
-  );
902
+    );
903 903
   
904
-  return $form;
904
+    return $form;
905 905
 }
906 906
 
907 907
 /**
@@ -914,76 +914,76 @@  discard block
 block discarded – undo
914 914
  * Handle submission of the merge host form
915 915
  */
916 916
 function boincwork_host_merge_form_submit($form, &$form_state) {
917
-  $merged = array();
918
-  $errors = array();
919
-  $current_host_id = $form_state['storage']['current_host_id'];
920
-  $current_host = boincwork_host_get_info($current_host_id);
921
-  $selected_hosts = array_filter($form_state['values']['merge']);
917
+    $merged = array();
918
+    $errors = array();
919
+    $current_host_id = $form_state['storage']['current_host_id'];
920
+    $current_host = boincwork_host_get_info($current_host_id);
921
+    $selected_hosts = array_filter($form_state['values']['merge']);
922 922
   
923
-  foreach ($selected_hosts as $host_id) {
923
+    foreach ($selected_hosts as $host_id) {
924 924
     // Attempt to merge each host, noting the results
925 925
     $message = '';
926 926
     $old_host = boincwork_host_get_info($host_id);
927 927
     if (boincwork_host_merge($old_host, $current_host, $message)) {
928
-      $merged[$old_host->id] = $old_host->id;
929
-      $current_host = boincwork_host_get_info($current_host_id);
928
+        $merged[$old_host->id] = $old_host->id;
929
+        $current_host = boincwork_host_get_info($current_host_id);
930 930
     }
931 931
     else {
932
-      $errors[$old_host->id] = $message;
932
+        $errors[$old_host->id] = $message;
933
+    }
933 934
     }
934
-  }
935 935
   
936
-  if ($merged) {
936
+    if ($merged) {
937 937
     // Generate a natural language list of IDs that were merged
938 938
     $oxford_comma = ',';
939 939
     $conjunction = bts('and', array(), NULL, 'boinc:account-preference');
940 940
     $list = array_keys($merged);
941 941
     $last = array_pop($list);
942 942
     if ($list) {
943
-      if (count($merged) == 2) {
943
+        if (count($merged) == 2) {
944 944
         $oxford_comma = '';
945
-      }
946
-      $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
945
+        }
946
+        $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
947 947
     }
948 948
     else {
949
-      $list = $last;
949
+        $list = $last;
950 950
     }
951 951
     if (count($merged) == 1) {
952
-      drupal_set_message(bts(
952
+        drupal_set_message(bts(
953 953
         'Computer @old_id has been merged successfully into @id.',
954 954
         array(
955
-          '@old_id' => $list,
956
-          '@id' => $current_host_id
955
+            '@old_id' => $list,
956
+            '@id' => $current_host_id
957 957
         ),
958 958
         NULL, 'boinc:account-host-merge'));
959 959
     }
960 960
     else {
961
-      drupal_set_message(bts(
961
+        drupal_set_message(bts(
962 962
         'Computers @old_ids have been merged successfully into @id.',
963 963
         array(
964
-          '@old_ids' => $list,
965
-          '@id' => $current_host_id
964
+            '@old_ids' => $list,
965
+            '@id' => $current_host_id
966 966
         ),
967 967
         NULL, 'boinc:account-host-merge'));
968 968
     }
969
-  }
969
+    }
970 970
   
971
-  if ($errors) {
971
+    if ($errors) {
972 972
     // Report any hosts that failed to merge
973 973
     foreach ($errors as $id => $error) {
974
-      drupal_set_message(
974
+        drupal_set_message(
975 975
         bts('Computer @old_id failed to merge: @message',
976
-          array(
976
+            array(
977 977
             '@old_id' => $id,
978 978
             '@message' => $error,
979
-          ),
980
-          NULL, 'boinc:account-host-merge'),
979
+            ),
980
+            NULL, 'boinc:account-host-merge'),
981 981
         'warning'
982
-      );
982
+        );
983
+    }
983 984
     }
984
-  }
985 985
   
986
-  drupal_goto("host/{$current_host_id}");
986
+    drupal_goto("host/{$current_host_id}");
987 987
 }
988 988
 
989 989
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -995,44 +995,44 @@  discard block
 block discarded – undo
995 995
  */
996 996
 function boincwork_projectprefs_form(&$form_state, $venue) {
997 997
   
998
-  global $user;
999
-  $account = user_load($user->uid);
998
+    global $user;
999
+    $account = user_load($user->uid);
1000 1000
   
1001
-  $established = TRUE;
1001
+    $established = TRUE;
1002 1002
   
1003
-  // Get availability of special BOINC preferences
1004
-  require_boinc(array('util'));
1005
-  $app_types = get_app_types();
1003
+    // Get availability of special BOINC preferences
1004
+    require_boinc(array('util'));
1005
+    $app_types = get_app_types();
1006 1006
   
1007
-  // Load any existing preferences from BOINC account
1008
-  $prefs = boincwork_load_prefs('project', $venue);
1007
+    // Load any existing preferences from BOINC account
1008
+    $prefs = boincwork_load_prefs('project', $venue);
1009 1009
   
1010
-  // Take note if this is not an established preference set on the account
1011
-  if (isset($prefs['@attributes']['cleared'])) {
1010
+    // Take note if this is not an established preference set on the account
1011
+    if (isset($prefs['@attributes']['cleared'])) {
1012 1012
     $established = FALSE;
1013
-  }
1013
+    }
1014 1014
 
1015
-  // Extract modified tag if present
1016
-  $modified = NULL;
1017
-  if (isset($prefs['modified']['@value'])) {
1015
+    // Extract modified tag if present
1016
+    $modified = NULL;
1017
+    if (isset($prefs['modified']['@value'])) {
1018 1018
     $modified = $prefs['modified']['@value'];
1019
-  }
1019
+    }
1020 1020
 
1021
-  $venue_is_default = FALSE;
1022
-  if ($account->boincuser_default_pref_set) {
1021
+    $venue_is_default = FALSE;
1022
+    if ($account->boincuser_default_pref_set) {
1023 1023
     if ($account->boincuser_default_pref_set == $venue) {
1024
-      $venue_is_default = TRUE;
1024
+        $venue_is_default = TRUE;
1025 1025
     }
1026
-  }
1027
-  elseif (!$venue OR $venue == 'generic') {
1026
+    }
1027
+    elseif (!$venue OR $venue == 'generic') {
1028 1028
     $venue_is_default = TRUE;
1029
-  }
1030
-  else {
1029
+    }
1030
+    else {
1031 1031
     $venue_is_default = FALSE;
1032
-  }
1032
+    }
1033 1033
   
1034
-  // Define form defaults
1035
-  $default = array(
1034
+    // Define form defaults
1035
+    $default = array(
1036 1036
     'resource_share' => 100,
1037 1037
     'no_cpu' => 0,
1038 1038
     'no_cuda' => 0,
@@ -1040,333 +1040,333 @@  discard block
 block discarded – undo
1040 1040
     'no_intel_gpu' => 0,
1041 1041
     'default_venue' => $venue_is_default,
1042 1042
     'allow_beta_work' => $prefs['allow_beta_work'],
1043
-  );
1044
-  foreach ($default as $name => $value) {
1043
+    );
1044
+    foreach ($default as $name => $value) {
1045 1045
     if (isset($prefs[$name])) {
1046
-      if (is_array($prefs[$name])) {
1046
+        if (is_array($prefs[$name])) {
1047 1047
         if (isset($prefs[$name]['@value'])) {
1048
-          $default[$name] = $prefs[$name]['@value'];
1048
+            $default[$name] = $prefs[$name]['@value'];
1049 1049
         }
1050
-      }
1051
-      else {
1050
+        }
1051
+        else {
1052 1052
         $default[$name] = $prefs[$name];
1053
-      }
1053
+        }
1054
+    }
1054 1055
     }
1055
-  }
1056 1056
   
1057
-  // Standard option sets
1058
-  $form['boolean_options'] = array(
1057
+    // Standard option sets
1058
+    $form['boolean_options'] = array(
1059 1059
     '#type' => 'value',
1060 1060
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1061
-  );
1061
+    );
1062 1062
   
1063
-  // Identify preference sets that are established to distinguish what has been
1064
-  // saved to the database from what is just showing default values
1065
-  $form['#established'] = $established;
1063
+    // Identify preference sets that are established to distinguish what has been
1064
+    // saved to the database from what is just showing default values
1065
+    $form['#established'] = $established;
1066 1066
   
1067
-  // Top level form options
1068
-  $form['#tree'] = TRUE;
1067
+    // Top level form options
1068
+    $form['#tree'] = TRUE;
1069 1069
   
1070
-  // Hidden elements
1071
-  $form['modified'] = array(
1070
+    // Hidden elements
1071
+    $form['modified'] = array(
1072 1072
     '#type' => 'hidden',
1073 1073
     '#value' => $modified,
1074
-  );
1075
-  $form['venue'] = array(
1074
+    );
1075
+    $form['venue'] = array(
1076 1076
     '#type' => 'hidden',
1077 1077
     '#value' => $venue,
1078
-  );
1078
+    );
1079 1079
   
1080
-  $form['separator_top'] = array(
1080
+    $form['separator_top'] = array(
1081 1081
     '#value' => '<div class="separator"></div>'
1082
-  );
1082
+    );
1083 1083
   
1084
-  // Common project preferences  
1085
-  $form['resource'] = array(
1084
+    // Common project preferences  
1085
+    $form['resource'] = array(
1086 1086
     '#title' => bts('Resource settings', array(), NULL, 'boinc:account-preferences-project'),
1087 1087
     '#type' => 'fieldset',
1088 1088
     '#description' => null,
1089 1089
     '#collapsible' => TRUE,
1090 1090
     '#collapsed' => FALSE
1091
-  );
1092
-  $form['resource']['resource_share'] = array(
1091
+    );
1092
+    $form['resource']['resource_share'] = array(
1093 1093
     '#title' => bts('Resource share', array(), NULL, 'boinc:account-preferences-project'),
1094 1094
     '#type' => 'textfield',
1095 1095
     '#default_value' => $default['resource_share'],
1096 1096
     '#size' => 5,
1097 1097
     '#description' => bts("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3.", array(), NULL, 'boinc:account-preferences-project')
1098
-  );
1099
-  if ($app_types->count > 1) {
1098
+    );
1099
+    if ($app_types->count > 1) {
1100 1100
     if ($app_types->cpu) {
1101
-      $form['resource']['no_cpu'] = array(
1101
+        $form['resource']['no_cpu'] = array(
1102 1102
         '#title' => bts('Use CPU', array(), NULL, 'boinc:account-preferences-project'),
1103 1103
         '#type' => 'radios',
1104 1104
         '#options' => $form['boolean_options']['#value'],
1105 1105
         '#attributes' => array('class' => 'fancy'),
1106 1106
         '#default_value' => $default['no_cpu'] ? 0 : 1,
1107 1107
         '#description' => bts('Request CPU-only tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1108
-      );
1108
+        );
1109 1109
     }
1110 1110
     if ($app_types->cuda) {
1111
-      $form['resource']['no_cuda'] = array(
1111
+        $form['resource']['no_cuda'] = array(
1112 1112
         '#title' => bts('Use NVIDIA GPU', array(), NULL, 'boinc:account-preferences-project'),
1113 1113
         '#type' => 'radios',
1114 1114
         '#options' => $form['boolean_options']['#value'],
1115 1115
         '#attributes' => array('class' => 'fancy'),
1116 1116
         '#default_value' => $default['no_cuda'] ? 0 : 1,
1117 1117
         '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1118
-      );
1118
+        );
1119 1119
     }
1120 1120
     if ($app_types->ati) {
1121
-      $form['resource']['no_ati'] = array(
1121
+        $form['resource']['no_ati'] = array(
1122 1122
         '#title' => bts('Use ATI GPU', array(), NULL, 'boinc:account-preferences-project'),
1123 1123
         '#type' => 'radios',
1124 1124
         '#options' => $form['boolean_options']['#value'],
1125 1125
         '#attributes' => array('class' => 'fancy'),
1126 1126
         '#default_value' => $default['no_ati'] ? 0 : 1,
1127 1127
         '#description' => bts('Request ATI GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1128
-      );
1128
+        );
1129 1129
     }
1130 1130
     if ($app_types->intel_gpu) {
1131
-      $form['resource']['no_intel_gpu'] = array(
1131
+        $form['resource']['no_intel_gpu'] = array(
1132 1132
         '#title' => bts('Use INTEL GPU', array(), NULL, 'boinc:account-preferences-project'),
1133 1133
         '#type' => 'radios',
1134 1134
         '#options' => $form['boolean_options']['#value'],
1135 1135
         '#attributes' => array('class' => 'fancy'),
1136 1136
         '#default_value' => $default['no_intel_gpu'] ? 0 : 1,
1137 1137
         '#description' => bts('Request Intel GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1138
-      );
1138
+        );
1139
+    }
1139 1140
     }
1140
-  }
1141 1141
   
1142
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1142
+    if (variable_get('boinc_prefs_options_beta', FALSE)) {
1143 1143
     $form['beta'] = array(
1144
-      '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'),
1145
-      '#type' => 'fieldset',
1146
-      '#description' => null,
1147
-      '#collapsible' => TRUE,
1148
-      '#collapsed' => FALSE
1144
+        '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'),
1145
+        '#type' => 'fieldset',
1146
+        '#description' => null,
1147
+        '#collapsible' => TRUE,
1148
+        '#collapsed' => FALSE
1149 1149
     );
1150 1150
     $form['beta']['allow_beta_work'] = array(
1151
-      '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'),
1152
-      '#type' => 'radios',
1153
-      '#options' => $form['boolean_options']['#value'],
1154
-      '#attributes' => array('class' => 'fancy'),
1155
-      '#default_value' => ($default['allow_beta_work']) ? 1 : 0,
1156
-      '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project')
1151
+        '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'),
1152
+        '#type' => 'radios',
1153
+        '#options' => $form['boolean_options']['#value'],
1154
+        '#attributes' => array('class' => 'fancy'),
1155
+        '#default_value' => ($default['allow_beta_work']) ? 1 : 0,
1156
+        '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project')
1157 1157
     );
1158
-  }
1158
+    }
1159 1159
   
1160
-  // Add project specific prefs to the form
1161
-  boincwork_add_project_specific_prefs($form, $prefs);
1160
+    // Add project specific prefs to the form
1161
+    boincwork_add_project_specific_prefs($form, $prefs);
1162 1162
   
1163
-  // Set whether to use this preference set by default for new computers
1164
-  $form['default_set'] = array(
1163
+    // Set whether to use this preference set by default for new computers
1164
+    $form['default_set'] = array(
1165 1165
     '#title' => bts('Default set', array(), NULL, 'boinc:account-preferences-project'),
1166 1166
     '#type' => 'fieldset',
1167 1167
     '#description' => null,
1168 1168
     '#collapsible' => TRUE,
1169 1169
     '#collapsed' => FALSE
1170
-  );
1171
-  $form['default_set']['default_venue'] = array(
1170
+    );
1171
+    $form['default_set']['default_venue'] = array(
1172 1172
     '#title' => bts('Set used for new computers', array(), NULL, 'boinc:account-preferences-project'),
1173 1173
     '#type' => 'radios',
1174 1174
     '#options' => $form['boolean_options']['#value'],
1175 1175
     '#attributes' => array('class' => 'fancy'),
1176 1176
     '#default_value' => $default['default_venue'] ? 1 : 0,
1177 1177
     '#description' => ''
1178
-  );
1178
+    );
1179 1179
   
1180
-  $form['prefs']['separator_bottom'] = array(
1180
+    $form['prefs']['separator_bottom'] = array(
1181 1181
     '#value' => '<div class="separator buttons"></div>'
1182
-  );
1182
+    );
1183 1183
   
1184
-  // Form control
1185
-  $form['prefs']['form control tabs prefix'] = array(
1184
+    // Form control
1185
+    $form['prefs']['form control tabs prefix'] = array(
1186 1186
     '#value' => '<ul class="form-control tab-list">'
1187
-  );
1188
-  $form['prefs']['submit'] = array(
1187
+    );
1188
+    $form['prefs']['submit'] = array(
1189 1189
     '#prefix' => '<li class="first tab">',
1190 1190
     '#type' => 'submit',
1191 1191
     '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1192 1192
     '#suffix' => '</li>'
1193
-  );
1194
-  $form['prefs']['form control tabs'] = array(
1193
+    );
1194
+    $form['prefs']['form control tabs'] = array(
1195 1195
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1196
-  );
1197
-  if ($venue AND $venue != 'generic') {
1196
+    );
1197
+    if ($venue AND $venue != 'generic') {
1198 1198
     global $base_path;
1199 1199
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
1200
-      l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1200
+        l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1201 1201
         array(
1202
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1203
-          'attributes' => array(
1202
+            'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1203
+            'attributes' => array(
1204 1204
             'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
1205
-              array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
1206
-          )
1205
+                array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
1206
+            )
1207 1207
         )
1208
-      ) . '</li>';
1209
-  }
1210
-  $form['prefs']['view control'] = array(
1211
-      '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1212
-  );
1213
-  $form['prefs']['form control tabs suffix'] = array(
1208
+        ) . '</li>';
1209
+    }
1210
+    $form['prefs']['view control'] = array(
1211
+        '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1212
+    );
1213
+    $form['prefs']['form control tabs suffix'] = array(
1214 1214
     '#value' => '</ul>'
1215
-  );
1215
+    );
1216 1216
   
1217
-  return $form;
1217
+    return $form;
1218 1218
 }
1219 1219
 
1220 1220
 /**
1221 1221
  * Add project specific preferences to the project preferences form
1222 1222
  */
1223 1223
 function boincwork_add_project_specific_prefs(&$form, $prefs) {
1224
-  // Load project specific preferences from XML config
1225
-  $xml = boincwork_get_project_specific_config();
1224
+    // Load project specific preferences from XML config
1225
+    $xml = boincwork_get_project_specific_config();
1226 1226
   
1227
-  // Respect the order of the top level elements
1228
-  $ordered_array = array();
1229
-  $unordered_array = array();
1230
-  foreach ($xml['project_specific_preferences'] as $type => $element) {
1227
+    // Respect the order of the top level elements
1228
+    $ordered_array = array();
1229
+    $unordered_array = array();
1230
+    foreach ($xml['project_specific_preferences'] as $type => $element) {
1231 1231
     if (is_array($element) AND is_numeric(key($element))) {
1232
-      foreach ($element as $ordered_element) {
1232
+        foreach ($element as $ordered_element) {
1233 1233
         if (isset($ordered_element['@position'])) {
1234
-          $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
1234
+            $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
1235 1235
         }
1236 1236
         else {
1237
-          $unordered_array[] = array($type => $ordered_element);
1237
+            $unordered_array[] = array($type => $ordered_element);
1238
+        }
1238 1239
         }
1239
-      }
1240 1240
     }
1241 1241
     elseif (isset($element['@position'])) {
1242
-      $ordered_array[$element['@position']] = array($type => $element);
1242
+        $ordered_array[$element['@position']] = array($type => $element);
1243 1243
     }
1244 1244
     else {
1245
-      $unordered_array[] = array($type => $element);
1245
+        $unordered_array[] = array($type => $element);
1246 1246
     }
1247
-  }
1248
-  ksort($ordered_array);
1249
-  $primed_array = array_merge($ordered_array, $unordered_array);
1250
-  $xml = array('project_specific_preferences' => $primed_array);
1247
+    }
1248
+    ksort($ordered_array);
1249
+    $primed_array = array_merge($ordered_array, $unordered_array);
1250
+    $xml = array('project_specific_preferences' => $primed_array);
1251 1251
     
1252
-  foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1252
+    foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1253 1253
     $type = key($wrapped_element);
1254 1254
     $element= reset($wrapped_element);
1255 1255
     boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']);
1256
-  }
1256
+    }
1257 1257
 }
1258 1258
 
1259 1259
 /**
1260
-  * Validate the project preferences form.
1261
-  */
1260
+ * Validate the project preferences form.
1261
+ */
1262 1262
 function boincwork_projectprefs_form_validate($form, &$form_state) {
1263 1263
   
1264
-  // Verify all text user input values and notify form API of failures
1265
-  $validation_rules = array(
1264
+    // Verify all text user input values and notify form API of failures
1265
+    $validation_rules = array(
1266 1266
     'resource' => array(
1267
-      'resource_share' => array(
1267
+        'resource_share' => array(
1268 1268
         'datatype' => 'integer',
1269 1269
         'min' => 0
1270
-      ),
1270
+        ),
1271 1271
     ),
1272
-  );
1272
+    );
1273 1273
   
1274
-  // Add validation rules for project specific settings
1275
-  $validation_rules += boincwork_get_project_specific_config_validation_rules();
1274
+    // Add validation rules for project specific settings
1275
+    $validation_rules += boincwork_get_project_specific_config_validation_rules();
1276 1276
   
1277
-  // Perform validation
1278
-  boincwork_validate_form($validation_rules, $form_state['values']);
1277
+    // Perform validation
1278
+    boincwork_validate_form($validation_rules, $form_state['values']);
1279 1279
   
1280
-  // Check for app validation
1281
-  if (isset($validation_rules['apps'])) {
1280
+    // Check for app validation
1281
+    if (isset($validation_rules['apps'])) {
1282 1282
     if (isset($validation_rules['apps']['minimum selected'])
1283 1283
         AND $validation_rules['apps']['minimum selected'] > 0) {
1284
-      $apps_selected = 0;
1285
-      foreach ($validation_rules['apps']['list'] as $app) {
1284
+        $apps_selected = 0;
1285
+        foreach ($validation_rules['apps']['list'] as $app) {
1286 1286
         if ($form_state['values']['applications'][$app]) $apps_selected++;
1287
-      }
1288
-      if ($apps_selected < $validation_rules['apps']['minimum selected']) {
1287
+        }
1288
+        if ($apps_selected < $validation_rules['apps']['minimum selected']) {
1289 1289
         form_set_error(
1290
-          'applications',
1291
-          bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project')
1290
+            'applications',
1291
+            bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project')
1292 1292
         );
1293
-      }
1294
-      if ($apps_selected == count($validation_rules['apps']['list'])) {
1293
+        }
1294
+        if ($apps_selected == count($validation_rules['apps']['list'])) {
1295 1295
         foreach ($validation_rules['apps']['list'] as $app) {
1296
-          unset($form_state['values']['applications'][$app]);
1296
+            unset($form_state['values']['applications'][$app]);
1297 1297
         }
1298 1298
         $form_state['storage']['all apps selected'] = TRUE;
1299
-      }
1299
+        }
1300
+    }
1300 1301
     }
1301
-  }
1302 1302
 }
1303 1303
 
1304 1304
 /**
1305
-  * Handle post-validation submission of project preferences form.
1306
-  */
1305
+ * Handle post-validation submission of project preferences form.
1306
+ */
1307 1307
 function boincwork_projectprefs_form_submit($form, &$form_state) {
1308
-  global $user;
1309
-  global $site_name;
1308
+    global $user;
1309
+    global $site_name;
1310 1310
   
1311
-  require_boinc(array('util'));
1312
-  $app_types = get_app_types();
1311
+    require_boinc(array('util'));
1312
+    $app_types = get_app_types();
1313 1313
   
1314
-  $account = user_load($user->uid);
1315
-  $edit = $form_state['values'];
1316
-  $venue = $edit['venue'];
1314
+    $account = user_load($user->uid);
1315
+    $edit = $form_state['values'];
1316
+    $venue = $edit['venue'];
1317 1317
   
1318
-  // Load preferences from BOINC account
1319
-  $prefs = boincwork_load_prefs('project', $venue);
1318
+    // Load preferences from BOINC account
1319
+    $prefs = boincwork_load_prefs('project', $venue);
1320 1320
   
1321
-  // Resource preferences
1322
-  $prefs['resource_share'] = $edit['resource']['resource_share'];
1323
-  if ($app_types->count > 1) {
1321
+    // Resource preferences
1322
+    $prefs['resource_share'] = $edit['resource']['resource_share'];
1323
+    if ($app_types->count > 1) {
1324 1324
     if ($app_types->cpu) $prefs['no_cpu'] = ($edit['resource']['no_cpu']) ? 0 : 1;
1325 1325
     if ($app_types->cuda) $prefs['no_cuda'] = ($edit['resource']['no_cuda']) ? 0 : 1;
1326 1326
     if ($app_types->ati) $prefs['no_ati'] = ($edit['resource']['no_ati']) ? 0 : 1;
1327 1327
     if ($app_types->intel_gpu) $prefs['no_intel_gpu'] = ($edit['resource']['no_intel_gpu']) ? 0 : 1;
1328
-  }
1328
+    }
1329 1329
   
1330
-  // Beta preferences
1331
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1330
+    // Beta preferences
1331
+    if (variable_get('boinc_prefs_options_beta', FALSE)) {
1332 1332
     $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0;
1333
-  }
1333
+    }
1334 1334
   
1335
-  // Load project specific preferences from XML config
1336
-  $xml = boincwork_get_project_specific_config();
1337
-  $updated_prefs = array(
1335
+    // Load project specific preferences from XML config
1336
+    $xml = boincwork_get_project_specific_config();
1337
+    $updated_prefs = array(
1338 1338
     'project_specific' => boincwork_format_project_specific_prefs_data($edit)
1339
-  );
1340
-  $prefs = $updated_prefs + $prefs;
1339
+    );
1340
+    $prefs = $updated_prefs + $prefs;
1341 1341
   
1342
-  // Don't specify apps if all are selected
1343
-  if (isset($form_state['storage']['all apps selected'])) {
1342
+    // Don't specify apps if all are selected
1343
+    if (isset($form_state['storage']['all apps selected'])) {
1344 1344
     unset($prefs['project_specific']['app_id']);
1345 1345
     unset($form_state['storage']['all apps selected']);
1346
-  }
1346
+    }
1347 1347
   
1348
-  // If this is a new preference set, be sure to unset the "cleared" attribute
1349
-  if (isset($prefs['@attributes']['cleared'])) {
1348
+    // If this is a new preference set, be sure to unset the "cleared" attribute
1349
+    if (isset($prefs['@attributes']['cleared'])) {
1350 1350
     unset($prefs['@attributes']['cleared']);
1351
-  }
1351
+    }
1352 1352
   
1353
-  // Save preferences back to the BOINC account
1354
-  $result = boincwork_save_prefs($prefs, 'project', $venue);
1353
+    // Save preferences back to the BOINC account
1354
+    $result = boincwork_save_prefs($prefs, 'project', $venue);
1355 1355
   
1356
-  // Update the user's default preference set
1357
-  if ($edit['default_set']['default_venue']) {
1356
+    // Update the user's default preference set
1357
+    if ($edit['default_set']['default_venue']) {
1358 1358
     boincwork_set_default_venue($venue);
1359
-  }
1360
-  elseif ($venue == $account->boincuser_default_pref_set) {
1359
+    }
1360
+    elseif ($venue == $account->boincuser_default_pref_set) {
1361 1361
     // User has cleared out the default venue setting
1362 1362
     boincwork_set_default_venue();
1363
-  }
1363
+    }
1364 1364
   
1365
-  if (!$result) {
1365
+    if (!$result) {
1366 1366
     watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysql_error()), WATCHDOG_ERROR);
1367 1367
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
1368
-  }
1369
-  elseif (!drupal_get_messages('status', FALSE)) {
1368
+    }
1369
+    elseif (!drupal_get_messages('status', FALSE)) {
1370 1370
     // Show this message if the set wasn't created automatically (in which case
1371 1371
     // there is a message tailored to that)
1372 1372
     drupal_set_message(t('Your preferences have been updated.
@@ -1374,53 +1374,53 @@  discard block
 block discarded – undo
1374 1374
         communicates with @project or you issue the "Update"
1375 1375
         command from the BOINC client.', 
1376 1376
         array('@project' => $site_name)));
1377
-  }
1377
+    }
1378 1378
 }
1379 1379
 
1380 1380
 /**
1381 1381
  * The structure of the community preferences form
1382 1382
  */
1383 1383
 function communityprefs_form(&$form_state) {
1384
-  global $user;
1385
-  $account = user_load($user->uid);
1386
-  $form = array();
1387
-  
1388
-  // Pull in some elements from the profile form
1389
-  $profile_form_state = array();
1390
-  $profile = new stdClass();
1391
-  $profile->type = 'profile';
1392
-  $profile->language = '';
1393
-  if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1384
+    global $user;
1385
+    $account = user_load($user->uid);
1386
+    $form = array();
1387
+  
1388
+    // Pull in some elements from the profile form
1389
+    $profile_form_state = array();
1390
+    $profile = new stdClass();
1391
+    $profile->type = 'profile';
1392
+    $profile->language = '';
1393
+    if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1394 1394
     $profile_node = node_load($profile_nid);
1395 1395
     $form_state['storage']['profile_node'] = $profile_node;
1396 1396
     module_load_include('inc', 'node', 'node.pages');    
1397 1397
     $profile_form = drupal_retrieve_form('profile_node_form', $profile_form_state, $profile_node);
1398 1398
     drupal_prepare_form('profile_node_form', $profile_form, $profile_form_state);
1399
-  }
1399
+    }
1400 1400
   
1401
-  // Standard option sets
1402
-  $form['boolean_options'] = array(
1401
+    // Standard option sets
1402
+    $form['boolean_options'] = array(
1403 1403
     '#type' => 'value',
1404 1404
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1405
-  );
1405
+    );
1406 1406
   
1407
-  $default = array(
1407
+    $default = array(
1408 1408
     'pm_send_notification' => '', // This is set already in pm_email_notify_user
1409 1409
     'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0,
1410 1410
     'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50),
1411 1411
     'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST),
1412
-  );
1412
+    );
1413 1413
   
1414
-  // General options
1415
-  $form['general'] = array(
1414
+    // General options
1415
+    $form['general'] = array(
1416 1416
     '#type' => 'fieldset',
1417 1417
     '#title' => bts('General settings', array(), NULL, 'boinc:account-preferences-community'),
1418 1418
     '#weight' => 0,
1419 1419
     '#collapsible' => TRUE,
1420 1420
     '#collapsed' => FALSE
1421
-  );
1422
-  // Add the BOINC user name (non-unique, user editable)
1423
-  $form['general']['boincuser_name'] = array(
1421
+    );
1422
+    // Add the BOINC user name (non-unique, user editable)
1423
+    $form['general']['boincuser_name'] = array(
1424 1424
     '#type' => 'textfield',
1425 1425
     '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'),
1426 1426
     '#default_value' => $account->boincuser_name,
@@ -1428,222 +1428,222 @@  discard block
 block discarded – undo
1428 1428
     '#required' => TRUE,
1429 1429
     '#description' => '',
1430 1430
     '#size' => 40
1431
-  );
1432
-  // Time zone
1433
-  if (variable_get('configurable_timezones', 1)) {
1431
+    );
1432
+    // Time zone
1433
+    if (variable_get('configurable_timezones', 1)) {
1434 1434
     $zones = _system_zonelist();
1435 1435
     $form['general']['timezone'] = array(
1436
-      '#type' => 'select',
1437
-      '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'),
1438
-      '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1439
-      '#options' => $zones,
1440
-      '#description' => '',
1436
+        '#type' => 'select',
1437
+        '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'),
1438
+        '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1439
+        '#options' => $zones,
1440
+        '#description' => '',
1441 1441
     );
1442
-  }
1442
+    }
1443 1443
   
1444
-  // Notification options
1445
-  $form['notifications'] = array(
1444
+    // Notification options
1445
+    $form['notifications'] = array(
1446 1446
     '#type' => 'fieldset',
1447 1447
     '#title' => bts('Notification settings', array(), NULL, 'boinc:account-preferences-community'),
1448 1448
     '#weight' => 5,
1449 1449
     '#collapsible' => TRUE,
1450 1450
     '#collapsed' => FALSE
1451
-  );
1452
-  // Pull in private message notification handling and tweak the form
1453
-  $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
1454
-  $form['notifications']['pm_send_notifications'] = array_replace(
1451
+    );
1452
+    // Pull in private message notification handling and tweak the form
1453
+    $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
1454
+    $form['notifications']['pm_send_notifications'] = array_replace(
1455 1455
     $pm_notify['enable_pm_mail']['pm_send_notifications'],
1456 1456
     array(
1457
-      '#type' => 'radios',
1458
-      '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'),
1459
-      '#description' => ' ',
1460
-      '#options' => $form['boolean_options']['#value'],
1461
-      '#attributes' => array('class' => 'fancy')
1457
+        '#type' => 'radios',
1458
+        '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'),
1459
+        '#description' => ' ',
1460
+        '#options' => $form['boolean_options']['#value'],
1461
+        '#attributes' => array('class' => 'fancy')
1462 1462
     )
1463
-  );
1464
-  $form['notifications']['friend_notification'] = array(
1463
+    );
1464
+    $form['notifications']['friend_notification'] = array(
1465 1465
     '#type' => 'radios',
1466 1466
     '#title' => bts('Receive email notification for friend requests?', array(), NULL, 'boinc:account-preferences-community'),
1467 1467
     '#description' => ' ',
1468 1468
     '#options' => array(0 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
1469 1469
     '#attributes' => array('class' => 'fancy'),
1470 1470
     '#default_value' => $default['friend_notification']
1471
-  );
1471
+    );
1472 1472
   
1473
-  // Internationalization options
1474
-  if (module_exists('internationalization')) {
1473
+    // Internationalization options
1474
+    if (module_exists('internationalization')) {
1475 1475
     $languages = language_list('enabled');
1476 1476
     $languages = $languages[1];
1477 1477
     $names = array();
1478 1478
     foreach ($languages as $langcode => $item) {
1479
-      $name = t($item->name);
1480
-      $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1479
+        $name = t($item->name);
1480
+        $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1481 1481
     }
1482 1482
     $form['locale'] = array(
1483
-      '#type' => 'fieldset',
1484
-      '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'),
1485
-      '#weight' => 10,
1486
-      '#collapsible' => TRUE,
1487
-      '#collapsed' => FALSE,
1483
+        '#type' => 'fieldset',
1484
+        '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'),
1485
+        '#weight' => 10,
1486
+        '#collapsible' => TRUE,
1487
+        '#collapsed' => FALSE,
1488 1488
     );
1489 1489
 
1490 1490
     // Get language negotiation settings.
1491 1491
     $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
1492 1492
     $user_preferred_language = user_preferred_language($account);
1493 1493
     $form['locale']['language'] = array(
1494
-      '#type' => 'select',
1495
-      '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'),
1496
-      '#default_value' => check_plain($user_preferred_language->language),
1497
-      '#options' => $names,
1498
-      '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'),
1494
+        '#type' => 'select',
1495
+        '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'),
1496
+        '#default_value' => check_plain($user_preferred_language->language),
1497
+        '#options' => $names,
1498
+        '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'),
1499 1499
     );
1500
-  }
1500
+    }
1501 1501
   
1502
-  // Avatar options
1503
-  $form['gravatar'] = array(
1502
+    // Avatar options
1503
+    $form['gravatar'] = array(
1504 1504
     '#type' => 'item',
1505 1505
     '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'),
1506 1506
     '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'),
1507
-  );
1508
-  if (user_access('disable own gravatar', $account)) {
1507
+    );
1508
+    if (user_access('disable own gravatar', $account)) {
1509 1509
     $form['gravatar'] = array(
1510
-      '#type' => 'checkbox',
1511
-      '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'),
1512
-      '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'),
1513
-      '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1514
-      '#disabled' => !empty($account->picture),
1515
-    );
1516
-  }
1517
-  $form['gravatar']['#weight'] = 15;
1518
-  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>';
1519
-  // Upload an avatar (pulled from profile_node_form):
1520
-  if (!empty($profile_form['field_image'])) {
1510
+        '#type' => 'checkbox',
1511
+        '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'),
1512
+        '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'),
1513
+        '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1514
+        '#disabled' => !empty($account->picture),
1515
+    );
1516
+    }
1517
+    $form['gravatar']['#weight'] = 15;
1518
+    $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>';
1519
+    // Upload an avatar (pulled from profile_node_form):
1520
+    if (!empty($profile_form['field_image'])) {
1521 1521
     $form['field_image'] = $profile_form['field_image'];
1522
-  }
1523
-  else {
1522
+    }
1523
+    else {
1524 1524
     $form['field_image'] = array(
1525
-      '#value' => '<div class="form-item">'
1525
+        '#value' => '<div class="form-item">'
1526 1526
         . '<label class="placeholder">'
1527 1527
         . bts('This is not available until your profile is set up.', array(), NULL, 'boinc:account-preferences-community')
1528 1528
         . '</label>'
1529 1529
         . l(bts('Create a profile', array(), NULL, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link')))
1530 1530
         . '</div>',
1531 1531
     );
1532
-  }
1533
-  $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community');
1534
-  $form['field_image']['#weight'] = 20;
1535
-  $form['field_image']['#suffix'] = '</fieldset>';
1532
+    }
1533
+    $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community');
1534
+    $form['field_image']['#weight'] = 20;
1535
+    $form['field_image']['#suffix'] = '</fieldset>';
1536 1536
   
1537
-  // Forum options
1538
-  $form['forums'] = array(
1537
+    // Forum options
1538
+    $form['forums'] = array(
1539 1539
     '#type' => 'fieldset',
1540 1540
     '#title' => bts('Forum settings', array(), NULL, 'boinc:account-preferences-community'),
1541 1541
     '#weight' => 25,
1542 1542
     '#collapsible' => TRUE,
1543 1543
     '#collapsed' => FALSE
1544
-  );
1545
-  $form['forums']['comments_per_page'] = array(
1544
+    );
1545
+    $form['forums']['comments_per_page'] = array(
1546 1546
     '#type' => 'select',
1547 1547
     '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), NULL, 'boinc:account-preferences-community'),
1548 1548
     '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100),
1549 1549
     '#default_value' => $default['comments_per_page']
1550
-  );
1551
-  // Can't have a typical Drupal form suffix on a select box?
1552
-  $form['forums']['comments_per_page_suffix'] = array(
1550
+    );
1551
+    // Can't have a typical Drupal form suffix on a select box?
1552
+    $form['forums']['comments_per_page_suffix'] = array(
1553 1553
     '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>'
1554
-  );
1555
-  $form['forums']['comments_order'] = array(
1554
+    );
1555
+    $form['forums']['comments_order'] = array(
1556 1556
     '#type' => 'select',
1557 1557
     '#title' => bts('Sort comments in discussions', array(), NULL, 'boinc:account-preferences-community'),
1558 1558
     '#options' => array(1 => bts('Newest post first', array(), NULL, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), NULL, 'boinc:account-preferences-community')),
1559 1559
     '#default_value' => $default['comments_order']
1560
-  );
1561
-  // Signature (pulled from user_edit_form):
1562
-  if (variable_get('user_signatures', 0) && module_exists('comment')) {
1560
+    );
1561
+    // Signature (pulled from user_edit_form):
1562
+    if (variable_get('user_signatures', 0) && module_exists('comment')) {
1563 1563
     $form['forums']['signature'] = array(
1564
-      '#type' => 'textarea',
1565
-      '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'),
1566
-      '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'),
1567
-      '#default_value' => $account->signature
1568
-      );
1564
+        '#type' => 'textarea',
1565
+        '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'),
1566
+        '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'),
1567
+        '#default_value' => $account->signature
1568
+        );
1569 1569
     // Prevent a "validation error" message when the user attempts to save with a default value they
1570 1570
     // do not have access to.
1571 1571
     if (!filter_access($account->signature_format) && empty($_POST)) {
1572
-      drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page."));
1573
-      $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1572
+        drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page."));
1573
+        $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1574 1574
     }
1575 1575
     $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format'));
1576 1576
     // Optionally hide signatures from comments
1577 1577
     $form['forums']['hide_signatures'] = array(
1578
-      '#type' => 'radios',
1579
-      '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'),
1580
-      '#description' => ' ',
1581
-      '#options' => $form['boolean_options']['#value'],
1582
-      '#attributes' => array('class' => 'fancy'),
1583
-      '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0,
1584
-    );
1585
-  }
1578
+        '#type' => 'radios',
1579
+        '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'),
1580
+        '#description' => ' ',
1581
+        '#options' => $form['boolean_options']['#value'],
1582
+        '#attributes' => array('class' => 'fancy'),
1583
+        '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0,
1584
+    );
1585
+    }
1586 1586
 
1587
-  //Bottom separator
1588
-  $form['separator_bottom'] = array(
1587
+    //Bottom separator
1588
+    $form['separator_bottom'] = array(
1589 1589
     '#value' => '<div class="separator buttons"></div>',
1590 1590
     '#weight' => 999,
1591
-  );
1591
+    );
1592 1592
   
1593
-  // Form control
1594
-  $form['form control tabs prefix'] = array(
1593
+    // Form control
1594
+    $form['form control tabs prefix'] = array(
1595 1595
     '#value' => '<ul class="form-control tab-list">',
1596 1596
     '#weight' => 1001,
1597
-  );
1598
-  $form['submit'] = array(
1597
+    );
1598
+    $form['submit'] = array(
1599 1599
     '#prefix' => '<li class="first tab">',
1600 1600
     '#type' => 'submit',
1601 1601
     '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1602 1602
     '#suffix' => '</li>',
1603 1603
     '#weight' => 1002,
1604
-  );
1605
-  $form['form control tabs'] = array(
1604
+    );
1605
+    $form['form control tabs'] = array(
1606 1606
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1607 1607
     '#weight' => 1003,
1608
-  );
1609
-  $form['form control tabs suffix'] = array(
1608
+    );
1609
+    $form['form control tabs suffix'] = array(
1610 1610
     '#value' => '</ul>',
1611 1611
     '#weight' => 1004,
1612
-  );
1613
-  return $form;
1612
+    );
1613
+    return $form;
1614 1614
 }
1615 1615
 
1616 1616
 /**
1617
-  * Handle post-validation submission of community preferences form.
1618
-  */
1617
+ * Handle post-validation submission of community preferences form.
1618
+ */
1619 1619
 function communityprefs_form_submit($form, &$form_state) {
1620
-  require_boinc('boinc_db');
1621
-  global $user;
1622
-  $account = user_load($user->uid);
1623
-  $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1624
-  $edit = $form_state['values'];
1625
-  $profile_node = $form_state['storage']['profile_node'];
1626
-  
1627
-  // Display name
1628
-  if ($edit['boincuser_name'] != $boinc_user->name) {
1620
+    require_boinc('boinc_db');
1621
+    global $user;
1622
+    $account = user_load($user->uid);
1623
+    $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1624
+    $edit = $form_state['values'];
1625
+    $profile_node = $form_state['storage']['profile_node'];
1626
+  
1627
+    // Display name
1628
+    if ($edit['boincuser_name'] != $boinc_user->name) {
1629 1629
     $boincuser_name = $edit['boincuser_name'];
1630 1630
     $result = $boinc_user->update(
1631 1631
         "name='{$boincuser_name}'"
1632 1632
     );
1633
-  }
1633
+    }
1634 1634
   
1635
-  // Private message settings
1636
-  pm_email_notify_user('submit', $edit, $user);
1635
+    // Private message settings
1636
+    pm_email_notify_user('submit', $edit, $user);
1637 1637
   
1638
-  // Avatar settings
1639
-  if (!$edit['field_image']) $edit['field_image'] = array();
1640
-  $profile_node->field_image = $edit['field_image'];
1641
-  node_save($profile_node);
1642
-  // Flush this from the node cache or changes won't show up immediately!
1643
-  $profile_node = node_load($profile_node->nid, NULL, TRUE);
1638
+    // Avatar settings
1639
+    if (!$edit['field_image']) $edit['field_image'] = array();
1640
+    $profile_node->field_image = $edit['field_image'];
1641
+    node_save($profile_node);
1642
+    // Flush this from the node cache or changes won't show up immediately!
1643
+    $profile_node = node_load($profile_node->nid, NULL, TRUE);
1644 1644
   
1645
-  // All other settings
1646
-  $settings = array(
1645
+    // All other settings
1646
+    $settings = array(
1647 1647
     'signature' => $edit['signature'],
1648 1648
     'signature_format' => $edit['signature_format'],
1649 1649
     'timezone' => $edit['timezone'],
@@ -1652,165 +1652,165 @@  discard block
 block discarded – undo
1652 1652
     'hide_signatures' => $edit['hide_signatures'],
1653 1653
     'sort' => $edit['comments_order'],
1654 1654
     'gravatar' => $edit['gravatar'],
1655
-  );
1656
-  if (module_exists('internationalization')) {
1655
+    );
1656
+    if (module_exists('internationalization')) {
1657 1657
     $settings['language'] = $edit['language'];
1658 1658
     global $language;
1659 1659
     if ($user->language != $edit['language']) {
1660
-      global $base_url;
1661
-      if ($edit['language'] != language_default('language')) {
1660
+        global $base_url;
1661
+        if ($edit['language'] != language_default('language')) {
1662 1662
         $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q'];
1663
-      }
1664
-      else {
1663
+        }
1664
+        else {
1665 1665
         $form_state['redirect'] = $base_url . '/' . $_GET['q'];
1666
-      }
1666
+        }
1667
+    }
1667 1668
     }
1668
-  }
1669
-  user_save($user, $settings);
1669
+    user_save($user, $settings);
1670 1670
   
1671
-  drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community'));
1671
+    drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community'));
1672 1672
   
1673
-  // Form will not redirect if storage is set; not good if language changes
1674
-  unset($form_state['storage']);
1673
+    // Form will not redirect if storage is set; not good if language changes
1674
+    unset($form_state['storage']);
1675 1675
 }
1676 1676
 
1677 1677
 /**
1678 1678
  * The structure of the privacy preferences form
1679 1679
  */
1680 1680
 function boincwork_privacyprefs_form(&$form_state) {
1681
-  require_boinc(array('user', 'prefs', 'util'));
1681
+    require_boinc(array('user', 'prefs', 'util'));
1682 1682
   
1683
-  global $user;
1684
-  $account = user_load($user->uid);
1685
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1683
+    global $user;
1684
+    $account = user_load($user->uid);
1685
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1686 1686
   
1687
-  // Load preferences from BOINC account
1688
-  $prefs = boincwork_load_prefs('project');
1687
+    // Load preferences from BOINC account
1688
+    $prefs = boincwork_load_prefs('project');
1689 1689
   
1690
-  //if (!$prefs AND !$initialize_if_empty) return null;
1690
+    //if (!$prefs AND !$initialize_if_empty) return null;
1691 1691
   
1692
-  // Define form defaults
1693
-  $default = array(
1692
+    // Define form defaults
1693
+    $default = array(
1694 1694
     'privacy' => array(
1695
-      'send_email' => ($boincuser->send_email) ? 1 : 0,
1696
-      'show_hosts' => ($boincuser->show_hosts) ? 1 : 0
1695
+        'send_email' => ($boincuser->send_email) ? 1 : 0,
1696
+        'show_hosts' => ($boincuser->show_hosts) ? 1 : 0
1697 1697
     )
1698
-  );
1698
+    );
1699 1699
   
1700
-  // Standard option sets
1701
-  $form['boolean_options'] = array(
1700
+    // Standard option sets
1701
+    $form['boolean_options'] = array(
1702 1702
     '#type' => 'value',
1703 1703
     '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1704
-  );
1704
+    );
1705 1705
   
1706
-  $form['privacy'] = array(
1706
+    $form['privacy'] = array(
1707 1707
     '#title' => bts('Privacy settings', array(), NULL, 'boinc:account-preferences-privacy'),
1708 1708
     '#type' => 'fieldset',
1709 1709
     '#description' => null,
1710 1710
     '#collapsible' => TRUE,
1711 1711
     '#collapsed' => FALSE
1712
-  );
1713
-  $form['privacy']['send_email'] = array(
1712
+    );
1713
+    $form['privacy']['send_email'] = array(
1714 1714
     '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'),
1715 1715
     '#type' => 'radios',
1716 1716
     '#options' => $form['boolean_options']['#value'],
1717 1717
     '#attributes' => array('class' => 'fancy'),
1718 1718
     '#default_value' => $default['privacy']['send_email']
1719
-  );
1720
-  $form['privacy']['show_hosts'] = array(
1719
+    );
1720
+    $form['privacy']['show_hosts'] = array(
1721 1721
     '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'),
1722 1722
     '#description' => bts('At times, you may be asked to enable this option in order to receive help from the forums. Advanced users may need to be able to inspect your computers\' information in order to help diagnose any problems.', array(), NULL, 'boinc:account-preferences-privacy'),
1723 1723
     '#type' => 'radios',
1724 1724
     '#options' => $form['boolean_options']['#value'],
1725 1725
     '#attributes' => array('class' => 'fancy'),
1726 1726
     '#default_value' => $default['privacy']['show_hosts']
1727
-  );
1727
+    );
1728 1728
 
1729
-  // Ignore and block users
1730
-  if (module_exists('ignore_user')) {
1729
+    // Ignore and block users
1730
+    if (module_exists('ignore_user')) {
1731 1731
     $form['ignoreblock'] = array(
1732
-      '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'),
1733
-      '#type' => 'fieldset',
1734
-      '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), NULL, 'boinc:ignore-user-help'),
1735
-      '#collapsible' => TRUE,
1736
-      '#collapsed' => FALSE
1732
+        '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'),
1733
+        '#type' => 'fieldset',
1734
+        '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), NULL, 'boinc:ignore-user-help'),
1735
+        '#collapsible' => TRUE,
1736
+        '#collapsed' => FALSE
1737 1737
     );
1738 1738
 
1739 1739
     // Table for ignored users
1740 1740
     $form['ignoreblock']['current_ignore_section'] = array(
1741
-      '#type' => 'item',
1742
-      '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'),
1743
-      '#prefix' => '<h4>',
1744
-      '#suffix' => '</h4>',
1745
-      '#weight' => -20,
1741
+        '#type' => 'item',
1742
+        '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'),
1743
+        '#prefix' => '<h4>',
1744
+        '#suffix' => '</h4>',
1745
+        '#weight' => -20,
1746 1746
     );
1747 1747
 
1748 1748
     $ignored_users = _ignore_user_ignored_users();
1749 1749
     foreach ($ignored_users as $ignored_user) {
1750
-      $form['ignoreblock']['username'][$ignored_user['iuid']] = array(
1750
+        $form['ignoreblock']['username'][$ignored_user['iuid']] = array(
1751 1751
         '#value' => $ignored_user['username'],
1752
-      );
1753
-      $form['ignoreblock']['delete'][$ignored_user['iuid']] = array(
1752
+        );
1753
+        $form['ignoreblock']['delete'][$ignored_user['iuid']] = array(
1754 1754
         '#value' => l(
1755
-          bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'),
1756
-          'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'],
1757
-          array()
1755
+            bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'),
1756
+            'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'],
1757
+            array()
1758 1758
         ),
1759
-      );
1759
+        );
1760 1760
     }
1761 1761
     $form['ignoreblock']['pager'] = array('#value' => theme('pager', NULL, 10, 0));
1762 1762
 
1763 1763
     // Sub-form to add user to ignore list
1764 1764
     $form['ignoreblock']['add_ignore_user_section'] = array(
1765
-      '#type' => 'item',
1766
-      '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'),
1767
-      '#prefix' => '<h4>',
1768
-      '#suffix' => '</h4>',
1769
-      '#weight' => 10,
1765
+        '#type' => 'item',
1766
+        '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'),
1767
+        '#prefix' => '<h4>',
1768
+        '#suffix' => '</h4>',
1769
+        '#weight' => 10,
1770 1770
     );
1771 1771
 
1772 1772
     $form['ignoreblock']['addusername_toignorelist'] = array(
1773
-      '#type' => 'textfield',
1774
-      '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'),
1775
-      '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), NULL, 'boinc:ignore-user-searchbox-help'),
1776
-      '#weight' => 11,
1777
-      '#size' => 50,
1778
-      '#autocomplete_path' => 'boincuser/autocomplete',
1773
+        '#type' => 'textfield',
1774
+        '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'),
1775
+        '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), NULL, 'boinc:ignore-user-searchbox-help'),
1776
+        '#weight' => 11,
1777
+        '#size' => 50,
1778
+        '#autocomplete_path' => 'boincuser/autocomplete',
1779 1779
     );
1780 1780
 
1781 1781
     $form['ignoreblock']['addusername_submit'] = array(
1782
-      '#type' => 'submit',
1783
-      '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'),
1784
-      '#submit' => array('_boincwork_ignore_list_form_submit'),
1785
-      '#weight' => 12,
1786
-      '#attributes' => array('class' => 'add_ignore_user'),
1782
+        '#type' => 'submit',
1783
+        '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'),
1784
+        '#submit' => array('_boincwork_ignore_list_form_submit'),
1785
+        '#weight' => 12,
1786
+        '#attributes' => array('class' => 'add_ignore_user'),
1787 1787
     );
1788
-  }// endif module_exists
1788
+    }// endif module_exists
1789 1789
 
1790
-  $form['prefs']['separator_bottom'] = array(
1790
+    $form['prefs']['separator_bottom'] = array(
1791 1791
     '#value' => '<div class="separator buttons"></div>'
1792
-  );
1792
+    );
1793 1793
   
1794
-  // Form control
1795
-  $form['prefs']['form control tabs prefix'] = array(
1794
+    // Form control
1795
+    $form['prefs']['form control tabs prefix'] = array(
1796 1796
     '#value' => '<ul class="form-control tab-list">'
1797
-  );
1798
-  $form['prefs']['submit'] = array(
1797
+    );
1798
+    $form['prefs']['submit'] = array(
1799 1799
     '#prefix' => '<li class="first tab">',
1800 1800
     '#type' => 'submit',
1801 1801
     '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1802 1802
     '#validate' => array('boincwork_privacyprefs_form_validate'),
1803 1803
     '#submit' => array('boincwork_privacyprefs_form_submit'),
1804 1804
     '#suffix' => '</li>'
1805
-  );
1806
-  $form['prefs']['form control tabs'] = array(
1805
+    );
1806
+    $form['prefs']['form control tabs'] = array(
1807 1807
     '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1808
-  );
1809
-  $form['prefs']['form control tabs suffix'] = array(
1808
+    );
1809
+    $form['prefs']['form control tabs suffix'] = array(
1810 1810
     '#value' => '</ul>'
1811
-  );
1811
+    );
1812 1812
   
1813
-  return $form;
1813
+    return $form;
1814 1814
 }
1815 1815
 
1816 1816
 /**
@@ -1818,78 +1818,78 @@  discard block
 block discarded – undo
1818 1818
  */
1819 1819
 function theme_boincwork_privacyprefs_form($form) {
1820 1820
 
1821
-  $output = '';
1822
-  $output .= drupal_render($form['privacy']);
1821
+    $output = '';
1822
+    $output .= drupal_render($form['privacy']);
1823 1823
 
1824
-  $header = array(
1824
+    $header = array(
1825 1825
     bts('Username', array(), NULL, 'boinc:ignore-user-list'),
1826 1826
     bts('Operations', array(), NULL, 'boinc:ignore-user-list')
1827
-  );
1827
+    );
1828 1828
 
1829
-  $rows = array();
1830
-  if (isset($form['ignoreblock']['username']) && is_array($form['ignoreblock']['username'])) {
1829
+    $rows = array();
1830
+    if (isset($form['ignoreblock']['username']) && is_array($form['ignoreblock']['username'])) {
1831 1831
     foreach (element_children($form['ignoreblock']['username']) as $key) {
1832
-      $row = array();
1833
-      $row[] = drupal_render($form['ignoreblock']['username'][$key]);
1834
-      $row[] = drupal_render($form['ignoreblock']['delete'][$key]);
1835
-      $rows[] = $row;
1832
+        $row = array();
1833
+        $row[] = drupal_render($form['ignoreblock']['username'][$key]);
1834
+        $row[] = drupal_render($form['ignoreblock']['delete'][$key]);
1835
+        $rows[] = $row;
1836 1836
     }
1837
-  }
1838
-  else {
1837
+    }
1838
+    else {
1839 1839
     $rows[] = array(
1840
-      array(
1840
+        array(
1841 1841
         'data' => bts('You have not added any users to your Ignore List.', array(), NULL, 'boinc:ignore-user-list'),
1842 1842
         'colspan' => '2',
1843
-      )
1843
+        )
1844 1844
     );
1845
-  }
1845
+    }
1846 1846
 
1847
-  $attr = array('class' => 'ignore_user');
1848
-  $form['ignoreblock']['current_list']['ignored_users']['#value'] = theme('table', $header, $rows, $attr);
1849
-  $output .= drupal_render($form['current_list']);
1847
+    $attr = array('class' => 'ignore_user');
1848
+    $form['ignoreblock']['current_list']['ignored_users']['#value'] = theme('table', $header, $rows, $attr);
1849
+    $output .= drupal_render($form['current_list']);
1850 1850
 
1851
-  if ($form['pager']['#value']) {
1851
+    if ($form['pager']['#value']) {
1852 1852
     $output .= drupal_render($form['pager']);
1853
-  }
1853
+    }
1854 1854
 
1855
-  $output .= drupal_render($form);
1855
+    $output .= drupal_render($form);
1856 1856
 
1857
-  return $output;
1857
+    return $output;
1858 1858
 }
1859 1859
 
1860 1860
 /**
1861
-  * Validate the privacy preferences form.
1862
-  */
1861
+ * Validate the privacy preferences form.
1862
+ */
1863 1863
 function boincwork_privacyprefs_form_validate($form, &$form_state) {
1864
-  require_boinc('util');
1864
+    require_boinc('util');
1865 1865
   
1866
-  // Verify all non-boolean user input values and notify form API of failures
1867
-  // ... currently there are no non-boolean values!
1866
+    // Verify all non-boolean user input values and notify form API of failures
1867
+    // ... currently there are no non-boolean values!
1868 1868
 }
1869 1869
 
1870 1870
 /**
1871
-  * Handle post-validation submission of privacy preferences form.
1872
-  */
1871
+ * Handle post-validation submission of privacy preferences form.
1872
+ */
1873 1873
 function boincwork_privacyprefs_form_submit($form, &$form_state) {
1874
-  require_boinc(array('user', 'prefs'));
1874
+    require_boinc(array('user', 'prefs'));
1875 1875
   
1876
-  global $user;
1877
-  $account = user_load($user->uid);
1876
+    global $user;
1877
+    $account = user_load($user->uid);
1878 1878
   
1879
-  // Load BOINC account
1880
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1879
+    // Load BOINC account
1880
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1881 1881
   
1882
-  // Privacy preferences
1883
-  $boincuser->send_email = ($form_state['values']['send_email']) ? true : false;
1884
-  $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false;
1882
+    // Privacy preferences
1883
+    $boincuser->send_email = ($form_state['values']['send_email']) ? true : false;
1884
+    $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false;
1885 1885
   
1886
-  //project_prefs_update($boincuser, $main_prefs);
1886
+    //project_prefs_update($boincuser, $main_prefs);
1887 1887
   
1888
-  db_set_active('boinc_rw');
1889
-  db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'");
1890
-  db_set_active('default');
1888
+    db_set_active('boinc_rw');
1889
+    db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'");
1890
+    db_set_active('default');
1891 1891
   
1892
-  drupal_set_message(t('Your privacy preferences have been updated.'));
1892
+    drupal_set_message(t('Your privacy preferences have been updated.'));
1893 1893
 }
1894 1894
 
1895 1895
 /**
@@ -1897,14 +1897,14 @@  discard block
 block discarded – undo
1897 1897
  * ignore list.
1898 1898
  */
1899 1899
 function _boincwork_ignore_list_form_submit($form, $form_state) {
1900
-  boincwork_ignore_user_add_user_username($form_state['values']['addusername_toignorelist']);
1901
-  drupal_set_message(
1900
+    boincwork_ignore_user_add_user_username($form_state['values']['addusername_toignorelist']);
1901
+    drupal_set_message(
1902 1902
     bts('@username has been added to your ignore list. See your !privacy_preferences for more details.',
1903
-      array(
1903
+        array(
1904 1904
         '@username' => $form_state['values']['addusername_toignorelist'],
1905 1905
         '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
1906
-      ),
1907
-      NULL, 'boinc:ignore-user-add'),
1906
+        ),
1907
+        NULL, 'boinc:ignore-user-add'),
1908 1908
     'status');
1909 1909
 }
1910 1910
 
@@ -1913,37 +1913,37 @@  discard block
 block discarded – undo
1913 1913
  */
1914 1914
 function boincwork_selectapp_form(&$form_state, $apps, $current_app) {
1915 1915
 
1916
-  $form['selectapp'] = array(
1916
+    $form['selectapp'] = array(
1917 1917
     '#type' => 'select',
1918 1918
     '#attributes' => array(
1919
-      'class' => 'task-app-filter',
1920
-      'onchange' => 'this.form.submit();',
1919
+        'class' => 'task-app-filter',
1920
+        'onchange' => 'this.form.submit();',
1921 1921
     ),
1922 1922
     '#default_value' => $current_app,
1923 1923
     '#options' => $apps,
1924 1924
     '#post_render' => array('_boincwork_selectapp_form_callback'),
1925
-  );
1925
+    );
1926 1926
 
1927
-  // Class task-app-filter-submit for this form is used in
1928
-  // theming. CSS sets 'display:none' if javascript is present. Thus
1929
-  // only non-js users/browsers will see the Apply Filter button.
1930
-  $form['submit'] = array(
1927
+    // Class task-app-filter-submit for this form is used in
1928
+    // theming. CSS sets 'display:none' if javascript is present. Thus
1929
+    // only non-js users/browsers will see the Apply Filter button.
1930
+    $form['submit'] = array(
1931 1931
     '#type' => 'submit',
1932 1932
     '#value' => bts('Apply Filter', array(), NULL, 'boinc:form-save'),
1933 1933
     '#attributes' => array('class' => 'js-hide',),
1934
-  );
1934
+    );
1935 1935
 
1936
-  return $form;
1936
+    return $form;
1937 1937
 }
1938 1938
 
1939 1939
 /**
1940 1940
  * Submit function for select appliacation form.
1941 1941
  */
1942 1942
 function boincwork_selectapp_form_submit($form, &$form_state) {
1943
-  $myargs = arg();
1944
-  array_pop($myargs);
1945
-  $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value'];
1946
-  $form_state['redirect'] = $newpath;
1943
+    $myargs = arg();
1944
+    array_pop($myargs);
1945
+    $newpath = implode('/', $myargs ) . '/' . $form['selectapp']['#value'];
1946
+    $form_state['redirect'] = $newpath;
1947 1947
 }
1948 1948
 
1949 1949
 /**
@@ -1953,7 +1953,7 @@  discard block
 block discarded – undo
1953 1953
  * 'title' for the Application drop down box.
1954 1954
  */
1955 1955
 function _boincwork_selectapp_form_callback($theContent, $theElement) {
1956
-  $disabled = '<option value="-1" disabled hidden';
1957
-  $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent);
1958
-  return $newContent;
1956
+    $disabled = '<option value="-1" disabled hidden';
1957
+    $newContent = preg_replace('/<option value="-1"/', $disabled, $theContent);
1958
+    return $newContent;
1959 1959
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +261 added lines, -261 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * The structure of the general preferences form
16 16
  */
17
-function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) {
17
+function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = false) {
18 18
   $form = array();
19 19
   $prefs = null;
20
-  $established = TRUE;
20
+  $established = true;
21 21
   
22 22
   // Enable AHAH form support for dynamically updating content based on preset
23 23
   ahah_helper_register($form, $form_state);
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     
33 33
     // Take note if this is not an established preference set on the account
34 34
     if (isset($prefs['@attributes']['cleared'])) {
35
-      $established = FALSE;
35
+      $established = false;
36 36
     }
37 37
     
38 38
     // Determine if a preset is selected or if these are custom settings
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
           break;
71 71
       }// switch
72 72
   } else {
73
-      $form_state['storage']['wip'] = TRUE;
73
+      $form_state['storage']['wip'] = true;
74 74
       if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75 75
           if ($established) {
76 76
               $prefs_preset = 'custom';
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
   // Standard option sets
138 138
   $form['boolean_options'] = array(
139 139
     '#type' => 'value',
140
-    '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
140
+    '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
141 141
   );
142 142
   $form['hour_options'] = array(
143 143
     '#type' => 'value',
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     '#prefix' => '<div id="prefs-wrapper">', // This is our wrapper div.
159 159
     '#attributes' => array('class' => 'ahah-container'),
160 160
     '#suffix' => '</div>',
161
-    '#tree'   => TRUE
161
+    '#tree'   => true
162 162
   );
163 163
   //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
164 164
   
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
   
179 179
   // Simplified selectors
180 180
   $form['prefs']['preset'] = array(
181
-      '#title' => bts('Presets', array(), NULL, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'),
181
+      '#title' => bts('Presets', array(), null, 'boinc:account-preferences-preset:-1:for a user to choose a computing or project preference preset.'),
182 182
     '#type' => 'radios',
183 183
     '#description' => ' ',
184 184
     '#options' => array(
185
-      'standard' => bts('Standard', array(), NULL, 'boinc:account-preferences-preset'),
186
-      'maximum' => bts('Maximum', array(), NULL, 'boinc:account-preferences-preset'),
187
-      'green' => bts('Green', array(), NULL, 'boinc:account-preferences-preset'),
188
-      'minimum' => bts('Minimum', array(), NULL, 'boinc:account-preferences-preset'),
189
-      'custom' => bts('Custom', array(), NULL, 'boinc:account-preferences-preset')
185
+      'standard' => bts('Standard', array(), null, 'boinc:account-preferences-preset'),
186
+      'maximum' => bts('Maximum', array(), null, 'boinc:account-preferences-preset'),
187
+      'green' => bts('Green', array(), null, 'boinc:account-preferences-preset'),
188
+      'minimum' => bts('Minimum', array(), null, 'boinc:account-preferences-preset'),
189
+      'custom' => bts('Custom', array(), null, 'boinc:account-preferences-preset')
190 190
     ),
191 191
     '#prefix' => '<div class="simple-form-controls">',
192 192
     '#suffix' => '</div>',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
   );
200 200
   $form['prefs']['select preset'] = array(
201 201
     '#type'  => 'submit',
202
-    '#value' => bts('Update preset', array(), NULL, 'boinc:account-preferences-preset'),
202
+    '#value' => bts('Update preset', array(), null, 'boinc:account-preferences-preset'),
203 203
     '#submit' => array('ahah_helper_generic_submit'),
204 204
     // The 'no-js' class only displays this button if javascript is disabled
205 205
     '#attributes' => array('class' => 'no-js'),
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
   
208 208
   // Advanced preferences
209 209
   $form['prefs']['advanced'] = array(
210
-    '#title' => bts('Advanced settings', array(), NULL, 'boinc:account-preferences-option'),
210
+    '#title' => bts('Advanced settings', array(), null, 'boinc:account-preferences-option'),
211 211
     '#type' => 'fieldset',
212 212
     '#description' => '',
213
-    '#collapsible' => TRUE,
213
+    '#collapsible' => true,
214 214
     '#collapsed' => !$advanced,
215 215
     '#attributes' => array('class' => 'advanced-settings'),
216 216
   );
@@ -226,62 +226,62 @@  discard block
 block discarded – undo
226 226
   );
227 227
   
228 228
   $form['prefs']['advanced']['processor'] = array(
229
-    '#title' => bts('Processor usage', array(), NULL, 'boinc:account-preferences-computing'),
229
+    '#title' => bts('Processor usage', array(), null, 'boinc:account-preferences-computing'),
230 230
     '#type' => 'fieldset',
231 231
     '#description' => '',
232
-    '#collapsible' => FALSE,
233
-    '#collapsed' => FALSE
232
+    '#collapsible' => false,
233
+    '#collapsed' => false
234 234
   );
235 235
   $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
236
-    '#title' => bts('Suspend when computer is on battery?', array(), NULL, 'boinc:account-preferences-computing'),
236
+    '#title' => bts('Suspend when computer is on battery?', array(), null, 'boinc:account-preferences-computing'),
237 237
     '#type' => 'radios',
238
-    '#description' => bts('Suspends computing on portables when running on battery power.', array(), NULL, 'boinc:account-preferences-computing'),
238
+    '#description' => bts('Suspends computing on portables when running on battery power.', array(), null, 'boinc:account-preferences-computing'),
239 239
     '#options' => $form['boolean_options']['#value'],
240 240
     '#attributes' => array('class' => 'fancy'),
241 241
     '#default_value' => ($default['run_on_batteries']) ? 0 : 1 // intentional inversion of setting
242 242
   );
243 243
   $form['prefs']['advanced']['processor']['run_if_user_active'] = array(
244
-    '#title' => bts('Suspend when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'),
244
+    '#title' => bts('Suspend when computer is in use?', array(), null, 'boinc:account-preferences-computing'),
245 245
     '#type' => 'radios',
246
-    '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'),
246
+    '#description' => bts("Suspends computing and file transfers when you're using the computer.", array(), null, 'boinc:account-preferences-computing'),
247 247
     '#options' => $form['boolean_options']['#value'],
248 248
     '#attributes' => array('class' => 'fancy'),
249 249
     '#default_value' => ($default['run_if_user_active']) ? 0 : 1 // intentional inversion of setting
250 250
   );
251 251
   $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array(
252
-    '#title' => bts('Suspend GPU computing when computer is in use?', array(), NULL, 'boinc:account-preferences-computing'),
252
+    '#title' => bts('Suspend GPU computing when computer is in use?', array(), null, 'boinc:account-preferences-computing'),
253 253
     '#type' => 'radios',
254
-    '#description' => bts("Suspends GPU computing when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing'),
254
+    '#description' => bts("Suspends GPU computing when you're using the computer.", array(), null, 'boinc:account-preferences-computing'),
255 255
     '#options' => $form['boolean_options']['#value'],
256 256
     '#attributes' => array('class' => 'fancy'),
257 257
     '#default_value' => ($default['run_gpu_if_user_active']) ? 0 : 1 // intentional inversion of setting
258 258
   );
259 259
   $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
260
-      '#title' => bts('"In use" means mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
260
+      '#title' => bts('"In use" means mouse/keyboard input in last', array(), null, 'boinc:account-preferences-computing'),
261 261
     '#type' => 'textfield',
262
-    '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
262
+    '#field_suffix' => bts('minutes', array(), null, 'boinc:unit-of-time'),
263 263
     '#default_value' => $default['idle_time_to_run'],
264 264
     '#size' => 1,
265
-    '#description' => bts('This determines when the computer is considered "in use".', array(), NULL, 'boinc:account-preferences-computing')
265
+    '#description' => bts('This determines when the computer is considered "in use".', array(), null, 'boinc:account-preferences-computing')
266 266
   );
267 267
   $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array(
268
-    '#title' => bts('Suspend when no mouse/keyboard input in last', array(), NULL, 'boinc:account-preferences-computing'),
268
+    '#title' => bts('Suspend when no mouse/keyboard input in last', array(), null, 'boinc:account-preferences-computing'),
269 269
     '#type' => 'textfield',
270
-    '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
270
+    '#field_suffix' => bts('minutes', array(), null, 'boinc:unit-of-time'),
271 271
     '#default_value' => $default['suspend_if_no_recent_input'],
272 272
     '#size' => 1,
273
-    '#description' => bts('This allows some computers to enter low-power mode when not in use.', array(), NULL, 'boinc:account-preferences-computing')
273
+    '#description' => bts('This allows some computers to enter low-power mode when not in use.', array(), null, 'boinc:account-preferences-computing')
274 274
   );
275 275
   $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array(
276
-    '#title' => bts('Suspend when non-BOINC CPU usage is above', array(), NULL, 'boinc:account-preferences-computing'),
276
+    '#title' => bts('Suspend when non-BOINC CPU usage is above', array(), null, 'boinc:account-preferences-computing'),
277 277
     '#type' => 'textfield',
278 278
     '#field_suffix' => '%',
279 279
     '#default_value' => $default['suspend_cpu_usage'],
280 280
     '#size' => 1,
281
-    '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), NULL, 'boinc:account-preferences-computing'),
281
+    '#description' => bts('Suspend computing when your computer is busy running other programs.', array(), null, 'boinc:account-preferences-computing'),
282 282
   );
283 283
   $form['prefs']['advanced']['processor']['hour_label'] = array(
284
-    '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
284
+    '#value' => '<div class="form-item"><label>' . bts('Compute only between:', array(), null, 'boinc:account-preferences-computing') . '</label></div>'
285 285
   );
286 286
   $form['prefs']['advanced']['processor']['start_hour'] = array(
287 287
     '#type' => 'select',
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     '#default_value' => $default['start_hour']
290 290
   );
291 291
   $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
292
-    '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
292
+    '#value' => '<span>' . bts('and', array(), null, 'boinc:account-preference') . '</span>'
293 293
   );
294 294
   $form['prefs']['advanced']['processor']['end_hour'] = array(
295 295
     '#type' => 'select',
@@ -297,164 +297,164 @@  discard block
 block discarded – undo
297 297
     '#default_value' => $default['end_hour']
298 298
   );
299 299
   $form['prefs']['advanced']['processor']['hour_description'] = array(
300
-    '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
300
+    '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.', array(), null, 'boinc:account-preferences-computing') . '</div></div>'
301 301
   );
302 302
   $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
303
-    '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), NULL, 'boinc:account-preferences-computing'),
303
+    '#title' => bts('Leave non-GPU tasks in memory while suspended?', array(), null, 'boinc:account-preferences-computing'),
304 304
     '#type' => 'radios',
305 305
     '#options' => $form['boolean_options']['#value'],
306 306
     '#attributes' => array('class' => 'fancy'),
307 307
     '#default_value' => $default['leave_apps_in_memory'],
308
-    '#description' => bts('If "Yes", suspended tasks stay in memory, and resume with no work lost. If "No", suspended tasks are removed from memory, and resume from their last checkpoint.', array(), NULL, 'boinc:account-preferences-computing')
308
+    '#description' => bts('If "Yes", suspended tasks stay in memory, and resume with no work lost. If "No", suspended tasks are removed from memory, and resume from their last checkpoint.', array(), null, 'boinc:account-preferences-computing')
309 309
   );
310 310
   $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array(
311
-    '#title' => bts('Switch between tasks every', array(), NULL, 'boinc:account-preferences-computing'),
311
+    '#title' => bts('Switch between tasks every', array(), null, 'boinc:account-preferences-computing'),
312 312
     '#type' => 'textfield',
313
-    '#field_suffix' => bts('minutes', array(), NULL, 'boinc:unit-of-time'),
313
+    '#field_suffix' => bts('minutes', array(), null, 'boinc:unit-of-time'),
314 314
     '#default_value' => $default['cpu_scheduling_period_minutes'],
315 315
     '#size' => 1,
316
-    '#description' => bts('If you run several projects, BOINC may switch between them this often.', array(), NULL, 'boinc:account-preferences-computing')
316
+    '#description' => bts('If you run several projects, BOINC may switch between them this often.', array(), null, 'boinc:account-preferences-computing')
317 317
   );
318 318
   $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array(
319
-    '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'),
319
+    '#title' => bts('Use at most', array(), null, 'boinc:account-preferences-computing'),
320 320
     '#type' => 'textfield',
321
-    '#field_suffix' => bts('% of the processors', array(), NULL, 'boinc:account-preferences-computing'),
321
+    '#field_suffix' => bts('% of the processors', array(), null, 'boinc:account-preferences-computing'),
322 322
     '#default_value' => $default['max_ncpus_pct'],
323 323
     '#size' => 1,
324
-    '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.', array(), NULL, 'boinc:account-preferences-computing'),
324
+    '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.', array(), null, 'boinc:account-preferences-computing'),
325 325
   );
326 326
   $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array(
327
-    '#title' => bts('Use at most', array(), NULL, 'boinc:account-preferences-computing'),
327
+    '#title' => bts('Use at most', array(), null, 'boinc:account-preferences-computing'),
328 328
     '#type' => 'textfield',
329
-    '#field_suffix' => bts('% of the CPU time', array(), NULL, 'boinc:account-preferences-computing'),
329
+    '#field_suffix' => bts('% of the CPU time', array(), null, 'boinc:account-preferences-computing'),
330 330
     '#default_value' => $default['cpu_usage_limit'],
331 331
     '#size' => 1,
332
-    '#description' => bts('Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.', array(), NULL, 'boinc:account-preferences-computing')
332
+    '#description' => bts('Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.', array(), null, 'boinc:account-preferences-computing')
333 333
   );
334 334
   
335 335
   // Disk and memory preferences
336 336
   $form['prefs']['advanced']['storage'] = array(
337
-    '#title' => bts('Disk and memory usage', array(), NULL, 'boinc:account-preferences-computing'),
337
+    '#title' => bts('Disk and memory usage', array(), null, 'boinc:account-preferences-computing'),
338 338
     '#type' => 'fieldset',
339 339
     '#description' => '',
340
-    '#collapsible' => FALSE,
341
-    '#collapsed' => FALSE
340
+    '#collapsible' => false,
341
+    '#collapsed' => false
342 342
   );
343 343
   $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
344
-    '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'),
344
+    '#title' => bts('Disk: use no more than', array(), null, 'boinc:account-preferences-computing'),
345 345
     '#type' => 'textfield',
346 346
     '#field_suffix' => 'GB',
347 347
     '#default_value' => $default['disk_max_used_gb'],
348 348
     '#size' => 1,
349
-    '#description' => bts('Limit the total amount of disk space used by BOINC.', array(), NULL, 'boinc:account-preferences-computing'),
349
+    '#description' => bts('Limit the total amount of disk space used by BOINC.', array(), null, 'boinc:account-preferences-computing'),
350 350
   ); 
351 351
   $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array(
352
-    '#title' => bts('Disk: leave at least', array(), NULL, 'boinc:account-preferences-computing'),
352
+    '#title' => bts('Disk: leave at least', array(), null, 'boinc:account-preferences-computing'),
353 353
     '#type' => 'textfield',
354 354
     '#field_suffix' => 'GB free',
355 355
     '#default_value' => $default['disk_min_free_gb'],
356 356
     '#size' => 1,
357
-    '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.', array(), NULL, 'boinc:account-preferences-computing'),
357
+    '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.', array(), null, 'boinc:account-preferences-computing'),
358 358
   );
359 359
   $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array(
360
-    '#title' => bts('Disk: use no more than', array(), NULL, 'boinc:account-preferences-computing'),
360
+    '#title' => bts('Disk: use no more than', array(), null, 'boinc:account-preferences-computing'),
361 361
     '#type' => 'textfield',
362
-    '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
362
+    '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'),
363 363
     '#default_value' => $default['disk_max_used_pct'],
364 364
     '#size' => 1,
365
-    '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.', array(), NULL, 'boinc:account-preferences-computing')
365
+    '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.', array(), null, 'boinc:account-preferences-computing')
366 366
   ); 
367 367
   $form['prefs']['advanced']['storage']['disk_interval'] = array(
368
-    '#title' => bts('Request tasks to checkpoint at most every', array(), NULL, 'boinc:account-preferences-computing'),
368
+    '#title' => bts('Request tasks to checkpoint at most every', array(), null, 'boinc:account-preferences-computing'),
369 369
     '#type' => 'textfield',
370
-    '#field_suffix' => bts('seconds', array(), NULL, 'boinc:unit-of-time'),
370
+    '#field_suffix' => bts('seconds', array(), null, 'boinc:unit-of-time'),
371 371
     '#default_value' => $default['disk_interval'],
372 372
     '#size' => 1,
373
-    '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.', array(), NULL, 'boinc:account-preferences-computing')
373
+    '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.', array(), null, 'boinc:account-preferences-computing')
374 374
   );
375 375
   $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array(
376
-    '#title' => bts('Page/swap file: use at most', array(), NULL, 'boinc:account-preferences-computing'),
376
+    '#title' => bts('Page/swap file: use at most', array(), null, 'boinc:account-preferences-computing'),
377 377
     '#type' => 'textfield',
378
-    '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
378
+    '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'),
379 379
     '#default_value' => $default['vm_max_used_pct'],
380 380
     '#size' => 1,
381
-    '#description' => bts('Limit the swap space (page file) used by BOINC.', array(), NULL, 'boinc:account-preferences-computing')
381
+    '#description' => bts('Limit the swap space (page file) used by BOINC.', array(), null, 'boinc:account-preferences-computing')
382 382
   );
383 383
   $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array(
384
-    '#title' => bts('Memory: when computer is in use, use at most', array(), NULL, 'boinc:account-preferences-computing'),
384
+    '#title' => bts('Memory: when computer is in use, use at most', array(), null, 'boinc:account-preferences-computing'),
385 385
     '#type' => 'textfield',
386
-    '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
386
+    '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'),
387 387
     '#default_value' => $default['ram_max_used_busy_pct'],
388 388
     '#size' => 1,
389
-    '#description' => bts("Limit the memory used by BOINC when you're using the computer.", array(), NULL, 'boinc:account-preferences-computing')
389
+    '#description' => bts("Limit the memory used by BOINC when you're using the computer.", array(), null, 'boinc:account-preferences-computing')
390 390
   );
391 391
   $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array(
392
-    '#title' => bts('Memory: when computer is not in use, use at most', array(), NULL, 'boinc:account-preferences-computing'),
392
+    '#title' => bts('Memory: when computer is not in use, use at most', array(), null, 'boinc:account-preferences-computing'),
393 393
     '#type' => 'textfield',
394
-    '#field_suffix' => bts('% of total', array(), NULL, 'boinc:account-preferences-computing'),
394
+    '#field_suffix' => bts('% of total', array(), null, 'boinc:account-preferences-computing'),
395 395
     '#default_value' => $default['ram_max_used_idle_pct'],
396 396
     '#size' => 1,
397
-    '#description' => bts("Limit the memory used by BOINC when you're not using the computer.", array(), NULL, 'boinc:account-preferences-computing')
397
+    '#description' => bts("Limit the memory used by BOINC when you're not using the computer.", array(), null, 'boinc:account-preferences-computing')
398 398
   );
399 399
   
400 400
   // Network preferences
401 401
   $form['prefs']['advanced']['network'] = array(
402
-    '#title' => bts('Network usage', array(), NULL, 'boinc:account-preferences-computing'),
402
+    '#title' => bts('Network usage', array(), null, 'boinc:account-preferences-computing'),
403 403
     '#type' => 'fieldset',
404 404
     '#description' => '',
405
-    '#collapsible' => FALSE,
406
-    '#collapsed' => FALSE
405
+    '#collapsible' => false,
406
+    '#collapsed' => false
407 407
   );
408 408
   $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
409
-    '#title' => bts('Store at least', array(), NULL, 'boinc:account-preferences-computing'),
409
+    '#title' => bts('Store at least', array(), null, 'boinc:account-preferences-computing'),
410 410
     '#type' => 'textfield',
411
-    '#field_suffix' => bts('days of work', array(), NULL, 'boinc:account-preferences-computing'),
411
+    '#field_suffix' => bts('days of work', array(), null, 'boinc:account-preferences-computing'),
412 412
     '#default_value' => $default['work_buf_min_days'],
413 413
     '#size' => 1,
414
-    '#description' => bts('Store at least enough tasks to keep the computer busy for this long.', array(), NULL, 'boinc:account-preferences-computing')
414
+    '#description' => bts('Store at least enough tasks to keep the computer busy for this long.', array(), null, 'boinc:account-preferences-computing')
415 415
   ); 
416 416
   $form['prefs']['advanced']['network']['work_buf_additional_days'] = array(
417
-    '#title' => bts('Store up to an additional', array(), NULL, 'boinc:account-preferences-computing'),
417
+    '#title' => bts('Store up to an additional', array(), null, 'boinc:account-preferences-computing'),
418 418
     '#type' => 'textfield',
419
-    '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'),
419
+    '#field_suffix' => bts('days', array(), null, 'boinc:unit-of-time'),
420 420
     '#default_value' => $default['work_buf_additional_days'],
421 421
     '#size' => 1,
422
-    '#description' => bts('Store additional tasks above the minimum level.  Determines how much work is requested when contacting a project.', array(), NULL, 'boinc:account-preferences-computing')
422
+    '#description' => bts('Store additional tasks above the minimum level.  Determines how much work is requested when contacting a project.', array(), null, 'boinc:account-preferences-computing')
423 423
   ); 
424 424
   $form['prefs']['advanced']['network']['confirm_before_connecting'] = array(
425
-    '#title' => bts('Confirm before connecting to Internet?', array(), NULL, 'boinc:account-preferences-computing'),
425
+    '#title' => bts('Confirm before connecting to Internet?', array(), null, 'boinc:account-preferences-computing'),
426 426
     '#type' => 'radios',
427 427
     '#options' => $form['boolean_options']['#value'],
428 428
     '#attributes' => array('class' => 'fancy'),
429 429
     '#default_value' => $default['confirm_before_connecting'],
430
-    '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing')
430
+    '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), null, 'boinc:account-preferences-computing')
431 431
   ); 
432 432
   $form['prefs']['advanced']['network']['hangup_if_dialed'] = array(
433
-    '#title' => bts('Disconnect when done?', array(), NULL, 'boinc:account-preferences-computing'),
433
+    '#title' => bts('Disconnect when done?', array(), null, 'boinc:account-preferences-computing'),
434 434
     '#type' => 'radios',
435 435
     '#options' => $form['boolean_options']['#value'],
436 436
     '#attributes' => array('class' => 'fancy'),
437 437
     '#default_value' => $default['hangup_if_dialed'],
438
-    '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), NULL, 'boinc:account-preferences-computing')
438
+    '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.', array(), null, 'boinc:account-preferences-computing')
439 439
   );
440 440
   $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array(
441
-    '#title' => bts('Limit download rate to', array(), NULL, 'boinc:account-preferences-computing'),
441
+    '#title' => bts('Limit download rate to', array(), null, 'boinc:account-preferences-computing'),
442 442
     '#type' => 'textfield',
443 443
     '#field_suffix' => 'Kbytes/sec',
444 444
     '#default_value' => $default['max_bytes_sec_down']/1000,
445 445
     '#size' => 1,
446
-    '#description' => bts('Limit the download rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing')
446
+    '#description' => bts('Limit the download rate of file transfers.', array(), null, 'boinc:account-preferences-computing')
447 447
   ); 
448 448
   $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array(
449
-    '#title' => bts('Limit upload rate to', array(), NULL, 'boinc:account-preferences-computing'),
449
+    '#title' => bts('Limit upload rate to', array(), null, 'boinc:account-preferences-computing'),
450 450
     '#type' => 'textfield',
451 451
     '#field_suffix' => 'Kbytes/sec',
452 452
     '#default_value' => $default['max_bytes_sec_up']/1000,
453 453
     '#size' => 1,
454
-    '#description' => bts('Limit the upload rate of file transfers.', array(), NULL, 'boinc:account-preferences-computing')
454
+    '#description' => bts('Limit the upload rate of file transfers.', array(), null, 'boinc:account-preferences-computing')
455 455
   );
456 456
   $form['prefs']['advanced']['network']['hour_label'] = array(
457
-    '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), NULL, 'boinc:account-preferences-computing') . '</label></div>'
457
+    '#value' => '<div class="form-item"><label>' . bts('Transfer files only between', array(), null, 'boinc:account-preferences-computing') . '</label></div>'
458 458
   );
459 459
   $form['prefs']['advanced']['network']['net_start_hour'] = array(
460 460
     '#type' => 'select',
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
     '#default_value' => $default['net_start_hour']
463 463
   );
464 464
   $form['prefs']['advanced']['network']['hour_delimiter'] = array(
465
-    '#value' => '<span>' . bts('and', array(), NULL, 'boinc:account-preference') . '</span>'
465
+    '#value' => '<span>' . bts('and', array(), null, 'boinc:account-preference') . '</span>'
466 466
   );
467 467
   $form['prefs']['advanced']['network']['net_end_hour'] = array(
468 468
     '#type' => 'select',
@@ -470,10 +470,10 @@  discard block
 block discarded – undo
470 470
     '#default_value' => $default['net_end_hour']
471 471
   );
472 472
   $form['prefs']['advanced']['network']['hour_description'] = array(
473
-    '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), NULL, 'boinc:account-preferences-computing') . '</div></div>'
473
+    '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.', array(), null, 'boinc:account-preferences-computing') . '</div></div>'
474 474
   ); 
475 475
   $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
476
-    '#title' => bts('Limit usage to', array(), NULL, 'boinc:account-preferences-computing'),
476
+    '#title' => bts('Limit usage to', array(), null, 'boinc:account-preferences-computing'),
477 477
     '#type' => 'textfield',
478 478
     '#field_suffix' => 'Mbytes',
479 479
     '#default_value' => $default['daily_xfer_limit_mb'],
@@ -482,18 +482,18 @@  discard block
 block discarded – undo
482 482
   $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array(
483 483
     '#field_prefix' => 'every',
484 484
     '#type' => 'textfield',
485
-    '#field_suffix' => bts('days', array(), NULL, 'boinc:unit-of-time'),
485
+    '#field_suffix' => bts('days', array(), null, 'boinc:unit-of-time'),
486 486
     '#default_value' => $default['daily_xfer_period_days'],
487 487
     '#size' => 1,
488
-    '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.', array(), NULL, 'boinc:account-preferences-computing'),
488
+    '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.', array(), null, 'boinc:account-preferences-computing'),
489 489
   ); 
490 490
   $form['prefs']['advanced']['network']['dont_verify_images'] = array(
491
-    '#title' => bts('Skip data verification for image files?', array(), NULL, 'boinc:account-preferences-computing'),
491
+    '#title' => bts('Skip data verification for image files?', array(), null, 'boinc:account-preferences-computing'),
492 492
     '#type' => 'radios',
493 493
     '#options' => $form['boolean_options']['#value'],
494 494
     '#attributes' => array('class' => 'fancy'),
495 495
     '#default_value' => $default['dont_verify_images'],
496
-    '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.', array(), NULL, 'boinc:account-preferences-computing')
496
+    '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.', array(), null, 'boinc:account-preferences-computing')
497 497
   );
498 498
   
499 499
   // The "fancy radios" are made via javascript on document load. In order for
@@ -526,27 +526,27 @@  discard block
 block discarded – undo
526 526
   $form['prefs']['submit'] = array(
527 527
     '#prefix' => '<li class="first tab">',
528 528
     '#type' => 'submit',
529
-    '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
529
+    '#value' => bts('Save changes', array(), null, 'boinc:form-save'),
530 530
     '#suffix' => '</li>'
531 531
   );
532 532
   $form['prefs']['form control tabs'] = array(
533
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
533
+    '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
534 534
   );
535
-  if ($venue AND $venue != 'generic') {
535
+  if ($venue and $venue != 'generic') {
536 536
     global $base_path;
537 537
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
538
-      l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
538
+      l(bts('Clear', array(), null, 'boinc:form-clear'), "account/prefs/computing/clear/{$venue}",
539 539
         array(
540 540
           'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541 541
           'attributes' => array(
542 542
             'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
-              array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
543
+              array('@name' => $venue), null, 'boinc:account-preferences') . '\')'
544 544
           )
545 545
         )
546 546
       ) . '</li>';
547 547
   }
548 548
   $form['prefs']['view control'] = array(
549
-    '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>'
549
+    '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), null, 'boinc:account-preferences') . ')', 'account/prefs/computing/combined') . '</li>'
550 550
   );
551 551
   $form['prefs']['form control tabs suffix'] = array(
552 552
     '#value' => '</ul>'
@@ -567,33 +567,33 @@  discard block
 block discarded – undo
567 567
   // Verify all non-boolean user input values and notify form API of failures
568 568
   
569 569
   // Processing preferences
570
-  if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
571
-  if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
572
-  if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
573
-  if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
574
-  if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
575
-  if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
576
-  if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
577
-  if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
570
+  if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
571
+  if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
572
+  if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
573
+  if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
574
+  if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
575
+  if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
576
+  if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
577
+  if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
578 578
 
579 579
   // Storage preferences
580
-  if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
581
-  if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
582
-  if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
583
-  if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
584
-  if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
585
-  if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
586
-  if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
580
+  if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
581
+  if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
582
+  if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
583
+  if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
584
+  if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
585
+  if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
586
+  if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
587 587
 
588 588
   // Network preferences
589
-  if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
590
-  if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
591
-  if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
592
-  if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
593
-  if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), NULL, 'boinc:account-prefrences-computing'));
594
-  if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
595
-  if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
596
-  if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), NULL, 'boinc:account-preferences-computing'));
589
+  if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
590
+  if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
591
+  if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
592
+  if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
593
+  if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}"), null, 'boinc:account-prefrences-computing'));
594
+  if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
595
+  if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
596
+  if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}"), null, 'boinc:account-preferences-computing'));
597 597
 }
598 598
 
599 599
 /**
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
     unset($prefs['@attributes']['preset']);
654 654
   }
655 655
   // Save the preset selection (or lack thereof)
656
-  if (!$preset OR $preset == 'custom') {
656
+  if (!$preset or $preset == 'custom') {
657 657
     $prefs['preset'] = 'custom';
658 658
   }
659 659
   else {
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
     watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysql_error()), WATCHDOG_ERROR);
673 673
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
674 674
   }
675
-  elseif (!drupal_get_messages('status', FALSE)) {
675
+  elseif (!drupal_get_messages('status', false)) {
676 676
     // Show this message if the set wasn't created automatically (in which case
677 677
     // there is a message tailored to that) {
678 678
     drupal_set_message(t('Your preferences have been updated.
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
   ));
707 707
   db_set_active('default');
708 708
   $current_host->task_count = boincwork_host_get_task_count($current_host->id);
709
-  $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count;
709
+  $current_host->is_new = !$current_host->total_credit and !$current_host->task_count;
710 710
   // Get the list of all other hosts owned by this user for comparison
711 711
   db_set_active('boinc_ro');
712 712
   $all_other_hosts = db_query("
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
     // First, disqualify if hosts were active at the same time
723 723
     if (!$current_host->is_new) {
724 724
       $other_host->task_count = boincwork_host_get_task_count($other_host->id);
725
-      $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count;
725
+      $other_host->is_new = !$other_host->total_credit and !$other_host->task_count;
726 726
       if (!$other_host->is_new) {
727 727
         // If both hosts being compared are not new, see if times overlap
728 728
         if (!times_disjoint($current_host, $other_host)) {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 /**
756 756
  * Perform the database updates to merge the old host into the new host
757 757
  */
758
-function boincwork_host_merge($old_host, $new_host, &$message = NULL) {
758
+function boincwork_host_merge($old_host, $new_host, &$message = null) {
759 759
   // Decay the average credit of the two hosts
760 760
   require_boinc('credit');
761 761
   $now = time();
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
   );
784 784
   db_set_active('default');
785 785
   if (!$credit_updated) {
786
-    if ($message !== NULL) {
787
-      $message = bts('Could not update credit', array(), NULL, 'boinc:account-host-merge');
786
+    if ($message !== null) {
787
+      $message = bts('Could not update credit', array(), null, 'boinc:account-host-merge');
788 788
     }
789
-    return FALSE;
789
+    return false;
790 790
   }
791 791
   
792 792
   // Move results from the old host to the new host
@@ -799,10 +799,10 @@  discard block
 block discarded – undo
799 799
   );
800 800
   db_set_active('default');
801 801
   if (!$results_updated) {
802
-    if ($message !== NULL) {
803
-      $message = bts('Could not update results', array(), NULL, 'boinc:account-host-merge');
802
+    if ($message !== null) {
803
+      $message = bts('Could not update results', array(), null, 'boinc:account-host-merge');
804 804
     }
805
-    return FALSE;
805
+    return false;
806 806
   }
807 807
   
808 808
   // Retire the old host
@@ -819,13 +819,13 @@  discard block
 block discarded – undo
819 819
   );
820 820
   db_set_active('default');
821 821
   if (!$old_host_retired) {
822
-    if ($message !== NULL) {
823
-      $message = bts('Could not retire old computer', array(), NULL, 'boinc:account-host-merge');
822
+    if ($message !== null) {
823
+      $message = bts('Could not retire old computer', array(), null, 'boinc:account-host-merge');
824 824
     }
825
-    return FALSE;
825
+    return false;
826 826
   }
827 827
   
828
-  return TRUE;
828
+  return true;
829 829
 }
830 830
 
831 831
 /**
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
   $form['overview'] = array(
855 855
     '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to'
856 856
       . ' the same computer by mistake. You can correct this by merging old'
857
-      . ' identities with the newest one.', array(), NULL, 'boinc:account-host-merge') . '</p>'
857
+      . ' identities with the newest one.', array(), null, 'boinc:account-host-merge') . '</p>'
858 858
       . '<p>'
859 859
       . bts('Check the computers that are the same as @name'
860 860
       . ' (created on @date at @time with computer ID @id)',
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
           '@time' => date('G:i:s T', $current_host->create_time),
865 865
           '@id' => $current_host->id,
866 866
         ),
867
-        NULL, 'boinc:account-host-merge') . '</p>',
867
+        null, 'boinc:account-host-merge') . '</p>',
868 868
   );
869 869
   
870 870
   $options = array();
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
   $form['merge'] = array(
880 880
     '#title' => '',
881 881
     '#type' => 'tableselect',
882
-    '#header' => array(bts('Name', array(), NULL, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), NULL, 'boinc:host-details'), bts('Computer ID', array(), NULL, 'boinc:host-list')),
882
+    '#header' => array(bts('Name', array(), null, 'boinc:details:-1:name-of-the-host-or-task-or-workunit-etc-being-viewed-ignoreoverwrite'), bts('Created', array(), null, 'boinc:host-details'), bts('Computer ID', array(), null, 'boinc:host-list')),
883 883
     '#options' => $options,
884 884
   );
885 885
   
@@ -894,11 +894,11 @@  discard block
 block discarded – undo
894 894
   $form['prefs']['submit'] = array(
895 895
     '#prefix' => '<li class="first tab">',
896 896
     '#type' => 'submit',
897
-    '#value' => bts('Merge', array(), NULL, 'boinc:form-merge'),
897
+    '#value' => bts('Merge', array(), null, 'boinc:form-merge'),
898 898
     '#suffix' => '</li>'
899 899
   );
900 900
   $form['prefs']['form control tabs'] = array(
901
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), "host/{$host_id}") . '</li>'
901
+    '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), "host/{$host_id}") . '</li>'
902 902
   );
903 903
   
904 904
   return $form;
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
   if ($merged) {
937 937
     // Generate a natural language list of IDs that were merged
938 938
     $oxford_comma = ',';
939
-    $conjunction = bts('and', array(), NULL, 'boinc:account-preference');
939
+    $conjunction = bts('and', array(), null, 'boinc:account-preference');
940 940
     $list = array_keys($merged);
941 941
     $last = array_pop($list);
942 942
     if ($list) {
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
           '@old_id' => $list,
956 956
           '@id' => $current_host_id
957 957
         ),
958
-        NULL, 'boinc:account-host-merge'));
958
+        null, 'boinc:account-host-merge'));
959 959
     }
960 960
     else {
961 961
       drupal_set_message(bts(
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
           '@old_ids' => $list,
965 965
           '@id' => $current_host_id
966 966
         ),
967
-        NULL, 'boinc:account-host-merge'));
967
+        null, 'boinc:account-host-merge'));
968 968
     }
969 969
   }
970 970
   
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
             '@old_id' => $id,
978 978
             '@message' => $error,
979 979
           ),
980
-          NULL, 'boinc:account-host-merge'),
980
+          null, 'boinc:account-host-merge'),
981 981
         'warning'
982 982
       );
983 983
     }
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
   global $user;
999 999
   $account = user_load($user->uid);
1000 1000
   
1001
-  $established = TRUE;
1001
+  $established = true;
1002 1002
   
1003 1003
   // Get availability of special BOINC preferences
1004 1004
   require_boinc(array('util'));
@@ -1009,26 +1009,26 @@  discard block
 block discarded – undo
1009 1009
   
1010 1010
   // Take note if this is not an established preference set on the account
1011 1011
   if (isset($prefs['@attributes']['cleared'])) {
1012
-    $established = FALSE;
1012
+    $established = false;
1013 1013
   }
1014 1014
 
1015 1015
   // Extract modified tag if present
1016
-  $modified = NULL;
1016
+  $modified = null;
1017 1017
   if (isset($prefs['modified']['@value'])) {
1018 1018
     $modified = $prefs['modified']['@value'];
1019 1019
   }
1020 1020
 
1021
-  $venue_is_default = FALSE;
1021
+  $venue_is_default = false;
1022 1022
   if ($account->boincuser_default_pref_set) {
1023 1023
     if ($account->boincuser_default_pref_set == $venue) {
1024
-      $venue_is_default = TRUE;
1024
+      $venue_is_default = true;
1025 1025
     }
1026 1026
   }
1027
-  elseif (!$venue OR $venue == 'generic') {
1028
-    $venue_is_default = TRUE;
1027
+  elseif (!$venue or $venue == 'generic') {
1028
+    $venue_is_default = true;
1029 1029
   }
1030 1030
   else {
1031
-    $venue_is_default = FALSE;
1031
+    $venue_is_default = false;
1032 1032
   }
1033 1033
   
1034 1034
   // Define form defaults
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
   // Standard option sets
1058 1058
   $form['boolean_options'] = array(
1059 1059
     '#type' => 'value',
1060
-    '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1060
+    '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1061 1061
   );
1062 1062
   
1063 1063
   // Identify preference sets that are established to distinguish what has been
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
   $form['#established'] = $established;
1066 1066
   
1067 1067
   // Top level form options
1068
-  $form['#tree'] = TRUE;
1068
+  $form['#tree'] = true;
1069 1069
   
1070 1070
   // Hidden elements
1071 1071
   $form['modified'] = array(
@@ -1083,77 +1083,77 @@  discard block
 block discarded – undo
1083 1083
   
1084 1084
   // Common project preferences  
1085 1085
   $form['resource'] = array(
1086
-    '#title' => bts('Resource settings', array(), NULL, 'boinc:account-preferences-project'),
1086
+    '#title' => bts('Resource settings', array(), null, 'boinc:account-preferences-project'),
1087 1087
     '#type' => 'fieldset',
1088 1088
     '#description' => null,
1089
-    '#collapsible' => TRUE,
1090
-    '#collapsed' => FALSE
1089
+    '#collapsible' => true,
1090
+    '#collapsed' => false
1091 1091
   );
1092 1092
   $form['resource']['resource_share'] = array(
1093
-    '#title' => bts('Resource share', array(), NULL, 'boinc:account-preferences-project'),
1093
+    '#title' => bts('Resource share', array(), null, 'boinc:account-preferences-project'),
1094 1094
     '#type' => 'textfield',
1095 1095
     '#default_value' => $default['resource_share'],
1096 1096
     '#size' => 5,
1097
-    '#description' => bts("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3.", array(), NULL, 'boinc:account-preferences-project')
1097
+    '#description' => bts("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3.", array(), null, 'boinc:account-preferences-project')
1098 1098
   );
1099 1099
   if ($app_types->count > 1) {
1100 1100
     if ($app_types->cpu) {
1101 1101
       $form['resource']['no_cpu'] = array(
1102
-        '#title' => bts('Use CPU', array(), NULL, 'boinc:account-preferences-project'),
1102
+        '#title' => bts('Use CPU', array(), null, 'boinc:account-preferences-project'),
1103 1103
         '#type' => 'radios',
1104 1104
         '#options' => $form['boolean_options']['#value'],
1105 1105
         '#attributes' => array('class' => 'fancy'),
1106 1106
         '#default_value' => $default['no_cpu'] ? 0 : 1,
1107
-        '#description' => bts('Request CPU-only tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1107
+        '#description' => bts('Request CPU-only tasks from this project.', array(), null, 'boinc:account-preferences-project')
1108 1108
       );
1109 1109
     }
1110 1110
     if ($app_types->cuda) {
1111 1111
       $form['resource']['no_cuda'] = array(
1112
-        '#title' => bts('Use NVIDIA GPU', array(), NULL, 'boinc:account-preferences-project'),
1112
+        '#title' => bts('Use NVIDIA GPU', array(), null, 'boinc:account-preferences-project'),
1113 1113
         '#type' => 'radios',
1114 1114
         '#options' => $form['boolean_options']['#value'],
1115 1115
         '#attributes' => array('class' => 'fancy'),
1116 1116
         '#default_value' => $default['no_cuda'] ? 0 : 1,
1117
-        '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1117
+        '#description' => bts('Request NVIDIA GPU tasks from this project.', array(), null, 'boinc:account-preferences-project')
1118 1118
       );
1119 1119
     }
1120 1120
     if ($app_types->ati) {
1121 1121
       $form['resource']['no_ati'] = array(
1122
-        '#title' => bts('Use ATI GPU', array(), NULL, 'boinc:account-preferences-project'),
1122
+        '#title' => bts('Use ATI GPU', array(), null, 'boinc:account-preferences-project'),
1123 1123
         '#type' => 'radios',
1124 1124
         '#options' => $form['boolean_options']['#value'],
1125 1125
         '#attributes' => array('class' => 'fancy'),
1126 1126
         '#default_value' => $default['no_ati'] ? 0 : 1,
1127
-        '#description' => bts('Request ATI GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1127
+        '#description' => bts('Request ATI GPU tasks from this project.', array(), null, 'boinc:account-preferences-project')
1128 1128
       );
1129 1129
     }
1130 1130
     if ($app_types->intel_gpu) {
1131 1131
       $form['resource']['no_intel_gpu'] = array(
1132
-        '#title' => bts('Use INTEL GPU', array(), NULL, 'boinc:account-preferences-project'),
1132
+        '#title' => bts('Use INTEL GPU', array(), null, 'boinc:account-preferences-project'),
1133 1133
         '#type' => 'radios',
1134 1134
         '#options' => $form['boolean_options']['#value'],
1135 1135
         '#attributes' => array('class' => 'fancy'),
1136 1136
         '#default_value' => $default['no_intel_gpu'] ? 0 : 1,
1137
-        '#description' => bts('Request Intel GPU tasks from this project.', array(), NULL, 'boinc:account-preferences-project')
1137
+        '#description' => bts('Request Intel GPU tasks from this project.', array(), null, 'boinc:account-preferences-project')
1138 1138
       );
1139 1139
     }
1140 1140
   }
1141 1141
   
1142
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1142
+  if (variable_get('boinc_prefs_options_beta', false)) {
1143 1143
     $form['beta'] = array(
1144
-      '#title' => bts('Beta settings', array(), NULL, 'boinc:account-preferences-project'),
1144
+      '#title' => bts('Beta settings', array(), null, 'boinc:account-preferences-project'),
1145 1145
       '#type' => 'fieldset',
1146 1146
       '#description' => null,
1147
-      '#collapsible' => TRUE,
1148
-      '#collapsed' => FALSE
1147
+      '#collapsible' => true,
1148
+      '#collapsed' => false
1149 1149
     );
1150 1150
     $form['beta']['allow_beta_work'] = array(
1151
-      '#title' => bts('Run test applications?', array(), NULL, 'boinc:account-preferences-project'),
1151
+      '#title' => bts('Run test applications?', array(), null, 'boinc:account-preferences-project'),
1152 1152
       '#type' => 'radios',
1153 1153
       '#options' => $form['boolean_options']['#value'],
1154 1154
       '#attributes' => array('class' => 'fancy'),
1155 1155
       '#default_value' => ($default['allow_beta_work']) ? 1 : 0,
1156
-      '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), NULL, 'boinc:account-preferences-project')
1156
+      '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer', array(), null, 'boinc:account-preferences-project')
1157 1157
     );
1158 1158
   }
1159 1159
   
@@ -1162,14 +1162,14 @@  discard block
 block discarded – undo
1162 1162
   
1163 1163
   // Set whether to use this preference set by default for new computers
1164 1164
   $form['default_set'] = array(
1165
-    '#title' => bts('Default set', array(), NULL, 'boinc:account-preferences-project'),
1165
+    '#title' => bts('Default set', array(), null, 'boinc:account-preferences-project'),
1166 1166
     '#type' => 'fieldset',
1167 1167
     '#description' => null,
1168
-    '#collapsible' => TRUE,
1169
-    '#collapsed' => FALSE
1168
+    '#collapsible' => true,
1169
+    '#collapsed' => false
1170 1170
   );
1171 1171
   $form['default_set']['default_venue'] = array(
1172
-    '#title' => bts('Set used for new computers', array(), NULL, 'boinc:account-preferences-project'),
1172
+    '#title' => bts('Set used for new computers', array(), null, 'boinc:account-preferences-project'),
1173 1173
     '#type' => 'radios',
1174 1174
     '#options' => $form['boolean_options']['#value'],
1175 1175
     '#attributes' => array('class' => 'fancy'),
@@ -1188,27 +1188,27 @@  discard block
 block discarded – undo
1188 1188
   $form['prefs']['submit'] = array(
1189 1189
     '#prefix' => '<li class="first tab">',
1190 1190
     '#type' => 'submit',
1191
-    '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1191
+    '#value' => bts('Save changes', array(), null, 'boinc:form-save'),
1192 1192
     '#suffix' => '</li>'
1193 1193
   );
1194 1194
   $form['prefs']['form control tabs'] = array(
1195
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1195
+    '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1196 1196
   );
1197
-  if ($venue AND $venue != 'generic') {
1197
+  if ($venue and $venue != 'generic') {
1198 1198
     global $base_path;
1199 1199
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
1200
-      l(bts('Clear', array(), NULL, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1200
+      l(bts('Clear', array(), null, 'boinc:form-clear'), "account/prefs/project/clear/{$venue}",
1201 1201
         array(
1202 1202
           'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1203 1203
           'attributes' => array(
1204 1204
             'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
1205
-              array('@name' => $venue), NULL, 'boinc:account-preferences') . '\')'
1205
+              array('@name' => $venue), null, 'boinc:account-preferences') . '\')'
1206 1206
           )
1207 1207
         )
1208 1208
       ) . '</li>';
1209 1209
   }
1210 1210
   $form['prefs']['view control'] = array(
1211
-      '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), NULL, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1211
+      '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view', array(), null, 'boinc:account-preferences') . ')', 'account/prefs/project/combined') . '</li>'
1212 1212
   );
1213 1213
   $form['prefs']['form control tabs suffix'] = array(
1214 1214
     '#value' => '</ul>'
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
   $ordered_array = array();
1229 1229
   $unordered_array = array();
1230 1230
   foreach ($xml['project_specific_preferences'] as $type => $element) {
1231
-    if (is_array($element) AND is_numeric(key($element))) {
1231
+    if (is_array($element) and is_numeric(key($element))) {
1232 1232
       foreach ($element as $ordered_element) {
1233 1233
         if (isset($ordered_element['@position'])) {
1234 1234
           $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
   // Check for app validation
1281 1281
   if (isset($validation_rules['apps'])) {
1282 1282
     if (isset($validation_rules['apps']['minimum selected'])
1283
-        AND $validation_rules['apps']['minimum selected'] > 0) {
1283
+        and $validation_rules['apps']['minimum selected'] > 0) {
1284 1284
       $apps_selected = 0;
1285 1285
       foreach ($validation_rules['apps']['list'] as $app) {
1286 1286
         if ($form_state['values']['applications'][$app]) $apps_selected++;
@@ -1288,14 +1288,14 @@  discard block
 block discarded – undo
1288 1288
       if ($apps_selected < $validation_rules['apps']['minimum selected']) {
1289 1289
         form_set_error(
1290 1290
           'applications',
1291
-          bts('At least one application must be selected', array(), NULL, 'boinc:account-preferences-project')
1291
+          bts('At least one application must be selected', array(), null, 'boinc:account-preferences-project')
1292 1292
         );
1293 1293
       }
1294 1294
       if ($apps_selected == count($validation_rules['apps']['list'])) {
1295 1295
         foreach ($validation_rules['apps']['list'] as $app) {
1296 1296
           unset($form_state['values']['applications'][$app]);
1297 1297
         }
1298
-        $form_state['storage']['all apps selected'] = TRUE;
1298
+        $form_state['storage']['all apps selected'] = true;
1299 1299
       }
1300 1300
     }
1301 1301
   }
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
   }
1329 1329
   
1330 1330
   // Beta preferences
1331
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1331
+  if (variable_get('boinc_prefs_options_beta', false)) {
1332 1332
     $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0;
1333 1333
   }
1334 1334
   
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
     watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysql_error()), WATCHDOG_ERROR);
1367 1367
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
1368 1368
   }
1369
-  elseif (!drupal_get_messages('status', FALSE)) {
1369
+  elseif (!drupal_get_messages('status', false)) {
1370 1370
     // Show this message if the set wasn't created automatically (in which case
1371 1371
     // there is a message tailored to that)
1372 1372
     drupal_set_message(t('Your preferences have been updated.
@@ -1401,31 +1401,31 @@  discard block
 block discarded – undo
1401 1401
   // Standard option sets
1402 1402
   $form['boolean_options'] = array(
1403 1403
     '#type' => 'value',
1404
-    '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1404
+    '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1405 1405
   );
1406 1406
   
1407 1407
   $default = array(
1408 1408
     'pm_send_notification' => '', // This is set already in pm_email_notify_user
1409 1409
     'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0,
1410
-    'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50),
1411
-    'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST),
1410
+    'comments_per_page' => (isset($account->comments_per_page) and $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50),
1411
+    'comments_order' => (isset($account->sort) and $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST),
1412 1412
   );
1413 1413
   
1414 1414
   // General options
1415 1415
   $form['general'] = array(
1416 1416
     '#type' => 'fieldset',
1417
-    '#title' => bts('General settings', array(), NULL, 'boinc:account-preferences-community'),
1417
+    '#title' => bts('General settings', array(), null, 'boinc:account-preferences-community'),
1418 1418
     '#weight' => 0,
1419
-    '#collapsible' => TRUE,
1420
-    '#collapsed' => FALSE
1419
+    '#collapsible' => true,
1420
+    '#collapsed' => false
1421 1421
   );
1422 1422
   // Add the BOINC user name (non-unique, user editable)
1423 1423
   $form['general']['boincuser_name'] = array(
1424 1424
     '#type' => 'textfield',
1425
-    '#title' => bts('Name', array(), NULL, 'boinc:user-or-team-name'),
1425
+    '#title' => bts('Name', array(), null, 'boinc:user-or-team-name'),
1426 1426
     '#default_value' => $account->boincuser_name,
1427 1427
     '#maxlength' => USERNAME_MAX_LENGTH,
1428
-    '#required' => TRUE,
1428
+    '#required' => true,
1429 1429
     '#description' => '',
1430 1430
     '#size' => 40
1431 1431
   );
@@ -1434,8 +1434,8 @@  discard block
 block discarded – undo
1434 1434
     $zones = _system_zonelist();
1435 1435
     $form['general']['timezone'] = array(
1436 1436
       '#type' => 'select',
1437
-      '#title' => bts('Time zone', array(), NULL, 'boinc:account-preferences-community'),
1438
-      '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1437
+      '#title' => bts('Time zone', array(), null, 'boinc:account-preferences-community'),
1438
+      '#default_value' => ($account->timezone !== null) ? $account->timezone : variable_get('date_default_timezone', 0),
1439 1439
       '#options' => $zones,
1440 1440
       '#description' => '',
1441 1441
     );
@@ -1444,10 +1444,10 @@  discard block
 block discarded – undo
1444 1444
   // Notification options
1445 1445
   $form['notifications'] = array(
1446 1446
     '#type' => 'fieldset',
1447
-    '#title' => bts('Notification settings', array(), NULL, 'boinc:account-preferences-community'),
1447
+    '#title' => bts('Notification settings', array(), null, 'boinc:account-preferences-community'),
1448 1448
     '#weight' => 5,
1449
-    '#collapsible' => TRUE,
1450
-    '#collapsed' => FALSE
1449
+    '#collapsible' => true,
1450
+    '#collapsed' => false
1451 1451
   );
1452 1452
   // Pull in private message notification handling and tweak the form
1453 1453
   $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
     $pm_notify['enable_pm_mail']['pm_send_notifications'],
1456 1456
     array(
1457 1457
       '#type' => 'radios',
1458
-      '#title' => bts('Receive email notification for private messages?', array(), NULL, 'boinc:account-preferences-community'),
1458
+      '#title' => bts('Receive email notification for private messages?', array(), null, 'boinc:account-preferences-community'),
1459 1459
       '#description' => ' ',
1460 1460
       '#options' => $form['boolean_options']['#value'],
1461 1461
       '#attributes' => array('class' => 'fancy')
@@ -1463,9 +1463,9 @@  discard block
 block discarded – undo
1463 1463
   );
1464 1464
   $form['notifications']['friend_notification'] = array(
1465 1465
     '#type' => 'radios',
1466
-    '#title' => bts('Receive email notification for friend requests?', array(), NULL, 'boinc:account-preferences-community'),
1466
+    '#title' => bts('Receive email notification for friend requests?', array(), null, 'boinc:account-preferences-community'),
1467 1467
     '#description' => ' ',
1468
-    '#options' => array(0 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
1468
+    '#options' => array(0 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), -1 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes')),
1469 1469
     '#attributes' => array('class' => 'fancy'),
1470 1470
     '#default_value' => $default['friend_notification']
1471 1471
   );
@@ -1481,10 +1481,10 @@  discard block
 block discarded – undo
1481 1481
     }
1482 1482
     $form['locale'] = array(
1483 1483
       '#type' => 'fieldset',
1484
-      '#title' => bts('Language settings', array(), NULL, 'boinc:account-preferences-community'),
1484
+      '#title' => bts('Language settings', array(), null, 'boinc:account-preferences-community'),
1485 1485
       '#weight' => 10,
1486
-      '#collapsible' => TRUE,
1487
-      '#collapsed' => FALSE,
1486
+      '#collapsible' => true,
1487
+      '#collapsed' => false,
1488 1488
     );
1489 1489
 
1490 1490
     // Get language negotiation settings.
@@ -1492,30 +1492,30 @@  discard block
 block discarded – undo
1492 1492
     $user_preferred_language = user_preferred_language($account);
1493 1493
     $form['locale']['language'] = array(
1494 1494
       '#type' => 'select',
1495
-      '#title' => bts('Language', array(), NULL, 'boinc:account-preferences-community'),
1495
+      '#title' => bts('Language', array(), null, 'boinc:account-preferences-community'),
1496 1496
       '#default_value' => check_plain($user_preferred_language->language),
1497 1497
       '#options' => $names,
1498
-      '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), NULL, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), NULL, 'boinc:account-preferences-community'),
1498
+      '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.", array(), null, 'boinc:account-preferences-community') : bts("This account's default language for e-mails.", array(), null, 'boinc:account-preferences-community'),
1499 1499
     );
1500 1500
   }
1501 1501
   
1502 1502
   // Avatar options
1503 1503
   $form['gravatar'] = array(
1504 1504
     '#type' => 'item',
1505
-    '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'),
1506
-    '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), NULL, 'boinc:account-preferences-community'),
1505
+    '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), null, 'boinc:account-preferences-community'),
1506
+    '#description' => bts('Your Gravatar will not be shown if you upload a user picture.', array(), null, 'boinc:account-preferences-community'),
1507 1507
   );
1508 1508
   if (user_access('disable own gravatar', $account)) {
1509 1509
     $form['gravatar'] = array(
1510 1510
       '#type' => 'checkbox',
1511
-      '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), NULL, 'boinc:account-preferences-community'),
1512
-      '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), NULL, 'boinc:account-preferences-community'),
1511
+      '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail), null, 'boinc:account-preferences-community'),
1512
+      '#description' => bts('Gravatar will not be shown if an avatar is uploaded.', array(), null, 'boinc:account-preferences-community'),
1513 1513
       '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1514 1514
       '#disabled' => !empty($account->picture),
1515 1515
     );
1516 1516
   }
1517 1517
   $form['gravatar']['#weight'] = 15;
1518
-  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), NULL, 'boinc:account-preferences-community') . '</a></legend>';
1518
+  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings', array(), null, 'boinc:account-preferences-community') . '</a></legend>';
1519 1519
   // Upload an avatar (pulled from profile_node_form):
1520 1520
   if (!empty($profile_form['field_image'])) {
1521 1521
     $form['field_image'] = $profile_form['field_image'];
@@ -1524,46 +1524,46 @@  discard block
 block discarded – undo
1524 1524
     $form['field_image'] = array(
1525 1525
       '#value' => '<div class="form-item">'
1526 1526
         . '<label class="placeholder">'
1527
-        . bts('This is not available until your profile is set up.', array(), NULL, 'boinc:account-preferences-community')
1527
+        . bts('This is not available until your profile is set up.', array(), null, 'boinc:account-preferences-community')
1528 1528
         . '</label>'
1529
-        . l(bts('Create a profile', array(), NULL, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link')))
1529
+        . l(bts('Create a profile', array(), null, 'boinc:account-preferences-community'), 'account/profile/edit', array('attributes' => array('class' => 'form-link')))
1530 1530
         . '</div>',
1531 1531
     );
1532 1532
   }
1533
-  $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), NULL, 'boinc:account-preferences-community');
1533
+  $form['field_image'][0]['#title'] = bts('Upload an avatar', array(), null, 'boinc:account-preferences-community');
1534 1534
   $form['field_image']['#weight'] = 20;
1535 1535
   $form['field_image']['#suffix'] = '</fieldset>';
1536 1536
   
1537 1537
   // Forum options
1538 1538
   $form['forums'] = array(
1539 1539
     '#type' => 'fieldset',
1540
-    '#title' => bts('Forum settings', array(), NULL, 'boinc:account-preferences-community'),
1540
+    '#title' => bts('Forum settings', array(), null, 'boinc:account-preferences-community'),
1541 1541
     '#weight' => 25,
1542
-    '#collapsible' => TRUE,
1543
-    '#collapsed' => FALSE
1542
+    '#collapsible' => true,
1543
+    '#collapsed' => false
1544 1544
   );
1545 1545
   $form['forums']['comments_per_page'] = array(
1546 1546
     '#type' => 'select',
1547
-    '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), NULL, 'boinc:account-preferences-community'),
1547
+    '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => ''), null, 'boinc:account-preferences-community'),
1548 1548
     '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100),
1549 1549
     '#default_value' => $default['comments_per_page']
1550 1550
   );
1551 1551
   // Can't have a typical Drupal form suffix on a select box?
1552 1552
   $form['forums']['comments_per_page_suffix'] = array(
1553
-    '#value' => '<span>' . bts('comments per page', array(), NULL, 'boinc:account-preferences-community') . '</span>'
1553
+    '#value' => '<span>' . bts('comments per page', array(), null, 'boinc:account-preferences-community') . '</span>'
1554 1554
   );
1555 1555
   $form['forums']['comments_order'] = array(
1556 1556
     '#type' => 'select',
1557
-    '#title' => bts('Sort comments in discussions', array(), NULL, 'boinc:account-preferences-community'),
1558
-    '#options' => array(1 => bts('Newest post first', array(), NULL, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), NULL, 'boinc:account-preferences-community')),
1557
+    '#title' => bts('Sort comments in discussions', array(), null, 'boinc:account-preferences-community'),
1558
+    '#options' => array(1 => bts('Newest post first', array(), null, 'boinc:account-preferences-community'), 2 => bts('Oldest post first', array(), null, 'boinc:account-preferences-community')),
1559 1559
     '#default_value' => $default['comments_order']
1560 1560
   );
1561 1561
   // Signature (pulled from user_edit_form):
1562 1562
   if (variable_get('user_signatures', 0) && module_exists('comment')) {
1563 1563
     $form['forums']['signature'] = array(
1564 1564
       '#type' => 'textarea',
1565
-      '#title' => bts('Signature', array(), NULL, 'boinc:account-preferences-community'),
1566
-      '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), NULL, 'boinc:account-preferences-community'),
1565
+      '#title' => bts('Signature', array(), null, 'boinc:account-preferences-community'),
1566
+      '#description' => bts('Your signature will be publicly displayed at the end of your comments.', array(), null, 'boinc:account-preferences-community'),
1567 1567
       '#default_value' => $account->signature
1568 1568
       );
1569 1569
     // Prevent a "validation error" message when the user attempts to save with a default value they
@@ -1572,11 +1572,11 @@  discard block
 block discarded – undo
1572 1572
       drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page."));
1573 1573
       $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1574 1574
     }
1575
-    $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format'));
1575
+    $form['forums']['signature_format'] = filter_form($account->signature_format, null, array('signature_format'));
1576 1576
     // Optionally hide signatures from comments
1577 1577
     $form['forums']['hide_signatures'] = array(
1578 1578
       '#type' => 'radios',
1579
-      '#title' => bts('Hide signatures in forums', array(), NULL, 'boinc:account-preferences-community'),
1579
+      '#title' => bts('Hide signatures in forums', array(), null, 'boinc:account-preferences-community'),
1580 1580
       '#description' => ' ',
1581 1581
       '#options' => $form['boolean_options']['#value'],
1582 1582
       '#attributes' => array('class' => 'fancy'),
@@ -1598,12 +1598,12 @@  discard block
 block discarded – undo
1598 1598
   $form['submit'] = array(
1599 1599
     '#prefix' => '<li class="first tab">',
1600 1600
     '#type' => 'submit',
1601
-    '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1601
+    '#value' => bts('Save changes', array(), null, 'boinc:form-save'),
1602 1602
     '#suffix' => '</li>',
1603 1603
     '#weight' => 1002,
1604 1604
   );
1605 1605
   $form['form control tabs'] = array(
1606
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1606
+    '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>',
1607 1607
     '#weight' => 1003,
1608 1608
   );
1609 1609
   $form['form control tabs suffix'] = array(
@@ -1640,7 +1640,7 @@  discard block
 block discarded – undo
1640 1640
   $profile_node->field_image = $edit['field_image'];
1641 1641
   node_save($profile_node);
1642 1642
   // Flush this from the node cache or changes won't show up immediately!
1643
-  $profile_node = node_load($profile_node->nid, NULL, TRUE);
1643
+  $profile_node = node_load($profile_node->nid, null, true);
1644 1644
   
1645 1645
   // All other settings
1646 1646
   $settings = array(
@@ -1668,7 +1668,7 @@  discard block
 block discarded – undo
1668 1668
   }
1669 1669
   user_save($user, $settings);
1670 1670
   
1671
-  drupal_set_message(bts('Your community preferences have been updated.', array(), NULL, 'boinc:account-preferences-community'));
1671
+  drupal_set_message(bts('Your community preferences have been updated.', array(), null, 'boinc:account-preferences-community'));
1672 1672
   
1673 1673
   // Form will not redirect if storage is set; not good if language changes
1674 1674
   unset($form_state['storage']);
@@ -1700,26 +1700,26 @@  discard block
 block discarded – undo
1700 1700
   // Standard option sets
1701 1701
   $form['boolean_options'] = array(
1702 1702
     '#type' => 'value',
1703
-    '#value' => array(1 => bts('yes', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), NULL, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1703
+    '#value' => array(1 => bts('yes', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-no'), 0 => bts('no', array(), null, 'boinc:form-yes-no:-1:binary-form-option-pairs-with-yes'))
1704 1704
   );
1705 1705
   
1706 1706
   $form['privacy'] = array(
1707
-    '#title' => bts('Privacy settings', array(), NULL, 'boinc:account-preferences-privacy'),
1707
+    '#title' => bts('Privacy settings', array(), null, 'boinc:account-preferences-privacy'),
1708 1708
     '#type' => 'fieldset',
1709 1709
     '#description' => null,
1710
-    '#collapsible' => TRUE,
1711
-    '#collapsed' => FALSE
1710
+    '#collapsible' => true,
1711
+    '#collapsed' => false
1712 1712
   );
1713 1713
   $form['privacy']['send_email'] = array(
1714
-    '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'),
1714
+    '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), null, 'boinc:account-preferences-privacy'),
1715 1715
     '#type' => 'radios',
1716 1716
     '#options' => $form['boolean_options']['#value'],
1717 1717
     '#attributes' => array('class' => 'fancy'),
1718 1718
     '#default_value' => $default['privacy']['send_email']
1719 1719
   );
1720 1720
   $form['privacy']['show_hosts'] = array(
1721
-    '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), NULL, 'boinc:account-preferences-privacy'),
1722
-    '#description' => bts('At times, you may be asked to enable this option in order to receive help from the forums. Advanced users may need to be able to inspect your computers\' information in order to help diagnose any problems.', array(), NULL, 'boinc:account-preferences-privacy'),
1721
+    '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'Drupal-BOINC')), null, 'boinc:account-preferences-privacy'),
1722
+    '#description' => bts('At times, you may be asked to enable this option in order to receive help from the forums. Advanced users may need to be able to inspect your computers\' information in order to help diagnose any problems.', array(), null, 'boinc:account-preferences-privacy'),
1723 1723
     '#type' => 'radios',
1724 1724
     '#options' => $form['boolean_options']['#value'],
1725 1725
     '#attributes' => array('class' => 'fancy'),
@@ -1729,17 +1729,17 @@  discard block
 block discarded – undo
1729 1729
   // Ignore and block users
1730 1730
   if (module_exists('ignore_user')) {
1731 1731
     $form['ignoreblock'] = array(
1732
-      '#title' => bts('Ignore Users', array(), NULL, 'boinc:account-preferences-privacy'),
1732
+      '#title' => bts('Ignore Users', array(), null, 'boinc:account-preferences-privacy'),
1733 1733
       '#type' => 'fieldset',
1734
-      '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), NULL, 'boinc:ignore-user-help'),
1735
-      '#collapsible' => TRUE,
1736
-      '#collapsed' => FALSE
1734
+      '#description' => bts('<p>You may ignore users in the forums and block users from sending you private messages.<p>', array(), null, 'boinc:ignore-user-help'),
1735
+      '#collapsible' => true,
1736
+      '#collapsed' => false
1737 1737
     );
1738 1738
 
1739 1739
     // Table for ignored users
1740 1740
     $form['ignoreblock']['current_ignore_section'] = array(
1741 1741
       '#type' => 'item',
1742
-      '#value' => bts('Current users on your Ignore List', array(), NULL, 'boinc:ignore-user-list'),
1742
+      '#value' => bts('Current users on your Ignore List', array(), null, 'boinc:ignore-user-list'),
1743 1743
       '#prefix' => '<h4>',
1744 1744
       '#suffix' => '</h4>',
1745 1745
       '#weight' => -20,
@@ -1752,18 +1752,18 @@  discard block
 block discarded – undo
1752 1752
       );
1753 1753
       $form['ignoreblock']['delete'][$ignored_user['iuid']] = array(
1754 1754
         '#value' => l(
1755
-          bts('delete', array(), NULL, 'boinc:ignore-user-delete-button'),
1755
+          bts('delete', array(), null, 'boinc:ignore-user-delete-button'),
1756 1756
           'account/prefs/privacy/ignore_user/remove/'. $ignored_user['iuid'],
1757 1757
           array()
1758 1758
         ),
1759 1759
       );
1760 1760
     }
1761
-    $form['ignoreblock']['pager'] = array('#value' => theme('pager', NULL, 10, 0));
1761
+    $form['ignoreblock']['pager'] = array('#value' => theme('pager', null, 10, 0));
1762 1762
 
1763 1763
     // Sub-form to add user to ignore list
1764 1764
     $form['ignoreblock']['add_ignore_user_section'] = array(
1765 1765
       '#type' => 'item',
1766
-      '#value' => bts('Add user to Ignore List', array(), NULL, 'boinc:ignore-user-add'),
1766
+      '#value' => bts('Add user to Ignore List', array(), null, 'boinc:ignore-user-add'),
1767 1767
       '#prefix' => '<h4>',
1768 1768
       '#suffix' => '</h4>',
1769 1769
       '#weight' => 10,
@@ -1771,8 +1771,8 @@  discard block
 block discarded – undo
1771 1771
 
1772 1772
     $form['ignoreblock']['addusername_toignorelist'] = array(
1773 1773
       '#type' => 'textfield',
1774
-      '#title' => bts('Username', array(), NULL, 'boinc:ignore-user-searchbox'),
1775
-      '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), NULL, 'boinc:ignore-user-searchbox-help'),
1774
+      '#title' => bts('Username', array(), null, 'boinc:ignore-user-searchbox'),
1775
+      '#description' => bts('To lookup a username start typing in the search box. A list of usernames will appear as you type. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.', array(), null, 'boinc:ignore-user-searchbox-help'),
1776 1776
       '#weight' => 11,
1777 1777
       '#size' => 50,
1778 1778
       '#autocomplete_path' => 'boincuser/autocomplete',
@@ -1780,7 +1780,7 @@  discard block
 block discarded – undo
1780 1780
 
1781 1781
     $form['ignoreblock']['addusername_submit'] = array(
1782 1782
       '#type' => 'submit',
1783
-      '#value' => bts('Ignore user', array(), NULL, 'boinc:ignore-user-add'),
1783
+      '#value' => bts('Ignore user', array(), null, 'boinc:ignore-user-add'),
1784 1784
       '#submit' => array('_boincwork_ignore_list_form_submit'),
1785 1785
       '#weight' => 12,
1786 1786
       '#attributes' => array('class' => 'add_ignore_user'),
@@ -1798,13 +1798,13 @@  discard block
 block discarded – undo
1798 1798
   $form['prefs']['submit'] = array(
1799 1799
     '#prefix' => '<li class="first tab">',
1800 1800
     '#type' => 'submit',
1801
-    '#value' => bts('Save changes', array(), NULL, 'boinc:form-save'),
1801
+    '#value' => bts('Save changes', array(), null, 'boinc:form-save'),
1802 1802
     '#validate' => array('boincwork_privacyprefs_form_validate'),
1803 1803
     '#submit' => array('boincwork_privacyprefs_form_submit'),
1804 1804
     '#suffix' => '</li>'
1805 1805
   );
1806 1806
   $form['prefs']['form control tabs'] = array(
1807
-    '#value' => '<li class="tab">' . l(bts('Cancel', array(), NULL, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1807
+    '#value' => '<li class="tab">' . l(bts('Cancel', array(), null, 'boinc:form-cancel'), $_GET['q']) . '</li>'
1808 1808
   );
1809 1809
   $form['prefs']['form control tabs suffix'] = array(
1810 1810
     '#value' => '</ul>'
@@ -1822,8 +1822,8 @@  discard block
 block discarded – undo
1822 1822
   $output .= drupal_render($form['privacy']);
1823 1823
 
1824 1824
   $header = array(
1825
-    bts('Username', array(), NULL, 'boinc:ignore-user-list'),
1826
-    bts('Operations', array(), NULL, 'boinc:ignore-user-list')
1825
+    bts('Username', array(), null, 'boinc:ignore-user-list'),
1826
+    bts('Operations', array(), null, 'boinc:ignore-user-list')
1827 1827
   );
1828 1828
 
1829 1829
   $rows = array();
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
   else {
1839 1839
     $rows[] = array(
1840 1840
       array(
1841
-        'data' => bts('You have not added any users to your Ignore List.', array(), NULL, 'boinc:ignore-user-list'),
1841
+        'data' => bts('You have not added any users to your Ignore List.', array(), null, 'boinc:ignore-user-list'),
1842 1842
         'colspan' => '2',
1843 1843
       )
1844 1844
     );
@@ -1902,9 +1902,9 @@  discard block
 block discarded – undo
1902 1902
     bts('@username has been added to your ignore list. See your !privacy_preferences for more details.',
1903 1903
       array(
1904 1904
         '@username' => $form_state['values']['addusername_toignorelist'],
1905
-        '!privacy_preferences' => l(bts('privacy preferences', array(), NULL, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
1905
+        '!privacy_preferences' => l(bts('privacy preferences', array(), null, 'boinc:ignore-user-add'), 'account/prefs/privacy'),
1906 1906
       ),
1907
-      NULL, 'boinc:ignore-user-add'),
1907
+      null, 'boinc:ignore-user-add'),
1908 1908
     'status');
1909 1909
 }
1910 1910
 
@@ -1929,7 +1929,7 @@  discard block
 block discarded – undo
1929 1929
   // only non-js users/browsers will see the Apply Filter button.
1930 1930
   $form['submit'] = array(
1931 1931
     '#type' => 'submit',
1932
-    '#value' => bts('Apply Filter', array(), NULL, 'boinc:form-save'),
1932
+    '#value' => bts('Apply Filter', array(), null, 'boinc:form-save'),
1933 1933
     '#attributes' => array('class' => 'js-hide',),
1934 1934
   );
1935 1935
 
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/bbcode/bbcode-filter.inc 5 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -1,6 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 // $Id: bbcode-filter.inc,v 1.66 2008/11/30 08:50:08 naudefj Exp $
3 3
 
4
+/**
5
+ * @param string $body
6
+ */
4 7
 function _bbcode_filter_process(&$body, $format = -1) {
5 8
 
6 9
   $quote_text = t('Quote:');
Please login to merge, or discard this patch.
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -3,128 +3,128 @@  discard block
 block discarded – undo
3 3
 
4 4
 function _bbcode_filter_process(&$body, $format = -1) {
5 5
 
6
-  $quote_text = t('Quote:');
7
-  $quote_user = t('\\1 wrote:');
6
+    $quote_text = t('Quote:');
7
+    $quote_user = t('\\1 wrote:');
8 8
 
9
-  // Encode all script tags to prevent XSS html injection attacks
10
-  $body = preg_replace(array('#<script([^>]*)>#i', '#</script([^>]*)>#i'), array('&lt;script\\1&gt;', '&lt;/script\\1&gt;'), $body);
9
+    // Encode all script tags to prevent XSS html injection attacks
10
+    $body = preg_replace(array('#<script([^>]*)>#i', '#</script([^>]*)>#i'), array('&lt;script\\1&gt;', '&lt;/script\\1&gt;'), $body);
11 11
 
12
-  // Find all [code] tags and check if they contain a newline. If we find a newline, 
13
-  // that [code] should be rendered as a block, otherwise it will still be inline
14
-  $mode = variable_get("bbcode_paragraph_breaks_$format", 2);
15
-  $pre = array(); $i = 0;
16
-  if (preg_match_all('#\[code(?::\w+)?\](.*?)\[/code(?::\w+)?\]#si', $body, $code_tags, PREG_SET_ORDER)) {
12
+    // Find all [code] tags and check if they contain a newline. If we find a newline, 
13
+    // that [code] should be rendered as a block, otherwise it will still be inline
14
+    $mode = variable_get("bbcode_paragraph_breaks_$format", 2);
15
+    $pre = array(); $i = 0;
16
+    if (preg_match_all('#\[code(?::\w+)?\](.*?)\[/code(?::\w+)?\]#si', $body, $code_tags, PREG_SET_ORDER)) {
17 17
     foreach ($code_tags as $code_tag) {
18
-      $code_tag[1] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $code_tag[1]);
19
-      if (strpos($code_tag[1], "\n") === FALSE)
18
+        $code_tag[1] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $code_tag[1]);
19
+        if (strpos($code_tag[1], "\n") === FALSE)
20 20
         $body = str_replace($code_tag[0], '<code class="bb-code">'. $code_tag[1] .'</code>', $body);
21
-      elseif ($mode) {
21
+        elseif ($mode) {
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
+        }
26
+        else
27 27
         $body = str_replace($code_tag[0], '<pre class="bb-code-block">'. $code_tag[1] .'</pre>', $body);
28 28
     }
29
-  }
29
+    }
30 30
 
31
-  // Apply line and paragraph breaks (skipping preformatted code)
32
-  if ($mode) {
31
+    // Apply line and paragraph breaks (skipping preformatted code)
32
+    if ($mode) {
33 33
 
34 34
     if ($mode == 1) 	// Line breaks only (starting with PHP 4.0.5, nl2br() is XHTML compliant)
35
-      $body = nl2br($body);
35
+        $body = nl2br($body);
36 36
 
37 37
     if ($mode == 2) {	// Line and paragraph breaks (may not always be XHTML compliant)
38
-      $body  = preg_replace("/(\r\n|\n|\r)/", "\n", $body);
39
-      $body  = preg_replace("/\n\n+/", "\n\n", $body);
40
-      $parts = explode("\n\n", $body);
41
-      for ($i=0; $i<sizeof($parts); $i++) {
42
-         // No linebreaks if paragraph starts with an HTML tag
43
-         if ( !preg_match('/^<.*>/', $parts[$i]) ) 
44
-           $parts[$i] = nl2br($parts[$i]);
45
-
46
-         // Some tags should not be in paragraph blocks
47
-         if ( !preg_match('/^(?:<|\[)(?:table|list|ol|ul|pre|select|form|blockquote|hr)/i', $parts[$i]) ) 
48
-           $parts[$i] = '<p>'. $parts[$i] .'</p>';
49
-      }
50
-      $body = implode("\n\n", $parts);
38
+        $body  = preg_replace("/(\r\n|\n|\r)/", "\n", $body);
39
+        $body  = preg_replace("/\n\n+/", "\n\n", $body);
40
+        $parts = explode("\n\n", $body);
41
+        for ($i=0; $i<sizeof($parts); $i++) {
42
+            // No linebreaks if paragraph starts with an HTML tag
43
+            if ( !preg_match('/^<.*>/', $parts[$i]) ) 
44
+            $parts[$i] = nl2br($parts[$i]);
45
+
46
+            // Some tags should not be in paragraph blocks
47
+            if ( !preg_match('/^(?:<|\[)(?:table|list|ol|ul|pre|select|form|blockquote|hr)/i', $parts[$i]) ) 
48
+            $parts[$i] = '<p>'. $parts[$i] .'</p>';
49
+        }
50
+        $body = implode("\n\n", $parts);
51 51
     }
52 52
 
53 53
     // Reinsert preformatted code blocks
54 54
     foreach ($pre as $i => $code_tag) 
55
-       $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body);
56
-  }
55
+        $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body);
56
+    }
57 57
   
58
-  // Replace any improper quote tags with proper quote tags
59
-  $body = str_replace('[quote/]', '[/quote]', $body);
58
+    // Replace any improper quote tags with proper quote tags
59
+    $body = str_replace('[quote/]', '[/quote]', $body);
60 60
   
61
-  // Add closing tags to prevent users from disruping your site's HTML
62
-  // (required for nestable tags only: [list] and [quote])
63
-  preg_match_all('/\[quote/i', $body, $matches);
64
-  $opentags = count($matches['0']);
65
-  preg_match_all('/\[\/quote\]/i', $body, $matches);
66
-  $unclosed = $opentags - count($matches['0']);
67
-  for ($i = 0; $i < $unclosed; $i++) {
61
+    // Add closing tags to prevent users from disruping your site's HTML
62
+    // (required for nestable tags only: [list] and [quote])
63
+    preg_match_all('/\[quote/i', $body, $matches);
64
+    $opentags = count($matches['0']);
65
+    preg_match_all('/\[\/quote\]/i', $body, $matches);
66
+    $unclosed = $opentags - count($matches['0']);
67
+    for ($i = 0; $i < $unclosed; $i++) {
68 68
     $body .= '[/quote]';
69
-  }
70
-  // Also add opening tags, if needed
71
-  for ($i = $unclosed; $i < 0; $i++) {
69
+    }
70
+    // Also add opening tags, if needed
71
+    for ($i = $unclosed; $i < 0; $i++) {
72 72
     $body = '[quote]' . $body;
73
-  }
74
-  preg_match_all('/\[list/i', $body, $matches);
75
-  $opentags = count($matches['0']);
76
-  preg_match_all('/\[\/list\]/i', $body, $matches);
77
-  $unclosed = $opentags - count($matches['0']);
78
-  for ($i = 0; $i < $unclosed; $i++) {
73
+    }
74
+    preg_match_all('/\[list/i', $body, $matches);
75
+    $opentags = count($matches['0']);
76
+    preg_match_all('/\[\/list\]/i', $body, $matches);
77
+    $unclosed = $opentags - count($matches['0']);
78
+    for ($i = 0; $i < $unclosed; $i++) {
79 79
     $body .= '[/list]';
80
-  }
81
-  for ($i = $unclosed; $i < 0; $i++) {
80
+    }
81
+    for ($i = $unclosed; $i < 0; $i++) {
82 82
     $body = '[list]' . $body;
83
-  }
83
+    }
84 84
 
85
-  // begin processing for [size] 
86
-  if (stristr($body, '[size=') !== FALSE) { // prevent useless processing
85
+    // begin processing for [size] 
86
+    if (stristr($body, '[size=') !== FALSE) { // prevent useless processing
87 87
     $arr = array(
88
-      'tag'         => 'size',
89
-      'pattern'     => '#\[\x07=([\d]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi',
90
-      'replacement' => '"<span style=\"font-size:". _bbcode_round_size_val(\'$1\') ."px\">". str_replace(\'\"\', \'"\', \'$2\') ."</span>"',
91
-      'text'        => $body);
88
+        'tag'         => 'size',
89
+        'pattern'     => '#\[\x07=([\d]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi',
90
+        'replacement' => '"<span style=\"font-size:". _bbcode_round_size_val(\'$1\') ."px\">". str_replace(\'\"\', \'"\', \'$2\') ."</span>"',
91
+        'text'        => $body);
92 92
     $body = _bbcode_replace_nest_tag($arr);
93
-  } // end processing for [size]
93
+    } // end processing for [size]
94 94
 
95
-  // begin processing for [color]
96
-  if (stristr($body, '[color=') !== FALSE) { // prevent useless processing
95
+    // begin processing for [color]
96
+    if (stristr($body, '[color=') !== FALSE) { // prevent useless processing
97 97
     $arr = array(
98
-      'tag'         => 'color',
99
-      'pattern'     => '#\[\x07=([\#\w]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
100
-      'replacement' => '<span style="color:$1">$2</span>',
101
-      'text'        => $body);
98
+        'tag'         => 'color',
99
+        'pattern'     => '#\[\x07=([\#\w]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
100
+        'replacement' => '<span style="color:$1">$2</span>',
101
+        'text'        => $body);
102 102
     $body = _bbcode_replace_nest_tag($arr);
103
-  } // end processing for [color]
103
+    } // end processing for [color]
104 104
 
105
-  // begin processing for [font]
106
-  if (stristr($body, '[font=') !== FALSE) { // prevent useless processing
105
+    // begin processing for [font]
106
+    if (stristr($body, '[font=') !== FALSE) { // prevent useless processing
107 107
     $arr = array(
108
-      'tag'         => 'font',
109
-      'pattern'     => '#\[\x07=([\w\s]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
110
-      'replacement' => '<span style="font-family:$1">$2</span>',
111
-      'text'        => $body);
108
+        'tag'         => 'font',
109
+        'pattern'     => '#\[\x07=([\w\s]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
110
+        'replacement' => '<span style="font-family:$1">$2</span>',
111
+        'text'        => $body);
112 112
     $body = _bbcode_replace_nest_tag($arr);
113
-  } // end processing for [font]
113
+    } // end processing for [font]
114 114
 
115
-  // begin processing for [list] and [*]
116
-  if (stristr($body, '[list') !== FALSE) { // prevent useless processing
115
+    // begin processing for [list] and [*]
116
+    if (stristr($body, '[list') !== FALSE) { // prevent useless processing
117 117
     $l_type = array(
118
-      NULL   => array('style' => 'circle', 'tag' => 'ul'),
119
-      'c'    => array('style' => 'circle', 'tag' => 'ul'),
120
-      'd'    => array('style' => 'disc', 'tag' => 'ul'),
121
-      's'    => array('style' => 'square', 'tag' => 'ul'),
122
-      '1'    => array('style' => 'decimal', 'tag' => 'ol'),
123
-      'a'    => array('style' => 'lower-alpha', 'tag' => 'ol'),
124
-      'A'    => array('style' => 'upper-alpha', 'tag' => 'ol'),
125
-      'i'    => array('style' => 'lower-roman', 'tag' => 'ol'),
126
-      'I'    => array('style' => 'upper-roman', 'tag' => 'ol')
127
-      );
118
+        NULL   => array('style' => 'circle', 'tag' => 'ul'),
119
+        'c'    => array('style' => 'circle', 'tag' => 'ul'),
120
+        'd'    => array('style' => 'disc', 'tag' => 'ul'),
121
+        's'    => array('style' => 'square', 'tag' => 'ul'),
122
+        '1'    => array('style' => 'decimal', 'tag' => 'ol'),
123
+        'a'    => array('style' => 'lower-alpha', 'tag' => 'ol'),
124
+        'A'    => array('style' => 'upper-alpha', 'tag' => 'ol'),
125
+        'i'    => array('style' => 'lower-roman', 'tag' => 'ol'),
126
+        'I'    => array('style' => 'upper-roman', 'tag' => 'ol')
127
+        );
128 128
     $body = preg_replace('#(\[[/]*)list(.*?\])#si', "$1\x07$2", $body);
129 129
 
130 130
     // replace to <li> tags - [*]..[*]|[*]..[/list]
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
     // replace to <ol>/<ul> and </ol>/</ul> tags
140 140
     // It will be better to use &count and do-while, if php 5 or higher.
141 141
     while (preg_match("#\[\x07[=]*((?-i)[cds1aAiI])*(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si", $body)) {
142
-      $body = preg_replace("#\[\x07[=]*((?-i)[cds1aAiI])*(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi", '"<". $l_type[\'$1\']["tag"] ." class=\"bb-list\" style=\"list-style-type:". $l_type[\'$1\']["style"] .";\">". str_replace(\'\"\', \'"\', \'$2\') ."</". $l_type[\'$1\']["tag"] .">"', $body);
142
+        $body = preg_replace("#\[\x07[=]*((?-i)[cds1aAiI])*(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi", '"<". $l_type[\'$1\']["tag"] ." class=\"bb-list\" style=\"list-style-type:". $l_type[\'$1\']["style"] .";\">". str_replace(\'\"\', \'"\', \'$2\') ."</". $l_type[\'$1\']["tag"] .">"', $body);
143 143
     }
144 144
 
145 145
     // remove <br /> tags
146 146
     $body = preg_replace('#(<[/]*([uo]l|li).*>.*)<br />#i', '$1', $body);
147
-  } // end processing for [list] and [*]
147
+    } // end processing for [list] and [*]
148 148
 
149
-  // Define BBCode tags
150
-  $preg = array(
149
+    // Define BBCode tags
150
+    $preg = array(
151 151
     // Implement [notag]
152 152
     '#\[notag(?::\w+)?\](.*?)\[/notag(?::\w+)?\]#sie'        => '_bbcode_notag_tag(\'\\1\')',
153 153
 
@@ -215,36 +215,36 @@  discard block
 block discarded – undo
215 215
     // Cleanup table output (td, th and tr tags)
216 216
     '#<([\/]?)t([dhr])><br />#si'                           => '<\\1t\\2>',
217 217
     '#<table(.+?)><br />#si'                                => '<table\\1>',
218
-  );
219
-  $body = preg_replace(array_keys($preg), array_values($preg), $body);
218
+    );
219
+    $body = preg_replace(array_keys($preg), array_values($preg), $body);
220 220
 
221
-  // Simple replacements (str_replace is faster than preg_replace)
222
-  $str = array(
221
+    // Simple replacements (str_replace is faster than preg_replace)
222
+    $str = array(
223 223
     // Horizontal delimiter
224 224
     '[hr]'   => '<hr class="bb-hr" />',
225 225
     // Force line break
226 226
     '[br]'   => '<br class="bb-br" />',
227 227
     // Force space
228 228
     '[sp]'   => '&nbsp;',
229
-  );
230
-  $body = str_replace(array_keys($str), array_values($str), $body);
229
+    );
230
+    $body = str_replace(array_keys($str), array_values($str), $body);
231 231
 
232
-  // We cannot evaluate the variable in callback function because 
233
-  // there is no way to pass the $format variable
234
-  if (variable_get("bbcode_encode_mailto_$format", 1)) {
232
+    // We cannot evaluate the variable in callback function because 
233
+    // there is no way to pass the $format variable
234
+    if (variable_get("bbcode_encode_mailto_$format", 1)) {
235 235
     // Replacing email addresses with encoded html
236 236
     $body = preg_replace_callback('#\[email(?::\w+)?\]([\w\.\-\+~@]+)\[/email(?::\w+)?\]#si', '_bbcode_encode_mailto', $body);
237 237
     $body = preg_replace_callback('#\[email=(.*?)(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si', '_bbcode_encode_mailto', $body);
238
-  }
239
-  else {
238
+    }
239
+    else {
240 240
     $body = preg_replace(
241
-      array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si','#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'),
242
-      array('<a href="mailto:\\1" class="bb-email">\\1</a>', '<a href="mailto:\\1" class="bb-email">\\2</a>'),
243
-      $body);
244
-  }
241
+        array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si','#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'),
242
+        array('<a href="mailto:\\1" class="bb-email">\\1</a>', '<a href="mailto:\\1" class="bb-email">\\2</a>'),
243
+        $body);
244
+    }
245 245
 
246
-  // Turns web and e-mail addresses into clickable links
247
-  if (variable_get("bbcode_make_links_$format", 1)) {
246
+    // Turns web and e-mail addresses into clickable links
247
+    if (variable_get("bbcode_make_links_$format", 1)) {
248 248
 
249 249
     // pad with a space so we can match things at the start of the 1st line
250 250
     $ret = ' ' . $body;
@@ -260,109 +260,109 @@  discard block
 block discarded – undo
260 260
     // Must contain at least 2 dots. xxxx contains either alphanum, or "-"
261 261
     // zzzz is optional.. will contain everything up to the first space, newline,
262 262
     // comma, double quote or <.
263
-     $ret = preg_replace('#([\t\r\n >\(\[\|])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\'\(\n\r\t<\)\[\]\|]*)?)#i', '\1<a href="http://\2.\3">\2.\3</a>', $ret);
263
+        $ret = preg_replace('#([\t\r\n >\(\[\|])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\'\(\n\r\t<\)\[\]\|]*)?)#i', '\1<a href="http://\2.\3">\2.\3</a>', $ret);
264 264
 
265 265
     // matches an email@domain type address at the start of a line, or after a space.
266 266
     // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
267 267
     if (variable_get("bbcode_encode_mailto_$format", 1))
268
-      $ret = preg_replace_callback("#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", '_bbcode_encode_mailto', $ret);
268
+        $ret = preg_replace_callback("#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", '_bbcode_encode_mailto', $ret);
269 269
     else 
270
-      $ret = preg_replace('#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i', '\\1<a href="mailto:\\2@\\3">\\2@\\3</a>', $ret);
270
+        $ret = preg_replace('#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i', '\\1<a href="mailto:\\2@\\3">\\2@\\3</a>', $ret);
271 271
 
272 272
     // Remove our padding
273 273
     $ret = str_replace("\x07", '', $ret);
274 274
     $body = substr($ret, 1);
275
-  }
275
+    }
276 276
 
277
-  if (variable_get("bbcode_filter_nofollow_$format", 0)) {
277
+    if (variable_get("bbcode_filter_nofollow_$format", 0)) {
278 278
     $body = preg_replace('#<a([^>]+)>#i', '<a\\1 rel="nofollow">', $body);
279
-  }
279
+    }
280 280
 
281
-  return $body;
281
+    return $body;
282 282
 }
283 283
 
284 284
 function _bbcode_generate_heading($level, $text) {
285
-  $anchor = preg_replace('/([\s]+)/', '_', $text);
286
-  $anchor = preg_replace('/([\W]+)/', '',  $anchor);
287
-  return '<h'. $level .'><a name="'. $anchor .'">'. $text .'</a></h'. $level .'>';
285
+    $anchor = preg_replace('/([\s]+)/', '_', $text);
286
+    $anchor = preg_replace('/([\W]+)/', '',  $anchor);
287
+    return '<h'. $level .'><a name="'. $anchor .'">'. $text .'</a></h'. $level .'>';
288 288
 }
289 289
 
290 290
 function _bbcode_generate_index($body, $tag = 'ol') {
291
-  $level = 0;
292
-  $index = '<'. $tag .">\n";
293
-  $close_tags = 0;
291
+    $level = 0;
292
+    $index = '<'. $tag .">\n";
293
+    $close_tags = 0;
294 294
 
295
-  if (preg_match_all('#\[h([1-6]).*?\](.*?)\[/h([1-6]).*?\]#si', $body, $head_tags, PREG_SET_ORDER)) {
295
+    if (preg_match_all('#\[h([1-6]).*?\](.*?)\[/h([1-6]).*?\]#si', $body, $head_tags, PREG_SET_ORDER)) {
296 296
     foreach ($head_tags as $head_tag) {
297
-      if ($level == 0) $level = $head_tag[1];
298
-      $anchor = preg_replace('/([\s]+)/', '_', $head_tag[2]);
299
-      $anchor = preg_replace('/([\W]+)/', '',  $anchor);
297
+        if ($level == 0) $level = $head_tag[1];
298
+        $anchor = preg_replace('/([\s]+)/', '_', $head_tag[2]);
299
+        $anchor = preg_replace('/([\W]+)/', '',  $anchor);
300 300
 
301
-      if ($head_tag[1] > $level) {
301
+        if ($head_tag[1] > $level) {
302 302
         $index .= '<'. $tag .">\n";
303 303
         $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
304 304
         $close_tags++;
305 305
         $level = $head_tag[1];
306
-      } else if ($head_tag[1] < $level) {
306
+        } else if ($head_tag[1] < $level) {
307 307
         while ($close_tags > 0) {
308
-           $index .= '</'. $tag .">\n";
309
-           $close_tags--;
308
+            $index .= '</'. $tag .">\n";
309
+            $close_tags--;
310 310
         }
311 311
         $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
312 312
         $level = $head_tag[1];
313
-      } else {
313
+        } else {
314 314
         $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
315 315
         $level = $head_tag[1];
316
-      }
316
+        }
317
+    }
317 318
     }
318
-  }
319
-  while ($close_tags >= 0) {
319
+    while ($close_tags >= 0) {
320 320
     $index .= '</'. $tag .">\n";
321 321
     $close_tags--;
322
-  }
323
-  return $index;
322
+    }
323
+    return $index;
324 324
 }
325 325
 
326 326
 function _bbcode_encode_mailto($matches) {
327
-  if (isset($matches[3])) 
327
+    if (isset($matches[3])) 
328 328
     $link = 'document.write(\'<a href="mailto:' . $matches[2].'@'.$matches[3] . '">' . $matches[2].'@'.$matches[3] . '</a>\');';
329
-  else 
329
+    else 
330 330
     $link = 'document.write(\'<a href="mailto:' . $matches[1] . '" class="bb-email">' . (isset($matches[2]) ? $matches[2] : $matches[1]) . '</a>\');';
331 331
 
332
-  $js_encode = '';
333
-  for ($x = 0; $x < strlen($link); $x++) 
332
+    $js_encode = '';
333
+    for ($x = 0; $x < strlen($link); $x++) 
334 334
     $js_encode .= '%' . bin2hex($link{$x});
335 335
 
336
-  $link = '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
337
-  if (isset($matches[3]))
336
+    $link = '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
337
+    if (isset($matches[3]))
338 338
     $link = $matches[1] . $link;
339 339
 
340
-  return $link;
340
+    return $link;
341 341
 }
342 342
 
343 343
 function _bbcode_notag_tag($text = NULL) {
344
-  return str_replace( array('[', ']', '@'), array('&#91;', '&#93;', '&#64;'), stripslashes($text));
344
+    return str_replace( array('[', ']', '@'), array('&#91;', '&#93;', '&#64;'), stripslashes($text));
345 345
 }
346 346
 
347 347
 function _bbcode_php_tag($text = NULL) {
348
-  return '<pre>'. highlight_string( str_replace('<br />', '', stripslashes($text)), true) .'</pre>';
348
+    return '<pre>'. highlight_string( str_replace('<br />', '', stripslashes($text)), true) .'</pre>';
349 349
 }
350 350
 
351 351
 function _bbcode_round_size_val($size) {
352
-  if ($size < 6)
353
-      return 6;
354
-  elseif ($size > 48)
355
-      return 48;
356
-  else
357
-     return $size;
352
+    if ($size < 6)
353
+        return 6;
354
+    elseif ($size > 48)
355
+        return 48;
356
+    else
357
+        return $size;
358 358
 }
359 359
 
360 360
 function _bbcode_replace_nest_tag($arr = NULL) {
361
-  $text = preg_replace('#(\[[/]*)'. $arr['tag'] .'(.*?\])#si', "$1\x07$2", $arr['text']);
362
-  // It will be better to use &count and do-while, if php 5 or higher.
363
-  while (preg_match($arr['pattern'], $text)) {
361
+    $text = preg_replace('#(\[[/]*)'. $arr['tag'] .'(.*?\])#si', "$1\x07$2", $arr['text']);
362
+    // It will be better to use &count and do-while, if php 5 or higher.
363
+    while (preg_match($arr['pattern'], $text)) {
364 364
     $text = preg_replace($arr['pattern'], $arr['replacement'], $text);
365
-  }
366
-  return $text;
365
+    }
366
+    return $text;
367 367
 }
368 368
 
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
     foreach ($code_tags as $code_tag) {
18 18
       $code_tag[1] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $code_tag[1]);
19 19
       if (strpos($code_tag[1], "\n") === FALSE)
20
-        $body = str_replace($code_tag[0], '<code class="bb-code">'. $code_tag[1] .'</code>', $body);
20
+        $body = str_replace($code_tag[0], '<code class="bb-code">'.$code_tag[1].'</code>', $body);
21 21
       elseif ($mode) {
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
-        $pre[$i++] = '<pre class="bb-code-block">'. $code_tag[1] .'</pre>';
24
+        $pre[$i++] = '<pre class="bb-code-block">'.$code_tag[1].'</pre>';
25 25
       }
26 26
       else
27
-        $body = str_replace($code_tag[0], '<pre class="bb-code-block">'. $code_tag[1] .'</pre>', $body);
27
+        $body = str_replace($code_tag[0], '<pre class="bb-code-block">'.$code_tag[1].'</pre>', $body);
28 28
     }
29 29
   }
30 30
 
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
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);
41
-      for ($i=0; $i<sizeof($parts); $i++) {
41
+      for ($i = 0; $i < sizeof($parts); $i++) {
42 42
          // No linebreaks if paragraph starts with an HTML tag
43
-         if ( !preg_match('/^<.*>/', $parts[$i]) ) 
43
+         if (!preg_match('/^<.*>/', $parts[$i])) 
44 44
            $parts[$i] = nl2br($parts[$i]);
45 45
 
46 46
          // Some tags should not be in paragraph blocks
47
-         if ( !preg_match('/^(?:<|\[)(?:table|list|ol|ul|pre|select|form|blockquote|hr)/i', $parts[$i]) ) 
48
-           $parts[$i] = '<p>'. $parts[$i] .'</p>';
47
+         if (!preg_match('/^(?:<|\[)(?:table|list|ol|ul|pre|select|form|blockquote|hr)/i', $parts[$i])) 
48
+           $parts[$i] = '<p>'.$parts[$i].'</p>';
49 49
       }
50 50
       $body = implode("\n\n", $parts);
51 51
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
   }
70 70
   // Also add opening tags, if needed
71 71
   for ($i = $unclosed; $i < 0; $i++) {
72
-    $body = '[quote]' . $body;
72
+    $body = '[quote]'.$body;
73 73
   }
74 74
   preg_match_all('/\[list/i', $body, $matches);
75 75
   $opentags = count($matches['0']);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     $body .= '[/list]';
80 80
   }
81 81
   for ($i = $unclosed; $i < 0; $i++) {
82
-    $body = '[list]' . $body;
82
+    $body = '[list]'.$body;
83 83
   }
84 84
 
85 85
   // begin processing for [size] 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
   }
239 239
   else {
240 240
     $body = preg_replace(
241
-      array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si','#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'),
241
+      array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si', '#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'),
242 242
       array('<a href="mailto:\\1" class="bb-email">\\1</a>', '<a href="mailto:\\1" class="bb-email">\\2</a>'),
243 243
       $body);
244 244
   }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
   if (variable_get("bbcode_make_links_$format", 1)) {
248 248
 
249 249
     // pad with a space so we can match things at the start of the 1st line
250
-    $ret = ' ' . $body;
250
+    $ret = ' '.$body;
251 251
     // padding to already filtered links
252 252
     $ret = preg_replace('#(<a.+>)(.+</a>)#i', "$1\x07$2", $ret);
253 253
 
@@ -283,41 +283,41 @@  discard block
 block discarded – undo
283 283
 
284 284
 function _bbcode_generate_heading($level, $text) {
285 285
   $anchor = preg_replace('/([\s]+)/', '_', $text);
286
-  $anchor = preg_replace('/([\W]+)/', '',  $anchor);
287
-  return '<h'. $level .'><a name="'. $anchor .'">'. $text .'</a></h'. $level .'>';
286
+  $anchor = preg_replace('/([\W]+)/', '', $anchor);
287
+  return '<h'.$level.'><a name="'.$anchor.'">'.$text.'</a></h'.$level.'>';
288 288
 }
289 289
 
290 290
 function _bbcode_generate_index($body, $tag = 'ol') {
291 291
   $level = 0;
292
-  $index = '<'. $tag .">\n";
292
+  $index = '<'.$tag.">\n";
293 293
   $close_tags = 0;
294 294
 
295 295
   if (preg_match_all('#\[h([1-6]).*?\](.*?)\[/h([1-6]).*?\]#si', $body, $head_tags, PREG_SET_ORDER)) {
296 296
     foreach ($head_tags as $head_tag) {
297 297
       if ($level == 0) $level = $head_tag[1];
298 298
       $anchor = preg_replace('/([\s]+)/', '_', $head_tag[2]);
299
-      $anchor = preg_replace('/([\W]+)/', '',  $anchor);
299
+      $anchor = preg_replace('/([\W]+)/', '', $anchor);
300 300
 
301 301
       if ($head_tag[1] > $level) {
302
-        $index .= '<'. $tag .">\n";
303
-        $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
302
+        $index .= '<'.$tag.">\n";
303
+        $index .= '<li><a href="#'.$anchor.'">'.$head_tag[2]."</a>\n";
304 304
         $close_tags++;
305 305
         $level = $head_tag[1];
306 306
       } else if ($head_tag[1] < $level) {
307 307
         while ($close_tags > 0) {
308
-           $index .= '</'. $tag .">\n";
308
+           $index .= '</'.$tag.">\n";
309 309
            $close_tags--;
310 310
         }
311
-        $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
311
+        $index .= '<li><a href="#'.$anchor.'">'.$head_tag[2]."</a>\n";
312 312
         $level = $head_tag[1];
313 313
       } else {
314
-        $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
314
+        $index .= '<li><a href="#'.$anchor.'">'.$head_tag[2]."</a>\n";
315 315
         $level = $head_tag[1];
316 316
       }
317 317
     }
318 318
   }
319 319
   while ($close_tags >= 0) {
320
-    $index .= '</'. $tag .">\n";
320
+    $index .= '</'.$tag.">\n";
321 321
     $close_tags--;
322 322
   }
323 323
   return $index;
@@ -325,27 +325,27 @@  discard block
 block discarded – undo
325 325
 
326 326
 function _bbcode_encode_mailto($matches) {
327 327
   if (isset($matches[3])) 
328
-    $link = 'document.write(\'<a href="mailto:' . $matches[2].'@'.$matches[3] . '">' . $matches[2].'@'.$matches[3] . '</a>\');';
328
+    $link = 'document.write(\'<a href="mailto:'.$matches[2].'@'.$matches[3].'">'.$matches[2].'@'.$matches[3].'</a>\');';
329 329
   else 
330
-    $link = 'document.write(\'<a href="mailto:' . $matches[1] . '" class="bb-email">' . (isset($matches[2]) ? $matches[2] : $matches[1]) . '</a>\');';
330
+    $link = 'document.write(\'<a href="mailto:'.$matches[1].'" class="bb-email">'.(isset($matches[2]) ? $matches[2] : $matches[1]).'</a>\');';
331 331
 
332 332
   $js_encode = '';
333 333
   for ($x = 0; $x < strlen($link); $x++) 
334
-    $js_encode .= '%' . bin2hex($link{$x});
334
+    $js_encode .= '%'.bin2hex($link{$x});
335 335
 
336 336
   $link = '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
337 337
   if (isset($matches[3]))
338
-    $link = $matches[1] . $link;
338
+    $link = $matches[1].$link;
339 339
 
340 340
   return $link;
341 341
 }
342 342
 
343 343
 function _bbcode_notag_tag($text = NULL) {
344
-  return str_replace( array('[', ']', '@'), array('&#91;', '&#93;', '&#64;'), stripslashes($text));
344
+  return str_replace(array('[', ']', '@'), array('&#91;', '&#93;', '&#64;'), stripslashes($text));
345 345
 }
346 346
 
347 347
 function _bbcode_php_tag($text = NULL) {
348
-  return '<pre>'. highlight_string( str_replace('<br />', '', stripslashes($text)), true) .'</pre>';
348
+  return '<pre>'.highlight_string(str_replace('<br />', '', stripslashes($text)), true).'</pre>';
349 349
 }
350 350
 
351 351
 function _bbcode_round_size_val($size) {
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 }
359 359
 
360 360
 function _bbcode_replace_nest_tag($arr = NULL) {
361
-  $text = preg_replace('#(\[[/]*)'. $arr['tag'] .'(.*?\])#si', "$1\x07$2", $arr['text']);
361
+  $text = preg_replace('#(\[[/]*)'.$arr['tag'].'(.*?\])#si', "$1\x07$2", $arr['text']);
362 362
   // It will be better to use &count and do-while, if php 5 or higher.
363 363
   while (preg_match($arr['pattern'], $text)) {
364 364
     $text = preg_replace($arr['pattern'], $arr['replacement'], $text);
Please login to merge, or discard this patch.
Braces   +18 added lines, -13 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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]))
Please login to merge, or discard this patch.
Upper-Lower-Casing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
   if (preg_match_all('#\[code(?::\w+)?\](.*?)\[/code(?::\w+)?\]#si', $body, $code_tags, PREG_SET_ORDER)) {
17 17
     foreach ($code_tags as $code_tag) {
18 18
       $code_tag[1] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $code_tag[1]);
19
-      if (strpos($code_tag[1], "\n") === FALSE)
19
+      if (strpos($code_tag[1], "\n") === false)
20 20
         $body = str_replace($code_tag[0], '<code class="bb-code">'. $code_tag[1] .'</code>', $body);
21 21
       elseif ($mode) {
22 22
         // Strip preformatted code blocks from text during line break processing, replaced below
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
   }
84 84
 
85 85
   // begin processing for [size] 
86
-  if (stristr($body, '[size=') !== FALSE) { // prevent useless processing
86
+  if (stristr($body, '[size=') !== false) { // prevent useless processing
87 87
     $arr = array(
88 88
       'tag'         => 'size',
89 89
       'pattern'     => '#\[\x07=([\d]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi',
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
   } // end processing for [size]
94 94
 
95 95
   // begin processing for [color]
96
-  if (stristr($body, '[color=') !== FALSE) { // prevent useless processing
96
+  if (stristr($body, '[color=') !== false) { // prevent useless processing
97 97
     $arr = array(
98 98
       'tag'         => 'color',
99 99
       'pattern'     => '#\[\x07=([\#\w]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
   } // end processing for [color]
104 104
 
105 105
   // begin processing for [font]
106
-  if (stristr($body, '[font=') !== FALSE) { // prevent useless processing
106
+  if (stristr($body, '[font=') !== false) { // prevent useless processing
107 107
     $arr = array(
108 108
       'tag'         => 'font',
109 109
       'pattern'     => '#\[\x07=([\w\s]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
   } // end processing for [font]
114 114
 
115 115
   // begin processing for [list] and [*]
116
-  if (stristr($body, '[list') !== FALSE) { // prevent useless processing
116
+  if (stristr($body, '[list') !== false) { // prevent useless processing
117 117
     $l_type = array(
118
-      NULL   => array('style' => 'circle', 'tag' => 'ul'),
118
+      null   => array('style' => 'circle', 'tag' => 'ul'),
119 119
       'c'    => array('style' => 'circle', 'tag' => 'ul'),
120 120
       'd'    => array('style' => 'disc', 'tag' => 'ul'),
121 121
       's'    => array('style' => 'square', 'tag' => 'ul'),
@@ -340,11 +340,11 @@  discard block
 block discarded – undo
340 340
   return $link;
341 341
 }
342 342
 
343
-function _bbcode_notag_tag($text = NULL) {
343
+function _bbcode_notag_tag($text = null) {
344 344
   return str_replace( array('[', ']', '@'), array('&#91;', '&#93;', '&#64;'), stripslashes($text));
345 345
 }
346 346
 
347
-function _bbcode_php_tag($text = NULL) {
347
+function _bbcode_php_tag($text = null) {
348 348
   return '<pre>'. highlight_string( str_replace('<br />', '', stripslashes($text)), true) .'</pre>';
349 349
 }
350 350
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
      return $size;
358 358
 }
359 359
 
360
-function _bbcode_replace_nest_tag($arr = NULL) {
360
+function _bbcode_replace_nest_tag($arr = null) {
361 361
   $text = preg_replace('#(\[[/]*)'. $arr['tag'] .'(.*?\])#si', "$1\x07$2", $arr['text']);
362 362
   // It will be better to use &count and do-while, if php 5 or higher.
363 363
   while (preg_match($arr['pattern'], $text)) {
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/cck/includes/content.devel.inc 5 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -68,6 +68,7 @@
 block discarded – undo
68 68
  * custom multiple value widgets but don't need any other special multiple
69 69
  * values handling. This will call the field generation function
70 70
  * a random number of times and compile the results into a node array.
71
+ * @param string $function
71 72
  */
72 73
 function content_devel_multiple($function, $node, $field) {
73 74
   $node_field = array();
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -19,48 +19,48 @@  discard block
 block discarded – undo
19 19
  * information in each of its CCK fields.
20 20
  **/
21 21
 function content_generate_fields(&$node, $field) {
22
-  $type_name = $node->type;
23
-  $type = content_types($type_name);
24
-  $field_types = _content_field_types();
22
+    $type_name = $node->type;
23
+    $type = content_types($type_name);
24
+    $field_types = _content_field_types();
25 25
 
26
-  if (!empty($type['fields'])) {
26
+    if (!empty($type['fields'])) {
27 27
     foreach ($type['fields'] as $field) {
28
-      $node_field = array();
29
-      // If module handles own multiples, then only call its hook once.
30
-      if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
28
+        $node_field = array();
29
+        // If module handles own multiples, then only call its hook once.
30
+        if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
31 31
         $max = 0;
32
-      }
33
-      else {
32
+        }
33
+        else {
34 34
         switch ($field['multiple']) {
35
-          case 0:
35
+            case 0:
36 36
             $max = 0;
37 37
             break;
38
-          case 1:
38
+            case 1:
39 39
             $max = rand(0, 3); //just an arbitrary number for 'unlimited'
40 40
             break;
41
-          default:
41
+            default:
42 42
             $max = $field['multiple'];
43 43
             break;
44 44
         }
45
-      }
46
-      for ($i = 0; $i <= $max; $i++) {
45
+        }
46
+        for ($i = 0; $i <= $max; $i++) {
47 47
         $module = $field_types[$field['type']]['module'];
48 48
         $function = $module .'_content_generate';
49 49
         if (function_exists($function)) {
50
-          $result = $function($node, $field); // $items, $teaser, $page
51
-          if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
50
+            $result = $function($node, $field); // $items, $teaser, $page
51
+            if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
52 52
             // Fields that handle their own multiples will add their own deltas.
53 53
             $node_field = $result;
54
-          }
55
-          else {
54
+            }
55
+            else {
56 56
             // When multiples are handled by the content module, add a delta for each result.
57 57
             $node_field[$i] = $result;
58
-          }
58
+            }
59 59
         }
60
-      }
61
-      $node->{$field['field_name']} = $node_field;
60
+        }
61
+        $node->{$field['field_name']} = $node_field;
62
+    }
62 63
     }
63
-  }
64 64
 }
65 65
 
66 66
 /**
@@ -70,149 +70,149 @@  discard block
 block discarded – undo
70 70
  * a random number of times and compile the results into a node array.
71 71
  */
72 72
 function content_devel_multiple($function, $node, $field) {
73
-  $node_field = array();
74
-  if (function_exists($function)) {
73
+    $node_field = array();
74
+    if (function_exists($function)) {
75 75
     switch ($field['multiple']) {
76
-      case 0:
76
+        case 0:
77 77
         $max = 0;
78 78
         break;
79
-      case 1:
79
+        case 1:
80 80
         $max = rand(0, 3); //just an arbitrary number for 'unlimited'
81 81
         break;
82
-      default:
82
+        default:
83 83
         $max = $field['multiple'];
84 84
         break;
85 85
     }
86 86
     for ($i = 0; $i <= $max; $i++) {
87
-      $node_field[$i] = $function($node, $field);
87
+        $node_field[$i] = $function($node, $field);
88
+    }
88 89
     }
89
-  }
90
-  return $node_field;
90
+    return $node_field;
91 91
 }
92 92
 
93 93
 if (module_exists('text')) {
94
-  function text_content_generate($node, $field) {
94
+    function text_content_generate($node, $field) {
95 95
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
96
-      return content_devel_multiple('_text_content_generate', $node, $field);
96
+        return content_devel_multiple('_text_content_generate', $node, $field);
97 97
     }
98 98
     else {
99
-      return _text_content_generate($node, $field);
99
+        return _text_content_generate($node, $field);
100
+    }
100 101
     }
101
-  }
102 102
 
103
-  function _text_content_generate($node, $field) {
103
+    function _text_content_generate($node, $field) {
104 104
     $node_field = array();
105 105
     if ($field['widget']['type'] == 'text_textarea') {
106
-      $format = $field['text_processing'] ? rand(0, 3) : 0;
107
-      $node_field['value'] = devel_create_content($format);
108
-      $node_field['format'] = $format;
106
+        $format = $field['text_processing'] ? rand(0, 3) : 0;
107
+        $node_field['value'] = devel_create_content($format);
108
+        $node_field['format'] = $format;
109 109
     }
110 110
     else {
111
-      $allowed_values = content_allowed_values($field);
112
-      if (!empty($allowed_values)) {
111
+        $allowed_values = content_allowed_values($field);
112
+        if (!empty($allowed_values)) {
113 113
         // Just pick one of the specified allowed values.
114 114
         $node_field['value'] = array_rand($allowed_values);
115
-      }
116
-      else {
115
+        }
116
+        else {
117 117
         // Generate a value that respects max_length.
118 118
         if (empty($field['max_length'])) {
119
-          $field['max_length'] = 12;
119
+            $field['max_length'] = 12;
120 120
         }
121 121
         $node_field['value'] = user_password($field['max_length']);
122
-      }
122
+        }
123 123
     }
124 124
     return $node_field;
125
-  }
125
+    }
126 126
 }
127 127
 
128 128
 if (module_exists('number')) {
129
-  function number_content_generate($node, $field) {
129
+    function number_content_generate($node, $field) {
130 130
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
131
-      return content_devel_multiple('_number_content_generate', $node, $field);
131
+        return content_devel_multiple('_number_content_generate', $node, $field);
132 132
     }
133 133
     else {
134
-      return _number_content_generate($node, $field);
134
+        return _number_content_generate($node, $field);
135
+    }
135 136
     }
136
-  }
137 137
 
138
-  function _number_content_generate($node, $field) {
138
+    function _number_content_generate($node, $field) {
139 139
     $node_field = array();
140 140
     $allowed_values = content_allowed_values($field);
141 141
     if (!empty($allowed_values)) {
142
-      // Just pick one of the specified allowed values.
143
-      $node_field['value'] = array_rand($allowed_values);
142
+        // Just pick one of the specified allowed values.
143
+        $node_field['value'] = array_rand($allowed_values);
144 144
     }
145 145
     else {
146
-      $min = is_numeric($field['min']) ? $field['min'] : 0;
147
-      switch ($field['type']) {
146
+        $min = is_numeric($field['min']) ? $field['min'] : 0;
147
+        switch ($field['type']) {
148 148
         case 'number_integer':
149 149
           $max = is_numeric($field['max']) ? $field['max'] : 10000;
150
-          $decimal = 0;
151
-          $scale = 0;
152
-          break;
150
+            $decimal = 0;
151
+            $scale = 0;
152
+            break;
153 153
 
154 154
         case 'number_decimal':
155 155
           $precision = is_numeric($field['precision']) ? $field['precision'] : 10;
156
-          $scale = is_numeric($field['scale']) ? $field['scale'] : 2;
157
-          $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
158
-          $decimal = rand(0, (10 * $scale)) / 100;
159
-          break;
156
+            $scale = is_numeric($field['scale']) ? $field['scale'] : 2;
157
+            $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
158
+            $decimal = rand(0, (10 * $scale)) / 100;
159
+            break;
160 160
 
161 161
         case 'number_float':
162 162
           $precision = rand(10, 32);
163
-          $scale = rand(0, 2);
164
-          $decimal = rand(0, (10 * $scale)) / 100;
165
-          $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
166
-          break;
167
-      }
168
-      $node_field['value'] = round((rand($min, $max) + $decimal), $scale);
163
+            $scale = rand(0, 2);
164
+            $decimal = rand(0, (10 * $scale)) / 100;
165
+            $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
166
+            break;
167
+        }
168
+        $node_field['value'] = round((rand($min, $max) + $decimal), $scale);
169 169
     }
170 170
     return $node_field;
171
-  }
171
+    }
172 172
 }
173 173
 
174 174
 if (module_exists('nodereference')) {
175
-  function nodereference_content_generate($node, $field) {
175
+    function nodereference_content_generate($node, $field) {
176 176
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
177
-      return content_devel_multiple('_nodereference_content_generate', $node, $field);
177
+        return content_devel_multiple('_nodereference_content_generate', $node, $field);
178 178
     }
179 179
     else {
180
-      return _nodereference_content_generate($node, $field);
180
+        return _nodereference_content_generate($node, $field);
181
+    }
181 182
     }
182
-  }
183 183
 
184
-  function _nodereference_content_generate($node, $field) {
184
+    function _nodereference_content_generate($node, $field) {
185 185
     $node_field = array();
186 186
     $allowed_values = nodereference_allowed_values($field);
187 187
     unset($allowed_values[0]);
188 188
     if (!empty($allowed_values)) {
189
-      // Just pick one of the specified allowed values.
190
-      $node_field['nid'] = array_rand($allowed_values);
189
+        // Just pick one of the specified allowed values.
190
+        $node_field['nid'] = array_rand($allowed_values);
191 191
     }
192 192
     return $node_field;
193
-  }
193
+    }
194 194
 }
195 195
 
196 196
 if (module_exists('userreference')) {
197
-  function userreference_content_generate($node, $field) {
197
+    function userreference_content_generate($node, $field) {
198 198
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
199
-      return content_devel_multiple('_userreference_content_generate', $node, $field);
199
+        return content_devel_multiple('_userreference_content_generate', $node, $field);
200 200
     }
201 201
     else {
202
-      return _userreference_content_generate($node, $field);
202
+        return _userreference_content_generate($node, $field);
203
+    }
203 204
     }
204
-  }
205 205
 
206
-  function _userreference_content_generate($node, $field) {
206
+    function _userreference_content_generate($node, $field) {
207 207
     $node_field = array();
208 208
     $allowed_values = userreference_allowed_values($field);
209 209
     if (isset($allowed_values['none'])) {
210
-      unset($allowed_values['none']);
210
+        unset($allowed_values['none']);
211 211
     }
212 212
     if (!empty($allowed_values)) {
213
-      // Just pick one of the specified allowed values.
214
-      $node_field['uid'] = array_rand($allowed_values);
213
+        // Just pick one of the specified allowed values.
214
+        $node_field['uid'] = array_rand($allowed_values);
215 215
     }
216 216
     return $node_field;
217
-  }
217
+    }
218 218
 }
219 219
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
       }
33 33
       else {
34 34
         switch ($field['multiple']) {
35
-          case 0:
36
-            $max = 0;
37
-            break;
38
-          case 1:
39
-            $max = rand(0, 3); //just an arbitrary number for 'unlimited'
40
-            break;
41
-          default:
42
-            $max = $field['multiple'];
43
-            break;
35
+        case 0:
36
+          $max = 0;
37
+          break;
38
+        case 1:
39
+          $max = rand(0, 3); //just an arbitrary number for 'unlimited'
40
+          break;
41
+        default:
42
+          $max = $field['multiple'];
43
+          break;
44 44
         }
45 45
       }
46 46
       for ($i = 0; $i <= $max; $i++) {
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
   $node_field = array();
74 74
   if (function_exists($function)) {
75 75
     switch ($field['multiple']) {
76
-      case 0:
77
-        $max = 0;
78
-        break;
79
-      case 1:
80
-        $max = rand(0, 3); //just an arbitrary number for 'unlimited'
81
-        break;
82
-      default:
83
-        $max = $field['multiple'];
84
-        break;
76
+    case 0:
77
+      $max = 0;
78
+      break;
79
+    case 1:
80
+      $max = rand(0, 3); //just an arbitrary number for 'unlimited'
81
+      break;
82
+    default:
83
+      $max = $field['multiple'];
84
+      break;
85 85
     }
86 86
     for ($i = 0; $i <= $max; $i++) {
87 87
       $node_field[$i] = $function($node, $field);
@@ -145,25 +145,25 @@  discard block
 block discarded – undo
145 145
     else {
146 146
       $min = is_numeric($field['min']) ? $field['min'] : 0;
147 147
       switch ($field['type']) {
148
-        case 'number_integer':
149
-          $max = is_numeric($field['max']) ? $field['max'] : 10000;
150
-          $decimal = 0;
151
-          $scale = 0;
152
-          break;
148
+      case 'number_integer':
149
+        $max = is_numeric($field['max']) ? $field['max'] : 10000;
150
+        $decimal = 0;
151
+        $scale = 0;
152
+        break;
153 153
 
154
-        case 'number_decimal':
155
-          $precision = is_numeric($field['precision']) ? $field['precision'] : 10;
156
-          $scale = is_numeric($field['scale']) ? $field['scale'] : 2;
157
-          $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
158
-          $decimal = rand(0, (10 * $scale)) / 100;
159
-          break;
154
+      case 'number_decimal':
155
+        $precision = is_numeric($field['precision']) ? $field['precision'] : 10;
156
+        $scale = is_numeric($field['scale']) ? $field['scale'] : 2;
157
+        $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
158
+        $decimal = rand(0, (10 * $scale)) / 100;
159
+        break;
160 160
 
161
-        case 'number_float':
162
-          $precision = rand(10, 32);
163
-          $scale = rand(0, 2);
164
-          $decimal = rand(0, (10 * $scale)) / 100;
165
-          $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
166
-          break;
161
+      case 'number_float':
162
+        $precision = rand(10, 32);
163
+        $scale = rand(0, 2);
164
+        $decimal = rand(0, (10 * $scale)) / 100;
165
+        $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
166
+        break;
167 167
       }
168 168
       $node_field['value'] = round((rand($min, $max) + $decimal), $scale);
169 169
     }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
       }
46 46
       for ($i = 0; $i <= $max; $i++) {
47 47
         $module = $field_types[$field['type']]['module'];
48
-        $function = $module .'_content_generate';
48
+        $function = $module.'_content_generate';
49 49
         if (function_exists($function)) {
50 50
           $result = $function($node, $field); // $items, $teaser, $page
51 51
           if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
           $precision = is_numeric($field['precision']) ? $field['precision'] : 10;
156 156
           $scale = is_numeric($field['scale']) ? $field['scale'] : 2;
157 157
           $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
158
-          $decimal = rand(0, (10 * $scale)) / 100;
158
+          $decimal = rand(0, (10*$scale))/100;
159 159
           break;
160 160
 
161 161
         case 'number_float':
162 162
           $precision = rand(10, 32);
163 163
           $scale = rand(0, 2);
164
-          $decimal = rand(0, (10 * $scale)) / 100;
164
+          $decimal = rand(0, (10*$scale))/100;
165 165
           $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
166 166
           break;
167 167
       }
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
       // If module handles own multiples, then only call its hook once.
30 30
       if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
31 31
         $max = 0;
32
-      }
33
-      else {
32
+      } else {
34 33
         switch ($field['multiple']) {
35 34
           case 0:
36 35
             $max = 0;
@@ -51,8 +50,7 @@  discard block
 block discarded – undo
51 50
           if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
52 51
             // Fields that handle their own multiples will add their own deltas.
53 52
             $node_field = $result;
54
-          }
55
-          else {
53
+          } else {
56 54
             // When multiples are handled by the content module, add a delta for each result.
57 55
             $node_field[$i] = $result;
58 56
           }
@@ -94,8 +92,7 @@  discard block
 block discarded – undo
94 92
   function text_content_generate($node, $field) {
95 93
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
96 94
       return content_devel_multiple('_text_content_generate', $node, $field);
97
-    }
98
-    else {
95
+    } else {
99 96
       return _text_content_generate($node, $field);
100 97
     }
101 98
   }
@@ -106,14 +103,12 @@  discard block
 block discarded – undo
106 103
       $format = $field['text_processing'] ? rand(0, 3) : 0;
107 104
       $node_field['value'] = devel_create_content($format);
108 105
       $node_field['format'] = $format;
109
-    }
110
-    else {
106
+    } else {
111 107
       $allowed_values = content_allowed_values($field);
112 108
       if (!empty($allowed_values)) {
113 109
         // Just pick one of the specified allowed values.
114 110
         $node_field['value'] = array_rand($allowed_values);
115
-      }
116
-      else {
111
+      } else {
117 112
         // Generate a value that respects max_length.
118 113
         if (empty($field['max_length'])) {
119 114
           $field['max_length'] = 12;
@@ -129,8 +124,7 @@  discard block
 block discarded – undo
129 124
   function number_content_generate($node, $field) {
130 125
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
131 126
       return content_devel_multiple('_number_content_generate', $node, $field);
132
-    }
133
-    else {
127
+    } else {
134 128
       return _number_content_generate($node, $field);
135 129
     }
136 130
   }
@@ -141,8 +135,7 @@  discard block
 block discarded – undo
141 135
     if (!empty($allowed_values)) {
142 136
       // Just pick one of the specified allowed values.
143 137
       $node_field['value'] = array_rand($allowed_values);
144
-    }
145
-    else {
138
+    } else {
146 139
       $min = is_numeric($field['min']) ? $field['min'] : 0;
147 140
       switch ($field['type']) {
148 141
         case 'number_integer':
@@ -175,8 +168,7 @@  discard block
 block discarded – undo
175 168
   function nodereference_content_generate($node, $field) {
176 169
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
177 170
       return content_devel_multiple('_nodereference_content_generate', $node, $field);
178
-    }
179
-    else {
171
+    } else {
180 172
       return _nodereference_content_generate($node, $field);
181 173
     }
182 174
   }
@@ -197,8 +189,7 @@  discard block
 block discarded – undo
197 189
   function userreference_content_generate($node, $field) {
198 190
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
199 191
       return content_devel_multiple('_userreference_content_generate', $node, $field);
200
-    }
201
-    else {
192
+    } else {
202 193
       return _userreference_content_generate($node, $field);
203 194
     }
204 195
   }
Please login to merge, or discard this patch.
sites/default/boinc/modules/contrib/cck/includes/content.node_form.inc 6 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
  *   the form_state for the above form
32 32
  * @param $field
33 33
  *   the field array to use to create the form element
34
- * @param $get_delta
34
+ * @param integer $get_delta
35 35
  *   use to get only a specific delta value of a multiple value field, otherwise
36 36
  *   function will return the entire $field form element.
37 37
  */
Please login to merge, or discard this patch.
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
  * chosen widget.
10 10
  */
11 11
 function content_form(&$form, &$form_state) {
12
-  $type = content_types($form['type']['#value']);
13
-  foreach ($type['fields'] as $field_name => $field) {
12
+    $type = content_types($form['type']['#value']);
13
+    foreach ($type['fields'] as $field_name => $field) {
14 14
     $form['#field_info'][$field['field_name']] = $field;
15 15
     $form += (array) content_field_form($form, $form_state, $field);
16
-  }
17
-  return $form;
16
+    }
17
+    return $form;
18 18
 }
19 19
 
20 20
 /**
@@ -36,18 +36,18 @@  discard block
 block discarded – undo
36 36
  *   function will return the entire $field form element.
37 37
  */
38 38
 function content_field_form(&$form, &$form_state, $field, $get_delta = NULL) {
39
-  $form['#cache'] = FALSE;
40
-  $node = $form['#node'];
41
-  $addition = array();
42
-  $form_element = array();
43
-  $field_name = $field['field_name'];
44
-
45
-  $items = array();
46
-
47
-  // TODO: is the "if (function_exists($function)) {" needed ?
48
-  // defining the $function here makes it unclear where it is actually called
49
-  $function = $field['widget']['module'] .'_widget';
50
-  if (function_exists($function)) {
39
+    $form['#cache'] = FALSE;
40
+    $node = $form['#node'];
41
+    $addition = array();
42
+    $form_element = array();
43
+    $field_name = $field['field_name'];
44
+
45
+    $items = array();
46
+
47
+    // TODO: is the "if (function_exists($function)) {" needed ?
48
+    // defining the $function here makes it unclear where it is actually called
49
+    $function = $field['widget']['module'] .'_widget';
50
+    if (function_exists($function)) {
51 51
     // Prepare the values to be filled in the widget.
52 52
     // We look in the following places:
53 53
     // - Form submitted values
@@ -55,88 +55,88 @@  discard block
 block discarded – undo
55 55
     //   creating a new node translation)
56 56
     // - Default values set for the field (when creating a new node).
57 57
     if (!empty($form_state['values'][$field['field_name']])) {
58
-      $items = $form_state['values'][$field['field_name']];
59
-      // If there was an AHAH add more button in this field, don't save it.
60
-      unset($items[$field['field_name'] .'_add_more']);
58
+        $items = $form_state['values'][$field['field_name']];
59
+        // If there was an AHAH add more button in this field, don't save it.
60
+        unset($items[$field['field_name'] .'_add_more']);
61 61
     }
62 62
     elseif (!empty($node->$field['field_name'])) {
63
-      $items = $node->$field['field_name'];
63
+        $items = $node->$field['field_name'];
64 64
     }
65 65
     elseif (empty($node->nid)) {
66
-      if (content_callback('widget', 'default value', $field) != CONTENT_CALLBACK_NONE) {
66
+        if (content_callback('widget', 'default value', $field) != CONTENT_CALLBACK_NONE) {
67 67
         // If a module wants to insert custom default values here,
68 68
         // it should provide a hook_default_value() function to call,
69 69
         // otherwise the content module's content_default_value() function
70 70
         // will be used.
71 71
         $callback = content_callback('widget', 'default value', $field) == CONTENT_CALLBACK_CUSTOM ? $field['widget']['module'] .'_default_value' : 'content_default_value';
72 72
         if (function_exists($callback)) {
73
-          $items = $callback($form, $form_state, $field, 0);
73
+            $items = $callback($form, $form_state, $field, 0);
74
+        }
74 75
         }
75
-      }
76 76
     }
77 77
 
78 78
     // See if access to this form element is restricted,
79 79
     // if so, skip widget processing and just set the value.
80 80
     $access = content_access('edit', $field, NULL, $node);
81 81
     if (!$access) {
82
-      $addition[$field_name] = array(
82
+        $addition[$field_name] = array(
83 83
         '#access' => $access,
84 84
         '#type' => 'value',
85 85
         '#value' => $items,
86
-      );
87
-      return $addition;
86
+        );
87
+        return $addition;
88 88
     }
89 89
 
90 90
     // If content module handles multiple values for this form element,
91 91
     // and not selecting an individual $delta, process the multiple value form.
92 92
     if (!isset($get_delta) && content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
93
-      $form_element = content_multiple_value_form($form, $form_state, $field, $items);
93
+        $form_element = content_multiple_value_form($form, $form_state, $field, $items);
94 94
     }
95 95
     // If the widget is handling multiple values (e.g optionwidgets),
96 96
     // or selecting an individual element, just get a single form
97 97
     // element and make it the $delta value.
98 98
     else {
99
-      $delta = isset($get_delta) ? $get_delta : 0;
100
-      if ($element = $function($form, $form_state, $field, $items, $delta)) {
99
+        $delta = isset($get_delta) ? $get_delta : 0;
100
+        if ($element = $function($form, $form_state, $field, $items, $delta)) {
101 101
         $title = check_plain(t($field['widget']['label']));
102 102
         $description = content_filter_xss(t($field['widget']['description']));
103 103
         $defaults = array(
104
-          '#required' => $get_delta > 0 ? FALSE : $field['required'],
105
-          '#columns'  => array_keys($field['columns']),
106
-          '#title' => $title,
107
-          '#description' => $description,
108
-          '#delta' => $delta,
109
-          '#field_name' => $field['field_name'],
110
-          '#type_name' => $field['type_name'],
104
+            '#required' => $get_delta > 0 ? FALSE : $field['required'],
105
+            '#columns'  => array_keys($field['columns']),
106
+            '#title' => $title,
107
+            '#description' => $description,
108
+            '#delta' => $delta,
109
+            '#field_name' => $field['field_name'],
110
+            '#type_name' => $field['type_name'],
111 111
         );
112 112
         // If we're processing a specific delta value for a field where the
113 113
         // content module handles multiples, set the delta in the result.
114 114
         // For fields that handle their own processing, we can't make assumptions
115 115
         // about how the field is structured, just merge in the returned value.
116 116
         if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
117
-          $form_element[$delta] = array_merge($element, $defaults);
117
+            $form_element[$delta] = array_merge($element, $defaults);
118 118
         }
119 119
         else {
120
-          $form_element = array_merge($element, $defaults);
120
+            $form_element = array_merge($element, $defaults);
121
+        }
121 122
         }
122
-      }
123 123
     }
124 124
 
125 125
     // Field name is needed at top level as well as the individual elements
126 126
     // so the multiple values or other field level theme or processing can find it.
127 127
     if ($form_element) {
128
-      $defaults = array(
128
+        $defaults = array(
129 129
         '#field_name' => $field['field_name'],
130 130
         '#tree' => TRUE,
131 131
         '#weight' => $field['widget']['weight'],
132 132
         '#access' => $access,
133 133
         // TODO: what's the need for #count ? does not seem to be used anywhere ?
134 134
         '#count' => count($form_element),
135
-      );
136
-      $addition[$field['field_name']] = array_merge($form_element, $defaults);
135
+        );
136
+        $addition[$field['field_name']] = array_merge($form_element, $defaults);
137
+    }
137 138
     }
138
-  }
139
-  return $addition;
139
+    return $addition;
140 140
 }
141 141
 
142 142
 /**
@@ -148,42 +148,42 @@  discard block
 block discarded – undo
148 148
  * - drag-n-drop value reordering
149 149
  */
150 150
 function content_multiple_value_form(&$form, &$form_state, $field, $items) {
151
-  $field_name = $field['field_name'];
151
+    $field_name = $field['field_name'];
152 152
 
153
-  switch ($field['multiple']) {
153
+    switch ($field['multiple']) {
154 154
     case 0:
155 155
       $max = 0;
156
-      break;
156
+        break;
157 157
     case 1:
158 158
       $filled_items = content_set_empty($field, $items);
159
-      $current_item_count = isset($form_state['item_count'][$field_name])
159
+        $current_item_count = isset($form_state['item_count'][$field_name])
160 160
                             ? $form_state['item_count'][$field_name]
161 161
                             : count($items);
162
-      // We always want at least one empty icon for the user to fill in.
163
-      $max = ($current_item_count > count($filled_items))
162
+        // We always want at least one empty icon for the user to fill in.
163
+        $max = ($current_item_count > count($filled_items))
164 164
               ? $current_item_count - 1
165 165
               : $current_item_count;
166 166
 
167
-      break;
167
+        break;
168 168
     default:
169 169
       $max = $field['multiple'] - 1;
170
-      break;
171
-  }
170
+        break;
171
+    }
172 172
 
173
-  $title = check_plain(t($field['widget']['label']));
174
-  $description = content_filter_xss(t($field['widget']['description']));
173
+    $title = check_plain(t($field['widget']['label']));
174
+    $description = content_filter_xss(t($field['widget']['description']));
175 175
 
176
-  $form_element = array(
176
+    $form_element = array(
177 177
     '#theme' => 'content_multiple_values',
178 178
     '#title' => $title,
179 179
     '#required' => $field['required'],
180 180
     '#description' => $description,
181
-  );
182
-  $function = $field['widget']['module'] .'_widget';
181
+    );
182
+    $function = $field['widget']['module'] .'_widget';
183 183
 
184
-  for ($delta = 0; $delta <= $max; $delta++) {
184
+    for ($delta = 0; $delta <= $max; $delta++) {
185 185
     if ($element = $function($form, $form_state, $field, $items, $delta)) {
186
-      $defaults = array(
186
+        $defaults = array(
187 187
         '#title' => ($field['multiple'] >= 1) ? '' : $title,
188 188
         '#description' => ($field['multiple'] >= 1) ? '' : $description,
189 189
         '#required' => $delta == 0 && $field['required'],
@@ -192,51 +192,51 @@  discard block
 block discarded – undo
192 192
         '#columns' => array_keys($field['columns']),
193 193
         '#field_name' => $field_name,
194 194
         '#type_name' => $field['type_name'],
195
-      );
195
+        );
196 196
 
197
-      // Add an input field for the delta (drag-n-drop reordering), which will
198
-      // be hidden by tabledrag js behavior.
199
-      if ($field['multiple'] >= 1) {
197
+        // Add an input field for the delta (drag-n-drop reordering), which will
198
+        // be hidden by tabledrag js behavior.
199
+        if ($field['multiple'] >= 1) {
200 200
         // We name the element '_weight' to avoid clashing with column names
201 201
         // defined by field modules.
202 202
         $element['_weight'] = array(
203
-          '#type' => 'weight',
204
-          '#delta' => $max, // this 'delta' is the 'weight' element's property
205
-          '#default_value' => isset($items[$delta]['_weight']) ? $items[$delta]['_weight'] : $delta,
206
-          '#weight' => 100,
203
+            '#type' => 'weight',
204
+            '#delta' => $max, // this 'delta' is the 'weight' element's property
205
+            '#default_value' => isset($items[$delta]['_weight']) ? $items[$delta]['_weight'] : $delta,
206
+            '#weight' => 100,
207 207
         );
208
-      }
208
+        }
209 209
 
210
-      $form_element[$delta] = array_merge($element, $defaults);
210
+        $form_element[$delta] = array_merge($element, $defaults);
211
+    }
211 212
     }
212
-  }
213 213
 
214
-  // Add AHAH add more button, if not working with a programmed form.
215
-  if ($field['multiple'] == 1 && empty($form['#programmed'])) {
214
+    // Add AHAH add more button, if not working with a programmed form.
215
+    if ($field['multiple'] == 1 && empty($form['#programmed'])) {
216 216
     // Make sure the form is cached so ahah can work.
217 217
     $form['#cache'] = TRUE;
218 218
     $content_type = content_types($field['type_name']);
219 219
     $field_name_css = str_replace('_', '-', $field_name);
220 220
 
221 221
     $form_element[$field_name .'_add_more'] = array(
222
-      '#type' => 'submit',
223
-      '#name' => $field_name .'_add_more',
224
-      '#value' => t('Add another item'),
225
-      '#weight' => $field['widget']['weight'] + $max + 1,
226
-      // Submit callback for disabled JavaScript. drupal_get_form() might get
227
-      // the form from the cache, so we can't rely on content_form_alter()
228
-      // including this file. Therefore, call a proxy function to do this.
229
-      '#submit' => array('content_add_more_submit_proxy'),
230
-      '#ahah' => array(
222
+        '#type' => 'submit',
223
+        '#name' => $field_name .'_add_more',
224
+        '#value' => t('Add another item'),
225
+        '#weight' => $field['widget']['weight'] + $max + 1,
226
+        // Submit callback for disabled JavaScript. drupal_get_form() might get
227
+        // the form from the cache, so we can't rely on content_form_alter()
228
+        // including this file. Therefore, call a proxy function to do this.
229
+        '#submit' => array('content_add_more_submit_proxy'),
230
+        '#ahah' => array(
231 231
         'path' => 'content/js_add_more/'. $content_type['url_str'] .'/'. $field_name,
232 232
         'wrapper' => $field_name_css .'-items',
233 233
         'method' => 'replace',
234 234
         'effect' => 'fade',
235
-      ),
236
-      // When JS is disabled, the content_add_more_submit handler will find
237
-      // the relevant field using these entries.
238
-      '#field_name' => $field_name,
239
-      '#type_name' => $field['type_name'],
235
+        ),
236
+        // When JS is disabled, the content_add_more_submit handler will find
237
+        // the relevant field using these entries.
238
+        '#field_name' => $field_name,
239
+        '#type_name' => $field['type_name'],
240 240
     );
241 241
 
242 242
     // Add wrappers for the fields and 'more' button.
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
     $form_element['#suffix'] = '</div>';
245 245
     $form_element[$field_name .'_add_more']['#prefix'] = '<div class="content-add-more clear-block">';
246 246
     $form_element[$field_name .'_add_more']['#suffix'] = '</div>';
247
-  }
248
-  return $form_element;
247
+    }
248
+    return $form_element;
249 249
 }
250 250
 
251 251
 /**
@@ -254,127 +254,127 @@  discard block
 block discarded – undo
254 254
  * entire form is rebuilt during the page reload.
255 255
  */
256 256
 function content_add_more_submit($form, &$form_state) {
257
-  // Set the form to rebuild and run submit handlers.
258
-  node_form_submit_build_node($form, $form_state);
259
-  $field_name = $form_state['clicked_button']['#field_name'];
260
-  $type_name = $form_state['clicked_button']['#type_name'];
257
+    // Set the form to rebuild and run submit handlers.
258
+    node_form_submit_build_node($form, $form_state);
259
+    $field_name = $form_state['clicked_button']['#field_name'];
260
+    $type_name = $form_state['clicked_button']['#type_name'];
261 261
 
262
-  // Make the changes we want to the form state.
263
-  if ($form_state['values'][$field_name][$field_name .'_add_more']) {
262
+    // Make the changes we want to the form state.
263
+    if ($form_state['values'][$field_name][$field_name .'_add_more']) {
264 264
     $form_state['item_count'][$field_name] = count($form_state['values'][$field_name]);
265
-  }
265
+    }
266 266
 }
267 267
 
268 268
 /**
269 269
  * Menu callback for AHAH addition of new empty widgets.
270 270
  */
271 271
 function content_add_more_js($type_name_url, $field_name) {
272
-  $type = content_types($type_name_url);
273
-  $field = content_fields($field_name, $type['type']);
272
+    $type = content_types($type_name_url);
273
+    $field = content_fields($field_name, $type['type']);
274 274
 
275
-  if (($field['multiple'] != 1) || empty($_POST['form_build_id'])) {
275
+    if (($field['multiple'] != 1) || empty($_POST['form_build_id'])) {
276 276
     // Invalid request.
277 277
     drupal_json(array('data' => ''));
278 278
     exit;
279
-  }
279
+    }
280 280
 
281
-  // Retrieve the cached form.
282
-  $form_state = array('submitted' => FALSE);
283
-  $form_build_id = $_POST['form_build_id'];
284
-  $form = form_get_cache($form_build_id, $form_state);
285
-  if (!$form) {
281
+    // Retrieve the cached form.
282
+    $form_state = array('submitted' => FALSE);
283
+    $form_build_id = $_POST['form_build_id'];
284
+    $form = form_get_cache($form_build_id, $form_state);
285
+    if (!$form) {
286 286
     // Invalid form_build_id.
287 287
     drupal_json(array('data' => ''));
288 288
     exit;
289
-  }
290
-
291
-  // We don't simply return a new empty widget to append to existing ones, because
292
-  // - ahah.js won't simply let us add a new row to a table
293
-  // - attaching the 'draggable' behavior won't be easy
294
-  // So we resort to rebuilding the whole table of widgets including the existing ones,
295
-  // which makes us jump through a few hoops.
296
-
297
-  // The form that we get from the cache is unbuilt. We need to build it so that
298
-  // _value callbacks can be executed and $form_state['values'] populated.
299
-  // We only want to affect $form_state['values'], not the $form itself
300
-  // (built forms aren't supposed to enter the cache) nor the rest of $form_data,
301
-  // so we use copies of $form and $form_data.
302
-  $form_copy = $form;
303
-  $form_state_copy = $form_state;
304
-  $form_copy['#post'] = array();
305
-  form_builder($_POST['form_id'], $form_copy, $form_state_copy);
306
-  // Just grab the data we need.
307
-  $form_state['values'] = $form_state_copy['values'];
308
-  // Reset cached ids, so that they don't affect the actual form we output.
309
-  form_clean_id(NULL, TRUE);
310
-
311
-  // Sort the $form_state['values'] we just built *and* the incoming $_POST data
312
-  // according to d-n-d reordering.
313
-  unset($form_state['values'][$field_name][$field['field_name'] .'_add_more']);
314
-  foreach ($_POST[$field_name] as $delta => $item) {
289
+    }
290
+
291
+    // We don't simply return a new empty widget to append to existing ones, because
292
+    // - ahah.js won't simply let us add a new row to a table
293
+    // - attaching the 'draggable' behavior won't be easy
294
+    // So we resort to rebuilding the whole table of widgets including the existing ones,
295
+    // which makes us jump through a few hoops.
296
+
297
+    // The form that we get from the cache is unbuilt. We need to build it so that
298
+    // _value callbacks can be executed and $form_state['values'] populated.
299
+    // We only want to affect $form_state['values'], not the $form itself
300
+    // (built forms aren't supposed to enter the cache) nor the rest of $form_data,
301
+    // so we use copies of $form and $form_data.
302
+    $form_copy = $form;
303
+    $form_state_copy = $form_state;
304
+    $form_copy['#post'] = array();
305
+    form_builder($_POST['form_id'], $form_copy, $form_state_copy);
306
+    // Just grab the data we need.
307
+    $form_state['values'] = $form_state_copy['values'];
308
+    // Reset cached ids, so that they don't affect the actual form we output.
309
+    form_clean_id(NULL, TRUE);
310
+
311
+    // Sort the $form_state['values'] we just built *and* the incoming $_POST data
312
+    // according to d-n-d reordering.
313
+    unset($form_state['values'][$field_name][$field['field_name'] .'_add_more']);
314
+    foreach ($_POST[$field_name] as $delta => $item) {
315 315
     $form_state['values'][$field_name][$delta]['_weight'] = $item['_weight'];
316
-  }
317
-  $form_state['values'][$field_name] = _content_sort_items($field, $form_state['values'][$field_name]);
318
-  $_POST[$field_name] = _content_sort_items($field, $_POST[$field_name]);
319
-
320
-  // Build our new form element for the whole field, asking for one more element.
321
-  $form_state['item_count'] = array($field_name => count($_POST[$field_name]) + 1);
322
-  $form_element = content_field_form($form, $form_state, $field);
323
-  // Let other modules alter it.
324
-  // We pass an empty array as hook_form_alter's usual 'form_state' parameter,
325
-  // instead of $form_state (for reasons we may never remember).
326
-  // However, this argument is still expected to be passed by-reference
327
-  // (and PHP5.3 will throw an error if it isn't.) This leads to:
328
-  $data = &$form_element;
329
-  $empty_form_state = array();
330
-  $data['__drupal_alter_by_ref'] = array(&$empty_form_state);
331
-  drupal_alter('form', $data, 'content_add_more_js');
332
-
333
-  // Add the new element at the right place in the (original, unbuilt) form.
334
-  if (module_exists('fieldgroup') && ($group_name = _fieldgroup_field_get_group($type['type'], $field_name))) {
316
+    }
317
+    $form_state['values'][$field_name] = _content_sort_items($field, $form_state['values'][$field_name]);
318
+    $_POST[$field_name] = _content_sort_items($field, $_POST[$field_name]);
319
+
320
+    // Build our new form element for the whole field, asking for one more element.
321
+    $form_state['item_count'] = array($field_name => count($_POST[$field_name]) + 1);
322
+    $form_element = content_field_form($form, $form_state, $field);
323
+    // Let other modules alter it.
324
+    // We pass an empty array as hook_form_alter's usual 'form_state' parameter,
325
+    // instead of $form_state (for reasons we may never remember).
326
+    // However, this argument is still expected to be passed by-reference
327
+    // (and PHP5.3 will throw an error if it isn't.) This leads to:
328
+    $data = &$form_element;
329
+    $empty_form_state = array();
330
+    $data['__drupal_alter_by_ref'] = array(&$empty_form_state);
331
+    drupal_alter('form', $data, 'content_add_more_js');
332
+
333
+    // Add the new element at the right place in the (original, unbuilt) form.
334
+    if (module_exists('fieldgroup') && ($group_name = _fieldgroup_field_get_group($type['type'], $field_name))) {
335 335
     $form[$group_name][$field_name] = $form_element[$field_name];
336
-  }
337
-  else {
336
+    }
337
+    else {
338 338
     $form[$field_name] = $form_element[$field_name];
339
-  }
340
-
341
-  // Save the new definition of the form.
342
-  $form_state['values'] = array();
343
-  form_set_cache($form_build_id, $form, $form_state);
344
-
345
-  // Build the new form against the incoming $_POST values so that we can
346
-  // render the new element.
347
-  $delta = max(array_keys($_POST[$field_name])) + 1;
348
-  $_POST[$field_name][$delta]['_weight'] = $delta;
349
-  $form_state = array('submitted' => FALSE);
350
-  $form += array(
339
+    }
340
+
341
+    // Save the new definition of the form.
342
+    $form_state['values'] = array();
343
+    form_set_cache($form_build_id, $form, $form_state);
344
+
345
+    // Build the new form against the incoming $_POST values so that we can
346
+    // render the new element.
347
+    $delta = max(array_keys($_POST[$field_name])) + 1;
348
+    $_POST[$field_name][$delta]['_weight'] = $delta;
349
+    $form_state = array('submitted' => FALSE);
350
+    $form += array(
351 351
     '#post' => $_POST,
352 352
     '#programmed' => FALSE,
353
-  );
354
-  $form = form_builder($_POST['form_id'], $form, $form_state);
355
-
356
-  // Render the new output.
357
-  $field_form = (!empty($group_name)) ? $form[$group_name][$field_name] : $form[$field_name];
358
-  // We add a div around the new content to receive the ahah effect.
359
-  $field_form[$delta]['#prefix'] = '<div class="ahah-new-content">'. (isset($field_form[$delta]['#prefix']) ? $field_form[$delta]['#prefix'] : '');
360
-  $field_form[$delta]['#suffix'] = (isset($field_form[$delta]['#suffix']) ? $field_form[$delta]['#suffix'] : '') .'</div>';
361
-  // Prevent duplicate wrapper.
362
-  unset($field_form['#prefix'], $field_form['#suffix']);
363
-
364
-  // If a newly inserted widget contains AHAH behaviors, they normally won't
365
-  // work because AHAH doesn't know about those - it just attaches to the exact
366
-  // form elements that were initially specified in the Drupal.settings object.
367
-  // The new ones didn't exist then, so we need to update Drupal.settings
368
-  // by ourselves in order to let AHAH know about those new form elements.
369
-  $javascript = drupal_add_js(NULL, NULL);
370
-  $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
371
-
372
-  $output = theme('status_messages') . drupal_render($field_form) . $output_js;
373
-
374
-  // Using drupal_json() breaks filefield's file upload, because the jQuery
375
-  // Form plugin handles file uploads in a way that is not compatible with
376
-  // 'text/javascript' response type.
377
-  $GLOBALS['devel_shutdown'] =  FALSE;
378
-  print drupal_to_js(array('status' => TRUE, 'data' => $output));
379
-  exit;
353
+    );
354
+    $form = form_builder($_POST['form_id'], $form, $form_state);
355
+
356
+    // Render the new output.
357
+    $field_form = (!empty($group_name)) ? $form[$group_name][$field_name] : $form[$field_name];
358
+    // We add a div around the new content to receive the ahah effect.
359
+    $field_form[$delta]['#prefix'] = '<div class="ahah-new-content">'. (isset($field_form[$delta]['#prefix']) ? $field_form[$delta]['#prefix'] : '');
360
+    $field_form[$delta]['#suffix'] = (isset($field_form[$delta]['#suffix']) ? $field_form[$delta]['#suffix'] : '') .'</div>';
361
+    // Prevent duplicate wrapper.
362
+    unset($field_form['#prefix'], $field_form['#suffix']);
363
+
364
+    // If a newly inserted widget contains AHAH behaviors, they normally won't
365
+    // work because AHAH doesn't know about those - it just attaches to the exact
366
+    // form elements that were initially specified in the Drupal.settings object.
367
+    // The new ones didn't exist then, so we need to update Drupal.settings
368
+    // by ourselves in order to let AHAH know about those new form elements.
369
+    $javascript = drupal_add_js(NULL, NULL);
370
+    $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
371
+
372
+    $output = theme('status_messages') . drupal_render($field_form) . $output_js;
373
+
374
+    // Using drupal_json() breaks filefield's file upload, because the jQuery
375
+    // Form plugin handles file uploads in a way that is not compatible with
376
+    // 'text/javascript' response type.
377
+    $GLOBALS['devel_shutdown'] =  FALSE;
378
+    print drupal_to_js(array('status' => TRUE, 'data' => $output));
379
+    exit;
380 380
 }
Please login to merge, or discard this patch.
Switch Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -151,23 +151,23 @@
 block discarded – undo
151 151
   $field_name = $field['field_name'];
152 152
 
153 153
   switch ($field['multiple']) {
154
-    case 0:
155
-      $max = 0;
156
-      break;
157
-    case 1:
158
-      $filled_items = content_set_empty($field, $items);
159
-      $current_item_count = isset($form_state['item_count'][$field_name])
160
-                            ? $form_state['item_count'][$field_name]
161
-                            : count($items);
162
-      // We always want at least one empty icon for the user to fill in.
163
-      $max = ($current_item_count > count($filled_items))
164
-              ? $current_item_count - 1
165
-              : $current_item_count;
166
-
167
-      break;
168
-    default:
169
-      $max = $field['multiple'] - 1;
170
-      break;
154
+  case 0:
155
+    $max = 0;
156
+    break;
157
+  case 1:
158
+    $filled_items = content_set_empty($field, $items);
159
+    $current_item_count = isset($form_state['item_count'][$field_name])
160
+                          ? $form_state['item_count'][$field_name]
161
+                          : count($items);
162
+    // We always want at least one empty icon for the user to fill in.
163
+    $max = ($current_item_count > count($filled_items))
164
+            ? $current_item_count - 1
165
+            : $current_item_count;
166
+
167
+    break;
168
+  default:
169
+    $max = $field['multiple'] - 1;
170
+    break;
171 171
   }
172 172
 
173 173
   $title = check_plain(t($field['widget']['label']));
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
   $type = content_types($form['type']['#value']);
13 13
   foreach ($type['fields'] as $field_name => $field) {
14 14
     $form['#field_info'][$field['field_name']] = $field;
15
-    $form += (array) content_field_form($form, $form_state, $field);
15
+    $form += (array)content_field_form($form, $form_state, $field);
16 16
   }
17 17
   return $form;
18 18
 }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
   // TODO: is the "if (function_exists($function)) {" needed ?
48 48
   // defining the $function here makes it unclear where it is actually called
49
-  $function = $field['widget']['module'] .'_widget';
49
+  $function = $field['widget']['module'].'_widget';
50 50
   if (function_exists($function)) {
51 51
     // Prepare the values to be filled in the widget.
52 52
     // We look in the following places:
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     if (!empty($form_state['values'][$field['field_name']])) {
58 58
       $items = $form_state['values'][$field['field_name']];
59 59
       // If there was an AHAH add more button in this field, don't save it.
60
-      unset($items[$field['field_name'] .'_add_more']);
60
+      unset($items[$field['field_name'].'_add_more']);
61 61
     }
62 62
     elseif (!empty($node->$field['field_name'])) {
63 63
       $items = $node->$field['field_name'];
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         // it should provide a hook_default_value() function to call,
69 69
         // otherwise the content module's content_default_value() function
70 70
         // will be used.
71
-        $callback = content_callback('widget', 'default value', $field) == CONTENT_CALLBACK_CUSTOM ? $field['widget']['module'] .'_default_value' : 'content_default_value';
71
+        $callback = content_callback('widget', 'default value', $field) == CONTENT_CALLBACK_CUSTOM ? $field['widget']['module'].'_default_value' : 'content_default_value';
72 72
         if (function_exists($callback)) {
73 73
           $items = $callback($form, $form_state, $field, 0);
74 74
         }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     '#required' => $field['required'],
180 180
     '#description' => $description,
181 181
   );
182
-  $function = $field['widget']['module'] .'_widget';
182
+  $function = $field['widget']['module'].'_widget';
183 183
 
184 184
   for ($delta = 0; $delta <= $max; $delta++) {
185 185
     if ($element = $function($form, $form_state, $field, $items, $delta)) {
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
     $content_type = content_types($field['type_name']);
219 219
     $field_name_css = str_replace('_', '-', $field_name);
220 220
 
221
-    $form_element[$field_name .'_add_more'] = array(
221
+    $form_element[$field_name.'_add_more'] = array(
222 222
       '#type' => 'submit',
223
-      '#name' => $field_name .'_add_more',
223
+      '#name' => $field_name.'_add_more',
224 224
       '#value' => t('Add another item'),
225 225
       '#weight' => $field['widget']['weight'] + $max + 1,
226 226
       // Submit callback for disabled JavaScript. drupal_get_form() might get
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
       // including this file. Therefore, call a proxy function to do this.
229 229
       '#submit' => array('content_add_more_submit_proxy'),
230 230
       '#ahah' => array(
231
-        'path' => 'content/js_add_more/'. $content_type['url_str'] .'/'. $field_name,
232
-        'wrapper' => $field_name_css .'-items',
231
+        'path' => 'content/js_add_more/'.$content_type['url_str'].'/'.$field_name,
232
+        'wrapper' => $field_name_css.'-items',
233 233
         'method' => 'replace',
234 234
         'effect' => 'fade',
235 235
       ),
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
     );
241 241
 
242 242
     // Add wrappers for the fields and 'more' button.
243
-    $form_element['#prefix'] = '<div id="'. $field_name_css .'-items">';
243
+    $form_element['#prefix'] = '<div id="'.$field_name_css.'-items">';
244 244
     $form_element['#suffix'] = '</div>';
245
-    $form_element[$field_name .'_add_more']['#prefix'] = '<div class="content-add-more clear-block">';
246
-    $form_element[$field_name .'_add_more']['#suffix'] = '</div>';
245
+    $form_element[$field_name.'_add_more']['#prefix'] = '<div class="content-add-more clear-block">';
246
+    $form_element[$field_name.'_add_more']['#suffix'] = '</div>';
247 247
   }
248 248
   return $form_element;
249 249
 }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
   $type_name = $form_state['clicked_button']['#type_name'];
261 261
 
262 262
   // Make the changes we want to the form state.
263
-  if ($form_state['values'][$field_name][$field_name .'_add_more']) {
263
+  if ($form_state['values'][$field_name][$field_name.'_add_more']) {
264 264
     $form_state['item_count'][$field_name] = count($form_state['values'][$field_name]);
265 265
   }
266 266
 }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
   // Sort the $form_state['values'] we just built *and* the incoming $_POST data
312 312
   // according to d-n-d reordering.
313
-  unset($form_state['values'][$field_name][$field['field_name'] .'_add_more']);
313
+  unset($form_state['values'][$field_name][$field['field_name'].'_add_more']);
314 314
   foreach ($_POST[$field_name] as $delta => $item) {
315 315
     $form_state['values'][$field_name][$delta]['_weight'] = $item['_weight'];
316 316
   }
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
   // Render the new output.
357 357
   $field_form = (!empty($group_name)) ? $form[$group_name][$field_name] : $form[$field_name];
358 358
   // We add a div around the new content to receive the ahah effect.
359
-  $field_form[$delta]['#prefix'] = '<div class="ahah-new-content">'. (isset($field_form[$delta]['#prefix']) ? $field_form[$delta]['#prefix'] : '');
360
-  $field_form[$delta]['#suffix'] = (isset($field_form[$delta]['#suffix']) ? $field_form[$delta]['#suffix'] : '') .'</div>';
359
+  $field_form[$delta]['#prefix'] = '<div class="ahah-new-content">'.(isset($field_form[$delta]['#prefix']) ? $field_form[$delta]['#prefix'] : '');
360
+  $field_form[$delta]['#suffix'] = (isset($field_form[$delta]['#suffix']) ? $field_form[$delta]['#suffix'] : '').'</div>';
361 361
   // Prevent duplicate wrapper.
362 362
   unset($field_form['#prefix'], $field_form['#suffix']);
363 363
 
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
   // The new ones didn't exist then, so we need to update Drupal.settings
368 368
   // by ourselves in order to let AHAH know about those new form elements.
369 369
   $javascript = drupal_add_js(NULL, NULL);
370
-  $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
370
+  $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '.drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])).');</script>' : '';
371 371
 
372
-  $output = theme('status_messages') . drupal_render($field_form) . $output_js;
372
+  $output = theme('status_messages').drupal_render($field_form).$output_js;
373 373
 
374 374
   // Using drupal_json() breaks filefield's file upload, because the jQuery
375 375
   // Form plugin handles file uploads in a way that is not compatible with
376 376
   // 'text/javascript' response type.
377
-  $GLOBALS['devel_shutdown'] =  FALSE;
377
+  $GLOBALS['devel_shutdown'] = FALSE;
378 378
   print drupal_to_js(array('status' => TRUE, 'data' => $output));
379 379
   exit;
380 380
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,11 +58,9 @@  discard block
 block discarded – undo
58 58
       $items = $form_state['values'][$field['field_name']];
59 59
       // If there was an AHAH add more button in this field, don't save it.
60 60
       unset($items[$field['field_name'] .'_add_more']);
61
-    }
62
-    elseif (!empty($node->$field['field_name'])) {
61
+    } elseif (!empty($node->$field['field_name'])) {
63 62
       $items = $node->$field['field_name'];
64
-    }
65
-    elseif (empty($node->nid)) {
63
+    } elseif (empty($node->nid)) {
66 64
       if (content_callback('widget', 'default value', $field) != CONTENT_CALLBACK_NONE) {
67 65
         // If a module wants to insert custom default values here,
68 66
         // it should provide a hook_default_value() function to call,
@@ -115,8 +113,7 @@  discard block
 block discarded – undo
115 113
         // about how the field is structured, just merge in the returned value.
116 114
         if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
117 115
           $form_element[$delta] = array_merge($element, $defaults);
118
-        }
119
-        else {
116
+        } else {
120 117
           $form_element = array_merge($element, $defaults);
121 118
         }
122 119
       }
@@ -333,8 +330,7 @@  discard block
 block discarded – undo
333 330
   // Add the new element at the right place in the (original, unbuilt) form.
334 331
   if (module_exists('fieldgroup') && ($group_name = _fieldgroup_field_get_group($type['type'], $field_name))) {
335 332
     $form[$group_name][$field_name] = $form_element[$field_name];
336
-  }
337
-  else {
333
+  } else {
338 334
     $form[$field_name] = $form_element[$field_name];
339 335
   }
340 336
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
  *   use to get only a specific delta value of a multiple value field, otherwise
36 36
  *   function will return the entire $field form element.
37 37
  */
38
-function content_field_form(&$form, &$form_state, $field, $get_delta = NULL) {
39
-  $form['#cache'] = FALSE;
38
+function content_field_form(&$form, &$form_state, $field, $get_delta = null) {
39
+  $form['#cache'] = false;
40 40
   $node = $form['#node'];
41 41
   $addition = array();
42 42
   $form_element = array();
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
     // See if access to this form element is restricted,
79 79
     // if so, skip widget processing and just set the value.
80
-    $access = content_access('edit', $field, NULL, $node);
80
+    $access = content_access('edit', $field, null, $node);
81 81
     if (!$access) {
82 82
       $addition[$field_name] = array(
83 83
         '#access' => $access,
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $title = check_plain(t($field['widget']['label']));
102 102
         $description = content_filter_xss(t($field['widget']['description']));
103 103
         $defaults = array(
104
-          '#required' => $get_delta > 0 ? FALSE : $field['required'],
104
+          '#required' => $get_delta > 0 ? false : $field['required'],
105 105
           '#columns'  => array_keys($field['columns']),
106 106
           '#title' => $title,
107 107
           '#description' => $description,
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     if ($form_element) {
128 128
       $defaults = array(
129 129
         '#field_name' => $field['field_name'],
130
-        '#tree' => TRUE,
130
+        '#tree' => true,
131 131
         '#weight' => $field['widget']['weight'],
132 132
         '#access' => $access,
133 133
         // TODO: what's the need for #count ? does not seem to be used anywhere ?
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
   // Add AHAH add more button, if not working with a programmed form.
215 215
   if ($field['multiple'] == 1 && empty($form['#programmed'])) {
216 216
     // Make sure the form is cached so ahah can work.
217
-    $form['#cache'] = TRUE;
217
+    $form['#cache'] = true;
218 218
     $content_type = content_types($field['type_name']);
219 219
     $field_name_css = str_replace('_', '-', $field_name);
220 220
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
   }
280 280
 
281 281
   // Retrieve the cached form.
282
-  $form_state = array('submitted' => FALSE);
282
+  $form_state = array('submitted' => false);
283 283
   $form_build_id = $_POST['form_build_id'];
284 284
   $form = form_get_cache($form_build_id, $form_state);
285 285
   if (!$form) {
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
   // Just grab the data we need.
307 307
   $form_state['values'] = $form_state_copy['values'];
308 308
   // Reset cached ids, so that they don't affect the actual form we output.
309
-  form_clean_id(NULL, TRUE);
309
+  form_clean_id(null, true);
310 310
 
311 311
   // Sort the $form_state['values'] we just built *and* the incoming $_POST data
312 312
   // according to d-n-d reordering.
@@ -346,10 +346,10 @@  discard block
 block discarded – undo
346 346
   // render the new element.
347 347
   $delta = max(array_keys($_POST[$field_name])) + 1;
348 348
   $_POST[$field_name][$delta]['_weight'] = $delta;
349
-  $form_state = array('submitted' => FALSE);
349
+  $form_state = array('submitted' => false);
350 350
   $form += array(
351 351
     '#post' => $_POST,
352
-    '#programmed' => FALSE,
352
+    '#programmed' => false,
353 353
   );
354 354
   $form = form_builder($_POST['form_id'], $form, $form_state);
355 355
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
   // form elements that were initially specified in the Drupal.settings object.
367 367
   // The new ones didn't exist then, so we need to update Drupal.settings
368 368
   // by ourselves in order to let AHAH know about those new form elements.
369
-  $javascript = drupal_add_js(NULL, NULL);
369
+  $javascript = drupal_add_js(null, null);
370 370
   $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
371 371
 
372 372
   $output = theme('status_messages') . drupal_render($field_form) . $output_js;
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
   // Using drupal_json() breaks filefield's file upload, because the jQuery
375 375
   // Form plugin handles file uploads in a way that is not compatible with
376 376
   // 'text/javascript' response type.
377
-  $GLOBALS['devel_shutdown'] =  FALSE;
378
-  print drupal_to_js(array('status' => TRUE, 'data' => $output));
377
+  $GLOBALS['devel_shutdown'] =  false;
378
+  print drupal_to_js(array('status' => true, 'data' => $output));
379 379
   exit;
380 380
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/cck/includes/content.rules.inc 5 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -289,6 +289,7 @@
 block discarded – undo
289 289
 /**
290 290
  * Returns the fields of a given field type only.
291 291
  * Suitable for using it with #options.
292
+ * @param string $type
292 293
  */
293 294
 function content_rules_get_field_names_by_type($type = NULL) {
294 295
   $fields = array();
Please login to merge, or discard this patch.
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -10,34 +10,34 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_rules_action_info().
11 11
  */
12 12
 function content_rules_action_info() {
13
-  $info = array();
14
-  $info['content_rules_action_populate_field'] = array(
13
+    $info = array();
14
+    $info['content_rules_action_populate_field'] = array(
15 15
     'label' => t('Populate a field'),
16 16
     'arguments' => array(
17
-      'node' => array(
17
+        'node' => array(
18 18
         'type' => 'node',
19 19
         'label' => t('Content'),
20
-      ),
20
+        ),
21 21
     ),
22 22
     'eval input' => array('code'),
23 23
     'help' => t('You should make sure that the used field exists in the given content type.'),
24 24
     'module' => 'CCK',
25
-  );
26
-  return $info;
25
+    );
26
+    return $info;
27 27
 }
28 28
 
29 29
 /**
30 30
  * Action: populate a field.
31 31
  */
32 32
 function content_rules_action_populate_field($node, $settings, $element, &$state) {
33
-  // Get information about the field.
34
-  $field = content_fields($settings['field_name'], $node->type);
35
-  $value = _content_rules_get_field_value($settings, $state);
33
+    // Get information about the field.
34
+    $field = content_fields($settings['field_name'], $node->type);
35
+    $value = _content_rules_get_field_value($settings, $state);
36 36
 
37
-  if (!empty($field) && is_array($value)) {
37
+    if (!empty($field) && is_array($value)) {
38 38
     $node->$settings['field_name'] = $value;
39 39
     return array('node' => $node);
40
-  }
40
+    }
41 41
 }
42 42
 
43 43
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
  * This is a multistep form!
47 47
  */
48 48
 function content_rules_action_populate_field_form($settings, &$form, &$form_state) {
49
-  $settings += array('field_name' => '', 'code' => '', 'value' => NULL);
50
-  if (empty($settings['field_name'])) {
49
+    $settings += array('field_name' => '', 'code' => '', 'value' => NULL);
50
+    if (empty($settings['field_name'])) {
51 51
     $form['settings']['field_name'] = array(
52
-      '#type' => 'select',
53
-      '#title' => t('Field'),
54
-      '#options' => content_rules_get_field_names_by_type(),
55
-      '#default_value' => $settings['field_name'],
56
-      '#description' => t('Select the machine-name of the field.'),
57
-      '#required' => TRUE,
52
+        '#type' => 'select',
53
+        '#title' => t('Field'),
54
+        '#options' => content_rules_get_field_names_by_type(),
55
+        '#default_value' => $settings['field_name'],
56
+        '#description' => t('Select the machine-name of the field.'),
57
+        '#required' => TRUE,
58 58
     );
59 59
     // Hide some form elements in the first step.
60 60
     $form['negate']['#access'] = FALSE;
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
     // Replace the usual submit handlers with a own handler.
65 65
     $form['submit']['#submit'] = array('content_rules_action_populate_field_form_step_submit');
66 66
     $form['submit']['#value'] = t('Continue');
67
-  }
68
-  else {
67
+    }
68
+    else {
69 69
     // Show the fields form here.
70 70
     module_load_include('inc', 'content', 'includes/content.node_form');
71 71
     $field = content_fields($settings['field_name']);
@@ -78,111 +78,111 @@  discard block
 block discarded – undo
78 78
 
79 79
     unset($form['#cache']);
80 80
 
81
-      // Advanced: PHP code.
81
+        // Advanced: PHP code.
82 82
     $form['advanced_options'] = array(
83
-      '#type' => 'fieldset',
84
-      '#title' => t('Advanced: Specify the fields value with PHP code'),
85
-      '#collapsible' => TRUE,
86
-      '#collapsed' => empty($settings['code']),
87
-      '#weight' => 5,
83
+        '#type' => 'fieldset',
84
+        '#title' => t('Advanced: Specify the fields value with PHP code'),
85
+        '#collapsible' => TRUE,
86
+        '#collapsed' => empty($settings['code']),
87
+        '#weight' => 5,
88 88
     );
89 89
 
90 90
     $db_info = content_database_info($field);
91 91
     $columns = array_keys($db_info['columns']);
92 92
     foreach ($columns as $key => $column) {
93
-      $columns[$key] = t("'@column' => value for @column", array('@column' => $column));
93
+        $columns[$key] = t("'@column' => value for @column", array('@column' => $column));
94 94
     }
95 95
     $sample = t("return array(\n  0 => array(@columns),\n  // You'll usually want to stop here. Provide more values\n  // if you want your 'default value' to be multi-valued:\n  1 => array(@columns),\n  2 => ...\n);", array('@columns' => implode(', ', $columns)));
96 96
 
97 97
     $form['advanced_options']['code'] = array(
98
-      '#type' => 'textarea',
99
-      '#title' => t('Code'),
100
-      '#default_value' => $settings['code'],
101
-      '#rows' => 6,
102
-      '#description' => t('Advanced usage only: PHP code that returns the value to set. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the value returned by this code will override any value specified above. Expected format: <pre>!sample</pre>Using <a href="@link_devel">devel.module\'s</a> \'devel load\' tab on a content page might help you figure out the expected format.', array(
98
+        '#type' => 'textarea',
99
+        '#title' => t('Code'),
100
+        '#default_value' => $settings['code'],
101
+        '#rows' => 6,
102
+        '#description' => t('Advanced usage only: PHP code that returns the value to set. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the value returned by this code will override any value specified above. Expected format: <pre>!sample</pre>Using <a href="@link_devel">devel.module\'s</a> \'devel load\' tab on a content page might help you figure out the expected format.', array(
103 103
         '!sample' => $sample,
104 104
         '@link_devel' => 'http://www.drupal.org/project/devel',
105
-      )),
105
+        )),
106 106
     );
107 107
 
108 108
     // Add this file to be included when the form is built by rules
109 109
     // as it's needed by CCKs add more button.
110 110
     // See rules_after_build_include_files().
111 111
     $form['#includes'][] = './'. drupal_get_path('module', 'node') .'/node.pages.inc';
112
-  }
112
+    }
113 113
 }
114 114
 
115 115
 function content_rules_action_populate_field_form_step_submit($form, &$form_state) {
116
-  $form_state['element']['#settings']['field_name'] = $form_state['values']['settings']['field_name'];
116
+    $form_state['element']['#settings']['field_name'] = $form_state['values']['settings']['field_name'];
117 117
 }
118 118
 
119 119
 /**
120 120
  * Validate the chosen value or php code.
121 121
  */
122 122
 function content_rules_action_populate_field_validate($form, &$form_state) {
123
-  if (!isset($form_state['element']['#settings']['field_name'])) {
123
+    if (!isset($form_state['element']['#settings']['field_name'])) {
124 124
     //Just validate the last step.
125 125
     return;
126
-  }
126
+    }
127 127
 
128
-  if (isset($form_state['values']['code']) && ($php = $form_state['values']['code'])) {
128
+    if (isset($form_state['values']['code']) && ($php = $form_state['values']['code'])) {
129 129
     if (strpos($php, 'return') === FALSE) {
130
-      form_set_error('code', t('You have to return the default value in the expected format.'));
130
+        form_set_error('code', t('You have to return the default value in the expected format.'));
131 131
     }
132
-  }
133
-  else {
132
+    }
133
+    else {
134 134
     // Validate the field.
135 135
     $settings = $form_state['element']['#settings'];
136 136
     $field = content_fields($settings['field_name']);
137 137
     $field_types = _content_field_types();
138 138
     $function = $field_types[$field['type']]['module'] .'_field';
139 139
     if (function_exists($function)) {
140
-      $form['#node'] = (object)array('type' => '', $settings['field_name'] => $form_state['values'][$settings['field_name']]);
141
-      $items = isset($form['#node']->$field['field_name']) ? $form['#node']->$field['field_name'] : array();
140
+        $form['#node'] = (object)array('type' => '', $settings['field_name'] => $form_state['values'][$settings['field_name']]);
141
+        $items = isset($form['#node']->$field['field_name']) ? $form['#node']->$field['field_name'] : array();
142 142
 
143
-      //Make sure AHAH 'add more' button isn't sent to the fields
144
-      // for processing.
145
-      unset($items[$field['field_name'] .'_add_more']);
143
+        //Make sure AHAH 'add more' button isn't sent to the fields
144
+        // for processing.
145
+        unset($items[$field['field_name'] .'_add_more']);
146 146
 
147
-      $function('validate', $form['#node'], $field, $items, $form, NULL);
148
-      content_field('validate', $form['#node'], $field, $items, $form, NULL);
147
+        $function('validate', $form['#node'], $field, $items, $form, NULL);
148
+        content_field('validate', $form['#node'], $field, $items, $form, NULL);
149
+    }
149 150
     }
150
-  }
151 151
 }
152 152
 
153 153
 function content_rules_action_populate_field_submit(&$settings, $form, &$form_state) {
154
-  // Take over field values and filter out private properties added by CCK
155
-  $settings['value'] = array_filter($form_state['values'][$settings['field_name']], 'is_array');
154
+    // Take over field values and filter out private properties added by CCK
155
+    $settings['value'] = array_filter($form_state['values'][$settings['field_name']], 'is_array');
156 156
 
157
-  foreach ($settings['value'] as $key => $data) {
157
+    foreach ($settings['value'] as $key => $data) {
158 158
     foreach (array_filter(array_keys($data)) as $col) {
159
-      if ($col[0] == '_') {
159
+        if ($col[0] == '_') {
160 160
         unset($settings['value'][$key][$col]);
161
-      }
161
+        }
162 162
     }
163 163
     if ($key && count(array_filter($settings['value'][$key])) == 0) {
164
-      // For multi-valued fields don't check for any additional empty values.
165
-      unset($settings['value'][$key]);
164
+        // For multi-valued fields don't check for any additional empty values.
165
+        unset($settings['value'][$key]);
166
+    }
166 167
     }
167
-  }
168 168
 
169
-  $settings['code'] = $form_state['values']['code'];
169
+    $settings['code'] = $form_state['values']['code'];
170 170
 
171
-  if (function_exists('rules_action_custom_php_submit')) {
171
+    if (function_exists('rules_action_custom_php_submit')) {
172 172
     // Support adding variables to the php code, if php module is present.
173 173
     rules_action_custom_php_submit($settings, $form, $form_state);
174
-  }
174
+    }
175 175
 
176
-  // Add all values to the input evaluator, so that textfields / textares can
177
-  // make use of it.
178
-  $names = array('code');
176
+    // Add all values to the input evaluator, so that textfields / textares can
177
+    // make use of it.
178
+    $names = array('code');
179 179
 
180
-  foreach ($settings['value'] as $key => $data) {
180
+    foreach ($settings['value'] as $key => $data) {
181 181
     foreach (array_filter($data, 'is_string') as $col => $value) {
182
-      $names[] = "value|$key|$col";
182
+        $names[] = "value|$key|$col";
183
+    }
183 184
     }
184
-  }
185
-  $form_state['element']['#info']['eval input'] = $names;
185
+    $form_state['element']['#info']['eval input'] = $names;
186 186
 }
187 187
 
188 188
 
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
  * Label callback: Improve the label of the action.
191 191
  */
192 192
 function content_rules_action_populate_field_label($settings, $argument_labels) {
193
-  return t("Populate @node's field '@field'", array('@field' => $settings['field_name']) + $argument_labels);
193
+    return t("Populate @node's field '@field'", array('@field' => $settings['field_name']) + $argument_labels);
194 194
 }
195 195
 
196 196
 function workflow_ng_action_populate_field_upgrade(&$element) {
197
-  $element['#name'] = 'content_rules_action_populate_field';
198
-  $element['#settings']['code'] = $element['#settings']['default_value_php'];
199
-  $element['#settings'][$element['#settings']['field_name']] = array();
200
-  unset($element['#settings']['default_value_php']);
197
+    $element['#name'] = 'content_rules_action_populate_field';
198
+    $element['#settings']['code'] = $element['#settings']['default_value_php'];
199
+    $element['#settings'][$element['#settings']['field_name']] = array();
200
+    unset($element['#settings']['default_value_php']);
201 201
 }
202 202
 
203 203
 
@@ -205,84 +205,84 @@  discard block
 block discarded – undo
205 205
  * Implementation of hook_rules_condition_info().
206 206
  */
207 207
 function content_rules_condition_info() {
208
-  $info = array();
209
-  $info['content_rules_field_has_value'] = array(
208
+    $info = array();
209
+    $info['content_rules_field_has_value'] = array(
210 210
     'label' => t('Field has value'),
211 211
     'arguments' => array(
212
-      'node' => array('type' => 'node', 'label' => t('Content')),
212
+        'node' => array('type' => 'node', 'label' => t('Content')),
213 213
     ),
214 214
     'eval input' => array('code'),
215 215
     'help' => t('You should make sure that the used field exists in the given content type. The condition returns TRUE, if the selected field has the given value.'),
216 216
     'module' => 'CCK',
217
-  );
218
-  $info['content_rules_field_changed'] = array(
217
+    );
218
+    $info['content_rules_field_changed'] = array(
219 219
     'label' => t('Field has changed'),
220 220
     'arguments' => array(
221
-      'node' => array('type' => 'node', 'label' => t('Content containing changes')),
222
-      'node_unchanged' => array('type' => 'node', 'label' => t('Content not containing changes')),
221
+        'node' => array('type' => 'node', 'label' => t('Content containing changes')),
222
+        'node_unchanged' => array('type' => 'node', 'label' => t('Content not containing changes')),
223 223
     ),
224 224
     'help' => t('You should make sure that the used field exists in the given content type.'),
225 225
     'module' => 'CCK',
226
-  );
227
-  return $info;
226
+    );
227
+    return $info;
228 228
 }
229 229
 
230 230
 /**
231 231
  * Condition: Check the value of a field.
232 232
  */
233 233
 function content_rules_field_has_value($node, $settings) {
234
-  // Get information about the field.
235
-  $field = content_fields($settings['field_name'], $node->type);
236
-  $value = _content_rules_get_field_value($settings, $state);
234
+    // Get information about the field.
235
+    $field = content_fields($settings['field_name'], $node->type);
236
+    $value = _content_rules_get_field_value($settings, $state);
237 237
 
238
-  if (empty($field) || !is_array($value)) {
238
+    if (empty($field) || !is_array($value)) {
239 239
     return FALSE;
240
-  }
240
+    }
241 241
 
242
-  return _content_rules_field_has_value($node->$settings['field_name'], $value);
242
+    return _content_rules_field_has_value($node->$settings['field_name'], $value);
243 243
 }
244 244
 
245 245
 /**
246 246
  * Use the same configuration form as the "populate field" action.
247 247
  */
248 248
 function content_rules_field_has_value_form($settings, &$form, &$form_state) {
249
-  content_rules_action_populate_field_form($settings, $form, $form_state);
249
+    content_rules_action_populate_field_form($settings, $form, $form_state);
250 250
 }
251 251
 function content_rules_field_has_value_validate($form, &$form_state) {
252
-  content_rules_action_populate_field_validate($form, $form_state);
252
+    content_rules_action_populate_field_validate($form, $form_state);
253 253
 }
254 254
 function content_rules_field_has_value_submit(&$settings, $form, &$form_state) {
255
-  content_rules_action_populate_field_submit($settings, $form, $form_state);
255
+    content_rules_action_populate_field_submit($settings, $form, $form_state);
256 256
 }
257 257
 
258 258
 function content_rules_field_has_value_label($settings, $argument_labels) {
259
-  return t("@node's field '@field' has value", array('@field' => $settings['field_name']) + $argument_labels);
259
+    return t("@node's field '@field' has value", array('@field' => $settings['field_name']) + $argument_labels);
260 260
 }
261 261
 
262 262
 /**
263 263
  * Condition: Check if the field has changed.
264 264
  */
265 265
 function content_rules_field_changed($node1, $node2, $settings) {
266
-  // Get information about the field.
267
-  $field = content_fields($settings['field_name'], $node1->type);
266
+    // Get information about the field.
267
+    $field = content_fields($settings['field_name'], $node1->type);
268 268
 
269
-  return !empty($field) && !_content_rules_field_has_value($node1->$settings['field_name'], $node2->$settings['field_name']);
269
+    return !empty($field) && !_content_rules_field_has_value($node1->$settings['field_name'], $node2->$settings['field_name']);
270 270
 }
271 271
 
272 272
 function content_rules_field_changed_form($settings, &$form, &$form_state) {
273
-  $settings += array('field_name' => '');
274
-  $form['settings']['field_name'] = array(
273
+    $settings += array('field_name' => '');
274
+    $form['settings']['field_name'] = array(
275 275
     '#type' => 'select',
276 276
     '#title' => t('Field'),
277 277
     '#options' => content_rules_get_field_names_by_type(),
278 278
     '#default_value' => $settings['field_name'],
279 279
     '#description' => t('Select the machine-name of the field to look at.'),
280 280
     '#required' => TRUE,
281
-  );
281
+    );
282 282
 }
283 283
 
284 284
 function content_rules_field_changed_label($settings, $argument_labels) {
285
-  return t("@node's field '@field' has been changed", array('@field' => $settings['field_name']) + $argument_labels);
285
+    return t("@node's field '@field' has been changed", array('@field' => $settings['field_name']) + $argument_labels);
286 286
 }
287 287
 
288 288
 
@@ -291,32 +291,32 @@  discard block
 block discarded – undo
291 291
  * Suitable for using it with #options.
292 292
  */
293 293
 function content_rules_get_field_names_by_type($type = NULL) {
294
-  $fields = array();
295
-  foreach (content_fields() as $field) {
294
+    $fields = array();
295
+    foreach (content_fields() as $field) {
296 296
     if (!isset($type) || $field['type'] == $type) {
297
-      $fields[$field['field_name']] = $field['field_name'];
297
+        $fields[$field['field_name']] = $field['field_name'];
298
+    }
298 299
     }
299
-  }
300
-  asort($fields);
301
-  return $fields;
300
+    asort($fields);
301
+    return $fields;
302 302
 }
303 303
 
304 304
 function _content_rules_get_field_value($settings, &$state) {
305
-  if ($settings['code']) {
305
+    if ($settings['code']) {
306 306
     if (function_exists('rules_input_evaluator_php_apply')) {
307
-      // Support adding variables to the php code, if php module is present.
308
-      $value = rules_input_evaluator_php_apply($settings['code'], $settings['vars'], $state, FALSE);
307
+        // Support adding variables to the php code, if php module is present.
308
+        $value = rules_input_evaluator_php_apply($settings['code'], $settings['vars'], $state, FALSE);
309 309
     }
310 310
     else {
311
-      ob_start();
312
-      $value = eval($settings['code']);
313
-      ob_end_clean();
311
+        ob_start();
312
+        $value = eval($settings['code']);
313
+        ob_end_clean();
314 314
     }
315
-  }
316
-  else {
315
+    }
316
+    else {
317 317
     $value = $settings['value'];
318
-  }
319
-  return $value;
318
+    }
319
+    return $value;
320 320
 }
321 321
 
322 322
 /**
@@ -329,20 +329,20 @@  discard block
 block discarded – undo
329 329
  * @param $value The value to check for.
330 330
  */
331 331
 function _content_rules_field_has_value($node_value, $value) {
332
-  if (count($value) != count($node_value)) {
332
+    if (count($value) != count($node_value)) {
333 333
     return FALSE;
334
-  }
335
-  // Loop over multiple fields
336
-  foreach ($value as $delta => $sub_value) {
334
+    }
335
+    // Loop over multiple fields
336
+    foreach ($value as $delta => $sub_value) {
337 337
     // Check if all properties of the value are there in the node value too
338 338
     if (is_array($sub_value) && is_array($node_value[$delta])) {
339
-      if (count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
339
+        if (count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
340 340
         return FALSE;
341
-      }
341
+        }
342 342
     }
343 343
     elseif ($sub_value !== $node_value[$delta]) {
344
-      return FALSE;
344
+        return FALSE;
345
+    }
345 346
     }
346
-  }
347
-  return TRUE;
347
+    return TRUE;
348 348
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
     $form['#node'] = (object)array('type' => '', $settings['field_name'] => $settings['value']);
74 74
     $form['#field_info'][$field['field_name']] = $field;
75 75
     // We can't put it into $form['settings'] as this would break AHAH callbacks
76
-    $form += (array) content_field_form($form, $form_state, $field);
77
-    $form[ $settings['field_name'] ]['#weight'] = 4;
76
+    $form += (array)content_field_form($form, $form_state, $field);
77
+    $form[$settings['field_name']]['#weight'] = 4;
78 78
 
79 79
     unset($form['#cache']);
80 80
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     // Add this file to be included when the form is built by rules
109 109
     // as it's needed by CCKs add more button.
110 110
     // See rules_after_build_include_files().
111
-    $form['#includes'][] = './'. drupal_get_path('module', 'node') .'/node.pages.inc';
111
+    $form['#includes'][] = './'.drupal_get_path('module', 'node').'/node.pages.inc';
112 112
   }
113 113
 }
114 114
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
     $settings = $form_state['element']['#settings'];
136 136
     $field = content_fields($settings['field_name']);
137 137
     $field_types = _content_field_types();
138
-    $function = $field_types[$field['type']]['module'] .'_field';
138
+    $function = $field_types[$field['type']]['module'].'_field';
139 139
     if (function_exists($function)) {
140 140
       $form['#node'] = (object)array('type' => '', $settings['field_name'] => $form_state['values'][$settings['field_name']]);
141 141
       $items = isset($form['#node']->$field['field_name']) ? $form['#node']->$field['field_name'] : array();
142 142
 
143 143
       //Make sure AHAH 'add more' button isn't sent to the fields
144 144
       // for processing.
145
-      unset($items[$field['field_name'] .'_add_more']);
145
+      unset($items[$field['field_name'].'_add_more']);
146 146
 
147 147
       $function('validate', $form['#node'], $field, $items, $form, NULL);
148 148
       content_field('validate', $form['#node'], $field, $items, $form, NULL);
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -64,8 +64,7 @@  discard block
 block discarded – undo
64 64
     // Replace the usual submit handlers with a own handler.
65 65
     $form['submit']['#submit'] = array('content_rules_action_populate_field_form_step_submit');
66 66
     $form['submit']['#value'] = t('Continue');
67
-  }
68
-  else {
67
+  } else {
69 68
     // Show the fields form here.
70 69
     module_load_include('inc', 'content', 'includes/content.node_form');
71 70
     $field = content_fields($settings['field_name']);
@@ -129,8 +128,7 @@  discard block
 block discarded – undo
129 128
     if (strpos($php, 'return') === FALSE) {
130 129
       form_set_error('code', t('You have to return the default value in the expected format.'));
131 130
     }
132
-  }
133
-  else {
131
+  } else {
134 132
     // Validate the field.
135 133
     $settings = $form_state['element']['#settings'];
136 134
     $field = content_fields($settings['field_name']);
@@ -306,14 +304,12 @@  discard block
 block discarded – undo
306 304
     if (function_exists('rules_input_evaluator_php_apply')) {
307 305
       // Support adding variables to the php code, if php module is present.
308 306
       $value = rules_input_evaluator_php_apply($settings['code'], $settings['vars'], $state, FALSE);
309
-    }
310
-    else {
307
+    } else {
311 308
       ob_start();
312 309
       $value = eval($settings['code']);
313 310
       ob_end_clean();
314 311
     }
315
-  }
316
-  else {
312
+  } else {
317 313
     $value = $settings['value'];
318 314
   }
319 315
   return $value;
@@ -339,8 +335,7 @@  discard block
 block discarded – undo
339 335
       if (count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
340 336
         return FALSE;
341 337
       }
342
-    }
343
-    elseif ($sub_value !== $node_value[$delta]) {
338
+    } elseif ($sub_value !== $node_value[$delta]) {
344 339
       return FALSE;
345 340
     }
346 341
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  * This is a multistep form!
47 47
  */
48 48
 function content_rules_action_populate_field_form($settings, &$form, &$form_state) {
49
-  $settings += array('field_name' => '', 'code' => '', 'value' => NULL);
49
+  $settings += array('field_name' => '', 'code' => '', 'value' => null);
50 50
   if (empty($settings['field_name'])) {
51 51
     $form['settings']['field_name'] = array(
52 52
       '#type' => 'select',
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
       '#options' => content_rules_get_field_names_by_type(),
55 55
       '#default_value' => $settings['field_name'],
56 56
       '#description' => t('Select the machine-name of the field.'),
57
-      '#required' => TRUE,
57
+      '#required' => true,
58 58
     );
59 59
     // Hide some form elements in the first step.
60
-    $form['negate']['#access'] = FALSE;
61
-    $form['input_help']['#access'] = FALSE;
62
-    $form['weight']['#access'] = FALSE;
60
+    $form['negate']['#access'] = false;
61
+    $form['input_help']['#access'] = false;
62
+    $form['weight']['#access'] = false;
63 63
 
64 64
     // Replace the usual submit handlers with a own handler.
65 65
     $form['submit']['#submit'] = array('content_rules_action_populate_field_form_step_submit');
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     $form['advanced_options'] = array(
83 83
       '#type' => 'fieldset',
84 84
       '#title' => t('Advanced: Specify the fields value with PHP code'),
85
-      '#collapsible' => TRUE,
85
+      '#collapsible' => true,
86 86
       '#collapsed' => empty($settings['code']),
87 87
       '#weight' => 5,
88 88
     );
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
   }
127 127
 
128 128
   if (isset($form_state['values']['code']) && ($php = $form_state['values']['code'])) {
129
-    if (strpos($php, 'return') === FALSE) {
129
+    if (strpos($php, 'return') === false) {
130 130
       form_set_error('code', t('You have to return the default value in the expected format.'));
131 131
     }
132 132
   }
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
       // for processing.
145 145
       unset($items[$field['field_name'] .'_add_more']);
146 146
 
147
-      $function('validate', $form['#node'], $field, $items, $form, NULL);
148
-      content_field('validate', $form['#node'], $field, $items, $form, NULL);
147
+      $function('validate', $form['#node'], $field, $items, $form, null);
148
+      content_field('validate', $form['#node'], $field, $items, $form, null);
149 149
     }
150 150
   }
151 151
 }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
   $value = _content_rules_get_field_value($settings, $state);
237 237
 
238 238
   if (empty($field) || !is_array($value)) {
239
-    return FALSE;
239
+    return false;
240 240
   }
241 241
 
242 242
   return _content_rules_field_has_value($node->$settings['field_name'], $value);
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     '#options' => content_rules_get_field_names_by_type(),
278 278
     '#default_value' => $settings['field_name'],
279 279
     '#description' => t('Select the machine-name of the field to look at.'),
280
-    '#required' => TRUE,
280
+    '#required' => true,
281 281
   );
282 282
 }
283 283
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
  * Returns the fields of a given field type only.
291 291
  * Suitable for using it with #options.
292 292
  */
293
-function content_rules_get_field_names_by_type($type = NULL) {
293
+function content_rules_get_field_names_by_type($type = null) {
294 294
   $fields = array();
295 295
   foreach (content_fields() as $field) {
296 296
     if (!isset($type) || $field['type'] == $type) {
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
   if ($settings['code']) {
306 306
     if (function_exists('rules_input_evaluator_php_apply')) {
307 307
       // Support adding variables to the php code, if php module is present.
308
-      $value = rules_input_evaluator_php_apply($settings['code'], $settings['vars'], $state, FALSE);
308
+      $value = rules_input_evaluator_php_apply($settings['code'], $settings['vars'], $state, false);
309 309
     }
310 310
     else {
311 311
       ob_start();
@@ -330,19 +330,19 @@  discard block
 block discarded – undo
330 330
  */
331 331
 function _content_rules_field_has_value($node_value, $value) {
332 332
   if (count($value) != count($node_value)) {
333
-    return FALSE;
333
+    return false;
334 334
   }
335 335
   // Loop over multiple fields
336 336
   foreach ($value as $delta => $sub_value) {
337 337
     // Check if all properties of the value are there in the node value too
338 338
     if (is_array($sub_value) && is_array($node_value[$delta])) {
339 339
       if (count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
340
-        return FALSE;
340
+        return false;
341 341
       }
342 342
     }
343 343
     elseif ($sub_value !== $node_value[$delta]) {
344
-      return FALSE;
344
+      return false;
345 345
     }
346 346
   }
347
-  return TRUE;
347
+  return true;
348 348
 }
Please login to merge, or discard this patch.
default/boinc/modules/contrib/cck/modules/content_copy/content_copy.module 6 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -607,7 +607,7 @@
 block discarded – undo
607 607
 }
608 608
 
609 609
 /**
610
- * @return a code representation of the recorded macro.
610
+ * @return string|null code representation of the recorded macro.
611 611
  */
612 612
 function content_copy_get_macro() {
613 613
   // Define the indexes for the evaluated code.
Please login to merge, or discard this patch.
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -32,174 +32,174 @@  discard block
 block discarded – undo
32 32
  * Implementation of hook_menu().
33 33
  */
34 34
 function content_copy_menu() {
35
-  $items = array();
35
+    $items = array();
36 36
 
37
-  $items['admin/content/types/export'] = array(
37
+    $items['admin/content/types/export'] = array(
38 38
     'title' => 'Export',
39 39
     'page callback' => 'drupal_get_form',
40 40
     'page arguments' => array('content_copy_export_form'),
41 41
     'access arguments' => array('administer content types'),
42 42
     'type' => MENU_LOCAL_TASK,
43 43
     'weight' => 3,
44
-  );
45
-  $items['admin/content/types/import'] = array(
44
+    );
45
+    $items['admin/content/types/import'] = array(
46 46
     'title' => 'Import',
47 47
     'page callback' => 'drupal_get_form',
48 48
     'page arguments' => array('content_copy_import_form'),
49 49
     'access arguments' => array('administer content types'),
50 50
     'type' => MENU_LOCAL_TASK,
51 51
     'weight' => 4,
52
-  );
53
-  return $items;
52
+    );
53
+    return $items;
54 54
 }
55 55
 
56 56
 /**
57 57
  * Implementation of hook_theme().
58 58
  */
59 59
 function content_copy_theme() {
60
-  return array(
60
+    return array(
61 61
     'content_copy_export_form' => array(
62
-      'template' => 'content_copy_export_form',
63
-      'arguments' => array('form' => NULL),
62
+        'template' => 'content_copy_export_form',
63
+        'arguments' => array('form' => NULL),
64 64
     ),
65
-  );
65
+    );
66 66
 }
67 67
 
68 68
 /**
69 69
  *  A form to export field definitions.
70 70
  */
71 71
 function content_copy_export_form(&$form_state) {
72
-  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
73
-  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
72
+    include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
73
+    include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
74 74
 
75
-  $form_values = isset($form_state['values']) ? $form_state['values'] : array();
76
-  $step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] + 1 : 1;
75
+    $form_values = isset($form_state['values']) ? $form_state['values'] : array();
76
+    $step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] + 1 : 1;
77 77
 
78
-  $exportable_fields = array();
79
-  $groups = array();
78
+    $exportable_fields = array();
79
+    $groups = array();
80 80
 
81
-  $type_name = isset($form_values['type_name']) ? $form_values['type_name'] : '';
82
-  if ($type_name) {
81
+    $type_name = isset($form_values['type_name']) ? $form_values['type_name'] : '';
82
+    if ($type_name) {
83 83
     $type = content_types($type_name);
84 84
     $exportable_fields = content_copy_fields($type_name);
85 85
     if (module_exists('fieldgroup')) {
86
-      $groups = fieldgroup_groups($type_name);
86
+        $groups = fieldgroup_groups($type_name);
87
+    }
87 88
     }
88
-  }
89 89
 
90
-  // If a content type has been selected and there are no fields or groups to select,
91
-  // jump straight to export.
92
-  if ($step == 2 && !($groups) && !($exportable_fields)) {
90
+    // If a content type has been selected and there are no fields or groups to select,
91
+    // jump straight to export.
92
+    if ($step == 2 && !($groups) && !($exportable_fields)) {
93 93
     $step = 3;
94
-  }
94
+    }
95 95
 
96
-  $form['#step'] = $step;
97
-  $form['#prefix'] = t('This form will process a content type and one or more fields from that type and export the settings. The export created by this process can be copied and pasted as an import into the current or any other database. The import will add the fields to an existing content type or create a new content type that includes the selected fields.');
96
+    $form['#step'] = $step;
97
+    $form['#prefix'] = t('This form will process a content type and one or more fields from that type and export the settings. The export created by this process can be copied and pasted as an import into the current or any other database. The import will add the fields to an existing content type or create a new content type that includes the selected fields.');
98 98
 
99
-  switch ($step) {
99
+    switch ($step) {
100 100
     case 1: // Select a content type.
101 101
       $types  = content_copy_types();
102
-      $form['type_name'] = array(
102
+        $form['type_name'] = array(
103 103
         '#title' => t('Types'),
104 104
         '#type' => 'radios',
105 105
         '#options' => $types,
106 106
         '#description' => t('Select the content type to export.'),
107
-      );
108
-      break;
107
+        );
108
+        break;
109 109
 
110 110
     case 2: // Select groups and fields.
111 111
       $form['type_name'] = array(
112 112
         '#type' => 'hidden',
113 113
         '#value' => $type_name,
114
-      );
114
+        );
115 115
 
116
-      $form += array(
116
+        $form += array(
117 117
         '#fields' => $exportable_fields,
118 118
         '#groups' => array_keys($groups),
119
-      );
119
+        );
120 120
 
121
-      $fields_options = $groups_options = array();
121
+        $fields_options = $groups_options = array();
122 122
 
123
-      // Fields.
124
-      foreach ($exportable_fields as $field_name) {
123
+        // Fields.
124
+        foreach ($exportable_fields as $field_name) {
125 125
         $field = content_fields($field_name, $type_name);
126 126
         $fields_options[$field_name] = '';
127 127
         $weight = $field['widget']['weight'];
128 128
         $form[$field_name] = array(
129
-          'human_name' => array('#value' => check_plain($field['widget']['label'])),
130
-          'field_name' => array('#value' => $field['field_name']),
131
-          'type' => array('#value' => $field['type']),
132
-          'weight' => array('#type' => 'value', '#value' => $weight),
133
-          'parent' => array('#type' => 'value', '#value' => ''),
134
-          '#row_type' => 'field',
129
+            'human_name' => array('#value' => check_plain($field['widget']['label'])),
130
+            'field_name' => array('#value' => $field['field_name']),
131
+            'type' => array('#value' => $field['type']),
132
+            'weight' => array('#type' => 'value', '#value' => $weight),
133
+            'parent' => array('#type' => 'value', '#value' => ''),
134
+            '#row_type' => 'field',
135 135
         );
136
-      }
137
-      $form['fields'] = array(
136
+        }
137
+        $form['fields'] = array(
138 138
         '#type' => 'checkboxes',
139 139
         '#options' => $fields_options,
140 140
         '#default_value' => array_keys($fields_options),
141
-      );
141
+        );
142 142
 
143
-      // Groups.
144
-      foreach ($groups as $name => $group) {
143
+        // Groups.
144
+        foreach ($groups as $name => $group) {
145 145
         $groups_options[$name] = '';
146 146
         $weight = $group['weight'];
147 147
         $form[$name] = array(
148
-          'human_name' => array('#value' => check_plain($group['label'])),
149
-          'group_name' => array('#value' => $group['group_name']),
150
-          'weight' => array('#type' => 'value', '#value' => $weight),
151
-          '#row_type' => 'group',
148
+            'human_name' => array('#value' => check_plain($group['label'])),
149
+            'group_name' => array('#value' => $group['group_name']),
150
+            'weight' => array('#type' => 'value', '#value' => $weight),
151
+            '#row_type' => 'group',
152 152
         );
153 153
         foreach ($group['fields'] as $field_name => $field) {
154
-          // Do nothing for non-exportable (inactive) fields.
155
-          if (isset($form[$field_name])) {
154
+            // Do nothing for non-exportable (inactive) fields.
155
+            if (isset($form[$field_name])) {
156 156
             $form[$field_name]['parent']['#value'] = $name;
157
-          }
157
+            }
158
+        }
158 159
         }
159
-      }
160
-      if ($groups) {
160
+        if ($groups) {
161 161
         $form['groups'] = array(
162
-          '#type' => 'checkboxes',
163
-          '#options' => $groups_options,
164
-          '#default_value' => array_keys($groups_options),
162
+            '#type' => 'checkboxes',
163
+            '#options' => $groups_options,
164
+            '#default_value' => array_keys($groups_options),
165 165
         );
166
-      }
167
-      break;
166
+        }
167
+        break;
168 168
 
169 169
     case 3: // Display the export macro.
170 170
       $GLOBALS['content_copy']['count'] = 0;
171
-      $form['export'] = array(
171
+        $form['export'] = array(
172 172
         '#title' => t('Export data'),
173 173
         '#type' => 'textarea',
174 174
         '#cols' => 60,
175 175
         '#value' => content_copy_export($form_values),
176 176
         '#rows' => max(40, $GLOBALS['content_copy']['count']),
177 177
         '#description' => t('Copy the export text and paste it into another content type using the import function.'),
178
-      );
179
-      // The calls to drupal_execute('content_field_edit_form') in
180
-      // content_copy_export() affect the page title,
181
-      drupal_set_title(t('Content types'));
182
-      break;
183
-  }
184
-
185
-  if ($step < 3) {  // Omit submit button on the textarea block to display the export data.
178
+        );
179
+        // The calls to drupal_execute('content_field_edit_form') in
180
+        // content_copy_export() affect the page title,
181
+        drupal_set_title(t('Content types'));
182
+        break;
183
+    }
184
+
185
+    if ($step < 3) {  // Omit submit button on the textarea block to display the export data.
186 186
     $form['submit'] = array(
187
-      '#type' => 'submit',
188
-      '#value' => t('Export'),
187
+        '#type' => 'submit',
188
+        '#value' => t('Export'),
189 189
     );
190
-  }
190
+    }
191 191
 
192
-  $form['step'] = array(
192
+    $form['step'] = array(
193 193
     '#type' => 'value',
194 194
     '#value' => $step,
195
-  );
195
+    );
196 196
 
197
-  return $form;
197
+    return $form;
198 198
 }
199 199
 
200 200
 function content_copy_export_form_submit($form, &$form_state) {
201
-  $form_state['rebuild'] = TRUE;
202
-  $form_state['storage']['step'] = $form_state['values']['step'];
201
+    $form_state['rebuild'] = TRUE;
202
+    $form_state['storage']['step'] = $form_state['values']['step'];
203 203
 }
204 204
 
205 205
 
@@ -208,66 +208,66 @@  discard block
 block discarded – undo
208 208
  *   and save the form values as formatted text.
209 209
  */
210 210
 function content_copy_export($form_values) {
211
-  // Set a global variable to tell when to intervene with form_alter().
212
-  $GLOBALS['content_copy']['status'] = 'export';
211
+    // Set a global variable to tell when to intervene with form_alter().
212
+    $GLOBALS['content_copy']['status'] = 'export';
213 213
 
214
-  // Get the content type info by submitting the content type form.
215
-  $node_state = array('values' => array('type_name' => $form_values['type_name']));
216
-  module_load_include('inc', 'node', 'content_types');
217
-  drupal_execute('node_type_form', $node_state, node_get_types('type', $form_values['type_name']));
214
+    // Get the content type info by submitting the content type form.
215
+    $node_state = array('values' => array('type_name' => $form_values['type_name']));
216
+    module_load_include('inc', 'node', 'content_types');
217
+    drupal_execute('node_type_form', $node_state, node_get_types('type', $form_values['type_name']));
218 218
 
219
-  module_load_include('inc', 'content', 'includes/content.admin');
220
-  module_load_include('inc', 'content', 'includes/content.crud');
219
+    module_load_include('inc', 'content', 'includes/content.admin');
220
+    module_load_include('inc', 'content', 'includes/content.crud');
221 221
 
222
-  // Get an array of groups to export.
223
-  // Record a macro for each group by submitting the group edit form.
224
-  $groups = array();
225
-  if (!empty($form_values['groups']) && module_exists('fieldgroup')) {
222
+    // Get an array of groups to export.
223
+    // Record a macro for each group by submitting the group edit form.
224
+    $groups = array();
225
+    if (!empty($form_values['groups']) && module_exists('fieldgroup')) {
226 226
     $groups = array_filter($form_values['groups']);
227 227
     foreach ($groups as $group) {
228
-      $group_state = array('values' => array('group_name' => $group));
229
-      drupal_execute('fieldgroup_group_edit_form', $group_state, $form_values['type_name'], $group, 'edit');
228
+        $group_state = array('values' => array('group_name' => $group));
229
+        drupal_execute('fieldgroup_group_edit_form', $group_state, $form_values['type_name'], $group, 'edit');
230
+    }
230 231
     }
231
-  }
232 232
 
233
-  // Get an array of fields to export
234
-  // Record a macro for each field by submitting the field settings form.
235
-  // Omit fields from the export if their module is not currently installed
236
-  // otherwise the system will generate errors when the macro tries to execute their forms.
237
-  if (!empty($form_values['fields'])) {
233
+    // Get an array of fields to export
234
+    // Record a macro for each field by submitting the field settings form.
235
+    // Omit fields from the export if their module is not currently installed
236
+    // otherwise the system will generate errors when the macro tries to execute their forms.
237
+    if (!empty($form_values['fields'])) {
238 238
     $type = content_types($form_values['type_name']);
239 239
     $fields = array_filter($form_values['fields']);
240 240
     foreach ($fields as $field_name) {
241
-      $field = $type['fields'][$field_name];
242
-      $field_types = _content_field_types();
243
-      $field_module = $field_types[$field['type']]['module'];
244
-      $widget_types = _content_widget_types();
245
-      $widget_module = $widget_types[$field['widget']['type']]['module'];
246
-      if (!empty($field_module) && module_exists($field_module) && !empty($widget_module) && module_exists($widget_module)) {
241
+        $field = $type['fields'][$field_name];
242
+        $field_types = _content_field_types();
243
+        $field_module = $field_types[$field['type']]['module'];
244
+        $widget_types = _content_widget_types();
245
+        $widget_module = $widget_types[$field['widget']['type']]['module'];
246
+        if (!empty($field_module) && module_exists($field_module) && !empty($widget_module) && module_exists($widget_module)) {
247 247
         $field_state = array('values' => content_field_instance_collapse($field));
248 248
         $field_state['values']['op'] = t('Save field settings');
249 249
         if (module_exists('fieldgroup')) {
250
-          // Avoid undefined index error by always creating this.
251
-          $field_state['values']['group'] = '';
252
-          $group_name = fieldgroup_get_group($form_values['type_name'], $field_name);
253
-          if (in_array($group_name, $groups)) {
250
+            // Avoid undefined index error by always creating this.
251
+            $field_state['values']['group'] = '';
252
+            $group_name = fieldgroup_get_group($form_values['type_name'], $field_name);
253
+            if (in_array($group_name, $groups)) {
254 254
             $field_state['values']['group'] = $group_name;
255
-          }
255
+            }
256 256
         }
257 257
         drupal_execute('content_field_edit_form', $field_state, $form_values['type_name'], $field_name);
258
-      }
258
+        }
259
+    }
259 260
     }
260
-  }
261 261
 
262
-  // Convert the macro array into formatted text.
263
-  $output = content_copy_get_macro();
262
+    // Convert the macro array into formatted text.
263
+    $output = content_copy_get_macro();
264 264
 
265
-  // Add weights of non-CCK fields.
266
-  if ($extra = variable_get('content_extra_weights_'. $form_values['type_name'], array())) {
265
+    // Add weights of non-CCK fields.
266
+    if ($extra = variable_get('content_extra_weights_'. $form_values['type_name'], array())) {
267 267
     $output .= "\$content['extra']  = ". var_export((array) $extra, TRUE) .";\n";
268
-  }
268
+    }
269 269
 
270
-  return $output;
270
+    return $output;
271 271
 }
272 272
 
273 273
 /**
@@ -294,37 +294,37 @@  discard block
 block discarded – undo
294 294
  * }
295 295
  */
296 296
 function content_copy_import_form(&$form_state, $type_name = '') {
297
-  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
298
-  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
297
+    include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
298
+    include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
299 299
 
300
-  $form['#prefix'] = t('This form will import field definitions exported from another content type or another database.<br/>Note that fields cannot be duplicated within the same content type, so imported fields will be added only if they do not already exist in the selected type.');
301
-  $form['type_name'] = array(
300
+    $form['#prefix'] = t('This form will import field definitions exported from another content type or another database.<br/>Note that fields cannot be duplicated within the same content type, so imported fields will be added only if they do not already exist in the selected type.');
301
+    $form['type_name'] = array(
302 302
     '#type' => 'select',
303 303
     '#options' => array('<create>' => t('<Create>')) + content_copy_types(),
304 304
     '#default_value' => $type_name,
305 305
     '#title' => t('Content type'),
306 306
     '#description' => t('Select the content type to import these fields into.<br/>Select &lt;Create&gt; to create a new content type to contain the fields.'),
307
-  );
308
-  $form['macro'] = array(
307
+    );
308
+    $form['macro'] = array(
309 309
     '#type' => 'textarea',
310 310
     '#rows' => 40,
311 311
     '#title' => t('Import data'),
312 312
     '#required' => TRUE,
313 313
     '#description' => t('Paste the text created by a content export into this field.'),
314
-  );
315
-  $form['submit'] = array(
314
+    );
315
+    $form['submit'] = array(
316 316
     '#type' => 'submit',
317 317
     '#value' => t('Import'),
318
-  );
319
-  // Read in a file if there is one and set it as the default macro value.
320
-  if (isset($_REQUEST['macro_file']) && $file = file_get_contents($_REQUEST['macro_file'])) {
318
+    );
319
+    // Read in a file if there is one and set it as the default macro value.
320
+    if (isset($_REQUEST['macro_file']) && $file = file_get_contents($_REQUEST['macro_file'])) {
321 321
     $form['macro']['#default_value'] = $file;
322 322
     if (isset($_REQUEST['type_name'])) {
323
-      $form['type_name']['#default_value'] = $_REQUEST['type_name'];
323
+        $form['type_name']['#default_value'] = $_REQUEST['type_name'];
324 324
     }
325 325
     $form['#prefix'] .= '<p class="error">'. t('A file has been pre-loaded for import.') .'</p>';
326
-  }
327
-  return $form;
326
+    }
327
+    return $form;
328 328
 }
329 329
 
330 330
 /**
@@ -334,90 +334,90 @@  discard block
 block discarded – undo
334 334
  *     2) execute the imported field macro to update the settings to the imported values
335 335
  */
336 336
 function content_copy_import_form_submit($form, &$form_state) {
337
-  $form_values = $form_state['values'];
337
+    $form_values = $form_state['values'];
338 338
 
339
-  // Get the content type we are importing into.
340
-  $type_name = $form_values['type_name'];
341
-  $type_label = node_get_types('name', $type_name);
339
+    // Get the content type we are importing into.
340
+    $type_name = $form_values['type_name'];
341
+    $type_label = node_get_types('name', $type_name);
342 342
 
343
-  $content = NULL;
344
-  // Convert the import formatted text back into a $content array.
345
-  // Return if errors generated or not an array.
346
-  // Use '@' to suppress errors about undefined constants in the macro.
347
-  @eval($form_values['macro']);
343
+    $content = NULL;
344
+    // Convert the import formatted text back into a $content array.
345
+    // Return if errors generated or not an array.
346
+    // Use '@' to suppress errors about undefined constants in the macro.
347
+    @eval($form_values['macro']);
348 348
 
349
-  // Preliminary error trapping, must have valid arrays to work with.
350
-  if (!isset($content) || !isset($content['type']) || !is_array($content) || !is_array($content['type'])) {
349
+    // Preliminary error trapping, must have valid arrays to work with.
350
+    if (!isset($content) || !isset($content['type']) || !is_array($content) || !is_array($content['type'])) {
351 351
     form_set_error('macro', t('The import data is not valid import text.'));
352 352
     return;
353
-  }
353
+    }
354 354
 
355
-  module_load_include('inc', 'content', 'includes/content.crud');
355
+    module_load_include('inc', 'content', 'includes/content.crud');
356 356
 
357
-  // Get all type and field info for this database.
358
-  $content_info = _content_type_info();
357
+    // Get all type and field info for this database.
358
+    $content_info = _content_type_info();
359 359
 
360
-  $imported_type = $content['type'];
361
-  $imported_type_name = $imported_type['type'];
362
-  $imported_type_label = $imported_type['name'];
360
+    $imported_type = $content['type'];
361
+    $imported_type_name = $imported_type['type'];
362
+    $imported_type_label = $imported_type['name'];
363 363
 
364
-  // It is allowed to import a type with no fields,
365
-  // so the fields array could be empty and must be cast as an array.
366
-  $imported_fields = isset($content['fields']) ? $content['fields'] : array();
364
+    // It is allowed to import a type with no fields,
365
+    // so the fields array could be empty and must be cast as an array.
366
+    $imported_fields = isset($content['fields']) ? $content['fields'] : array();
367 367
 
368
-  // Perform more pre-import error trapping.
369
-  // If there are potential problems, exit without doing the import.
370
-  $not_enabled = array();
368
+    // Perform more pre-import error trapping.
369
+    // If there are potential problems, exit without doing the import.
370
+    $not_enabled = array();
371 371
 
372
-  // The groups array could be empty and still valid, make sure to cast it as an array.
373
-  // If there are groups in the import, make sure the fieldgroup module is enabled.
374
-  $imported_groups = array();
375
-  if (isset($content['groups']) && module_exists('fieldgroup')) {
372
+    // The groups array could be empty and still valid, make sure to cast it as an array.
373
+    // If there are groups in the import, make sure the fieldgroup module is enabled.
374
+    $imported_groups = array();
375
+    if (isset($content['groups']) && module_exists('fieldgroup')) {
376 376
     $imported_groups = (array) $content['groups'];
377
-  }
378
-  elseif (isset($content['groups']) && is_array($content['groups'])) {
377
+    }
378
+    elseif (isset($content['groups']) && is_array($content['groups'])) {
379 379
     $not_enabled[] = 'fieldgroup';
380
-  }
380
+    }
381 381
 
382
-  // Make sure that all the field and widget modules in the import are enabled in this database.
383
-  foreach ($imported_fields as $import) {
382
+    // Make sure that all the field and widget modules in the import are enabled in this database.
383
+    foreach ($imported_fields as $import) {
384 384
     $field = content_field_instance_collapse($import);
385 385
     if (empty($field['module']) || empty($field['widget_module'])) {
386
-      $not_enabled[] = $field['field_name'];
386
+        $not_enabled[] = $field['field_name'];
387 387
     }
388 388
     else {
389
-      if (!module_exists($field['module'])) {
389
+        if (!module_exists($field['module'])) {
390 390
         $not_enabled[] = $field['module'];
391
-      }
392
-      if (!module_exists($field['widget_module'])) {
391
+        }
392
+        if (!module_exists($field['widget_module'])) {
393 393
         $not_enabled[] = $field['widget_module'];
394
-      }
394
+        }
395
+    }
395 396
     }
396
-  }
397 397
 
398
-  // If any required module is not enabled, set an error message and exit.
399
-  if ($not_enabled) {
398
+    // If any required module is not enabled, set an error message and exit.
399
+    if ($not_enabled) {
400 400
     form_set_error('macro', t('The following modules must be enabled for this import to work: %modules.', array(
401 401
         '%modules' => implode(', ', array_unique($not_enabled))
402 402
         )));
403
-  }
403
+    }
404 404
 
405
-  // Make sure the imported content type doesn't already exist in the database.
406
-  if ($form_values['type_name'] == '<create>') {
405
+    // Make sure the imported content type doesn't already exist in the database.
406
+    if ($form_values['type_name'] == '<create>') {
407 407
     if (in_array($imported_type_name, array_keys($content_info['content types']))) {
408
-      form_set_error('macro', t('The content type %type already exists in this database.', array(
408
+        form_set_error('macro', t('The content type %type already exists in this database.', array(
409 409
             '%type' => $imported_type_name
410 410
             )));
411 411
     }
412
-  }
412
+    }
413 413
 
414
-  if (form_get_errors()) {
414
+    if (form_get_errors()) {
415 415
     drupal_set_message(t('Exiting. No import performed.'), 'error');
416 416
     return;
417
-  }
417
+    }
418 418
 
419
-  // Create the content type, if requested.
420
-  if ($form_values['type_name'] == '<create>') {
419
+    // Create the content type, if requested.
420
+    if ($form_values['type_name'] == '<create>') {
421 421
 
422 422
     $type = (object) $imported_type;
423 423
     $values = $imported_type;
@@ -435,26 +435,26 @@  discard block
 block discarded – undo
435 435
     $content_info = _content_type_info();
436 436
 
437 437
     if (form_get_errors() || !isset($content_info['content types']) || !is_array($content_info['content types'][$type_name])) {
438
-       drupal_set_message(t('An error has occurred adding the content type %type.<br/>Please check the errors displayed for more details.', array(
438
+        drupal_set_message(t('An error has occurred adding the content type %type.<br/>Please check the errors displayed for more details.', array(
439 439
             '%type' => $imported_type_name
440 440
             )));
441
-       return;
441
+        return;
442
+    }
442 443
     }
443
-  }
444 444
 
445
-  // Create the groups for this type, if they don't already exist.
446
-  if (module_exists('fieldgroup') && $imported_groups) {
445
+    // Create the groups for this type, if they don't already exist.
446
+    if (module_exists('fieldgroup') && $imported_groups) {
447 447
     foreach ($imported_groups as $group) {
448
-      $group_name = $group['group_name'];
449
-      fieldgroup_save_group($type_name, $group);
448
+        $group_name = $group['group_name'];
449
+        fieldgroup_save_group($type_name, $group);
450 450
     }
451 451
     // Reset the static variable in fieldgroup_groups() with new data.
452 452
     fieldgroup_groups('', FALSE, TRUE);
453
-  }
453
+    }
454 454
 
455
-  // Iterate through the field forms in the import and execute each.
456
-  $rebuild = FALSE;
457
-  foreach ($imported_fields as $field) {
455
+    // Iterate through the field forms in the import and execute each.
456
+    $rebuild = FALSE;
457
+    foreach ($imported_fields as $field) {
458 458
 
459 459
     // Make sure the field doesn't already exist in the type.
460 460
     // If so, do nothing, fields can't be duplicated within a content type.
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
     $field['type_name'] = $type_name;
465 465
 
466 466
     if (!empty($field['field_name']) && isset($content_info['content types'][$type_name]['fields'][$field_name])) {
467
-      drupal_set_message(t('The imported field %field_label (%field_name) was not added to %type because that field already exists in %type.', array(
467
+        drupal_set_message(t('The imported field %field_label (%field_name) was not added to %type because that field already exists in %type.', array(
468 468
         '%field_label' => $field['label'], '%field_name' => $field_name, '%type' => $type_label)));
469 469
     }
470 470
     else {
471
-      $field = content_field_instance_create($field, FALSE);
472
-      $rebuild = TRUE;
473
-      drupal_set_message(t('The field %field_label (%field_name) was added to the content type %type.', array(
471
+        $field = content_field_instance_create($field, FALSE);
472
+        $rebuild = TRUE;
473
+        drupal_set_message(t('The field %field_label (%field_name) was added to the content type %type.', array(
474 474
         '%field_label' => $field['widget']['label'], '%field_name' => $field_name, '%type' => $type_label)));
475 475
     }
476 476
 
@@ -480,20 +480,20 @@  discard block
 block discarded – undo
480 480
     // restored. Hence, we need to update field group data for newly imported
481 481
     // field, but also for fields that already exist.
482 482
     if (module_exists('fieldgroup') && isset($imported_groups)) {
483
-      fieldgroup_update_fields($field);
483
+        fieldgroup_update_fields($field);
484
+    }
484 485
     }
485
-  }
486 486
 
487
-  // Clear caches and rebuild menu only if any field has been created.
488
-  if ($rebuild) {
487
+    // Clear caches and rebuild menu only if any field has been created.
488
+    if ($rebuild) {
489 489
     content_clear_type_cache(TRUE);
490 490
     menu_rebuild();
491
-  }
491
+    }
492 492
 
493
-  // Import weights of non-CCK fields.
494
-  if (isset($content['extra'])) {
493
+    // Import weights of non-CCK fields.
494
+    if (isset($content['extra'])) {
495 495
     variable_set('content_extra_weights_'. $type_name, $content['extra']);
496
-  }
496
+    }
497 497
 }
498 498
 
499 499
 /**
@@ -501,22 +501,22 @@  discard block
 block discarded – undo
501 501
  * Intervene to run form through macro when doing export
502 502
  */
503 503
 function content_copy_form_alter(&$form, $form_state, $form_id) {
504
-  $alter_forms = array('node_type_form', 'content_field_edit_form', 'fieldgroup_group_edit_form');
505
-  if (isset($GLOBALS['content_copy']) && isset($GLOBALS['content_copy']['status']) && $GLOBALS['content_copy']['status'] == 'export' && in_array($form_id, $alter_forms)) {
504
+    $alter_forms = array('node_type_form', 'content_field_edit_form', 'fieldgroup_group_edit_form');
505
+    if (isset($GLOBALS['content_copy']) && isset($GLOBALS['content_copy']['status']) && $GLOBALS['content_copy']['status'] == 'export' && in_array($form_id, $alter_forms)) {
506 506
     $form['#submit'][] = 'content_copy_record_macro';
507
-  }
507
+    }
508 508
 }
509 509
 
510 510
 /**
511 511
  * Get all the *active* fields for a content type.
512 512
  */
513 513
 function content_copy_fields($type_name) {
514
-  $fields = array();
515
-  if (!$type_name) {
514
+    $fields = array();
515
+    if (!$type_name) {
516 516
     return $fields;
517
-  }
518
-  $content_info = _content_type_info();
519
-  foreach ($content_info['content types'][$type_name]['fields'] as $field_name => $field) {
517
+    }
518
+    $content_info = _content_type_info();
519
+    foreach ($content_info['content types'][$type_name]['fields'] as $field_name => $field) {
520 520
     // Omit fields from the export if their module is not currently installed
521 521
     // otherwise the system will generate errors when the macro tries to execute their forms.
522 522
     $field_types = _content_field_types();
@@ -525,125 +525,125 @@  discard block
 block discarded – undo
525 525
     $widget_module = $widget_types[$field['widget']['type']]['module'];
526 526
 
527 527
     if (!$field['locked'] && !empty($field_module) && module_exists($field_module) && !empty($widget_module) && module_exists($widget_module)) {
528
-      $fields[] = $field_name;
528
+        $fields[] = $field_name;
529 529
     }
530
-  }
531
-  return $fields;
530
+    }
531
+    return $fields;
532 532
 }
533 533
 
534 534
 /**
535 535
  *  Get all content types.
536 536
  */
537 537
 function content_copy_types() {
538
-  $types = array();
539
-  $content_info = _content_type_info();
540
-  foreach ($content_info['content types'] as $type_name => $val) {
538
+    $types = array();
539
+    $content_info = _content_type_info();
540
+    foreach ($content_info['content types'] as $type_name => $val) {
541 541
     $types[$type_name] = check_plain($val['name']) .' ('. $type_name .')';
542
-  }
543
-  return $types;
542
+    }
543
+    return $types;
544 544
 }
545 545
 
546 546
 /**
547 547
  * A handler that stores the form submissions into a $GLOBALS array
548 548
  */
549 549
 function content_copy_record_macro($form, &$form_state) {
550
-  $edit = $form_state['values'];
551
-  $subs = isset($GLOBALS['content_copy']['submissions']) ? $GLOBALS['content_copy']['submissions'] : array();
550
+    $edit = $form_state['values'];
551
+    $subs = isset($GLOBALS['content_copy']['submissions']) ? $GLOBALS['content_copy']['submissions'] : array();
552 552
 
553
-  // Get the form values and store them in a $GLOBALS['content_copy']['submissions'] array.
554
-  // Update $GLOBALS['content_copy']['count'] with an approximation of the number of rows in this item.
555
-  // Count is used to approximate necessary size of textarea in form.
553
+    // Get the form values and store them in a $GLOBALS['content_copy']['submissions'] array.
554
+    // Update $GLOBALS['content_copy']['count'] with an approximation of the number of rows in this item.
555
+    // Count is used to approximate necessary size of textarea in form.
556 556
 
557
-  $form_id = $form_state['values']['form_id'];
558
-  if (isset($edit['type_name']) || isset($edit['submit']) || isset($edit['delete']) || isset($edit['form_id'])) {
557
+    $form_id = $form_state['values']['form_id'];
558
+    if (isset($edit['type_name']) || isset($edit['submit']) || isset($edit['delete']) || isset($edit['form_id'])) {
559 559
     unset($edit['type_name'], $edit['submit'], $edit['delete'], $edit['form_id'], $edit['previous_field']);
560
-  }
561
-  switch ($form_id) {
560
+    }
561
+    switch ($form_id) {
562 562
     case 'node_type_form':
563 563
       $subs['type'] = $edit;
564
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
565
-      break;
564
+        $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
565
+        break;
566 566
 
567 567
     case 'fieldgroup_group_edit_form':
568 568
       $subs['groups'][] = $edit;
569
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
570
-      break;
569
+        $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
570
+        break;
571 571
 
572 572
     default:
573 573
       if (isset($edit['field_widget_type'])) {
574 574
         $tmp = explode('-', $edit['field_widget_type']);
575 575
         $field_name = $tmp[0];
576
-      }
577
-      else {
576
+        }
577
+        else {
578 578
         $field_name = isset($edit['field_name']) ? $edit['field_name'] : '';
579
-      }
579
+        }
580 580
 
581
-      // The display settings are being fetched directly from the DB. During import,
582
-      // we'll re-insert the data directly as well.
583
-      //
584
-      $query = 'SELECT display_settings FROM {'. content_instance_tablename() .'} WHERE field_name = \'%s\'';
585
-      $row_info = db_fetch_array(db_query($query, $field_name));
581
+        // The display settings are being fetched directly from the DB. During import,
582
+        // we'll re-insert the data directly as well.
583
+        //
584
+        $query = 'SELECT display_settings FROM {'. content_instance_tablename() .'} WHERE field_name = \'%s\'';
585
+        $row_info = db_fetch_array(db_query($query, $field_name));
586 586
 
587
-      // If an error occurs, notify the user.
588
-      if ($db_err = db_error()) {
587
+        // If an error occurs, notify the user.
588
+        if ($db_err = db_error()) {
589 589
         drupal_set_message(t("An error occurred when exporting the 'display settings' data for the field %field_name.<br/>The db error is: '%db_err'.", array(
590
-             '%field_name' => $field_name,
591
-             '%db_err' => $db_err
590
+                '%field_name' => $field_name,
591
+                '%db_err' => $db_err
592 592
         )));
593
-      }
594
-      else {
593
+        }
594
+        else {
595 595
         // The db fetch occurred successfully, unserialize the data blob and
596 596
         // insert it into a new "display_settings" field of the data.
597 597
         if ($display_settings = unserialize($row_info['display_settings'])) {
598
-          $edit['display_settings'] = $display_settings;
598
+            $edit['display_settings'] = $display_settings;
599 599
         }
600
-      }
601
-      $subs['fields'][] = $edit;
602
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
603
-      break;
604
-  }
600
+        }
601
+        $subs['fields'][] = $edit;
602
+        $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
603
+        break;
604
+    }
605 605
 
606
-  $GLOBALS['content_copy']['submissions'] = $subs;
606
+    $GLOBALS['content_copy']['submissions'] = $subs;
607 607
 }
608 608
 
609 609
 /**
610 610
  * @return a code representation of the recorded macro.
611 611
  */
612 612
 function content_copy_get_macro() {
613
-  // Define the indexes for the evaluated code.
614
-  $string = "";
615
-  if (array_key_exists('submissions', $GLOBALS['content_copy'])) {
613
+    // Define the indexes for the evaluated code.
614
+    $string = "";
615
+    if (array_key_exists('submissions', $GLOBALS['content_copy'])) {
616 616
     foreach ($GLOBALS['content_copy']['submissions'] as $form_type => $form) {
617
-      $string .= "\$content['$form_type']  = ". var_export((array) $form, TRUE) .";\n";
617
+        $string .= "\$content['$form_type']  = ". var_export((array) $form, TRUE) .";\n";
618 618
     }
619 619
     return $string;
620
-  }
620
+    }
621 621
 }
622 622
 
623 623
 function template_preprocess_content_copy_export_form($vars) {
624
-  $form = &$vars['form'];
624
+    $form = &$vars['form'];
625 625
 
626
-  if ($form['#step'] == 2) {
626
+    if ($form['#step'] == 2) {
627 627
     $order = _content_overview_order($form, $form['#fields'], $form['#groups']);
628 628
 
629 629
     $rows = array();
630 630
     foreach ($order as $key) {
631
-      $element = &$form[$key];
632
-      $row = new stdClass();
631
+        $element = &$form[$key];
632
+        $row = new stdClass();
633 633
 
634
-      $row->row_type = $element['#row_type'];
635
-      $checkbox_key = $element['#row_type'] == 'field' ? 'fields' : 'groups';
636
-      $row->checkbox = drupal_render($form[$checkbox_key][$key]);
637
-      foreach (element_children($element) as $child) {
634
+        $row->row_type = $element['#row_type'];
635
+        $checkbox_key = $element['#row_type'] == 'field' ? 'fields' : 'groups';
636
+        $row->checkbox = drupal_render($form[$checkbox_key][$key]);
637
+        foreach (element_children($element) as $child) {
638 638
         $row->{$child} = drupal_render($element[$child]);
639
-      }
640
-      $row->label_class = in_array($key, $form['#groups']) ? 'label-group' : 'label-field';
641
-      $row->indentation = theme('indentation', isset($element['#depth']) ? $element['#depth'] : 0);
639
+        }
640
+        $row->label_class = in_array($key, $form['#groups']) ? 'label-group' : 'label-field';
641
+        $row->indentation = theme('indentation', isset($element['#depth']) ? $element['#depth'] : 0);
642 642
 
643
-      $rows[] = $row;
643
+        $rows[] = $row;
644 644
     }
645 645
     $vars['rows'] = $rows;
646
-  }
646
+    }
647 647
 
648
-  $vars['submit'] = drupal_render($form);
648
+    $vars['submit'] = drupal_render($form);
649 649
 }
650 650
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -97,89 +97,89 @@  discard block
 block discarded – undo
97 97
   $form['#prefix'] = t('This form will process a content type and one or more fields from that type and export the settings. The export created by this process can be copied and pasted as an import into the current or any other database. The import will add the fields to an existing content type or create a new content type that includes the selected fields.');
98 98
 
99 99
   switch ($step) {
100
-    case 1: // Select a content type.
101
-      $types  = content_copy_types();
102
-      $form['type_name'] = array(
103
-        '#title' => t('Types'),
104
-        '#type' => 'radios',
105
-        '#options' => $types,
106
-        '#description' => t('Select the content type to export.'),
107
-      );
108
-      break;
100
+  case 1: // Select a content type.
101
+    $types  = content_copy_types();
102
+    $form['type_name'] = array(
103
+      '#title' => t('Types'),
104
+      '#type' => 'radios',
105
+      '#options' => $types,
106
+      '#description' => t('Select the content type to export.'),
107
+    );
108
+    break;
109 109
 
110
-    case 2: // Select groups and fields.
111
-      $form['type_name'] = array(
112
-        '#type' => 'hidden',
113
-        '#value' => $type_name,
114
-      );
110
+  case 2: // Select groups and fields.
111
+    $form['type_name'] = array(
112
+      '#type' => 'hidden',
113
+      '#value' => $type_name,
114
+    );
115 115
 
116
-      $form += array(
117
-        '#fields' => $exportable_fields,
118
-        '#groups' => array_keys($groups),
119
-      );
116
+    $form += array(
117
+      '#fields' => $exportable_fields,
118
+      '#groups' => array_keys($groups),
119
+    );
120 120
 
121
-      $fields_options = $groups_options = array();
122
-
123
-      // Fields.
124
-      foreach ($exportable_fields as $field_name) {
125
-        $field = content_fields($field_name, $type_name);
126
-        $fields_options[$field_name] = '';
127
-        $weight = $field['widget']['weight'];
128
-        $form[$field_name] = array(
129
-          'human_name' => array('#value' => check_plain($field['widget']['label'])),
130
-          'field_name' => array('#value' => $field['field_name']),
131
-          'type' => array('#value' => $field['type']),
132
-          'weight' => array('#type' => 'value', '#value' => $weight),
133
-          'parent' => array('#type' => 'value', '#value' => ''),
134
-          '#row_type' => 'field',
135
-        );
136
-      }
137
-      $form['fields'] = array(
138
-        '#type' => 'checkboxes',
139
-        '#options' => $fields_options,
140
-        '#default_value' => array_keys($fields_options),
121
+    $fields_options = $groups_options = array();
122
+
123
+    // Fields.
124
+    foreach ($exportable_fields as $field_name) {
125
+      $field = content_fields($field_name, $type_name);
126
+      $fields_options[$field_name] = '';
127
+      $weight = $field['widget']['weight'];
128
+      $form[$field_name] = array(
129
+        'human_name' => array('#value' => check_plain($field['widget']['label'])),
130
+        'field_name' => array('#value' => $field['field_name']),
131
+        'type' => array('#value' => $field['type']),
132
+        'weight' => array('#type' => 'value', '#value' => $weight),
133
+        'parent' => array('#type' => 'value', '#value' => ''),
134
+        '#row_type' => 'field',
141 135
       );
136
+    }
137
+    $form['fields'] = array(
138
+      '#type' => 'checkboxes',
139
+      '#options' => $fields_options,
140
+      '#default_value' => array_keys($fields_options),
141
+    );
142 142
 
143
-      // Groups.
144
-      foreach ($groups as $name => $group) {
145
-        $groups_options[$name] = '';
146
-        $weight = $group['weight'];
147
-        $form[$name] = array(
148
-          'human_name' => array('#value' => check_plain($group['label'])),
149
-          'group_name' => array('#value' => $group['group_name']),
150
-          'weight' => array('#type' => 'value', '#value' => $weight),
151
-          '#row_type' => 'group',
152
-        );
153
-        foreach ($group['fields'] as $field_name => $field) {
154
-          // Do nothing for non-exportable (inactive) fields.
155
-          if (isset($form[$field_name])) {
156
-            $form[$field_name]['parent']['#value'] = $name;
157
-          }
143
+    // Groups.
144
+    foreach ($groups as $name => $group) {
145
+      $groups_options[$name] = '';
146
+      $weight = $group['weight'];
147
+      $form[$name] = array(
148
+        'human_name' => array('#value' => check_plain($group['label'])),
149
+        'group_name' => array('#value' => $group['group_name']),
150
+        'weight' => array('#type' => 'value', '#value' => $weight),
151
+        '#row_type' => 'group',
152
+      );
153
+      foreach ($group['fields'] as $field_name => $field) {
154
+        // Do nothing for non-exportable (inactive) fields.
155
+        if (isset($form[$field_name])) {
156
+          $form[$field_name]['parent']['#value'] = $name;
158 157
         }
159 158
       }
160
-      if ($groups) {
161
-        $form['groups'] = array(
162
-          '#type' => 'checkboxes',
163
-          '#options' => $groups_options,
164
-          '#default_value' => array_keys($groups_options),
165
-        );
166
-      }
167
-      break;
168
-
169
-    case 3: // Display the export macro.
170
-      $GLOBALS['content_copy']['count'] = 0;
171
-      $form['export'] = array(
172
-        '#title' => t('Export data'),
173
-        '#type' => 'textarea',
174
-        '#cols' => 60,
175
-        '#value' => content_copy_export($form_values),
176
-        '#rows' => max(40, $GLOBALS['content_copy']['count']),
177
-        '#description' => t('Copy the export text and paste it into another content type using the import function.'),
159
+    }
160
+    if ($groups) {
161
+      $form['groups'] = array(
162
+        '#type' => 'checkboxes',
163
+        '#options' => $groups_options,
164
+        '#default_value' => array_keys($groups_options),
178 165
       );
179
-      // The calls to drupal_execute('content_field_edit_form') in
180
-      // content_copy_export() affect the page title,
181
-      drupal_set_title(t('Content types'));
182
-      break;
166
+    }
167
+    break;
168
+
169
+  case 3: // Display the export macro.
170
+    $GLOBALS['content_copy']['count'] = 0;
171
+    $form['export'] = array(
172
+      '#title' => t('Export data'),
173
+      '#type' => 'textarea',
174
+      '#cols' => 60,
175
+      '#value' => content_copy_export($form_values),
176
+      '#rows' => max(40, $GLOBALS['content_copy']['count']),
177
+      '#description' => t('Copy the export text and paste it into another content type using the import function.'),
178
+    );
179
+    // The calls to drupal_execute('content_field_edit_form') in
180
+    // content_copy_export() affect the page title,
181
+    drupal_set_title(t('Content types'));
182
+    break;
183 183
   }
184 184
 
185 185
   if ($step < 3) {  // Omit submit button on the textarea block to display the export data.
@@ -559,48 +559,48 @@  discard block
 block discarded – undo
559 559
     unset($edit['type_name'], $edit['submit'], $edit['delete'], $edit['form_id'], $edit['previous_field']);
560 560
   }
561 561
   switch ($form_id) {
562
-    case 'node_type_form':
563
-      $subs['type'] = $edit;
564
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
565
-      break;
566
-
567
-    case 'fieldgroup_group_edit_form':
568
-      $subs['groups'][] = $edit;
569
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
570
-      break;
571
-
572
-    default:
573
-      if (isset($edit['field_widget_type'])) {
574
-        $tmp = explode('-', $edit['field_widget_type']);
575
-        $field_name = $tmp[0];
576
-      }
577
-      else {
578
-        $field_name = isset($edit['field_name']) ? $edit['field_name'] : '';
579
-      }
562
+  case 'node_type_form':
563
+    $subs['type'] = $edit;
564
+    $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
565
+    break;
566
+
567
+  case 'fieldgroup_group_edit_form':
568
+    $subs['groups'][] = $edit;
569
+    $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
570
+    break;
571
+
572
+  default:
573
+    if (isset($edit['field_widget_type'])) {
574
+      $tmp = explode('-', $edit['field_widget_type']);
575
+      $field_name = $tmp[0];
576
+    }
577
+    else {
578
+      $field_name = isset($edit['field_name']) ? $edit['field_name'] : '';
579
+    }
580 580
 
581
-      // The display settings are being fetched directly from the DB. During import,
582
-      // we'll re-insert the data directly as well.
583
-      //
584
-      $query = 'SELECT display_settings FROM {'. content_instance_tablename() .'} WHERE field_name = \'%s\'';
585
-      $row_info = db_fetch_array(db_query($query, $field_name));
586
-
587
-      // If an error occurs, notify the user.
588
-      if ($db_err = db_error()) {
589
-        drupal_set_message(t("An error occurred when exporting the 'display settings' data for the field %field_name.<br/>The db error is: '%db_err'.", array(
590
-             '%field_name' => $field_name,
591
-             '%db_err' => $db_err
592
-        )));
593
-      }
594
-      else {
595
-        // The db fetch occurred successfully, unserialize the data blob and
596
-        // insert it into a new "display_settings" field of the data.
597
-        if ($display_settings = unserialize($row_info['display_settings'])) {
598
-          $edit['display_settings'] = $display_settings;
599
-        }
581
+    // The display settings are being fetched directly from the DB. During import,
582
+    // we'll re-insert the data directly as well.
583
+    //
584
+    $query = 'SELECT display_settings FROM {'. content_instance_tablename() .'} WHERE field_name = \'%s\'';
585
+    $row_info = db_fetch_array(db_query($query, $field_name));
586
+
587
+    // If an error occurs, notify the user.
588
+    if ($db_err = db_error()) {
589
+      drupal_set_message(t("An error occurred when exporting the 'display settings' data for the field %field_name.<br/>The db error is: '%db_err'.", array(
590
+           '%field_name' => $field_name,
591
+           '%db_err' => $db_err
592
+      )));
593
+    }
594
+    else {
595
+      // The db fetch occurred successfully, unserialize the data blob and
596
+      // insert it into a new "display_settings" field of the data.
597
+      if ($display_settings = unserialize($row_info['display_settings'])) {
598
+        $edit['display_settings'] = $display_settings;
600 599
       }
601
-      $subs['fields'][] = $edit;
602
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
603
-      break;
600
+    }
601
+    $subs['fields'][] = $edit;
602
+    $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
603
+    break;
604 604
   }
605 605
 
606 606
   $GLOBALS['content_copy']['submissions'] = $subs;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
  *  A form to export field definitions.
70 70
  */
71 71
 function content_copy_export_form(&$form_state) {
72
-  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
73
-  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
72
+  include_once('./'.drupal_get_path('module', 'content').'/includes/content.admin.inc');
73
+  include_once('./'.drupal_get_path('module', 'node').'/content_types.inc');
74 74
 
75 75
   $form_values = isset($form_state['values']) ? $form_state['values'] : array();
76 76
   $step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] + 1 : 1;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
   switch ($step) {
100 100
     case 1: // Select a content type.
101
-      $types  = content_copy_types();
101
+      $types = content_copy_types();
102 102
       $form['type_name'] = array(
103 103
         '#title' => t('Types'),
104 104
         '#type' => 'radios',
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
   $output = content_copy_get_macro();
264 264
 
265 265
   // Add weights of non-CCK fields.
266
-  if ($extra = variable_get('content_extra_weights_'. $form_values['type_name'], array())) {
267
-    $output .= "\$content['extra']  = ". var_export((array) $extra, TRUE) .";\n";
266
+  if ($extra = variable_get('content_extra_weights_'.$form_values['type_name'], array())) {
267
+    $output .= "\$content['extra']  = ".var_export((array)$extra, TRUE).";\n";
268 268
   }
269 269
 
270 270
   return $output;
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
  * }
295 295
  */
296 296
 function content_copy_import_form(&$form_state, $type_name = '') {
297
-  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
298
-  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
297
+  include_once('./'.drupal_get_path('module', 'content').'/includes/content.admin.inc');
298
+  include_once('./'.drupal_get_path('module', 'node').'/content_types.inc');
299 299
 
300 300
   $form['#prefix'] = t('This form will import field definitions exported from another content type or another database.<br/>Note that fields cannot be duplicated within the same content type, so imported fields will be added only if they do not already exist in the selected type.');
301 301
   $form['type_name'] = array(
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
     if (isset($_REQUEST['type_name'])) {
323 323
       $form['type_name']['#default_value'] = $_REQUEST['type_name'];
324 324
     }
325
-    $form['#prefix'] .= '<p class="error">'. t('A file has been pre-loaded for import.') .'</p>';
325
+    $form['#prefix'] .= '<p class="error">'.t('A file has been pre-loaded for import.').'</p>';
326 326
   }
327 327
   return $form;
328 328
 }
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
   // If there are groups in the import, make sure the fieldgroup module is enabled.
374 374
   $imported_groups = array();
375 375
   if (isset($content['groups']) && module_exists('fieldgroup')) {
376
-    $imported_groups = (array) $content['groups'];
376
+    $imported_groups = (array)$content['groups'];
377 377
   }
378 378
   elseif (isset($content['groups']) && is_array($content['groups'])) {
379 379
     $not_enabled[] = 'fieldgroup';
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
   // Create the content type, if requested.
420 420
   if ($form_values['type_name'] == '<create>') {
421 421
 
422
-    $type = (object) $imported_type;
422
+    $type = (object)$imported_type;
423 423
     $values = $imported_type;
424 424
     // Prevent a warning in node/content_types.inc
425 425
     $type->has_title = TRUE;
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 
459 459
     // Make sure the field doesn't already exist in the type.
460 460
     // If so, do nothing, fields can't be duplicated within a content type.
461
-    $field_name   = $field['field_name'];
461
+    $field_name = $field['field_name'];
462 462
 
463 463
     // Might need to overwrite the content type name if a new type was created.
464 464
     $field['type_name'] = $type_name;
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
   // Import weights of non-CCK fields.
494 494
   if (isset($content['extra'])) {
495
-    variable_set('content_extra_weights_'. $type_name, $content['extra']);
495
+    variable_set('content_extra_weights_'.$type_name, $content['extra']);
496 496
   }
497 497
 }
498 498
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
   $types = array();
539 539
   $content_info = _content_type_info();
540 540
   foreach ($content_info['content types'] as $type_name => $val) {
541
-    $types[$type_name] = check_plain($val['name']) .' ('. $type_name .')';
541
+    $types[$type_name] = check_plain($val['name']).' ('.$type_name.')';
542 542
   }
543 543
   return $types;
544 544
 }
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
       // The display settings are being fetched directly from the DB. During import,
582 582
       // we'll re-insert the data directly as well.
583 583
       //
584
-      $query = 'SELECT display_settings FROM {'. content_instance_tablename() .'} WHERE field_name = \'%s\'';
584
+      $query = 'SELECT display_settings FROM {'.content_instance_tablename().'} WHERE field_name = \'%s\'';
585 585
       $row_info = db_fetch_array(db_query($query, $field_name));
586 586
 
587 587
       // If an error occurs, notify the user.
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
   $string = "";
615 615
   if (array_key_exists('submissions', $GLOBALS['content_copy'])) {
616 616
     foreach ($GLOBALS['content_copy']['submissions'] as $form_type => $form) {
617
-      $string .= "\$content['$form_type']  = ". var_export((array) $form, TRUE) .";\n";
617
+      $string .= "\$content['$form_type']  = ".var_export((array)$form, TRUE).";\n";
618 618
     }
619 619
     return $string;
620 620
   }
Please login to merge, or discard this patch.
Braces   +7 added lines, -11 removed lines patch added patch discarded remove patch
@@ -182,7 +182,8 @@  discard block
 block discarded – undo
182 182
       break;
183 183
   }
184 184
 
185
-  if ($step < 3) {  // Omit submit button on the textarea block to display the export data.
185
+  if ($step < 3) {
186
+// Omit submit button on the textarea block to display the export data.
186 187
     $form['submit'] = array(
187 188
       '#type' => 'submit',
188 189
       '#value' => t('Export'),
@@ -374,8 +375,7 @@  discard block
 block discarded – undo
374 375
   $imported_groups = array();
375 376
   if (isset($content['groups']) && module_exists('fieldgroup')) {
376 377
     $imported_groups = (array) $content['groups'];
377
-  }
378
-  elseif (isset($content['groups']) && is_array($content['groups'])) {
378
+  } elseif (isset($content['groups']) && is_array($content['groups'])) {
379 379
     $not_enabled[] = 'fieldgroup';
380 380
   }
381 381
 
@@ -384,8 +384,7 @@  discard block
 block discarded – undo
384 384
     $field = content_field_instance_collapse($import);
385 385
     if (empty($field['module']) || empty($field['widget_module'])) {
386 386
       $not_enabled[] = $field['field_name'];
387
-    }
388
-    else {
387
+    } else {
389 388
       if (!module_exists($field['module'])) {
390 389
         $not_enabled[] = $field['module'];
391 390
       }
@@ -466,8 +465,7 @@  discard block
 block discarded – undo
466 465
     if (!empty($field['field_name']) && isset($content_info['content types'][$type_name]['fields'][$field_name])) {
467 466
       drupal_set_message(t('The imported field %field_label (%field_name) was not added to %type because that field already exists in %type.', array(
468 467
         '%field_label' => $field['label'], '%field_name' => $field_name, '%type' => $type_label)));
469
-    }
470
-    else {
468
+    } else {
471 469
       $field = content_field_instance_create($field, FALSE);
472 470
       $rebuild = TRUE;
473 471
       drupal_set_message(t('The field %field_label (%field_name) was added to the content type %type.', array(
@@ -573,8 +571,7 @@  discard block
 block discarded – undo
573 571
       if (isset($edit['field_widget_type'])) {
574 572
         $tmp = explode('-', $edit['field_widget_type']);
575 573
         $field_name = $tmp[0];
576
-      }
577
-      else {
574
+      } else {
578 575
         $field_name = isset($edit['field_name']) ? $edit['field_name'] : '';
579 576
       }
580 577
 
@@ -590,8 +587,7 @@  discard block
 block discarded – undo
590 587
              '%field_name' => $field_name,
591 588
              '%db_err' => $db_err
592 589
         )));
593
-      }
594
-      else {
590
+      } else {
595 591
         // The db fetch occurred successfully, unserialize the data blob and
596 592
         // insert it into a new "display_settings" field of the data.
597 593
         if ($display_settings = unserialize($row_info['display_settings'])) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
   return array(
61 61
     'content_copy_export_form' => array(
62 62
       'template' => 'content_copy_export_form',
63
-      'arguments' => array('form' => NULL),
63
+      'arguments' => array('form' => null),
64 64
     ),
65 65
   );
66 66
 }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 }
199 199
 
200 200
 function content_copy_export_form_submit($form, &$form_state) {
201
-  $form_state['rebuild'] = TRUE;
201
+  $form_state['rebuild'] = true;
202 202
   $form_state['storage']['step'] = $form_state['values']['step'];
203 203
 }
204 204
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
   // Add weights of non-CCK fields.
266 266
   if ($extra = variable_get('content_extra_weights_'. $form_values['type_name'], array())) {
267
-    $output .= "\$content['extra']  = ". var_export((array) $extra, TRUE) .";\n";
267
+    $output .= "\$content['extra']  = ". var_export((array) $extra, true) .";\n";
268 268
   }
269 269
 
270 270
   return $output;
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     '#type' => 'textarea',
310 310
     '#rows' => 40,
311 311
     '#title' => t('Import data'),
312
-    '#required' => TRUE,
312
+    '#required' => true,
313 313
     '#description' => t('Paste the text created by a content export into this field.'),
314 314
   );
315 315
   $form['submit'] = array(
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
   $type_name = $form_values['type_name'];
341 341
   $type_label = node_get_types('name', $type_name);
342 342
 
343
-  $content = NULL;
343
+  $content = null;
344 344
   // Convert the import formatted text back into a $content array.
345 345
   // Return if errors generated or not an array.
346 346
   // Use '@' to suppress errors about undefined constants in the macro.
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
     $type = (object) $imported_type;
423 423
     $values = $imported_type;
424 424
     // Prevent a warning in node/content_types.inc
425
-    $type->has_title = TRUE;
425
+    $type->has_title = true;
426 426
     $type_form_state = array('values' => $values);
427 427
 
428 428
     // There's no API for creating node types, we still have to use drupal_execute().
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
       fieldgroup_save_group($type_name, $group);
450 450
     }
451 451
     // Reset the static variable in fieldgroup_groups() with new data.
452
-    fieldgroup_groups('', FALSE, TRUE);
452
+    fieldgroup_groups('', false, true);
453 453
   }
454 454
 
455 455
   // Iterate through the field forms in the import and execute each.
456
-  $rebuild = FALSE;
456
+  $rebuild = false;
457 457
   foreach ($imported_fields as $field) {
458 458
 
459 459
     // Make sure the field doesn't already exist in the type.
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
         '%field_label' => $field['label'], '%field_name' => $field_name, '%type' => $type_label)));
469 469
     }
470 470
     else {
471
-      $field = content_field_instance_create($field, FALSE);
472
-      $rebuild = TRUE;
471
+      $field = content_field_instance_create($field, false);
472
+      $rebuild = true;
473 473
       drupal_set_message(t('The field %field_label (%field_name) was added to the content type %type.', array(
474 474
         '%field_label' => $field['widget']['label'], '%field_name' => $field_name, '%type' => $type_label)));
475 475
     }
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 
487 487
   // Clear caches and rebuild menu only if any field has been created.
488 488
   if ($rebuild) {
489
-    content_clear_type_cache(TRUE);
489
+    content_clear_type_cache(true);
490 490
     menu_rebuild();
491 491
   }
492 492
 
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
   $string = "";
615 615
   if (array_key_exists('submissions', $GLOBALS['content_copy'])) {
616 616
     foreach ($GLOBALS['content_copy']['submissions'] as $form_type => $form) {
617
-      $string .= "\$content['$form_type']  = ". var_export((array) $form, TRUE) .";\n";
617
+      $string .= "\$content['$form_type']  = ". var_export((array) $form, true) .";\n";
618 618
     }
619 619
     return $string;
620 620
   }
Please login to merge, or discard this patch.
boinc/modules/contrib/cck/modules/nodereference/nodereference.module 6 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -788,7 +788,7 @@
 block discarded – undo
788 788
  * @param $ids
789 789
  *   Optional node ids to lookup (the $string and $match arguments will be
790 790
  *   ignored).
791
- * @param $limit
791
+ * @param integer $limit
792 792
  *   If non-zero, limit the size of the result set.
793 793
  *
794 794
  * @return
Please login to merge, or discard this patch.
Indentation   +360 added lines, -360 removed lines patch added patch discarded remove patch
@@ -10,230 +10,230 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_menu().
11 11
  */
12 12
 function nodereference_menu() {
13
-  $items = array();
14
-  $items['nodereference/autocomplete'] = array(
13
+    $items = array();
14
+    $items['nodereference/autocomplete'] = array(
15 15
     'title' => 'Nodereference autocomplete',
16 16
     'page callback' => 'nodereference_autocomplete',
17 17
     'access callback' => 'nodereference_autocomplete_access',
18 18
     'access arguments' => array(2),
19 19
     'type' => MENU_CALLBACK
20
-  );
21
-  return $items;
20
+    );
21
+    return $items;
22 22
 }
23 23
 
24 24
 /**
25 25
  * Implementation of hook_theme().
26 26
  */
27 27
 function nodereference_theme() {
28
-  return array(
28
+    return array(
29 29
     'nodereference_select' => array(
30
-      'arguments' => array('element' => NULL),
30
+        'arguments' => array('element' => NULL),
31 31
     ),
32 32
     'nodereference_buttons' => array(
33
-      'arguments' => array('element' => NULL),
33
+        'arguments' => array('element' => NULL),
34 34
     ),
35 35
     'nodereference_autocomplete' => array(
36
-      'arguments' => array('element' => NULL),
36
+        'arguments' => array('element' => NULL),
37 37
     ),
38 38
     'nodereference_formatter_default' => array(
39
-      'arguments' => array('element'),
39
+        'arguments' => array('element'),
40 40
     ),
41 41
     'nodereference_formatter_plain' => array(
42
-      'arguments' => array('element'),
42
+        'arguments' => array('element'),
43 43
     ),
44 44
     'nodereference_formatter_full' => array(
45
-      'arguments' => array('element'),
46
-      'function' => 'theme_nodereference_formatter_full_teaser',
45
+        'arguments' => array('element'),
46
+        'function' => 'theme_nodereference_formatter_full_teaser',
47 47
     ),
48 48
     'nodereference_formatter_teaser' => array(
49
-      'arguments' => array('element'),
50
-      'function' => 'theme_nodereference_formatter_full_teaser',
49
+        'arguments' => array('element'),
50
+        'function' => 'theme_nodereference_formatter_full_teaser',
51 51
     ),
52
-  );
52
+    );
53 53
 }
54 54
 
55 55
 /**
56 56
  * Implementaion of hook_ctools_plugin_directory().
57 57
  */
58 58
 function nodereference_ctools_plugin_directory($module, $plugin) {
59
-  if ($module == 'ctools' && $plugin == 'relationships') {
59
+    if ($module == 'ctools' && $plugin == 'relationships') {
60 60
     return 'panels/' . $plugin;
61
-  }
61
+    }
62 62
 }
63 63
 
64 64
 /**
65 65
  * Implementation of hook_field_info().
66 66
  */
67 67
 function nodereference_field_info() {
68
-  return array(
68
+    return array(
69 69
     'nodereference' => array(
70
-      'label' => t('Node reference'),
71
-      'description' => t('Store the ID of a related node as an integer value.'),
70
+        'label' => t('Node reference'),
71
+        'description' => t('Store the ID of a related node as an integer value.'),
72 72
 //      'content_icon' => 'icon_content_noderef.png',
73 73
     ),
74
-  );
74
+    );
75 75
 }
76 76
 
77 77
 /**
78 78
  * Implementation of hook_field_settings().
79 79
  */
80 80
 function nodereference_field_settings($op, $field) {
81
-  switch ($op) {
81
+    switch ($op) {
82 82
     case 'form':
83 83
       $form = array();
84
-      $form['referenceable_types'] = array(
84
+        $form['referenceable_types'] = array(
85 85
         '#type' => 'checkboxes',
86 86
         '#title' => t('Content types that can be referenced'),
87 87
         '#multiple' => TRUE,
88 88
         '#default_value' => is_array($field['referenceable_types']) ? $field['referenceable_types'] : array(),
89 89
         '#options' => array_map('check_plain', node_get_types('names')),
90
-      );
91
-      if (module_exists('views')) {
90
+        );
91
+        if (module_exists('views')) {
92 92
         $views = array('--' => '--');
93 93
         $all_views = views_get_all_views();
94 94
         foreach ($all_views as $view) {
95
-          // Only 'node' views that have fields will work for our purpose.
96
-          if ($view->base_table == 'node' && !empty($view->display['default']->display_options['fields'])) {
95
+            // Only 'node' views that have fields will work for our purpose.
96
+            if ($view->base_table == 'node' && !empty($view->display['default']->display_options['fields'])) {
97 97
             if ($view->type == 'Default') {
98
-              $views[t('Default Views')][$view->name] = $view->name;
98
+                $views[t('Default Views')][$view->name] = $view->name;
99 99
             }
100 100
             else {
101
-              $views[t('Existing Views')][$view->name] = $view->name;
101
+                $views[t('Existing Views')][$view->name] = $view->name;
102
+            }
102 103
             }
103
-          }
104 104
         }
105 105
 
106 106
         $form['advanced'] = array(
107
-           '#type' => 'fieldset',
108
-           '#title' => t('Advanced - Nodes that can be referenced (View)'),
109
-           '#collapsible' => TRUE,
110
-           '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
111
-         );
107
+            '#type' => 'fieldset',
108
+            '#title' => t('Advanced - Nodes that can be referenced (View)'),
109
+            '#collapsible' => TRUE,
110
+            '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
111
+            );
112 112
         if (count($views) > 1) {
113
-          $form['advanced']['advanced_view'] = array(
113
+            $form['advanced']['advanced_view'] = array(
114 114
             '#type' => 'select',
115 115
             '#title' => t('View used to select the nodes'),
116 116
             '#options' => $views,
117 117
             '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
118 118
             '#description' => t('<p>Choose the "Views module" view that selects the nodes that can be referenced.<br />Note:</p>') .
119
-              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>'),
120
-          );
121
-          $form['advanced']['advanced_view_args'] = array(
119
+                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>'),
120
+            );
121
+            $form['advanced']['advanced_view_args'] = array(
122 122
             '#type' => 'textfield',
123 123
             '#title' => t('View arguments'),
124 124
             '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
125 125
             '#required' => FALSE,
126 126
             '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
127
-          );
127
+            );
128 128
         }
129 129
         else {
130
-          $form['advanced']['no_view_help'] = array(
130
+            $form['advanced']['no_view_help'] = array(
131 131
             '#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
-              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>'),
133
-          );
132
+                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>'),
133
+            );
134 134
         }
135
-      }
136
-      return $form;
135
+        }
136
+        return $form;
137 137
 
138 138
     case 'save':
139 139
       $settings = array('referenceable_types');
140
-      if (module_exists('views')) {
140
+        if (module_exists('views')) {
141 141
         $settings[] = 'advanced_view';
142 142
         $settings[] = 'advanced_view_args';
143
-      }
144
-      return $settings;
143
+        }
144
+        return $settings;
145 145
 
146 146
     case 'database columns':
147 147
       $columns = array(
148 148
         'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
149
-      );
150
-      return $columns;
149
+        );
150
+        return $columns;
151 151
 
152 152
     case 'views data':
153 153
       $data = content_views_field_views_data($field);
154
-      $db_info = content_database_info($field);
155
-      $table_alias = content_views_tablename($field);
154
+        $db_info = content_database_info($field);
155
+        $table_alias = content_views_tablename($field);
156 156
 
157
-      // Filter: swap the handler to the 'in' operator.
158
-      $data[$table_alias][$field['field_name'] .'_nid']['filter']['handler'] = 'content_handler_filter_many_to_one';
159
-      // Argument: use node.title for summaries.
160
-      $data["node_$table_alias"]['table']['join']['node'] = array(
157
+        // Filter: swap the handler to the 'in' operator.
158
+        $data[$table_alias][$field['field_name'] .'_nid']['filter']['handler'] = 'content_handler_filter_many_to_one';
159
+        // Argument: use node.title for summaries.
160
+        $data["node_$table_alias"]['table']['join']['node'] = array(
161 161
         'table' => 'node',
162 162
         'field' => 'nid',
163 163
         'left_table' => $table_alias,
164 164
         'left_field' => $field['field_name'] .'_nid',
165
-      );
166
-      $data[$table_alias][$field['field_name'] .'_nid']['argument']['handler'] = 'content_handler_argument_reference';
167
-      $data[$table_alias][$field['field_name'] .'_nid']['argument']['name table'] = "node_$table_alias";
168
-      $data[$table_alias][$field['field_name'] .'_nid']['argument']['name field'] = 'title';
169
-      // Relationship: add a relationship for related node.
170
-      $data[$table_alias][$field['field_name'] .'_nid']['relationship'] = array(
165
+        );
166
+        $data[$table_alias][$field['field_name'] .'_nid']['argument']['handler'] = 'content_handler_argument_reference';
167
+        $data[$table_alias][$field['field_name'] .'_nid']['argument']['name table'] = "node_$table_alias";
168
+        $data[$table_alias][$field['field_name'] .'_nid']['argument']['name field'] = 'title';
169
+        // Relationship: add a relationship for related node.
170
+        $data[$table_alias][$field['field_name'] .'_nid']['relationship'] = array(
171 171
         'base' => 'node',
172 172
         'field' => $db_info['columns']['nid']['column'],
173 173
         'handler' => 'content_handler_relationship',
174 174
         'label' => t($field['widget']['label']),
175 175
         'content_field_name' => $field['field_name'],
176
-      );
177
-      return $data;
178
-  }
176
+        );
177
+        return $data;
178
+    }
179 179
 }
180 180
 
181 181
 /**
182 182
  * Implementation of hook_field().
183 183
  */
184 184
 function nodereference_field($op, &$node, $field, &$items, $teaser, $page) {
185
-  static $sanitized_nodes = array();
185
+    static $sanitized_nodes = array();
186 186
   
187
-  switch ($op) {
187
+    switch ($op) {
188 188
     // When preparing a translation, load any translations of existing references.
189 189
     case 'prepare translation':
190 190
       $addition = array();
191
-      $addition[$field['field_name']] = array();
192
-      if (isset($node->translation_source->$field['field_name']) && is_array($node->translation_source->$field['field_name'])) {
191
+        $addition[$field['field_name']] = array();
192
+        if (isset($node->translation_source->$field['field_name']) && is_array($node->translation_source->$field['field_name'])) {
193 193
         foreach ($node->translation_source->$field['field_name'] as $key => $reference) {
194
-          $reference_node = node_load($reference['nid']);
195
-          // Test if the referenced node type is translatable and, if so,
196
-          // load translations if the reference is not for the current language.
197
-          // We can assume the translation module is present because it invokes 'prepare translation'.
198
-          if (translation_supported_type($reference_node->type) && !empty($reference_node->language) && $reference_node->language != $node->language && $translations = translation_node_get_translations($reference_node->tnid)) {
194
+            $reference_node = node_load($reference['nid']);
195
+            // Test if the referenced node type is translatable and, if so,
196
+            // load translations if the reference is not for the current language.
197
+            // We can assume the translation module is present because it invokes 'prepare translation'.
198
+            if (translation_supported_type($reference_node->type) && !empty($reference_node->language) && $reference_node->language != $node->language && $translations = translation_node_get_translations($reference_node->tnid)) {
199 199
             // If there is a translation for the current language, use it.
200 200
             $addition[$field['field_name']][] = array(
201
-              'nid' => isset($translations[$node->language]) ? $translations[$node->language]->nid : $reference['nid'],
201
+                'nid' => isset($translations[$node->language]) ? $translations[$node->language]->nid : $reference['nid'],
202 202
             );
203
-          }
203
+            }
204
+        }
204 205
         }
205
-      }
206
-      return $addition;
206
+        return $addition;
207 207
 
208 208
     case 'validate':
209 209
       // Extract nids to check.
210 210
       $ids = array();
211
-      foreach ($items as $delta => $item) {
211
+        foreach ($items as $delta => $item) {
212 212
         if (is_array($item) && !empty($item['nid'])) {
213
-          if (is_numeric($item['nid'])) {
213
+            if (is_numeric($item['nid'])) {
214 214
             $ids[] = $item['nid'];
215
-          }
216
-          else {
215
+            }
216
+            else {
217 217
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
218 218
             if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
219 219
             form_set_error($error_element, t("%name: invalid input.", array('%name' => t($field['widget']['label']))));
220
-          }
220
+            }
221
+        }
221 222
         }
222
-      }
223
-      // Prevent performance hog if there are no ids to check.
224
-      if ($ids) {
223
+        // Prevent performance hog if there are no ids to check.
224
+        if ($ids) {
225 225
         $refs = _nodereference_potential_references($field, '', NULL, $ids);
226 226
         foreach ($items as $delta => $item) {
227
-          if (is_array($item)) {
227
+            if (is_array($item)) {
228 228
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
229 229
             if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
230 230
             if (!empty($item['nid']) && !isset($refs[$item['nid']])) {
231
-              form_set_error($error_element, t("%name: this post can't be referenced.", array('%name' => t($field['widget']['label']))));
231
+                form_set_error($error_element, t("%name: this post can't be referenced.", array('%name' => t($field['widget']['label']))));
232 232
             }
233
-          }
233
+            }
234
+        }
234 235
         }
235
-      }
236
-      return $items;
236
+        return $items;
237 237
 
238 238
     case 'sanitize':
239 239
       // We can't just check the node is 'referenceable', because Views-mode
@@ -241,133 +241,133 @@  discard block
 block discarded – undo
241 241
 
242 242
       // Extract nids to check.
243 243
       $ids = array();
244
-      foreach ($items as $delta => $item) {
244
+        foreach ($items as $delta => $item) {
245 245
         if (is_array($item)) {
246
-          // Default to 'non accessible'.
247
-          $items[$delta]['safe'] = array();
248
-          if (!empty($item['nid']) && is_numeric($item['nid'])) {
246
+            // Default to 'non accessible'.
247
+            $items[$delta]['safe'] = array();
248
+            if (!empty($item['nid']) && is_numeric($item['nid'])) {
249 249
             $ids[] = $item['nid'];
250
-          }
250
+            }
251
+        }
251 252
         }
252
-      }
253
-      if ($ids) {
253
+        if ($ids) {
254 254
         // Load information about nids that we haven't already loaded during
255 255
         // this page request.
256 256
         $missing_ids = array_diff($ids, array_keys($sanitized_nodes));
257 257
         if (!empty($missing_ids)) {
258
-          $where = array('n.nid in ('. db_placeholders($missing_ids) . ')');
259
-          if (!user_access('administer nodes')) {
258
+            $where = array('n.nid in ('. db_placeholders($missing_ids) . ')');
259
+            if (!user_access('administer nodes')) {
260 260
             $where[] = 'n.status = 1';
261
-          }
262
-          $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status FROM {node} n WHERE '. implode(' AND ', $where)), $missing_ids);
263
-          while ($row = db_fetch_array($result)) {
261
+            }
262
+            $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status FROM {node} n WHERE '. implode(' AND ', $where)), $missing_ids);
263
+            while ($row = db_fetch_array($result)) {
264 264
             $sanitized_nodes[$row['nid']] = $row;
265
-          }
265
+            }
266 266
         }
267 267
         foreach ($items as $delta => $item) {
268
-          if (is_array($item) && !empty($item['nid']) && isset($sanitized_nodes[$item['nid']])) {
268
+            if (is_array($item) && !empty($item['nid']) && isset($sanitized_nodes[$item['nid']])) {
269 269
             $items[$delta]['safe'] = $sanitized_nodes[$item['nid']];
270
-          }
270
+            }
271
+        }
271 272
         }
272
-      }
273
-      return $items;
274
-  }
273
+        return $items;
274
+    }
275 275
 }
276 276
 
277 277
 /**
278 278
  * Implementation of hook_content_is_empty().
279 279
  */
280 280
 function nodereference_content_is_empty($item, $field) {
281
-  if (empty($item['nid'])) {
281
+    if (empty($item['nid'])) {
282 282
     return TRUE;
283
-  }
284
-  return FALSE;
283
+    }
284
+    return FALSE;
285 285
 }
286 286
 
287 287
 /**
288 288
  * Implementation of hook_field_formatter_info().
289 289
  */
290 290
 function nodereference_field_formatter_info() {
291
-  return array(
291
+    return array(
292 292
     'default' => array(
293
-      'label' => t('Title (link)'),
294
-      'field types' => array('nodereference'),
295
-      'multiple values' => CONTENT_HANDLE_CORE,
293
+        'label' => t('Title (link)'),
294
+        'field types' => array('nodereference'),
295
+        'multiple values' => CONTENT_HANDLE_CORE,
296 296
     ),
297 297
     'plain' => array(
298
-      'label' => t('Title (no link)'),
299
-      'field types' => array('nodereference'),
300
-      'multiple values' => CONTENT_HANDLE_CORE,
298
+        'label' => t('Title (no link)'),
299
+        'field types' => array('nodereference'),
300
+        'multiple values' => CONTENT_HANDLE_CORE,
301 301
     ),
302 302
     'full' => array(
303
-      'label' => t('Full node'),
304
-      'field types' => array('nodereference'),
305
-      'multiple values' => CONTENT_HANDLE_CORE,
303
+        'label' => t('Full node'),
304
+        'field types' => array('nodereference'),
305
+        'multiple values' => CONTENT_HANDLE_CORE,
306 306
     ),
307 307
     'teaser' => array(
308
-      'label' => t('Teaser'),
309
-      'field types' => array('nodereference'),
310
-      'multiple values' => CONTENT_HANDLE_CORE,
308
+        'label' => t('Teaser'),
309
+        'field types' => array('nodereference'),
310
+        'multiple values' => CONTENT_HANDLE_CORE,
311 311
     ),
312
-  );
312
+    );
313 313
 }
314 314
 
315 315
 /**
316 316
  * Theme function for 'default' nodereference field formatter.
317 317
  */
318 318
 function theme_nodereference_formatter_default($element) {
319
-  $output = '';
320
-  if (!empty($element['#item']['safe']['nid'])) {
319
+    $output = '';
320
+    if (!empty($element['#item']['safe']['nid'])) {
321 321
     $output = l($element['#item']['safe']['title'], 'node/'. $element['#item']['safe']['nid']);
322 322
     if (!$element['#item']['safe']['status']) {
323
-      $output = '<span class="node-unpublished"> '. t('(Unpublished)') ." $output</span>";
323
+        $output = '<span class="node-unpublished"> '. t('(Unpublished)') ." $output</span>";
324 324
     }
325
-  }
326
-  return $output;
325
+    }
326
+    return $output;
327 327
 }
328 328
 
329 329
 /**
330 330
  * Theme function for 'plain' nodereference field formatter.
331 331
  */
332 332
 function theme_nodereference_formatter_plain($element) {
333
-  $output = '';
334
-  if (!empty($element['#item']['safe']['nid'])) {
333
+    $output = '';
334
+    if (!empty($element['#item']['safe']['nid'])) {
335 335
     $output = check_plain($element['#item']['safe']['title']);
336 336
     if (!$element['#item']['safe']['status']) {
337
-      $output = '<span class="node-unpublished"> '. t('(Unpublished)') ." $output</span>";
337
+        $output = '<span class="node-unpublished"> '. t('(Unpublished)') ." $output</span>";
338
+    }
338 339
     }
339
-  }
340
-  return $output;
340
+    return $output;
341 341
 }
342 342
 
343 343
 /**
344 344
  * Proxy theme function for 'full' and 'teaser' nodereference field formatters.
345 345
  */
346 346
 function theme_nodereference_formatter_full_teaser($element) {
347
-  static $recursion_queue = array();
348
-  $output = '';
349
-  if (!empty($element['#item']['safe']['nid'])) {
347
+    static $recursion_queue = array();
348
+    $output = '';
349
+    if (!empty($element['#item']['safe']['nid'])) {
350 350
     $nid = $element['#item']['safe']['nid'];
351 351
     $node = $element['#node'];
352 352
     $field = content_fields($element['#field_name'], $element['#type_name']);
353 353
     // If no 'referencing node' is set, we are starting a new 'reference thread'
354 354
     if (!isset($node->referencing_node)) {
355
-      $recursion_queue = array();
355
+        $recursion_queue = array();
356 356
     }
357 357
     $recursion_queue[] = $node->nid;
358 358
     if (in_array($nid, $recursion_queue)) {
359
-      // Prevent infinite recursion caused by reference cycles:
360
-      // if the node has already been rendered earlier in this 'thread',
361
-      // we fall back to 'default' (node title) formatter.
362
-      return theme('nodereference_formatter_default', $element);
359
+        // Prevent infinite recursion caused by reference cycles:
360
+        // if the node has already been rendered earlier in this 'thread',
361
+        // we fall back to 'default' (node title) formatter.
362
+        return theme('nodereference_formatter_default', $element);
363 363
     }
364 364
     if ($referenced_node = node_load($nid)) {
365
-      $referenced_node->referencing_node = $node;
366
-      $referenced_node->referencing_field = $field;
367
-      $output = node_view($referenced_node, $element['#formatter'] == 'teaser');
365
+        $referenced_node->referencing_node = $node;
366
+        $referenced_node->referencing_field = $field;
367
+        $output = node_view($referenced_node, $element['#formatter'] == 'teaser');
368
+    }
368 369
     }
369
-  }
370
-  return $output;
370
+    return $output;
371 371
 }
372 372
 
373 373
 /**
@@ -376,12 +376,12 @@  discard block
 block discarded – undo
376 376
  * Store node titles collected in the curent request.
377 377
  */
378 378
 function _nodereference_titles($nid, $known_title = NULL) {
379
-  static $titles = array();
380
-  if (!isset($titles[$nid])) {
379
+    static $titles = array();
380
+    if (!isset($titles[$nid])) {
381 381
     $title = $known_title ? $known_title : db_result(db_query(db_rewrite_sql("SELECT n.title FROM {node} n WHERE n.nid=%d"), $nid));
382 382
     $titles[$nid] = $title ? $title : '';
383
-  }
384
-  return $titles[$nid];
383
+    }
384
+    return $titles[$nid];
385 385
 }
386 386
 
387 387
 /**
@@ -399,32 +399,32 @@  discard block
 block discarded – undo
399 399
  * differently.
400 400
  */
401 401
 function nodereference_widget_info() {
402
-  return array(
402
+    return array(
403 403
     'nodereference_select' => array(
404
-      'label' => t('Select list'),
405
-      'field types' => array('nodereference'),
406
-      'multiple values' => CONTENT_HANDLE_MODULE,
407
-      'callbacks' => array(
404
+        'label' => t('Select list'),
405
+        'field types' => array('nodereference'),
406
+        'multiple values' => CONTENT_HANDLE_MODULE,
407
+        'callbacks' => array(
408 408
         'default value' => CONTENT_CALLBACK_DEFAULT,
409
-      ),
409
+        ),
410 410
     ),
411 411
     'nodereference_buttons' => array(
412
-      'label' => t('Check boxes/radio buttons'),
413
-      'field types' => array('nodereference'),
414
-      'multiple values' => CONTENT_HANDLE_MODULE,
415
-      'callbacks' => array(
412
+        'label' => t('Check boxes/radio buttons'),
413
+        'field types' => array('nodereference'),
414
+        'multiple values' => CONTENT_HANDLE_MODULE,
415
+        'callbacks' => array(
416 416
         'default value' => CONTENT_CALLBACK_DEFAULT,
417
-      ),
417
+        ),
418 418
     ),
419 419
     'nodereference_autocomplete' => array(
420
-      'label' => t('Autocomplete text field'),
421
-      'field types' => array('nodereference'),
422
-      'multiple values' => CONTENT_HANDLE_CORE,
423
-      'callbacks' => array(
420
+        'label' => t('Autocomplete text field'),
421
+        'field types' => array('nodereference'),
422
+        'multiple values' => CONTENT_HANDLE_CORE,
423
+        'callbacks' => array(
424 424
         'default value' => CONTENT_CALLBACK_DEFAULT,
425
-      ),
425
+        ),
426 426
     ),
427
-  );
427
+    );
428 428
 }
429 429
 
430 430
 /**
@@ -440,23 +440,23 @@  discard block
 block discarded – undo
440 440
  * (see nodereference and userreference).
441 441
  */
442 442
 function nodereference_elements() {
443
-  return array(
443
+    return array(
444 444
     'nodereference_select' => array(
445
-      '#input' => TRUE,
446
-      '#columns' => array('uid'), '#delta' => 0,
447
-      '#process' => array('nodereference_select_process'),
445
+        '#input' => TRUE,
446
+        '#columns' => array('uid'), '#delta' => 0,
447
+        '#process' => array('nodereference_select_process'),
448 448
     ),
449 449
     'nodereference_buttons' => array(
450
-      '#input' => TRUE,
451
-      '#columns' => array('uid'), '#delta' => 0,
452
-      '#process' => array('nodereference_buttons_process'),
450
+        '#input' => TRUE,
451
+        '#columns' => array('uid'), '#delta' => 0,
452
+        '#process' => array('nodereference_buttons_process'),
453 453
     ),
454 454
     'nodereference_autocomplete' => array(
455
-      '#input' => TRUE,
456
-      '#columns' => array('name'), '#delta' => 0,
457
-      '#process' => array('nodereference_autocomplete_process'),
458
-      '#autocomplete_path' => FALSE,
459
-      ),
455
+        '#input' => TRUE,
456
+        '#columns' => array('name'), '#delta' => 0,
457
+        '#process' => array('nodereference_autocomplete_process'),
458
+        '#autocomplete_path' => FALSE,
459
+        ),
460 460
     );
461 461
 }
462 462
 
@@ -464,39 +464,39 @@  discard block
 block discarded – undo
464 464
  * Implementation of hook_widget_settings().
465 465
  */
466 466
 function nodereference_widget_settings($op, $widget) {
467
-  switch ($op) {
467
+    switch ($op) {
468 468
     case 'form':
469 469
       $form = array();
470
-      $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
471
-      $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
472
-      if ($widget['type'] == 'nodereference_autocomplete') {
470
+        $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
471
+        $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
472
+        if ($widget['type'] == 'nodereference_autocomplete') {
473 473
         $form['autocomplete_match'] = array(
474
-          '#type' => 'select',
475
-          '#title' => t('Autocomplete matching'),
476
-          '#default_value' => $match,
477
-          '#options' => array(
474
+            '#type' => 'select',
475
+            '#title' => t('Autocomplete matching'),
476
+            '#default_value' => $match,
477
+            '#options' => array(
478 478
             'starts_with' => t('Starts with'),
479 479
             'contains' => t('Contains'),
480
-          ),
481
-          '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of nodes.'),
480
+            ),
481
+            '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of nodes.'),
482 482
         );
483 483
         $form['size'] = array(
484
-          '#type' => 'textfield',
485
-          '#title' => t('Size of textfield'),
486
-          '#default_value' => $size,
487
-          '#element_validate' => array('_element_validate_integer_positive'),
488
-          '#required' => TRUE,
484
+            '#type' => 'textfield',
485
+            '#title' => t('Size of textfield'),
486
+            '#default_value' => $size,
487
+            '#element_validate' => array('_element_validate_integer_positive'),
488
+            '#required' => TRUE,
489 489
         );
490
-      }
491
-      else {
490
+        }
491
+        else {
492 492
         $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
493 493
         $form['size'] = array('#type' => 'hidden', '#value' => $size);
494
-      }
495
-      return $form;
494
+        }
495
+        return $form;
496 496
 
497 497
     case 'save':
498 498
       return array('autocomplete_match', 'size');
499
-  }
499
+    }
500 500
 }
501 501
 
502 502
 /**
@@ -531,30 +531,30 @@  discard block
 block discarded – undo
531 531
  *   the form item for a single element for this field
532 532
  */
533 533
 function nodereference_widget(&$form, &$form_state, $field, $items, $delta = 0) {
534
-  switch ($field['widget']['type']) {
534
+    switch ($field['widget']['type']) {
535 535
     case 'nodereference_select':
536 536
       $element = array(
537 537
         '#type' => 'nodereference_select',
538 538
         '#default_value' => $items,
539
-      );
540
-      break;
539
+        );
540
+        break;
541 541
 
542 542
     case 'nodereference_buttons':
543 543
       $element = array(
544 544
         '#type' => 'nodereference_buttons',
545 545
         '#default_value' => $items,
546
-      );
547
-      break;
546
+        );
547
+        break;
548 548
 
549 549
     case 'nodereference_autocomplete':
550 550
       $element = array(
551 551
         '#type' => 'nodereference_autocomplete',
552 552
         '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
553 553
         '#value_callback' => 'nodereference_autocomplete_value',
554
-      );
555
-      break;
556
-  }
557
-  return $element;
554
+        );
555
+        break;
556
+    }
557
+    return $element;
558 558
 }
559 559
 
560 560
 /**
@@ -563,14 +563,14 @@  discard block
 block discarded – undo
563 563
  * Substitute in the node title for the node nid.
564 564
  */
565 565
 function nodereference_autocomplete_value($element, $edit = FALSE) {
566
-  $field_key  = $element['#columns'][0];
567
-  if (!empty($element['#default_value'][$field_key])) {
566
+    $field_key  = $element['#columns'][0];
567
+    if (!empty($element['#default_value'][$field_key])) {
568 568
     $nid = $element['#default_value'][$field_key];
569 569
     $value = db_result(db_query(db_rewrite_sql('SELECT n.title FROM {node} n WHERE n.nid = %d'), $nid));
570 570
     $value .= ' [nid:'. $nid .']';
571 571
     return array($field_key => $value);
572
-  }
573
-  return array($field_key => NULL);
572
+    }
573
+    return array($field_key => NULL);
574 574
 }
575 575
 
576 576
 /**
@@ -582,12 +582,12 @@  discard block
 block discarded – undo
582 582
  * The $fields array is in $form['#field_info'][$element['#field_name']].
583 583
  */
584 584
 function nodereference_select_process($element, $edit, $form_state, $form) {
585
-  // The nodereference_select widget doesn't need to create its own
586
-  // element, it can wrap around the optionwidgets_select element.
587
-  // This will create a new, nested instance of the field.
588
-  // Add a validation step where the value can be unwrapped.
589
-  $field_key  = $element['#columns'][0];
590
-  $element[$field_key] = array(
585
+    // The nodereference_select widget doesn't need to create its own
586
+    // element, it can wrap around the optionwidgets_select element.
587
+    // This will create a new, nested instance of the field.
588
+    // Add a validation step where the value can be unwrapped.
589
+    $field_key  = $element['#columns'][0];
590
+    $element[$field_key] = array(
591 591
     '#type' => 'optionwidgets_select',
592 592
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
593 593
     // The following values were set by the content module and need
@@ -599,12 +599,12 @@  discard block
 block discarded – undo
599 599
     '#type_name' => $element['#type_name'],
600 600
     '#delta' => $element['#delta'],
601 601
     '#columns' => $element['#columns'],
602
-  );
603
-  if (empty($element[$field_key]['#element_validate'])) {
602
+    );
603
+    if (empty($element[$field_key]['#element_validate'])) {
604 604
     $element[$field_key]['#element_validate'] = array();
605
-  }
606
-  array_unshift($element[$field_key]['#element_validate'], 'nodereference_optionwidgets_validate');
607
-  return $element;
605
+    }
606
+    array_unshift($element[$field_key]['#element_validate'], 'nodereference_optionwidgets_validate');
607
+    return $element;
608 608
 }
609 609
 
610 610
 /**
@@ -616,12 +616,12 @@  discard block
 block discarded – undo
616 616
  * The $fields array is in $form['#field_info'][$element['#field_name']].
617 617
  */
618 618
 function nodereference_buttons_process($element, $edit, $form_state, $form) {
619
-  // The nodereference_select widget doesn't need to create its own
620
-  // element, it can wrap around the optionwidgets_select element.
621
-  // This will create a new, nested instance of the field.
622
-  // Add a validation step where the value can be unwrapped.
623
-  $field_key  = $element['#columns'][0];
624
-  $element[$field_key] = array(
619
+    // The nodereference_select widget doesn't need to create its own
620
+    // element, it can wrap around the optionwidgets_select element.
621
+    // This will create a new, nested instance of the field.
622
+    // Add a validation step where the value can be unwrapped.
623
+    $field_key  = $element['#columns'][0];
624
+    $element[$field_key] = array(
625 625
     '#type' => 'optionwidgets_buttons',
626 626
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
627 627
     // The following values were set by the content module and need
@@ -633,12 +633,12 @@  discard block
 block discarded – undo
633 633
     '#type_name' => $element['#type_name'],
634 634
     '#delta' => $element['#delta'],
635 635
     '#columns' => $element['#columns'],
636
-  );
637
-  if (empty($element[$field_key]['#element_validate'])) {
636
+    );
637
+    if (empty($element[$field_key]['#element_validate'])) {
638 638
     $element[$field_key]['#element_validate'] = array();
639
-  }
640
-  array_unshift($element[$field_key]['#element_validate'], 'nodereference_optionwidgets_validate');
641
-  return $element;
639
+    }
640
+    array_unshift($element[$field_key]['#element_validate'], 'nodereference_optionwidgets_validate');
641
+    return $element;
642 642
 }
643 643
 
644 644
 /**
@@ -650,13 +650,13 @@  discard block
 block discarded – undo
650 650
  */
651 651
 function nodereference_autocomplete_process($element, $edit, $form_state, $form) {
652 652
 
653
-  // The nodereference autocomplete widget doesn't need to create its own
654
-  // element, it can wrap around the text_textfield element and add an autocomplete
655
-  // path and some extra processing to it.
656
-  // Add a validation step where the value can be unwrapped.
657
-  $field_key  = $element['#columns'][0];
653
+    // The nodereference autocomplete widget doesn't need to create its own
654
+    // element, it can wrap around the text_textfield element and add an autocomplete
655
+    // path and some extra processing to it.
656
+    // Add a validation step where the value can be unwrapped.
657
+    $field_key  = $element['#columns'][0];
658 658
 
659
-  $element[$field_key] = array(
659
+    $element[$field_key] = array(
660 660
     '#type' => 'text_textfield',
661 661
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
662 662
     '#autocomplete_path' => 'nodereference/autocomplete/'. $element['#field_name'],
@@ -669,20 +669,20 @@  discard block
 block discarded – undo
669 669
     '#type_name' => $element['#type_name'],
670 670
     '#delta' => $element['#delta'],
671 671
     '#columns' => $element['#columns'],
672
-  );
673
-  if (empty($element[$field_key]['#element_validate'])) {
672
+    );
673
+    if (empty($element[$field_key]['#element_validate'])) {
674 674
     $element[$field_key]['#element_validate'] = array();
675
-  }
676
-  array_unshift($element[$field_key]['#element_validate'], 'nodereference_autocomplete_validate');
675
+    }
676
+    array_unshift($element[$field_key]['#element_validate'], 'nodereference_autocomplete_validate');
677 677
 
678
-  // Used so that hook_field('validate') knows where to flag an error.
679
-  $element['_error_element'] = array(
678
+    // Used so that hook_field('validate') knows where to flag an error.
679
+    $element['_error_element'] = array(
680 680
     '#type' => 'value',
681 681
     // Wrapping the element around a text_textfield element creates a
682 682
     // nested element, so the final id will look like 'field-name-0-nid-nid'.
683 683
     '#value' => implode('][', array_merge($element['#parents'], array($field_key, $field_key))),
684
-  );
685
-  return $element;
684
+    );
685
+    return $element;
686 686
 }
687 687
 
688 688
 /**
@@ -697,20 +697,20 @@  discard block
 block discarded – undo
697 697
  * like optionwidgets are using #element_validate to alter the value.
698 698
  */
699 699
 function nodereference_optionwidgets_validate($element, &$form_state) {
700
-  $field_key  = $element['#columns'][0];
700
+    $field_key  = $element['#columns'][0];
701 701
 
702
-  $value = $form_state['values'];
703
-  $new_parents = array();
704
-  foreach ($element['#parents'] as $parent) {
702
+    $value = $form_state['values'];
703
+    $new_parents = array();
704
+    foreach ($element['#parents'] as $parent) {
705 705
     $value = $value[$parent];
706 706
     // Use === to be sure we get right results if parent is a zero (delta) value.
707 707
     if ($parent === $field_key) {
708
-      $element['#parents'] = $new_parents;
709
-      form_set_value($element, $value, $form_state);
710
-      break;
708
+        $element['#parents'] = $new_parents;
709
+        form_set_value($element, $value, $form_state);
710
+        break;
711 711
     }
712 712
     $new_parents[] = $parent;
713
-  }
713
+    }
714 714
 }
715 715
 
716 716
 /**
@@ -721,52 +721,52 @@  discard block
 block discarded – undo
721 721
  * back to its original location, 'field-name-0-nid'.
722 722
  */
723 723
 function nodereference_autocomplete_validate($element, &$form_state) {
724
-  $field_name = $element['#field_name'];
725
-  $type_name = $element['#type_name'];
726
-  $field = content_fields($field_name, $type_name);
727
-  $field_key  = $element['#columns'][0];
728
-  $delta = $element['#delta'];
729
-  $value = $element['#value'][$field_key];
730
-  $nid = NULL;
731
-  if (!empty($value)) {
724
+    $field_name = $element['#field_name'];
725
+    $type_name = $element['#type_name'];
726
+    $field = content_fields($field_name, $type_name);
727
+    $field_key  = $element['#columns'][0];
728
+    $delta = $element['#delta'];
729
+    $value = $element['#value'][$field_key];
730
+    $nid = NULL;
731
+    if (!empty($value)) {
732 732
     preg_match('/^(?:\s*|(.*) )?\[\s*nid\s*:\s*(\d+)\s*\]$/', $value, $matches);
733 733
     if (!empty($matches)) {
734
-      // Explicit [nid:n].
735
-      list(, $title, $nid) = $matches;
736
-      if (!empty($title) && ($n = node_load($nid)) && trim($title) != trim($n->title)) {
734
+        // Explicit [nid:n].
735
+        list(, $title, $nid) = $matches;
736
+        if (!empty($title) && ($n = node_load($nid)) && trim($title) != trim($n->title)) {
737 737
         form_error($element[$field_key], t('%name: title mismatch. Please check your selection.', array('%name' => t($field['widget']['label']))));
738
-      }
738
+        }
739 739
     }
740 740
     else {
741
-      // No explicit nid.
742
-      $reference = _nodereference_potential_references($field, $value, 'equals', NULL, 1);
743
-      if (empty($reference)) {
741
+        // No explicit nid.
742
+        $reference = _nodereference_potential_references($field, $value, 'equals', NULL, 1);
743
+        if (empty($reference)) {
744 744
         form_error($element[$field_key], t('%name: found no valid post with that title.', array('%name' => t($field['widget']['label']))));
745
-      }
746
-      else {
745
+        }
746
+        else {
747 747
         // TODO:
748 748
         // the best thing would be to present the user with an additional form,
749 749
         // allowing the user to choose between valid candidates with the same title
750 750
         // ATM, we pick the first matching candidate...
751 751
         $nid = key($reference);
752
-      }
752
+        }
753 753
     }
754
-  }
755
-  form_set_value($element, $nid, $form_state);
754
+    }
755
+    form_set_value($element, $nid, $form_state);
756 756
 }
757 757
 
758 758
 /**
759 759
  * Implementation of hook_allowed_values().
760 760
  */
761 761
 function nodereference_allowed_values($field) {
762
-  $references = _nodereference_potential_references($field);
762
+    $references = _nodereference_potential_references($field);
763 763
 
764
-  $options = array();
765
-  foreach ($references as $key => $value) {
764
+    $options = array();
765
+    foreach ($references as $key => $value) {
766 766
     $options[$key] = $value['rendered'];
767
-  }
767
+    }
768 768
 
769
-  return $options;
769
+    return $options;
770 770
 }
771 771
 
772 772
 /**
@@ -802,26 +802,26 @@  discard block
 block discarded – undo
802 802
  *   )
803 803
  */
804 804
 function _nodereference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
805
-  static $results = array();
805
+    static $results = array();
806 806
 
807
-  // Create unique id for static cache.
808
-  $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
809
-  if (!isset($results[$cid])) {
807
+    // Create unique id for static cache.
808
+    $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
809
+    if (!isset($results[$cid])) {
810 810
     $references = FALSE;
811 811
     if (module_exists('views') && !empty($field['advanced_view']) && $field['advanced_view'] != '--') {
812
-      $references = _nodereference_potential_references_views($field, $string, $match, $ids, $limit);
812
+        $references = _nodereference_potential_references_views($field, $string, $match, $ids, $limit);
813 813
     }
814 814
     // If the view doesn't exist, we got FALSE, and fallback to the regular 'standard mode'.
815 815
 
816 816
     if ($references === FALSE) {
817
-      $references = _nodereference_potential_references_standard($field, $string, $match, $ids, $limit);
817
+        $references = _nodereference_potential_references_standard($field, $string, $match, $ids, $limit);
818 818
     }
819 819
 
820 820
     // Store the results.
821 821
     $results[$cid] = !empty($references) ? $references : array();
822
-  }
822
+    }
823 823
 
824
-  return $results[$cid];
824
+    return $results[$cid];
825 825
 }
826 826
 
827 827
 /**
@@ -829,9 +829,9 @@  discard block
 block discarded – undo
829 829
  * case of Views-defined referenceable nodes.
830 830
  */
831 831
 function _nodereference_potential_references_views($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
832
-  $view_name = $field['advanced_view'];
832
+    $view_name = $field['advanced_view'];
833 833
 
834
-  if ($view = views_get_view($view_name)) {
834
+    if ($view = views_get_view($view_name)) {
835 835
     // We add a display, and let it derive from the 'default' display.
836 836
     // TODO: We should let the user pick a display in the fields settings - sort of requires AHAH...
837 837
     $display = $view->add_display('content_references');
@@ -848,12 +848,12 @@  discard block
 block discarded – undo
848 848
     // Additional options to let content_plugin_display_references::query()
849 849
     // narrow the results.
850 850
     $options = array(
851
-      'table' => 'node',
852
-      'field_string' => 'title',
853
-      'string' => $string,
854
-      'match' => $match,
855
-      'field_id' => 'nid',
856
-      'ids' => $ids,
851
+        'table' => 'node',
852
+        'field_string' => 'title',
853
+        'string' => $string,
854
+        'match' => $match,
855
+        'field_id' => 'nid',
856
+        'ids' => $ids,
857 857
     );
858 858
     $view->display_handler->set_option('content_options', $options);
859 859
 
@@ -866,26 +866,26 @@  discard block
 block discarded – undo
866 866
 
867 867
     // Get arguments for the view.
868 868
     if (!empty($field['advanced_view_args'])) {
869
-      // TODO: Support Tokens using token.module ?
870
-      $view_args = array_map('trim', explode(',', $field['advanced_view_args']));
869
+        // TODO: Support Tokens using token.module ?
870
+        $view_args = array_map('trim', explode(',', $field['advanced_view_args']));
871 871
     }
872 872
     else {
873
-      $view_args = array();
873
+        $view_args = array();
874 874
     }
875 875
 
876 876
     // We do need title field, so add it if not present (unlikely, but...)
877 877
     $fields = $view->get_items('field', $display);
878 878
     if (!isset($fields['title'])) {
879
-      $view->add_item($display, 'field', 'node', 'title');
879
+        $view->add_item($display, 'field', 'node', 'title');
880 880
     }
881 881
 
882 882
     // If not set, make all fields inline and define a separator.
883 883
     $options = $view->display_handler->get_option('row_options');
884 884
     if (empty($options['inline'])) {
885
-      $options['inline'] = drupal_map_assoc(array_keys($view->get_items('field', $display)));
885
+        $options['inline'] = drupal_map_assoc(array_keys($view->get_items('field', $display)));
886 886
     }
887 887
     if (empty($options['separator'])) {
888
-      $options['separator'] = '-';
888
+        $options['separator'] = '-';
889 889
     }
890 890
     $view->display_handler->set_option('row_options', $options);
891 891
 
@@ -894,12 +894,12 @@  discard block
 block discarded – undo
894 894
 
895 895
     // Get the results.
896 896
     $result = $view->execute_display($display, $view_args);
897
-  }
898
-  else {
897
+    }
898
+    else {
899 899
     $result = FALSE;
900
-  }
900
+    }
901 901
 
902
-  return $result;
902
+    return $result;
903 903
 }
904 904
 
905 905
 /**
@@ -907,50 +907,50 @@  discard block
 block discarded – undo
907 907
  * referenceable nodes defined by content types.
908 908
  */
909 909
 function _nodereference_potential_references_standard($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
910
-  $related_types = array();
911
-  $where = array();
912
-  $args = array();
910
+    $related_types = array();
911
+    $where = array();
912
+    $args = array();
913 913
 
914
-  if (is_array($field['referenceable_types'])) {
914
+    if (is_array($field['referenceable_types'])) {
915 915
     foreach (array_filter($field['referenceable_types']) as $related_type) {
916
-      $related_types[] = "n.type = '%s'";
917
-      $args[] = $related_type;
916
+        $related_types[] = "n.type = '%s'";
917
+        $args[] = $related_type;
918
+    }
918 919
     }
919
-  }
920 920
 
921
-  $where[] = implode(' OR ', $related_types);
921
+    $where[] = implode(' OR ', $related_types);
922 922
 
923
-  if (!count($related_types)) {
923
+    if (!count($related_types)) {
924 924
     return array();
925
-  }
925
+    }
926 926
 
927
-  if ($string !== '') {
927
+    if ($string !== '') {
928 928
     $like = $GLOBALS["db_type"] == 'pgsql' ? "ILIKE" : "LIKE";
929 929
     $match_clauses = array(
930
-      'contains' => "$like '%%%s%%'",
931
-      'equals' => "= '%s'",
932
-      'starts_with' => "$like '%s%%'",
930
+        'contains' => "$like '%%%s%%'",
931
+        'equals' => "= '%s'",
932
+        'starts_with' => "$like '%s%%'",
933 933
     );
934 934
     $where[] = 'n.title '. (isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
935 935
     $args[] = $string;
936
-  }
937
-  elseif ($ids) {
936
+    }
937
+    elseif ($ids) {
938 938
     $where[] = 'n.nid IN (' . db_placeholders($ids) . ')';
939 939
     $args = array_merge($args, $ids);
940
-  }
940
+    }
941 941
 
942
-  $where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
943
-  $sql = db_rewrite_sql("SELECT n.nid, n.title AS node_title, n.type AS node_type FROM {node} n $where_clause ORDER BY n.title, n.type");
944
-  $result = $limit ? db_query_range($sql, $args, 0, $limit) : db_query($sql, $args);
945
-  $references = array();
946
-  while ($node = db_fetch_object($result)) {
942
+    $where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
943
+    $sql = db_rewrite_sql("SELECT n.nid, n.title AS node_title, n.type AS node_type FROM {node} n $where_clause ORDER BY n.title, n.type");
944
+    $result = $limit ? db_query_range($sql, $args, 0, $limit) : db_query($sql, $args);
945
+    $references = array();
946
+    while ($node = db_fetch_object($result)) {
947 947
     $references[$node->nid] = array(
948
-      'title' => $node->node_title,
949
-      'rendered' => check_plain($node->node_title),
948
+        'title' => $node->node_title,
949
+        'rendered' => check_plain($node->node_title),
950 950
     );
951
-  }
951
+    }
952 952
 
953
-  return $references;
953
+    return $references;
954 954
 }
955 955
 
956 956
 /**
@@ -960,31 +960,31 @@  discard block
 block discarded – undo
960 960
  * a user has edit but not view access.
961 961
  */
962 962
 function nodereference_autocomplete_access($field_name) {
963
-  return user_access('access content') && ($field = content_fields($field_name)) && isset($field['field_name']) && content_access('view', $field) && content_access('edit', $field);
963
+    return user_access('access content') && ($field = content_fields($field_name)) && isset($field['field_name']) && content_access('view', $field) && content_access('edit', $field);
964 964
 }
965 965
 
966 966
 /**
967 967
  * Menu callback; Retrieve a pipe delimited string of autocomplete suggestions for existing users
968 968
  */
969 969
 function nodereference_autocomplete($field_name, $string = '') {
970
-  $fields = content_fields();
971
-  $field = $fields[$field_name];
972
-  $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
973
-  $matches = array();
970
+    $fields = content_fields();
971
+    $field = $fields[$field_name];
972
+    $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
973
+    $matches = array();
974 974
 
975
-  $references = _nodereference_potential_references($field, $string, $match, array(), 10);
976
-  foreach ($references as $id => $row) {
975
+    $references = _nodereference_potential_references($field, $string, $match, array(), 10);
976
+    foreach ($references as $id => $row) {
977 977
     // Add a class wrapper for a few required CSS overrides.
978 978
     $matches[$row['title'] ." [nid:$id]"] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';
979
-  }
980
-  drupal_json($matches);
979
+    }
980
+    drupal_json($matches);
981 981
 }
982 982
 
983 983
 /**
984 984
  * Implementation of hook_node_types.
985 985
  */
986 986
 function nodereference_node_type($op, $info) {
987
-  switch ($op) {
987
+    switch ($op) {
988 988
     case 'update':
989 989
       // Reflect type name changes to the 'referenceable types' settings.
990 990
       if (!empty($info->old_type) && $info->old_type != $info->type) {
@@ -993,22 +993,22 @@  discard block
 block discarded – undo
993 993
         $fields = content_fields();
994 994
         $rebuild = FALSE;
995 995
         foreach ($fields as $field_name => $field) {
996
-          if ($field['type'] == 'nodereference' && isset($field['referenceable_types'][$info->old_type])) {
996
+            if ($field['type'] == 'nodereference' && isset($field['referenceable_types'][$info->old_type])) {
997 997
             $field['referenceable_types'][$info->type] = empty($field['referenceable_types'][$info->old_type]) ? 0 : $info->type;
998 998
             unset($field['referenceable_types'][$info->old_type]);
999 999
             content_field_instance_update($field, FALSE);
1000 1000
             $rebuild = TRUE;
1001
-          }
1001
+            }
1002 1002
         }
1003 1003
 
1004 1004
         // Clear caches and rebuild menu only if any field has been updated.
1005 1005
         if ($rebuild) {
1006
-          content_clear_type_cache(TRUE);
1007
-          menu_rebuild();
1006
+            content_clear_type_cache(TRUE);
1007
+            menu_rebuild();
1008
+        }
1008 1009
         }
1009
-      }
1010
-      break;
1011
-  }
1010
+        break;
1011
+    }
1012 1012
 }
1013 1013
 
1014 1014
 /**
@@ -1018,16 +1018,16 @@  discard block
 block discarded – undo
1018 1018
  * nodereference field with the 'full node' / 'teaser' formatters.
1019 1019
  */
1020 1020
 function nodereference_preprocess_node(&$vars) {
1021
-  // The 'referencing_field' attribute of the node is added by the 'teaser'
1022
-  // and 'full node' formatters.
1023
-  if (!empty($vars['node']->referencing_field)) {
1021
+    // The 'referencing_field' attribute of the node is added by the 'teaser'
1022
+    // and 'full node' formatters.
1023
+    if (!empty($vars['node']->referencing_field)) {
1024 1024
     $node = $vars['node'];
1025 1025
     $field = $node->referencing_field;
1026 1026
     $vars['template_files'][] = 'node-nodereference';
1027 1027
     $vars['template_files'][] = 'node-nodereference-'. $field['field_name'];
1028 1028
     $vars['template_files'][] = 'node-nodereference-'. $node->type;
1029 1029
     $vars['template_files'][] = 'node-nodereference-'. $field['field_name'] .'-'. $node->type;
1030
-  }
1030
+    }
1031 1031
 }
1032 1032
 
1033 1033
 /**
@@ -1042,13 +1042,13 @@  discard block
 block discarded – undo
1042 1042
  * $element['#delta]  is the position of this element in the group
1043 1043
  */
1044 1044
 function theme_nodereference_select($element) {
1045
-  return $element['#children'];
1045
+    return $element['#children'];
1046 1046
 }
1047 1047
 
1048 1048
 function theme_nodereference_buttons($element) {
1049
-  return $element['#children'];
1049
+    return $element['#children'];
1050 1050
 }
1051 1051
 
1052 1052
 function theme_nodereference_autocomplete($element) {
1053
-  return $element['#children'];
1053
+    return $element['#children'];
1054 1054
 }
Please login to merge, or discard this patch.
Switch Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -79,102 +79,102 @@  discard block
 block discarded – undo
79 79
  */
80 80
 function nodereference_field_settings($op, $field) {
81 81
   switch ($op) {
82
-    case 'form':
83
-      $form = array();
84
-      $form['referenceable_types'] = array(
85
-        '#type' => 'checkboxes',
86
-        '#title' => t('Content types that can be referenced'),
87
-        '#multiple' => TRUE,
88
-        '#default_value' => is_array($field['referenceable_types']) ? $field['referenceable_types'] : array(),
89
-        '#options' => array_map('check_plain', node_get_types('names')),
90
-      );
91
-      if (module_exists('views')) {
92
-        $views = array('--' => '--');
93
-        $all_views = views_get_all_views();
94
-        foreach ($all_views as $view) {
95
-          // Only 'node' views that have fields will work for our purpose.
96
-          if ($view->base_table == 'node' && !empty($view->display['default']->display_options['fields'])) {
97
-            if ($view->type == 'Default') {
98
-              $views[t('Default Views')][$view->name] = $view->name;
99
-            }
100
-            else {
101
-              $views[t('Existing Views')][$view->name] = $view->name;
102
-            }
82
+  case 'form':
83
+    $form = array();
84
+    $form['referenceable_types'] = array(
85
+      '#type' => 'checkboxes',
86
+      '#title' => t('Content types that can be referenced'),
87
+      '#multiple' => TRUE,
88
+      '#default_value' => is_array($field['referenceable_types']) ? $field['referenceable_types'] : array(),
89
+      '#options' => array_map('check_plain', node_get_types('names')),
90
+    );
91
+    if (module_exists('views')) {
92
+      $views = array('--' => '--');
93
+      $all_views = views_get_all_views();
94
+      foreach ($all_views as $view) {
95
+        // Only 'node' views that have fields will work for our purpose.
96
+        if ($view->base_table == 'node' && !empty($view->display['default']->display_options['fields'])) {
97
+          if ($view->type == 'Default') {
98
+            $views[t('Default Views')][$view->name] = $view->name;
99
+          }
100
+          else {
101
+            $views[t('Existing Views')][$view->name] = $view->name;
103 102
           }
104
-        }
105
-
106
-        $form['advanced'] = array(
107
-           '#type' => 'fieldset',
108
-           '#title' => t('Advanced - Nodes that can be referenced (View)'),
109
-           '#collapsible' => TRUE,
110
-           '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
111
-         );
112
-        if (count($views) > 1) {
113
-          $form['advanced']['advanced_view'] = array(
114
-            '#type' => 'select',
115
-            '#title' => t('View used to select the nodes'),
116
-            '#options' => $views,
117
-            '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
118
-            '#description' => t('<p>Choose the "Views module" view that selects the nodes that can be referenced.<br />Note:</p>') .
119
-              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>'),
120
-          );
121
-          $form['advanced']['advanced_view_args'] = array(
122
-            '#type' => 'textfield',
123
-            '#title' => t('View arguments'),
124
-            '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
125
-            '#required' => FALSE,
126
-            '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
127
-          );
128
-        }
129
-        else {
130
-          $form['advanced']['no_view_help'] = array(
131
-            '#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
-              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>'),
133
-          );
134 103
         }
135 104
       }
136
-      return $form;
137 105
 
138
-    case 'save':
139
-      $settings = array('referenceable_types');
140
-      if (module_exists('views')) {
141
-        $settings[] = 'advanced_view';
142
-        $settings[] = 'advanced_view_args';
106
+      $form['advanced'] = array(
107
+         '#type' => 'fieldset',
108
+         '#title' => t('Advanced - Nodes that can be referenced (View)'),
109
+         '#collapsible' => TRUE,
110
+         '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
111
+       );
112
+      if (count($views) > 1) {
113
+        $form['advanced']['advanced_view'] = array(
114
+          '#type' => 'select',
115
+          '#title' => t('View used to select the nodes'),
116
+          '#options' => $views,
117
+          '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
118
+          '#description' => t('<p>Choose the "Views module" view that selects the nodes that can be referenced.<br />Note:</p>') .
119
+            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>'),
120
+        );
121
+        $form['advanced']['advanced_view_args'] = array(
122
+          '#type' => 'textfield',
123
+          '#title' => t('View arguments'),
124
+          '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
125
+          '#required' => FALSE,
126
+          '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
127
+        );
128
+      }
129
+      else {
130
+        $form['advanced']['no_view_help'] = array(
131
+          '#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
+            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>'),
133
+        );
143 134
       }
144
-      return $settings;
135
+    }
136
+    return $form;
145 137
 
146
-    case 'database columns':
147
-      $columns = array(
148
-        'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
149
-      );
150
-      return $columns;
151
-
152
-    case 'views data':
153
-      $data = content_views_field_views_data($field);
154
-      $db_info = content_database_info($field);
155
-      $table_alias = content_views_tablename($field);
156
-
157
-      // Filter: swap the handler to the 'in' operator.
158
-      $data[$table_alias][$field['field_name'] .'_nid']['filter']['handler'] = 'content_handler_filter_many_to_one';
159
-      // Argument: use node.title for summaries.
160
-      $data["node_$table_alias"]['table']['join']['node'] = array(
161
-        'table' => 'node',
162
-        'field' => 'nid',
163
-        'left_table' => $table_alias,
164
-        'left_field' => $field['field_name'] .'_nid',
165
-      );
166
-      $data[$table_alias][$field['field_name'] .'_nid']['argument']['handler'] = 'content_handler_argument_reference';
167
-      $data[$table_alias][$field['field_name'] .'_nid']['argument']['name table'] = "node_$table_alias";
168
-      $data[$table_alias][$field['field_name'] .'_nid']['argument']['name field'] = 'title';
169
-      // Relationship: add a relationship for related node.
170
-      $data[$table_alias][$field['field_name'] .'_nid']['relationship'] = array(
171
-        'base' => 'node',
172
-        'field' => $db_info['columns']['nid']['column'],
173
-        'handler' => 'content_handler_relationship',
174
-        'label' => t($field['widget']['label']),
175
-        'content_field_name' => $field['field_name'],
176
-      );
177
-      return $data;
138
+  case 'save':
139
+    $settings = array('referenceable_types');
140
+    if (module_exists('views')) {
141
+      $settings[] = 'advanced_view';
142
+      $settings[] = 'advanced_view_args';
143
+    }
144
+    return $settings;
145
+
146
+  case 'database columns':
147
+    $columns = array(
148
+      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
149
+    );
150
+    return $columns;
151
+
152
+  case 'views data':
153
+    $data = content_views_field_views_data($field);
154
+    $db_info = content_database_info($field);
155
+    $table_alias = content_views_tablename($field);
156
+
157
+    // Filter: swap the handler to the 'in' operator.
158
+    $data[$table_alias][$field['field_name'] .'_nid']['filter']['handler'] = 'content_handler_filter_many_to_one';
159
+    // Argument: use node.title for summaries.
160
+    $data["node_$table_alias"]['table']['join']['node'] = array(
161
+      'table' => 'node',
162
+      'field' => 'nid',
163
+      'left_table' => $table_alias,
164
+      'left_field' => $field['field_name'] .'_nid',
165
+    );
166
+    $data[$table_alias][$field['field_name'] .'_nid']['argument']['handler'] = 'content_handler_argument_reference';
167
+    $data[$table_alias][$field['field_name'] .'_nid']['argument']['name table'] = "node_$table_alias";
168
+    $data[$table_alias][$field['field_name'] .'_nid']['argument']['name field'] = 'title';
169
+    // Relationship: add a relationship for related node.
170
+    $data[$table_alias][$field['field_name'] .'_nid']['relationship'] = array(
171
+      'base' => 'node',
172
+      'field' => $db_info['columns']['nid']['column'],
173
+      'handler' => 'content_handler_relationship',
174
+      'label' => t($field['widget']['label']),
175
+      'content_field_name' => $field['field_name'],
176
+    );
177
+    return $data;
178 178
   }
179 179
 }
180 180
 
@@ -186,91 +186,91 @@  discard block
 block discarded – undo
186 186
   
187 187
   switch ($op) {
188 188
     // When preparing a translation, load any translations of existing references.
189
-    case 'prepare translation':
190
-      $addition = array();
191
-      $addition[$field['field_name']] = array();
192
-      if (isset($node->translation_source->$field['field_name']) && is_array($node->translation_source->$field['field_name'])) {
193
-        foreach ($node->translation_source->$field['field_name'] as $key => $reference) {
194
-          $reference_node = node_load($reference['nid']);
195
-          // Test if the referenced node type is translatable and, if so,
196
-          // load translations if the reference is not for the current language.
197
-          // We can assume the translation module is present because it invokes 'prepare translation'.
198
-          if (translation_supported_type($reference_node->type) && !empty($reference_node->language) && $reference_node->language != $node->language && $translations = translation_node_get_translations($reference_node->tnid)) {
199
-            // If there is a translation for the current language, use it.
200
-            $addition[$field['field_name']][] = array(
201
-              'nid' => isset($translations[$node->language]) ? $translations[$node->language]->nid : $reference['nid'],
202
-            );
203
-          }
189
+  case 'prepare translation':
190
+    $addition = array();
191
+    $addition[$field['field_name']] = array();
192
+    if (isset($node->translation_source->$field['field_name']) && is_array($node->translation_source->$field['field_name'])) {
193
+      foreach ($node->translation_source->$field['field_name'] as $key => $reference) {
194
+        $reference_node = node_load($reference['nid']);
195
+        // Test if the referenced node type is translatable and, if so,
196
+        // load translations if the reference is not for the current language.
197
+        // We can assume the translation module is present because it invokes 'prepare translation'.
198
+        if (translation_supported_type($reference_node->type) && !empty($reference_node->language) && $reference_node->language != $node->language && $translations = translation_node_get_translations($reference_node->tnid)) {
199
+          // If there is a translation for the current language, use it.
200
+          $addition[$field['field_name']][] = array(
201
+            'nid' => isset($translations[$node->language]) ? $translations[$node->language]->nid : $reference['nid'],
202
+          );
204 203
         }
205 204
       }
206
-      return $addition;
207
-
208
-    case 'validate':
209
-      // Extract nids to check.
210
-      $ids = array();
211
-      foreach ($items as $delta => $item) {
212
-        if (is_array($item) && !empty($item['nid'])) {
213
-          if (is_numeric($item['nid'])) {
214
-            $ids[] = $item['nid'];
215
-          }
216
-          else {
217
-            $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
218
-            if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
219
-            form_set_error($error_element, t("%name: invalid input.", array('%name' => t($field['widget']['label']))));
220
-          }
205
+    }
206
+    return $addition;
207
+
208
+  case 'validate':
209
+    // Extract nids to check.
210
+    $ids = array();
211
+    foreach ($items as $delta => $item) {
212
+      if (is_array($item) && !empty($item['nid'])) {
213
+        if (is_numeric($item['nid'])) {
214
+          $ids[] = $item['nid'];
221 215
         }
222
-      }
223
-      // Prevent performance hog if there are no ids to check.
224
-      if ($ids) {
225
-        $refs = _nodereference_potential_references($field, '', NULL, $ids);
226
-        foreach ($items as $delta => $item) {
227
-          if (is_array($item)) {
228
-            $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
229
-            if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
230
-            if (!empty($item['nid']) && !isset($refs[$item['nid']])) {
231
-              form_set_error($error_element, t("%name: this post can't be referenced.", array('%name' => t($field['widget']['label']))));
232
-            }
233
-          }
216
+        else {
217
+          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
218
+          if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
219
+          form_set_error($error_element, t("%name: invalid input.", array('%name' => t($field['widget']['label']))));
234 220
         }
235 221
       }
236
-      return $items;
237
-
238
-    case 'sanitize':
239
-      // We can't just check the node is 'referenceable', because Views-mode
240
-      // could rely on 'current user' (at edit time).
241
-
242
-      // Extract nids to check.
243
-      $ids = array();
222
+    }
223
+    // Prevent performance hog if there are no ids to check.
224
+    if ($ids) {
225
+      $refs = _nodereference_potential_references($field, '', NULL, $ids);
244 226
       foreach ($items as $delta => $item) {
245 227
         if (is_array($item)) {
246
-          // Default to 'non accessible'.
247
-          $items[$delta]['safe'] = array();
248
-          if (!empty($item['nid']) && is_numeric($item['nid'])) {
249
-            $ids[] = $item['nid'];
228
+          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
229
+          if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
230
+          if (!empty($item['nid']) && !isset($refs[$item['nid']])) {
231
+            form_set_error($error_element, t("%name: this post can't be referenced.", array('%name' => t($field['widget']['label']))));
250 232
           }
251 233
         }
252 234
       }
253
-      if ($ids) {
254
-        // Load information about nids that we haven't already loaded during
255
-        // this page request.
256
-        $missing_ids = array_diff($ids, array_keys($sanitized_nodes));
257
-        if (!empty($missing_ids)) {
258
-          $where = array('n.nid in ('. db_placeholders($missing_ids) . ')');
259
-          if (!user_access('administer nodes')) {
260
-            $where[] = 'n.status = 1';
261
-          }
262
-          $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status FROM {node} n WHERE '. implode(' AND ', $where)), $missing_ids);
263
-          while ($row = db_fetch_array($result)) {
264
-            $sanitized_nodes[$row['nid']] = $row;
265
-          }
235
+    }
236
+    return $items;
237
+
238
+  case 'sanitize':
239
+    // We can't just check the node is 'referenceable', because Views-mode
240
+    // could rely on 'current user' (at edit time).
241
+
242
+    // Extract nids to check.
243
+    $ids = array();
244
+    foreach ($items as $delta => $item) {
245
+      if (is_array($item)) {
246
+        // Default to 'non accessible'.
247
+        $items[$delta]['safe'] = array();
248
+        if (!empty($item['nid']) && is_numeric($item['nid'])) {
249
+          $ids[] = $item['nid'];
266 250
         }
267
-        foreach ($items as $delta => $item) {
268
-          if (is_array($item) && !empty($item['nid']) && isset($sanitized_nodes[$item['nid']])) {
269
-            $items[$delta]['safe'] = $sanitized_nodes[$item['nid']];
270
-          }
251
+      }
252
+    }
253
+    if ($ids) {
254
+      // Load information about nids that we haven't already loaded during
255
+      // this page request.
256
+      $missing_ids = array_diff($ids, array_keys($sanitized_nodes));
257
+      if (!empty($missing_ids)) {
258
+        $where = array('n.nid in ('. db_placeholders($missing_ids) . ')');
259
+        if (!user_access('administer nodes')) {
260
+          $where[] = 'n.status = 1';
261
+        }
262
+        $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status FROM {node} n WHERE '. implode(' AND ', $where)), $missing_ids);
263
+        while ($row = db_fetch_array($result)) {
264
+          $sanitized_nodes[$row['nid']] = $row;
271 265
         }
272 266
       }
273
-      return $items;
267
+      foreach ($items as $delta => $item) {
268
+        if (is_array($item) && !empty($item['nid']) && isset($sanitized_nodes[$item['nid']])) {
269
+          $items[$delta]['safe'] = $sanitized_nodes[$item['nid']];
270
+        }
271
+      }
272
+    }
273
+    return $items;
274 274
   }
275 275
 }
276 276
 
@@ -465,37 +465,37 @@  discard block
 block discarded – undo
465 465
  */
466 466
 function nodereference_widget_settings($op, $widget) {
467 467
   switch ($op) {
468
-    case 'form':
469
-      $form = array();
470
-      $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
471
-      $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
472
-      if ($widget['type'] == 'nodereference_autocomplete') {
473
-        $form['autocomplete_match'] = array(
474
-          '#type' => 'select',
475
-          '#title' => t('Autocomplete matching'),
476
-          '#default_value' => $match,
477
-          '#options' => array(
478
-            'starts_with' => t('Starts with'),
479
-            'contains' => t('Contains'),
480
-          ),
481
-          '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of nodes.'),
482
-        );
483
-        $form['size'] = array(
484
-          '#type' => 'textfield',
485
-          '#title' => t('Size of textfield'),
486
-          '#default_value' => $size,
487
-          '#element_validate' => array('_element_validate_integer_positive'),
488
-          '#required' => TRUE,
489
-        );
490
-      }
491
-      else {
492
-        $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
493
-        $form['size'] = array('#type' => 'hidden', '#value' => $size);
494
-      }
495
-      return $form;
468
+  case 'form':
469
+    $form = array();
470
+    $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
471
+    $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
472
+    if ($widget['type'] == 'nodereference_autocomplete') {
473
+      $form['autocomplete_match'] = array(
474
+        '#type' => 'select',
475
+        '#title' => t('Autocomplete matching'),
476
+        '#default_value' => $match,
477
+        '#options' => array(
478
+          'starts_with' => t('Starts with'),
479
+          'contains' => t('Contains'),
480
+        ),
481
+        '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of nodes.'),
482
+      );
483
+      $form['size'] = array(
484
+        '#type' => 'textfield',
485
+        '#title' => t('Size of textfield'),
486
+        '#default_value' => $size,
487
+        '#element_validate' => array('_element_validate_integer_positive'),
488
+        '#required' => TRUE,
489
+      );
490
+    }
491
+    else {
492
+      $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
493
+      $form['size'] = array('#type' => 'hidden', '#value' => $size);
494
+    }
495
+    return $form;
496 496
 
497
-    case 'save':
498
-      return array('autocomplete_match', 'size');
497
+  case 'save':
498
+    return array('autocomplete_match', 'size');
499 499
   }
500 500
 }
501 501
 
@@ -532,27 +532,27 @@  discard block
 block discarded – undo
532 532
  */
533 533
 function nodereference_widget(&$form, &$form_state, $field, $items, $delta = 0) {
534 534
   switch ($field['widget']['type']) {
535
-    case 'nodereference_select':
536
-      $element = array(
537
-        '#type' => 'nodereference_select',
538
-        '#default_value' => $items,
539
-      );
540
-      break;
535
+  case 'nodereference_select':
536
+    $element = array(
537
+      '#type' => 'nodereference_select',
538
+      '#default_value' => $items,
539
+    );
540
+    break;
541 541
 
542
-    case 'nodereference_buttons':
543
-      $element = array(
544
-        '#type' => 'nodereference_buttons',
545
-        '#default_value' => $items,
546
-      );
547
-      break;
542
+  case 'nodereference_buttons':
543
+    $element = array(
544
+      '#type' => 'nodereference_buttons',
545
+      '#default_value' => $items,
546
+    );
547
+    break;
548 548
 
549
-    case 'nodereference_autocomplete':
550
-      $element = array(
551
-        '#type' => 'nodereference_autocomplete',
552
-        '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
553
-        '#value_callback' => 'nodereference_autocomplete_value',
554
-      );
555
-      break;
549
+  case 'nodereference_autocomplete':
550
+    $element = array(
551
+      '#type' => 'nodereference_autocomplete',
552
+      '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
553
+      '#value_callback' => 'nodereference_autocomplete_value',
554
+    );
555
+    break;
556 556
   }
557 557
   return $element;
558 558
 }
@@ -985,29 +985,29 @@  discard block
 block discarded – undo
985 985
  */
986 986
 function nodereference_node_type($op, $info) {
987 987
   switch ($op) {
988
-    case 'update':
989
-      // Reflect type name changes to the 'referenceable types' settings.
990
-      if (!empty($info->old_type) && $info->old_type != $info->type) {
991
-        // content.module's implementaion of hook_node_type() has already
992
-        // refreshed _content_type_info().
993
-        $fields = content_fields();
994
-        $rebuild = FALSE;
995
-        foreach ($fields as $field_name => $field) {
996
-          if ($field['type'] == 'nodereference' && isset($field['referenceable_types'][$info->old_type])) {
997
-            $field['referenceable_types'][$info->type] = empty($field['referenceable_types'][$info->old_type]) ? 0 : $info->type;
998
-            unset($field['referenceable_types'][$info->old_type]);
999
-            content_field_instance_update($field, FALSE);
1000
-            $rebuild = TRUE;
1001
-          }
988
+  case 'update':
989
+    // Reflect type name changes to the 'referenceable types' settings.
990
+    if (!empty($info->old_type) && $info->old_type != $info->type) {
991
+      // content.module's implementaion of hook_node_type() has already
992
+      // refreshed _content_type_info().
993
+      $fields = content_fields();
994
+      $rebuild = FALSE;
995
+      foreach ($fields as $field_name => $field) {
996
+        if ($field['type'] == 'nodereference' && isset($field['referenceable_types'][$info->old_type])) {
997
+          $field['referenceable_types'][$info->type] = empty($field['referenceable_types'][$info->old_type]) ? 0 : $info->type;
998
+          unset($field['referenceable_types'][$info->old_type]);
999
+          content_field_instance_update($field, FALSE);
1000
+          $rebuild = TRUE;
1002 1001
         }
1002
+      }
1003 1003
 
1004
-        // Clear caches and rebuild menu only if any field has been updated.
1005
-        if ($rebuild) {
1006
-          content_clear_type_cache(TRUE);
1007
-          menu_rebuild();
1008
-        }
1004
+      // Clear caches and rebuild menu only if any field has been updated.
1005
+      if ($rebuild) {
1006
+        content_clear_type_cache(TRUE);
1007
+        menu_rebuild();
1009 1008
       }
1010
-      break;
1009
+    }
1010
+    break;
1011 1011
   }
1012 1012
 }
1013 1013
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
  */
58 58
 function nodereference_ctools_plugin_directory($module, $plugin) {
59 59
   if ($module == 'ctools' && $plugin == 'relationships') {
60
-    return 'panels/' . $plugin;
60
+    return 'panels/'.$plugin;
61 61
   }
62 62
 }
63 63
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             '#title' => t('View used to select the nodes'),
116 116
             '#options' => $views,
117 117
             '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
118
-            '#description' => t('<p>Choose the "Views module" view that selects the nodes that can be referenced.<br />Note:</p>') .
118
+            '#description' => t('<p>Choose the "Views module" view that selects the nodes that can be referenced.<br />Note:</p>').
119 119
               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>'),
120 120
           );
121 121
           $form['advanced']['advanced_view_args'] = array(
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         }
129 129
         else {
130 130
           $form['advanced']['no_view_help'] = array(
131
-            '#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>') .
131
+            '#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 132
               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>'),
133 133
           );
134 134
         }
@@ -155,19 +155,19 @@  discard block
 block discarded – undo
155 155
       $table_alias = content_views_tablename($field);
156 156
 
157 157
       // Filter: swap the handler to the 'in' operator.
158
-      $data[$table_alias][$field['field_name'] .'_nid']['filter']['handler'] = 'content_handler_filter_many_to_one';
158
+      $data[$table_alias][$field['field_name'].'_nid']['filter']['handler'] = 'content_handler_filter_many_to_one';
159 159
       // Argument: use node.title for summaries.
160 160
       $data["node_$table_alias"]['table']['join']['node'] = array(
161 161
         'table' => 'node',
162 162
         'field' => 'nid',
163 163
         'left_table' => $table_alias,
164
-        'left_field' => $field['field_name'] .'_nid',
164
+        'left_field' => $field['field_name'].'_nid',
165 165
       );
166
-      $data[$table_alias][$field['field_name'] .'_nid']['argument']['handler'] = 'content_handler_argument_reference';
167
-      $data[$table_alias][$field['field_name'] .'_nid']['argument']['name table'] = "node_$table_alias";
168
-      $data[$table_alias][$field['field_name'] .'_nid']['argument']['name field'] = 'title';
166
+      $data[$table_alias][$field['field_name'].'_nid']['argument']['handler'] = 'content_handler_argument_reference';
167
+      $data[$table_alias][$field['field_name'].'_nid']['argument']['name table'] = "node_$table_alias";
168
+      $data[$table_alias][$field['field_name'].'_nid']['argument']['name field'] = 'title';
169 169
       // Relationship: add a relationship for related node.
170
-      $data[$table_alias][$field['field_name'] .'_nid']['relationship'] = array(
170
+      $data[$table_alias][$field['field_name'].'_nid']['relationship'] = array(
171 171
         'base' => 'node',
172 172
         'field' => $db_info['columns']['nid']['column'],
173 173
         'handler' => 'content_handler_relationship',
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
         // this page request.
256 256
         $missing_ids = array_diff($ids, array_keys($sanitized_nodes));
257 257
         if (!empty($missing_ids)) {
258
-          $where = array('n.nid in ('. db_placeholders($missing_ids) . ')');
258
+          $where = array('n.nid in ('.db_placeholders($missing_ids).')');
259 259
           if (!user_access('administer nodes')) {
260 260
             $where[] = 'n.status = 1';
261 261
           }
262
-          $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status FROM {node} n WHERE '. implode(' AND ', $where)), $missing_ids);
262
+          $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.status FROM {node} n WHERE '.implode(' AND ', $where)), $missing_ids);
263 263
           while ($row = db_fetch_array($result)) {
264 264
             $sanitized_nodes[$row['nid']] = $row;
265 265
           }
@@ -318,9 +318,9 @@  discard block
 block discarded – undo
318 318
 function theme_nodereference_formatter_default($element) {
319 319
   $output = '';
320 320
   if (!empty($element['#item']['safe']['nid'])) {
321
-    $output = l($element['#item']['safe']['title'], 'node/'. $element['#item']['safe']['nid']);
321
+    $output = l($element['#item']['safe']['title'], 'node/'.$element['#item']['safe']['nid']);
322 322
     if (!$element['#item']['safe']['status']) {
323
-      $output = '<span class="node-unpublished"> '. t('(Unpublished)') ." $output</span>";
323
+      $output = '<span class="node-unpublished"> '.t('(Unpublished)')." $output</span>";
324 324
     }
325 325
   }
326 326
   return $output;
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
   if (!empty($element['#item']['safe']['nid'])) {
335 335
     $output = check_plain($element['#item']['safe']['title']);
336 336
     if (!$element['#item']['safe']['status']) {
337
-      $output = '<span class="node-unpublished"> '. t('(Unpublished)') ." $output</span>";
337
+      $output = '<span class="node-unpublished"> '.t('(Unpublished)')." $output</span>";
338 338
     }
339 339
   }
340 340
   return $output;
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
  * Substitute in the node title for the node nid.
564 564
  */
565 565
 function nodereference_autocomplete_value($element, $edit = FALSE) {
566
-  $field_key  = $element['#columns'][0];
566
+  $field_key = $element['#columns'][0];
567 567
   if (!empty($element['#default_value'][$field_key])) {
568 568
     $nid = $element['#default_value'][$field_key];
569 569
     $value = db_result(db_query(db_rewrite_sql('SELECT n.title FROM {node} n WHERE n.nid = %d'), $nid));
570
-    $value .= ' [nid:'. $nid .']';
570
+    $value .= ' [nid:'.$nid.']';
571 571
     return array($field_key => $value);
572 572
   }
573 573
   return array($field_key => NULL);
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
   // element, it can wrap around the optionwidgets_select element.
587 587
   // This will create a new, nested instance of the field.
588 588
   // Add a validation step where the value can be unwrapped.
589
-  $field_key  = $element['#columns'][0];
589
+  $field_key = $element['#columns'][0];
590 590
   $element[$field_key] = array(
591 591
     '#type' => 'optionwidgets_select',
592 592
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
   // element, it can wrap around the optionwidgets_select element.
621 621
   // This will create a new, nested instance of the field.
622 622
   // Add a validation step where the value can be unwrapped.
623
-  $field_key  = $element['#columns'][0];
623
+  $field_key = $element['#columns'][0];
624 624
   $element[$field_key] = array(
625 625
     '#type' => 'optionwidgets_buttons',
626 626
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
@@ -654,12 +654,12 @@  discard block
 block discarded – undo
654 654
   // element, it can wrap around the text_textfield element and add an autocomplete
655 655
   // path and some extra processing to it.
656 656
   // Add a validation step where the value can be unwrapped.
657
-  $field_key  = $element['#columns'][0];
657
+  $field_key = $element['#columns'][0];
658 658
 
659 659
   $element[$field_key] = array(
660 660
     '#type' => 'text_textfield',
661 661
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
662
-    '#autocomplete_path' => 'nodereference/autocomplete/'. $element['#field_name'],
662
+    '#autocomplete_path' => 'nodereference/autocomplete/'.$element['#field_name'],
663 663
     // The following values were set by the content module and need
664 664
     // to be passed down to the nested element.
665 665
     '#title' => $element['#title'],
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
  * like optionwidgets are using #element_validate to alter the value.
698 698
  */
699 699
 function nodereference_optionwidgets_validate($element, &$form_state) {
700
-  $field_key  = $element['#columns'][0];
700
+  $field_key = $element['#columns'][0];
701 701
 
702 702
   $value = $form_state['values'];
703 703
   $new_parents = array();
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
   static $results = array();
806 806
 
807 807
   // Create unique id for static cache.
808
-  $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
808
+  $cid = $field['field_name'].':'.$match.':'.($string !== '' ? $string : implode('-', $ids)).':'.$limit;
809 809
   if (!isset($results[$cid])) {
810 810
     $references = FALSE;
811 811
     if (module_exists('views') && !empty($field['advanced_view']) && $field['advanced_view'] != '--') {
@@ -931,15 +931,15 @@  discard block
 block discarded – undo
931 931
       'equals' => "= '%s'",
932 932
       'starts_with' => "$like '%s%%'",
933 933
     );
934
-    $where[] = 'n.title '. (isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
934
+    $where[] = 'n.title '.(isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
935 935
     $args[] = $string;
936 936
   }
937 937
   elseif ($ids) {
938
-    $where[] = 'n.nid IN (' . db_placeholders($ids) . ')';
938
+    $where[] = 'n.nid IN ('.db_placeholders($ids).')';
939 939
     $args = array_merge($args, $ids);
940 940
   }
941 941
 
942
-  $where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
942
+  $where_clause = $where ? 'WHERE ('.implode(') AND (', $where).')' : '';
943 943
   $sql = db_rewrite_sql("SELECT n.nid, n.title AS node_title, n.type AS node_type FROM {node} n $where_clause ORDER BY n.title, n.type");
944 944
   $result = $limit ? db_query_range($sql, $args, 0, $limit) : db_query($sql, $args);
945 945
   $references = array();
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
   $references = _nodereference_potential_references($field, $string, $match, array(), 10);
976 976
   foreach ($references as $id => $row) {
977 977
     // Add a class wrapper for a few required CSS overrides.
978
-    $matches[$row['title'] ." [nid:$id]"] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';
978
+    $matches[$row['title']." [nid:$id]"] = '<div class="reference-autocomplete">'.$row['rendered'].'</div>';
979 979
   }
980 980
   drupal_json($matches);
981 981
 }
@@ -1024,9 +1024,9 @@  discard block
 block discarded – undo
1024 1024
     $node = $vars['node'];
1025 1025
     $field = $node->referencing_field;
1026 1026
     $vars['template_files'][] = 'node-nodereference';
1027
-    $vars['template_files'][] = 'node-nodereference-'. $field['field_name'];
1028
-    $vars['template_files'][] = 'node-nodereference-'. $node->type;
1029
-    $vars['template_files'][] = 'node-nodereference-'. $field['field_name'] .'-'. $node->type;
1027
+    $vars['template_files'][] = 'node-nodereference-'.$field['field_name'];
1028
+    $vars['template_files'][] = 'node-nodereference-'.$node->type;
1029
+    $vars['template_files'][] = 'node-nodereference-'.$field['field_name'].'-'.$node->type;
1030 1030
   }
1031 1031
 }
1032 1032
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -96,8 +96,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 function nodereference_theme() {
28 28
   return array(
29 29
     'nodereference_select' => array(
30
-      'arguments' => array('element' => NULL),
30
+      'arguments' => array('element' => null),
31 31
     ),
32 32
     'nodereference_buttons' => array(
33
-      'arguments' => array('element' => NULL),
33
+      'arguments' => array('element' => null),
34 34
     ),
35 35
     'nodereference_autocomplete' => array(
36
-      'arguments' => array('element' => NULL),
36
+      'arguments' => array('element' => null),
37 37
     ),
38 38
     'nodereference_formatter_default' => array(
39 39
       'arguments' => array('element'),
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
       $form['referenceable_types'] = array(
85 85
         '#type' => 'checkboxes',
86 86
         '#title' => t('Content types that can be referenced'),
87
-        '#multiple' => TRUE,
87
+        '#multiple' => true,
88 88
         '#default_value' => is_array($field['referenceable_types']) ? $field['referenceable_types'] : array(),
89 89
         '#options' => array_map('check_plain', node_get_types('names')),
90 90
       );
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         $form['advanced'] = array(
107 107
            '#type' => 'fieldset',
108 108
            '#title' => t('Advanced - Nodes that can be referenced (View)'),
109
-           '#collapsible' => TRUE,
109
+           '#collapsible' => true,
110 110
            '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
111 111
          );
112 112
         if (count($views) > 1) {
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             '#type' => 'textfield',
123 123
             '#title' => t('View arguments'),
124 124
             '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
125
-            '#required' => FALSE,
125
+            '#required' => false,
126 126
             '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
127 127
           );
128 128
         }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
     case 'database columns':
147 147
       $columns = array(
148
-        'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
148
+        'nid' => array('type' => 'int', 'unsigned' => true, 'not null' => false, 'index' => true),
149 149
       );
150 150
       return $columns;
151 151
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
       }
223 223
       // Prevent performance hog if there are no ids to check.
224 224
       if ($ids) {
225
-        $refs = _nodereference_potential_references($field, '', NULL, $ids);
225
+        $refs = _nodereference_potential_references($field, '', null, $ids);
226 226
         foreach ($items as $delta => $item) {
227 227
           if (is_array($item)) {
228 228
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
  */
280 280
 function nodereference_content_is_empty($item, $field) {
281 281
   if (empty($item['nid'])) {
282
-    return TRUE;
282
+    return true;
283 283
   }
284
-  return FALSE;
284
+  return false;
285 285
 }
286 286
 
287 287
 /**
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
  *
376 376
  * Store node titles collected in the curent request.
377 377
  */
378
-function _nodereference_titles($nid, $known_title = NULL) {
378
+function _nodereference_titles($nid, $known_title = null) {
379 379
   static $titles = array();
380 380
   if (!isset($titles[$nid])) {
381 381
     $title = $known_title ? $known_title : db_result(db_query(db_rewrite_sql("SELECT n.title FROM {node} n WHERE n.nid=%d"), $nid));
@@ -442,20 +442,20 @@  discard block
 block discarded – undo
442 442
 function nodereference_elements() {
443 443
   return array(
444 444
     'nodereference_select' => array(
445
-      '#input' => TRUE,
445
+      '#input' => true,
446 446
       '#columns' => array('uid'), '#delta' => 0,
447 447
       '#process' => array('nodereference_select_process'),
448 448
     ),
449 449
     'nodereference_buttons' => array(
450
-      '#input' => TRUE,
450
+      '#input' => true,
451 451
       '#columns' => array('uid'), '#delta' => 0,
452 452
       '#process' => array('nodereference_buttons_process'),
453 453
     ),
454 454
     'nodereference_autocomplete' => array(
455
-      '#input' => TRUE,
455
+      '#input' => true,
456 456
       '#columns' => array('name'), '#delta' => 0,
457 457
       '#process' => array('nodereference_autocomplete_process'),
458
-      '#autocomplete_path' => FALSE,
458
+      '#autocomplete_path' => false,
459 459
       ),
460 460
     );
461 461
 }
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
           '#title' => t('Size of textfield'),
486 486
           '#default_value' => $size,
487 487
           '#element_validate' => array('_element_validate_integer_positive'),
488
-          '#required' => TRUE,
488
+          '#required' => true,
489 489
         );
490 490
       }
491 491
       else {
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
     case 'nodereference_autocomplete':
550 550
       $element = array(
551 551
         '#type' => 'nodereference_autocomplete',
552
-        '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
552
+        '#default_value' => isset($items[$delta]) ? $items[$delta] : null,
553 553
         '#value_callback' => 'nodereference_autocomplete_value',
554 554
       );
555 555
       break;
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
  *
563 563
  * Substitute in the node title for the node nid.
564 564
  */
565
-function nodereference_autocomplete_value($element, $edit = FALSE) {
565
+function nodereference_autocomplete_value($element, $edit = false) {
566 566
   $field_key  = $element['#columns'][0];
567 567
   if (!empty($element['#default_value'][$field_key])) {
568 568
     $nid = $element['#default_value'][$field_key];
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
     $value .= ' [nid:'. $nid .']';
571 571
     return array($field_key => $value);
572 572
   }
573
-  return array($field_key => NULL);
573
+  return array($field_key => null);
574 574
 }
575 575
 
576 576
 /**
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
   $field_key  = $element['#columns'][0];
728 728
   $delta = $element['#delta'];
729 729
   $value = $element['#value'][$field_key];
730
-  $nid = NULL;
730
+  $nid = null;
731 731
   if (!empty($value)) {
732 732
     preg_match('/^(?:\s*|(.*) )?\[\s*nid\s*:\s*(\d+)\s*\]$/', $value, $matches);
733 733
     if (!empty($matches)) {
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
     }
740 740
     else {
741 741
       // No explicit nid.
742
-      $reference = _nodereference_potential_references($field, $value, 'equals', NULL, 1);
742
+      $reference = _nodereference_potential_references($field, $value, 'equals', null, 1);
743 743
       if (empty($reference)) {
744 744
         form_error($element[$field_key], t('%name: found no valid post with that title.', array('%name' => t($field['widget']['label']))));
745 745
       }
@@ -801,19 +801,19 @@  discard block
 block discarded – undo
801 801
  *     ...
802 802
  *   )
803 803
  */
804
-function _nodereference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
804
+function _nodereference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = null) {
805 805
   static $results = array();
806 806
 
807 807
   // Create unique id for static cache.
808 808
   $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
809 809
   if (!isset($results[$cid])) {
810
-    $references = FALSE;
810
+    $references = false;
811 811
     if (module_exists('views') && !empty($field['advanced_view']) && $field['advanced_view'] != '--') {
812 812
       $references = _nodereference_potential_references_views($field, $string, $match, $ids, $limit);
813 813
     }
814 814
     // If the view doesn't exist, we got FALSE, and fallback to the regular 'standard mode'.
815 815
 
816
-    if ($references === FALSE) {
816
+    if ($references === false) {
817 817
       $references = _nodereference_potential_references_standard($field, $string, $match, $ids, $limit);
818 818
     }
819 819
 
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
  * Helper function for _nodereference_potential_references():
829 829
  * case of Views-defined referenceable nodes.
830 830
  */
831
-function _nodereference_potential_references_views($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
831
+function _nodereference_potential_references_views($field, $string = '', $match = 'contains', $ids = array(), $limit = null) {
832 832
   $view_name = $field['advanced_view'];
833 833
 
834 834
   if ($view = views_get_view($view_name)) {
@@ -890,13 +890,13 @@  discard block
 block discarded – undo
890 890
     $view->display_handler->set_option('row_options', $options);
891 891
 
892 892
     // Make sure the query is not cached
893
-    $view->is_cacheable = FALSE;
893
+    $view->is_cacheable = false;
894 894
 
895 895
     // Get the results.
896 896
     $result = $view->execute_display($display, $view_args);
897 897
   }
898 898
   else {
899
-    $result = FALSE;
899
+    $result = false;
900 900
   }
901 901
 
902 902
   return $result;
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
  * Helper function for _nodereference_potential_references():
907 907
  * referenceable nodes defined by content types.
908 908
  */
909
-function _nodereference_potential_references_standard($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
909
+function _nodereference_potential_references_standard($field, $string = '', $match = 'contains', $ids = array(), $limit = null) {
910 910
   $related_types = array();
911 911
   $where = array();
912 912
   $args = array();
@@ -991,19 +991,19 @@  discard block
 block discarded – undo
991 991
         // content.module's implementaion of hook_node_type() has already
992 992
         // refreshed _content_type_info().
993 993
         $fields = content_fields();
994
-        $rebuild = FALSE;
994
+        $rebuild = false;
995 995
         foreach ($fields as $field_name => $field) {
996 996
           if ($field['type'] == 'nodereference' && isset($field['referenceable_types'][$info->old_type])) {
997 997
             $field['referenceable_types'][$info->type] = empty($field['referenceable_types'][$info->old_type]) ? 0 : $info->type;
998 998
             unset($field['referenceable_types'][$info->old_type]);
999
-            content_field_instance_update($field, FALSE);
1000
-            $rebuild = TRUE;
999
+            content_field_instance_update($field, false);
1000
+            $rebuild = true;
1001 1001
           }
1002 1002
         }
1003 1003
 
1004 1004
         // Clear caches and rebuild menu only if any field has been updated.
1005 1005
         if ($rebuild) {
1006
-          content_clear_type_cache(TRUE);
1006
+          content_clear_type_cache(true);
1007 1007
           menu_rebuild();
1008 1008
         }
1009 1009
       }
Please login to merge, or discard this patch.
boinc/modules/contrib/cck/modules/userreference/userreference.module 6 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -653,7 +653,7 @@
 block discarded – undo
653 653
  * @param $ids
654 654
  *   Optional user ids to lookup (the $string and $match arguments will be
655 655
  *   ignored).
656
- * @param $limit
656
+ * @param integer $limit
657 657
  *   If non-zero, limit the size of the result set.
658 658
  *
659 659
  * @return
Please login to merge, or discard this patch.
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -10,258 +10,258 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_menu().
11 11
  */
12 12
 function userreference_menu() {
13
-  $items = array();
14
-  $items['userreference/autocomplete'] = array(
13
+    $items = array();
14
+    $items['userreference/autocomplete'] = array(
15 15
     'title' => 'Userreference autocomplete',
16 16
     'page callback' => 'userreference_autocomplete',
17 17
     'access arguments' => array('access content'),
18 18
     'type' => MENU_CALLBACK
19
-  );
20
-  return $items;
19
+    );
20
+    return $items;
21 21
 }
22 22
 
23 23
 /**
24 24
  * Implementation of hook_theme().
25 25
  */
26 26
 function userreference_theme() {
27
-  return array(
27
+    return array(
28 28
     'userreference_select' => array(
29
-      'arguments' => array('element' => NULL),
29
+        'arguments' => array('element' => NULL),
30 30
     ),
31 31
     'userreference_buttons' => array(
32
-      'arguments' => array('element' => NULL),
32
+        'arguments' => array('element' => NULL),
33 33
     ),
34 34
     'userreference_autocomplete' => array(
35
-      'arguments' => array('element' => NULL),
35
+        'arguments' => array('element' => NULL),
36 36
     ),
37 37
     'userreference_formatter_default' => array(
38
-      'arguments' => array('element'),
38
+        'arguments' => array('element'),
39 39
     ),
40 40
     'userreference_formatter_plain' => array(
41
-      'arguments' => array('element'),
41
+        'arguments' => array('element'),
42 42
     ),
43
-  );
43
+    );
44 44
 }
45 45
 
46 46
 /**
47 47
  * Implementaion of hook_ctools_plugin_directory().
48 48
  */
49 49
 function userreference_ctools_plugin_directory($module, $plugin) {
50
-  if ($module == 'ctools' && $plugin == 'relationships') {
50
+    if ($module == 'ctools' && $plugin == 'relationships') {
51 51
     return 'panels/' . $plugin;
52
-  }
52
+    }
53 53
 }
54 54
 
55 55
 /**
56 56
  * Implementation of hook_field_info().
57 57
  */
58 58
 function userreference_field_info() {
59
-  return array(
59
+    return array(
60 60
     'userreference' => array(
61
-      'label' => t('User reference'),
62
-      'description' => t('Store the ID of a related user as an integer value.'),
61
+        'label' => t('User reference'),
62
+        'description' => t('Store the ID of a related user as an integer value.'),
63 63
 //      'content_icon' => 'icon_content_noderef.png',
64 64
     ),
65
-  );
65
+    );
66 66
 }
67 67
 
68 68
 /**
69 69
  * Implementation of hook_field_settings().
70 70
  */
71 71
 function userreference_field_settings($op, $field) {
72
-  switch ($op) {
72
+    switch ($op) {
73 73
     case 'form':
74 74
       $form = array();
75
-      $form['referenceable_roles'] = array(
75
+        $form['referenceable_roles'] = array(
76 76
         '#type' => 'checkboxes',
77 77
         '#title' => t('User roles that can be referenced'),
78 78
         '#default_value' => isset($field['referenceable_roles']) && is_array($field['referenceable_roles']) ? array_filter($field['referenceable_roles']) : array(),
79 79
         '#options' => user_roles(1),
80
-      );
81
-      $form['referenceable_status'] = array(
80
+        );
81
+        $form['referenceable_status'] = array(
82 82
         '#type' => 'radios',
83 83
         '#title' => t('User status that can be referenced'),
84 84
         '#default_value' => isset($field['referenceable_status']) ? $field['referenceable_status'] : '',
85 85
         '#options' => array('' => t('All users'), 1 => t('Active users'), 0 => t('Blocked users')),
86
-      );
87
-      if (module_exists('views')) {
86
+        );
87
+        if (module_exists('views')) {
88 88
         $views = array('--' => '--');
89 89
         $all_views = views_get_all_views();
90 90
         foreach ($all_views as $view) {
91
-          // Only 'users' views that have fields will work for our purpose.
92
-          if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) {
91
+            // Only 'users' views that have fields will work for our purpose.
92
+            if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) {
93 93
             if ($view->type == 'Default') {
94
-              $views[t('Default Views')][$view->name] = $view->name;
94
+                $views[t('Default Views')][$view->name] = $view->name;
95 95
             }
96 96
             else {
97
-              $views[t('Existing Views')][$view->name] = $view->name;
97
+                $views[t('Existing Views')][$view->name] = $view->name;
98
+            }
98 99
             }
99
-          }
100 100
         }
101 101
 
102 102
         $form['advanced'] = array(
103
-           '#type' => 'fieldset',
104
-           '#title' => t('Advanced - Users that can be referenced (View)'),
105
-           '#collapsible' => TRUE,
106
-           '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
107
-         );
103
+            '#type' => 'fieldset',
104
+            '#title' => t('Advanced - Users that can be referenced (View)'),
105
+            '#collapsible' => TRUE,
106
+            '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
107
+            );
108 108
         if (count($views) > 1) {
109
-          $form['advanced']['advanced_view'] = array(
109
+            $form['advanced']['advanced_view'] = array(
110 110
             '#type' => 'select',
111 111
             '#title' => t('View used to select the users'),
112 112
             '#options' => $views,
113 113
             '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
114 114
             '#description' =>  t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>') .
115
-              t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
116
-          );
117
-          $form['advanced']['advanced_view_args'] = array(
115
+                t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
116
+            );
117
+            $form['advanced']['advanced_view_args'] = array(
118 118
             '#type' => 'textfield',
119 119
             '#title' => t('View arguments'),
120 120
             '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
121 121
             '#required' => FALSE,
122 122
             '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
123
-          );
123
+            );
124 124
         }
125 125
         else {
126
-          $form['advanced']['no_view_help'] = array(
126
+            $form['advanced']['no_view_help'] = array(
127 127
             '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') .
128
-              t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
129
-          );
128
+                t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
129
+            );
130
+        }
130 131
         }
131
-      }
132
-      return $form;
132
+        return $form;
133 133
 
134 134
     case 'save':
135 135
       $settings = array('referenceable_roles', 'referenceable_status');
136
-      if (module_exists('views')) {
136
+        if (module_exists('views')) {
137 137
         $settings[] = 'advanced_view';
138 138
         $settings[] = 'advanced_view_args';
139
-      }
140
-      return $settings;
139
+        }
140
+        return $settings;
141 141
 
142 142
     case 'database columns':
143 143
       $columns = array(
144 144
         'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
145
-      );
146
-      return $columns;
145
+        );
146
+        return $columns;
147 147
 
148 148
     case 'views data':
149 149
       $data = content_views_field_views_data($field);
150
-      $db_info = content_database_info($field);
151
-      $table_alias = content_views_tablename($field);
152
-
153
-      // Filter : swap the handler to the 'in' operator.
154
-      $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
155
-      // Argument: get the user name for summaries.
156
-      // We need to join a new instance of the users table.
157
-      $data["users_$table_alias"]['table']['join']['node'] = array(
150
+        $db_info = content_database_info($field);
151
+        $table_alias = content_views_tablename($field);
152
+
153
+        // Filter : swap the handler to the 'in' operator.
154
+        $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
155
+        // Argument: get the user name for summaries.
156
+        // We need to join a new instance of the users table.
157
+        $data["users_$table_alias"]['table']['join']['node'] = array(
158 158
         'table' => 'users',
159 159
         'field' => 'uid',
160 160
         'left_table' => $table_alias,
161 161
         'left_field' => $field['field_name'] .'_uid',
162
-      );
163
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias";
165
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name';
166
-      // Relationship: Add a relationship for related user.
167
-      $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array(
162
+        );
163
+        $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
+        $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias";
165
+        $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name';
166
+        // Relationship: Add a relationship for related user.
167
+        $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array(
168 168
         'base' => 'users',
169 169
         'field' => $db_info['columns']['uid']['column'],
170 170
         'handler' => 'content_handler_relationship',
171 171
         'label' => t($field['widget']['label']),
172 172
         'content_field_name' => $field['field_name'],
173
-      );
174
-      return $data;
173
+        );
174
+        return $data;
175 175
 
176
-  }
176
+    }
177 177
 }
178 178
 
179 179
 /**
180 180
  * Implementation of hook_field().
181 181
  */
182 182
 function userreference_field($op, &$node, $field, &$items, $teaser, $page) {
183
-  switch ($op) {
183
+    switch ($op) {
184 184
     case 'validate':
185 185
       // Extract uids to check.
186 186
       $ids = array();
187
-      foreach ($items as $delta => $item) {
187
+        foreach ($items as $delta => $item) {
188 188
         if (is_array($item) && !empty($item['uid'])) {
189
-          if (is_numeric($item['uid'])) {
189
+            if (is_numeric($item['uid'])) {
190 190
             $ids[] = $item['uid'];
191
-          }
192
-          else {
191
+            }
192
+            else {
193 193
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
194 194
             if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
195 195
             form_set_error($error_element, t('%name: invalid input.', array('%name' => t($field['widget']['label']))));
196
-          }
196
+            }
197
+        }
197 198
         }
198
-      }
199
-      // Prevent performance hog if there are no ids to check.
200
-      if ($ids) {
199
+        // Prevent performance hog if there are no ids to check.
200
+        if ($ids) {
201 201
         $refs = _userreference_potential_references($field, '', NULL, $ids);
202 202
         foreach ($items as $delta => $item) {
203
-          if (is_array($item)) {
203
+            if (is_array($item)) {
204 204
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
205 205
             if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
206 206
             if (!empty($item['uid']) && !isset($refs[$item['uid']])) {
207
-              form_set_error($error_element, t('%name: invalid user.', array('%name' => t($field['widget']['label']))));
207
+                form_set_error($error_element, t('%name: invalid user.', array('%name' => t($field['widget']['label']))));
208
+            }
208 209
             }
209
-          }
210 210
         }
211
-      }
212
-      return $items;
213
-  }
211
+        }
212
+        return $items;
213
+    }
214 214
 }
215 215
 
216 216
 /**
217 217
  * Implementation of hook_content_is_empty().
218 218
  */
219 219
 function userreference_content_is_empty($item, $field) {
220
-  if (empty($item['uid'])) {
220
+    if (empty($item['uid'])) {
221 221
     return TRUE;
222
-  }
223
-  return FALSE;
222
+    }
223
+    return FALSE;
224 224
 }
225 225
 
226 226
 /**
227 227
  * Implementation of hook_field_formatter_info().
228 228
  */
229 229
 function userreference_field_formatter_info() {
230
-  return array(
230
+    return array(
231 231
     'default' => array(
232
-      'label' => t('Default'),
233
-      'field types' => array('userreference'),
234
-      'multiple values' => CONTENT_HANDLE_CORE,
232
+        'label' => t('Default'),
233
+        'field types' => array('userreference'),
234
+        'multiple values' => CONTENT_HANDLE_CORE,
235 235
     ),
236 236
     'plain' => array(
237
-      'label' => t('Plain text'),
238
-      'field types' => array('userreference'),
239
-      'multiple values' => CONTENT_HANDLE_CORE,
237
+        'label' => t('Plain text'),
238
+        'field types' => array('userreference'),
239
+        'multiple values' => CONTENT_HANDLE_CORE,
240 240
     ),
241
-  );
241
+    );
242 242
 }
243 243
 
244 244
 /**
245 245
  * Theme function for 'default' userreference field formatter.
246 246
  */
247 247
 function theme_userreference_formatter_default($element) {
248
-  $output = '';
248
+    $output = '';
249 249
 
250
-  if (isset($element['#item']['uid']) && $account = user_load(array('uid' => $element['#item']['uid']))) {
250
+    if (isset($element['#item']['uid']) && $account = user_load(array('uid' => $element['#item']['uid']))) {
251 251
     $output = theme('username', $account);
252
-  }
253
-  return $output;
252
+    }
253
+    return $output;
254 254
 }
255 255
 
256 256
 /**
257 257
  * Theme function for 'plain' userreference field formatter.
258 258
  */
259 259
 function theme_userreference_formatter_plain($element) {
260
-  $output = '';
261
-  if (isset($element['#item']['uid']) && $account = user_load(array('uid' => $element['#item']['uid']))) {
260
+    $output = '';
261
+    if (isset($element['#item']['uid']) && $account = user_load(array('uid' => $element['#item']['uid']))) {
262 262
     $output = $account->name;
263
-  }
264
-  return $output;
263
+    }
264
+    return $output;
265 265
 }
266 266
 
267 267
 /**
@@ -279,32 +279,32 @@  discard block
 block discarded – undo
279 279
  * differently.
280 280
  */
281 281
 function userreference_widget_info() {
282
-  return array(
282
+    return array(
283 283
     'userreference_select' => array(
284
-      'label' => t('Select list'),
285
-      'field types' => array('userreference'),
286
-      'multiple values' => CONTENT_HANDLE_MODULE,
287
-      'callbacks' => array(
284
+        'label' => t('Select list'),
285
+        'field types' => array('userreference'),
286
+        'multiple values' => CONTENT_HANDLE_MODULE,
287
+        'callbacks' => array(
288 288
         'default value' => CONTENT_CALLBACK_DEFAULT,
289
-      ),
289
+        ),
290 290
     ),
291 291
     'userreference_buttons' => array(
292
-      'label' => t('Check boxes/radio buttons'),
293
-      'field types' => array('userreference'),
294
-      'multiple values' => CONTENT_HANDLE_MODULE,
295
-      'callbacks' => array(
292
+        'label' => t('Check boxes/radio buttons'),
293
+        'field types' => array('userreference'),
294
+        'multiple values' => CONTENT_HANDLE_MODULE,
295
+        'callbacks' => array(
296 296
         'default value' => CONTENT_CALLBACK_DEFAULT,
297
-      ),
297
+        ),
298 298
     ),
299 299
     'userreference_autocomplete' => array(
300
-      'label' => t('Autocomplete text field'),
301
-      'field types' => array('userreference'),
302
-      'multiple values' => CONTENT_HANDLE_CORE,
303
-      'callbacks' => array(
300
+        'label' => t('Autocomplete text field'),
301
+        'field types' => array('userreference'),
302
+        'multiple values' => CONTENT_HANDLE_CORE,
303
+        'callbacks' => array(
304 304
         'default value' => CONTENT_CALLBACK_DEFAULT,
305
-      ),
305
+        ),
306 306
     ),
307
-  );
307
+    );
308 308
 }
309 309
 
310 310
 /**
@@ -320,23 +320,23 @@  discard block
 block discarded – undo
320 320
  * (see nodereference and userreference).
321 321
  */
322 322
 function userreference_elements() {
323
-  return array(
323
+    return array(
324 324
     'userreference_select' => array(
325
-      '#input' => TRUE,
326
-      '#columns' => array('uid'), '#delta' => 0,
327
-      '#process' => array('userreference_select_process'),
325
+        '#input' => TRUE,
326
+        '#columns' => array('uid'), '#delta' => 0,
327
+        '#process' => array('userreference_select_process'),
328 328
     ),
329 329
     'userreference_buttons' => array(
330
-      '#input' => TRUE,
331
-      '#columns' => array('uid'), '#delta' => 0,
332
-      '#process' => array('userreference_buttons_process'),
330
+        '#input' => TRUE,
331
+        '#columns' => array('uid'), '#delta' => 0,
332
+        '#process' => array('userreference_buttons_process'),
333 333
     ),
334 334
     'userreference_autocomplete' => array(
335
-      '#input' => TRUE,
336
-      '#columns' => array('name'), '#delta' => 0,
337
-      '#process' => array('userreference_autocomplete_process'),
338
-      '#autocomplete_path' => FALSE,
339
-      ),
335
+        '#input' => TRUE,
336
+        '#columns' => array('name'), '#delta' => 0,
337
+        '#process' => array('userreference_autocomplete_process'),
338
+        '#autocomplete_path' => FALSE,
339
+        ),
340 340
     );
341 341
 }
342 342
 
@@ -344,45 +344,45 @@  discard block
 block discarded – undo
344 344
  * Implementation of hook_widget_settings().
345 345
  */
346 346
 function userreference_widget_settings($op, $widget) {
347
-  switch ($op) {
347
+    switch ($op) {
348 348
     case 'form':
349 349
       $form = array();
350
-      $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
351
-      $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
352
-      if ($widget['type'] == 'userreference_autocomplete') {
350
+        $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
351
+        $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
352
+        if ($widget['type'] == 'userreference_autocomplete') {
353 353
         $form['autocomplete_match'] = array(
354
-          '#type' => 'select',
355
-          '#title' => t('Autocomplete matching'),
356
-          '#default_value' => $match,
357
-          '#options' => array(
354
+            '#type' => 'select',
355
+            '#title' => t('Autocomplete matching'),
356
+            '#default_value' => $match,
357
+            '#options' => array(
358 358
             'starts_with' => t('Starts with'),
359 359
             'contains' => t('Contains'),
360
-          ),
361
-          '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'),
360
+            ),
361
+            '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'),
362 362
         );
363 363
         $form['size'] = array(
364
-          '#type' => 'textfield',
365
-          '#title' => t('Size of textfield'),
366
-          '#default_value' => $size,
367
-          '#element_validate' => array('_element_validate_integer_positive'),
368
-          '#required' => TRUE,
364
+            '#type' => 'textfield',
365
+            '#title' => t('Size of textfield'),
366
+            '#default_value' => $size,
367
+            '#element_validate' => array('_element_validate_integer_positive'),
368
+            '#required' => TRUE,
369 369
         );
370
-      }
371
-      else {
370
+        }
371
+        else {
372 372
         $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
373 373
         $form['size'] = array('#type' => 'hidden', '#value' => $size);
374
-      }
375
-      $form['reverse_link'] = array(
374
+        }
375
+        $form['reverse_link'] = array(
376 376
         '#type' => 'checkbox',
377 377
         '#title' => t('Reverse link'),
378 378
         '#default_value' => isset($widget['reverse_link']) ? $widget['reverse_link'] : 0,
379 379
         '#description' => t('If selected, a reverse link back to the referencing node will displayed on the referenced user record.'),
380
-      );
381
-      return $form;
380
+        );
381
+        return $form;
382 382
 
383 383
     case 'save':
384 384
       return array('autocomplete_match', 'size', 'reverse_link');
385
-  }
385
+    }
386 386
 }
387 387
 
388 388
 /**
@@ -417,30 +417,30 @@  discard block
 block discarded – undo
417 417
  *   the form item for a single element for this field
418 418
  */
419 419
 function userreference_widget(&$form, &$form_state, $field, $items, $delta = 0) {
420
-  switch ($field['widget']['type']) {
420
+    switch ($field['widget']['type']) {
421 421
     case 'userreference_select':
422 422
       $element = array(
423 423
         '#type' => 'userreference_select',
424 424
         '#default_value' => $items,
425
-      );
426
-      break;
425
+        );
426
+        break;
427 427
 
428 428
     case 'userreference_buttons':
429 429
       $element = array(
430 430
         '#type' => 'userreference_buttons',
431 431
         '#default_value' => $items,
432
-      );
433
-      break;
432
+        );
433
+        break;
434 434
 
435 435
     case 'userreference_autocomplete':
436 436
       $element = array(
437 437
         '#type' => 'userreference_autocomplete',
438 438
         '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
439 439
         '#value_callback' => 'userreference_autocomplete_value',
440
-      );
441
-      break;
442
-  }
443
-  return $element;
440
+        );
441
+        break;
442
+    }
443
+    return $element;
444 444
 }
445 445
 
446 446
 /**
@@ -449,12 +449,12 @@  discard block
 block discarded – undo
449 449
  * Substitute in the user name for the uid.
450 450
  */
451 451
 function userreference_autocomplete_value($element, $edit = FALSE) {
452
-  $field_key  = $element['#columns'][0];
453
-  if (!empty($element['#default_value'][$field_key])) {
452
+    $field_key  = $element['#columns'][0];
453
+    if (!empty($element['#default_value'][$field_key])) {
454 454
     $value = db_result(db_query("SELECT name FROM {users} WHERE uid = '%d'", $element['#default_value'][$field_key]));
455 455
     return array($field_key => $value);
456
-  }
457
-  return array($field_key => NULL);
456
+    }
457
+    return array($field_key => NULL);
458 458
 }
459 459
 
460 460
 /**
@@ -466,11 +466,11 @@  discard block
 block discarded – undo
466 466
  * The $fields array is in $form['#field_info'][$element['#field_name']].
467 467
  */
468 468
 function userreference_select_process($element, $edit, $form_state, $form) {
469
-  // The userreference_select widget doesn't need to create its own
470
-  // element, it can wrap around the optionwidgets_select element.
471
-  // Add a validation step where the value can be unwrapped.
472
-  $field_key  = $element['#columns'][0];
473
-  $element[$field_key] = array(
469
+    // The userreference_select widget doesn't need to create its own
470
+    // element, it can wrap around the optionwidgets_select element.
471
+    // Add a validation step where the value can be unwrapped.
472
+    $field_key  = $element['#columns'][0];
473
+    $element[$field_key] = array(
474 474
     '#type' => 'optionwidgets_select',
475 475
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
476 476
     // The following values were set by the content module and need
@@ -482,12 +482,12 @@  discard block
 block discarded – undo
482 482
     '#type_name' => $element['#type_name'],
483 483
     '#delta' => $element['#delta'],
484 484
     '#columns' => $element['#columns'],
485
-  );
486
-  if (empty($element[$field_key]['#element_validate'])) {
485
+    );
486
+    if (empty($element[$field_key]['#element_validate'])) {
487 487
     $element[$field_key]['#element_validate'] = array();
488
-  }
489
-  array_unshift($element[$field_key]['#element_validate'], 'userreference_optionwidgets_validate');
490
-  return $element;
488
+    }
489
+    array_unshift($element[$field_key]['#element_validate'], 'userreference_optionwidgets_validate');
490
+    return $element;
491 491
 }
492 492
 
493 493
 /**
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
  * The $fields array is in $form['#field_info'][$element['#field_name']].
500 500
  */
501 501
 function userreference_buttons_process($element, $edit, $form_state, $form) {
502
-  // The userreference_select widget doesn't need to create its own
503
-  // element, it can wrap around the optionwidgets_select element.
504
-  // Add a validation step where the value can be unwrapped.
505
-  $field_key  = $element['#columns'][0];
506
-  $element[$field_key] = array(
502
+    // The userreference_select widget doesn't need to create its own
503
+    // element, it can wrap around the optionwidgets_select element.
504
+    // Add a validation step where the value can be unwrapped.
505
+    $field_key  = $element['#columns'][0];
506
+    $element[$field_key] = array(
507 507
     '#type' => 'optionwidgets_buttons',
508 508
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
509 509
     // The following values were set by the content module and need
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
     '#type_name' => $element['#type_name'],
516 516
     '#delta' => $element['#delta'],
517 517
     '#columns' => $element['#columns'],
518
-  );
519
-  if (empty($element[$field_key]['#element_validate'])) {
518
+    );
519
+    if (empty($element[$field_key]['#element_validate'])) {
520 520
     $element[$field_key]['#element_validate'] = array();
521
-  }
522
-  array_unshift($element[$field_key]['#element_validate'], 'userreference_optionwidgets_validate');
523
-  return $element;
521
+    }
522
+    array_unshift($element[$field_key]['#element_validate'], 'userreference_optionwidgets_validate');
523
+    return $element;
524 524
 }
525 525
 
526 526
 /**
@@ -531,13 +531,13 @@  discard block
 block discarded – undo
531 531
  *
532 532
  */
533 533
 function userreference_autocomplete_process($element, $edit, $form_state, $form) {
534
-  // The userreference autocomplete widget doesn't need to create its own
535
-  // element, it can wrap around the text_textfield element and add an autocomplete
536
-  // path and some extra processing to it.
537
-  // Add a validation step where the value can be unwrapped.
538
-  $field_key  = $element['#columns'][0];
534
+    // The userreference autocomplete widget doesn't need to create its own
535
+    // element, it can wrap around the text_textfield element and add an autocomplete
536
+    // path and some extra processing to it.
537
+    // Add a validation step where the value can be unwrapped.
538
+    $field_key  = $element['#columns'][0];
539 539
 
540
-  $element[$field_key] = array(
540
+    $element[$field_key] = array(
541 541
     '#type' => 'text_textfield',
542 542
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
543 543
     '#autocomplete_path' => 'userreference/autocomplete/'. $element['#field_name'],
@@ -550,20 +550,20 @@  discard block
 block discarded – undo
550 550
     '#type_name' => $element['#type_name'],
551 551
     '#delta' => $element['#delta'],
552 552
     '#columns' => $element['#columns'],
553
-  );
554
-  if (empty($element[$field_key]['#element_validate'])) {
553
+    );
554
+    if (empty($element[$field_key]['#element_validate'])) {
555 555
     $element[$field_key]['#element_validate'] = array();
556
-  }
557
-  array_unshift($element[$field_key]['#element_validate'], 'userreference_autocomplete_validate');
556
+    }
557
+    array_unshift($element[$field_key]['#element_validate'], 'userreference_autocomplete_validate');
558 558
 
559
-  // Used so that hook_field('validate') knows where to flag an error.
560
-  $element['_error_element'] = array(
559
+    // Used so that hook_field('validate') knows where to flag an error.
560
+    $element['_error_element'] = array(
561 561
     '#type' => 'value',
562 562
     // Wrapping the element around a text_textfield element creates a
563 563
     // nested element, so the final id will look like 'field-name-0-uid-uid'.
564 564
     '#value' => implode('][', array_merge($element['#parents'], array($field_key, $field_key))),
565
-  );
566
-  return $element;
565
+    );
566
+    return $element;
567 567
 }
568 568
 
569 569
 /**
@@ -578,20 +578,20 @@  discard block
 block discarded – undo
578 578
  * like optionwidgets are using #element_validate to alter the value.
579 579
  */
580 580
 function userreference_optionwidgets_validate($element, &$form_state) {
581
-  $field_key  = $element['#columns'][0];
581
+    $field_key  = $element['#columns'][0];
582 582
 
583
-  $value = $form_state['values'];
584
-  $new_parents = array();
585
-  foreach ($element['#parents'] as $parent) {
583
+    $value = $form_state['values'];
584
+    $new_parents = array();
585
+    foreach ($element['#parents'] as $parent) {
586 586
     $value = $value[$parent];
587 587
     // Use === to be sure we get right results if parent is a zero (delta) value.
588 588
     if ($parent === $field_key) {
589
-      $element['#parents'] = $new_parents;
590
-      form_set_value($element, $value, $form_state);
591
-      break;
589
+        $element['#parents'] = $new_parents;
590
+        form_set_value($element, $value, $form_state);
591
+        break;
592 592
     }
593 593
     $new_parents[] = $parent;
594
-  }
594
+    }
595 595
 }
596 596
 
597 597
 /**
@@ -602,36 +602,36 @@  discard block
 block discarded – undo
602 602
  * back to its original location, 'field-name-0-uid'.
603 603
  */
604 604
 function userreference_autocomplete_validate($element, &$form_state) {
605
-  $field_name = $element['#field_name'];
606
-  $type_name = $element['#type_name'];
607
-  $field = content_fields($field_name, $type_name);
608
-  $field_key = $element['#columns'][0];
609
-  $value = $element['#value'][$field_key];
610
-  $uid = NULL;
611
-  if (!empty($value)) {
605
+    $field_name = $element['#field_name'];
606
+    $type_name = $element['#type_name'];
607
+    $field = content_fields($field_name, $type_name);
608
+    $field_key = $element['#columns'][0];
609
+    $value = $element['#value'][$field_key];
610
+    $uid = NULL;
611
+    if (!empty($value)) {
612 612
     $reference = _userreference_potential_references($field, $value, 'equals', NULL, 1);
613 613
     if (empty($reference)) {
614
-      form_error($element[$field_key], t('%name: found no valid user with that name.', array('%name' => t($field['widget']['label']))));
614
+        form_error($element[$field_key], t('%name: found no valid user with that name.', array('%name' => t($field['widget']['label']))));
615 615
     }
616 616
     else {
617
-      $uid = key($reference);
617
+        $uid = key($reference);
618
+    }
618 619
     }
619
-  }
620
-  form_set_value($element, $uid, $form_state);
620
+    form_set_value($element, $uid, $form_state);
621 621
 }
622 622
 
623 623
 /**
624 624
  * Implementation of hook_allowed_values().
625 625
  */
626 626
 function userreference_allowed_values($field) {
627
-  $references = _userreference_potential_references($field);
627
+    $references = _userreference_potential_references($field);
628 628
 
629
-  $options = array();
630
-  foreach ($references as $key => $value) {
629
+    $options = array();
630
+    foreach ($references as $key => $value) {
631 631
     $options[$key] = $value['rendered'];
632
-  }
632
+    }
633 633
 
634
-  return $options;
634
+    return $options;
635 635
 }
636 636
 
637 637
 /**
@@ -667,26 +667,26 @@  discard block
 block discarded – undo
667 667
  *   )
668 668
  */
669 669
 function _userreference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
670
-  static $results = array();
670
+    static $results = array();
671 671
 
672
-  // Create unique id for static cache.
673
-  $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
674
-  if (!isset($results[$cid])) {
672
+    // Create unique id for static cache.
673
+    $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
674
+    if (!isset($results[$cid])) {
675 675
     $references = FALSE;
676 676
     if (module_exists('views') && !empty($field['advanced_view']) && $field['advanced_view'] != '--') {
677
-      $references = _userreference_potential_references_views($field, $string, $match, $ids, $limit);
677
+        $references = _userreference_potential_references_views($field, $string, $match, $ids, $limit);
678 678
     }
679 679
     // If the view doesn't exist, we got FALSE, and fallback to the regular 'standard mode'.
680 680
 
681 681
     if ($references === FALSE) {
682
-      $references = _userreference_potential_references_standard($field, $string, $match, $ids, $limit);
682
+        $references = _userreference_potential_references_standard($field, $string, $match, $ids, $limit);
683 683
     }
684 684
 
685 685
     // Store the results.
686 686
     $results[$cid] = !empty($references) ? $references : array();
687
-  }
687
+    }
688 688
 
689
-  return $results[$cid];
689
+    return $results[$cid];
690 690
 }
691 691
 
692 692
 /**
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
  * case of Views-defined referenceable users.
695 695
  */
696 696
 function _userreference_potential_references_views($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
697
-  $view_name = $field['advanced_view'];
697
+    $view_name = $field['advanced_view'];
698 698
 
699
-  if ($view = views_get_view($view_name)) {
699
+    if ($view = views_get_view($view_name)) {
700 700
     // We add a display, and let it derive from the 'default' display.
701 701
     // TODO: We should let the user pick a display in the fields settings - sort of requires AHAH...
702 702
     $display = $view->add_display('content_references');
@@ -713,12 +713,12 @@  discard block
 block discarded – undo
713 713
     // Additional options to let content_plugin_display_references::query()
714 714
     // narrow the results.
715 715
     $options = array(
716
-      'table' => 'users',
717
-      'field_string' => 'name',
718
-      'string' => $string,
719
-      'match' => $match,
720
-      'field_id' => 'uid',
721
-      'ids' => $ids,
716
+        'table' => 'users',
717
+        'field_string' => 'name',
718
+        'string' => $string,
719
+        'match' => $match,
720
+        'field_id' => 'uid',
721
+        'ids' => $ids,
722 722
     );
723 723
     $view->display_handler->set_option('content_options', $options);
724 724
 
@@ -731,26 +731,26 @@  discard block
 block discarded – undo
731 731
 
732 732
     // Get arguments for the view.
733 733
     if (!empty($field['advanced_view_args'])) {
734
-      // TODO: Support Tokens using token.module ?
735
-      $view_args = array_map('trim', explode(',', $field['advanced_view_args']));
734
+        // TODO: Support Tokens using token.module ?
735
+        $view_args = array_map('trim', explode(',', $field['advanced_view_args']));
736 736
     }
737 737
     else {
738
-      $view_args = array();
738
+        $view_args = array();
739 739
     }
740 740
 
741 741
     // We do need name field, so add it if not present (unlikely, but...)
742 742
     $fields = $view->get_items('field', $display);
743 743
     if (!isset($fields['name'])) {
744
-      $view->add_item($display, 'field', 'users', 'name');
744
+        $view->add_item($display, 'field', 'users', 'name');
745 745
     }
746 746
 
747 747
     // If not set, make all fields inline and define a separator.
748 748
     $options = $view->display_handler->get_option('row_options');
749 749
     if (empty($options['inline'])) {
750
-      $options['inline'] = drupal_map_assoc(array_keys($view->get_items('field', $display)));
750
+        $options['inline'] = drupal_map_assoc(array_keys($view->get_items('field', $display)));
751 751
     }
752 752
     if (empty($options['separator'])) {
753
-      $options['separator'] = '-';
753
+        $options['separator'] = '-';
754 754
     }
755 755
     $view->display_handler->set_option('row_options', $options);
756 756
 
@@ -759,12 +759,12 @@  discard block
 block discarded – undo
759 759
 
760 760
     // Get the results.
761 761
     $result = $view->execute_display($display, $view_args);
762
-  }
763
-  else {
762
+    }
763
+    else {
764 764
     $result = FALSE;
765
-  }
765
+    }
766 766
 
767
-  return $result;
767
+    return $result;
768 768
 }
769 769
 
770 770
 /**
@@ -772,112 +772,112 @@  discard block
 block discarded – undo
772 772
  * referenceable users defined by user role and status
773 773
  */
774 774
 function _userreference_potential_references_standard($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
775
-  $where = array();
776
-  $args = array();
777
-  $join = array();
775
+    $where = array();
776
+    $args = array();
777
+    $join = array();
778 778
 
779
-  if ($string !== '') {
779
+    if ($string !== '') {
780 780
     $like = $GLOBALS["db_type"] == 'pgsql' ? "ILIKE" : "LIKE";
781 781
     $match_clauses = array(
782
-      'contains' => "$like '%%%s%%'",
783
-      'equals' => "= '%s'",
784
-      'starts_with' => "$like '%s%%'",
782
+        'contains' => "$like '%%%s%%'",
783
+        'equals' => "= '%s'",
784
+        'starts_with' => "$like '%s%%'",
785 785
     );
786 786
     $where[] = 'u.name '. (isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
787 787
     $args[] = $string;
788
-  }
789
-  elseif ($ids) {
788
+    }
789
+    elseif ($ids) {
790 790
     $where[] = 'u.uid IN (' . db_placeholders($ids) . ')';
791 791
     $args = array_merge($args, $ids);
792
-  }
793
-  else {
792
+    }
793
+    else {
794 794
     $where[] = "u.uid > 0";
795
-  }
795
+    }
796 796
 
797
-  $roles = array();
798
-  if (isset($field['referenceable_roles']) && is_array($field['referenceable_roles'])) {
797
+    $roles = array();
798
+    if (isset($field['referenceable_roles']) && is_array($field['referenceable_roles'])) {
799 799
     // keep only selected checkboxes
800 800
     $roles = array_filter($field['referenceable_roles']);
801 801
     // filter invalid values that seems to get through sometimes ??
802 802
     $roles = array_intersect(array_keys(user_roles(1)), $roles);
803
-  }
804
-  if (!empty($roles) && !in_array(DRUPAL_AUTHENTICATED_RID, $roles)) {
803
+    }
804
+    if (!empty($roles) && !in_array(DRUPAL_AUTHENTICATED_RID, $roles)) {
805 805
     $where[] = "r.rid IN (". implode($roles, ',') .")";
806 806
     $join[] = 'LEFT JOIN {users_roles} r ON u.uid = r.uid';
807
-  }
807
+    }
808 808
 
809
-  if (isset($field['referenceable_status']) && is_numeric($field['referenceable_status'])) {
809
+    if (isset($field['referenceable_status']) && is_numeric($field['referenceable_status'])) {
810 810
     $where[] = 'u.status = %d';
811 811
     $args[] = $field['referenceable_status'];
812
-  }
812
+    }
813 813
 
814
-  $users = array();
815
-  $where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
816
-  $result = db_query('SELECT u.name, u.uid FROM {users} u '. implode(' ', $join) ." $where_clause ORDER BY u.name ASC", $args);
817
-  while ($user = db_fetch_object($result)) {
814
+    $users = array();
815
+    $where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
816
+    $result = db_query('SELECT u.name, u.uid FROM {users} u '. implode(' ', $join) ." $where_clause ORDER BY u.name ASC", $args);
817
+    while ($user = db_fetch_object($result)) {
818 818
     $users[$user->uid] = array(
819
-      'title' => $user->name,
820
-      'rendered' => check_plain($user->name),
819
+        'title' => $user->name,
820
+        'rendered' => check_plain($user->name),
821 821
     );
822
-  }
823
-  return $users;
822
+    }
823
+    return $users;
824 824
 }
825 825
 
826 826
 /**
827 827
  * Menu callback; Retrieve a pipe delimited string of autocomplete suggestions for existing users
828 828
  */
829 829
 function userreference_autocomplete($field_name, $string = '') {
830
-  $fields = content_fields();
831
-  $field = $fields[$field_name];
832
-  $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
833
-  $matches = array();
830
+    $fields = content_fields();
831
+    $field = $fields[$field_name];
832
+    $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
833
+    $matches = array();
834 834
 
835
-  $references = _userreference_potential_references($field, $string, $match, array(), 10);
836
-  foreach ($references as $id => $row) {
835
+    $references = _userreference_potential_references($field, $string, $match, array(), 10);
836
+    foreach ($references as $id => $row) {
837 837
     // Add a class wrapper for a few required CSS overrides.
838 838
     $matches[$row['title']] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';
839
-  }
840
-  drupal_json($matches);
839
+    }
840
+    drupal_json($matches);
841 841
 }
842 842
 
843 843
 /**
844 844
  * Implementation of hook_user().
845 845
  */
846 846
 function userreference_user($type, &$edit, &$account) {
847
-  switch ($type) {
847
+    switch ($type) {
848 848
     case 'load':
849 849
       // Only add links if we are on the user 'view' page.
850 850
       if (arg(0) != 'user' || arg(2)) {
851 851
         return;
852
-      }
853
-      // find CCK userreference field tables
854
-      // search through them for matching user ids and load those nodes
855
-      $additions = array();
856
-      $types = content_types();
857
-
858
-      // Find the table and columns to search through, if the same
859
-      // table comes up in more than one content type, we only need
860
-      // to search it once.
861
-      $search_tables = array();
862
-      foreach ($types as $type_name => $type) {
852
+        }
853
+        // find CCK userreference field tables
854
+        // search through them for matching user ids and load those nodes
855
+        $additions = array();
856
+        $types = content_types();
857
+
858
+        // Find the table and columns to search through, if the same
859
+        // table comes up in more than one content type, we only need
860
+        // to search it once.
861
+        $search_tables = array();
862
+        foreach ($types as $type_name => $type) {
863 863
         foreach ($type['fields'] as $field) {
864
-          // Only add tables when reverse link has been selected.
865
-          if ($field['type'] == 'userreference' && !empty($field['widget']['reverse_link'])) {
864
+            // Only add tables when reverse link has been selected.
865
+            if ($field['type'] == 'userreference' && !empty($field['widget']['reverse_link'])) {
866 866
             $db_info = content_database_info($field);
867 867
             $search_tables[$db_info['table']][] = $db_info['columns']['uid']['column'];
868
-          }
868
+            }
869
+        }
869 870
         }
870
-      }
871
-      foreach ($search_tables as $table => $columns) {
871
+        foreach ($search_tables as $table => $columns) {
872 872
         foreach ($columns as $column) {
873
-          $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1"));
874
-          while ($data = db_fetch_object($ids)) {
873
+            $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1"));
874
+            while ($data = db_fetch_object($ids)) {
875 875
             $additions[$data->type][$data->nid] = $data->title;
876
-          }
876
+            }
877 877
         }
878
-      }
879
-      $account->userreference = $additions;
880
-      break;
878
+        }
879
+        $account->userreference = $additions;
880
+        break;
881 881
 
882 882
     case 'view':
883 883
       if (!empty($account->userreference)) {
@@ -885,28 +885,28 @@  discard block
 block discarded – undo
885 885
         $additions = array();
886 886
         $values = array();
887 887
         foreach ($account->userreference as $node_type => $nodes) {
888
-          foreach ($nodes as $nid => $title) {
888
+            foreach ($nodes as $nid => $title) {
889 889
             $values[$node_type][] = l($title, 'node/'. $nid);
890
-          }
891
-          if (isset($values[$node_type])) {
890
+            }
891
+            if (isset($values[$node_type])) {
892 892
             $additions[] = array(
893
-              '#type' => 'user_profile_item',
894
-              '#title' => check_plain($node_types[$node_type]['name']),
895
-              '#value' => theme('item_list', $values[$node_type]),
893
+                '#type' => 'user_profile_item',
894
+                '#title' => check_plain($node_types[$node_type]['name']),
895
+                '#value' => theme('item_list', $values[$node_type]),
896 896
             );
897
-          }
897
+            }
898 898
         }
899 899
         if ($additions) {
900
-          $account->content['userreference'] = $additions + array(
900
+            $account->content['userreference'] = $additions + array(
901 901
             '#type' => 'user_profile_category',
902 902
             '#attributes' => array('class' => 'user-member'),
903 903
             '#title' => t('Related content'),
904 904
             '#weight' => 10,
905
-          );
905
+            );
906 906
         }
907
-      }
908
-      break;
909
-  }
907
+        }
908
+        break;
909
+    }
910 910
 }
911 911
 
912 912
 /**
@@ -921,13 +921,13 @@  discard block
 block discarded – undo
921 921
  * $element['#delta]  is the position of this element in the group
922 922
  */
923 923
 function theme_userreference_select($element) {
924
-  return $element['#children'];
924
+    return $element['#children'];
925 925
 }
926 926
 
927 927
 function theme_userreference_buttons($element) {
928
-  return $element['#children'];
928
+    return $element['#children'];
929 929
 }
930 930
 
931 931
 function theme_userreference_autocomplete($element) {
932
-  return $element['#children'];
932
+    return $element['#children'];
933 933
 }
934 934
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -70,108 +70,108 @@  discard block
 block discarded – undo
70 70
  */
71 71
 function userreference_field_settings($op, $field) {
72 72
   switch ($op) {
73
-    case 'form':
74
-      $form = array();
75
-      $form['referenceable_roles'] = array(
76
-        '#type' => 'checkboxes',
77
-        '#title' => t('User roles that can be referenced'),
78
-        '#default_value' => isset($field['referenceable_roles']) && is_array($field['referenceable_roles']) ? array_filter($field['referenceable_roles']) : array(),
79
-        '#options' => user_roles(1),
80
-      );
81
-      $form['referenceable_status'] = array(
82
-        '#type' => 'radios',
83
-        '#title' => t('User status that can be referenced'),
84
-        '#default_value' => isset($field['referenceable_status']) ? $field['referenceable_status'] : '',
85
-        '#options' => array('' => t('All users'), 1 => t('Active users'), 0 => t('Blocked users')),
86
-      );
87
-      if (module_exists('views')) {
88
-        $views = array('--' => '--');
89
-        $all_views = views_get_all_views();
90
-        foreach ($all_views as $view) {
91
-          // Only 'users' views that have fields will work for our purpose.
92
-          if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) {
93
-            if ($view->type == 'Default') {
94
-              $views[t('Default Views')][$view->name] = $view->name;
95
-            }
96
-            else {
97
-              $views[t('Existing Views')][$view->name] = $view->name;
98
-            }
73
+  case 'form':
74
+    $form = array();
75
+    $form['referenceable_roles'] = array(
76
+      '#type' => 'checkboxes',
77
+      '#title' => t('User roles that can be referenced'),
78
+      '#default_value' => isset($field['referenceable_roles']) && is_array($field['referenceable_roles']) ? array_filter($field['referenceable_roles']) : array(),
79
+      '#options' => user_roles(1),
80
+    );
81
+    $form['referenceable_status'] = array(
82
+      '#type' => 'radios',
83
+      '#title' => t('User status that can be referenced'),
84
+      '#default_value' => isset($field['referenceable_status']) ? $field['referenceable_status'] : '',
85
+      '#options' => array('' => t('All users'), 1 => t('Active users'), 0 => t('Blocked users')),
86
+    );
87
+    if (module_exists('views')) {
88
+      $views = array('--' => '--');
89
+      $all_views = views_get_all_views();
90
+      foreach ($all_views as $view) {
91
+        // Only 'users' views that have fields will work for our purpose.
92
+        if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) {
93
+          if ($view->type == 'Default') {
94
+            $views[t('Default Views')][$view->name] = $view->name;
95
+          }
96
+          else {
97
+            $views[t('Existing Views')][$view->name] = $view->name;
99 98
           }
100
-        }
101
-
102
-        $form['advanced'] = array(
103
-           '#type' => 'fieldset',
104
-           '#title' => t('Advanced - Users that can be referenced (View)'),
105
-           '#collapsible' => TRUE,
106
-           '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
107
-         );
108
-        if (count($views) > 1) {
109
-          $form['advanced']['advanced_view'] = array(
110
-            '#type' => 'select',
111
-            '#title' => t('View used to select the users'),
112
-            '#options' => $views,
113
-            '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
114
-            '#description' =>  t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>') .
115
-              t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
116
-          );
117
-          $form['advanced']['advanced_view_args'] = array(
118
-            '#type' => 'textfield',
119
-            '#title' => t('View arguments'),
120
-            '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
121
-            '#required' => FALSE,
122
-            '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
123
-          );
124
-        }
125
-        else {
126
-          $form['advanced']['no_view_help'] = array(
127
-            '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') .
128
-              t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
129
-          );
130 99
         }
131 100
       }
132
-      return $form;
133 101
 
134
-    case 'save':
135
-      $settings = array('referenceable_roles', 'referenceable_status');
136
-      if (module_exists('views')) {
137
-        $settings[] = 'advanced_view';
138
-        $settings[] = 'advanced_view_args';
102
+      $form['advanced'] = array(
103
+         '#type' => 'fieldset',
104
+         '#title' => t('Advanced - Users that can be referenced (View)'),
105
+         '#collapsible' => TRUE,
106
+         '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
107
+       );
108
+      if (count($views) > 1) {
109
+        $form['advanced']['advanced_view'] = array(
110
+          '#type' => 'select',
111
+          '#title' => t('View used to select the users'),
112
+          '#options' => $views,
113
+          '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
114
+          '#description' =>  t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>') .
115
+            t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
116
+        );
117
+        $form['advanced']['advanced_view_args'] = array(
118
+          '#type' => 'textfield',
119
+          '#title' => t('View arguments'),
120
+          '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
121
+          '#required' => FALSE,
122
+          '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
123
+        );
124
+      }
125
+      else {
126
+        $form['advanced']['no_view_help'] = array(
127
+          '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') .
128
+            t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
129
+        );
139 130
       }
140
-      return $settings;
131
+    }
132
+    return $form;
141 133
 
142
-    case 'database columns':
143
-      $columns = array(
144
-        'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
145
-      );
146
-      return $columns;
147
-
148
-    case 'views data':
149
-      $data = content_views_field_views_data($field);
150
-      $db_info = content_database_info($field);
151
-      $table_alias = content_views_tablename($field);
152
-
153
-      // Filter : swap the handler to the 'in' operator.
154
-      $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
155
-      // Argument: get the user name for summaries.
156
-      // We need to join a new instance of the users table.
157
-      $data["users_$table_alias"]['table']['join']['node'] = array(
158
-        'table' => 'users',
159
-        'field' => 'uid',
160
-        'left_table' => $table_alias,
161
-        'left_field' => $field['field_name'] .'_uid',
162
-      );
163
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias";
165
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name';
166
-      // Relationship: Add a relationship for related user.
167
-      $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array(
168
-        'base' => 'users',
169
-        'field' => $db_info['columns']['uid']['column'],
170
-        'handler' => 'content_handler_relationship',
171
-        'label' => t($field['widget']['label']),
172
-        'content_field_name' => $field['field_name'],
173
-      );
174
-      return $data;
134
+  case 'save':
135
+    $settings = array('referenceable_roles', 'referenceable_status');
136
+    if (module_exists('views')) {
137
+      $settings[] = 'advanced_view';
138
+      $settings[] = 'advanced_view_args';
139
+    }
140
+    return $settings;
141
+
142
+  case 'database columns':
143
+    $columns = array(
144
+      'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
145
+    );
146
+    return $columns;
147
+
148
+  case 'views data':
149
+    $data = content_views_field_views_data($field);
150
+    $db_info = content_database_info($field);
151
+    $table_alias = content_views_tablename($field);
152
+
153
+    // Filter : swap the handler to the 'in' operator.
154
+    $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
155
+    // Argument: get the user name for summaries.
156
+    // We need to join a new instance of the users table.
157
+    $data["users_$table_alias"]['table']['join']['node'] = array(
158
+      'table' => 'users',
159
+      'field' => 'uid',
160
+      'left_table' => $table_alias,
161
+      'left_field' => $field['field_name'] .'_uid',
162
+    );
163
+    $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
+    $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias";
165
+    $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name';
166
+    // Relationship: Add a relationship for related user.
167
+    $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array(
168
+      'base' => 'users',
169
+      'field' => $db_info['columns']['uid']['column'],
170
+      'handler' => 'content_handler_relationship',
171
+      'label' => t($field['widget']['label']),
172
+      'content_field_name' => $field['field_name'],
173
+    );
174
+    return $data;
175 175
 
176 176
   }
177 177
 }
@@ -181,35 +181,35 @@  discard block
 block discarded – undo
181 181
  */
182 182
 function userreference_field($op, &$node, $field, &$items, $teaser, $page) {
183 183
   switch ($op) {
184
-    case 'validate':
185
-      // Extract uids to check.
186
-      $ids = array();
187
-      foreach ($items as $delta => $item) {
188
-        if (is_array($item) && !empty($item['uid'])) {
189
-          if (is_numeric($item['uid'])) {
190
-            $ids[] = $item['uid'];
191
-          }
192
-          else {
193
-            $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
194
-            if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
195
-            form_set_error($error_element, t('%name: invalid input.', array('%name' => t($field['widget']['label']))));
196
-          }
184
+  case 'validate':
185
+    // Extract uids to check.
186
+    $ids = array();
187
+    foreach ($items as $delta => $item) {
188
+      if (is_array($item) && !empty($item['uid'])) {
189
+        if (is_numeric($item['uid'])) {
190
+          $ids[] = $item['uid'];
191
+        }
192
+        else {
193
+          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
194
+          if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
195
+          form_set_error($error_element, t('%name: invalid input.', array('%name' => t($field['widget']['label']))));
197 196
         }
198 197
       }
199
-      // Prevent performance hog if there are no ids to check.
200
-      if ($ids) {
201
-        $refs = _userreference_potential_references($field, '', NULL, $ids);
202
-        foreach ($items as $delta => $item) {
203
-          if (is_array($item)) {
204
-            $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
205
-            if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
206
-            if (!empty($item['uid']) && !isset($refs[$item['uid']])) {
207
-              form_set_error($error_element, t('%name: invalid user.', array('%name' => t($field['widget']['label']))));
208
-            }
198
+    }
199
+    // Prevent performance hog if there are no ids to check.
200
+    if ($ids) {
201
+      $refs = _userreference_potential_references($field, '', NULL, $ids);
202
+      foreach ($items as $delta => $item) {
203
+        if (is_array($item)) {
204
+          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
205
+          if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
206
+          if (!empty($item['uid']) && !isset($refs[$item['uid']])) {
207
+            form_set_error($error_element, t('%name: invalid user.', array('%name' => t($field['widget']['label']))));
209 208
           }
210 209
         }
211 210
       }
212
-      return $items;
211
+    }
212
+    return $items;
213 213
   }
214 214
 }
215 215
 
@@ -345,43 +345,43 @@  discard block
 block discarded – undo
345 345
  */
346 346
 function userreference_widget_settings($op, $widget) {
347 347
   switch ($op) {
348
-    case 'form':
349
-      $form = array();
350
-      $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
351
-      $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
352
-      if ($widget['type'] == 'userreference_autocomplete') {
353
-        $form['autocomplete_match'] = array(
354
-          '#type' => 'select',
355
-          '#title' => t('Autocomplete matching'),
356
-          '#default_value' => $match,
357
-          '#options' => array(
358
-            'starts_with' => t('Starts with'),
359
-            'contains' => t('Contains'),
360
-          ),
361
-          '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'),
362
-        );
363
-        $form['size'] = array(
364
-          '#type' => 'textfield',
365
-          '#title' => t('Size of textfield'),
366
-          '#default_value' => $size,
367
-          '#element_validate' => array('_element_validate_integer_positive'),
368
-          '#required' => TRUE,
369
-        );
370
-      }
371
-      else {
372
-        $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
373
-        $form['size'] = array('#type' => 'hidden', '#value' => $size);
374
-      }
375
-      $form['reverse_link'] = array(
376
-        '#type' => 'checkbox',
377
-        '#title' => t('Reverse link'),
378
-        '#default_value' => isset($widget['reverse_link']) ? $widget['reverse_link'] : 0,
379
-        '#description' => t('If selected, a reverse link back to the referencing node will displayed on the referenced user record.'),
348
+  case 'form':
349
+    $form = array();
350
+    $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
351
+    $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
352
+    if ($widget['type'] == 'userreference_autocomplete') {
353
+      $form['autocomplete_match'] = array(
354
+        '#type' => 'select',
355
+        '#title' => t('Autocomplete matching'),
356
+        '#default_value' => $match,
357
+        '#options' => array(
358
+          'starts_with' => t('Starts with'),
359
+          'contains' => t('Contains'),
360
+        ),
361
+        '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'),
380 362
       );
381
-      return $form;
363
+      $form['size'] = array(
364
+        '#type' => 'textfield',
365
+        '#title' => t('Size of textfield'),
366
+        '#default_value' => $size,
367
+        '#element_validate' => array('_element_validate_integer_positive'),
368
+        '#required' => TRUE,
369
+      );
370
+    }
371
+    else {
372
+      $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
373
+      $form['size'] = array('#type' => 'hidden', '#value' => $size);
374
+    }
375
+    $form['reverse_link'] = array(
376
+      '#type' => 'checkbox',
377
+      '#title' => t('Reverse link'),
378
+      '#default_value' => isset($widget['reverse_link']) ? $widget['reverse_link'] : 0,
379
+      '#description' => t('If selected, a reverse link back to the referencing node will displayed on the referenced user record.'),
380
+    );
381
+    return $form;
382 382
 
383
-    case 'save':
384
-      return array('autocomplete_match', 'size', 'reverse_link');
383
+  case 'save':
384
+    return array('autocomplete_match', 'size', 'reverse_link');
385 385
   }
386 386
 }
387 387
 
@@ -418,27 +418,27 @@  discard block
 block discarded – undo
418 418
  */
419 419
 function userreference_widget(&$form, &$form_state, $field, $items, $delta = 0) {
420 420
   switch ($field['widget']['type']) {
421
-    case 'userreference_select':
422
-      $element = array(
423
-        '#type' => 'userreference_select',
424
-        '#default_value' => $items,
425
-      );
426
-      break;
421
+  case 'userreference_select':
422
+    $element = array(
423
+      '#type' => 'userreference_select',
424
+      '#default_value' => $items,
425
+    );
426
+    break;
427 427
 
428
-    case 'userreference_buttons':
429
-      $element = array(
430
-        '#type' => 'userreference_buttons',
431
-        '#default_value' => $items,
432
-      );
433
-      break;
428
+  case 'userreference_buttons':
429
+    $element = array(
430
+      '#type' => 'userreference_buttons',
431
+      '#default_value' => $items,
432
+    );
433
+    break;
434 434
 
435
-    case 'userreference_autocomplete':
436
-      $element = array(
437
-        '#type' => 'userreference_autocomplete',
438
-        '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
439
-        '#value_callback' => 'userreference_autocomplete_value',
440
-      );
441
-      break;
435
+  case 'userreference_autocomplete':
436
+    $element = array(
437
+      '#type' => 'userreference_autocomplete',
438
+      '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
439
+      '#value_callback' => 'userreference_autocomplete_value',
440
+    );
441
+    break;
442 442
   }
443 443
   return $element;
444 444
 }
@@ -845,67 +845,67 @@  discard block
 block discarded – undo
845 845
  */
846 846
 function userreference_user($type, &$edit, &$account) {
847 847
   switch ($type) {
848
-    case 'load':
849
-      // Only add links if we are on the user 'view' page.
850
-      if (arg(0) != 'user' || arg(2)) {
851
-        return;
852
-      }
853
-      // find CCK userreference field tables
854
-      // search through them for matching user ids and load those nodes
855
-      $additions = array();
856
-      $types = content_types();
857
-
858
-      // Find the table and columns to search through, if the same
859
-      // table comes up in more than one content type, we only need
860
-      // to search it once.
861
-      $search_tables = array();
862
-      foreach ($types as $type_name => $type) {
863
-        foreach ($type['fields'] as $field) {
864
-          // Only add tables when reverse link has been selected.
865
-          if ($field['type'] == 'userreference' && !empty($field['widget']['reverse_link'])) {
866
-            $db_info = content_database_info($field);
867
-            $search_tables[$db_info['table']][] = $db_info['columns']['uid']['column'];
868
-          }
848
+  case 'load':
849
+    // Only add links if we are on the user 'view' page.
850
+    if (arg(0) != 'user' || arg(2)) {
851
+      return;
852
+    }
853
+    // find CCK userreference field tables
854
+    // search through them for matching user ids and load those nodes
855
+    $additions = array();
856
+    $types = content_types();
857
+
858
+    // Find the table and columns to search through, if the same
859
+    // table comes up in more than one content type, we only need
860
+    // to search it once.
861
+    $search_tables = array();
862
+    foreach ($types as $type_name => $type) {
863
+      foreach ($type['fields'] as $field) {
864
+        // Only add tables when reverse link has been selected.
865
+        if ($field['type'] == 'userreference' && !empty($field['widget']['reverse_link'])) {
866
+          $db_info = content_database_info($field);
867
+          $search_tables[$db_info['table']][] = $db_info['columns']['uid']['column'];
869 868
         }
870 869
       }
871
-      foreach ($search_tables as $table => $columns) {
872
-        foreach ($columns as $column) {
873
-          $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1"));
874
-          while ($data = db_fetch_object($ids)) {
875
-            $additions[$data->type][$data->nid] = $data->title;
876
-          }
870
+    }
871
+    foreach ($search_tables as $table => $columns) {
872
+      foreach ($columns as $column) {
873
+        $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1"));
874
+        while ($data = db_fetch_object($ids)) {
875
+          $additions[$data->type][$data->nid] = $data->title;
877 876
         }
878 877
       }
879
-      $account->userreference = $additions;
880
-      break;
878
+    }
879
+    $account->userreference = $additions;
880
+    break;
881 881
 
882
-    case 'view':
883
-      if (!empty($account->userreference)) {
884
-        $node_types = content_types();
885
-        $additions = array();
886
-        $values = array();
887
-        foreach ($account->userreference as $node_type => $nodes) {
888
-          foreach ($nodes as $nid => $title) {
889
-            $values[$node_type][] = l($title, 'node/'. $nid);
890
-          }
891
-          if (isset($values[$node_type])) {
892
-            $additions[] = array(
893
-              '#type' => 'user_profile_item',
894
-              '#title' => check_plain($node_types[$node_type]['name']),
895
-              '#value' => theme('item_list', $values[$node_type]),
896
-            );
897
-          }
882
+  case 'view':
883
+    if (!empty($account->userreference)) {
884
+      $node_types = content_types();
885
+      $additions = array();
886
+      $values = array();
887
+      foreach ($account->userreference as $node_type => $nodes) {
888
+        foreach ($nodes as $nid => $title) {
889
+          $values[$node_type][] = l($title, 'node/'. $nid);
898 890
         }
899
-        if ($additions) {
900
-          $account->content['userreference'] = $additions + array(
901
-            '#type' => 'user_profile_category',
902
-            '#attributes' => array('class' => 'user-member'),
903
-            '#title' => t('Related content'),
904
-            '#weight' => 10,
891
+        if (isset($values[$node_type])) {
892
+          $additions[] = array(
893
+            '#type' => 'user_profile_item',
894
+            '#title' => check_plain($node_types[$node_type]['name']),
895
+            '#value' => theme('item_list', $values[$node_type]),
905 896
           );
906 897
         }
907 898
       }
908
-      break;
899
+      if ($additions) {
900
+        $account->content['userreference'] = $additions + array(
901
+          '#type' => 'user_profile_category',
902
+          '#attributes' => array('class' => 'user-member'),
903
+          '#title' => t('Related content'),
904
+          '#weight' => 10,
905
+        );
906
+      }
907
+    }
908
+    break;
909 909
   }
910 910
 }
911 911
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  */
49 49
 function userreference_ctools_plugin_directory($module, $plugin) {
50 50
   if ($module == 'ctools' && $plugin == 'relationships') {
51
-    return 'panels/' . $plugin;
51
+    return 'panels/'.$plugin;
52 52
   }
53 53
 }
54 54
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             '#title' => t('View used to select the users'),
112 112
             '#options' => $views,
113 113
             '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
114
-            '#description' =>  t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>') .
114
+            '#description' =>  t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>').
115 115
               t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
116 116
           );
117 117
           $form['advanced']['advanced_view_args'] = array(
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         }
125 125
         else {
126 126
           $form['advanced']['no_view_help'] = array(
127
-            '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') .
127
+            '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>').
128 128
               t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
129 129
           );
130 130
         }
@@ -151,20 +151,20 @@  discard block
 block discarded – undo
151 151
       $table_alias = content_views_tablename($field);
152 152
 
153 153
       // Filter : swap the handler to the 'in' operator.
154
-      $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
154
+      $data[$table_alias][$field['field_name'].'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
155 155
       // Argument: get the user name for summaries.
156 156
       // We need to join a new instance of the users table.
157 157
       $data["users_$table_alias"]['table']['join']['node'] = array(
158 158
         'table' => 'users',
159 159
         'field' => 'uid',
160 160
         'left_table' => $table_alias,
161
-        'left_field' => $field['field_name'] .'_uid',
161
+        'left_field' => $field['field_name'].'_uid',
162 162
       );
163
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias";
165
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name';
163
+      $data[$table_alias][$field['field_name'].'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
+      $data[$table_alias][$field['field_name'].'_uid']['argument']['name table'] = "users_$table_alias";
165
+      $data[$table_alias][$field['field_name'].'_uid']['argument']['name field'] = 'name';
166 166
       // Relationship: Add a relationship for related user.
167
-      $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array(
167
+      $data[$table_alias][$field['field_name'].'_uid']['relationship'] = array(
168 168
         'base' => 'users',
169 169
         'field' => $db_info['columns']['uid']['column'],
170 170
         'handler' => 'content_handler_relationship',
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
  * Substitute in the user name for the uid.
450 450
  */
451 451
 function userreference_autocomplete_value($element, $edit = FALSE) {
452
-  $field_key  = $element['#columns'][0];
452
+  $field_key = $element['#columns'][0];
453 453
   if (!empty($element['#default_value'][$field_key])) {
454 454
     $value = db_result(db_query("SELECT name FROM {users} WHERE uid = '%d'", $element['#default_value'][$field_key]));
455 455
     return array($field_key => $value);
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
   // The userreference_select widget doesn't need to create its own
470 470
   // element, it can wrap around the optionwidgets_select element.
471 471
   // Add a validation step where the value can be unwrapped.
472
-  $field_key  = $element['#columns'][0];
472
+  $field_key = $element['#columns'][0];
473 473
   $element[$field_key] = array(
474 474
     '#type' => 'optionwidgets_select',
475 475
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
   // The userreference_select widget doesn't need to create its own
503 503
   // element, it can wrap around the optionwidgets_select element.
504 504
   // Add a validation step where the value can be unwrapped.
505
-  $field_key  = $element['#columns'][0];
505
+  $field_key = $element['#columns'][0];
506 506
   $element[$field_key] = array(
507 507
     '#type' => 'optionwidgets_buttons',
508 508
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
@@ -535,12 +535,12 @@  discard block
 block discarded – undo
535 535
   // element, it can wrap around the text_textfield element and add an autocomplete
536 536
   // path and some extra processing to it.
537 537
   // Add a validation step where the value can be unwrapped.
538
-  $field_key  = $element['#columns'][0];
538
+  $field_key = $element['#columns'][0];
539 539
 
540 540
   $element[$field_key] = array(
541 541
     '#type' => 'text_textfield',
542 542
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
543
-    '#autocomplete_path' => 'userreference/autocomplete/'. $element['#field_name'],
543
+    '#autocomplete_path' => 'userreference/autocomplete/'.$element['#field_name'],
544 544
     // The following values were set by the content module and need
545 545
     // to be passed down to the nested element.
546 546
     '#title' => $element['#title'],
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
  * like optionwidgets are using #element_validate to alter the value.
579 579
  */
580 580
 function userreference_optionwidgets_validate($element, &$form_state) {
581
-  $field_key  = $element['#columns'][0];
581
+  $field_key = $element['#columns'][0];
582 582
 
583 583
   $value = $form_state['values'];
584 584
   $new_parents = array();
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
   static $results = array();
671 671
 
672 672
   // Create unique id for static cache.
673
-  $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
673
+  $cid = $field['field_name'].':'.$match.':'.($string !== '' ? $string : implode('-', $ids)).':'.$limit;
674 674
   if (!isset($results[$cid])) {
675 675
     $references = FALSE;
676 676
     if (module_exists('views') && !empty($field['advanced_view']) && $field['advanced_view'] != '--') {
@@ -783,11 +783,11 @@  discard block
 block discarded – undo
783 783
       'equals' => "= '%s'",
784 784
       'starts_with' => "$like '%s%%'",
785 785
     );
786
-    $where[] = 'u.name '. (isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
786
+    $where[] = 'u.name '.(isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
787 787
     $args[] = $string;
788 788
   }
789 789
   elseif ($ids) {
790
-    $where[] = 'u.uid IN (' . db_placeholders($ids) . ')';
790
+    $where[] = 'u.uid IN ('.db_placeholders($ids).')';
791 791
     $args = array_merge($args, $ids);
792 792
   }
793 793
   else {
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
     $roles = array_intersect(array_keys(user_roles(1)), $roles);
803 803
   }
804 804
   if (!empty($roles) && !in_array(DRUPAL_AUTHENTICATED_RID, $roles)) {
805
-    $where[] = "r.rid IN (". implode($roles, ',') .")";
805
+    $where[] = "r.rid IN (".implode($roles, ',').")";
806 806
     $join[] = 'LEFT JOIN {users_roles} r ON u.uid = r.uid';
807 807
   }
808 808
 
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
   }
813 813
 
814 814
   $users = array();
815
-  $where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
816
-  $result = db_query('SELECT u.name, u.uid FROM {users} u '. implode(' ', $join) ." $where_clause ORDER BY u.name ASC", $args);
815
+  $where_clause = $where ? 'WHERE ('.implode(') AND (', $where).')' : '';
816
+  $result = db_query('SELECT u.name, u.uid FROM {users} u '.implode(' ', $join)." $where_clause ORDER BY u.name ASC", $args);
817 817
   while ($user = db_fetch_object($result)) {
818 818
     $users[$user->uid] = array(
819 819
       'title' => $user->name,
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
   $references = _userreference_potential_references($field, $string, $match, array(), 10);
836 836
   foreach ($references as $id => $row) {
837 837
     // Add a class wrapper for a few required CSS overrides.
838
-    $matches[$row['title']] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';
838
+    $matches[$row['title']] = '<div class="reference-autocomplete">'.$row['rendered'].'</div>';
839 839
   }
840 840
   drupal_json($matches);
841 841
 }
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
       }
871 871
       foreach ($search_tables as $table => $columns) {
872 872
         foreach ($columns as $column) {
873
-          $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1"));
873
+          $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {".$table."} f ON n.vid = f.vid WHERE f.".$column."=".$account->uid." AND n.status = 1"));
874 874
           while ($data = db_fetch_object($ids)) {
875 875
             $additions[$data->type][$data->nid] = $data->title;
876 876
           }
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
         $values = array();
887 887
         foreach ($account->userreference as $node_type => $nodes) {
888 888
           foreach ($nodes as $nid => $title) {
889
-            $values[$node_type][] = l($title, 'node/'. $nid);
889
+            $values[$node_type][] = l($title, 'node/'.$nid);
890 890
           }
891 891
           if (isset($values[$node_type])) {
892 892
             $additions[] = array(
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -92,8 +92,7 @@  discard block
 block discarded – undo
92 92
           if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) {
93 93
             if ($view->type == 'Default') {
94 94
               $views[t('Default Views')][$view->name] = $view->name;
95
-            }
96
-            else {
95
+            } else {
97 96
               $views[t('Existing Views')][$view->name] = $view->name;
98 97
             }
99 98
           }
@@ -121,8 +120,7 @@  discard block
 block discarded – undo
121 120
             '#required' => FALSE,
122 121
             '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
123 122
           );
124
-        }
125
-        else {
123
+        } else {
126 124
           $form['advanced']['no_view_help'] = array(
127 125
             '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') .
128 126
               t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
@@ -188,8 +186,7 @@  discard block
 block discarded – undo
188 186
         if (is_array($item) && !empty($item['uid'])) {
189 187
           if (is_numeric($item['uid'])) {
190 188
             $ids[] = $item['uid'];
191
-          }
192
-          else {
189
+          } else {
193 190
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
194 191
             if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
195 192
             form_set_error($error_element, t('%name: invalid input.', array('%name' => t($field['widget']['label']))));
@@ -367,8 +364,7 @@  discard block
 block discarded – undo
367 364
           '#element_validate' => array('_element_validate_integer_positive'),
368 365
           '#required' => TRUE,
369 366
         );
370
-      }
371
-      else {
367
+      } else {
372 368
         $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
373 369
         $form['size'] = array('#type' => 'hidden', '#value' => $size);
374 370
       }
@@ -612,8 +608,7 @@  discard block
 block discarded – undo
612 608
     $reference = _userreference_potential_references($field, $value, 'equals', NULL, 1);
613 609
     if (empty($reference)) {
614 610
       form_error($element[$field_key], t('%name: found no valid user with that name.', array('%name' => t($field['widget']['label']))));
615
-    }
616
-    else {
611
+    } else {
617 612
       $uid = key($reference);
618 613
     }
619 614
   }
@@ -733,8 +728,7 @@  discard block
 block discarded – undo
733 728
     if (!empty($field['advanced_view_args'])) {
734 729
       // TODO: Support Tokens using token.module ?
735 730
       $view_args = array_map('trim', explode(',', $field['advanced_view_args']));
736
-    }
737
-    else {
731
+    } else {
738 732
       $view_args = array();
739 733
     }
740 734
 
@@ -759,8 +753,7 @@  discard block
 block discarded – undo
759 753
 
760 754
     // Get the results.
761 755
     $result = $view->execute_display($display, $view_args);
762
-  }
763
-  else {
756
+  } else {
764 757
     $result = FALSE;
765 758
   }
766 759
 
@@ -785,12 +778,10 @@  discard block
 block discarded – undo
785 778
     );
786 779
     $where[] = 'u.name '. (isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
787 780
     $args[] = $string;
788
-  }
789
-  elseif ($ids) {
781
+  } elseif ($ids) {
790 782
     $where[] = 'u.uid IN (' . db_placeholders($ids) . ')';
791 783
     $args = array_merge($args, $ids);
792
-  }
793
-  else {
784
+  } else {
794 785
     $where[] = "u.uid > 0";
795 786
   }
796 787
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 function userreference_theme() {
27 27
   return array(
28 28
     'userreference_select' => array(
29
-      'arguments' => array('element' => NULL),
29
+      'arguments' => array('element' => null),
30 30
     ),
31 31
     'userreference_buttons' => array(
32
-      'arguments' => array('element' => NULL),
32
+      'arguments' => array('element' => null),
33 33
     ),
34 34
     'userreference_autocomplete' => array(
35
-      'arguments' => array('element' => NULL),
35
+      'arguments' => array('element' => null),
36 36
     ),
37 37
     'userreference_formatter_default' => array(
38 38
       'arguments' => array('element'),
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         $form['advanced'] = array(
103 103
            '#type' => 'fieldset',
104 104
            '#title' => t('Advanced - Users that can be referenced (View)'),
105
-           '#collapsible' => TRUE,
105
+           '#collapsible' => true,
106 106
            '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
107 107
          );
108 108
         if (count($views) > 1) {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             '#type' => 'textfield',
119 119
             '#title' => t('View arguments'),
120 120
             '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
121
-            '#required' => FALSE,
121
+            '#required' => false,
122 122
             '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
123 123
           );
124 124
         }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
     case 'database columns':
143 143
       $columns = array(
144
-        'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
144
+        'uid' => array('type' => 'int', 'unsigned' => true, 'not null' => false, 'index' => true),
145 145
       );
146 146
       return $columns;
147 147
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
       }
199 199
       // Prevent performance hog if there are no ids to check.
200 200
       if ($ids) {
201
-        $refs = _userreference_potential_references($field, '', NULL, $ids);
201
+        $refs = _userreference_potential_references($field, '', null, $ids);
202 202
         foreach ($items as $delta => $item) {
203 203
           if (is_array($item)) {
204 204
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
  */
219 219
 function userreference_content_is_empty($item, $field) {
220 220
   if (empty($item['uid'])) {
221
-    return TRUE;
221
+    return true;
222 222
   }
223
-  return FALSE;
223
+  return false;
224 224
 }
225 225
 
226 226
 /**
@@ -322,20 +322,20 @@  discard block
 block discarded – undo
322 322
 function userreference_elements() {
323 323
   return array(
324 324
     'userreference_select' => array(
325
-      '#input' => TRUE,
325
+      '#input' => true,
326 326
       '#columns' => array('uid'), '#delta' => 0,
327 327
       '#process' => array('userreference_select_process'),
328 328
     ),
329 329
     'userreference_buttons' => array(
330
-      '#input' => TRUE,
330
+      '#input' => true,
331 331
       '#columns' => array('uid'), '#delta' => 0,
332 332
       '#process' => array('userreference_buttons_process'),
333 333
     ),
334 334
     'userreference_autocomplete' => array(
335
-      '#input' => TRUE,
335
+      '#input' => true,
336 336
       '#columns' => array('name'), '#delta' => 0,
337 337
       '#process' => array('userreference_autocomplete_process'),
338
-      '#autocomplete_path' => FALSE,
338
+      '#autocomplete_path' => false,
339 339
       ),
340 340
     );
341 341
 }
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
           '#title' => t('Size of textfield'),
366 366
           '#default_value' => $size,
367 367
           '#element_validate' => array('_element_validate_integer_positive'),
368
-          '#required' => TRUE,
368
+          '#required' => true,
369 369
         );
370 370
       }
371 371
       else {
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
     case 'userreference_autocomplete':
436 436
       $element = array(
437 437
         '#type' => 'userreference_autocomplete',
438
-        '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
438
+        '#default_value' => isset($items[$delta]) ? $items[$delta] : null,
439 439
         '#value_callback' => 'userreference_autocomplete_value',
440 440
       );
441 441
       break;
@@ -448,13 +448,13 @@  discard block
 block discarded – undo
448 448
  *
449 449
  * Substitute in the user name for the uid.
450 450
  */
451
-function userreference_autocomplete_value($element, $edit = FALSE) {
451
+function userreference_autocomplete_value($element, $edit = false) {
452 452
   $field_key  = $element['#columns'][0];
453 453
   if (!empty($element['#default_value'][$field_key])) {
454 454
     $value = db_result(db_query("SELECT name FROM {users} WHERE uid = '%d'", $element['#default_value'][$field_key]));
455 455
     return array($field_key => $value);
456 456
   }
457
-  return array($field_key => NULL);
457
+  return array($field_key => null);
458 458
 }
459 459
 
460 460
 /**
@@ -607,9 +607,9 @@  discard block
 block discarded – undo
607 607
   $field = content_fields($field_name, $type_name);
608 608
   $field_key = $element['#columns'][0];
609 609
   $value = $element['#value'][$field_key];
610
-  $uid = NULL;
610
+  $uid = null;
611 611
   if (!empty($value)) {
612
-    $reference = _userreference_potential_references($field, $value, 'equals', NULL, 1);
612
+    $reference = _userreference_potential_references($field, $value, 'equals', null, 1);
613 613
     if (empty($reference)) {
614 614
       form_error($element[$field_key], t('%name: found no valid user with that name.', array('%name' => t($field['widget']['label']))));
615 615
     }
@@ -666,19 +666,19 @@  discard block
 block discarded – undo
666 666
  *     ...
667 667
  *   )
668 668
  */
669
-function _userreference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
669
+function _userreference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = null) {
670 670
   static $results = array();
671 671
 
672 672
   // Create unique id for static cache.
673 673
   $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
674 674
   if (!isset($results[$cid])) {
675
-    $references = FALSE;
675
+    $references = false;
676 676
     if (module_exists('views') && !empty($field['advanced_view']) && $field['advanced_view'] != '--') {
677 677
       $references = _userreference_potential_references_views($field, $string, $match, $ids, $limit);
678 678
     }
679 679
     // If the view doesn't exist, we got FALSE, and fallback to the regular 'standard mode'.
680 680
 
681
-    if ($references === FALSE) {
681
+    if ($references === false) {
682 682
       $references = _userreference_potential_references_standard($field, $string, $match, $ids, $limit);
683 683
     }
684 684
 
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
  * Helper function for _userreference_potential_references():
694 694
  * case of Views-defined referenceable users.
695 695
  */
696
-function _userreference_potential_references_views($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
696
+function _userreference_potential_references_views($field, $string = '', $match = 'contains', $ids = array(), $limit = null) {
697 697
   $view_name = $field['advanced_view'];
698 698
 
699 699
   if ($view = views_get_view($view_name)) {
@@ -755,13 +755,13 @@  discard block
 block discarded – undo
755 755
     $view->display_handler->set_option('row_options', $options);
756 756
 
757 757
     // Make sure the query is not cached
758
-    $view->is_cacheable = FALSE;
758
+    $view->is_cacheable = false;
759 759
 
760 760
     // Get the results.
761 761
     $result = $view->execute_display($display, $view_args);
762 762
   }
763 763
   else {
764
-    $result = FALSE;
764
+    $result = false;
765 765
   }
766 766
 
767 767
   return $result;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
  * Helper function for _userreference_potential_references():
772 772
  * referenceable users defined by user role and status
773 773
  */
774
-function _userreference_potential_references_standard($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
774
+function _userreference_potential_references_standard($field, $string = '', $match = 'contains', $ids = array(), $limit = null) {
775 775
   $where = array();
776 776
   $args = array();
777 777
   $join = array();
Please login to merge, or discard this patch.