diff --git a/uvote/api/votes/votes.php b/uvote/api/votes/votes.php index 12b5d70..319e8d9 100644 --- a/uvote/api/votes/votes.php +++ b/uvote/api/votes/votes.php @@ -131,16 +131,10 @@ class votes { } public static function write_vote($poll_ID, $vote){ - if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ - throw new ERROR("You need to be logged in.");} - $con = new \SYSTEM\DB\Connection(new \SQL\uVote()); $res = $con->prepare( 'selVote', - 'SELECT * FROM `uvote_votes` WHERE `ID` = ? AND time_end < CURDATE();', - array($poll_ID)); - if ($res->next()){ - throw new ERROR('Your rights have expired!');} - + 'SELECT * FROM `uvote_votes` WHERE `ID` = ?;', + array($poll_ID)); $res = $con->prepare( 'insertVote', 'REPLACE uvote_data VALUES (?, ?, ?, 0, NOW());', diff --git a/uvote/page/autoload.inc b/uvote/page/autoload.inc index fcecc93..f7129ac 100644 --- a/uvote/page/autoload.inc +++ b/uvote/page/autoload.inc @@ -2,13 +2,15 @@ SYSTEM\autoload::registerFolder(dirname(__FILE__),''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_page',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_register',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_bulletin',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_comment',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_uVote',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_urVote',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_myVote',''); + +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_votelist',''); +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_analysis',''); +SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_options',''); SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_poll',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list_active',''); -SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list_ended',''); + + +//SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list_ended',''); +//SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main',''); +//SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_uVote',''); +//SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list',''); \ No newline at end of file diff --git a/uvote/page/default_bulletin/css/bars_user.css b/uvote/page/default_bulletin/css/bars_user.css deleted file mode 100644 index 513c5aa..0000000 --- a/uvote/page/default_bulletin/css/bars_user.css +++ /dev/null @@ -1,4 +0,0 @@ -.progress#progress_bars_user { - height: 20px; - width: 350px; -} \ No newline at end of file diff --git a/uvote/page/default_bulletin/css/bulletin.css b/uvote/page/default_bulletin/css/bulletin.css deleted file mode 100644 index 1cb78e3..0000000 --- a/uvote/page/default_bulletin/css/bulletin.css +++ /dev/null @@ -1,48 +0,0 @@ -#bulletin_main { - float: left; - width: 100%; -} - -#bulletin_left { - float: left; -} - -#bulletin_sub1 { - margin-top: 30px; -} - -#bulletin_sub2 { - float: left; - width: 50%; - padding-top: 30px; -} - -#bulletin_sub3 { - float: right; - width: 50%; - padding-top: 30px; -} -#divider { - clear: both; -} - -#bulletin_sub4 { - padding-top: 30px; -} -#bulletin_sub5 { - padding-top: 20px; -} - -#bulletin_sub5_sub { - float: left; - width: 40%; -} - - #bulletin_sub6 { - float: right; - width: 40%; - } - - #bulletin_sub7 { - clear: both; - } \ No newline at end of file diff --git a/uvote/page/default_bulletin/css/comment.css b/uvote/page/default_bulletin/css/comment.css deleted file mode 100644 index 125793f..0000000 --- a/uvote/page/default_bulletin/css/comment.css +++ /dev/null @@ -1,22 +0,0 @@ -#comment_main { - float: left; - width: 90%; -} - -#comment_sub1 { - float: left; - font-size: 1; -} - -#comment_sub2 { - clear: both; -} - -#comment_sub3 { - font-size: 2; -} - -#comment_sub4 { - float: right; - font-size: 1; -} \ No newline at end of file diff --git a/uvote/page/default_bulletin/default_bulletin.php b/uvote/page/default_bulletin/default_bulletin.php deleted file mode 100644 index 15fb5c7..0000000 --- a/uvote/page/default_bulletin/default_bulletin.php +++ /dev/null @@ -1,242 +0,0 @@ -poll_ID=$poll_ID;} - - public function vote_choice(){ - $vars = votes::getUserPollData($this->poll_ID); - return $this->tablerow_class($vars); - } - - private static function tablerow_class($choice){ - switch($choice){ - case 1: - return 'pro'; - case 2: - return 'con'; - case 3: - return 'ent'; - default: - return 'open'; - } - } - - private function get_party_per_poll($choice){ - switch($choice){ - case 1: - return 'PRO'; - case 2: - return 'CON'; - case 3: - return 'ENT'; - default: - return 'NONE'; - } - } - - private function choice_party (){ - $result = ''; - $party_votes = votes::get_barsperparty($this->poll_ID); - -// $vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']); - foreach($party_votes as $pv){ - - $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/vote_bt.tpl'), - array( 'party' => $pv['party'], - 'choice' => $this->get_party_per_poll($pv['choice']), - 'choice_class' => $this->tablerow_class($pv['choice']), - 'party_yes' => $pv['votes_pro'] > 0 ? round($pv['votes_pro']/$pv['total']*100,0) : $pv['votes_pro'], - 'party_no' => $pv['votes_contra'] > 0 ? round($pv['votes_contra']/$pv['total']*100,0) : $pv['votes_contra'], - 'party_off' => $pv['total'] > 0 ? round(($pv['total'] - $pv['nr_attending'])/$pv['total']*100,0) : $pv['total'], - 'party_ent' => $pv['nr_attending'] > 0 ? round(($pv['nr_attending'] - $pv['votes_pro'] - $pv['votes_contra'])/$pv['nr_attending']*100,0) : $pv['nr_attending'])); - } - return $result; - } - - private function get_pro_comments (){ - $result = ''; - /*$vars = votes::getUserComments($this->poll_ID, 1); - - foreach($vars as $com){ - $rating = votes::get_commentrate($com['c_ID'], 1); - $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']); - $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/comment.tpl'), $com); - }*/ - return $result; - - } - private function get_con_comments (){ - $result = ''; - /*$vars = votes::getUserComments($this->poll_ID, 2); - - foreach($vars as $com){ - $rating = votes::get_commentrate($com['c_ID'], 1); - $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']); - $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/comment.tpl'), $com); - }*/ - return $result; - - } - private function bars_user(){ - $bars = votes::get_barsperusers($this->poll_ID,false); - $bars['vote_yes_perc'] = round($bars['yes_perc']*100,0); - $bars['vote_no_perc'] = round($bars['no_perc']*100,0); - $bars['vote_ent_perc'] = round($bars['ent_perc']*100,0); - $bars['title'] = 'Gemessen auf uVote'; - return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/bars_user.tpl'),$bars); - } - - private function bars_party(){ - $partyvotes = votes::get_barsperparty($this->poll_ID); - - $result = ""; - foreach($partyvotes as $vote){ - $vote['party_yes'] = $vote['votes_pro'] > 0 ? round($vote['votes_pro']/$vote['total']*100,0) : $vote['votes_pro']; - $vote['party_no'] = $vote['votes_contra'] > 0 ? round($vote['votes_contra']/$vote['total']*100,0) : $vote['votes_contra']; - $vote['party_ent'] = $vote['nr_attending'] > 0 ? round(($vote['nr_attending'] - $vote['votes_pro'] - $vote['votes_contra'])/$vote['total']*100,0) : $vote['nr_attending']; - $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/table_parties.tpl'), $vote); - } - - return $result; - } - - private function icons_party(){ - $vars = votes::get_bar_bt_per_poll($this->poll_ID); - if (!$vars['bt_total']){ - return '';} - $info = array(); - return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/icons_table_parties.tpl'), $info); - } - - private function bars_bt(){ - $vars = votes::get_bar_bt_per_poll($this->poll_ID); - if (!$vars['bt_total']){ - return 'Keine Ergebnisse für den Bundestag verfügbar';} - $vars['bt_ent'] = round(($vars['bt_attending'] - $vars['bt_pro'] - $vars['bt_con'])/$vars['bt_total']*100,0); - $vars['bt_pro'] = round($vars['bt_pro']/$vars['bt_total']*100,0); - $vars['bt_con'] = round($vars['bt_con']/$vars['bt_total']*100,0); - return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/table_bt.tpl'), $vars); - } - - private function voice_weight(){ - $vars = votes::get_count_user_votes_per_poll($this->poll_ID); - $vars['voteweight'] = $vars['count'] ? round(1/$vars['count']*100) : 'no votes'; - return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/voteweight.tpl'), $vars); - } - - private function p_fields (){ - $result = ""; - - $list = array (array(1, 'Aussenpolitik'), - array(2, 'Aussenpolitik'), - array(4, 'Aussenpolitik'), - array(8, 'Aussenpolitik')); - foreach($list as $l){ - if($p_fields & $l[0]) $result .= $l[1]; - } - return $result; - } - - private function vote_buttons($poll_expired,$user_poll){ - if($poll_expired){ - if(!$user_poll){ - return '
Stimme hier ab
- Pro - Contra - Enthaltung';} - $classes = array('','',''); - switch($user_poll){ - case 1: $classes = array('btn-success disabled','btn-danger','btn-info'); break; - case 2: $classes = array('btn-success','btn-danger disabled','btn-info'); break; - case 3: $classes = array('btn-success','btn-danger','btn-info disabled'); break; - default: array('','',''); - } - - return '
Ändere deine Stimme hier ab
- Pro - Contra - Enthaltung - '; - } else { - return 'ye soon to come infos'; - } - } - - private function js(){ - return \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin/js/vote.js'));} - private function css(){ - return \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin\css\bars_user.css')). - \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin\css\bulletin.css')). - \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_bulletin\css\comment.css')); - } - - - - public function html(){ - $poll_expired = \SQL\UVOTE_POLL_EXPIRED::Q1(array($this->poll_ID)); - $user_vote = votes::getUserPollData($this->poll_ID); - - $vars = array(); - $vars['choice_party'] = ''; - $vars['voice_weight'] = $vars['bars_user'] = $vars['bars_bt'] = ''; - $vars['bars_party'] = ''; - $vars['icons_party'] = ''; - $vars['vote_class'] = $this->vote_choice(); - $vars['comments_pro'] = ''; - $vars['comments_con'] = ''; - $vars['js'] = $this->js(); - $vars['css'] = $this->css(); - - $vars['vote_buttons'] = $this->vote_buttons($poll_expired,$user_vote); -// $vars['p_fields'] = $this->p_fields(); - if($user_vote){ - $vars['comments_pro'] = $this->get_pro_comments(); - $vars['comments_con'] = $this->get_con_comments(); - $vars['icons_party'] = $this->icons_party(); - $vars['choice_party'] = $this->choice_party(); - $vars['bars_party'] = $this->bars_party(); - $vars['bars_user'] = $this->bars_user(); - $vars['bars_bt'] = $this->bars_bt(); - $vars['voice_weight'] = $this->voice_weight(); - } - - $vars['poll_ID'] = $this->poll_ID; //put it here - so its filled in! - $vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=files&cat=frontend_logos&id='; - $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote_register')); - $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote')); - - $vars = array_merge($vars,votes::get_voteinfo($this->poll_ID)); - return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/tpl/bulletin.tpl'),$vars); - } - -} \ No newline at end of file diff --git a/uvote/page/default_bulletin/tpl/bulletin.tpl b/uvote/page/default_bulletin/tpl/bulletin.tpl deleted file mode 100644 index 1c6a945..0000000 --- a/uvote/page/default_bulletin/tpl/bulletin.tpl +++ /dev/null @@ -1,58 +0,0 @@ -
-

