Completed
Pull Request — master (#1795)
by Christian
09:22
created
default/boinc/modules/boincstats/includes/pchart/class/pCache.class.php 1 patch
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- /*
2
+    /*
3 3
      pCache - speed up the rendering by caching up the pictures
4 4
 
5 5
      Version     : 2.1.3
@@ -13,268 +13,268 @@  discard block
 block discarded – undo
13 13
      You can find the whole class documentation on the pChart web site.
14 14
  */
15 15
 
16
- /* pData class definition */
17
- class pCache
18
-  {
19
-   var $CacheFolder;
20
-   var $CacheIndex;
21
-   var $CacheDB;
16
+    /* pData class definition */
17
+    class pCache
18
+    {
19
+    var $CacheFolder;
20
+    var $CacheIndex;
21
+    var $CacheDB;
22 22
 
23
-   /* Class creator */
24
-   function pCache($Settings="")
23
+    /* Class creator */
24
+    function pCache($Settings="")
25 25
     {
26
-     $CacheFolder	= isset($Settings["CacheFolder"]) ? $Settings["CacheFolder"] : "cache";
27
-     $CacheIndex	= isset($Settings["CacheIndex"]) ? $Settings["CacheIndex"] : "index.db";
28
-     $CacheDB		= isset($Settings["CacheDB"]) ? $Settings["CacheDB"] : "cache.db";
26
+        $CacheFolder	= isset($Settings["CacheFolder"]) ? $Settings["CacheFolder"] : "cache";
27
+        $CacheIndex	= isset($Settings["CacheIndex"]) ? $Settings["CacheIndex"] : "index.db";
28
+        $CacheDB		= isset($Settings["CacheDB"]) ? $Settings["CacheDB"] : "cache.db";
29 29
 
30
-     $this->CacheFolder	= $CacheFolder;
31
-     $this->CacheIndex	= $CacheIndex;
32
-     $this->CacheDB	= $CacheDB;
30
+        $this->CacheFolder	= $CacheFolder;
31
+        $this->CacheIndex	= $CacheIndex;
32
+        $this->CacheDB	= $CacheDB;
33 33
 
34
-     if (!file_exists($this->CacheFolder."/".$this->CacheIndex)) { touch($this->CacheFolder."/".$this->CacheIndex); }
35
-     if (!file_exists($this->CacheFolder."/".$this->CacheDB))    { touch($this->CacheFolder."/".$this->CacheDB); }
34
+        if (!file_exists($this->CacheFolder."/".$this->CacheIndex)) { touch($this->CacheFolder."/".$this->CacheIndex); }
35
+        if (!file_exists($this->CacheFolder."/".$this->CacheDB))    { touch($this->CacheFolder."/".$this->CacheDB); }
36 36
     }
37 37
 
38
-   /* Flush the cache contents */
39
-   function flush()
38
+    /* Flush the cache contents */
39
+    function flush()
40 40
     {
41
-     if (file_exists($this->CacheFolder."/".$this->CacheIndex)) { unlink($this->CacheFolder."/".$this->CacheIndex); touch($this->CacheFolder."/".$this->CacheIndex); }
42
-     if (file_exists($this->CacheFolder."/".$this->CacheDB))    { unlink($this->CacheFolder."/".$this->CacheDB); touch($this->CacheFolder."/".$this->CacheDB); }
41
+        if (file_exists($this->CacheFolder."/".$this->CacheIndex)) { unlink($this->CacheFolder."/".$this->CacheIndex); touch($this->CacheFolder."/".$this->CacheIndex); }
42
+        if (file_exists($this->CacheFolder."/".$this->CacheDB))    { unlink($this->CacheFolder."/".$this->CacheDB); touch($this->CacheFolder."/".$this->CacheDB); }
43 43
     }
44 44
 
45
-   /* Return the MD5 of the data array to clearly identify the chart */
46
-   function getHash($Data,$Marker="")
45
+    /* Return the MD5 of the data array to clearly identify the chart */
46
+    function getHash($Data,$Marker="")
47 47
     { return(md5($Marker.serialize($Data->Data))); }
48 48
 
49
-   /* Write the generated picture to the cache */
50
-   function writeToCache($ID,$pChartObject)
49
+    /* Write the generated picture to the cache */
50
+    function writeToCache($ID,$pChartObject)
51 51
     {
52
-     /* Compute the paths */
53
-     $TemporaryFile = $this->CacheFolder."/tmp_".rand(0,1000).".png";
54
-     $Database      = $this->CacheFolder."/".$this->CacheDB;
55
-     $Index         = $this->CacheFolder."/".$this->CacheIndex;
56
-
57
-     /* Flush the picture to a temporary file */
58
-     imagepng($pChartObject->Picture ,$TemporaryFile);
59
-
60
-     /* Retrieve the files size */
61
-     $PictureSize = filesize($TemporaryFile);
62
-     $DBSize      = filesize($Database);
63
-
64
-     /* Save the index */
65
-     $Handle = fopen($Index,"a");
66
-     fwrite($Handle, $ID.",".$DBSize.",".$PictureSize.",".time().",0      \r\n");
67
-     fclose($Handle);
68
-
69
-     /* Get the picture raw contents */
70
-     $Handle = fopen($TemporaryFile,"r");
71
-     $Raw    = fread($Handle,$PictureSize);
72
-     fclose($Handle);
73
-
74
-     /* Save the picture in the solid database file */
75
-     $Handle = fopen($Database,"a");
76
-     fwrite($Handle, $Raw);
77
-     fclose($Handle);
78
-
79
-     /* Remove temporary file */
80
-     unlink($TemporaryFile);
52
+        /* Compute the paths */
53
+        $TemporaryFile = $this->CacheFolder."/tmp_".rand(0,1000).".png";
54
+        $Database      = $this->CacheFolder."/".$this->CacheDB;
55
+        $Index         = $this->CacheFolder."/".$this->CacheIndex;
56
+
57
+        /* Flush the picture to a temporary file */
58
+        imagepng($pChartObject->Picture ,$TemporaryFile);
59
+
60
+        /* Retrieve the files size */
61
+        $PictureSize = filesize($TemporaryFile);
62
+        $DBSize      = filesize($Database);
63
+
64
+        /* Save the index */
65
+        $Handle = fopen($Index,"a");
66
+        fwrite($Handle, $ID.",".$DBSize.",".$PictureSize.",".time().",0      \r\n");
67
+        fclose($Handle);
68
+
69
+        /* Get the picture raw contents */
70
+        $Handle = fopen($TemporaryFile,"r");
71
+        $Raw    = fread($Handle,$PictureSize);
72
+        fclose($Handle);
73
+
74
+        /* Save the picture in the solid database file */
75
+        $Handle = fopen($Database,"a");
76
+        fwrite($Handle, $Raw);
77
+        fclose($Handle);
78
+
79
+        /* Remove temporary file */
80
+        unlink($TemporaryFile);
81 81
     }
82 82
 
83
-   /* Remove object older than the specified TS */
84
-   function removeOlderThan($Expiry)
83
+    /* Remove object older than the specified TS */
84
+    function removeOlderThan($Expiry)
85 85
     { $this->dbRemoval(array("Expiry"=>$Expiry)); }
86 86
 
87
-   /* Remove an object from the cache */
88
-   function remove($ID)
87
+    /* Remove an object from the cache */
88
+    function remove($ID)
89 89
     { $this->dbRemoval(array("Name"=>$ID)); }
90 90
 
91
-   /* Remove with specified criterias */
92
-   function dbRemoval($Settings)
91
+    /* Remove with specified criterias */
92
+    function dbRemoval($Settings)
93 93
     {
94
-     $ID     = isset($Settings["Name"]) ? $Settings["Name"] : NULL;
95
-     $Expiry = isset($Settings["Expiry"]) ? $Settings["Expiry"] : -(24*60*60);
96
-     $TS     = time()-$Expiry;
97
-
98
-     /* Compute the paths */
99
-     $Database     = $this->CacheFolder."/".$this->CacheDB;
100
-     $Index        = $this->CacheFolder."/".$this->CacheIndex;
101
-     $DatabaseTemp = $this->CacheFolder."/".$this->CacheDB.".tmp";
102
-     $IndexTemp    = $this->CacheFolder."/".$this->CacheIndex.".tmp";
103
-
104
-     /* Single file removal */
105
-     if ( $ID != NULL )
106
-      {
107
-       /* Retrieve object informations */
108
-       $Object = $this->isInCache($ID,TRUE);
109
-
110
-       /* If it's not in the cache DB, go away */
111
-       if ( !$Object ) { return(0); }
112
-      }
113
-
114
-     /* Create the temporary files */
115
-     if (!file_exists($DatabaseTemp)) { touch($DatabaseTemp); }
116
-     if (!file_exists($IndexTemp))    { touch($IndexTemp); }
117
-
118
-     /* Open the file handles */
119
-     $IndexHandle     = @fopen($Index, "r");
120
-     $IndexTempHandle = @fopen($IndexTemp, "w");
121
-     $DBHandle        = @fopen($Database, "r");
122
-     $DBTempHandle    = @fopen($DatabaseTemp, "w");
123
-
124
-     /* Remove the selected ID from the database */
125
-     while (!feof($IndexHandle))
126
-      {
127
-       $Entry    = fgets($IndexHandle, 4096);
128
-       $Entry    = str_replace("\r","",$Entry);
129
-       $Entry    = str_replace("\n","",$Entry);
130
-       $Settings = preg_split("/,/",$Entry);
131
-
132
-       if ( $Entry != "" )
94
+        $ID     = isset($Settings["Name"]) ? $Settings["Name"] : NULL;
95
+        $Expiry = isset($Settings["Expiry"]) ? $Settings["Expiry"] : -(24*60*60);
96
+        $TS     = time()-$Expiry;
97
+
98
+        /* Compute the paths */
99
+        $Database     = $this->CacheFolder."/".$this->CacheDB;
100
+        $Index        = $this->CacheFolder."/".$this->CacheIndex;
101
+        $DatabaseTemp = $this->CacheFolder."/".$this->CacheDB.".tmp";
102
+        $IndexTemp    = $this->CacheFolder."/".$this->CacheIndex.".tmp";
103
+
104
+        /* Single file removal */
105
+        if ( $ID != NULL )
133 106
         {
134
-         $PicID       = $Settings[0];
135
-         $DBPos       = $Settings[1];
136
-         $PicSize     = $Settings[2];
137
-         $GeneratedTS = $Settings[3];
138
-         $Hits        = $Settings[4];
139
-
140
-         if ( $Settings[0] != $ID && $GeneratedTS > $TS)
141
-          {
142
-           $CurrentPos  = ftell($DBTempHandle);
143
-           fwrite($IndexTempHandle, $PicID.",".$CurrentPos.",".$PicSize.",".$GeneratedTS.",".$Hits."\r\n");
144
-
145
-           fseek($DBHandle,$DBPos);
146
-           $Picture = fread($DBHandle,$PicSize);
147
-           fwrite($DBTempHandle,$Picture);
148
-          }
107
+        /* Retrieve object informations */
108
+        $Object = $this->isInCache($ID,TRUE);
109
+
110
+        /* If it's not in the cache DB, go away */
111
+        if ( !$Object ) { return(0); }
112
+        }
113
+
114
+        /* Create the temporary files */
115
+        if (!file_exists($DatabaseTemp)) { touch($DatabaseTemp); }
116
+        if (!file_exists($IndexTemp))    { touch($IndexTemp); }
117
+
118
+        /* Open the file handles */
119
+        $IndexHandle     = @fopen($Index, "r");
120
+        $IndexTempHandle = @fopen($IndexTemp, "w");
121
+        $DBHandle        = @fopen($Database, "r");
122
+        $DBTempHandle    = @fopen($DatabaseTemp, "w");
123
+
124
+        /* Remove the selected ID from the database */
125
+        while (!feof($IndexHandle))
126
+        {
127
+        $Entry    = fgets($IndexHandle, 4096);
128
+        $Entry    = str_replace("\r","",$Entry);
129
+        $Entry    = str_replace("\n","",$Entry);
130
+        $Settings = preg_split("/,/",$Entry);
131
+
132
+        if ( $Entry != "" )
133
+        {
134
+            $PicID       = $Settings[0];
135
+            $DBPos       = $Settings[1];
136
+            $PicSize     = $Settings[2];
137
+            $GeneratedTS = $Settings[3];
138
+            $Hits        = $Settings[4];
139
+
140
+            if ( $Settings[0] != $ID && $GeneratedTS > $TS)
141
+            {
142
+            $CurrentPos  = ftell($DBTempHandle);
143
+            fwrite($IndexTempHandle, $PicID.",".$CurrentPos.",".$PicSize.",".$GeneratedTS.",".$Hits."\r\n");
144
+
145
+            fseek($DBHandle,$DBPos);
146
+            $Picture = fread($DBHandle,$PicSize);
147
+            fwrite($DBTempHandle,$Picture);
148
+            }
149
+        }
149 150
         }
150
-      }
151 151
 
152
-     /* Close the handles */
153
-     fclose($IndexHandle);
154
-     fclose($IndexTempHandle);
155
-     fclose($DBHandle);
156
-     fclose($DBTempHandle);
152
+        /* Close the handles */
153
+        fclose($IndexHandle);
154
+        fclose($IndexTempHandle);
155
+        fclose($DBHandle);
156
+        fclose($DBTempHandle);
157 157
 
158
-     /* Remove the prod files */
159
-     unlink($Database);
160
-     unlink($Index);
158
+        /* Remove the prod files */
159
+        unlink($Database);
160
+        unlink($Index);
161 161
 
162
-     /* Swap the temp & prod DB */
163
-     rename($DatabaseTemp,$Database);
164
-     rename($IndexTemp,$Index);
162
+        /* Swap the temp & prod DB */
163
+        rename($DatabaseTemp,$Database);
164
+        rename($IndexTemp,$Index);
165 165
     }
166 166
 
167
-   function isInCache($ID,$Verbose=FALSE,$UpdateHitsCount=FALSE)
167
+    function isInCache($ID,$Verbose=FALSE,$UpdateHitsCount=FALSE)
168 168
     {
169
-     /* Compute the paths */
170
-     $Index = $this->CacheFolder."/".$this->CacheIndex;
171
-
172
-     /* Search the picture in the index file */
173
-     $Handle = @fopen($Index, "r");
174
-     while (!feof($Handle))
175
-      {
176
-       $IndexPos = ftell($Handle);
177
-       $Entry = fgets($Handle, 4096);
178
-       if ( $Entry != "" )
169
+        /* Compute the paths */
170
+        $Index = $this->CacheFolder."/".$this->CacheIndex;
171
+
172
+        /* Search the picture in the index file */
173
+        $Handle = @fopen($Index, "r");
174
+        while (!feof($Handle))
175
+        {
176
+        $IndexPos = ftell($Handle);
177
+        $Entry = fgets($Handle, 4096);
178
+        if ( $Entry != "" )
179 179
         {
180
-         $Settings = preg_split("/,/",$Entry);
181
-         $PicID    = $Settings[0];
182
-         if ( $PicID == $ID )
183
-          {
184
-           fclose($Handle);
185
-
186
-           $DBPos       = $Settings[1];
187
-           $PicSize     = $Settings[2];
188
-           $GeneratedTS = $Settings[3];
189
-           $Hits        = intval($Settings[4]);
190
-
191
-           if ( $UpdateHitsCount )
180
+            $Settings = preg_split("/,/",$Entry);
181
+            $PicID    = $Settings[0];
182
+            if ( $PicID == $ID )
192 183
             {
193
-             $Hits++;
194
-             if ( strlen($Hits) < 7 ) { $Hits = $Hits.str_repeat(" ",7-strlen($Hits)); }
184
+            fclose($Handle);
185
+
186
+            $DBPos       = $Settings[1];
187
+            $PicSize     = $Settings[2];
188
+            $GeneratedTS = $Settings[3];
189
+            $Hits        = intval($Settings[4]);
195 190
 
196
-             $Handle = @fopen($Index, "r+");
197
-             fseek($Handle,$IndexPos);
198
-             fwrite($Handle, $PicID.",".$DBPos.",".$PicSize.",".$GeneratedTS.",".$Hits."\r\n");
199
-             fclose($Handle);
191
+            if ( $UpdateHitsCount )
192
+            {
193
+                $Hits++;
194
+                if ( strlen($Hits) < 7 ) { $Hits = $Hits.str_repeat(" ",7-strlen($Hits)); }
195
+
196
+                $Handle = @fopen($Index, "r+");
197
+                fseek($Handle,$IndexPos);
198
+                fwrite($Handle, $PicID.",".$DBPos.",".$PicSize.",".$GeneratedTS.",".$Hits."\r\n");
199
+                fclose($Handle);
200 200
             }
201 201
 
202
-           if ($Verbose)
202
+            if ($Verbose)
203 203
             { return(array("DBPos"=>$DBPos,"PicSize"=>$PicSize,"GeneratedTS"=>$GeneratedTS,"Hits"=>$Hits)); }
204
-           else
204
+            else
205 205
             { return(TRUE); }
206
-          }
206
+            }
207 207
         }
208
-      }
209
-     fclose($Handle);
208
+        }
209
+        fclose($Handle);
210 210
 
211
-     /* Picture isn't in the cache */
212
-     return(FALSE);
211
+        /* Picture isn't in the cache */
212
+        return(FALSE);
213 213
     }
214 214
 
215
-   /* Automatic output method based on the calling interface */
216
-   function autoOutput($ID,$Destination="output.png")
215
+    /* Automatic output method based on the calling interface */
216
+    function autoOutput($ID,$Destination="output.png")
217 217
     {
218
-     if (php_sapi_name() == "cli")
219
-      $this->saveFromCache($ID,$Destination);
220
-     else
221
-      $this->strokeFromCache($ID);
218
+        if (php_sapi_name() == "cli")
219
+        $this->saveFromCache($ID,$Destination);
220
+        else
221
+        $this->strokeFromCache($ID);
222 222
     }
223 223
 
224
-   function strokeFromCache($ID)
224
+    function strokeFromCache($ID)
225 225
     {
226
-     /* Get the raw picture from the cache */
227
-     $Picture = $this->getFromCache($ID);
226
+        /* Get the raw picture from the cache */
227
+        $Picture = $this->getFromCache($ID);
228 228
 
229
-     /* Do we have a hit? */
230
-     if ( $Picture == NULL ) { return(FALSE); }
229
+        /* Do we have a hit? */
230
+        if ( $Picture == NULL ) { return(FALSE); }
231 231
 
232
-     header('Content-type: image/png');
233
-     echo $Picture;
232
+        header('Content-type: image/png');
233
+        echo $Picture;
234 234
 
235
-     return(TRUE);
235
+        return(TRUE);
236 236
     }
237 237
 
238
-   function saveFromCache($ID,$Destination)
238
+    function saveFromCache($ID,$Destination)
239 239
     {
240
-     /* Get the raw picture from the cache */
241
-     $Picture = $this->getFromCache($ID);
240
+        /* Get the raw picture from the cache */
241
+        $Picture = $this->getFromCache($ID);
242 242
 
243
-     /* Do we have a hit? */
244
-     if ( $Picture == NULL ) { return(FALSE); }
243
+        /* Do we have a hit? */
244
+        if ( $Picture == NULL ) { return(FALSE); }
245 245
 
246
-     /* Flush the picture to a file */
247
-     $Handle = fopen($Destination,"w");
248
-     fwrite($Handle,$Picture);
249
-     fclose($Handle);
246
+        /* Flush the picture to a file */
247
+        $Handle = fopen($Destination,"w");
248
+        fwrite($Handle,$Picture);
249
+        fclose($Handle);
250 250
 
251
-     /* All went fine */
252
-     return(TRUE);
251
+        /* All went fine */
252
+        return(TRUE);
253 253
     }
254 254
 
255
-   function getFromCache($ID)
255
+    function getFromCache($ID)
256 256
     {
257
-     /* Compute the path */
258
-     $Database = $this->CacheFolder."/".$this->CacheDB;
257
+        /* Compute the path */
258
+        $Database = $this->CacheFolder."/".$this->CacheDB;
259 259
 
260
-     /* Lookup for the picture in the cache */
261
-     $CacheInfo = $this->isInCache($ID,TRUE,TRUE);
260
+        /* Lookup for the picture in the cache */
261
+        $CacheInfo = $this->isInCache($ID,TRUE,TRUE);
262 262
 
263
-     /* Not in the cache */
264
-     if (!$CacheInfo) { return(NULL); }
263
+        /* Not in the cache */
264
+        if (!$CacheInfo) { return(NULL); }
265 265
 
266
-     /* Get the database extended information */     
267
-     $DBPos   = $CacheInfo["DBPos"];
268
-     $PicSize = $CacheInfo["PicSize"];
266
+        /* Get the database extended information */     
267
+        $DBPos   = $CacheInfo["DBPos"];
268
+        $PicSize = $CacheInfo["PicSize"];
269 269
 
270
-     /* Extract the picture from the solid cache file */
271
-     $Handle = @fopen($Database, "r");
272
-     fseek($Handle,$DBPos);
273
-     $Picture = fread($Handle,$PicSize);
274
-     fclose($Handle);
270
+        /* Extract the picture from the solid cache file */
271
+        $Handle = @fopen($Database, "r");
272
+        fseek($Handle,$DBPos);
273
+        $Picture = fread($Handle,$PicSize);
274
+        fclose($Handle);
275 275
 
276
-     /* Return back the raw picture data */
277
-     return($Picture);
276
+        /* Return back the raw picture data */
277
+        return($Picture);
278
+    }
278 279
     }
279
-  }
280 280
 ?>
281 281
\ No newline at end of file
Please login to merge, or discard this patch.
default/boinc/modules/boincstats/includes/pchart/class/pSurface.class.php 1 patch
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- /*
2
+    /*
3 3
      pSurface - class to draw surface charts
4 4
 
5 5
      Version     : 2.1.3
@@ -13,303 +13,303 @@  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("UNKNOWN"		, 0.123456789);
17
- define("IGNORED"		, -1);
16
+    define("UNKNOWN"		, 0.123456789);
17
+    define("IGNORED"		, -1);
18 18
 
19
- define("LABEL_POSITION_LEFT"	, 880001);
20
- define("LABEL_POSITION_RIGHT"	, 880002);
21
- define("LABEL_POSITION_TOP"	, 880003);
22
- define("LABEL_POSITION_BOTTOM"	, 880004);
19
+    define("LABEL_POSITION_LEFT"	, 880001);
20
+    define("LABEL_POSITION_RIGHT"	, 880002);
21
+    define("LABEL_POSITION_TOP"	, 880003);
22
+    define("LABEL_POSITION_BOTTOM"	, 880004);
23 23
 
24
- /* pStock class definition */
25
- class pSurface
26
-  {
27
-   var $pChartObject;
28
-   var $GridSizeX;
29
-   var $GridSizeY;
30
-   var $Points;
24
+    /* pStock class definition */
25
+    class pSurface
26
+    {
27
+    var $pChartObject;
28
+    var $GridSizeX;
29
+    var $GridSizeY;
30
+    var $Points;
31 31
 
32
-   /* Class creator */
33
-   function pSurface($pChartObject)
32
+    /* Class creator */
33
+    function pSurface($pChartObject)
34 34
     {
35
-     $this->pChartObject = $pChartObject;
36
-     $this->GridSize     = 10;
37
-     $this->Points       = "";
35
+        $this->pChartObject = $pChartObject;
36
+        $this->GridSize     = 10;
37
+        $this->Points       = "";
38 38
     }
39 39
 
40
-   /* Define the grid size and initialise the 2D matrix */
41
-   function setGrid($XSize=10,$YSize=10)
40
+    /* Define the grid size and initialise the 2D matrix */
41
+    function setGrid($XSize=10,$YSize=10)
42 42
     {
43
-     for($X=0; $X<=$XSize; $X++) { for($Y=0; $Y<=$YSize; $Y++) { $this->Points[$X][$Y]=UNKNOWN; } } 
43
+        for($X=0; $X<=$XSize; $X++) { for($Y=0; $Y<=$YSize; $Y++) { $this->Points[$X][$Y]=UNKNOWN; } } 
44 44
 
45
-     $this->GridSizeX = $XSize;
46
-     $this->GridSizeY = $YSize;
45
+        $this->GridSizeX = $XSize;
46
+        $this->GridSizeY = $YSize;
47 47
     }
48 48
 
49
-   /* Add a point on the grid */
50
-   function addPoint($X,$Y,$Value,$Force=TRUE)
49
+    /* Add a point on the grid */
50
+    function addPoint($X,$Y,$Value,$Force=TRUE)
51 51
     {
52
-     if ( $X < 0 || $X >$this->GridSizeX ) { return(0); }
53
-     if ( $Y < 0 || $Y >$this->GridSizeY ) { return(0); }
54
-
55
-     if ( $this->Points[$X][$Y] == UNKNOWN || $Force )
56
-      $this->Points[$X][$Y] = $Value;
57
-     elseif ( $this->Points[$X][$Y] == UNKNOWN )
58
-      $this->Points[$X][$Y] = $Value;
59
-     else
60
-      $this->Points[$X][$Y] = ($this->Points[$X][$Y] + $Value)/2;
52
+        if ( $X < 0 || $X >$this->GridSizeX ) { return(0); }
53
+        if ( $Y < 0 || $Y >$this->GridSizeY ) { return(0); }
54
+
55
+        if ( $this->Points[$X][$Y] == UNKNOWN || $Force )
56
+        $this->Points[$X][$Y] = $Value;
57
+        elseif ( $this->Points[$X][$Y] == UNKNOWN )
58
+        $this->Points[$X][$Y] = $Value;
59
+        else
60
+        $this->Points[$X][$Y] = ($this->Points[$X][$Y] + $Value)/2;
61 61
     }
62 62
 
63
-   /* Write the X labels */
64
-   function writeXLabels($Format="")
63
+    /* Write the X labels */
64
+    function writeXLabels($Format="")
65 65
     {
66
-     $R			= isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR;
67
-     $G			= isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG;
68
-     $B			= isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB;
69
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA;
70
-     $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
71
-     $Padding		= isset($Format["Padding"]) ? $Format["Padding"] : 5;
72
-     $Position		= isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_TOP;
73
-     $Labels		= isset($Format["Labels"]) ? $Format["Labels"] : NULL;
74
-     $CountOffset	= isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0;
75
-
76
-     if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; }
77
-
78
-     $X0    = $this->pChartObject->GraphAreaX1;
79
-     $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1);
80
-
81
-     $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
82
-     if ( $Position == LABEL_POSITION_TOP )
83
-      {
84
-       $YPos  = $this->pChartObject->GraphAreaY1 - $Padding;
85
-       if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; }
86
-       if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; }
87
-      }
88
-     elseif ( $Position == LABEL_POSITION_BOTTOM )
89
-      {
90
-       $YPos  = $this->pChartObject->GraphAreaY2 + $Padding;
91
-       if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_TOPMIDDLE; }
92
-       if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; }
93
-      }
94
-     else
95
-      return(-1);
96
-
97
-     for($X=0;$X<=$this->GridSizeX;$X++)
98
-      {
99
-       $XPos = floor($X0+$X*$XSize + $XSize/2);
100
-
101
-       if( $Labels == NULL || !isset($Labels[$X]) )
66
+        $R			= isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR;
67
+        $G			= isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG;
68
+        $B			= isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB;
69
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA;
70
+        $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
71
+        $Padding		= isset($Format["Padding"]) ? $Format["Padding"] : 5;
72
+        $Position		= isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_TOP;
73
+        $Labels		= isset($Format["Labels"]) ? $Format["Labels"] : NULL;
74
+        $CountOffset	= isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0;
75
+
76
+        if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; }
77
+
78
+        $X0    = $this->pChartObject->GraphAreaX1;
79
+        $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1);
80
+
81
+        $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
82
+        if ( $Position == LABEL_POSITION_TOP )
83
+        {
84
+        $YPos  = $this->pChartObject->GraphAreaY1 - $Padding;
85
+        if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; }
86
+        if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; }
87
+        }
88
+        elseif ( $Position == LABEL_POSITION_BOTTOM )
89
+        {
90
+        $YPos  = $this->pChartObject->GraphAreaY2 + $Padding;
91
+        if ($Angle == 0 ) { $Settings["Align"] = TEXT_ALIGN_TOPMIDDLE; }
92
+        if ($Angle != 0 ) { $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; }
93
+        }
94
+        else
95
+        return(-1);
96
+
97
+        for($X=0;$X<=$this->GridSizeX;$X++)
98
+        {
99
+        $XPos = floor($X0+$X*$XSize + $XSize/2);
100
+
101
+        if( $Labels == NULL || !isset($Labels[$X]) )
102 102
         $Value = $X+$CountOffset;
103
-       else
103
+        else
104 104
         $Value = $Labels[$X];
105 105
 
106
-       $this->pChartObject->drawText($XPos,$YPos,$Value,$Settings);
107
-      }
106
+        $this->pChartObject->drawText($XPos,$YPos,$Value,$Settings);
107
+        }
108 108
     }
