@@ -57,6 +57,9 @@ |
||
57 | 57 | edit_form($user, $team, $forum, true); |
58 | 58 | } |
59 | 59 | |
60 | +/** |
|
61 | + * @param boolean $first |
|
62 | + */ |
|
60 | 63 | function edit_form($user, $team, $forum, $first) { |
61 | 64 | page_head(tra("Team Message Board")); |
62 | 65 | echo " |
@@ -30,6 +30,9 @@ |
||
30 | 30 | // list entries are of the form id => team, |
31 | 31 | // where team includes a field "refcnt". |
32 | 32 | // |
33 | +/** |
|
34 | + * @param integer $weight |
|
35 | + */ |
|
33 | 36 | function merge_lists($list1, &$list2, $weight) { |
34 | 37 | foreach($list1 as $team) { |
35 | 38 | $id = $team->id; |
@@ -106,6 +106,9 @@ discard block |
||
106 | 106 | return secure_url_base(); |
107 | 107 | } |
108 | 108 | |
109 | +/** |
|
110 | + * @param string $name |
|
111 | + */ |
|
109 | 112 | function send_cookie($name, $value, $permanent, $ops=false) { |
110 | 113 | global $master_url; |
111 | 114 | |
@@ -188,6 +191,9 @@ discard block |
||
188 | 191 | // To do so, define page_head() in the project include file. |
189 | 192 | // |
190 | 193 | if (!function_exists("page_head")){ |
194 | +/** |
|
195 | + * @param string $body_attrs |
|
196 | + */ |
|
191 | 197 | function page_head( |
192 | 198 | $title, |
193 | 199 | // page title. Put in <title>, used as title for browser tab. |
@@ -455,6 +461,9 @@ discard block |
||
455 | 461 | "; |
456 | 462 | } |
457 | 463 | |
464 | +/** |
|
465 | + * @param string $x |
|
466 | + */ |
|
458 | 467 | function row2_init($x, $y, $lwidth='40%') { |
459 | 468 | echo '<tr> |
460 | 469 | <td class="text-right " width="'.$lwidth.'" style="padding-right: 20px;">'.$x.'</td> |
@@ -466,6 +475,9 @@ discard block |
||
466 | 475 | echo "<tr><td>$x</td><td>$y</td></tr>\n"; |
467 | 476 | } |
468 | 477 | |
478 | +/** |
|
479 | + * @param string $string |
|
480 | + */ |
|
469 | 481 | function rowify($string) { |
470 | 482 | echo "<tr><td>$string</td></tr>"; |
471 | 483 | } |
@@ -491,6 +503,9 @@ discard block |
||
491 | 503 | echo "</tr>\n"; |
492 | 504 | } |
493 | 505 | |
506 | +/** |
|
507 | + * @param string $x |
|
508 | + */ |
|
494 | 509 | function row_heading($x) { |
495 | 510 | echo '<tr><th class="bg-primary" colspan=99>'.$x.'</th></tr> |
496 | 511 | '; |
@@ -555,6 +570,11 @@ discard block |
||
555 | 570 | // If $ellipsis is true, then an ellipsis is added to any sentence which |
556 | 571 | // is cut short. |
557 | 572 | |
573 | +/** |
|
574 | + * @param string $sentence |
|
575 | + * @param string $delimiter |
|
576 | + * @param integer $max_chars |
|
577 | + */ |
|
558 | 578 | function sub_sentence($sentence, $delimiter, $max_chars, $ellipsis=false) { |
559 | 579 | $words = explode($delimiter, $sentence); |
560 | 580 | $total_chars = 0; |
@@ -605,6 +625,9 @@ discard block |
||
605 | 625 | ob_implicit_flush(0); |
606 | 626 | } |
607 | 627 | |
628 | +/** |
|
629 | + * @param string $filename |
|
630 | + */ |
|
608 | 631 | function close_output_buffer($filename) { |
609 | 632 | $fh = fopen($filename, "w"); |
610 | 633 | $page = ob_get_contents(); |
@@ -673,6 +696,9 @@ discard block |
||
673 | 696 | |
674 | 697 | // returns null if the arg is optional and missing |
675 | 698 | // |
699 | +/** |
|
700 | + * @param string $name |
|
701 | + */ |
|
676 | 702 | function post_int($name, $optional=false) { |
677 | 703 | $x = post_num($name, $optional); |
678 | 704 | if (is_null($x)) return null; |
@@ -772,6 +798,9 @@ discard block |
||
772 | 798 | |
773 | 799 | // Generate a "select" element from an array of values |
774 | 800 | // |
801 | +/** |
|
802 | + * @param string $name |
|
803 | + */ |
|
775 | 804 | function select_from_array($name, $array, $selection=null, $width=240) { |
776 | 805 | $out = '<select style="color:#000;"class="form-control input-sm" style="width:'.$width.'px" name="'.$name.'">"'; |
777 | 806 | |
@@ -833,6 +862,9 @@ discard block |
||
833 | 862 | "; |
834 | 863 | } |
835 | 864 | |
865 | +/** |
|
866 | + * @param string $text |
|
867 | + */ |
|
836 | 868 | function button_text($url, $text, $desc=null, $class="btn btn-default") { |
837 | 869 | if (!$desc) $desc = $text; |
838 | 870 | return "<a href=\"".$url."\" title=\"$desc\" class=\"".$class."\">".$text."</a> |
@@ -854,6 +886,12 @@ discard block |
||
854 | 886 | |
855 | 887 | // used for showing icons |
856 | 888 | // |
889 | +/** |
|
890 | + * @param string $src |
|
891 | + * @param string $title |
|
892 | + * @param string $alt |
|
893 | + * @param string $height |
|
894 | + */ |
|
857 | 895 | function show_image($src, $title, $alt, $height=null) { |
858 | 896 | $h = ""; |
859 | 897 | if ($height) { |
@@ -969,6 +1007,9 @@ discard block |
||
969 | 1007 | } |
970 | 1008 | } |
971 | 1009 | |
1010 | +/** |
|
1011 | + * @param integer $f |
|
1012 | + */ |
|
972 | 1013 | function flops_to_credit($f) { |
973 | 1014 | return $f*(200/86400e9); |
974 | 1015 | } |
@@ -1004,6 +1045,9 @@ discard block |
||
1004 | 1045 | } |
1005 | 1046 | } |
1006 | 1047 | |
1048 | +/** |
|
1049 | + * @param integer $height |
|
1050 | + */ |
|
1007 | 1051 | function badges_string($is_user, $item, $height) { |
1008 | 1052 | if (DISABLE_BADGES) return null; |
1009 | 1053 | if ($is_user) { |
@@ -1020,6 +1064,9 @@ discard block |
||
1020 | 1064 | return $x; |
1021 | 1065 | } |
1022 | 1066 | |
1067 | +/** |
|
1068 | + * @param boolean $is_user |
|
1069 | + */ |
|
1023 | 1070 | function show_badges_row($is_user, $item) { |
1024 | 1071 | if (BADGE_HEIGHT_LARGE == 0) return; |
1025 | 1072 | $x = badges_string($is_user, $item, BADGE_HEIGHT_LARGE); |
@@ -1064,6 +1111,11 @@ discard block |
||
1064 | 1111 | // return HTML for a textarea with chars-remaining counter. |
1065 | 1112 | // Call text_counter_script() before using this. |
1066 | 1113 | // |
1114 | +/** |
|
1115 | + * @param string $name |
|
1116 | + * @param integer $maxlen |
|
1117 | + * @param string $text |
|
1118 | + */ |
|
1067 | 1119 | function textarea_with_counter($name, $maxlen, $text) { |
1068 | 1120 | $rem_name = $name."_remaining"; |
1069 | 1121 | return "<textarea name=\"$name\" class=\"form-control\" rows=3 id=\"$name\" onkeydown=\"text_counter(this.form.$name, this.form.$rem_name, $maxlen);\" |
@@ -36,6 +36,10 @@ discard block |
||
36 | 36 | return file_exists("$d/stop_sched"); |
37 | 37 | } |
38 | 38 | |
39 | +/** |
|
40 | + * @param string $x |
|
41 | + * @param string $y |
|
42 | + */ |
|
39 | 43 | function show_page($x, $y) { |
40 | 44 | echo " |
41 | 45 | <title>$x</title> |
@@ -44,6 +48,9 @@ discard block |
||
44 | 48 | "; |
45 | 49 | } |
46 | 50 | |
51 | +/** |
|
52 | + * @param integer $num |
|
53 | + */ |
|
47 | 54 | function xml_error($num, $msg=null, $file=null, $line=null) { |
48 | 55 | global $xml_outer_tag; |
49 | 56 | if (!$msg) { |
@@ -92,6 +99,9 @@ discard block |
||
92 | 99 | // Look for an element in a line of XML text |
93 | 100 | // If it's a single-tag element, and it's present, just return the tag |
94 | 101 | // |
102 | +/** |
|
103 | + * @return string |
|
104 | + */ |
|
95 | 105 | function parse_element($xml, $tag) { |
96 | 106 | $element = null; |
97 | 107 | $closetag = "</" . substr($tag,1); |
@@ -107,6 +117,9 @@ discard block |
||
107 | 117 | return trim($element); |
108 | 118 | } |
109 | 119 | |
120 | +/** |
|
121 | + * @param string $tag |
|
122 | + */ |
|
110 | 123 | function parse_next_element($xml, $tag, &$cursor) { |
111 | 124 | $element = null; |
112 | 125 | $closetag = "</" . substr($tag,1); |
@@ -137,6 +150,9 @@ discard block |
||
137 | 150 | |
138 | 151 | // look for a particular element in the config file |
139 | 152 | // |
153 | +/** |
|
154 | + * @param string $tag |
|
155 | + */ |
|
140 | 156 | function parse_config($config, $tag) { |
141 | 157 | $element = parse_element($config, $tag); |
142 | 158 | return $element; |
@@ -168,6 +168,7 @@ discard block |
||
168 | 168 | /** |
169 | 169 | * Implementation of hook_node_view(); add custom actions when a node |
170 | 170 | * is viewed (forward compatible to Drupal 7) |
171 | + * @param string $view_mode |
|
171 | 172 | */ |
172 | 173 | function boinctranslate_node_view($node, $view_mode, $langcode) { |
173 | 174 | switch($node->type) { |
@@ -706,6 +707,7 @@ discard block |
||
706 | 707 | |
707 | 708 | /** |
708 | 709 | * |
710 | + * @param string $type |
|
709 | 711 | */ |
710 | 712 | function boinctranslate_export_po_generate($language = NULL, $strings = array(), $header = NULL, $type = NULL) { |
711 | 713 | |
@@ -1081,6 +1083,7 @@ discard block |
||
1081 | 1083 | |
1082 | 1084 | /** |
1083 | 1085 | * |
1086 | + * @param stdClass $file |
|
1084 | 1087 | */ |
1085 | 1088 | function _boinctranslate_locale_import_po($file, $langcode, $mode, $group = NULL) { |
1086 | 1089 | // Try to allocate enough time to parse and import the data. |
@@ -1127,6 +1130,7 @@ discard block |
||
1127 | 1130 | |
1128 | 1131 | /** |
1129 | 1132 | * |
1133 | + * @param string $op |
|
1130 | 1134 | */ |
1131 | 1135 | function _boinctranslate_locale_import_read_po($op, $file, $mode = NULL, $lang = NULL, $group = 'default') { |
1132 | 1136 | |
@@ -1478,6 +1482,7 @@ discard block |
||
1478 | 1482 | * |
1479 | 1483 | * Textgroups 'boinc' and 'project' use the location string to |
1480 | 1484 | * uniquely identify rows in the locales_source database. |
1485 | + * @param string $textgroup |
|
1481 | 1486 | */ |
1482 | 1487 | function _boinctranslate_locale_import_one_string_db(&$report, $langcode, $source, $translation, $textgroup, $location, $mode, $plid = NULL, $plural = NULL) { |
1483 | 1488 |
@@ -40,6 +40,10 @@ discard block |
||
40 | 40 | // 2: only use replica_db_user, only try replica_db_host |
41 | 41 | // can be set projectwide using <replica_fallback_mode> |
42 | 42 | // |
43 | + |
|
44 | + /** |
|
45 | + * @param boolean $readonly |
|
46 | + */ |
|
43 | 47 | static function get_aux($readonly, $fallback_mode = 0) { |
44 | 48 | $config = get_config(); |
45 | 49 | $user = parse_config($config, '<db_user>'); |
@@ -204,6 +208,10 @@ discard block |
||
204 | 208 | $db = BoincDb::get(); |
205 | 209 | return $db->count('user', $clause); |
206 | 210 | } |
211 | + |
|
212 | + /** |
|
213 | + * @param string $field |
|
214 | + */ |
|
207 | 215 | static function max($field) { |
208 | 216 | $db = BoincDb::get(); |
209 | 217 | return $db->max('user', $field); |
@@ -216,6 +224,10 @@ discard block |
||
216 | 224 | $db = BoincDb::get(); |
217 | 225 | return $db->enum('user', 'BoincUser', $where_clause, $order_clause); |
218 | 226 | } |
227 | + |
|
228 | + /** |
|
229 | + * @param string $fields |
|
230 | + */ |
|
219 | 231 | static function enum_fields($fields, $where_clause, $order_clause=null) { |
220 | 232 | $db = BoincDb::get(); |
221 | 233 | return $db->enum_fields( |
@@ -233,10 +245,19 @@ discard block |
||
233 | 245 | $db->delete_aux('profile', "userid=$this->id"); |
234 | 246 | return $db->delete($this, 'user'); |
235 | 247 | } |
248 | + |
|
249 | + /** |
|
250 | + * @param string $field |
|
251 | + */ |
|
236 | 252 | static function sum($field) { |
237 | 253 | $db = BoincDb::get(); |
238 | 254 | return $db->sum('user', $field); |
239 | 255 | } |
256 | + |
|
257 | + /** |
|
258 | + * @param string $field |
|
259 | + * @param string $clause |
|
260 | + */ |
|
240 | 261 | static function percentile($field, $clause, $pct) { |
241 | 262 | $db = BoincDb::get(); |
242 | 263 | return $db->percentile('user', $field, $clause, $pct); |
@@ -245,6 +266,10 @@ discard block |
||
245 | 266 | |
246 | 267 | class BoincTeam { |
247 | 268 | static $cache; |
269 | + |
|
270 | + /** |
|
271 | + * @param string $clause |
|
272 | + */ |
|
248 | 273 | static function insert($clause) { |
249 | 274 | $db = BoincDb::get(); |
250 | 275 | $ret = $db->insert('team', $clause); |
@@ -282,14 +307,27 @@ discard block |
||
282 | 307 | $db = BoincDb::get(); |
283 | 308 | return $db->delete($this, 'team'); |
284 | 309 | } |
310 | + |
|
311 | + /** |
|
312 | + * @param string $field |
|
313 | + * @param string $clause |
|
314 | + */ |
|
285 | 315 | static function percentile($field, $clause, $pct) { |
286 | 316 | $db = BoincDb::get(); |
287 | 317 | return $db->percentile('team', $field, $clause, $pct); |
288 | 318 | } |
319 | + |
|
320 | + /** |
|
321 | + * @param string $field |
|
322 | + */ |
|
289 | 323 | static function max($field) { |
290 | 324 | $db = BoincDb::get(); |
291 | 325 | return $db->max('team', $field); |
292 | 326 | } |
327 | + |
|
328 | + /** |
|
329 | + * @param string $fields |
|
330 | + */ |
|
293 | 331 | static function enum_fields($fields, $where_clause, $order_clause=null) { |
294 | 332 | $db = BoincDb::get(); |
295 | 333 | return $db->enum_fields( |
@@ -326,6 +364,12 @@ discard block |
||
326 | 364 | $db = BoincDb::get(); |
327 | 365 | return $db->enum('host', 'BoincHost', $where_clause, $order_clause); |
328 | 366 | } |
367 | + |
|
368 | + /** |
|
369 | + * @param string $fields |
|
370 | + * @param string $where_clause |
|
371 | + * @param string $order_clause |
|
372 | + */ |
|
329 | 373 | static function enum_fields($fields, $where_clause, $order_clause=null) { |
330 | 374 | $db = BoincDb::get(); |
331 | 375 | return $db->enum_fields( |
@@ -358,6 +402,10 @@ discard block |
||
358 | 402 | $db = BoincDb::get(); |
359 | 403 | return $db->enum('result', 'BoincResult', $where_clause); |
360 | 404 | } |
405 | + |
|
406 | + /** |
|
407 | + * @param string $fields |
|
408 | + */ |
|
361 | 409 | static function enum_fields($fields, $where_clause, $order_clause) { |
362 | 410 | $db = BoincDb::get(); |
363 | 411 | return $db->enum_fields('result', 'BoincResult', $fields, $where_clause, $order_clause); |
@@ -412,6 +460,10 @@ discard block |
||
412 | 460 | $db = BoincDb::get(); |
413 | 461 | return $db->update_aux('workunit', $clause); |
414 | 462 | } |
463 | + |
|
464 | + /** |
|
465 | + * @param string $clause |
|
466 | + */ |
|
415 | 467 | static function count($clause) { |
416 | 468 | $db = BoincDb::get(); |
417 | 469 | return $db->count('workunit', $clause); |
@@ -427,6 +479,10 @@ discard block |
||
427 | 479 | $db = BoincDb::get(); |
428 | 480 | return $db->lookup('app', 'BoincApp', $clause); |
429 | 481 | } |
482 | + |
|
483 | + /** |
|
484 | + * @param string $where_clause |
|
485 | + */ |
|
430 | 486 | static function enum($where_clause) { |
431 | 487 | $db = BoincDb::get(); |
432 | 488 | return $db->enum('app', 'BoincApp', $where_clause); |
@@ -441,6 +497,11 @@ discard block |
||
441 | 497 | $db = BoincDb::get(); |
442 | 498 | return $db->update($this, 'app', $clause); |
443 | 499 | } |
500 | + |
|
501 | + /** |
|
502 | + * @param string $field |
|
503 | + * @param string $clause |
|
504 | + */ |
|
444 | 505 | static function sum($field, $clause=null) { |
445 | 506 | $db = BoincDb::get(); |
446 | 507 | return $db->sum('app', $field, $clause); |
@@ -473,6 +534,10 @@ discard block |
||
473 | 534 | } |
474 | 535 | |
475 | 536 | class BoincProfile { |
537 | + |
|
538 | + /** |
|
539 | + * @param string $fields |
|
540 | + */ |
|
476 | 541 | static function lookup_fields($fields, $clause) { |
477 | 542 | $db = BoincDb::get(); |
478 | 543 | return $db->lookup_fields('profile', 'BoincProfile', $fields, $clause); |
@@ -489,18 +554,37 @@ discard block |
||
489 | 554 | $db = BoincDb::get(); |
490 | 555 | return $db->update_aux('profile', $clause.' where userid='.$this->userid); |
491 | 556 | } |
557 | + |
|
558 | + /** |
|
559 | + * @param string $clause |
|
560 | + */ |
|
492 | 561 | static function update_aux($clause) { |
493 | 562 | $db = BoincDb::get(); |
494 | 563 | return $db->update_aux('profile', $clause); |
495 | 564 | } |
565 | + |
|
566 | + /** |
|
567 | + * @param string $clause |
|
568 | + */ |
|
496 | 569 | static function insert($clause) { |
497 | 570 | $db = BoincDb::get(); |
498 | 571 | return $db->insert('profile', $clause); |
499 | 572 | } |
573 | + |
|
574 | + /** |
|
575 | + * @param string $where_clause |
|
576 | + * @param string $order_clause |
|
577 | + */ |
|
500 | 578 | static function enum($where_clause=null, $order_clause=null) { |
501 | 579 | $db = BoincDb::get(); |
502 | 580 | return $db->enum('profile', 'BoincProfile', $where_clause, $order_clause); |
503 | 581 | } |
582 | + |
|
583 | + /** |
|
584 | + * @param string $fields |
|
585 | + * @param string $where_clause |
|
586 | + * @param string $order_clause |
|
587 | + */ |
|
504 | 588 | static function enum_fields($fields, $where_clause=null, $order_clause=null) { |
505 | 589 | $db = BoincDb::get(); |
506 | 590 | return $db->enum_fields('profile', 'BoincProfile', $fields, $where_clause, $order_clause); |
@@ -568,6 +652,10 @@ discard block |
||
568 | 652 | } |
569 | 653 | |
570 | 654 | class BoincPlatform { |
655 | + |
|
656 | + /** |
|
657 | + * @param string $where_clause |
|
658 | + */ |
|
571 | 659 | static function enum($where_clause) { |
572 | 660 | $db = BoincDb::get(); |
573 | 661 | return $db->enum('platform', 'BoincPlatform', $where_clause); |
@@ -648,6 +736,10 @@ discard block |
||
648 | 736 | } |
649 | 737 | |
650 | 738 | class BoincBadge { |
739 | + |
|
740 | + /** |
|
741 | + * @param string $where_clause |
|
742 | + */ |
|
651 | 743 | static function enum($where_clause) { |
652 | 744 | $db = BoincDb::get(); |
653 | 745 | return $db->enum('badge', 'BoincBadge', $where_clause); |
@@ -743,6 +835,11 @@ discard block |
||
743 | 835 | $db = BoincDb::get(); |
744 | 836 | return $db->enum('credit_user', 'BoincCreditUser', $where_clause); |
745 | 837 | } |
838 | + |
|
839 | + /** |
|
840 | + * @param string $field |
|
841 | + * @param string $clause |
|
842 | + */ |
|
746 | 843 | static function sum($field, $clause) { |
747 | 844 | $db = BoincDb::get(); |
748 | 845 | return $db->sum('credit_user', $field, $clause); |
@@ -755,6 +852,11 @@ discard block |
||
755 | 852 | $db = BoincDb::get(); |
756 | 853 | $db->delete_aux('credit_user', "userid=$user->id"); |
757 | 854 | } |
855 | + |
|
856 | + /** |
|
857 | + * @param string $order_clause |
|
858 | + * @param string $limit |
|
859 | + */ |
|
758 | 860 | static function get_list($where_clause, $order_clause, $limit) { |
759 | 861 | $db = BoincDB::get(); |
760 | 862 | return $db->get_list('user', 'credit_user', 'id', 'userid', 'BoincCreditUser', '*', $where_clause, $order_clause, $limit); |
@@ -770,6 +872,11 @@ discard block |
||
770 | 872 | $db = BoincDb::get(); |
771 | 873 | return $db->enum('credit_team', 'BoincCreditTeam', $where_clause); |
772 | 874 | } |
875 | + |
|
876 | + /** |
|
877 | + * @param string $field |
|
878 | + * @param string $clause |
|
879 | + */ |
|
773 | 880 | static function sum($field, $clause) { |
774 | 881 | $db = BoincDb::get(); |
775 | 882 | return $db->sum('credit_team', $field, $clause); |
@@ -778,6 +885,11 @@ discard block |
||
778 | 885 | $db = BoincDb::get(); |
779 | 886 | return $db->update_aux('credit_team', $clause); |
780 | 887 | } |
888 | + |
|
889 | + /** |
|
890 | + * @param string $order_clause |
|
891 | + * @param string $limit |
|
892 | + */ |
|
781 | 893 | static function get_list($where_clause, $order_clause, $limit) { |
782 | 894 | $db = BoincDB::get(); |
783 | 895 | return $db->get_list('team', 'credit_team', 'id', 'teamid', 'BoincCreditTeam', '*', $where_clause, $order_clause, $limit); |
@@ -788,6 +900,11 @@ discard block |
||
788 | 900 | // |
789 | 901 | // apply this to any user-supplied strings used in queries |
790 | 902 | // |
903 | +/** |
|
904 | + * @param string $x |
|
905 | + * |
|
906 | + * @return string |
|
907 | + */ |
|
791 | 908 | function boinc_real_escape_string($x) { |
792 | 909 | if (version_compare(phpversion(),"4.3.0")>=0) { |
793 | 910 | return BoincDb::escape_string($x); |
@@ -26,6 +26,9 @@ discard block |
||
26 | 26 | var $db_name; |
27 | 27 | var $readonly; |
28 | 28 | |
29 | + /** |
|
30 | + * @param boolean $readonly |
|
31 | + */ |
|
29 | 32 | function init_conn($user, $passwd, $host, $name, $readonly) { |
30 | 33 | if (MYSQLI) { |
31 | 34 | $x = explode(":", $host); |
@@ -92,6 +95,14 @@ discard block |
||
92 | 95 | } |
93 | 96 | } |
94 | 97 | |
98 | + /** |
|
99 | + * @param string $table1 |
|
100 | + * @param string $table2 |
|
101 | + * @param string $joinfield1 |
|
102 | + * @param string $joinfield2 |
|
103 | + * @param string $classname |
|
104 | + * @param string $fields |
|
105 | + */ |
|
95 | 106 | function get_list($table1, $table2, $joinfield1, $joinfield2, $classname, $fields, $where_clause, $order_clause, $limit) { |
96 | 107 | $query = "select $fields from DBNAME.$table1 a join DBNAME.$table2 b on a.$joinfield1=b.$joinfield2 where $where_clause order by $order_clause desc limit $limit"; |
97 | 108 | $result = $this->do_query($query); |
@@ -131,6 +142,10 @@ discard block |
||
131 | 142 | return $this->lookup_fields($table, $classname, "*", $clause); |
132 | 143 | } |
133 | 144 | |
145 | + /** |
|
146 | + * @param string $table |
|
147 | + * @param string $classname |
|
148 | + */ |
|
134 | 149 | function lookup_id($id, $table, $classname) { |
135 | 150 | $id = (int)$id; |
136 | 151 | return $this->lookup($table, $classname, "id=$id"); |
@@ -165,28 +180,51 @@ discard block |
||
165 | 180 | return $this->enum_general($classname,$query); |
166 | 181 | } |
167 | 182 | |
183 | + /** |
|
184 | + * @param string $table |
|
185 | + * @param string $classname |
|
186 | + */ |
|
168 | 187 | function enum($table, $classname, $where_clause=null, $order_clause=null) { |
169 | 188 | return self::enum_fields( |
170 | 189 | $table, $classname, '*', $where_clause, $order_clause |
171 | 190 | ); |
172 | 191 | } |
173 | 192 | |
193 | + /** |
|
194 | + * @param string $table |
|
195 | + */ |
|
174 | 196 | function update($obj, $table, $clause) { |
175 | 197 | $query = "update DBNAME.$table set $clause where id=$obj->id"; |
176 | 198 | return $this->do_query($query); |
177 | 199 | } |
200 | + |
|
201 | + /** |
|
202 | + * @param string $table |
|
203 | + */ |
|
178 | 204 | function update_aux($table, $clause) { |
179 | 205 | $query = "update DBNAME.$table set $clause"; |
180 | 206 | return $this->do_query($query); |
181 | 207 | } |
208 | + |
|
209 | + /** |
|
210 | + * @param string $table |
|
211 | + */ |
|
182 | 212 | function insert($table, $clause) { |
183 | 213 | $query = "insert into DBNAME.$table $clause"; |
184 | 214 | return $this->do_query($query); |
185 | 215 | } |
216 | + |
|
217 | + /** |
|
218 | + * @param string $table |
|
219 | + */ |
|
186 | 220 | function delete($obj, $table) { |
187 | 221 | $query = "delete from DBNAME.$table where id=$obj->id"; |
188 | 222 | return $this->do_query($query); |
189 | 223 | } |
224 | + |
|
225 | + /** |
|
226 | + * @param string $table |
|
227 | + */ |
|
190 | 228 | function delete_aux($table, $clause) { |
191 | 229 | $query = "delete from DBNAME.$table where $clause"; |
192 | 230 | return $this->do_query($query); |
@@ -198,6 +236,10 @@ discard block |
||
198 | 236 | return mysql_insert_id($this->db_conn); |
199 | 237 | } |
200 | 238 | } |
239 | + |
|
240 | + /** |
|
241 | + * @param string $field |
|
242 | + */ |
|
201 | 243 | function get_int($query, $field) { |
202 | 244 | $result = $this->do_query($query); |
203 | 245 | if (!$result) error_page("database error on query $query"); |
@@ -228,14 +270,26 @@ discard block |
||
228 | 270 | $query = "select count(*) as total from DBNAME.$table where $clause"; |
229 | 271 | return $this->get_int($query, 'total'); |
230 | 272 | } |
273 | + |
|
274 | + /** |
|
275 | + * @param string $table |
|
276 | + */ |
|
231 | 277 | function sum($table, $field, $clause="") { |
232 | 278 | $query = "select sum($field) as total from DBNAME.$table $clause"; |
233 | 279 | return $this->get_double($query, 'total'); |
234 | 280 | } |
281 | + |
|
282 | + /** |
|
283 | + * @param string $table |
|
284 | + */ |
|
235 | 285 | function max($table, $field, $clause="") { |
236 | 286 | $query = "select max($field) as total from DBNAME.$table $clause"; |
237 | 287 | return $this->get_double($query, 'total'); |
238 | 288 | } |
289 | + |
|
290 | + /** |
|
291 | + * @param string $table |
|
292 | + */ |
|
239 | 293 | function percentile($table, $field, $clause, $pct) { |
240 | 294 | $n = $this->count($table, $clause); |
241 | 295 | if (!$n) return false; |
@@ -243,6 +297,10 @@ discard block |
||
243 | 297 | $query = "select $field from DBNAME.$table where $clause order by $field limit $m,1"; |
244 | 298 | return $this->get_double($query, $field); |
245 | 299 | } |
300 | + |
|
301 | + /** |
|
302 | + * @param string $table |
|
303 | + */ |
|
246 | 304 | function replace($table, $clause) { |
247 | 305 | $query = "replace into DBNAME.$table set $clause"; |
248 | 306 | return $this->do_query($query); |
@@ -38,6 +38,9 @@ |
||
38 | 38 | // return a column title (Average or Total), |
39 | 39 | // hyperlinked if this is not the current sort column |
40 | 40 | // |
41 | +/** |
|
42 | + * @param integer $i |
|
43 | + */ |
|
41 | 44 | function col_title($is_team, $app, $appid, $is_total, $i) { |
42 | 45 | $x = $i ? tra("Total") : tra("Average"); |
43 | 46 | if ($app->id == $appid && ($is_total ? $i : !$i)) { |