Mercurial > hg > fapweb
comparison admajax.php @ 1052:fb5a468e647d
Implement compo voting enable/disable in entry pages.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 21 Nov 2015 17:01:59 +0200 |
parents | 178ed843b6c2 |
children | 86f6a6191749 |
comparison
equal
deleted
inserted
replaced
1051:78449511df14 | 1052:fb5a468e647d |
---|---|
222 "',".stGetSetting($type."MaxSize").", 'updateEntry(".$entry["compo_id"].",".$eid.", 1)')")."\n". | 222 "',".stGetSetting($type."MaxSize").", 'updateEntry(".$entry["compo_id"].",".$eid.", 1)')")."\n". |
223 " </form>\n"; | 223 " </form>\n"; |
224 } | 224 } |
225 | 225 |
226 return $str."</div>\n"; | 226 return $str."</div>\n"; |
227 } | |
228 | |
229 | |
230 function stGetCompoVoting($compo, $outer) | |
231 { | |
232 return | |
233 ($outer ? "<span id=\"covoting".$compo["id"]."\">" : ""). | |
234 stGetFormCheckBoxInput( | |
235 "votingbutton", $compo["id"], "co", $compo["voting"], "Voting ".($compo["voting"] ? "IS ACTIVE" : "disabled"), | |
236 "class=\"votingactive\" onChange=\"updateCompoVoting(".$compo["id"].")\"", ""). | |
237 ($outer ? "</span>" : ""); | |
227 } | 238 } |
228 | 239 |
229 | 240 |
230 function stPrintEntryItemData($item, $row, $tr, $prefix, $compo, $mode) | 241 function stPrintEntryItemData($item, $row, $tr, $prefix, $compo, $mode) |
231 { | 242 { |
1606 "\"".$compo["id"]."\":\"".chentities($compo["name"]). | 1617 "\"".$compo["id"]."\":\"".chentities($compo["name"]). |
1607 (($ne !== false && $ne > 0) ? " <span class='cnotice'>(".$ne.")</span>" : "")."\""; | 1618 (($ne !== false && $ne > 0) ? " <span class='cnotice'>(".$ne.")</span>" : "")."\""; |
1608 } | 1619 } |
1609 break; | 1620 break; |
1610 | 1621 |
1622 case "compovoting": | |
1623 $id = intval(stGetRequestItem("id", 0)); | |
1624 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false) | |
1625 echo stGetCompoVoting($compo, FALSE); | |
1626 break; | |
1627 | |
1611 case "entries": | 1628 case "entries": |
1612 $id = intval(stGetRequestItem("id", 0)); | 1629 $id = intval(stGetRequestItem("id", 0)); |
1613 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false) | 1630 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false) |
1614 { | 1631 { |
1615 $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$id); | 1632 $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$id); |
1619 | 1636 |
1620 if ($nentries > 0 && $compo["ctype"] == COMPO_NORMAL) | 1637 if ($nentries > 0 && $compo["ctype"] == COMPO_NORMAL) |
1621 { | 1638 { |
1622 echo | 1639 echo |
1623 stGetFormButtonInput("generate", "", "", " Add missing show positions ", "generateEntryPositions(".$id.", 1)")."\n". | 1640 stGetFormButtonInput("generate", "", "", " Add missing show positions ", "generateEntryPositions(".$id.", 1)")."\n". |
1624 stGetFormButtonInput("regenerate", "", "", " ReGenerate show positions ", "generateEntryPositions(".$id.", 0)")."\n"; | 1641 stGetFormButtonInput("regenerate", "", "", " ReGenerate show positions ", "generateEntryPositions(".$id.", 0)")."\n". |
1642 stGetCompoVoting($compo, TRUE)."\n"; | |
1625 } | 1643 } |
1626 | 1644 |
1627 stPrintEntryItemData(array( | 1645 stPrintEntryItemData(array( |
1628 "id" => $id, | 1646 "id" => $id, |
1629 "show_id" => 0, | 1647 "show_id" => 0, |
1820 stChkRequestItem("ctype", $compotype, | 1838 stChkRequestItem("ctype", $compotype, |
1821 array(CHK_RANGE, VT_INT, array(COMPO_NORMAL, COMPO_ASSIGN), "Invalid compo type.") | 1839 array(CHK_RANGE, VT_INT, array(COMPO_NORMAL, COMPO_ASSIGN), "Invalid compo type.") |
1822 )) | 1840 )) |
1823 { | 1841 { |
1824 $sql = stPrepareSQL("UPDATE compos SET ctype=%d WHERE id=%d", $compotype, $id); | 1842 $sql = stPrepareSQL("UPDATE compos SET ctype=%d WHERE id=%d", $compotype, $id); |
1843 stExecSQLCond($sql, "OK, compo updated."); | |
1844 } | |
1845 else | |
1846 if ($type == "compovoting" && | |
1847 stChkRequestItem("voting", $compovoting, $qres, | |
1848 array(CHK_TYPE, VT_BOOL, "Invalid data.") | |
1849 )) | |
1850 { | |
1851 $sql = stPrepareSQL("UPDATE compos SET voting=%b WHERE id=%d", $compovoting, $id); | |
1825 stExecSQLCond($sql, "OK, compo updated."); | 1852 stExecSQLCond($sql, "OK, compo updated."); |
1826 } | 1853 } |
1827 else | 1854 else |
1828 if ($type == "compo") | 1855 if ($type == "compo") |
1829 { | 1856 { |