Mercurial > hg > fapweb
comparison admajax.php @ 1104:0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 14 May 2019 14:45:36 +0300 |
parents | 95b74632cfe2 |
children | 51f24cb35fc8 |
comparison
equal
deleted
inserted
replaced
1103:1fe7df7c77fb | 1104:0a2117349f46 |
---|---|
191 | 191 |
192 $eid = $entry["id"]; | 192 $eid = $entry["id"]; |
193 $str = "<div class=\"editControl\"><span class=\"editControlTitle\">".chentities($title)."</span>\n"; | 193 $str = "<div class=\"editControl\"><span class=\"editControlTitle\">".chentities($title)."</span>\n"; |
194 | 194 |
195 // Show currently selected / active file | 195 // Show currently selected / active file |
196 if (($efile = stFetchSQL("SELECT * FROM files WHERE deleted=0 AND id=".$entry[$file_id])) !== false) | 196 if (($efile = stFetchSQL("SELECT * FROM files WHERE deleted=0 AND id=".$entry[$file_id])) !== FALSE) |
197 { | 197 { |
198 $str .= | 198 $str .= |
199 "<div>File: <b>".chentities($efile["filename"])."</b></div>\n". | 199 "<div>File: <b>".chentities($efile["filename"])."</b></div>\n". |
200 "<div>Orig: <b>".chentities($efile["origname"])."</b></div>\n"; | 200 "<div>Orig: <b>".chentities($efile["origname"])."</b></div>\n"; |
201 } | 201 } |
250 // Output wrapper div only if requested | 250 // Output wrapper div only if requested |
251 if ($tr) | 251 if ($tr) |
252 { | 252 { |
253 echo | 253 echo |
254 " <div class=\"entryRow ".($row % 2 == 1 ? "rodd" : "reven"). | 254 " <div class=\"entryRow ".($row % 2 == 1 ? "rodd" : "reven"). |
255 "\"".($mode == EEMODE_NORMAL ? " id=\"entry".$eid."\" onClick=\"activateEntry(".$eid.", false)\"" : "").">\n"; | 255 "\"".($mode == EEMODE_NORMAL ? " id=\"entry".$eid."\" onClick=\"activateEntry(".$eid.", FALSE)\"" : "").">\n"; |
256 } | 256 } |
257 | 257 |
258 // Only show show_id if this is a normal compo and we are not adding | 258 // Only show show_id if this is a normal compo and we are not adding |
259 if ($mode != EEMODE_ADD && $compo["ctype"] == COMPO_NORMAL) | 259 if ($mode != EEMODE_ADD && $compo["ctype"] == COMPO_NORMAL) |
260 { | 260 { |
472 if ($show_id > 0) | 472 if ($show_id > 0) |
473 { | 473 { |
474 $sql = stPrepareSQL("SELECT * FROM entries WHERE show_id=%d AND compo_id=%d", | 474 $sql = stPrepareSQL("SELECT * FROM entries WHERE show_id=%d AND compo_id=%d", |
475 $show_id, $compo_id); | 475 $show_id, $compo_id); |
476 | 476 |
477 if (($entry = stFetchSQL($sql)) !== false) | 477 if (($entry = stFetchSQL($sql)) !== FALSE) |
478 { | 478 { |
479 // Entry show#/title/author information | 479 // Entry show#/title/author information |
480 $str = | 480 $str = |
481 "<div class=\"entryInfo\">#".$entry["show_id"]." - ". | 481 "<div class=\"entryInfo\">#".$entry["show_id"]." - ". |
482 "<span class=\"entryName\">".chentities($entry["name"])."</span>". | 482 "<span class=\"entryName\">".chentities($entry["name"])."</span>". |
483 "<span class=\"entryBy\"> by </span>". | 483 "<span class=\"entryBy\"> by </span>". |
484 "<span class=\"entryAuthor\">".chentities($entry["author"])."</span>". | 484 "<span class=\"entryAuthor\">".chentities($entry["author"])."</span>". |
485 "</div>"; | 485 "</div>"; |
486 | 486 |
487 // File information for quick reference | 487 // File information for quick reference |
488 if (($efile = stFetchSQL("SELECT * FROM files WHERE deleted=0 AND id=".$entry["file_id"])) !== false) | 488 if (($efile = stFetchSQL("SELECT * FROM files WHERE deleted=0 AND id=".$entry["file_id"])) !== FALSE) |
489 { | 489 { |
490 foreach (array("S" => "filename", "O" => "origname") as $ftitle => $fid) | 490 foreach (array("S" => "filename", "O" => "origname") as $ftitle => $fid) |
491 { | 491 { |
492 $str .= | 492 $str .= |
493 "<div class=\"entryFile\">". | 493 "<div class=\"entryFile\">". |
514 { | 514 { |
515 $compoID = stGetDisplayVar("compoID"); | 515 $compoID = stGetDisplayVar("compoID"); |
516 if ($compoID > 0) | 516 if ($compoID > 0) |
517 { | 517 { |
518 $sql = stPrepareSQL("SELECT * FROM compos WHERE id=%d", $compoID); | 518 $sql = stPrepareSQL("SELECT * FROM compos WHERE id=%d", $compoID); |
519 if (($entry = stFetchSQL($sql)) !== false) | 519 if (($entry = stFetchSQL($sql)) !== FALSE) |
520 $strCompo = chentities($entry["name"]); | 520 $strCompo = chentities($entry["name"]); |
521 | 521 |
522 $strCurrEntry = stGetInfoEntryData(stGetDisplayVar("compoCurrEntry"), $compoID, TRUE); | 522 $strCurrEntry = stGetInfoEntryData(stGetDisplayVar("compoCurrEntry"), $compoID, TRUE); |
523 $strPrevEntry = stGetInfoEntryData(stGetDisplayVar("compoPrevEntry"), $compoID, FALSE); | 523 $strPrevEntry = stGetInfoEntryData(stGetDisplayVar("compoPrevEntry"), $compoID, FALSE); |
524 } | 524 } |
542 if ($currShowID <= 0) | 542 if ($currShowID <= 0) |
543 $currShowID = -1; | 543 $currShowID = -1; |
544 | 544 |
545 $str = stGetFormOptionListStart("ctrlEntryList", $indent, $outer); | 545 $str = stGetFormOptionListStart("ctrlEntryList", $indent, $outer); |
546 | 546 |
547 if (($res = stExecSQL($sql)) !== false) | 547 if (($res = stExecSQL($sql)) !== FALSE) |
548 { | 548 { |
549 foreach ($res as $item) | 549 foreach ($res as $item) |
550 { | 550 { |
551 $str .= stGetFormOptionListItem($indent." ", $item["show_id"], | 551 $str .= stGetFormOptionListItem($indent." ", $item["show_id"], |
552 ($item["show_id"] == $currShowID), | 552 ($item["show_id"] == $currShowID), |
570 "ORDER BY id DESC"; | 570 "ORDER BY id DESC"; |
571 | 571 |
572 $str = stGetFormOptionListStart("ctrlRotationLists", $indent, $outer); | 572 $str = stGetFormOptionListStart("ctrlRotationLists", $indent, $outer); |
573 $currListID = stGetDisplayVar("rotateList"); | 573 $currListID = stGetDisplayVar("rotateList"); |
574 | 574 |
575 if (($res = stExecSQL($sql)) !== false) | 575 if (($res = stExecSQL($sql)) !== FALSE) |
576 { | 576 { |
577 foreach ($res as $item) | 577 foreach ($res as $item) |
578 { | 578 { |
579 $str .= stGetFormOptionListItem($indent." ", $item["id"], | 579 $str .= stGetFormOptionListItem($indent." ", $item["id"], |
580 ($currListID == $item["id"]), | 580 ($currListID == $item["id"]), |
589 function stGetInfoDisplaySlides($indent, $outer) | 589 function stGetInfoDisplaySlides($indent, $outer) |
590 { | 590 { |
591 $str = stGetFormOptionListStart("ctrlDisplaySlides", $indent, $outer); | 591 $str = stGetFormOptionListStart("ctrlDisplaySlides", $indent, $outer); |
592 | 592 |
593 $sql = "SELECT * FROM display_slides ORDER BY id DESC"; | 593 $sql = "SELECT * FROM display_slides ORDER BY id DESC"; |
594 if (($res = stExecSQL($sql)) !== false) | 594 if (($res = stExecSQL($sql)) !== FALSE) |
595 { | 595 { |
596 foreach ($res as $item) | 596 foreach ($res as $item) |
597 $str .= stGetFormOptionListItem($indent." ", $item["id"], FALSE, $item["title"]); | 597 $str .= stGetFormOptionListItem($indent." ", $item["id"], FALSE, $item["title"]); |
598 } | 598 } |
599 | 599 |
602 | 602 |
603 | 603 |
604 function stGetInfoRotationListEditFull($indent, $outer, $list_id) | 604 function stGetInfoRotationListEditFull($indent, $outer, $list_id) |
605 { | 605 { |
606 $sql = stPrepareSQL("SELECT * FROM rot_list_data WHERE id=%d", $list_id); | 606 $sql = stPrepareSQL("SELECT * FROM rot_list_data WHERE id=%d", $list_id); |
607 if (($data = stFetchSQL($sql)) === false) | 607 if (($data = stFetchSQL($sql)) === FALSE) |
608 return "<p>No such rotation list ID #".intval($list_id)."</p>"; | 608 return "<p>No such rotation list ID #".intval($list_id)."</p>"; |
609 | 609 |
610 $str = | 610 $str = |
611 ($outer ? $indent."<div class=\"ctrlBox\" id=\"ctrlRotationListEdit\">\n" : ""). | 611 ($outer ? $indent."<div class=\"ctrlBox\" id=\"ctrlRotationListEdit\">\n" : ""). |
612 $indent." <div class=\"ctrlTitle\">Edit rotation list</div>\n". | 612 $indent." <div class=\"ctrlTitle\">Edit rotation list</div>\n". |
614 $indent." ".stGetFormButtonInput("updname", "", "", "Save", "updateRotationList(".$list_id.")")."\n". | 614 $indent." ".stGetFormButtonInput("updname", "", "", "Save", "updateRotationList(".$list_id.")")."\n". |
615 "<div>Available slides:</div>\n". | 615 "<div>Available slides:</div>\n". |
616 stGetFormOptionListStart("ctrlEDDisplaySlides", $indent." ", TRUE); | 616 stGetFormOptionListStart("ctrlEDDisplaySlides", $indent." ", TRUE); |
617 | 617 |
618 $sql = "SELECT * FROM display_slides"; | 618 $sql = "SELECT * FROM display_slides"; |
619 if (($res = stExecSQL($sql)) !== false) | 619 if (($res = stExecSQL($sql)) !== FALSE) |
620 { | 620 { |
621 foreach ($res as $item) | 621 foreach ($res as $item) |
622 $str .= stGetFormOptionListItem($indent." ", $item["id"], FALSE, $item["title"]); | 622 $str .= stGetFormOptionListItem($indent." ", $item["id"], FALSE, $item["title"]); |
623 } | 623 } |
624 | 624 |
648 "ORDER BY rot_list_slides.order_num DESC", | 648 "ORDER BY rot_list_slides.order_num DESC", |
649 $list_id); | 649 $list_id); |
650 | 650 |
651 $str = stGetFormOptionListStart("ctrlEDRotationList", $indent, $outer); | 651 $str = stGetFormOptionListStart("ctrlEDRotationList", $indent, $outer); |
652 | 652 |
653 if (($res = stExecSQL($sql)) !== false) | 653 if (($res = stExecSQL($sql)) !== FALSE) |
654 { | 654 { |
655 foreach ($res as $item) | 655 foreach ($res as $item) |
656 { | 656 { |
657 $str .= stGetFormOptionListItem($indent." ", $item["id"]."_".$item["order_num"], FALSE, $item["title"]); | 657 $str .= stGetFormOptionListItem($indent." ", $item["id"]."_".$item["order_num"], FALSE, $item["title"]); |
658 } | 658 } |
668 stGetDisplayVar("rotateList")); | 668 stGetDisplayVar("rotateList")); |
669 | 669 |
670 $str = $indent.($outer ? "<div id=\"ctrlActiveRotationList\">" : ""). | 670 $str = $indent.($outer ? "<div id=\"ctrlActiveRotationList\">" : ""). |
671 "<b>Active list:</b> "; | 671 "<b>Active list:</b> "; |
672 | 672 |
673 if (($slist = stFetchSQL($sql)) === false) | 673 if (($slist = stFetchSQL($sql)) === FALSE) |
674 $str .= "-"; | 674 $str .= "-"; |
675 else | 675 else |
676 $str .= chentities(substr($slist["name"], 0, 40)); | 676 $str .= chentities(substr($slist["name"], 0, 40)); |
677 | 677 |
678 return $str.($outer ? "</div>\n" : ""); | 678 return $str.($outer ? "</div>\n" : ""); |
687 ($outer ? "<div class=\"ctrlBox\" id=\"".$prefix."Edit\">\n" : ""). | 687 ($outer ? "<div class=\"ctrlBox\" id=\"".$prefix."Edit\">\n" : ""). |
688 $indent." <form method=\"post\" action=\"\" onsubmit=\"return updateDisplaySlide(".$slide_id.")\">\n". | 688 $indent." <form method=\"post\" action=\"\" onsubmit=\"return updateDisplaySlide(".$slide_id.")\">\n". |
689 $indent." <div class=\"ctrlTitle\">Edit display slide</div>\n"; | 689 $indent." <div class=\"ctrlTitle\">Edit display slide</div>\n"; |
690 | 690 |
691 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", $slide_id); | 691 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", $slide_id); |
692 if (($slide = stFetchSQL($sql)) !== false) | 692 if (($slide = stFetchSQL($sql)) !== FALSE) |
693 { | 693 { |
694 $str .= | 694 $str .= |
695 " ".stGetFormTextInput(40, SET_LEN_DISP_SLIDE_TITLE, "", "Title", $prefix, $slide["title"])."<br />\n". | 695 " ".stGetFormTextInput(40, SET_LEN_DISP_SLIDE_TITLE, "", "Title", $prefix, $slide["title"])."<br />\n". |
696 " ".stGetFormTextArea(10, 80, "", "Text", $prefix, $slide["text"])."<br />\n"; | 696 " ".stGetFormTextArea(10, 80, "", "Text", $prefix, $slide["text"])."<br />\n"; |
697 } | 697 } |
758 | 758 |
759 stDBBeginTransaction(); | 759 stDBBeginTransaction(); |
760 foreach ($final as $entry) | 760 foreach ($final as $entry) |
761 { | 761 { |
762 $sql = stPrepareSQL("UPDATE entries SET show_id=%d WHERE id=%d", $index, $entry); | 762 $sql = stPrepareSQL("UPDATE entries SET show_id=%d WHERE id=%d", $index, $entry); |
763 if (stExecSQL($sql) === false) | 763 if (stExecSQL($sql) === FALSE) |
764 { | 764 { |
765 stError("Error updating entry show positions."); | 765 stError("Error updating entry show positions."); |
766 break; | 766 break; |
767 } | 767 } |
768 $index++; | 768 $index++; |
887 | 887 |
888 // Count entries and compos | 888 // Count entries and compos |
889 $nentries = $ncompos = 0; | 889 $nentries = $ncompos = 0; |
890 foreach (stExecSQL("SELECT * FROM compos WHERE ctype=".COMPO_NORMAL) as $compo) | 890 foreach (stExecSQL("SELECT * FROM compos WHERE ctype=".COMPO_NORMAL) as $compo) |
891 { | 891 { |
892 if (($ne = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"])) !== false && $ne > 0) | 892 if (($ne = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"])) !== FALSE && $ne > 0) |
893 { | 893 { |
894 $nentries += $ne; | 894 $nentries += $ne; |
895 $ncompos++; | 895 $ncompos++; |
896 } | 896 } |
897 } | 897 } |
899 echo "<li>VOTING COMPOS: <b>".$nentries."</b> entries in <b>".$ncompos."</b> compos.</li>\n"; | 899 echo "<li>VOTING COMPOS: <b>".$nentries."</b> entries in <b>".$ncompos."</b> compos.</li>\n"; |
900 | 900 |
901 $nentries = $ncompos = 0; | 901 $nentries = $ncompos = 0; |
902 foreach (stExecSQL("SELECT * FROM compos WHERE ctype <> ".COMPO_NORMAL) as $compo) | 902 foreach (stExecSQL("SELECT * FROM compos WHERE ctype <> ".COMPO_NORMAL) as $compo) |
903 { | 903 { |
904 if (($ne = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"])) !== false && $ne > 0) | 904 if (($ne = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"])) !== FALSE && $ne > 0) |
905 { | 905 { |
906 $nentries += $ne; | 906 $nentries += $ne; |
907 $ncompos++; | 907 $ncompos++; |
908 } | 908 } |
909 } | 909 } |
951 break; | 951 break; |
952 | 952 |
953 case "setCompoID": | 953 case "setCompoID": |
954 if (stChkRequestItem("id", $compo_id, array(CHK_TYPE, VT_INT, "Invalid data."))) | 954 if (stChkRequestItem("id", $compo_id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
955 { | 955 { |
956 if (stFetchSQL("SELECT id FROM compos WHERE id=".$compo_id) === false) | 956 if (stFetchSQL("SELECT id FROM compos WHERE id=".$compo_id) === FALSE) |
957 stError("Invalid compo ID ".$compo_id); | 957 stError("Invalid compo ID ".$compo_id); |
958 else | 958 else |
959 { | 959 { |
960 stSetDisplayVarUpd("compoID", $compo_id); | 960 stSetDisplayVarUpd("compoID", $compo_id); |
961 stSetDisplayVar("compoCurrEntry", 0); | 961 stSetDisplayVar("compoCurrEntry", 0); |
1005 case "setTempSlide": | 1005 case "setTempSlide": |
1006 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && | 1006 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && |
1007 stChkRequestItem("duration", $slide_dur, array(CHK_RANGE, VT_INT, array(1, 60), "Invalid duration range, should be 1-60 min."))) | 1007 stChkRequestItem("duration", $slide_dur, array(CHK_RANGE, VT_INT, array(1, 60), "Invalid duration range, should be 1-60 min."))) |
1008 { | 1008 { |
1009 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", $slide_id); | 1009 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", $slide_id); |
1010 if (($slide = stFetchSQL($sql)) !== false) | 1010 if (($slide = stFetchSQL($sql)) !== FALSE) |
1011 { | 1011 { |
1012 stSetDisplayVar("tempDuration", $slide_dur); | 1012 stSetDisplayVar("tempDuration", $slide_dur); |
1013 stSetDisplayVar("tempSlide", $slide["id"]); | 1013 stSetDisplayVar("tempSlide", $slide["id"]); |
1014 stSetDisplayVar("tempSlideSet", TRUE); | 1014 stSetDisplayVar("tempSlideSet", TRUE); |
1015 echo "Temporary slide '".chentities($slide["title"])."' set for <b>".$slide_dur."</b> minutes."; | 1015 echo "Temporary slide '".chentities($slide["title"])."' set for <b>".$slide_dur."</b> minutes."; |
1030 | 1030 |
1031 case "copyDisplaySlide": | 1031 case "copyDisplaySlide": |
1032 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data."))) | 1032 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
1033 { | 1033 { |
1034 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", $slide_id); | 1034 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", $slide_id); |
1035 if (($slide = stFetchSQL($sql)) !== false) | 1035 if (($slide = stFetchSQL($sql)) !== FALSE) |
1036 { | 1036 { |
1037 $sql = stPrepareSQL("INSERT INTO display_slides (title,text) VALUES (%s,%s)", | 1037 $sql = stPrepareSQL("INSERT INTO display_slides (title,text) VALUES (%s,%s)", |
1038 $slide["title"]." (copy)", $slide["text"]); | 1038 $slide["title"]." (copy)", $slide["text"]); |
1039 | 1039 |
1040 if (($new_id = stExecSQLInsert($sql)) !== false) | 1040 if (($new_id = stExecSQLInsert($sql)) !== FALSE) |
1041 echo stGetInfoDisplaySlideEdit("", TRUE, $new_id); | 1041 echo stGetInfoDisplaySlideEdit("", TRUE, $new_id); |
1042 else | 1042 else |
1043 stError("Could not insert slide."); | 1043 stError("Could not insert slide."); |
1044 } | 1044 } |
1045 else | 1045 else |
1047 } | 1047 } |
1048 break; | 1048 break; |
1049 | 1049 |
1050 case "newDisplaySlide": | 1050 case "newDisplaySlide": |
1051 $sql = stPrepareSQL("INSERT INTO display_slides (title) VALUES (%s)", "New slide"); | 1051 $sql = stPrepareSQL("INSERT INTO display_slides (title) VALUES (%s)", "New slide"); |
1052 if (($slide_id = stExecSQLInsert($sql)) !== false) | 1052 if (($slide_id = stExecSQLInsert($sql)) !== FALSE) |
1053 echo stGetInfoDisplaySlideEdit("", TRUE, $slide_id); | 1053 echo stGetInfoDisplaySlideEdit("", TRUE, $slide_id); |
1054 break; | 1054 break; |
1055 | 1055 |
1056 case "updateDisplaySlide": | 1056 case "updateDisplaySlide": |
1057 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && | 1057 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && |
1068 array( | 1068 array( |
1069 "title" => "S", | 1069 "title" => "S", |
1070 "text" => "S", | 1070 "text" => "S", |
1071 )); | 1071 )); |
1072 | 1072 |
1073 if (stExecSQL($sql) !== false) | 1073 if (stExecSQL($sql) !== FALSE) |
1074 { | 1074 { |
1075 stSetStatus(200, "Slide updated."); | 1075 stSetStatus(200, "Slide updated."); |
1076 stDisplayUpdated(); | 1076 stDisplayUpdated(); |
1077 } | 1077 } |
1078 } | 1078 } |
1090 } | 1090 } |
1091 break; | 1091 break; |
1092 | 1092 |
1093 case "newRotationList": | 1093 case "newRotationList": |
1094 $sql = stPrepareSQL("INSERT INTO rot_list_data (name) VALUES (%s)", "New list #"); | 1094 $sql = stPrepareSQL("INSERT INTO rot_list_data (name) VALUES (%s)", "New list #"); |
1095 if (($list_id = stExecSQLInsert($sql)) !== false) | 1095 if (($list_id = stExecSQLInsert($sql)) !== FALSE) |
1096 { | 1096 { |
1097 $sql = stPrepareSQL("UPDATE rot_list_data SET name=%s WHERE id=%d", | 1097 $sql = stPrepareSQL("UPDATE rot_list_data SET name=%s WHERE id=%d", |
1098 "New list #".$list_id, $list_id); | 1098 "New list #".$list_id, $list_id); |
1099 | 1099 |
1100 if (stExecSQLCond($sql, "OK!") !== false) | 1100 if (stExecSQLCond($sql, "OK!") !== FALSE) |
1101 echo stGetInfoRotationListEditFull("", TRUE, $list_id); | 1101 echo stGetInfoRotationListEditFull("", TRUE, $list_id); |
1102 } | 1102 } |
1103 break; | 1103 break; |
1104 | 1104 |
1105 case "updateRotationList": | 1105 case "updateRotationList": |
1289 "GROUP BY compos.id ". | 1289 "GROUP BY compos.id ". |
1290 "HAVING COUNT(DISTINCT entries.id) > 0 AND compos.ctype=".COMPO_NORMAL." ". | 1290 "HAVING COUNT(DISTINCT entries.id) > 0 AND compos.ctype=".COMPO_NORMAL." ". |
1291 "ORDER BY compos.id DESC"; | 1291 "ORDER BY compos.id DESC"; |
1292 | 1292 |
1293 $currCompoID = stGetDisplayVar("compoID"); | 1293 $currCompoID = stGetDisplayVar("compoID"); |
1294 if (($res = stExecSQL($sql)) !== false) | 1294 if (($res = stExecSQL($sql)) !== FALSE) |
1295 { | 1295 { |
1296 foreach ($res as $item) | 1296 foreach ($res as $item) |
1297 { | 1297 { |
1298 echo stGetFormOptionListItem(" ", $item["id"], | 1298 echo stGetFormOptionListItem(" ", $item["id"], |
1299 ($item["id"] == $currCompoID), | 1299 ($item["id"] == $currCompoID), |
1444 if (($tmp = stGetSetting("maxAttendeesSoft")) > $numUsers) | 1444 if (($tmp = stGetSetting("maxAttendeesSoft")) > $numUsers) |
1445 $numUsers = $tmp; | 1445 $numUsers = $tmp; |
1446 | 1446 |
1447 while ($numVKeys <= $numUsers) | 1447 while ($numVKeys <= $numUsers) |
1448 { | 1448 { |
1449 if (($key = stGenerateUserKey()) !== false) | 1449 if (($key = stGenerateUserKey()) !== FALSE) |
1450 { | 1450 { |
1451 if (stExecSQL(stPrepareSQL("INSERT INTO userkeys (key) VALUES (%s)", $key)) !== false) | 1451 if (stExecSQL(stPrepareSQL("INSERT INTO userkeys (key) VALUES (%s)", $key)) !== FALSE) |
1452 $numVKeys++; | 1452 $numVKeys++; |
1453 } | 1453 } |
1454 } | 1454 } |
1455 | 1455 |
1456 // Some information | 1456 // Some information |
1627 { | 1627 { |
1628 $ne = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]); | 1628 $ne = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]); |
1629 if ($index++ > 0) echo ","; | 1629 if ($index++ > 0) echo ","; |
1630 echo | 1630 echo |
1631 "\"".$compo["id"]."\":\"".chentities($compo["name"]). | 1631 "\"".$compo["id"]."\":\"".chentities($compo["name"]). |
1632 (($ne !== false && $ne > 0) ? " <span class='cnotice'>(".$ne.")</span>" : "")."\""; | 1632 (($ne !== FALSE && $ne > 0) ? " <span class='cnotice'>(".$ne.")</span>" : "")."\""; |
1633 } | 1633 } |
1634 break; | 1634 break; |
1635 | 1635 |
1636 case "compovoting": | 1636 case "compovoting": |
1637 $id = intval(stGetRequestItem("id", 0)); | 1637 $id = intval(stGetRequestItem("id", 0)); |
1638 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false) | 1638 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== FALSE) |
1639 echo stGetCompoVoting($compo, FALSE); | 1639 echo stGetCompoVoting($compo, FALSE); |
1640 break; | 1640 break; |
1641 | 1641 |
1642 case "entries": | 1642 case "entries": |
1643 $id = intval(stGetRequestItem("id", 0)); | 1643 $id = intval(stGetRequestItem("id", 0)); |
1644 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false) | 1644 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== FALSE) |
1645 { | 1645 { |
1646 $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$id); | 1646 $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$id); |
1647 $prefix = "ne"; | 1647 $prefix = "ne"; |
1648 echo | 1648 echo |
1649 "<h1>#".$id." - ".chentities($compo["name"])." (".$nentries." entries)</h1>\n"; | 1649 "<h1>#".$id." - ".chentities($compo["name"])." (".$nentries." entries)</h1>\n"; |
1711 else | 1711 else |
1712 if ($type == "attendees") | 1712 if ($type == "attendees") |
1713 { | 1713 { |
1714 // Attendees require some more work | 1714 // Attendees require some more work |
1715 $sql = stPrepareSQL("SELECT * FROM attendees WHERE id=%d", $id); | 1715 $sql = stPrepareSQL("SELECT * FROM attendees WHERE id=%d", $id); |
1716 if (($attn = stFetchSQL($sql)) !== false) | 1716 if (($attn = stFetchSQL($sql)) !== FALSE) |
1717 { | 1717 { |
1718 $sql = stPrepareSQL("DELETE FROM attendees WHERE id=%d", $id); | 1718 $sql = stPrepareSQL("DELETE FROM attendees WHERE id=%d", $id); |
1719 stExecSQLCond($sql, "OK, attendee ".$id." deleted."); | 1719 stExecSQLCond($sql, "OK, attendee ".$id." deleted."); |
1720 | 1720 |
1721 // If assigned userkey mode, delete the key and votes as well | 1721 // If assigned userkey mode, delete the key and votes as well |
1867 } | 1867 } |
1868 else | 1868 else |
1869 if ($type == "compo") | 1869 if ($type == "compo") |
1870 { | 1870 { |
1871 // Check if compo ID exists | 1871 // Check if compo ID exists |
1872 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) === false) | 1872 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) === FALSE) |
1873 stError("No such compo ID."); | 1873 stError("No such compo ID."); |
1874 else | 1874 else |
1875 if (stValidateRequestCompoData(TRUE, $compo["ctype"])) | 1875 if (stValidateRequestCompoData(TRUE, $compo["ctype"])) |
1876 { | 1876 { |
1877 switch ($compo["ctype"]) | 1877 switch ($compo["ctype"]) |
1953 { | 1953 { |
1954 case "assign": | 1954 case "assign": |
1955 // Check if already assigned to someone .. | 1955 // Check if already assigned to someone .. |
1956 $key_id = intval(stGetRequestItem("key_id", 0)); | 1956 $key_id = intval(stGetRequestItem("key_id", 0)); |
1957 $sql = stPrepareSQL("SELECT * FROM userkeys WHERE id=%d", $key_id); | 1957 $sql = stPrepareSQL("SELECT * FROM userkeys WHERE id=%d", $key_id); |
1958 if (stFetchSQL($sql) === false) | 1958 if (stFetchSQL($sql) === FALSE) |
1959 stError("Invalid key ID #."); | 1959 stError("Invalid key ID #."); |
1960 else | 1960 else |
1961 { | 1961 { |
1962 $sql = stPrepareSQL("SELECT * FROM attendees WHERE key_id=%d", $key_id); | 1962 $sql = stPrepareSQL("SELECT * FROM attendees WHERE key_id=%d", $key_id); |
1963 if (($attn = stFetchSQL($sql)) !== false && $attn["id"] != $id) | 1963 if (($attn = stFetchSQL($sql)) !== FALSE && $attn["id"] != $id) |
1964 stError("That key has already been assigned to another attendee!"); | 1964 stError("That key has already been assigned to another attendee!"); |
1965 else | 1965 else |
1966 { | 1966 { |
1967 // Assign .. | 1967 // Assign .. |
1968 $sql = stPrepareSQL("UPDATE attendees SET key_id=%d WHERE id=%d", $key_id, $id); | 1968 $sql = stPrepareSQL("UPDATE attendees SET key_id=%d WHERE id=%d", $key_id, $id); |