109 109
 
110
-   /* Write the Y labels */
111
-   function writeYLabels($Format="")
110
+    /* Write the Y labels */
111
+    function writeYLabels($Format="")
112 112
     {
113
-     $R			= isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR;
114
-     $G			= isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG;
115
-     $B			= isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB;
116
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA;
117
-     $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
118
-     $Padding		= isset($Format["Padding"]) ? $Format["Padding"] : 5;
119
-     $Position		= isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_LEFT;
120
-     $Labels		= isset($Format["Labels"]) ? $Format["Labels"] : NULL;
121
-     $CountOffset	= isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0;
122
-
123
-     if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; }
124
-
125
-     $Y0    = $this->pChartObject->GraphAreaY1;
126
-     $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1);
127
-
128
-     $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
129
-     if ( $Position == LABEL_POSITION_LEFT )
130
-      { $XPos  = $this->pChartObject->GraphAreaX1 - $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; }
131
-     elseif ( $Position == LABEL_POSITION_RIGHT )
132
-      { $XPos  = $this->pChartObject->GraphAreaX2 + $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; }
133
-     else
134
-      return(-1);
135
-
136
-     for($Y=0;$Y<=$this->GridSizeY;$Y++)
137
-      {
138
-       $YPos = floor($Y0+$Y*$YSize + $YSize/2);
139
-
140
-       if( $Labels == NULL || !isset($Labels[$Y]) )
113
+        $R			= isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR;
114
+        $G			= isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG;
115
+        $B			= isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB;
116
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA;
117
+        $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
118
+        $Padding		= isset($Format["Padding"]) ? $Format["Padding"] : 5;
119
+        $Position		= isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_LEFT;
120
+        $Labels		= isset($Format["Labels"]) ? $Format["Labels"] : NULL;
121
+        $CountOffset	= isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0;
122
+
123
+        if ( $Labels != NULL && !is_array($Labels) ) { $Label = $Labels; $Labels = ""; $Labels[] = $Label; }
124
+
125
+        $Y0    = $this->pChartObject->GraphAreaY1;
126
+        $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1);
127
+
128
+        $Settings = array("Angle"=>$Angle,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
129
+        if ( $Position == LABEL_POSITION_LEFT )
130
+        { $XPos  = $this->pChartObject->GraphAreaX1 - $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT; }
131
+        elseif ( $Position == LABEL_POSITION_RIGHT )
132
+        { $XPos  = $this->pChartObject->GraphAreaX2 + $Padding; $Settings["Align"] = TEXT_ALIGN_MIDDLELEFT; }
133
+        else
134
+        return(-1);
135
+
136
+        for($Y=0;$Y<=$this->GridSizeY;$Y++)
137
+        {
138
+        $YPos = floor($Y0+$Y*$YSize + $YSize/2);
139
+
140
+        if( $Labels == NULL || !isset($Labels[$Y]) )
141 141
         $Value = $Y+$CountOffset;
142
-       else
142
+        else
143 143
         $Value = $Labels[$Y];
144 144
 
145
-       $this->pChartObject->drawText($XPos,$YPos,$Value,$Settings);
146
-      }
145
+        $this->pChartObject->drawText($XPos,$YPos,$Value,$Settings);
146
+        }
147 147
     }
148 148
 
149
-   /* Draw the area arround the specified Threshold */
150
-   function drawContour($Threshold,$Format="")
149
+    /* Draw the area arround the specified Threshold */
150
+    function drawContour($Threshold,$Format="")
151 151
     {
152
-     $R		= isset($Format["R"]) ? $Format["R"] : 0;
153
-     $G		= isset($Format["G"]) ? $Format["G"] : 0;
154
-     $B		= isset($Format["B"]) ? $Format["B"] : 0;
155
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
156
-     $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : 3;
157
-     $Padding	= isset($Format["Padding"]) ? $Format["Padding"] : 0;
158
-
159
-     $X0    = $this->pChartObject->GraphAreaX1;
160
-     $Y0    = $this->pChartObject->GraphAreaY1;
161
-     $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1);
162
-     $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1);
163
-
164
-     $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks);
165
-
166
-     for($X=0;$X<=$this->GridSizeX;$X++)
167
-      {
168
-       for($Y=0;$Y<=$this->GridSizeY;$Y++)
152
+        $R		= isset($Format["R"]) ? $Format["R"] : 0;
153
+        $G		= isset($Format["G"]) ? $Format["G"] : 0;
154
+        $B		= isset($Format["B"]) ? $Format["B"] : 0;
155
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
156
+        $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : 3;
157
+        $Padding	= isset($Format["Padding"]) ? $Format["Padding"] : 0;
158
+
159
+        $X0    = $this->pChartObject->GraphAreaX1;
160
+        $Y0    = $this->pChartObject->GraphAreaY1;
161
+        $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1);
162
+        $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1);
163
+
164
+        $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks);
165
+
166
+        for($X=0;$X<=$this->GridSizeX;$X++)
169 167
         {
170
-         $Value = $this->Points[$X][$Y];
168
+        for($Y=0;$Y<=$this->GridSizeY;$Y++)
169
+        {
170
+            $Value = $this->Points[$X][$Y];
171 171
 
172
-         if ( $Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold)
173
-          {
174
-           $X1 = floor($X0+$X*$XSize)+$Padding;
175
-           $Y1 = floor($Y0+$Y*$YSize)+$Padding;
176
-           $X2 = floor($X0+$X*$XSize+$XSize);
177
-           $Y2 = floor($Y0+$Y*$YSize+$YSize);
172
+            if ( $Value != UNKNOWN && $Value != IGNORED && $Value >= $Threshold)
173
+            {
174
+            $X1 = floor($X0+$X*$XSize)+$Padding;
175
+            $Y1 = floor($Y0+$Y*$YSize)+$Padding;
176
+            $X2 = floor($X0+$X*$XSize+$XSize);
177
+            $Y2 = floor($Y0+$Y*$YSize+$YSize);
178 178
 
179
-           if ( $X > 0 && $this->Points[$X-1][$Y] != UNKNOWN && $this->Points[$X-1][$Y] != IGNORED && $this->Points[$X-1][$Y] < $Threshold)
179
+            if ( $X > 0 && $this->Points[$X-1][$Y] != UNKNOWN && $this->Points[$X-1][$Y] != IGNORED && $this->Points[$X-1][$Y] < $Threshold)
180 180
             $this->pChartObject->drawLine($X1,$Y1,$X1,$Y2,$Color);
181
-           if ( $Y > 0 && $this->Points[$X][$Y-1] != UNKNOWN && $this->Points[$X][$Y-1] != IGNORED && $this->Points[$X][$Y-1] < $Threshold)
181
+            if ( $Y > 0 && $this->Points[$X][$Y-1] != UNKNOWN && $this->Points[$X][$Y-1] != IGNORED && $this->Points[$X][$Y-1] < $Threshold)
182 182
             $this->pChartObject->drawLine($X1,$Y1,$X2,$Y1,$Color);
183
-           if ( $X < $this->GridSizeX && $this->Points[$X+1][$Y] != UNKNOWN && $this->Points[$X+1][$Y] != IGNORED && $this->Points[$X+1][$Y] < $Threshold)
183
+            if ( $X < $this->GridSizeX && $this->Points[$X+1][$Y] != UNKNOWN && $this->Points[$X+1][$Y] != IGNORED && $this->Points[$X+1][$Y] < $Threshold)
184 184
             $this->pChartObject->drawLine($X2,$Y1,$X2,$Y2,$Color);
185
-           if ( $Y < $this->GridSizeY && $this->Points[$X][$Y+1] != UNKNOWN && $this->Points[$X][$Y+1] != IGNORED && $this->Points[$X][$Y+1] < $Threshold)
185
+            if ( $Y < $this->GridSizeY && $this->Points[$X][$Y+1] != UNKNOWN && $this->Points[$X][$Y+1] != IGNORED && $this->Points[$X][$Y+1] < $Threshold)
186 186
             $this->pChartObject->drawLine($X1,$Y2,$X2,$Y2,$Color);
187
-          }
187
+            }
188
+        }
188 189
         }
189
-      }
190 190
     }
191 191
 
