@uvote cleaned api and split it into several logical purpose orientated files
This commit is contained in:
parent
3ff3f4ddb6
commit
769fe98f8e
@ -1,60 +1,41 @@
|
||||
<?php
|
||||
|
||||
class api_uvote extends \SYSTEM\API\api_login {
|
||||
class api_uvote extends \SYSTEM\API\api_system {
|
||||
//votes
|
||||
public static function call_vote_action_vote($poll_ID, $vote) {
|
||||
return votes::write_vote($poll_ID, $vote);
|
||||
return votes::write_vote($poll_ID, $vote);}
|
||||
|
||||
}
|
||||
public static function call_vote_action_data($location, $birthyear, $gender, $children) {
|
||||
return votes::write_data($location, $birthyear, $gender, $children);
|
||||
|
||||
}
|
||||
|
||||
public static function call_vote_action_comment($poll_ID, $c_choice, $c_txt, $c_src) {
|
||||
return votes::write_comment($poll_ID, $c_choice, $c_txt, $c_src);
|
||||
|
||||
}
|
||||
|
||||
public static function call_vote_action_commentrate($c_ID, $val) {
|
||||
return votes::write_commentrate($c_ID, $val);
|
||||
|
||||
}
|
||||
public static function call_vote_action_data($location, $birthyear, $gender, $children) {
|
||||
return votes::write_data($location, $birthyear, $gender, $children);}
|
||||
|
||||
public static function call_vote_action_new_vote($ID, $title, $iframe_link) {
|
||||
return votes::write_poll($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);
|
||||
|
||||
}
|
||||
return votes::write_feedback($feedback);}
|
||||
|
||||
public static function call_vote_action_open_vote($poll_ID) {
|
||||
return votes::open_vote($poll_ID);
|
||||
return votes::open_vote($poll_ID);}
|
||||
|
||||
}
|
||||
public static function call_vote_action_barsperusers($poll_ID){
|
||||
return votes::get_barsperusers($poll_ID);}
|
||||
|
||||
|
||||
public static function call_img($cat, $id){
|
||||
return \SYSTEM\IMG\img::get($cat, $id);
|
||||
|
||||
}
|
||||
return votes::get_barsperusers($poll_ID);}
|
||||
|
||||
public static function call_vote_action_submit($poll_ID) {
|
||||
return votes::vote_submit($poll_ID);
|
||||
|
||||
}
|
||||
|
||||
return votes::vote_submit($poll_ID);}
|
||||
public static function call_vote_action_accord($party){
|
||||
return votes::vote_accord_with_party($party);
|
||||
}
|
||||
return votes::vote_accord_with_party($party);}
|
||||
|
||||
//graphs
|
||||
public static function call_graph_bt_to_uvote_overall_by_time($timespan = 84600){
|
||||
return votes::get_graph_bt_to_uvote_overall_by_time($timespan);}
|
||||
return graphs::graph_bt_to_uvote_overall_by_time($timespan);}
|
||||
|
||||
public static function call_graph_bt_to_user_overall_by_time($timespan = 84600){
|
||||
return votes::get_graph_bt_to_user_overall_by_time($timespan);}
|
||||
return graphs::graph_bt_to_user_overall_by_time($timespan);}
|
||||
|
||||
//comments
|
||||
public static function call_vote_action_comment($poll_ID, $c_choice, $c_txt, $c_src) {
|
||||
return comments::write_comment($poll_ID, $c_choice, $c_txt, $c_src);}
|
||||
|
||||
public static function call_vote_action_commentrate($c_ID, $val) {
|
||||
return comments::write_commentrate($c_ID, $val);}
|
||||
}
|
||||
|
||||
22
uVote/api/votes/comments.php
Normal file
22
uVote/api/votes/comments.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class comments {
|
||||
public static function getUserComments($poll_ID, $c_choice){
|
||||
return \DBD\UVOTE_GENERATE_COMMENTS_PER_POLL::QA(array($poll_ID, $c_choice));}
|
||||
|
||||
public static function insertUserComment($c_choice, $poll_ID, $user_ID, $c_txt, $c_src, $timestamp){
|
||||
return \DBD\UVOTE_DATA_USER_COMMENT_INSERT::QI(array($c_choice, $poll_ID, $user_ID, $c_txt, $c_src, $timestamp));}
|
||||
|
||||
public static function get_commentrate($c_ID, $val){
|
||||
return \DBD\UVOTE_DATA_USER_COMMENTRATE_PER_COMMENT::Q1(array($c_ID, $val));}
|
||||
|
||||
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, utf8_encode($c_txt), $c_src));}
|
||||
|
||||
public static function write_commentrate($c_ID, $val){
|
||||
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
|
||||
throw new ERROR("You need to be logged in.");}
|
||||
return \DBD\UVOTE_DATA_USER_COMMENTRATE_INSERT::Q1(array($c_ID, \SYSTEM\SECURITY\Security::getUser()->id, $val, $c_ID, \SYSTEM\SECURITY\Security::getUser()->id, $val));}
|
||||
}
|
||||
27
uVote/api/votes/graphs.php
Normal file
27
uVote/api/votes/graphs.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class graphs {
|
||||
|
||||
public static function graph_bt_to_uvote_overall_by_time ($timespan = 84600,$returnasjson = true){
|
||||
$result = array();
|
||||
$res = \DBD\UVOTE_DATA_GRAPH_BT_TO_UVOTE_OVERALL_BY_TIME::QQ(array($timespan));
|
||||
while ($row = $res->next()){
|
||||
$result[] = array( 0 => $row['day'],
|
||||
'match' => $row['class_match'] > 0 ? round($row['class_match'] / ($row['class_match']+$row['class_mismatch']),2) : 0,
|
||||
'mismatch' => $row['class_match'] > 0 ? round($row['class_mismatch'] / ($row['class_match']+$row['class_mismatch']),2) : 0);
|
||||
}
|
||||
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
|
||||
}
|
||||
|
||||
public static function graph_bt_to_user_overall_by_time ($timespan = 84600,$returnasjson = true){
|
||||
$result = array();
|
||||
$res = \DBD\UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id));
|
||||
while ($row = $res->next()){
|
||||
$result[] = array( 0 => $row['day'],
|
||||
'class_match' => $row['class_match'] / ($row['class_match']+$row['class_mismatch']+1),
|
||||
'class_mismatch' => $row['class_mismatch'] / ($row['class_match']+$row['class_mismatch']+1));
|
||||
}
|
||||
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
|
||||
}
|
||||
|
||||
}
|
||||
13
uVote/api/votes/should_be_in_backend.php
Normal file
13
uVote/api/votes/should_be_in_backend.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class should_be_in_backend {
|
||||
public static function insertPartyChoice($poll_ID, $party, $votes_pro, $votes_contra, $nr_attending, $total, $choice){
|
||||
return \DBD\UVOTE_GENERATE_VOTELIST::QI(array($poll_ID, $party, $votes_pro, $votes_contra, $nr_attending, $total, $choice));}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
@ -1,55 +1,15 @@
|
||||
<?php
|
||||
|
||||
class votes {
|
||||
|
||||
public static function get_graph_bt_to_uvote_overall_by_time ($timespan = 84600,$returnasjson = true){
|
||||
$result = array();
|
||||
$res = \DBD\UVOTE_DATA_GRAPH_BT_TO_UVOTE_OVERALL_BY_TIME::QQ(array($timespan));
|
||||
while ($row = $res->next()){
|
||||
$result[] = array( 0 => $row['day'],
|
||||
'match' => $row['class_match'] > 0 ? round($row['class_match'] / ($row['class_match']+$row['class_mismatch']),2) : 0,
|
||||
'mismatch' => $row['class_match'] > 0 ? round($row['class_mismatch'] / ($row['class_match']+$row['class_mismatch']),2) : 0);
|
||||
}
|
||||
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
|
||||
}
|
||||
|
||||
public static function get_graph_bt_to_user_overall_by_time ($timespan = 84600,$returnasjson = true){
|
||||
$result = array();
|
||||
$res = \DBD\UVOTE_DATA_GRAPH_BT_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id));
|
||||
while ($row = $res->next()){
|
||||
$result[] = array( 0 => $row['day'],
|
||||
'class_match' => $row['class_match'] / ($row['class_match']+$row['class_mismatch']+1),
|
||||
'class_mismatch' => $row['class_mismatch'] / ($row['class_match']+$row['class_mismatch']+1));
|
||||
}
|
||||
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
|
||||
}
|
||||
|
||||
public static function getAllVotesOfGroup($groupid){
|
||||
return \DBD\UVOTE_GENERATE_VOTELIST::QA(array($groupid));}
|
||||
|
||||
public static function getAllExpVotesOfGroup($groupid){
|
||||
return \DBD\UVOTE_GENERATE_VOTELIST_EXP::QA(array($groupid));}
|
||||
|
||||
public static function getUserComments($poll_ID, $c_choice){
|
||||
return \DBD\UVOTE_GENERATE_COMMENTS_PER_POLL::QA(array($poll_ID, $c_choice));}
|
||||
return \DBD\UVOTE_GENERATE_VOTELIST_EXP::QA(array($groupid));}
|
||||
|
||||
public static function countAllPolls(){
|
||||
$res = \DBD\UVOTE_DATA_COUNT_VOTES::QQ();
|
||||
return $res;}
|
||||
|
||||
public static function insertPartyChoice($poll_ID, $party, $votes_pro, $votes_contra, $nr_attending, $total, $choice){
|
||||
return \DBD\UVOTE_GENERATE_VOTELIST::QI(array($poll_ID, $party, $votes_pro, $votes_contra, $nr_attending, $total, $choice));}
|
||||
|
||||
public static function insertUserComment($c_choice, $poll_ID, $user_ID, $c_txt, $c_src, $timestamp){
|
||||
return \DBD\UVOTE_DATA_USER_COMMENT_INSERT::QI(array($c_choice, $poll_ID, $user_ID, $c_txt, $c_src, $timestamp));}
|
||||
/*public static function getVoteOfGroup($poll_ID){
|
||||
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
|
||||
$res = $con->prepare( 'selVoteByGrp',
|
||||
'SELECT * FROM `uvote_votes` WHERE `ID` = ? LIMIT 1;',
|
||||
array($poll_ID));
|
||||
$result = $res->next();
|
||||
return $result;
|
||||
}*/
|
||||
return $res;}
|
||||
|
||||
public static function get_user_choice_per_poll($poll_ID, $user_ID){
|
||||
return \DBD\UVOTE_DATA_USER_CHOICE_PER_POLL::Q1(array($poll_ID, $user_ID));
|
||||
@ -122,10 +82,7 @@ class votes {
|
||||
return \DBD\UVOTE_DATA_BT_PER_POLL::Q1(array($poll_ID));}
|
||||
|
||||
public static function get_user_count(){
|
||||
return \DBD\UVOTE_DATA_USER_COUNT_USERS::Q1(array());}
|
||||
|
||||
public static function get_commentrate($c_ID, $val){
|
||||
return \DBD\UVOTE_DATA_USER_COMMENTRATE_PER_COMMENT::Q1(array($c_ID, $val));}
|
||||
return \DBD\UVOTE_DATA_USER_COUNT_USERS::Q1(array());}
|
||||
|
||||
public static function get_count_user_votes_per_poll($poll_ID){
|
||||
return \DBD\UVOTE_DATA_USER_COUNT_CHOICE_PER_POLL::Q1(array($poll_ID));}
|
||||
@ -194,28 +151,11 @@ class votes {
|
||||
public static function write_data($location, $birthyear, $gender, $children){
|
||||
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
|
||||
throw new ERROR("You need to be logged in.");}
|
||||
return \DBD\UVOTE_DATA_USER_ADD_DATA_INSERT::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, $location, $birthyear, $gender, $children, \SYSTEM\SECURITY\Security::getUser()->id, $location, $birthyear, $gender, $children));}
|
||||
|
||||
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, utf8_encode($c_txt), $c_src));}
|
||||
|
||||
public static function write_commentrate($c_ID, $val){
|
||||
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
|
||||
throw new ERROR("You need to be logged in.");}
|
||||
return \DBD\UVOTE_DATA_USER_COMMENTRATE_INSERT::Q1(array($c_ID, \SYSTEM\SECURITY\Security::getUser()->id, $val, $c_ID, \SYSTEM\SECURITY\Security::getUser()->id, $val));}
|
||||
return \DBD\UVOTE_DATA_USER_ADD_DATA_INSERT::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, $location, $birthyear, $gender, $children, \SYSTEM\SECURITY\Security::getUser()->id, $location, $birthyear, $gender, $children));}
|
||||
|
||||
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 ){
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function write_feedback($feedback){
|
||||
$feedback = json_decode($feedback);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user