diff --git a/uVote/api/api_uvote.php b/uVote/api/api_uvote.php index 896f912..8af9c52 100644 --- a/uVote/api/api_uvote.php +++ b/uVote/api/api_uvote.php @@ -6,6 +6,11 @@ class api_uvote extends \SYSTEM\API\api_login { } + public static function call_vote_action_new_vote($ID, $title, $iframe_link) { + return votes::write_poll($ID, $title, $iframe_link); + + } + public static function call_vote_action_feedback($feedback) { return votes::write_feedback($feedback); diff --git a/uVote/api/votes/votes.php b/uVote/api/votes/votes.php index bbfcccf..2b472f5 100644 --- a/uVote/api/votes/votes.php +++ b/uVote/api/votes/votes.php @@ -61,6 +61,13 @@ class votes { return $return_as_json ? JsonResult::toString($result) : $result; } + public static function get_all_votes(){ + $res = \DBD\UVOTE_DATA_ALL_VOTES::Q1(); + $votes = mysql_query($res); + $result = mysql_num_rows($votes); + return $result; + } + public static function get_bar_bt_per_poll($poll_ID){ return \DBD\UVOTE_DATA_BT_PER_POLL::Q1(array($poll_ID));} @@ -98,6 +105,15 @@ class votes { return JsonResult::ok(); } + public static function write_poll($ID, $title, $iframe_link ){ + $con = new \SYSTEM\DB\Connection(new \DBD\uVote()); + $res = $con->prepare( 'insertPoll', + 'INSERT INTO uvote_votes + VALUES (?, ?, ?);', + array($ID, $title, $iframe_link)); + return JsonResult::ok(); + } + public static function write_feedback($feedback){ if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ throw new ERROR("You need to be logged in.");} diff --git a/uVote/page/default_page/full_vote.tpl b/uVote/page/default_page/full_vote.tpl index d32513d..77a95af 100644 --- a/uVote/page/default_page/full_vote.tpl +++ b/uVote/page/default_page/full_vote.tpl @@ -1,8 +1,7 @@
-

${title}

- +
diff --git a/uVote/page/user_main/user_main.php b/uVote/page/user_main/user_main.php index 88347b7..bfd927f 100644 --- a/uVote/page/user_main/user_main.php +++ b/uVote/page/user_main/user_main.php @@ -3,8 +3,16 @@ class user_main extends SYSTEM\PAGE\Page { public function get_main_uVote(){ return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_uVote/uVote.tpl'), array());} + + private static function user_all_votes(){ + $result = ''; + $res = votes::get_all_votes($result); + return $result; + } public function html(){ + $vars = array(); +// $vars['votes_all'] = $this->user_all_votes(); $vars['uVote'] = $this->get_main_uVote(); $vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id='; return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main/main_menu.tpl'),$vars); diff --git a/uVote/page/user_main_uVote/uVote.tpl b/uVote/page/user_main_uVote/uVote.tpl index 769a703..c96d41d 100644 --- a/uVote/page/user_main_uVote/uVote.tpl +++ b/uVote/page/user_main_uVote/uVote.tpl @@ -1,3 +1,4 @@ +${votes_all}

diff --git a/uVote/page/user_main_uVote/user_main_uVote.php b/uVote/page/user_main_uVote/user_main_uVote.php index 91d53ef..291fcdc 100644 --- a/uVote/page/user_main_uVote/user_main_uVote.php +++ b/uVote/page/user_main_uVote/user_main_uVote.php @@ -14,12 +14,17 @@ class user_main_uVote extends SYSTEM\PAGE\Page { return $pbpp; } + private static function user_all_votes(){ + $res = votes::get_all_votes(); + return $res; + } + public function html(){ $poll_data = array(); $poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(1)); $poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(2)); $poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(3)); - $vars['votes_overall'] = $this->votes_overall(); + $vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id='; return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_uVote/uVote.tpl'),$vars); } diff --git a/uVote/sai/saimod_uvote_vote_edit/main.tpl b/uVote/sai/saimod_uvote_vote_edit/main.tpl index b54e856..fcfac14 100644 --- a/uVote/sai/saimod_uvote_vote_edit/main.tpl +++ b/uVote/sai/saimod_uvote_vote_edit/main.tpl @@ -1,8 +1,9 @@ +

-

Eingebracht durch

+ @@ -42,7 +43,7 @@

poll end

- 00:00 -
+
Submit \ No newline at end of file diff --git a/uVote/sai/saimod_uvote_vote_edit/saimod_uvote_vote_edit.js b/uVote/sai/saimod_uvote_vote_edit/saimod_uvote_vote_edit.js index bb0aadc..f954963 100644 --- a/uVote/sai/saimod_uvote_vote_edit/saimod_uvote_vote_edit.js +++ b/uVote/sai/saimod_uvote_vote_edit/saimod_uvote_vote_edit.js @@ -1,28 +1,38 @@ function init_saimod_uvote_vote_edit(){ -$('#vote_data_submit').click(function() { - var data = new Array(); - alert("bla") - $.ajax({ - url: SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_uvote_vote_edit&action='+ vote, - contentType : "application/json; charset=utf-8", - vote : JSON.stringify({ - sai_mod: 'saimod_uvote_vote_edit', - action: 'new_vote', - json: data, - }), - dataType : 'json', - type : 'POST' , - success: function(vote) { - alert("success"); - }}); - alert("js läuft"); + + $('#vote_data_submit').click(function() { + alert ('bla'); + vote_data_edit(array( + $('#vote_title').val(title), + $('#iframe_link').val(iframe_link), + $('#poll_ID').val(poll_ID) + )); + alert (''); + + +// var data = new Array(); +// alert("bla") +// $.ajax({ +// url: SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_uvote_vote_edit&action='+ vote, +// contentType : "application/json; charset=utf-8", +// vote : JSON.stringify({ +// sai_mod: 'saimod_uvote_vote_edit', +// action: 'new_vote', +// json: data, +// }), +// dataType : 'json', +// type : 'POST' , +// success: function(vote) { +// alert("success"); +// }}); +// alert("js läuft"); })}; -function vote_data_edit (poll_ID, vote) { - $.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID, function(data) { +function vote_data_edit (poll_ID, title, iframe_link) { + $.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + 'title=' + title + '&iframe_link=' + iframe_link, function(data) { var items = []; if(data.status == true){ alert("success");