This commit is contained in:
Nael 2014-03-15 22:50:15 +01:00
parent 2a18c523d5
commit 1acc2498c9
18 changed files with 128 additions and 17 deletions

View File

@ -163,7 +163,7 @@ class votes {
'SELECT * FROM `uvote_votes` WHERE `ID` = ?;',
array($poll_ID));
$res = $res->next();
$res['title'] = utf8_encode($res['title']);
// $res['title'] = utf8_encode($res['title']);
return $res;
}
@ -201,7 +201,7 @@ class votes {
public static function write_comment($poll_ID, $c_choice, $c_txt, $c_src){
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
throw new ERROR("You need to be logged in.");}
return \DBD\UVOTE_DATA_USER_COMMENT_INSERT::Q1(array($c_choice, $poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $c_txt, $c_src));}
return \DBD\UVOTE_DATA_USER_COMMENT_INSERT::Q1(array($c_choice, $poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, utf8_encode($c_txt), $c_src));}
public static function write_commentrate($c_ID, $val){
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
@ -211,8 +211,11 @@ class votes {
public static function get_add_data(){
return \DBD\UVOTE_DATA_USER_ADD_DATA::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id));
}
public static function write_poll($ID, $title, $iframe_link ){
return \DBD\UVOTE_DATA_NEW_POLL::Q1($ID, $title, $iframe_link);
public static function write_poll($ID, $title, $iframe_link ){
if ($ID == -1){
return \DBD\UVOTE_DATA_NEW_POLL::QI(array($title, $iframe_link));
}
return \DBD\UVOTE_DATA_UPDATE_POLL::QI(array($title, $iframe_link, $ID));
}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class UVOTE_ACCORD_WITH_FRACTION extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT uvote_votes.*
FROM uvote_votes
WHERE ID IN (SELECT poll_ID FROM uvote_votes_per_party WHERE party = ?
AND choice = ?);'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace DBD;
class UVOTE_DATA_ALL_VOTES extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT COUNT(*) FROM uvote_data;'
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class UVOTE_DATA_BT_INSERT extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'INSERT INTO uvote_votes_per_party
(poll_ID, party, votes_pro, votes_contra, nr_attending, total, choice)
VALUES (?, ?, ?, ?, ?, ?, ?);'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace DBD;
class UVOTE_DATA_CHOICE_BT_OVERALL extends \SYSTEM\DB\QQ {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT COUNT(*) as "count", bt_choice FROM uvote_votes GROUP BY bt_choice;'
);}}

View File

@ -1,12 +1,12 @@
<?php
namespace DBD;
class UVOTE_DATA_USER_COMMENT_INSERT extends \SYSTEM\DB\QP {
class UVOTE_DATA_NEW_POLL extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'INSERT INTO `uvote_votes` (`ID`, `title`, `iframe_link`)
VALUES (?, ?, ?);'
'INSERT INTO `uvote_votes` (`title`, `iframe_link`)
VALUES (?, ?);'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace DBD;
class UVOTE_DATA_PARTY_CHOICE_PER_POLL extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT `choice` FROM `uvote_votes_per_party` WHERE `poll_ID` = ? AND `party` = ?;'
);}}

View File

@ -0,0 +1,12 @@
<?php
namespace DBD;
class UVOTE_DATA_UPDATE_POLL extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'UPDATE `uvote_votes` SET `title` = ?, `iframe_link` = ?
WHERE ID = ?;'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace DBD;
class UVOTE_DATA_USER_COUNT_CHOICE_PER_POLL extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT COUNT(*) AS count FROM uvote_data WHERE `poll_ID` = ?;'
);}}

View File

@ -0,0 +1,11 @@
<?php
namespace DBD;
class UVOTE_DATA_USER_COUNT_USERS extends \SYSTEM\DB\QQ {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT COUNT(*) AS count FROM system_user;'
);}}

View File

@ -0,0 +1,2 @@
SELECT SUM(CASE WHEN uvote_data.user_ID = 15 THEN 1 ELSE 0 END) as voted,
SUM(CASE WHEN uvote_data.user_ID = 15 THEN 0 ELSE 1 END) as not_voted FROM uvote_data RIGHT JOIN uvote_votes ON ( uvote_data.poll_ID = uvote_votes.ID AND uvote_data.user_ID = 15);

View File