192
-   /* Draw the surface chart */
193
-   function drawSurface($Format="")
192
+    /* Draw the surface chart */
193
+    function drawSurface($Format="")
194 194
     {
195
-     $Palette		= isset($Format["Palette"]) ? $Format["Palette"] : NULL;
196
-     $ShadeR1		= isset($Format["ShadeR1"]) ? $Format["ShadeR1"] : 77;
197
-     $ShadeG1		= isset($Format["ShadeG1"]) ? $Format["ShadeG1"] : 205;
198
-     $ShadeB1		= isset($Format["ShadeB1"]) ? $Format["ShadeB1"] : 21;
199
-     $ShadeA1		= isset($Format["ShadeA1"]) ? $Format["ShadeA1"] : 40;
200
-     $ShadeR2		= isset($Format["ShadeR2"]) ? $Format["ShadeR2"] : 227;
201
-     $ShadeG2		= isset($Format["ShadeG2"]) ? $Format["ShadeG2"] : 135;
202
-     $ShadeB2		= isset($Format["ShadeB2"]) ? $Format["ShadeB2"] : 61;
203
-     $ShadeA2		= isset($Format["ShadeA2"]) ? $Format["ShadeA2"] : 100;
204
-     $Border		= isset($Format["Border"]) ? $Format["Border"] : FALSE;
205
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : 0;
206
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : 0;
207
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : 0;
208
-     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : -1;
209
-     $Padding		= isset($Format["Padding"]) ? $Format["Padding"] : 1;
210
-
211
-     $X0    = $this->pChartObject->GraphAreaX1;
212
-     $Y0    = $this->pChartObject->GraphAreaY1;
213
-     $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1);
214
-     $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1);
215
-
216
-     for($X=0;$X<=$this->GridSizeX;$X++)
217
-      {
218
-       for($Y=0;$Y<=$this->GridSizeY;$Y++)
195
+        $Palette		= isset($Format["Palette"]) ? $Format["Palette"] : NULL;
196
+        $ShadeR1		= isset($Format["ShadeR1"]) ? $Format["ShadeR1"] : 77;
197
+        $ShadeG1		= isset($Format["ShadeG1"]) ? $Format["ShadeG1"] : 205;
198
+        $ShadeB1		= isset($Format["ShadeB1"]) ? $Format["ShadeB1"] : 21;
199
+        $ShadeA1		= isset($Format["ShadeA1"]) ? $Format["ShadeA1"] : 40;
200
+        $ShadeR2		= isset($Format["ShadeR2"]) ? $Format["ShadeR2"] : 227;
201
+        $ShadeG2		= isset($Format["ShadeG2"]) ? $Format["ShadeG2"] : 135;
202
+        $ShadeB2		= isset($Format["ShadeB2"]) ? $Format["ShadeB2"] : 61;
203
+        $ShadeA2		= isset($Format["ShadeA2"]) ? $Format["ShadeA2"] : 100;
204
+        $Border		= isset($Format["Border"]) ? $Format["Border"] : FALSE;
205
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : 0;
206
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : 0;
207
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : 0;
208
+        $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : -1;
209
+        $Padding		= isset($Format["Padding"]) ? $Format["Padding"] : 1;
210
+
211
+        $X0    = $this->pChartObject->GraphAreaX1;
212
+        $Y0    = $this->pChartObject->GraphAreaY1;
213
+        $XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX+1);
214
+        $YSize = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1) / ($this->GridSizeY+1);
215
+
216
+        for($X=0;$X<=$this->GridSizeX;$X++)
217
+        {
218
+        for($Y=0;$Y<=$this->GridSizeY;$Y++)
219 219
         {
220
-         $Value = $this->Points[$X][$Y];
220
+            $Value = $this->Points[$X][$Y];
221 221
 
222
-         if ( $Value != UNKNOWN && $Value != IGNORED )
223
-          {
224
-           $X1 = floor($X0+$X*$XSize)+$Padding;
225
-           $Y1 = floor($Y0+$Y*$YSize)+$Padding;
226
-           $X2 = floor($X0+$X*$XSize+$XSize);
227
-           $Y2 = floor($Y0+$Y*$YSize+$YSize);
222
+            if ( $Value != UNKNOWN && $Value != IGNORED )
223
+            {
224
+            $X1 = floor($X0+$X*$XSize)+$Padding;
225
+            $Y1 = floor($Y0+$Y*$YSize)+$Padding;
226
+            $X2 = floor($X0+$X*$XSize+$XSize);
227
+            $Y2 = floor($Y0+$Y*$YSize+$YSize);
228 228
 
229
-           if ( $Palette != NULL )
229
+            if ( $Palette != NULL )
230 230
             {
231
-             if ( isset($Palette[$Value]) && isset($Palette[$Value]["R"]) ) { $R = $Palette[$Value]["R"]; } else { $R = 0; }
232
-             if ( isset($Palette[$Value]) && isset($Palette[$Value]["G"]) ) { $G = $Palette[$Value]["G"]; } else { $G = 0; }
233
-             if ( isset($Palette[$Value]) && isset($Palette[$Value]["B"]) ) { $B = $Palette[$Value]["B"]; } else { $B = 0; }
234
-             if ( isset($Palette[$Value]) && isset($Palette[$Value]["Alpha"]) ) { $Alpha = $Palette[$Value]["Alpha"]; } else { $Alpha = 1000; }
231
+                if ( isset($Palette[$Value]) && isset($Palette[$Value]["R"]) ) { $R = $Palette[$Value]["R"]; } else { $R = 0; }
232
+                if ( isset($Palette[$Value]) && isset($Palette[$Value]["G"]) ) { $G = $Palette[$Value]["G"]; } else { $G = 0; }
233
+                if ( isset($Palette[$Value]) && isset($Palette[$Value]["B"]) ) { $B = $Palette[$Value]["B"]; } else { $B = 0; }
234
+                if ( isset($Palette[$Value]) && isset($Palette[$Value]["Alpha"]) ) { $Alpha = $Palette[$Value]["Alpha"]; } else { $Alpha = 1000; }
235 235
             }
236
-           else
236
+            else
237 237
             {
238
-             $R = (($ShadeR2-$ShadeR1)/100)*$Value + $ShadeR1;
239
-             $G = (($ShadeG2-$ShadeG1)/100)*$Value + $ShadeG1;
240
-             $B = (($ShadeB2-$ShadeB1)/100)*$Value + $ShadeB1;
241
-             $Alpha = (($ShadeA2-$ShadeA1)/100)*$Value + $ShadeA1;
238
+                $R = (($ShadeR2-$ShadeR1)/100)*$Value + $ShadeR1;
239
+                $G = (($ShadeG2-$ShadeG1)/100)*$Value + $ShadeG1;
240
+                $B = (($ShadeB2-$ShadeB1)/100)*$Value + $ShadeB1;
241
+                $Alpha = (($ShadeA2-$ShadeA1)/100)*$Value + $ShadeA1;
242 242
             }
243 243
 
244
-           $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
245
-           if ( $Border ) { $Settings["BorderR"] = $BorderR; $Settings["BorderG"] = $BorderG; $Settings["BorderB"] = $BorderB; }
246
-           if ( $Surrounding != -1 ) { $Settings["BorderR"] = $R+$Surrounding; $Settings["BorderG"] = $G+$Surrounding; $Settings["BorderB"] = $B+$Surrounding; }
244
+            $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
245
+            if ( $Border ) { $Settings["BorderR"] = $BorderR; $Settings["BorderG"] = $BorderG; $Settings["BorderB"] = $BorderB; }
246
+            if ( $Surrounding != -1 ) { $Settings["BorderR"] = $R+$Surrounding; $Settings["BorderG"] = $G+$Surrounding; $Settings["BorderB"] = $B+$Surrounding; }
247 247
 
248
-           $this->pChartObject->drawFilledRectangle($X1,$Y1,$X2-1,$Y2-1,$Settings);
249
-          }
248
+            $this->pChartObject->drawFilledRectangle($X1,$Y1,$X2-1,$Y2-1,$Settings);
249
+            }
250
+        }
250 251
         }
251
-      }
252 252
     }
253 253
 
254
-   /* Compute the missing points */
255
-   function computeMissing()
254
+    /* Compute the missing points */
255
+    function computeMissing()
256 256
     {
257
-     $Missing = "";
258
-     for($X=0;$X<=$this->GridSizeX;$X++)
259
-      {
260
-       for($Y=0;$Y<=$this->GridSizeY;$Y++)
257
+        $Missing = "";
258
+        for($X=0;$X<=$this->GridSizeX;$X++)
259
+        {
260
+        for($Y=0;$Y<=$this->GridSizeY;$Y++)
261 261
         {
262
-         if ( $this->Points[$X][$Y] == UNKNOWN )
263
-          $Missing[] = $X.",".$Y;
262
+            if ( $this->Points[$X][$Y] == UNKNOWN )
263
+            $Missing[] = $X.",".$Y;
264 264
         }
265
-      }
266
-     shuffle($Missing);
265
+        }
266
+        shuffle($Missing);
267 267
      
268
-     foreach($Missing as $Key => $Pos)
269
-      {
270
-       $Pos = preg_split("/,/",$Pos);
271
-       $X   = $Pos[0];
272
-       $Y   = $Pos[1];
268
+        foreach($Missing as $Key => $Pos)
269
+        {
270
+        $Pos = preg_split("/,/",$Pos);
271
+        $X   = $Pos[0];
272
+        $Y   = $Pos[1];
273 273
 
274
-       if ( $this->Points[$X][$Y] == UNKNOWN )
274
+        if ( $this->Points[$X][$Y] == UNKNOWN )
275 275
         {
276
-         $NearestNeighbor = $this->getNearestNeighbor($X,$Y);
276
+            $NearestNeighbor = $this->getNearestNeighbor($X,$Y);
277 277
 
278
-         $Value = 0; $Points = 0;
279
-         for($Xi=$X-$NearestNeighbor;$Xi<=$X+$NearestNeighbor;$Xi++)
280
-          {
281
-           for($Yi=$Y-$NearestNeighbor;$Yi<=$Y+$NearestNeighbor;$Yi++)
278
+            $Value = 0; $Points = 0;
279
+            for($Xi=$X-$NearestNeighbor;$Xi<=$X+$NearestNeighbor;$Xi++)
282 280
             {
283
-             if ($Xi >=0 && $Yi >= 0 && $Xi <= $this->GridSizeX && $Yi <= $this->GridSizeY && $this->Points[$Xi][$Yi] != UNKNOWN && $this->Points[$Xi][$Yi] != IGNORED)
284
-              {
285
-               $Value = $Value + $this->Points[$Xi][$Yi]; $Points++;
286
-              }
281
+            for($Yi=$Y-$NearestNeighbor;$Yi<=$Y+$NearestNeighbor;$Yi++)
282
+            {
283
+                if ($Xi >=0 && $Yi >= 0 && $Xi <= $this->GridSizeX && $Yi <= $this->GridSizeY && $this->Points[$Xi][$Yi] != UNKNOWN && $this->Points[$Xi][$Yi] != IGNORED)
284
+                {
285
+                $Value = $Value + $this->Points[$Xi][$Yi]; $Points++;
286
+                }
287
+            }
287 288
             }
288
-          }
289 289
 
290
-         if ( $Points != 0 ) { $this->Points[$X][$Y] = $Value / $Points; }
290
+            if ( $Points != 0 ) { $this->Points[$X][$Y] = $Value / $Points; }
291
+        }
291 292
         }
292
-      }
293 293
     }
294 294
 
295
-   /* Return the nearest Neighbor distance of a point */
296
-   function getNearestNeighbor($Xp,$Yp)
295
+    /* Return the nearest Neighbor distance of a point */
296
+    function getNearestNeighbor($Xp,$Yp)
297 297
     {
298
-     $Nearest = UNKNOWN;
299
-     for($X=0;$X<=$this->GridSizeX;$X++)
300
-      {
301
-       for($Y=0;$Y<=$this->GridSizeY;$Y++)
298
+        $Nearest = UNKNOWN;
299
+        for($X=0;$X<=$this->GridSizeX;$X++)
300
+        {
301
+        for($Y=0;$Y<=$this->GridSizeY;$Y++)
302 302
         {
303
-         if ( $this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED )
304
-          {
305
-           $DistanceX = max($Xp,$X)-min($Xp,$X);
306
-           $DistanceY = max($Yp,$Y)-min($Yp,$Y);
307
-           $Distance  = max($DistanceX,$DistanceY);
308
-           if ( $Distance < $Nearest || $Nearest == UNKNOWN ) { $Nearest = $Distance; }
309
-          }
303
+            if ( $this->Points[$X][$Y] != UNKNOWN && $this->Points[$X][$Y] != IGNORED )
304
+            {
305
+            $DistanceX = max($Xp,$X)-min($Xp,$X);
306
+            $DistanceY = max($Yp,$Y)-min($Yp,$Y);
307
+            $Distance  = max($DistanceX,$DistanceY);
308
+            if ( $Distance < $Nearest || $Nearest == UNKNOWN ) { $Nearest = $Distance; }
309
+            }
310 310
         }
311
-      }
312
-     return($Nearest);
311
+        }
312
+        return($Nearest);
313
+    }
313 314
     }
314
-  }
315 315
 ?>
316 316
\ No newline at end of file
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincstats/boincstats.module 1 patch
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@  discard block
 block discarded – undo
2 2
 // $Id$
3 3
 
4 4
 /**
5
-  * @file
6
-  * Enable BOINC charting features for statistics
7
-  */
5
+ * @file
6
+ * Enable BOINC charting features for statistics
7
+ */
8 8
 
9 9
 
10 10
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
19 19
 
20 20
 /**
21
-  * Implementation of hook_menu().
22
-  */
21
+ * Implementation of hook_menu().
22
+ */
23 23
 function boincstats_menu() {
24
-  $items['admin/boinc/stats'] = array(
24
+    $items['admin/boinc/stats'] = array(
25 25
     'title' => 'Environment: Statistics setup',
26 26
     'description' => 'Configure the stats system for generating charts and 
27 27
       providing cross project data.',
@@ -30,18 +30,18 @@  discard block
 block discarded – undo
30 30
     'access arguments' => array('administer site configuration'),
31 31
     'type' => MENU_NORMAL_ITEM,
32 32
     'file' => 'boincstats.admin.inc'
33
-  );
34
-  $items['charts/user'] = array(
33
+    );
34
+    $items['charts/user'] = array(
35 35
     'page callback' => 'boincstats_get_user_stats_chart',
36 36
     'access arguments' => array('access content'),
37 37
     'type' => MENU_CALLBACK
38
-  );
39
-  $items['charts/project'] = array(
38
+    );
39
+    $items['charts/project'] = array(
40 40
     'page callback' => 'boincstats_get_project_stats_chart',
41 41
     'access arguments' => array('access content'),
42 42
     'type' => MENU_CALLBACK
43
-  );
44
-  return $items;
43
+    );
44
+    return $items;
45 45
 }
46 46
 
47 47
 
@@ -50,44 +50,44 @@  discard block
 block discarded – undo
50 50
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
51 51
  
52 52
 /**
53
-  * User stats chart menu callback
54
-  * Called to generate the daily credit status chart for a user (dashboard)
55
-  */
53
+ * User stats chart menu callback
54
+ * Called to generate the daily credit status chart for a user (dashboard)
55
+ */
56 56
 function boincstats_get_user_stats_chart($cpid = null, $chart_size = 'medium') {
57 57
   
58
-  // pChart library inclusions
59
-  module_load_include('php', 'boincstats', 'includes/pchart/class/pData.class');
60
-  module_load_include('php', 'boincstats', 'includes/pchart/class/pDraw.class');
61
-  module_load_include('php', 'boincstats', 'includes/pchart/class/pImage.class');
62
-  module_load_include('php', 'boincstats', 'includes/pchart/class/pCache.class');
58
+    // pChart library inclusions
59
+    module_load_include('php', 'boincstats', 'includes/pchart/class/pData.class');
60
+    module_load_include('php', 'boincstats', 'includes/pchart/class/pDraw.class');
61
+    module_load_include('php', 'boincstats', 'includes/pchart/class/pImage.class');
62
+    module_load_include('php', 'boincstats', 'includes/pchart/class/pCache.class');
63 63
   
64
-  init_theme();
65
-  global $theme_key;
66
-  $cache_name = "{$theme_key}_";
64
+    init_theme();
65
+    global $theme_key;
66
+    $cache_name = "{$theme_key}_";
67 67
   
68
-  // Determine the stats environment
69
-  boincstats_check_configuration();
70
-  $stats_server = variable_get('boinc_stats_server', '');
71
-  $stats_rpc = variable_get('boinc_stats_user_credit_history_rpc', '');
72
-  $project_id = variable_get('boinc_stats_remote_project_id', '');
68
+    // Determine the stats environment
69
+    boincstats_check_configuration();
70
+    $stats_server = variable_get('boinc_stats_server', '');
71
+    $stats_rpc = variable_get('boinc_stats_user_credit_history_rpc', '');
72
+    $project_id = variable_get('boinc_stats_remote_project_id', '');
73 73
   
74
-  $dataset_size = 0;
75
-  $chart_height = 0;
76
-  $chart_width = 0;
77
-  $draw_x_lines = FALSE;
78
-  $label_x_axis = FALSE;
74
+    $dataset_size = 0;
75
+    $chart_height = 0;
76
+    $chart_width = 0;
77
+    $draw_x_lines = FALSE;
78
+    $label_x_axis = FALSE;
79 79
   
80
-  $stats_xml = NULL;
81
-  $color_keys = array('R', 'G', 'B');
80
+    $stats_xml = NULL;
81
+    $color_keys = array('R', 'G', 'B');
82 82
   
83
-  // Get color configuration
84
-  $palette_color_hex = theme_get_setting('boinc_stats_chart_color');
85
-  $palette_color = array_combine($color_keys, sscanf($palette_color_hex, "#%02x%02x%02x"));
86
-  $backdrop_color_hex = theme_get_setting('boinc_stats_chart_bcolor');
87
-  $backdrop_color = array_combine($color_keys, sscanf($backdrop_color_hex, "#%02x%02x%02x"));
83
+    // Get color configuration
84
+    $palette_color_hex = theme_get_setting('boinc_stats_chart_color');
85
+    $palette_color = array_combine($color_keys, sscanf($palette_color_hex, "#%02x%02x%02x"));
86
+    $backdrop_color_hex = theme_get_setting('boinc_stats_chart_bcolor');
87
+    $backdrop_color = array_combine($color_keys, sscanf($backdrop_color_hex, "#%02x%02x%02x"));
88 88
   
89
-  switch($chart_size) {
90
-  case 'small':
89
+    switch($chart_size) {
90
+    case 'small':
91 91
     $cache_name .= "{$cpid}_small";
92 92
     $dataset_size = 30;
93 93
     $chart_height = 80;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     $draw_x_lines = FALSE;
97 97
     $label_x_axis = FALSE;
98 98
     break;
99
-  case 'medium':
99
+    case 'medium':
100 100
   default:
101 101
     $cache_name .= $cpid;
102 102
     $dataset_size = 60;
@@ -104,25 +104,25 @@  discard block
 block discarded – undo
104 104
     $chart_width = 589;
105 105
     $draw_x_lines = TRUE;
106 106
     $label_x_axis = TRUE;
107
-  }
107
+    }
108 108
   
109
-  // Sanity check for cache directory
110
-  if (!boincstats_check_cache_dir()) {
109
+    // Sanity check for cache directory
110
+    if (!boincstats_check_cache_dir()) {
111 111
     return;
112
-  }
112
+    }
113 113
   
114
-  // Initialize the cache object and flush stale images
115
-  $myCache = new pCache(array('CacheFolder' => realpath('.') . '/' . conf_path() . '/files/cache'));
116
-  $myCache->removeOlderThan(60*60*24);
114
+    // Initialize the cache object and flush stale images
115
+    $myCache = new pCache(array('CacheFolder' => realpath('.') . '/' . conf_path() . '/files/cache'));
116
+    $myCache->removeOlderThan(60*60*24);
117 117
   
118
-  if ($myCache->isInCache($cache_name)) {
118
+    if ($myCache->isInCache($cache_name)) {
119 119
     $myCache->strokeFromCache($cache_name);
120
-  }
121
-  else {
120
+    }
121
+    else {
122 122
     // Construct query string
123 123
     $get = array(
124
-      'cpid' => $cpid,
125
-      'projectid' => $project_id
124
+        'cpid' => $cpid,
125
+        'projectid' => $project_id
126 126
     );
127 127
     $args = array();
128 128
     foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     $target_url = "http://{$stats_server}/{$stats_rpc}{$query}";
133 133
     $result = drupal_http_request($target_url);
134 134
     if (in_array($result->code, array(200, 304))) {
135
-      $stats_xml = simplexml_load_string($result->data);
135
+        $stats_xml = simplexml_load_string($result->data);
136 136
     }
137 137
     
138 138
     // Create and populate the pData object
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
     // Initialize dataset
142 142
     $dataset = array();
143 143
     if ($stats_xml) {
144
-      $credit = null;
145
-      for ($i = 0, $j = 31; $j <= 91; $i++, $j++) {
144
+        $credit = null;
145
+        for ($i = 0, $j = 31; $j <= 91; $i++, $j++) {
146 146
         $day = "day_{$j}";
147 147
         $credit[$i] = isset($stats_xml->total_credit_history_last_91_days->$day) ? (int) $stats_xml->total_credit_history_last_91_days->$day : 0;
148 148
         $dataset[$i] = ($i) ? ($credit[$i] - $credit[$i-1]) : 0;
149
-      }
149
+        }
150 150
     }
151 151
     else {
152
-      for ($i = 0; $i <= $dataset_size; $i++) $dataset[] = 0;
152
+        for ($i = 0; $i <= $dataset_size; $i++) $dataset[] = 0;
153 153
     }
154 154
     
155 155
     $MyData->addPoints($dataset, 'series1');
@@ -168,39 +168,39 @@  discard block
 block discarded – undo
168 168
     // Define the chart area
169 169
     $myPicture->setGraphArea(0, 3, $chart_width, $chart_height);
170 170
     if ($backdrop_color) {
171
-      $myPicture->drawFilledRectangle(0, 0, $chart_width, $chart_height, $backdrop_color);
171
+        $myPicture->drawFilledRectangle(0, 0, $chart_width, $chart_height, $backdrop_color);
172 172
     }
173 173
     
174 174
     // Draw the scale
175 175
     $scaleSettings = array(
176
-      'Mode' => SCALE_MODE_START0,
177
-      'DrawYLines' => false,
178
-      'DrawXLines' => $draw_x_lines,
179
-      'GridTicks' => 2,
180
-      'LabelSkip' => 9,
181
-      'SkippedAxisAlpha' => 0,
182
-      'SkippedInnerTickWidth' => 0,
183
-      'SkippedOuterTickWidth' => 0,
184
-      'AxisAlpha' => 0,
185
-      'InnerTickWidth' => 0,
186
-      'OuterTickWidth' => 0,
187
-      'XMargin' => 1,
188
-      'YMargin' => 0,
189
-      'Floating' => TRUE,
190
-      'GridR' => 200,
191
-      'GridG' => 200,
192
-      'GridB' => 200,
193
-      'DrawSubTicks' => false,
194
-      'CycleBackground' => false
176
+        'Mode' => SCALE_MODE_START0,
177
+        'DrawYLines' => false,
178
+        'DrawXLines' => $draw_x_lines,
179
+        'GridTicks' => 2,
180
+        'LabelSkip' => 9,
181
+        'SkippedAxisAlpha' => 0,
182
+        'SkippedInnerTickWidth' => 0,
183
+        'SkippedOuterTickWidth' => 0,
184
+        'AxisAlpha' => 0,
185
+        'InnerTickWidth' => 0,
186
+        'OuterTickWidth' => 0,
187
+        'XMargin' => 1,
188
+        'YMargin' => 0,
189
+        'Floating' => TRUE,
190
+        'GridR' => 200,
191
+        'GridG' => 200,
192
+        'GridB' => 200,
193
+        'DrawSubTicks' => false,
194
+        'CycleBackground' => false
195 195
     );
196 196
     $myPicture->setFontProperties(array('FontSize' => 10));
197 197
     $myPicture->drawScale($scaleSettings);
198 198
     
199 199
     if ($label_x_axis) {
200
-      for ($i = 5; $i >= 0; $i--) {
200
+        for ($i = 5; $i >= 0; $i--) {
201 201
         $label = ($i) ? -10*$i : 'Today';
202 202
         $myPicture->drawText(589-587*($i/6)-5, 2, $label, array('Align' => TEXT_ALIGN_TOPRIGHT));
203
-      }
203
+        }
204 204
     }
205 205
 
206 206
     // Draw the area chart
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     // Render the picture (choose the best way)
213 213
     //$myPicture->autoOutput('pictures/example.drawAreaChart.simple.png');
214 214
     $myPicture->stroke();
215
-  }
215
+    }
216 216
 }