${title}

- ${vote_buttons} -
- -
-
- ${openvote_help_text} - ${title} - ${openvote_help_text1} -
-
- ${voice_weight} -
-
- ${bars_user}
- ${bars_bt} -
-
- ${icons_party} - ${choice_party} -
-
-
-
-

Kommentare

-
-
-
Pro
- ${comments_pro} -
-
-
Contra
- ${comments_con} -
-
-
-
- Kommentar
-
- Quelle
-
-
-
${submit}
-
-
- - - - -
\ No newline at end of file diff --git a/uvote/page/default_page/css/vote.css b/uvote/page/default_page/css/vote.css index a73fddb..7ab7d22 100644 --- a/uvote/page/default_page/css/vote.css +++ b/uvote/page/default_page/css/vote.css @@ -1,9 +1,7 @@ #vote_main { - margin-bottom: 5px; + padding: 5px; width: 100%; - min-height: 125px; - border: solid lightgray 1px; - background: beige; + border: solid lightgray 3px; } #vote_sub1 { diff --git a/uvote/page/default_page/default_page.php b/uvote/page/default_page/default_page.php index 9b193b7..112fd12 100644 --- a/uvote/page/default_page/default_page.php +++ b/uvote/page/default_page/default_page.php @@ -25,111 +25,8 @@ class default_page extends SYSTEM\PAGE\Page { \SYSTEM\HTML\html::link(\SYSTEM\WEBPATH(new \PPAGE(),'default_page/css/loginform.css')) ; } - private function get_party_per_poll($choice){ - switch($choice){ - case 1: - return 'PRO'; - case 2: - return 'CON'; - case 3: - return 'ENT'; - default: - return 'NONE'; - } - } - - private static function tablerow_class($choice){ - switch($choice){ - case 1: - return 'pro'; - case 2: - return 'con'; - case 3: - return 'ent'; - default: - return 'open'; - } - } - - private static function badge_class($choice){ - switch($choice){ - case 1: - return 'badge-success'; - case 2: - return 'badge-important'; - case 3: - return 'badge-info'; - default: - return ''; - } - } - - public static function panel_class($choice){ - switch($choice){ - case 1: - return 'panel-success'; - case 2: - return 'panel-danger'; - case 3: - return 'panel-info'; - default: - return 'panel-default'; - } - } - - public function generate_votelist(){ - $result = array('',''); - $votes = votes::getAllVotesOfGroup(1); - foreach($votes as $vote){ - $time_remain = strtotime($vote['time_end'])- microtime(true); - $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['time_left'] = round($time_remain/($time_span+1)*100,0); - $vote['time_done'] = 100-$vote['time_left']; - - $vote['full_vote_btn'] = $time_remain > 0 ? 'Abstimmen' : 'Ansehen'; - $vote['uv'] = $vote['bt'] = ''; - $vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5'; - - $user_vote = votes::getUserPollData($vote['ID']); - $vote['vote_class'] = $this->tablerow_class($user_vote); - if($user_vote){ - //user vote - $vote['vote_class'] = $this->tablerow_class($user_vote); - //bt vote - $party_votes = votes::get_barsperparty($vote['ID']); - $vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']); - foreach($party_votes as $pv){ - $vote['bt'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/vote_bt.tpl'), - array( 'party' => $pv['party'], - 'choice' => $this->get_party_per_poll($pv['choice']), - 'choice_class' => $this->badge_class($pv['choice']))); - } - - //uvote vote - $uvote = votes::get_users_choice_per_poll($vote['ID']); - $vote['uv_vote_class'] = count($uvote) > 0 ? $this->tablerow_class($uvote[0]['choice']) : ''; - foreach($uvote as $v){ - $vote['uv'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/vote_uv.tpl'), - array( 'badge' => self::badge_class($v['choice']), - 'perc' => $v['count'] > 0 ? round($v['count']/$vote_count['count']*100, 2) : 0)); - } - } - - //new panels: - $vote['panel_class'] = self::panel_class($user_vote); - - if($time_remain > 0){ - $result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/vote.tpl'), $vote); - } else { - $result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/vote.tpl'), $vote); - } - } - return $result[0].$result[1]; - } + public function getloggedinform(){ return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/loggedinform.tpl'),array());} diff --git a/uvote/page/default_page/js/loadtexts.js b/uvote/page/default_page/js/loadtexts.js index 8aeb6b4..883dee7 100644 --- a/uvote/page/default_page/js/loadtexts.js +++ b/uvote/page/default_page/js/loadtexts.js @@ -62,7 +62,7 @@ function get_barsperparty (poll_ID) { } function vote_click (poll_ID, vote) { - $.getJSON('./api.php?call=vote&page=vote&poll_ID=' + poll_ID + '&vote=' + vote, function(data) { + $.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + '&vote=' + vote, function(data) { var items = []; if(data.status == true){ alert("success"); diff --git a/uvote/page/default_page/tpl/page.tpl b/uvote/page/default_page/tpl/page.tpl index 5c02c9f..b0f0678 100644 --- a/uvote/page/default_page/tpl/page.tpl +++ b/uvote/page/default_page/tpl/page.tpl @@ -34,7 +34,8 @@ -