@ -64,7 +64,7 @@ class default_bulletin extends SYSTEM\PAGE\Page {
$com['count_up'] = $rating['count'];
$rating2 = votes::get_commentrate($com['c_ID'], 2);
$com['count_down'] = $rating2['count'];
$com['c_txt'] = utf8_encode($com['c_txt']);
// $com['c_txt'] = utf8_encode($com['c_txt']);
$result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/comment.tpl'), $com);
}
return $result;
@ -79,7 +79,7 @@ class default_bulletin extends SYSTEM\PAGE\Page {
$com['count_up'] = $rating['count'];
$rating2 = votes::get_commentrate($com['c_ID'], 2);
$com['count_down'] = $rating2['count'];
$com['c_txt'] = utf8_encode($com['c_txt']);
// $com['c_txt'] = utf8_encode($com['c_txt']);
$result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/comment.tpl'), $com);
}
return $result;

View File

@ -0,0 +1,4 @@
<div style="margin-top: 20px;">
Dein aktuelles Stimmgewicht bei dieser Abstimmung:
<span class="badge badge-info">${voteweight}%</span>
</div>

View File

@ -225,8 +225,16 @@ function submit_commentrate (c_ID, val) {
});
}
function encode_utf8(c) {
return unescape(encodeURIComponent(c));
}
function decode_utf8(c) {
return decodeURIComponent(escape(c));
}
function submit_c_data (poll_ID) {
var c_txt = $("#c_txt_pro").val();
var c = $("#c_txt_pro").val();
var c_src = $("#c_src_pro").val();
var a = document.getElementById("side_select");
var c_choice = a.options[a.selectedIndex].value;

View File

@ -48,7 +48,7 @@ class user_list_active extends SYSTEM\PAGE\Page {
$time_span = strtotime($vote['time_end']) - strtotime($vote['time_start']);
$vote_count = votes::get_count_user_votes_per_poll($vote['ID']);
$vote['title'] = utf8_encode($vote['title']);
// $vote['title'] = utf8_encode($vote['title']);
$vote['time_left'] = round($time_remain/($time_span+1)*100,0);
$vote['time_done'] = 100-$vote['time_left'];

View File

@ -2,7 +2,7 @@ function init_saimod_uvote_vote_edit(){
$('.btn_editvote').click(function() {
alert ('');
var poll_ID = $('#input_poll_ID').val();
var poll_ID = $('#input_poll_title').attr('poll_ID');
var title = $('#input_poll_title').val();
var iframe_link = $('#input_poll_link').val();
vote_data_edit(poll_ID, title, iframe_link);
@ -33,7 +33,7 @@ function init_saimod_uvote_vote_edit(){
function vote_data_edit (poll_ID, title, iframe_link) {
alert('vote_data_edit');
$.getJSON('./api.php?call=vote&action=new_vote&poll_ID=' + poll_ID + 'title=' + title + '&iframe_link=' + iframe_link, function(data) {
$.getJSON('./api.php?call=vote&action=new_vote&poll_ID=' + poll_ID + '&title=' + title + '&iframe_link=' + iframe_link, function(data) {
var items = [];
if(data.status == true){
alert("success");

View File

@ -28,6 +28,7 @@ class saimod_uvote_vote_edit extends \SYSTEM\SAI\SaiModule {
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/main.tpl', $vars);*/
$result = '';
// $result.=self::sai_mod_saimod_uvote_new_vote();
$votes = votes::getAllVotesOfGroup(1);
foreach($votes as $vote){
$time_remain = strtotime($vote['time_end'])- microtime(true);
@ -60,5 +61,6 @@ class saimod_uvote_vote_edit extends \SYSTEM\SAI\SaiModule {
public static function sai_mod_saimod_uvote_vote_edit_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array(
\SYSTEM\WEBPATH(new PSAI(),'saimod_uvote_vote_edit/saimod_uvote_vote_edit.js')
));}
public static function sai_mod_saimod_uvote_vote_edit_flag_css(){return \SYSTEM\LOG\JsonResult::toString(array()
);}
}

View File

@ -1,8 +1,7 @@
<tr style="border: solid lightgray 1px;">
<td style="padding: 5px;">
<input id="input_poll_title" type="text" placeholder="${title}" style="width: 500px;">
<input id="input_poll_link" type="text" placeholder="Link" style="width: 500px;">
<input id="input_poll_id" type="text" placeholder="ID" style="">
<input id="input_poll_title" poll_ID="${ID}" type="text" value="${title}" style="width: 500px;">
<input id="input_poll_link" type="text" value="${iframe_link}" style="width: 500px;">
</td>
<td>
Nr.${ID}