217 217
 
218 218
 /**
@@ -220,53 +220,53 @@  discard block
 block discarded – undo
220 220
  * Called to generate the daily credit status chart for the whole project
221 221
  */
222 222
 function boincstats_get_project_stats_chart() {
223
-  // pChart library inclusions
224
-  module_load_include('php', 'boincstats', 'includes/pchart/class/pData.class');
225
-  module_load_include('php', 'boincstats', 'includes/pchart/class/pDraw.class');
226
-  module_load_include('php', 'boincstats', 'includes/pchart/class/pImage.class');
227
-  module_load_include('php', 'boincstats', 'includes/pchart/class/pCache.class');
223
+    // pChart library inclusions
224
+    module_load_include('php', 'boincstats', 'includes/pchart/class/pData.class');
225
+    module_load_include('php', 'boincstats', 'includes/pchart/class/pDraw.class');
226
+    module_load_include('php', 'boincstats', 'includes/pchart/class/pImage.class');
227
+    module_load_include('php', 'boincstats', 'includes/pchart/class/pCache.class');
228 228
   
229
-  init_theme();
230
-  global $theme_key;
231
-  $cache_name = "{$theme_key}_project_chart";
229
+    init_theme();
230
+    global $theme_key;
231
+    $cache_name = "{$theme_key}_project_chart";
232 232
   
233
-  $stats_xml = boincstats_get_project_stats();
234
-  $color_keys = array('R', 'G', 'B');
233
+    $stats_xml = boincstats_get_project_stats();
234
+    $color_keys = array('R', 'G', 'B');
235 235
   
236
-  // Get color configuration
237
-  $palette_color_hex = theme_get_setting('boinc_stats_chart_color');
238
-  $palette_color = array_combine($color_keys, sscanf($palette_color_hex, "#%02x%02x%02x"));
239
-  $backdrop_color_hex = theme_get_setting('boinc_stats_chart_bcolor');
240
-  $backdrop_color = array_combine($color_keys, sscanf($backdrop_color_hex, "#%02x%02x%02x"));
236
+    // Get color configuration
237
+    $palette_color_hex = theme_get_setting('boinc_stats_chart_color');
238
+    $palette_color = array_combine($color_keys, sscanf($palette_color_hex, "#%02x%02x%02x"));
239
+    $backdrop_color_hex = theme_get_setting('boinc_stats_chart_bcolor');
240
+    $backdrop_color = array_combine($color_keys, sscanf($backdrop_color_hex, "#%02x%02x%02x"));
241 241
    
242
-  // Create and populate the pData object
243
-  $MyData = new pData();
242
+    // Create and populate the pData object
243
+    $MyData = new pData();
244 244
   
245
-  // Sanity check for cache directory
246
-  if (!boincstats_check_cache_dir()) {
245
+    // Sanity check for cache directory
246
+    if (!boincstats_check_cache_dir()) {
247 247
     return;
248
-  }
248
+    }
249 249
   
250
-  // Initialize the cache object and flush stale images
251
-  $myCache = new pCache(array('CacheFolder' => realpath('.') . '/' . conf_path(). '/files/cache'));
252
-  $myCache->removeOlderThan(60*60*24);
250
+    // Initialize the cache object and flush stale images
251
+    $myCache = new pCache(array('CacheFolder' => realpath('.') . '/' . conf_path(). '/files/cache'));
252
+    $myCache->removeOlderThan(60*60*24);
253 253
   
254
-  if ($myCache->isInCache($cache_name)) {
254
+    if ($myCache->isInCache($cache_name)) {
255 255
     $myCache->strokeFromCache($cache_name);
256
-  }
257
-  else {
256
+    }
257
+    else {
258 258
     // Initialize dataset
259 259
     $dataset = array();
260 260
     if ($stats_xml) {
261
-      $credit = null;
262
-      for ($i = 0, $j = 31; $j <= 91; $i++, $j++) {
261
+        $credit = null;
262
+        for ($i = 0, $j = 31; $j <= 91; $i++, $j++) {
263 263
         $day = "day_{$j}";
264 264
         $credit[$i] = isset($stats_xml->$day) ? (int) $stats_xml->$day : 0;
265 265
         $dataset[$i] = ($i) ? ($credit[$i] - $credit[$i-1]) : 0;
266
-      }
266
+        }
267 267
     }
268 268
     else {
269
-      for ($i = 0; $i <= 30; $i++) $dataset[] = 0;
269
+        for ($i = 0; $i <= 30; $i++) $dataset[] = 0;
270 270
     }
271 271
     
272 272
     $MyData->addPoints($dataset, 'series1');
@@ -288,25 +288,25 @@  discard block
 block discarded – undo
288 288
 
289 289
     // Draw the scale
290 290
     $scaleSettings = array(
291
-      'Mode' => SCALE_MODE_START0,
292
-      'DrawYLines' => false,
293
-      'DrawXLines' => false,
294
-      'GridTicks' => 2,
295
-      'LabelSkip' => 9,
296
-      'SkippedAxisAlpha' => 0,
297
-      'SkippedInnerTickWidth' => 0,
298
-      'SkippedOuterTickWidth' => 0,
299
-      'AxisAlpha' => 0,
300
-      'InnerTickWidth' => 0,
301
-      'OuterTickWidth' => 0,
302
-      'XMargin' => 1,
303
-      'YMargin' => 0,
304
-      'Floating' => TRUE,
305
-      'GridR' => 200,
306
-      'GridG' => 200,
307
-      'GridB' => 200,
308
-      'DrawSubTicks' => false,
309
-      'CycleBackground' => false
291
+        'Mode' => SCALE_MODE_START0,
292
+        'DrawYLines' => false,
293
+        'DrawXLines' => false,
294
+        'GridTicks' => 2,
295
+        'LabelSkip' => 9,
296
+        'SkippedAxisAlpha' => 0,
297
+        'SkippedInnerTickWidth' => 0,
298
+        'SkippedOuterTickWidth' => 0,
299
+        'AxisAlpha' => 0,
300
+        'InnerTickWidth' => 0,
301
+        'OuterTickWidth' => 0,
302
+        'XMargin' => 1,
303
+        'YMargin' => 0,
304
+        'Floating' => TRUE,
305
+        'GridR' => 200,
306
+        'GridG' => 200,
307
+        'GridB' => 200,
308
+        'DrawSubTicks' => false,
309
+        'CycleBackground' => false
310 310
     );
311 311
     $myPicture->setFontProperties(array('FontSize' => 10));
312 312
     $myPicture->drawScale($scaleSettings);
@@ -325,41 +325,41 @@  discard block
 block discarded – undo
325 325
     // Render the picture (choose the best way)
326 326
     //$myPicture->autoOutput('pictures/example.drawAreaChart.simple.png');
327 327
     $myPicture->stroke();
328
-  }
328
+    }
329 329
 }
330 330
 
331 331
 /*
332 332
  *
333 333
  */
334 334
 function boincstats_check_cache_dir($cache_path = 'files/cache') {
335
-  $cache_dir = realpath('.') . '/' . conf_path() . '/' . $cache_path;
336
-  if (!is_writeable($cache_dir)) {
335
+    $cache_dir = realpath('.') . '/' . conf_path() . '/' . $cache_path;
336
+    if (!is_writeable($cache_dir)) {
337 337
     if (!is_dir($cache_dir)) {
338
-      if (!is_writeable(dirname($cache_dir))) {
338
+        if (!is_writeable(dirname($cache_dir))) {
339 339
         // If the parent "files" dir isn't even writeable...
340 340
         watchdog('boincstats', '@parent_dir directory is not writeable. This
341 341
           directory must be writeable by the web server.',
342
-          array('@parent_dir' => dirname($cache_dir)), WATCHDOG_ERROR);
342
+            array('@parent_dir' => dirname($cache_dir)), WATCHDOG_ERROR);
343 343
         return FALSE;
344
-      }
345
-      else {
344
+        }
345
+        else {
346 346
         // Create the cache dir
347 347
         if (!mkdir($cache_dir, 0775)) {
348
-          watchdog('boincstats', 'Failed to create @cache_dir directory. Check
348
+            watchdog('boincstats', 'Failed to create @cache_dir directory. Check
349 349
             filesystem permissions...?',
350 350
             array('@cache_dir' => $cache_dir), WATCHDOG_ERROR);
351
-          return FALSE;
351
+            return FALSE;
352
+        }
352 353
         }
353
-      }
354 354
     }
355 355
     else {
356
-      watchdog('boincstats', 'Cache directory at @cache_dir is not writeable.
356
+        watchdog('boincstats', 'Cache directory at @cache_dir is not writeable.
357 357
         Please allow webserver write access.',
358 358
         array('@cache_dir' => $cache_dir), WATCHDOG_ERROR);
359
-      return FALSE;
359
+        return FALSE;
360 360
     }
361
-  }
362
-  return TRUE;
361
+    }
362
+    return TRUE;
363 363
 }
364 364
 
365 365
 /*
@@ -367,76 +367,76 @@  discard block
 block discarded – undo
367 367
  */
368 368
 function boincstats_get_project_stats() {
369 369
   
370
-  // Determine the stats environment
371
-  boincstats_check_configuration();
372
-  $stats_server = variable_get('boinc_stats_server', '');
373
-  $stats_rpc = variable_get('boinc_stats_project_credit_history_rpc', '');
374
-  $project_id = variable_get('boinc_stats_remote_project_id', '');
370
+    // Determine the stats environment
371
+    boincstats_check_configuration();
372
+    $stats_server = variable_get('boinc_stats_server', '');
373
+    $stats_rpc = variable_get('boinc_stats_project_credit_history_rpc', '');
374
+    $project_id = variable_get('boinc_stats_remote_project_id', '');
375 375
   
376
-  // Construct query string
377
-  $get = array(
376
+    // Construct query string
377
+    $get = array(
378 378
     'projectid' => $project_id
379
-  );
380
-  $args = array();
381
-  foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value);
382
-  $query = '?' . implode('&', $args);
379
+    );
380
+    $args = array();
381
+    foreach ($get as $arg => $value) $args[] = "{$arg}=" . rawurlencode($value);
382
+    $query = '?' . implode('&', $args);
383 383
   
384
-  // Load XML from RPC
385
-  $stats_xml = NULL;
386
-  $target_url = "http://{$stats_server}/{$stats_rpc}{$query}";
387
-  $result = drupal_http_request($target_url);
388
-  if (in_array($result->code, array(200, 304))) {
384
+    // Load XML from RPC
385
+    $stats_xml = NULL;
386
+    $target_url = "http://{$stats_server}/{$stats_rpc}{$query}";
387
+    $result = drupal_http_request($target_url);
388
+    if (in_array($result->code, array(200, 304))) {
389 389
     $stats_xml = simplexml_load_string($result->data);
390
-  }
391
-  watchdog('boincstats', $target_url);
392
-  return $stats_xml;
390
+    }
391
+    watchdog('boincstats', $target_url);
392
+    return $stats_xml;
393 393
 }
394 394
 
395 395
 /*
396 396
  *
397 397
  */
398 398
 function boincstats_get_project_total_credit() {
399
-  $stats_xml = boincstats_get_project_stats();
400
-  return isset($stats_xml->day_91) ? (int) $stats_xml->day_91 : 0;
399
+    $stats_xml = boincstats_get_project_stats();
400
+    return isset($stats_xml->day_91) ? (int) $stats_xml->day_91 : 0;
401 401
 }
402 402
 
403 403
 /*
404 404
  *
405 405
  */
406 406
 function boincstats_get_project_avg_credit() {
407
-  $stats_xml = boincstats_get_project_stats();
408
-  $dataset = array();
409
-  if ($stats_xml) {
407
+    $stats_xml = boincstats_get_project_stats();
408
+    $dataset = array();
409
+    if ($stats_xml) {
410 410
     $daily_values = null;
411 411
     $dail_totals = null;
412 412
     for ($i = 61; $i <= 91; $i++) {
413
-      $day = "day_{$i}";
414
-      $daily_totals[$i] = isset($stats_xml->$day) ? (int) $stats_xml->$day : 0;
415
-      if ($i == 61) continue;
416
-      $daily_values[$i] = ($i) ? ($daily_totals[$i] - $daily_totals[$i-1]) : 0;
413
+        $day = "day_{$i}";
414
+        $daily_totals[$i] = isset($stats_xml->$day) ? (int) $stats_xml->$day : 0;
415
+        if ($i == 61) continue;
416
+        $daily_values[$i] = ($i) ? ($daily_totals[$i] - $daily_totals[$i-1]) : 0;
417 417
     }
418
-  }
419
-  return (count($daily_values)) ? array_sum($daily_values) / count($daily_values) : 0;
418
+    }
419
+    return (count($daily_values)) ? array_sum($daily_values) / count($daily_values) : 0;
420 420
 }
421 421
 
422 422
 /*
423 423
  *
424 424
  */
425 425
 function boincstats_credit_to_ghours($credit) {
426
-  return $credit / (100 * 365);
426
+    return $credit / (100 * 365);
427 427
 }
428 428
 
429 429
 /*
430 430
  *
431 431
  */
432 432
 function boincstats_credit_to_flops($credit, $prefix = 0) {
433
-  $factor = array(
433
+    $factor = array(
434 434
     '0' => 0,
435 435
     'g' => 3,
436 436
     't' => 6,
437 437
     'p' => 9
438
-  );
439
-  return $credit / (pow(10, (int) $factor[$prefix]) / 10);
438
+    );
439
+    return $credit / (pow(10, (int) $factor[$prefix]) / 10);
440 440
 }
441 441
 
442 442
 
@@ -445,22 +445,22 @@  discard block
 block discarded – undo
445 445
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
446 446
 
