comparison msite.inc.php @ 1092:95b74632cfe2

Rename votekeys table to userkeys, and all related variables and settings.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 26 Jan 2017 13:38:19 +0200
parents 00632d30bafe
children 0a2117349f46
comparison
equal deleted inserted replaced
1091:c4b93729269d 1092:95b74632cfe2
38 38
39 define("SET_LEN_DISP_SLIDE_TITLE", 64); 39 define("SET_LEN_DISP_SLIDE_TITLE", 64);
40 define("SET_LEN_DISP_SLIDE_TEXT", 4096); 40 define("SET_LEN_DISP_SLIDE_TEXT", 4096);
41 define("SET_LEN_ROT_LIST_NAME", 128); 41 define("SET_LEN_ROT_LIST_NAME", 128);
42 42
43 define("SET_LEN_VOTEKEY", 64); 43 define("SET_LEN_USERKEY", 64);
44 44
45 45
46 // 46 //
47 // File format classes 47 // File format classes
48 // 48 //
117 define("VOTE_ACTIVATE", 1); 117 define("VOTE_ACTIVATE", 1);
118 define("VOTE_ASSIGN", 2); 118 define("VOTE_ASSIGN", 2);
119 119
120 $voteModeData = array( 120 $voteModeData = array(
121 VOTE_FREELY => array("Freeform voting", 121 VOTE_FREELY => array("Freeform voting",
122 "Vote keys are not tied to attendees, and do not need to be activated. ". 122 "User keys are not tied to attendees, and do not need to be activated. ".
123 "Take one printed key slip, give it to attendee." 123 "Take one printed key slip, give it to attendee."
124 ), 124 ),
125 VOTE_ACTIVATE => array("Key activation", 125 VOTE_ACTIVATE => array("Key activation",
126 "Vote keys are not tied to attendees, but require manual activation. ". 126 "User keys are not tied to attendees, but require manual activation. ".
127 "Take one printed key slip, find it by the index number in the list below, set to activated. ". 127 "Take one printed key slip, find it by the index number in the list below, set to activated. ".
128 "Give key slip to attendee." 128 "Give key slip to attendee."
129 ), 129 ),
130 VOTE_ASSIGN => array("Assigned keys", 130 VOTE_ASSIGN => array("Assigned keys",
131 "Votekeys are tied to attendees, activated by assigning the key to attendee. ". 131 "User keys are tied to attendees, activated by assigning the key to attendee. ".
132 "Take one printed key slip, find attendee in the list below, enter key ID number, assign, check. ". 132 "Take one printed key slip, find attendee in the list below, enter key ID number, assign, check. ".
133 "Give key slip to attendee." 133 "Give key slip to attendee."
134 ), 134 ),
135 ); 135 );
136 136
575 $key .= $keyChars[rand() % strlen($keyChars)]; 575 $key .= $keyChars[rand() % strlen($keyChars)];
576 576
577 // Check if it already exists, to avoid duplicates 577 // Check if it already exists, to avoid duplicates
578 // We need custom query code here, because stFetchSQLColumn() 578 // We need custom query code here, because stFetchSQLColumn()
579 // won't work due to it returning FALSE in error cases. 579 // won't work due to it returning FALSE in error cases.
580 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE key=%s", $key); 580 $sql = stPrepareSQL("SELECT * FROM userkeys WHERE key=%s", $key);
581 if (($res = @$db->query($sql)) !== FALSE) 581 if (($res = @$db->query($sql)) !== FALSE)
582 { 582 {
583 // Did we get results? 583 // Did we get results?
584 if ($res->fetchColumn() === FALSE) 584 if ($res->fetchColumn() === FALSE)
585 { 585 {
716 716
717 case VOTE_ACTIVATE: 717 case VOTE_ACTIVATE:
718 $sql = 718 $sql =
719 "SELECT entries.*, ". 719 "SELECT entries.*, ".
720 "(SELECT SUM(votes.value) FROM votes ". 720 "(SELECT SUM(votes.value) FROM votes ".
721 "LEFT JOIN votekeys ON votes.key_id=votekeys.id ". 721 "LEFT JOIN userkeys ON votes.key_id=userkeys.id ".
722 "WHERE votes.entry_id=entries.id AND votekeys.active<>0) ". 722 "WHERE votes.entry_id=entries.id AND userkeys.active<>0) ".
723 "AS votesum ". 723 "AS votesum ".
724 "FROM entries"; 724 "FROM entries";
725 break; 725 break;
726 726
727 case VOTE_ASSIGN: 727 case VOTE_ASSIGN:
728 $sql = 728 $sql =
729 "SELECT entries.*, ". 729 "SELECT entries.*, ".
730 "(SELECT SUM(votes.value) FROM votes ". 730 "(SELECT SUM(votes.value) FROM votes ".
731 "LEFT JOIN votekeys ON votes.key_id=votekeys.id ". 731 "LEFT JOIN userkeys ON votes.key_id=userkeys.id ".
732 "LEFT JOIN attendees ON votekeys.id=attendees.key_id ". 732 "LEFT JOIN attendees ON userkeys.id=attendees.key_id ".
733 "WHERE votes.entry_id=entries.id AND attendees.key_id<>0) ". 733 "WHERE votes.entry_id=entries.id AND attendees.key_id<>0) ".
734 "AS votesum ". 734 "AS votesum ".
735 "FROM entries"; 735 "FROM entries";
736 break; 736 break;
737 } 737 }
765 } 765 }
766 766
767 767
768 function stGetCompoResults($flags) 768 function stGetCompoResults($flags)
769 { 769 {
770 $voteKeyMode = stGetSetting("voteKeyMode"); 770 $userKeyMode = stGetSetting("userKeyMode");
771 $out = array(); 771 $out = array();
772 $sql = "SELECT * FROM compos ".(($flags & RFLAG_HIDDEN_COMPOS) ? "" : "WHERE visible<>0 ")."ORDER BY name DESC"; 772 $sql = "SELECT * FROM compos ".(($flags & RFLAG_HIDDEN_COMPOS) ? "" : "WHERE visible<>0 ")."ORDER BY name DESC";
773 if (($res = stExecSQL($sql)) === false) 773 if (($res = stExecSQL($sql)) === false)
774 return $out; 774 return $out;
775 775
784 784
785 if (($nentries = stFetchSQLColumn($sql)) !== FALSE && 785 if (($nentries = stFetchSQLColumn($sql)) !== FALSE &&
786 ($nentries > 0 || ($flags & RFLAG_HIDDEN_COMPOS))) 786 ($nentries > 0 || ($flags & RFLAG_HIDDEN_COMPOS)))
787 { 787 {
788 // Get voting results by mode 788 // Get voting results by mode
789 $sql = stGetCompoResultsSQL($voteKeyMode, $compo, $flags); 789 $sql = stGetCompoResultsSQL($userKeyMode, $compo, $flags);
790 790
791 $out[$compo["id"]] = $compo; 791 $out[$compo["id"]] = $compo;
792 $out[$compo["id"]]["results"] = array(); 792 $out[$compo["id"]]["results"] = array();
793 $prev = FALSE; 793 $prev = FALSE;
794 $index = 0; 794 $index = 0;