447 447
 function boincstats_get_project_stats_overview($type = 'basic') {
448
-  global $base_path;
449
-  $output = '';
450
-  switch ($type) {
451
-  case 'basic':
448
+    global $base_path;
449
+    $output = '';
450
+    switch ($type) {
451
+    case 'basic':
452 452
     $output .= '<div class="overlay"><span>(' . bts('Credits per day') . ')</span></div>' . "\n";
453 453
     $output .= '<div class="chart"><img src="' . $base_path . 'charts/project" /></div>' . "\n";
454 454
     break;
455
-  case 'detailed':
455
+    case 'detailed':
456 456
     $output .= '<div class="stats"><label>' . bts('Total G-hours') . ': </label><span>' . number_format(boincstats_credit_to_ghours(boincstats_get_project_total_credit())) . '</span></div>' . "\n";
457 457
     $output .= '<div class="stats"><label>' . bts('Avg TFlops') . ': </label><span>' . number_format(boincstats_credit_to_flops(boincstats_get_project_avg_credit(), 't')) . '</span></div>' . "\n";
458 458
     //$output .= '<div class="stats"><a href="#">' . bts('Pending credits') . '</a></div>' . "\n";
459 459
     $output .= '<div class="chart"><img src="' . $base_path . 'charts/project" /></div>' . "\n";
460 460
     break;
461
-  default:
461
+    default:
462 462
   }
463
-  return $output;
463
+    return $output;
464 464
 }
465 465
 
466 466
 
@@ -472,19 +472,19 @@  discard block
 block discarded – undo
472 472
  * Check that the stats system is configured, report if it isn't
473 473
  */
474 474
 function boincstats_check_configuration() {
475
-  $project_id = variable_get('boinc_stats_remote_project_id', '');
476
-  if (!$project_id) {
475
+    $project_id = variable_get('boinc_stats_remote_project_id', '');
476
+    if (!$project_id) {
477 477
     watchdog('boincstats', 'The BOINC stats system is not configured. Please
478 478
         !configure_it', array('!configure_it' => l(t('configure it now'),
479
-          'admin/boinc/stats')), WATCHDOG_ERROR);
479
+            'admin/boinc/stats')), WATCHDOG_ERROR);
480 480
     if (user_access('administer site configuration')) {
481
-      drupal_set_message(t('The BOINC stats system is not configured. Please
481
+        drupal_set_message(t('The BOINC stats system is not configured. Please
482 482
         !configure_it', array('!configure_it' => l(t('configure it now'),
483
-          'admin/boinc/stats'))), 'error', FALSE);
483
+            'admin/boinc/stats'))), 'error', FALSE);
484 484
     }
485 485
     else {
486
-      drupal_set_message(t('There is a problem with the site. Please contact
486
+        drupal_set_message(t('There is a problem with the site. Please contact
487 487
         the system administrator.'), 'error', FALSE);
488 488
     }
489
-  }
489
+    }
490 490
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincstats/boincstats.admin.inc 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -8,38 +8,38 @@  discard block
 block discarded – undo
8 8
 
9 9
 
10 10
 /**
11
-  * The BOINC stats configuration determines where statistics are sourced
12
-  */
11
+ * The BOINC stats configuration determines where statistics are sourced
12
+ */
13 13
 function boincstats_admin_stats_system(&$form_state) {
14
-  $form = array();
15
-  $default = array(
14
+    $form = array();
15
+    $default = array(
16 16
     'boinc_stats_server' => variable_get('boinc_stats_server', 'stats.gridrepublic.org'),
17 17
     'boinc_stats_project_list_rpc' => variable_get('boinc_stats_project_list_rpc', 'rpc/get_projects.php'),
18 18
     'boinc_stats_project_credit_history_rpc' => variable_get('boinc_stats_project_credit_history_rpc', 'rpc/get_project_tc_history.php'),
19 19
     'boinc_stats_user_credit_history_rpc' => variable_get('boinc_stats_user_credit_history_rpc', 'rpc/get_user_credit_history_by_project.php'),
20 20
     'boinc_stats_remote_project_id' => variable_get('boinc_stats_remote_project_id', ''),
21
-  );
22
-  // Define the form
23
-  $form['boinc_stats_server'] = array(
21
+    );
22
+    // Define the form
23
+    $form['boinc_stats_server'] = array(
24 24
     '#type' => 'value',
25 25
     '#value' => $default['boinc_stats_server']
26
-  );
27
-  $form['boinc_stats_project_list_rpc'] = array(
26
+    );
27
+    $form['boinc_stats_project_list_rpc'] = array(
28 28
     '#type' => 'value',
29 29
     '#value' => $default['boinc_stats_project_list_rpc']
30
-  );
31
-  $form['boinc_stats_project_credit_history_rpc'] = array(
30
+    );
31
+    $form['boinc_stats_project_credit_history_rpc'] = array(
32 32
     '#type' => 'value',
33 33
     '#value' => $default['boinc_stats_project_credit_history_rpc']
34
-  );
35
-  $form['boinc_stats_user_credit_history_rpc'] = array(
34
+    );
35
+    $form['boinc_stats_user_credit_history_rpc'] = array(
36 36
     '#type' => 'value',
37 37
     '#value' => $default['boinc_stats_user_credit_history_rpc']
38
-  );
39
-  $form['boinc_stats_remote_project_id'] = array(
38
+    );
39
+    $form['boinc_stats_remote_project_id'] = array(
40 40
     '#type' => 'textfield',
41 41
     '#title' => t('Stats ID for @project', array(
42
-      '@project' => variable_get('site_name', t('this project')))),
42
+        '@project' => variable_get('site_name', t('this project')))),
43 43
     '#default_value' => $default['boinc_stats_remote_project_id'], 
44 44
     '#description' => t('This project must be registered with a stats system in
45 45
       order for some statistics to be available. Currently only one system is
@@ -47,26 +47,26 @@  discard block
 block discarded – undo
47 47
         '!find_project_id' => l(t('Find your project ID'),
48 48
         "http://{$default['boinc_stats_server']}/{$default['boinc_stats_project_list_rpc']}",
49 49
         array('attributes' => array('target' => 'external')))
50
-      )
50
+        )
51 51
     )
52
-  );
53
-  return system_settings_form($form);
52
+    );
53
+    return system_settings_form($form);
54 54
 }
55 55
 
56 56
 /**
57
-  * Validate the BOINC stats form.
58
-  */
57
+ * Validate the BOINC stats form.
58
+ */
59 59
 function boincstats_admin_stats_system_validate($form, &$form_state) {
60
-  $values = $form_state['values'];
61
-  if (!$values['boinc_stats_remote_project_id']) {
60
+    $values = $form_state['values'];
61
+    if (!$values['boinc_stats_remote_project_id']) {
62 62
     form_set_error('boinc_stats_remote_project_id',
63
-      t('Stats may not work without a valid stats ID configured!'));
64
-  }
63
+        t('Stats may not work without a valid stats ID configured!'));
64
+    }
65 65
 }
66 66
 
67 67
 /**
68
-  * Handle post-validation submission of BOINC stats form.
69
-  */
68
+ * Handle post-validation submission of BOINC stats form.
69
+ */
70 70
 function boincstats_admin_stats_system_submit($form, &$form_state) {
71
-  drupal_set_message(t('Stats system configuration has been updated.'));
71
+    drupal_set_message(t('Stats system configuration has been updated.'));
72 72
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/includes/boincteam.forms.inc 1 patch
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * The definition of the create team form
15 15
  */
16 16
 function boincteam_create_form(&$form_state) {
17
-  $form = array();
17
+    $form = array();
18 18
   
19
-  $default = array(
19
+    $default = array(
20 20
     'name' => '',
21 21
     'name_html' => '',
22 22
     'website' => '',
@@ -24,105 +24,105 @@  discard block
 block discarded – undo
24 24
     'country' => 0,
25 25
     'joinable' => TRUE,
26 26
     'description' => '',
27
-  );
27
+    );
28 28
   
29
-  // Standard option sets
30
-  $form['boolean_options'] = array(
29
+    // Standard option sets
30
+    $form['boolean_options'] = array(
31 31
     '#type' => 'value',
32 32
     '#value' => array(1 => bts('yes'), 0 => bts('no')),
33
-  );
33
+    );
34 34
   
35
-  // Vocabulary based option sets
36
-  $form['type_options'] = array(
35
+    // Vocabulary based option sets
36
+    $form['type_options'] = array(
37 37
     '#type' => 'value',
38 38
     '#value' => array(0 => bts('Choose type'))
39
-  );
40
-  $vocabs = taxonomy_get_vocabularies(NULL);
41
-  foreach ($vocabs as $vocab) {
39
+    );
40
+    $vocabs = taxonomy_get_vocabularies(NULL);
41
+    foreach ($vocabs as $vocab) {
42 42
     switch ($vocab->name) {
43 43
     case 'Teams':
44 44
       $team_types = taxonomy_get_tree($vocab->vid);
45
-      if (module_exists('internationalization')) {
45
+        if (module_exists('internationalization')) {
46 46
         $team_types = i18ntaxonomy_localize_terms($team_types);
47
-      }
48
-      foreach ($team_types as $team_type) {
47
+        }
48
+        foreach ($team_types as $team_type) {
49 49
         $form['type_options']['#value'][$team_type->tid] = $team_type->name;
50
-      }
51
-      break;
50
+        }
51
+        break;
52 52
     default:
53 53
     }
54
-  }
55
-  $form['country_options'] = array(
54
+    }
55
+    $form['country_options'] = array(
56 56
     '#type' => 'value',
57 57
     '#value' => boinccore_get_country_list(),
58
-  );
58
+    );
59 59
   
60
-  // Form elements
61
-  $form['name'] = array(
60
+    // Form elements
61
+    $form['name'] = array(
62 62
     '#title' => bts('Team name'),
63 63
     '#type' => 'textfield',
64 64
     '#default_value' => $default['name'],
65 65
     '#size' => 34,
66 66
     '#description' => bts('Text only, no HTML tags'),
67
-  );
68
-  $form['name_html'] = array(
67
+    );
68
+    $form['name_html'] = array(
69 69
     '#title' => bts('Team name -- HTML version (optional)'),
70 70
     '#type' => 'textfield',
71 71
     '#default_value' => $default['name_html'],
72 72
     '#size' => 34,
73 73
     '#description' => bts('You may use limited HTML tags'),
74
-  );
75
-  $form['website'] = array(
74
+    );
75
+    $form['website'] = array(
76 76
     '#title' => bts('Team website (optional)'),
77 77
     '#type' => 'textfield',
78 78
     '#default_value' => $default['website'],
79 79
     '#size' => 34,
80 80
     '#description' => bts("Displayed on the team's page"),
81
-  );
82
-  $form['type'] = array(
81
+    );
82
+    $form['type'] = array(
83 83
     '#title' => bts('Type of team'),
84 84
     '#type' => 'select',
85 85
     '#options' => $form['type_options']['#value'],
86 86
     '#default_value' => $default['type'],
87
-  );
88
-  $form['country'] = array(
87
+    );
88
+    $form['country'] = array(
89 89
     '#title' => bts('Country'),
90 90
     '#type' => 'select',
91 91
     '#options' => $form['country_options']['#value'],
92 92
     '#default_value' => $default['country'],
93
-  );
94
-  $form['joinable'] = array(
93
+    );
94
+    $form['joinable'] = array(
95 95
     '#title' => bts('Accept new members?'),
96 96
     '#type' => 'radios',
97 97
     '#options' => $form['boolean_options']['#value'],
98 98
     '#attributes' => array('class' => 'fancy'),
99 99
     '#default_value' => $default['joinable'],
100 100
     '#size' => 34,
101
-  );
102
-  $form['description'] = array(
101
+    );
102
+    $form['description'] = array(
103 103
     '#title' => bts('Description of team'),
104 104
     '#type' => 'textarea',
105 105
     '#default_value' => $default['description'],
106 106
     '#size' => 5,
107 107
     '#description' => NULL,
108
-  );
109
-  $form['format'] = filter_form();
108
+    );
109
+    $form['format'] = filter_form();
110 110
   
111
-  // Form control
112
-  $form['form control tabs prefix'] = array(
111
+    // Form control
112
+    $form['form control tabs prefix'] = array(
113 113
     '#value' => '<ul class="form-control tab-list">'
114
-  );
115
-  $form['submit'] = array(
114
+    );
115
+    $form['submit'] = array(
116 116
     '#prefix' => '<li class="first tab">',
117 117
     '#type' => 'submit',
118 118
     '#value' => bts('Save team'),
119 119
     '#suffix' => '</li>',
120
-  );
121
-  $form['form control tabs'] = array(
120
+    );
121
+    $form['form control tabs'] = array(
122 122
     '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>'
123
-  );
123
+    );
124 124
   
125
-  return $form;
125
+    return $form;
126 126
 }
127 127
 
128 128
 /**
@@ -130,41 +130,41 @@  discard block
 block discarded – undo
130 130
  */
131 131
 function boincteam_create_form_validate($form, &$form_state) {
132 132
 
133
-  $values = $form_state['values'];
134
-  $name = $values['name'];
133
+    $values = $form_state['values'];
134
+    $name = $values['name'];
135 135
   
136
-  if (!$name) {
136
+    if (!$name) {
137 137
     form_set_error('name', bts('Team name is required.'));
138
-  }
139
-  else {
138
+    }
139
+    else {
140 140
     require_boinc('boinc_db');
141 141
     if (BoincTeam::lookup_name($name)) {
142
-      form_set_error('name', bts('A team named "@name" already exists.',
142
+        form_set_error('name', bts('A team named "@name" already exists.',
143 143
         array('@name' => $name)));
144 144
     }
145
-  }
145
+    }
146 146
   
147
-  if (!$values['type'] OR !isset($values['type_options'][$values['type']])) {
147
+    if (!$values['type'] OR !isset($values['type_options'][$values['type']])) {
148 148
     form_set_error('type', bts('Please select a team type.'));
149
-  }
149
+    }
150 150
 }
151 151
 
152 152
 /**
153 153
  * The create team submit handler
154 154
  */
155 155
 function boincteam_create_form_submit($form, &$form_state) {
156
-  global $user;
157
-  $account = user_load($user->uid);
158
-  $values = $form_state['values'];
159
-  //drupal_set_message('<pre>' . print_r($values,true) . '</pre>');
156
+    global $user;
157
+    $account = user_load($user->uid);
158
+    $values = $form_state['values'];
159
+    //drupal_set_message('<pre>' . print_r($values,true) . '</pre>');
160 160
   
161
-  $input_format = !empty($values['format']) ? $values['format'] : 4;
162
-  $values['description'] = check_markup($values['description'], $input_format);
161
+    $input_format = !empty($values['format']) ? $values['format'] : 4;
162
+    $values['description'] = check_markup($values['description'], $input_format);
163 163
   
164
-  // Create the team in the BOINC db
164
+    // Create the team in the BOINC db
165 165
   
166
-  require_boinc(array('user','team'));
167
-  $boinc_team = make_team(
166
+    require_boinc(array('user','team'));
167
+    $boinc_team = make_team(
168 168
     $account->boincuser_id,
169 169
     $values['name'],
170 170
     $values['website'],
@@ -172,27 +172,27 @@  discard block
 block discarded – undo
172 172
     $values['name_html'],
173 173
     $values['description'],
174 174
     $values['country']
175
-  );
175
+    );
176 176
 
177
-  if ($boinc_team) {
177
+    if ($boinc_team) {
178 178
     $boinc_user = BoincUser::lookup_id($account->boincuser_id);
179 179
     user_join_team($boinc_team, $boinc_user);
180
-  }
181
-  else {
180
+    }
181
+    else {
182 182
     drupal_set_message(t('Teams cannot be created at this time. Please 
183 183
       contact the @project administrators!', array('@project' => PROJECT)));
184 184
     watchdog('BOINC team', 'BOINC teams cannot be created for an unknown
185 185
       reason.', 'error');
186 186
     return FALSE;
187
-  }
187
+    }
188 188
   
189
-  // Create the team node in Drupal
189
+    // Create the team node in Drupal
190 190
   
191
-  $teaser = node_teaser($values['description']);
192
-  $created_time = time();
193
-  $input_format = variable_get('filter_default_format', 1);
191
+    $teaser = node_teaser($values['description']);
192
+    $created_time = time();
193
+    $input_format = variable_get('filter_default_format', 1);
194 194
   
195
-  $node = array(
195
+    $node = array(
196 196
     'type' => 'team',
197 197
     'title' => $values['name'],
198 198
     'body' => $values['description'],
@@ -206,21 +206,21 @@  discard block
 block discarded – undo
206 206
     'moderate' => 0,
207 207
     'sticky' => 0,
208 208
     'format' => $input_format
209
-  );
209
+    );
210 210
   
211
-  // Use pathauto function, if available, to clean up the path
212
-  if (module_exists('pathauto')) {
211
+    // Use pathauto function, if available, to clean up the path
212
+    if (module_exists('pathauto')) {
213 213
     module_load_include('inc', 'pathauto', 'pathauto');
214 214
     $node['path'] = pathauto_cleanstring($values['name']);
215
-  }
216
-  else {
215
+    }
216
+    else {
217 217
     drupal_set_message(t('Teams cannot be created at this time. Please 
218 218
       contact the @project administrators!', array('@project' => PROJECT)));
219 219
     watchdog('BOINC team', 'BOINC teams require the Pathauto module. Teams
220 220
       cannot be created.', 'error');
221
-  }
221
+    }
222 222
   
223
-  /*
223
+    /*
224 224
   // Add special organic group properties
225 225
   $node['og_description'] = strip_tags($boincteam->description);
226 226
   $node['og_selective'] = OG_OPEN;
@@ -229,26 +229,26 @@  discard block
 block discarded – undo
229 229
   $node['og_private'] = 0;
230 230
   */
231 231
   
232
-  $node = (object) $node; // node_save requires an object form
232
+    $node = (object) $node; // node_save requires an object form
233 233
   
234
-  /*
234
+    /*
235 235
   $node->field_description[]['value'] = $boincteam->description;
236 236
   $node->field_url[]['value'] = $boincteam->url;
237 237
   $node->field_country[]['value'] = $boincteam->country;
238 238
   */
239 239
   
240
-  $node->taxonomy[] = taxonomy_get_term($values['type']);
240
+    $node->taxonomy[] = taxonomy_get_term($values['type']);
241 241
   
242
-  // Save the team node
243
-  node_save($node);
242
+    // Save the team node
243
+    node_save($node);
244 244
   
245
-  // Save the team IDs to a BOINC <--> Drupal reference table.
246
-  db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boinc_team->id, $node->nid);
245
+    // Save the team IDs to a BOINC <--> Drupal reference table.
246
+    db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boinc_team->id, $node->nid);
247 247
   
248
-  drupal_set_message(t('Team "@name" has been created.', 
248
+    drupal_set_message(t('Team "@name" has been created.', 
249 249
     array('@name' => $values['name'])));
250 250
   
251
-  $form_state['redirect'] = "community/teams/{$node->nid}";
251
+    $form_state['redirect'] = "community/teams/{$node->nid}";
252 252
 }
253 253
 
254 254
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -259,17 +259,17 @@  discard block
 block discarded – undo
259 259
  * The definition of the edit team form
260 260
  */
261 261
 function boincteam_edit_form(&$form_state, $team_id) {
262
-  $form = array();
262
+    $form = array();
263 263
   
264
-  $team = node_load($team_id);
265
-  $boincteam = boincteam_load(boincteam_lookup_id($team_id));
264
+    $team = node_load($team_id);
265
+    $boincteam = boincteam_load(boincteam_lookup_id($team_id));
266 266
   
267
-  $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE;
267
+    $is_boinc_wide = ($boincteam->seti_id > 0) ? TRUE : FALSE;
268 268
   
269
-  $form_state['storage']['team_id'] = $team_id;
270
-  $form_state['storage']['is_boinc_wide'] = $is_boinc_wide;
269
+    $form_state['storage']['team_id'] = $team_id;
270
+    $form_state['storage']['is_boinc_wide'] = $is_boinc_wide;
271 271
   
272
-  $default = array(
272
+    $default = array(
273 273
     'name' => $boincteam->name,
274 274
     'name_html' => $boincteam->name_html,
275 275
     'website' => $boincteam->url,
@@ -277,79 +277,79 @@  discard block
 block discarded – undo
277 277
     'country' => $boincteam->country,
278 278
     'joinable' => $boincteam->joinable,
279 279
     'description' => $boincteam->description,
280
-  );
280
+    );
281 281
   
282
-  // Standard option sets
283
-  $form['boolean_options'] = array(
282
+    // Standard option sets
283
+    $form['boolean_options'] = array(
284 284
     '#type' => 'value',
285 285
     '#value' => array(1 => bts('yes'), 0 => bts('no')),
286
-  );
286
+    );
287 287
   
288
-  // Vocabulary based option sets
289
-  $form['type_options'] = array(
288
+    // Vocabulary based option sets
289
+    $form['type_options'] = array(
290 290
     '#type' => 'value',
291 291
     '#value' => array(0 => bts('Choose type'))
292
-  );
293
-  $vocabs = taxonomy_get_vocabularies(NULL);
294
-  foreach ($vocabs as $vocab) {
292
+    );
293
+    $vocabs = taxonomy_get_vocabularies(NULL);
294
+    foreach ($vocabs as $vocab) {
295 295
     switch ($vocab->name) {
296 296
     case 'Teams':
297 297
       $team_types = taxonomy_get_tree($vocab->vid);
298
-      if (module_exists('internationalization')) {
298
+        if (module_exists('internationalization')) {
299 299
         $team_types = i18ntaxonomy_localize_terms($team_types);
300
-      }
301
-      foreach ($team_types as $team_type) {
300
+        }
301
+        foreach ($team_types as $team_type) {
302 302
         $form['type_options']['#value'][$team_type->tid] = $team_type->name;
303
-      }
304
-      break;
303
+        }
304
+        break;
305 305
     default:
306 306
     }
307
-  }
308
-  $form['country_options'] = array(
307
+    }
308
+    $form['country_options'] = array(
309 309
     '#type' => 'value',
310 310
     '#value' => boinccore_get_country_list(),
311
-  );
311
+    );
312 312
   
313
-  // Form elements
314
-  $form['name'] = array(
313
+    // Form elements
314
+    $form['name'] = array(
315 315
     '#title' => bts('Team name'),
316 316
     '#type' => 'textfield',
317 317
     '#default_value' => $default['name'],
318 318
     '#size' => 34,
319 319
     '#description' => bts('Text only, no HTML tags'),
320 320
     '#disabled' => $is_boinc_wide,
321
-  );
322
-  $form['name_html'] = array(
321
+    );
322
+    $form['name_html'] = array(
323 323
     '#title' => bts('Team name -- HTML version (optional)'),
324 324
     '#type' => 'textfield',
325 325
     '#default_value' => $default['name_html'],
326 326
     '#size' => 34,
327 327
     '#description' => bts('You may use limited HTML tags'),
328 328
     '#disabled' => $is_boinc_wide,
329
-  );
330
-  $form['website'] = array(
329
+    );
330
+    $form['website'] = array(
331 331
     '#title' => bts('Team website (optional)'),
332 332
     '#type' => 'textfield',
333 333
     '#default_value' => $default['website'],
334 334
     '#size' => 34,
335 335
     '#description' => bts("Displayed on the team's page"),
336 336
     '#disabled' => $is_boinc_wide,
337
-  );
338
-  $form['type'] = array(
337
+    );
338
+    $form['type'] = array(
339 339
     '#title' => bts('Type of team'),
340 340
     '#type' => 'select',
341 341
     '#options' => $form['type_options']['#value'],
342 342
     '#default_value' => $default['type'],
343 343
     '#disabled' => $is_boinc_wide,
344
-  );
345
-  $form['country'] = array(
344
+    );
345
+    $form['country'] = array(
346 346
     '#title' => bts('Country'),
347 347
     '#type' => 'select',
348 348
     '#options' => $form['country_options']['#value'],
349 349
     '#default_value' => $default['country'],
350 350
     '#disabled' => $is_boinc_wide,
351
-  );
352
-  $form['joinable'] = array(
351
+    );
352
+    $form['joinable'] = array(
353 353
     '#title' => bts('Accept new members?'),
354 354
     '#type' => 'radios',
355 355
     '#options' => $form['boolean_options']['#value'],
@@ -357,49 +357,49 @@  discard block
 block discarded – undo
357 357
     '#default_value' => $default['joinable'],
358 358
     '#size' => 34,
359 359
     '#disabled' => $is_boinc_wide,
360
-  );
361
-  if (!$is_boinc_wide) {
360
+    );
361
+    if (!$is_boinc_wide) {
362 362
     $form['description'] = array(
363
-      '#title' => bts('Description of team'),
364
-      '#type' => 'textarea',
365
-      '#default_value' => $default['description'],
366
-      '#size' => 5,
367
-      '#description' => NULL,
363
+        '#title' => bts('Description of team'),
364
+        '#type' => 'textarea',
365
+        '#default_value' => $default['description'],
366
+        '#size' => 5,
367
+        '#description' => NULL,
368 368
     );
369 369
     $form['format'] = filter_form();
370 370
     
371 371
     // Form control
372 372
     $form['form control tabs prefix'] = array(
373
-      '#value' => '<ul class="form-control tab-list">'
373
+        '#value' => '<ul class="form-control tab-list">'
374 374
     );
375 375
     $form['submit'] = array(
376
-      '#prefix' => '<li class="first tab">',
377
-      '#type' => 'submit',
378
-      '#value' => bts('Save changes'),
379
-      '#suffix' => '</li>',
376
+        '#prefix' => '<li class="first tab">',
377
+        '#type' => 'submit',
378
+        '#value' => bts('Save changes'),
379
+        '#suffix' => '</li>',
380 380
     );
381 381
     $form['form control tabs'] = array(
382
-      '#value' => '<li class="tab">' . l(bts('Cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>'
382
+        '#value' => '<li class="tab">' . l(bts('Cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>'
383 383
     );
384
-  }
385
-  else {
384
+    }
385
+    else {
386 386
     $form['description'] = array(
387
-      '#prefix' => '<div class="form-item"><label>' . bts('Description') . ':</label></div><div class="form-item">',
388
-      '#value' => $default['description'],
389
-      '#suffix' => '</div>',
387
+        '#prefix' => '<div class="form-item"><label>' . bts('Description') . ':</label></div><div class="form-item">',
388
+        '#value' => $default['description'],
389
+        '#suffix' => '</div>',
390 390
     );
391 391
     drupal_set_message(
392
-      bts('This is a BOINC-wide team. Changes can be made at the !site.',
392
+        bts('This is a BOINC-wide team. Changes can be made at the !site.',
393 393
         array('!site' => l(bts('BOINC-wide teams site'),
394
-          'http://boinc.berkeley.edu/teams/'
394
+            'http://boinc.berkeley.edu/teams/'
395 395
         ))
396
-      ),
397
-      'warning');
398
-  }
396
+        ),
397
+        'warning');
398
+    }
399 399
   
400
-  $form['#redirect'] = "community/teams/{$team_id}";
400
+    $form['#redirect'] = "community/teams/{$team_id}";
401 401
   
402
-  return $form;
402
+    return $form;
403 403
 }
404 404
 
405 405
 /**
@@ -407,32 +407,32 @@  discard block
 block discarded – undo
407 407
  */
408 408
 function boincteam_edit_form_validate($form, &$form_state) {
409 409
 
410
-  $values = $form_state['values'];
411
-  $name = $values['name'];
410
+    $values = $form_state['values'];
411
+    $name = $values['name'];
412 412
   
413
-  if ($form_state['storage']['is_boinc_wide']) {
413
+    if ($form_state['storage']['is_boinc_wide']) {
414 414
     form_set_error('none', bts('This team is managed by the BOINC-wide teams system and cannot be updated here.'));
415
-  }
416
-  else {
415
+    }
416
+    else {
417 417
     if (!$name) {
418
-      form_set_error('name', bts('Team name is required.'));
418
+        form_set_error('name', bts('Team name is required.'));
419 419
     }
420 420
     else {
421
-      $team = node_load($form_state['storage']['team_id']);
422
-      if ($name != $team->title) {
421
+        $team = node_load($form_state['storage']['team_id']);
422
+        if ($name != $team->title) {
423 423
         // If changing the name ("title" in Drupal terms), check that the new name is available
424 424
         require_boinc('boinc_db');
425 425
         if (BoincTeam::lookup_name($name)) {
426
-          form_set_error('name', bts('A team named "@name" already exists.',
426
+            form_set_error('name', bts('A team named "@name" already exists.',
427 427
             array('@name' => $name)));
428 428
         }
429
-      }
429
+        }
430 430
     }
431 431
   
432 432
     if (!$values['type'] OR !isset($values['type_options'][$values['type']])) {
433
-      form_set_error('type', bts('Please select a team type.'));
433
+        form_set_error('type', bts('Please select a team type.'));
434
+    }
434 435
     }
435
-  }
436 436
 }
437 437
 
438 438
 /**
@@ -440,18 +440,18 @@  discard block
 block discarded – undo
440 440
  */
441 441
 function boincteam_edit_form_submit($form, &$form_state) {
442 442
   
443
-  $team_id = $form_state['storage']['team_id'];
444
-  $values = $form_state['values'];
443
+    $team_id = $form_state['storage']['team_id'];
444
+    $values = $form_state['values'];
445 445
   
446
-  $team = node_load($team_id);
447
-  $boincteam_id = boincteam_lookup_id($team_id);
446
+    $team = node_load($team_id);
447
+    $boincteam_id = boincteam_lookup_id($team_id);
448 448
   
449
-  $input_format = !empty($values['format']) ? $values['format'] : 4;
450
-  $values['description'] = check_markup($values['description'], $input_format);
449
+    $input_format = !empty($values['format']) ? $values['format'] : 4;
450
+    $values['description'] = check_markup($values['description'], $input_format);
451 451
   
452
-  // Update the team in the BOINC db
453
-  db_set_active('boinc');
454
-  db_query("
452
+    // Update the team in the BOINC db
453
+    db_set_active('boinc');
454
+    db_query("
455 455
     UPDATE {team} SET
456 456
       name = '%s',
457 457
       name_lc = '%s',
@@ -471,32 +471,32 @@  discard block
 block discarded – undo
471 471
     $values['country'],
472 472
     $values['joinable'],
473 473
     $boincteam_id
474
-  );
475
-  db_set_active('default');
474
+    );
475
+    db_set_active('default');
476 476
   
477
-  // Update the team node in Drupal
477
+    // Update the team node in Drupal
478 478
   
479
-  $team->title = $values['name'];
480
-  $team->body = $values['description'];
481
-  $team->teaser = node_teaser($values['description']);
479
+    $team->title = $values['name'];
480
+    $team->body = $values['description'];
481
+    $team->teaser = node_teaser($values['description']);
482 482
   
483
-  /*
483
+    /*
484 484
   $node->field_description[]['value'] = $boincteam->description;
485 485
   $node->field_url[]['value'] = $boincteam->url;
486 486
   $node->field_country[]['value'] = $boincteam->country;
487 487
   */
488 488
   
489
-  // Replace any existing taxonomy with the new one
490
-  $team->taxonomy = array(taxonomy_get_term($values['type']));
489
+    // Replace any existing taxonomy with the new one
490
+    $team->taxonomy = array(taxonomy_get_term($values['type']));
491 491
   
492
-  // Save the team node
493
-  node_save($team);
492
+    // Save the team node
493
+    node_save($team);
494 494
   
495
-  drupal_set_message(t('Details for "@team" have been updated.', 
495
+    drupal_set_message(t('Details for "@team" have been updated.', 
496 496
     array('@team' => $values['name'])));
497 497
     
498
-  // The storage variable quietly kills redirection for some reason... unset it
499
-  unset($form_state['storage']);
498
+    // The storage variable quietly kills redirection for some reason... unset it
499
+    unset($form_state['storage']);
500 500
 }
501 501
 
502 502
 
@@ -508,42 +508,42 @@  discard block
 block discarded – undo
508 508
  * The definition of the add team admin form
509 509
  */
510 510
 function boincteam_add_admin_form(&$form_state, $team_id) {
511
-  $form = array();
511
+    $form = array();
512 512
   
513
-  $team = node_load($team_id);
514
-  $boincteam = boincteam_load(boincteam_lookup_id($team_id));
513
+    $team = node_load($team_id);
514
+    $boincteam = boincteam_load(boincteam_lookup_id($team_id));
515 515
   
516
-  $form_state['storage']['team_id'] = $team_id;
516
+    $form_state['storage']['team_id'] = $team_id;
517 517
   
518
-  $default = array(
518
+    $default = array(
519 519
     'email' => '',
520
-  );
520
+    );
521 521
   
522
-  // Form elements
523
-  $form['email'] = array(
522
+    // Form elements
523
+    $form['email'] = array(
524 524
     '#title' => bts('Enter email address'),
525 525
     '#type' => 'textfield',
526 526
     '#default_value' => $default['email'],
527 527
     '#size' => 34,
528
-  );
528
+    );
529 529
   
530
-  // Form control
531
-  $form['form control tabs prefix'] = array(
530
+    // Form control
531
+    $form['form control tabs prefix'] = array(
532 532
     '#value' => '<ul class="form-control tab-list">'
533
-  );
534
-  $form['submit'] = array(
533
+    );
534
+    $form['submit'] = array(
535 535
     '#prefix' => '<li class="first tab">',
536 536
     '#type' => 'submit',
537 537
     '#value' => bts('Add'),
538 538
     '#suffix' => '</li>',
539
-  );
540
-  $form['form control tabs'] = array(
539
+    );
540
+    $form['form control tabs'] = array(
541 541
     '#value' => '<li class="tab">' . l(bts('Cancel'), strstr($_GET['q'], '/edit', TRUE)) . '</li>'
542
-  );
542
+    );
543 543
   
544
-  //$form['#redirect'] = "community/teams/{$team_id}";
544
+    //$form['#redirect'] = "community/teams/{$team_id}";
545 545
   
546
-  return $form;
546
+    return $form;
547 547
 }
548 548
 
549 549
 /**
@@ -551,40 +551,40 @@  discard block
 block discarded – undo
551 551
  */
552 552
 function boincteam_add_admin_form_validate($form, &$form_state) {
553 553
 
554
-  $team_id = $form_state['storage']['team_id'];
555
-  $values = $form_state['values'];
554
+    $team_id = $form_state['storage']['team_id'];
555
+    $values = $form_state['values'];
556 556
   
557
-  $team = node_load($team_id);
557
+    $team = node_load($team_id);
558 558
   
559
-  if (!$values['email']) {
559
+    if (!$values['email']) {
560 560
     form_set_error('email', bts('Email address is required.'));
561
-  }
562
-  else {
561
+    }
562
+    else {
563 563
     $account = user_load(array('mail' => $values['email']));
564 564
     if ((!$account) OR ($account->team != $team_id)) {
565
-      form_set_error('email', bts('There is no user on your team with that email address.'));
565
+        form_set_error('email', bts('There is no user on your team with that email address.'));
566 566
     }
567 567
     elseif (boincteam_is_founder($team_id, $account->uid)) {
568
-      form_set_error('email', bts('@user is the founder of @team!',
568
+        form_set_error('email', bts('@user is the founder of @team!',
569 569
         array(
570
-          '@user' => $account->boincuser_name,
571
-          '@team' => $team->title,
570
+            '@user' => $account->boincuser_name,
571
+            '@team' => $team->title,
572 572
         )
573
-      ));
573
+        ));
574 574
     }
575 575
     elseif (boincteam_is_admin($team_id, $account->uid)) {
576
-      form_set_error('email', bts('@user is already an admin of @team.',
576
+        form_set_error('email', bts('@user is already an admin of @team.',
577 577
         array(
578
-          '@user' => $account->boincuser_name,
579
-          '@team' => $team->title,
578
+            '@user' => $account->boincuser_name,
579
+            '@team' => $team->title,
580 580
         )
581
-      ));
581
+        ));
582 582
     }
583 583
     else {
584
-      $form_state['storage']['boincuser_id'] = $account->boincuser_id;
585
-      $form_state['storage']['boincuser_name'] = $account->boincuser_name;
584
+        $form_state['storage']['boincuser_id'] = $account->boincuser_id;
585
+        $form_state['storage']['boincuser_name'] = $account->boincuser_name;
586
+    }
586 587
     }
587
-  }
588 588
 }
589 589
 
590 590
 /**
@@ -592,17 +592,17 @@  discard block
 block discarded – undo
592 592
  */
593 593
 function boincteam_add_admin_form_submit($form, &$form_state) {
594 594
   
595
-  $team_id = $form_state['storage']['team_id'];
596
-  $boincuser_id = $form_state['storage']['boincuser_id'];
597
-  $user_name = $form_state['storage']['boincuser_name'];
598
-  $values = $form_state['values'];
595
+    $team_id = $form_state['storage']['team_id'];
596
+    $boincuser_id = $form_state['storage']['boincuser_id'];
597
+    $user_name = $form_state['storage']['boincuser_name'];
598
+    $values = $form_state['values'];
599 599
   
600
-  $team = node_load($team_id);
601
-  $boincteam_id = boincteam_lookup_id($team_id);
600
+    $team = node_load($team_id);
601
+    $boincteam_id = boincteam_lookup_id($team_id);
602 602
   
603
-  // Update the team in the BOINC db
604
-  db_set_active('boinc');
605
-  db_query("
603
+    // Update the team in the BOINC db
604
+    db_set_active('boinc');
605
+    db_query("
606 606
     INSERT INTO {team_admin} SET
607 607
       teamid = '%d',
608 608
       userid = '%d',
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
     $boincteam_id,
611 611
     $boincuser_id,
612 612
     time()
613
-  );
614
-  db_set_active('default');
613
+    );
614
+    db_set_active('default');
615 615
   
616
-  // Could assign a role in Drupal here, as needed
616
+    // Could assign a role in Drupal here, as needed
617 617
   
618 618
   
619
-  drupal_set_message(t('@user has been added as an admin.', 
619
+    drupal_set_message(t('@user has been added as an admin.', 
620 620
     array('@user' => $user_name)));
621 621
     
622
-  // The storage variable quietly kills redirection for some reason... unset it
623
-  unset($form_state['storage']);
622
+    // The storage variable quietly kills redirection for some reason... unset it
623
+    unset($form_state['storage']);
624 624
 }
Please login to merge, or discard this patch.
boinc/modules/boincteam/includes/views_handler_argument_boincteam_id.inc 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
  */
8 8
 
9 9
 class views_handler_argument_boincteam_id extends views_handler_argument_numeric {
10
-  function construct() {
10
+    function construct() {
11 11
     parent::construct();
12
-  }
12
+    }
13 13
 
14
-  function set_argument($arg) {
14
+    function set_argument($arg) {
15 15
     // When setting the ID argument, convert to BOINC ID
16 16
     $id = is_numeric($arg) ? $arg : 0;
17 17
     $boinc_id = db_result(db_query("SELECT team_id FROM {boincteam} WHERE nid = %d", $id));
18 18
     $this->argument = $boinc_id;
19 19
     return $this->validate_arg($boinc_id);
20
-  }
20
+    }
21 21
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/includes/boincteam.helpers.inc 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,41 +15,41 @@  discard block
 block discarded – undo
15 15
  */
16 16
 function boincteam_sync() {
17 17
   
18
-  // Get the list of teams to import
19
-  db_set_active('boinc');
20
-  $boinc_teams = db_query('
18
+    // Get the list of teams to import
19
+    db_set_active('boinc');
20
+    $boinc_teams = db_query('
21 21
     SELECT id, name, description, userid, create_time, seti_id
22 22
     FROM team
23 23
     WHERE mod_time > FROM_UNIXTIME(%d)',
24 24
     variable_get('boincteam_last_sync', 0)
25
-  );
26
-  db_set_active('default');
25
+    );
26
+    db_set_active('default');
27 27
   
28
-  $existing_teams = array();
28
+    $existing_teams = array();
29 29
   
30
-  // Get the list of teams already in Drupal to be sure we're not importing
31
-  // any twice
32
-  $result = db_query('
30
+    // Get the list of teams already in Drupal to be sure we're not importing
31
+    // any twice
32
+    $result = db_query('
33 33
     SELECT nid, team_id FROM {boincteam}'
34
-  );
35
-  while ($row = db_fetch_object($result)) {
34
+    );
35
+    while ($row = db_fetch_object($result)) {
36 36
     $existing_teams[$row->team_id] = $row->nid;
37
-  }
37
+    }
38 38
   
39
-  while ($boinc_team = db_fetch_object($boinc_teams)) {
39
+    while ($boinc_team = db_fetch_object($boinc_teams)) {
40 40
     $success = NULL;
41 41
     if (isset($existing_teams[$boinc_team->id])) {
42
-      if ($boinc_team->seti_id > 0) {
42
+        if ($boinc_team->seti_id > 0) {
43 43
         // Sync BOINC-wide teams
44 44
         $nid = $existing_teams[$boinc_team->id];
45 45
         $success = boincteam_import($boinc_team, $nid);
46
-      }
46
+        }
47 47
     }
48 48
     else {
49
-      // Import new teams created by RPC or ops/team_import.php
50
-      $success = boincteam_import($boinc_team);
49
+        // Import new teams created by RPC or ops/team_import.php
50
+        $success = boincteam_import($boinc_team);
51
+    }
51 52
     }
52
-  }
53 53
 }
54 54
 
55 55
 
@@ -58,56 +58,56 @@  discard block
 block discarded – undo
58 58
  */
59 59
 function boincteam_import($boincteam, $nid = NULL) {
60 60
   
61
-  $input_format = variable_get('boincimport_input_format', 0);
62
-  $team_type_map = variable_get('boincimport_team_types', array()); 
61
+    $input_format = variable_get('boincimport_input_format', 0);
62
+    $team_type_map = variable_get('boincimport_team_types', array()); 
63 63
   
64
-  // Save the team type affiliation
65
-  $team_type_tid = $team_type_map[$boincteam->type];
64
+    // Save the team type affiliation
65
+    $team_type_tid = $team_type_map[$boincteam->type];
66 66
   
67
-  $boincteam->description = html_entity_decode($boincteam->description, ENT_QUOTES, 'utf-8');
68
-  // Be sure the text is filtered for the default input format
69
-  $boincteam->description = check_markup($boincteam->description, $input_format);
67
+    $boincteam->description = html_entity_decode($boincteam->description, ENT_QUOTES, 'utf-8');
68
+    // Be sure the text is filtered for the default input format
69
+    $boincteam->description = check_markup($boincteam->description, $input_format);
70 70
   
71
-  $teaser = node_teaser($boincteam->description);
71
+    $teaser = node_teaser($boincteam->description);
72 72
   
73
-  if ($nid) {
73
+    if ($nid) {
74 74
     // Update an existing node
75 75
     $node = node_load($nid);
76 76
     $node->title = $boincteam->name;
77 77
     $node->body = $boincteam->description;
78 78
     $node->teaser = $teaser;
79 79
     $node->uid = boincuser_lookup_uid($boincteam->userid);
80
-  }
81
-  else {
80
+    }
81
+    else {
82 82
     // Construct the team as a new node
83 83
     $node = array(
84
-      'type' => 'team',
85
-      'title' => $boincteam->name,
86
-      'body' => $boincteam->description,
87
-      'teaser' => $teaser,
88
-      'uid' => boincuser_lookup_uid($boincteam->userid),
89
-      'path' => null,
90
-      'status' => 1,  // published or not - always publish
91
-      'promote' => 0,
92
-      'created' => $boincteam->create_time,
93
-      'comment' => 0,  // comments disabled
94
-      'moderate' => 0,
95
-      'sticky' => 0,
96
-      'format' => $input_format
84
+        'type' => 'team',
85
+        'title' => $boincteam->name,
86
+        'body' => $boincteam->description,
87
+        'teaser' => $teaser,
88
+        'uid' => boincuser_lookup_uid($boincteam->userid),
89
+        'path' => null,
90
+        'status' => 1,  // published or not - always publish
91
+        'promote' => 0,
92
+        'created' => $boincteam->create_time,
93
+        'comment' => 0,  // comments disabled
94
+        'moderate' => 0,
95
+        'sticky' => 0,
96
+        'format' => $input_format
97 97
     );
98 98
     $node = (object) $node; // node_save requires an object form
99
-  }
99
+    }
100 100
   
101
-  $node->taxonomy[] = taxonomy_get_term($team_type_tid);
101
+    $node->taxonomy[] = taxonomy_get_term($team_type_tid);
102 102
   
103
-  // Save the team node
104
-  node_save($node);
105
-  $success = ($node->nid) ? TRUE : FALSE;
103
+    // Save the team node
104
+    node_save($node);
105
+    $success = ($node->nid) ? TRUE : FALSE;
106 106
   
107
-  if (!$nid) {
107
+    if (!$nid) {
108 108
     // Save the team IDs to a BOINC <--> Drupal reference table, if needed
109 109
     db_query('INSERT INTO {boincteam} (team_id, nid) VALUES (%d, %d)', $boincteam->id, $node->nid);
110
-  }
110
+    }
111 111
   
112
-  return $success;
112
+    return $success;
113 113
 }
Please login to merge, or discard this patch.
sites/default/boinc/modules/boincteam/includes/boincteam_forum.forms.inc 1 patch
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -14,84 +14,84 @@  discard block
 block discarded – undo
14 14
  * The definition of the create team form
15 15
  */
16 16
 function boincteam_forum_create_form(&$form_state) {
17
-  $form = array();
17
+    $form = array();
18 18
   
19
-  global $user;
20
-  $account = user_load($user->uid);
19
+    global $user;
20
+    $account = user_load($user->uid);
21 21
   
22
-  $default = array(
22
+    $default = array(
23 23
     'title' => '',
24 24
     'min_time_between_posts' => '',
25 25
     'min_total_credit_to_post' => '',
26 26
     'min_avg_credit_to_post' => '',
27 27
     'public' => 0,
28 28
     'description' => '',
29
-  );
29
+    );
30 30
   
31
-  // Standard option sets
32
-  $form['boolean_options'] = array(
31
+    // Standard option sets
32
+    $form['boolean_options'] = array(
33 33
     '#type' => 'value',
34 34
     '#value' => array(1 => bts('yes'), 0 => bts('no')),
35
-  );
35
+    );
36 36
   
37
-  // Form elements
38
-  $form['title'] = array(
37
+    // Form elements
38
+    $form['title'] = array(
39 39
     '#title' => bts('Message board title'),
40 40
     '#type' => 'textfield',
41 41
     '#default_value' => $default['title'],
42 42
     '#size' => 34,
43 43
     '#description' => bts('Text only, no HTML tags'),
44
-  );
45
-  $form['min_time_between_posts'] = array(
44
+    );
45
+    $form['min_time_between_posts'] = array(
46 46
     '#title' => bts('Minimum time between posts'),
47 47
     '#type' => 'textfield',
48 48
     '#default_value' => $default['min_time_between_posts'],
49 49
     '#size' => 12,
50 50
     '#description' => bts('Seconds'),
51
-  );
52
-  $form['min_total_credit_to_post'] = array(
51
+    );
52
+    $form['min_total_credit_to_post'] = array(
53 53
     '#title' => bts('Minimum total credit to post'),
54 54
     '#type' => 'textfield',
55 55
     '#default_value' => $default['min_total_credit_to_post'],
56 56
     '#size' => 12,
57
-  );
58
-  $form['min_avg_credit_to_post'] = array(
57
+    );
58
+    $form['min_avg_credit_to_post'] = array(
59 59
     '#title' => bts('Minimum avg credit to post'),
60 60
     '#type' => 'textfield',
61 61
     '#default_value' => $default['min_avg_credit_to_post'],
62 62
     '#size' => 12,
63
-  );
64
-  $form['public'] = array(
63
+    );
64
+    $form['public'] = array(
65 65
     '#title' => bts('Allow public to read board?'),
66 66
     '#type' => 'radios',
67 67
     '#options' => $form['boolean_options']['#value'],
68 68
     '#attributes' => array('class' => 'fancy'),
69 69
     '#default_value' => $default['public'],
70
-  );
71
-  $form['description'] = array(
70
+    );
71
+    $form['description'] = array(
72 72
     '#title' => bts('Description'),
73 73
     '#type' => 'textarea',
74 74
     '#default_value' => $default['description'],
75 75
     '#size' => 5,
76
-  );
76
+    );
77 77
   
78
-  // Form control
79
-  $form['form control tabs prefix'] = array(
78
+    // Form control
79
+    $form['form control tabs prefix'] = array(
80 80
     '#value' => '<ul class="form-control tab-list">'
81
-  );
82
-  $form['submit'] = array(
81
+    );
82
+    $form['submit'] = array(
83 83
     '#prefix' => '<li class="first tab">',
84 84
     '#type' => 'submit',
85 85
     '#value' => bts('Create message board'),
86 86
     '#suffix' => '</li>',
87
-  );
88
-  $form['form control tabs'] = array(
87
+    );
88
+    $form['form control tabs'] = array(
89 89
     '#value' => '<li class="tab">' . l(bts('Cancel'), strstr($_GET['q'], '/forum/add', TRUE)) . '</li>'
90
-  );
90
+    );
91 91
   
92
-  $form['#redirect'] = "community/teams/{$account->team}";
92
+    $form['#redirect'] = "community/teams/{$account->team}";
93 93
   
94
-  return $form;
94
+    return $form;
95 95
 }
96 96
 
97 97
 /**
@@ -99,33 +99,33 @@  discard block
 block discarded – undo
99 99
  */
100 100
 function boincteam_forum_create_form_validate($form, &$form_state) {
101 101
 
102
-  $values = $form_state['values'];
102
+    $values = $form_state['values'];
103 103
   
104
-  if (!$values['title']) {
104
+    if (!$values['title']) {
105 105
     form_set_error('name', bts('Message board title is required.'));
106
-  }
107
-  if (!is_numeric($values['min_time_between_posts']) OR
106
+    }
107
+    if (!is_numeric($values['min_time_between_posts']) OR
108 108
       $values['min_time_between_posts'] < 0) {
109 109
     form_set_error('min_time_between_posts',
110
-      bts('Please set the minimum time required between posts.')
110
+        bts('Please set the minimum time required between posts.')
111 111
     );
112
-  }
113
-  if (!is_numeric($values['min_total_credit_to_post']) OR
112
+    }
113
+    if (!is_numeric($values['min_total_credit_to_post']) OR
114 114
       $values['min_total_credit_to_post'] < 0) {
115 115
     form_set_error('min_total_credit_to_post',
116
-      bts('Please set the minimum total credit that a user'
116
+        bts('Please set the minimum total credit that a user'
117 117
         . ' must earn in order to post to this message board.'
118
-      )
118
+        )
119 119
     );
120
-  }
121
-  if (!is_numeric($values['min_avg_credit_to_post']) OR
120
+    }
121
+    if (!is_numeric($values['min_avg_credit_to_post']) OR
122 122
       $values['min_avg_credit_to_post'] < 0) {
123 123
     form_set_error('min_avg_credit_to_post',
124
-      bts('Please set the minimum average credit that a user'
124
+        bts('Please set the minimum average credit that a user'
125 125
         . ' is required to have in order to post to this message board.'
126
-      )
126
+        )
127 127
     );
128
-  }
128
+    }
129 129
 }
130 130
 
131 131
 /**
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
  */
134 134
 function boincteam_forum_create_form_submit($form, &$form_state) {
135 135
   
136
-  $values = $form_state['values'];
136
+    $values = $form_state['values'];
137 137
   
138
-  global $user;
139
-  $account = user_load($user->uid);
138
+    global $user;
139
+    $account = user_load($user->uid);
140 140
   
141
-  // Add the team forum to the db
142
-  db_query("
141
+    // Add the team forum to the db
142
+    db_query("
143 143
     INSERT INTO {boincteam_forum} SET
144 144
       nid = %d,
145 145
       title = '%s',
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
     (int) $values['min_avg_credit_to_post'],
158 158
     ($values['public']) ? 1 : 0,
159 159
     $values['description']
160
-  );
160
+    );
161 161
   
162
-  drupal_set_message(t('Message board "@forum" has been created.',
162
+    drupal_set_message(t('Message board "@forum" has been created.',
163 163
     array('@forum' => $values['title'])));
164 164
 }
165 165
 
@@ -171,84 +171,84 @@  discard block
 block discarded – undo
171 171
  * The definition of the edit team forum form
172 172
  */
173 173
 function boincteam_forum_edit_form(&$form_state, $tfid) {
174
-  $form = array();
175
-  $boincteam_forum = boincteam_forum_load($tfid);
174
+    $form = array();
175
+    $boincteam_forum = boincteam_forum_load($tfid);
176 176
   
177
-  $form_state['storage']['tfid'] = $tfid;
177
+    $form_state['storage']['tfid'] = $tfid;
178 178
   
179
-  $default = array(
179
+    $default = array(
180 180
     'title' => $boincteam_forum->title,
181 181
     'min_time_between_posts' => $boincteam_forum->min_time_between_posts,
182 182
     'min_total_credit_to_post' => $boincteam_forum->min_total_credit_to_post,
183 183
     'min_avg_credit_to_post' => $boincteam_forum->min_avg_credit_to_post,
184 184
     'public' => ($boincteam_forum->public) ? 1 : 0,
185 185
     'description' => $boincteam_forum->description,
186
-  );
186
+    );
187 187
   
188
-  // Standard option sets
189
-  $form['boolean_options'] = array(
188
+    // Standard option sets
189
+    $form['boolean_options'] = array(
190 190
     '#type' => 'value',
191 191
     '#value' => array(1 => bts('yes'), 0 => bts('no')),
192
-  );
192
+    );
193 193
   
194
-  // Form elements
195
-  $form['title'] = array(
194
+    // Form elements
195
+    $form['title'] = array(
196 196
     '#title' => bts('Message board title'),
197 197
     '#type' => 'textfield',
198 198
     '#default_value' => $default['title'],
199 199
     '#size' => 34,
200 200
     '#description' => bts('Text only, no HTML tags'),
201
-  );
202
-  $form['min_time_between_posts'] = array(
201
+    );
202
+    $form['min_time_between_posts'] = array(
203 203
     '#title' => bts('Minimum time between posts'),
204 204
     '#type' => 'textfield',
205 205
     '#default_value' => $default['min_time_between_posts'],
206 206
     '#size' => 12,
207 207
     '#description' => bts('Seconds'),
208
-  );
209
-  $form['min_total_credit_to_post'] = array(
208
+    );
209
+    $form['min_total_credit_to_post'] = array(
210 210
     '#title' => bts('Minimum total credit to post'),
211 211
     '#type' => 'textfield',
212 212
     '#default_value' => $default['min_total_credit_to_post'],
213 213
     '#size' => 12,
214
-  );
215
-  $form['min_avg_credit_to_post'] = array(
214
+    );
215
+    $form['min_avg_credit_to_post'] = array(
216 216
     '#title' => bts('Minimum avg credit to post'),
217 217
     '#type' => 'textfield',
218 218
     '#default_value' => $default['min_avg_credit_to_post'],
219 219
     '#size' => 12,
220
-  );
221
-  $form['public'] = array(
220
+    );
221
+    $form['public'] = array(
222 222
     '#title' => bts('Allow public to read board?'),
223 223
     '#type' => 'radios',
224 224
     '#options' => $form['boolean_options']['#value'],
225 225
     '#attributes' => array('class' => 'fancy'),
226 226
     '#default_value' => $default['public'],
227
-  );
228
-  $form['description'] = array(
227
+    );
228
+    $form['description'] = array(
229 229
     '#title' => bts('Description'),
230 230
     '#type' => 'textarea',
231 231
     '#default_value' => $default['description'],
232 232
     '#size' => 5,
233
-  );
233
+    );
234 234
   
235
-  // Form control
236
-  $form['form control tabs prefix'] = array(
235
+    // Form control
236
+    $form['form control tabs prefix'] = array(
237 237
     '#value' => '<ul class="form-control tab-list">'
238
-  );
239
-  $form['submit'] = array(
238
+    );
239
+    $form['submit'] = array(
240 240
     '#prefix' => '<li class="first tab">',
241 241
     '#type' => 'submit',
242 242
     '#value' => bts('Save message board'),
243 243
     '#suffix' => '</li>',
244
-  );
245
-  $form['form control tabs'] = array(
244
+    );
245
+    $form['form control tabs'] = array(
246 246
     '#value' => '<li class="tab">' . l(bts('Cancel'), strstr($_GET['q'], '/forum', TRUE)) . '</li>'
247
-  );
247
+    );
248 248
   
249
-  $form['#redirect'] = "community/teams/{$boincteam_forum->nid}";
249
+    $form['#redirect'] = "community/teams/{$boincteam_forum->nid}";
250 250
   
251
-  return $form;
251
+    return $form;
252 252
 }
253 253
 
254 254
 /**
@@ -256,33 +256,33 @@  discard block
 block discarded – undo
256 256
  */
257 257
 function boincteam_forum_edit_form_validate($form, &$form_state) {
258 258
 
259
-  $values = $form_state['values'];
259
+    $values = $form_state['values'];
260 260
   
261
-  if (!$values['title']) {
261
+    if (!$values['title']) {
262 262
     form_set_error('name', bts('Message board title is required.'));
263
-  }
264
-  if (!is_numeric($values['min_time_between_posts']) OR
263
+    }
264
+    if (!is_numeric($values['min_time_between_posts']) OR
265 265
       $values['min_time_between_posts'] < 0) {
266 266
     form_set_error('min_time_between_posts', 
267
-      bts('Please set the minimum time required between posts.')
267
+        bts('Please set the minimum time required between posts.')
268 268
     );
269
-  }
270
-  if (!is_numeric($values['min_total_credit_to_post']) OR
269
+    }
270
+    if (!is_numeric($values['min_total_credit_to_post']) OR
271 271
       $values['min_total_credit_to_post'] < 0) {
272 272
     form_set_error('min_total_credit_to_post',
273
-      bts('Please set the minimum total credit that a user'
273
+        bts('Please set the minimum total credit that a user'
274 274
         . ' must earn in order to post to this message board.'
275
-      )
275
+        )
276 276
     );
277
-  }
278
-  if (!is_numeric($values['min_avg_credit_to_post']) OR
277
+    }
278
+    if (!is_numeric($values['min_avg_credit_to_post']) OR
279 279
       $values['min_avg_credit_to_post'] < 0) {
280 280
     form_set_error('min_avg_credit_to_post', 
281
-      bts('Please set the minimum average credit that a user'
281
+        bts('Please set the minimum average credit that a user'
282 282
         . ' is required to have in order to post to this message board.'
283
-      )
283
+        )
284 284
     );
285
-  }
285
+    }
286 286
 }
287 287
 
288 288
 /**
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
  */
291 291
 function boincteam_forum_edit_form_submit($form, &$form_state) {
292 292
   
293
-  $tfid = $form_state['storage']['tfid'];
294
-  $values = $form_state['values'];
293
+    $tfid = $form_state['storage']['tfid'];
294
+    $values = $form_state['values'];
295 295
   
296
-  // Update the team forum in the db
297
-  db_query("
296
+    // Update the team forum in the db
297
+    db_query("
298 298
     UPDATE {boincteam_forum} SET
299 299
       title = '%s',
300 300
       min_time_between_posts = '%d',
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
     ($values['public']) ? 1 : 0,
312 312
     $values['description'],
313 313
     $tfid
314
-  );
314
+    );
315 315
   
316
-  drupal_set_message(t('Details for message board "@forum" have been updated.',
316
+    drupal_set_message(t('Details for message board "@forum" have been updated.',
317 317
     array('@forum' => $values['title'])));
318 318
   
319
-  // The storage variable quietly kills redirection for some reason... unset it
320
-  unset($form_state['storage']);
319
+    // The storage variable quietly kills redirection for some reason... unset it
320
+    unset($form_state['storage']);
321 321
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincteam/boincteam_forum.module 1 patch
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -25,29 +25,29 @@  discard block
 block discarded – undo
25 25
  * Implementation of hook_menu()
26 26
  */
27 27
 function boincteam_forum_menu() {
28
-  $items = array();
28
+    $items = array();
29 29
 
30
-  return $items;
30
+    return $items;
31 31
 }
32 32
 
33 33
 /**
34 34
 * Implementation of hook_form_alter()
35 35
 */
36 36
 function boincteam_forum_form_alter(&$form, $form_state, $form_id) {
37
-  switch ($form_id) {
38
-  // Team forum node edit form
39
-  case 'team_forum_node_form':
37
+    switch ($form_id) {
38
+    // Team forum node edit form
39
+    case 'team_forum_node_form':
40 40
     
41 41
     // Internal fields to indicate where these changes are taking place
42 42
     array_unshift($form, array(
43
-      'tfid' => array(
43
+        'tfid' => array(
44 44
         '#type' => 'hidden',
45 45
         '#value' => arg(3),
46
-      ),
46
+        ),
47 47
     ));
48 48
     break;
49 49
   
50
-  default:
50
+    default:
51 51
   }
52 52
 }
53 53
 
@@ -56,26 +56,26 @@  discard block
 block discarded – undo
56 56
  * Obsolete in Drupal 7...
57 57
  */
58 58
 function boincteam_forum_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
59
-  // In Drupal 7, these operation cases will all exist as their own hooks,
60
-  // so let's approximate that here so that this function can simply be removed
61
-  // upon migration to 7
62
-  switch($op) {
63
-  case 'insert':
59
+    // In Drupal 7, these operation cases will all exist as their own hooks,
60
+    // so let's approximate that here so that this function can simply be removed
61
+    // upon migration to 7
62
+    switch($op) {
63
+    case 'insert':
64 64
     boincteam_forum_node_insert($node);
65 65
     break;
66
-  case 'load':
66
+    case 'load':
67 67
     boincteam_forum_node_load($node);
68 68
     break;
69
-  case 'update':
69
+    case 'update':
70 70
     boincteam_forum_node_update($node);
71 71
     break;
72
-  case 'validate':
72
+    case 'validate':
73 73
     boincteam_forum_node_validate($node);
74 74
     break;
75
-  case 'view':
75
+    case 'view':
76 76
     boincteam_forum_node_view($node);
77 77
     break;
78
-  default:
78
+    default:
79 79
   }
80 80
 }
81 81
 
@@ -84,21 +84,21 @@  discard block
 block discarded – undo
84 84
  * is inserted (forward compatible to Drupal 7)
85 85
  */
86 86
 function boincteam_forum_node_insert($node) {
87
-  switch($node->type) {
88
-  case 'team_forum':
87
+    switch($node->type) {
88
+    case 'team_forum':
89 89
     $account = user_load($node->uid);
90 90
     $team_id = boincteam_forum_lookup_nid($node->tfid);
91 91
     if ($account->team == $team_id) {
92
-      db_query("
92
+        db_query("
93 93
         INSERT INTO {boincteam_forum_node} SET
94 94
           nid = %d,
95 95
           tfid = %d",
96 96
         $node->nid, $node->tfid
97
-      );
97
+        );
98 98
     }
99 99
     unset($node->tfid);
100 100
     break;
101
-  default:
101
+    default:
102 102
   }
103 103
 }
104 104
 
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
  * is loaded (forward compatible to Drupal 7)
108 108
  */
109 109
 function boincteam_forum_node_load($node) {
110
-  switch($node->type) {
111
-  case 'team_forum':
110
+    switch($node->type) {
111
+    case 'team_forum':
112 112
     $node->tfid = db_result(db_query("
113 113
       SELECT tfid FROM {boincteam_forum_node}
114 114
       WHERE nid = %d", $node->nid
115 115
     ));
116 116
     break;
117 117
     
118
-  default:
118
+    default:
119 119
     
120 120
   }
121 121
 }
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
  * is updated (forward compatible to Drupal 7)
126 126
  */
127 127
 function boincteam_forum_node_update($node) {
128
-  switch($node->type) {
129
-  case 'team_forum':
128
+    switch($node->type) {
129
+    case 'team_forum':
130 130
     
131 131
     break;
132 132
     
133
-  default:
133
+    default:
134 134
     
135 135
   }
136 136
 }
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
  * is validated (forward compatible to Drupal 7)
141 141
  */
142 142
 function boincteam_forum_node_validate($node) {
143
-  switch($node->type) {
144
-  case 'team_forum':
143
+    switch($node->type) {
144
+    case 'team_forum':
145 145
     $account = user_load($node->uid);
146 146
     // Get tfid from node, but if empty/null, get it from the database
147 147
     if (!($node->tfid)) {
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
     }
155 155
     $team_id = boincteam_forum_lookup_nid($tfid);
156 156
     if (!$account->team OR $account->team != $team_id) {
157
-      drupal_set_message(t('Failed to add team forum topic.'), 'error');
158
-      drupal_goto('community/forum');
157
+        drupal_set_message(t('Failed to add team forum topic.'), 'error');
158
+        drupal_goto('community/forum');
159 159
     }
160 160
     break;
161
-  default:
161
+    default:
162 162
   }
163 163
 }
164 164
 
@@ -167,19 +167,19 @@  discard block
 block discarded – undo
167 167
  * is viewed (forward compatible to Drupal 7)
168 168
  */
169 169
 function boincteam_forum_node_view($node) {
170
-  switch($node->type) {
171
-  case 'team_forum':
170
+    switch($node->type) {
171
+    case 'team_forum':
172 172
     $team_id = boincteam_forum_lookup_nid($node->tfid);
173 173
     $public_forum = boincteam_forum_is_public($node->tfid);
174 174
     $is_member = boincteam_is_member($team_id);
175 175
     $is_global_moderator = boincteam_forum_is_global_moderator();
176 176
     if (!$public_forum AND !$is_member AND !$is_global_moderator) {
177
-      drupal_not_found();
178
-      module_invoke_all('exit');
179
-      exit();
177
+        drupal_not_found();
178
+        module_invoke_all('exit');
179
+        exit();
180 180
     }
181 181
     break;
182
-  default:
182
+    default:
183 183
   }
184 184
 }
185 185
 
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
 * Implementation of hook_views_api().
188 188
 */
189 189
 function boincteam_forum_views_api() {
190
-  return array(
190
+    return array(
191 191
     'api' => 2.0,
192 192
     'path' => drupal_get_path('module', 'boincteam_forum')
193
-  );
193
+    );
194 194
 }
195 195
 
196 196
 /**
197 197
  * Implementation of hook_perm()
198 198
  */
199 199
 function boincteam_forum_perm() {
200
-  return array('manage boincteam forum');
200
+    return array('manage boincteam forum');
201 201
 }
202 202
 
203 203
 
@@ -209,43 +209,43 @@  discard block
 block discarded – undo
209 209
  * Check if the user has global access to moderate team forums
210 210
  */
211 211
 function boincteam_forum_is_global_moderator() {
212
-  global $user;
213
-  return user_access('manage boincteam forum');
212
+    global $user;
213
+    return user_access('manage boincteam forum');
214 214
 }
215 215
 
216 216
 /*
217 217
  * Check if any forums for a team are public
218 218
  */
219 219
 function boincteam_forum_is_any_public($team_id) {
220
-  $forums = boincteam_forum_list($team_id);
221
-  foreach ($forums as $forum) {
220
+    $forums = boincteam_forum_list($team_id);
221
+    foreach ($forums as $forum) {
222 222
     if ($forum->public) {
223
-      return TRUE;
223
+        return TRUE;
224 224
     }
225
-  }
226
-  return FALSE;
225
+    }
226
+    return FALSE;
227 227
 }
228 228
 
229 229
 /*
230 230
  * Check if a team forum should be visible to everyone
231 231
  */
232 232
 function boincteam_forum_is_public($tfid) {
233
-  return db_result(db_query("
233
+    return db_result(db_query("
234 234
     SELECT public FROM {boincteam_forum} WHERE tfid=%d", $tfid
235
-  ));
235
+    ));
236 236
 }
237 237
 
238 238
 /*
239 239
  * Load the forums for a team, if any exist
240 240
  */
241 241
 function boincteam_forum_list($team_id = NULL) {
242
-  if (!$team_id) {
242
+    if (!$team_id) {
243 243
     global $user;
244 244
     $account = user_load($user->uid);
245 245
     $team_id = $account->team;
246
-  }
247
-  $team_forums = array();
248
-  if ($team_id) {
246
+    }
247
+    $team_forums = array();
248
+    if ($team_id) {
249 249
     // Load any team forum objects for the user's team
250 250
     $result = db_query("
251 251
       SELECT tfid, nid, title, description, created, updated, public,
@@ -255,26 +255,26 @@  discard block
 block discarded – undo
255 255
     $row = 0;
256 256
     while ($team_forum = db_fetch_object($result)) {
257 257
       
258
-      $team_forum->link = url("community/teams/{$team_id}/forum/{$team_forum->tfid}");
259
-      $team_forum->zebra = $row % 2 ? 'even' : 'odd';
260
-      $team_forum->new_topics = 0; // TODO: Track user views of team topics
261
-      $team_forum->new_text = '';
262
-      $team_forum->new_url = '';
263
-      $team_forum->num_topics = db_result(db_query("
258
+        $team_forum->link = url("community/teams/{$team_id}/forum/{$team_forum->tfid}");
259
+        $team_forum->zebra = $row % 2 ? 'even' : 'odd';
260
+        $team_forum->new_topics = 0; // TODO: Track user views of team topics
261
+        $team_forum->new_text = '';
262
+        $team_forum->new_url = '';
263
+        $team_forum->num_topics = db_result(db_query("
264 264
         SELECT COUNT(nid) FROM {boincteam_forum_node}
265 265
         WHERE tfid = %d",
266 266
         $team_forum->tfid
267
-      ));
268
-      $team_forum->num_posts = db_result(db_query("
267
+        ));
268
+        $team_forum->num_posts = db_result(db_query("
269 269
         SELECT COALESCE(SUM(ncs.comment_count),0) + COUNT(ncs.nid)
270 270
         FROM {boincteam_forum_node} bfn
271 271
         JOIN {node_comment_statistics} ncs ON ncs.nid = bfn.nid
272 272
         JOIN {node} n ON n.nid = ncs.nid
273 273
         WHERE bfn.tfid = %d AND n.status = 1",
274 274
         $team_forum->tfid
275
-      ));
276
-      $last_post = new stdClass();
277
-      $last_post->timestamp = db_result(db_query("
275
+        ));
276
+        $last_post = new stdClass();
277
+        $last_post->timestamp = db_result(db_query("
278 278
         SELECT ncs.last_comment_timestamp FROM {node} n
279 279
         INNER JOIN {boincteam_forum_node} bfn
280 280
         INNER JOIN {node_comment_statistics} ncs ON n.nid = bfn.nid AND n.nid = ncs.nid
@@ -282,36 +282,36 @@  discard block
 block discarded – undo
282 282
         ORDER BY ncs.last_comment_timestamp DESC
283 283
         LIMIT 1",
284 284
         $team_forum->tfid
285
-      ));
286
-      $team_forum->last_reply = theme('forum_submitted', ($last_post->timestamp) ? $last_post : NULL);
287
-      $team_forums[$team_forum->tfid] = $team_forum;
288
-      $row++;
285
+        ));
286
+        $team_forum->last_reply = theme('forum_submitted', ($last_post->timestamp) ? $last_post : NULL);
287
+        $team_forums[$team_forum->tfid] = $team_forum;
288
+        $row++;
289 289
     }
290
-  }
291
-  return $team_forums;
290
+    }
291
+    return $team_forums;
292 292
 }
293 293
 
294 294
 /*
295 295
  * Load a team forum by ID
296 296
  */
297 297
 function boincteam_forum_load($tfid) {
298
-  // Load any team forum objects for the user's team
299
-  $result = db_query("
298
+    // Load any team forum objects for the user's team
299
+    $result = db_query("
300 300
     SELECT tfid, nid, title, description, created, updated, public,
301 301
       min_time_between_posts, min_total_credit_to_post, min_avg_credit_to_post
302 302
     FROM {boincteam_forum} WHERE tfid=%d", $tfid
303
-  );
304
-  return db_fetch_object($result);
303
+    );
304
+    return db_fetch_object($result);
305 305
 }
306 306
 
307 307
 /*
308 308
  * Look up the team ID for a given team forum
309 309
  */
310 310
 function boincteam_forum_lookup_nid($tfid) {
311
-  return db_result(db_query("
311
+    return db_result(db_query("
312 312
     SELECT nid FROM {boincteam_forum}
313 313
     WHERE tfid=%d", $tfid
314
-  ));
314
+    ));
315 315
 }
316 316
 
317 317
 
@@ -323,80 +323,80 @@  discard block
 block discarded – undo
323 323
  * Create team forum form
324 324
  */
325 325
 function boincteam_forum_create_form_panel() {
326
-  $output = '';
327
-  $output .= '<h2 class="pane-title">' . bts('Create team message board')
326
+    $output = '';
327
+    $output .= '<h2 class="pane-title">' . bts('Create team message board')
328 328
     . '</h2>';
329
-  $output .= drupal_get_form('boincteam_forum_create_form');
329
+    $output .= drupal_get_form('boincteam_forum_create_form');
330 330
   
331
-  return $output;
331
+    return $output;
332 332
 }
333 333
 
334 334
 /**
335 335
  * Edit team forum form
336 336
  */
337 337
 function boincteam_forum_edit_form_panel($tfid) {
338
-  $team_forum = boincteam_forum_load($tfid);
339
-  $output = '';
340
-  $output .= '<h2 class="pane-title">' . bts('Edit message board') . ': ' . 
338
+    $team_forum = boincteam_forum_load($tfid);
339
+    $output = '';
340
+    $output .= '<h2 class="pane-title">' . bts('Edit message board') . ': ' . 
341 341
     $team_forum->title . '</h2>';
342
-  $output .= drupal_get_form('boincteam_forum_edit_form', $tfid);
342
+    $output .= drupal_get_form('boincteam_forum_edit_form', $tfid);
343 343
   
344
-  return $output;
344
+    return $output;
345 345
 }
346 346
 
347 347
 /**
348 348
  * Link to team forums
349 349
  */
350 350
 function boincteam_forum_link_panel($team_id) {
351
-  $show_public_only = (
351
+    $show_public_only = (
352 352
     !boincteam_is_member($team_id) AND
353 353
     !boincteam_forum_is_global_moderator()
354
-  );
355
-  $forums = boincteam_forum_list($team_id);
356
-  $output = '';
357
-  $output .= '<h2 class="pane-title">' . bts('Team forum') . '</h2>';
358
-  $output .= '<p>'
354
+    );
355
+    $forums = boincteam_forum_list($team_id);
356
+    $output = '';
357
+    $output .= '<h2 class="pane-title">' . bts('Team forum') . '</h2>';
358
+    $output .= '<p>'
359 359
     . bts('A discussion forum has been set up for team members.')
360 360
     . '</p>';
361
-  $output .= '<ul class="tab-list action-list">';
362
-  foreach ($forums as $forum) {
361
+    $output .= '<ul class="tab-list action-list">';
362
+    foreach ($forums as $forum) {
363 363
     if (!$show_public_only OR $forum->public) {
364
-      $output .= '  <li class="tab primary">' . 
364
+        $output .= '  <li class="tab primary">' . 
365 365
         l(
366
-          //$forum->title,
367
-          bts('Enter forum'),
368
-          "community/teams/{$team_id}/forum/{$forum->tfid}"
366
+            //$forum->title,
367
+            bts('Enter forum'),
368
+            "community/teams/{$team_id}/forum/{$forum->tfid}"
369 369
         ) . '</li>';
370
-      // Since we're only supporting one team forum for now, we've labeled the
371
-      // link in a generic way above and will now just break out of the loop
372
-      break;
370
+        // Since we're only supporting one team forum for now, we've labeled the
371
+        // link in a generic way above and will now just break out of the loop
372
+        break;
373 373
     }
374
-  }
375
-  $output .= '</ul>';
376
-  return $output;
374
+    }
375
+    $output .= '</ul>';
376
+    return $output;
377 377
 }
378 378
 
379 379
 /**
380 380
  * General info about team forums
381 381
  */                                         
382 382
 function boincteam_forum_topic_overview_panel($nid = NULL) {
383
-  $output = '';
384
-  $output .= '<h2 class="pane-title">' . bts('About message boards') . '</h2>';
385
-  $output .= '<div>';
386
-  if ($nid) {
383
+    $output = '';
384
+    $output .= '<h2 class="pane-title">' . bts('About message boards') . '</h2>';
385
+    $output .= '<div>';
386
+    if ($nid) {
387 387
     $team = node_load($nid);
388 388
     $output .= '<p>' . bts('You may create a message board for use by @team',
389
-      array('@team' => $team->title)) . ':</p>';
390
-  }
391
-  else {
389
+        array('@team' => $team->title)) . ':</p>';
390
+    }
391
+    else {
392 392
     $output .= '<p>' . bts('This is a team-only message board') . ':</p>';
393
-  }
394
-  $output .= '<ul>';
395
-  $output .= '  <li>' . bts('Only members may post') . '</li>';
396
-  $output .= '  <li>' . bts('Only members may read (optional)') . '</li>';
397
-  $output .= '  <li>' . bts('Founder & Team Admins have moderator privileges') .
393
+    }
394
+    $output .= '<ul>';
395
+    $output .= '  <li>' . bts('Only members may post') . '</li>';
396
+    $output .= '  <li>' . bts('Only members may read (optional)') . '</li>';
397
+    $output .= '  <li>' . bts('Founder & Team Admins have moderator privileges') .
398 398
     '</li>';
399
-  $output .= '</ul>';
400
-  $output .= '</div>';
401
-  return $output;
399
+    $output .= '</ul>';
400
+    $output .= '</div>';
401
+    return $output;
402 402
 }
Please login to merge, or discard this patch.