Beispiel #1
0
 function addConnectionVotes($con)
 {
     $votesObj = getVotes($con->connid);
     if (!$votesObj instanceof Error) {
         $posvotes = $votesObj->positivevoteslist;
         $negvotes = $votesObj->negativevoteslist;
         $count = count($posvotes);
         for ($i = 0; $i < $count; $i++) {
             $vote = $posvotes[$i];
             $id = $vote->id;
             $type = $vote->type;
             $date = $vote->date;
             $moddate = $this->timestampToISO($date);
             $userid = $vote->userid;
             $pseudo_id = $this->getPseudonym($userid);
             if (in_array($userid, $this->checkUsers) === FALSE) {
                 $user = getUser($userid);
                 $this->addUser($user);
                 array_push($this->checkUsers, $userid);
             }
             $this->dataGraphStr .= '{';
             $this->dataGraphStr .= '"@type": "BinaryVote",';
             $this->dataGraphStr .= '"@id": "' . $this->site . ':votes/' . $id . '_' . $pseudo_id . '",';
             $this->dataGraphStr .= '"voter": "' . $this->site . ':users/' . $pseudo_id . '",';
             //pseudo
             $this->dataGraphStr .= '"created": "' . $moddate . '",';
             $this->dataGraphStr .= '"positive": "true",';
             $this->dataGraphStr .= '"vote_subject_link": "' . $this->site . ':connections/' . $id . '"';
             $this->dataGraphStr .= '},';
         }
         $count = count($negvotes);
         for ($i = 0; $i < $count; $i++) {
             $vote = $negvotes[$i];
             $id = $vote->id;
             $type = $vote->type;
             $date = $vote->date;
             $userid = $vote->userid;
             $moddate = $this->timestampToISO($date);
             $userid = $vote->userid;
             $pseudo_id = $this->getPseudonym($userid);
             if (in_array($userid, $this->checkUsers) === FALSE) {
                 $user = getUser($userid);
                 $this->addUser($user);
                 array_push($this->checkUsers, $userid);
             }
             $this->dataGraphStr .= '{';
             $this->dataGraphStr .= '"@type": "BinaryVote",';
             $this->dataGraphStr .= '"@id": "' . $this->site . ':votes/' . $id . '_' . $pseudo_id . '",';
             $this->dataGraphStr .= '"voter": "' . $this->site . ':users/' . $pseudo_id . '",';
             //pseudo
             $this->dataGraphStr .= '"created": "' . $moddate . '",';
             $this->dataGraphStr .= '"positive": "false",';
             $this->dataGraphStr .= '"vote_subject_link": "' . $this->site . ':connections/' . $id . '"';
             $this->dataGraphStr .= '},';
         }
     }
 }
Beispiel #2
0
$success = FALSE;
$errorMessage = '';
$students = array();
$studentCategories = array();
$teachers = array();
$teacherCategories = array();
$studentCouple1 = 0;
$studentCouple2 = 0;
if (isset($_POST['publicId']) && isset($_POST['voteCode'])) {
    $publicId = strip_tags($_POST['publicId']);
    $accountId = getAccountId($publicId, '');
    $voteCode = strip_tags($_POST['voteCode']);
    if ($accountId !== FALSE) {
        $voteCodeId = checkVoteCode($voteCode, $accountId);
        if ($voteCodeId) {
            $votes = getVotes($voteCodeId);
            $students = getNames('student', $accountId);
            $studentCategories = getCategories('student', $accountId, $votes);
            $teachers = getNames('teacher', $accountId);
            $teacherCategories = getCategories('teacher', $accountId, $votes);
            $pdos = $GLOBALS['pdo']->prepare('
					SELECT
						`Couple1`, `Couple2`
					FROM
						`CoupleVote`
					WHERE
						`VoteCode` = :voteCode
				');
            $pdos->bindValue(':voteCode', $voteCodeId);
            $pdos->execute();
            $result = $pdos->fetch();
function pullRating($id, $show5 = false, $showPerc = false, $showVotes = false, $static = NULL)
{
    // Check if they have already voted...
    $text = '';
    $sel = mysql_query("SELECT id FROM ratings WHERE ip = '" . $_SERVER['REMOTE_ADDR'] . "' AND beer_id = '{$id}'");
    if (mysql_num_rows($sel) > 0 || $static == 'novote' || isset($_COOKIE['has_voted_' . $id])) {
        if ($show5 || $showPerc || $showVotes) {
            $text .= '<div class="rated_text">';
        }
        if ($show5) {
            $text .= 'Rated <span id="outOfFive_' . $id . '" class="out5Class">' . outOfFive($id) . '</span>/5';
        }
        if ($showPerc) {
            $text .= ' (<span id="percentage_' . $id . '" class="percentClass">' . getRating($id) . '</span>)';
        }
        if ($showVotes) {
            $text .= ' (<span id="showvotes_' . $id . '" class="votesClass">' . getVotes($id) . '</span>)';
        }
        if ($show5 || $showPerc || $showVotes) {
            $text .= '</div>';
        }
        return $text . '
			<ul class="star-rating2" id="rater_' . $id . '">
				<li class="current-rating" style="width:' . getRating($id) . ';" id="ul_' . $id . '"></li>
				<li><a onclick="return false;" href="#" title="1 star out of 5" class="one-star" >1</a></li>
				<li><a onclick="return false;" href="#" title="2 stars out of 5" class="two-stars">2</a></li>
				<li><a onclick="return false;" href="#" title="3 stars out of 5" class="three-stars">3</a></li>
				<li><a onclick="return false;" href="#" title="4 stars out of 5" class="four-stars">4</a></li>
				<li><a onclick="return false;" href="#" title="5 stars out of 5" class="five-stars">5</a></li>
			</ul>
			<div id="loading_' . $id . '"></div>';
    } else {
        if ($show5 || $showPerc || $showVotes) {
            $text .= '<div class="rated_text">';
        }
        if ($show5) {
            $show5bool = 'true';
            $text .= 'Rated <span id="outOfFive_' . $id . '" class="out5Class">' . outOfFive($id) . '</span>/5';
        } else {
            $show5bool = 'false';
        }
        if ($showPerc) {
            $showPercbool = 'true';
            $text .= ' (<span id="percentage_' . $id . '" class="percentClass">' . getRating($id) . '</span>)';
        } else {
            $showPercbool = 'false';
        }
        if ($showVotes) {
            $showVotesbool = 'true';
            $text .= ' (<span id="showvotes_' . $id . '" class="votesClass">' . getVotes($id) . '</span>)';
        } else {
            $showVotesbool = 'false';
        }
        if ($show5 || $showPerc || $showVotes) {
            $text .= '</div>';
        }
        return $text . '
			<ul class="star-rating" id="rater_' . $id . '">
				<li class="current-rating" style="width:' . getRating($id) . ';" id="ul_' . $id . '"></li>
				<li><a onclick="rate(\'1\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?id=' . $id . '&rating=1" title="1 star out of 5" class="one-star" >1</a></li>
				<li><a onclick="rate(\'2\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?id=' . $id . '&rating=2" title="2 stars out of 5" class="two-stars">2</a></li>
				<li><a onclick="rate(\'3\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?id=' . $id . '&rating=3" title="3 stars out of 5" class="three-stars">3</a></li>
				<li><a onclick="rate(\'4\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?id=' . $id . '&rating=4" title="4 stars out of 5" class="four-stars">4</a></li>
				<li><a onclick="rate(\'5\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?id=' . $id . '&rating=5" title="5 stars out of 5" class="five-stars">5</a></li>
			</ul>
			<div id="loading_' . $id . '"></div>';
    }
}
Beispiel #4
0
 /**
  * Loads the data for the node from the database
  *
  * @param String $style (optional - default 'long') may be 'short' or 'long' or 'mini' or 'full' or 'shortactivity' (mini used for graphs)
  * 'mini' include the base information like name, description, role, user, private, creation and modifications dates, connectedness, image, thumb.
  * 'short' includes 'mini' plus address information, start and end date, otherconnections, userfollow.
  * 'long' includes 'short' and associated website objects, tag objects, group onjects, votes, view counts and extra properties.
  * 'full' includes 'long' and all activity and voting data. This is likely to be very heavy. Use wisely.
  * 'shortactivity' includes 'short' plus the activity and voting data.
  * 'cif' just what is needed for cif.
  * @return Node object (this)
  */
 function load($style = 'long')
 {
     global $DB, $CFG, $USER, $ERROR, $HUB_FLM, $HUB_SQL;
     try {
         $this->canview();
     } catch (Exception $e) {
         return access_denied_error();
     }
     $this->style = $style;
     $params = array();
     $params[0] = $this->nodeid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_NODE_SELECT, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count == 0) {
             $ERROR = new error();
             $ERROR->createNodeNotFoundError($this->nodeid);
             return $ERROR;
         } else {
             for ($i = 0; $i < $count; $i++) {
                 $array = $resArray[$i];
                 $this->name = stripslashes(trim($array['Name']));
                 $this->creationdate = $array['CreationDate'];
                 $this->modificationdate = $array['ModificationDate'];
                 if (isset($array['NodeTypeID'])) {
                     $this->role = new Role($array['NodeTypeID']);
                     $this->role = $this->role->load();
                 }
                 if (trim($array['Description']) != "") {
                     $this->hasdesc = true;
                 }
                 if ($style == 'long' || $style == 'cif') {
                     $this->description = stripslashes(trim($array['Description']));
                 }
                 $this->users = array();
                 if ($style == 'cif') {
                     //CIF does not need the whole user info at present
                     // or just userid at this level?
                     $this->users[0] = new User($array['UserID']);
                 } else {
                     $maps = getMapsForNode($this->nodeid, 0, 0);
                     $this->mapcount = $maps->totalno;
                     $this->connectedness = $array['connectedness'];
                     $this->private = $array['Private'];
                     $this->users[0] = getUser($array['UserID'], $style);
                     if ($array['Image']) {
                         $this->filename = $array['Image'];
                         $imagedir = $HUB_FLM->getUploadsNodeDir($this->nodeid, $array['UserID']);
                         $originalphotopath = $HUB_FLM->createUploadsDirPath($imagedir . "/" . stripslashes($array['Image']));
                         if (file_exists($originalphotopath)) {
                             $this->image = $HUB_FLM->getUploadsWebPath($imagedir . "/" . stripslashes($array['Image']));
                             $this->thumb = $HUB_FLM->getUploadsWebPath($imagedir . "/" . str_replace('.', '_thumb.', stripslashes($array['Image'])));
                             if (!file_exists($this->thumb)) {
                                 create_image_thumb($array['Image'], $CFG->IMAGE_THUMB_WIDTH, $imagedir);
                             }
                         } else {
                             if ($this->role->name == 'Map') {
                                 $this->image = $HUB_FLM->getUploadsWebPath($CFG->DEFAULT_ISSUE_PHOTO);
                                 $this->thumb = $HUB_FLM->getUploadsWebPath(str_replace('.', '_thumb.', stripslashes($CFG->DEFAULT_ISSUE_PHOTO)));
                             }
                         }
                     } else {
                         if ($this->role->name == 'Map') {
                             $this->image = $HUB_FLM->getUploadsWebPath($CFG->DEFAULT_ISSUE_PHOTO);
                             $this->thumb = $HUB_FLM->getUploadsWebPath(str_replace('.', '_thumb.', stripslashes($CFG->DEFAULT_ISSUE_PHOTO)));
                         }
                     }
                     //if(isset($array['Image'])){
                     //    $this->imageurlid = $array['Image'];
                     //}
                     //if(isset($array['ImageThumbnail'])){
                     //    $this->thum = $array['ImageThumbnail'];
                     //}
                     if ($style != 'mini') {
                         if (isset($array['StartDate']) && $array['StartDate'] != 0) {
                             $this->startdatetime = $array['StartDate'];
                         }
                         if (isset($array['EndDate']) && $array['EndDate'] != 0) {
                             $this->enddatetime = $array['EndDate'];
                         }
                         if (isset($array['LocationText'])) {
                             $this->location = $array['LocationText'];
                         } else {
                             $this->location = '';
                         }
                         if (isset($array['LocationCountry'])) {
                             $cs = getCountryList();
                             $this->countrycode = $array['LocationCountry'];
                             if (isset($cs[$array['LocationCountry']])) {
                                 $this->country = $cs[$array['LocationCountry']];
                             }
                         }
                         if (isset($array['LocationLat'])) {
                             $this->locationlat = $array['LocationLat'];
                         }
                         if (isset($array['LocationLng'])) {
                             $this->locationlng = $array['LocationLng'];
                         }
                         if (isset($array['LocationAddress1'])) {
                             $this->locationaddress1 = $array['LocationAddress1'];
                         }
                         if (isset($array['LocationAddress2'])) {
                             $this->locationaddress2 = $array['LocationAddress2'];
                         }
                         if (isset($array['LocationPostCode'])) {
                             $this->locationpostcode = $array['LocationPostCode'];
                         }
                         if (isset($array['AdditionalIdentifier'])) {
                             $this->identifier = $array['AdditionalIdentifier'];
                         }
                         if (isset($array['CurrentStatus'])) {
                             $this->status = $array['CurrentStatus'];
                         }
                     }
                 }
             }
         }
     } else {
         return database_error();
     }
     $currentuser = '';
     if (isset($USER->userid)) {
         $currentuser = $USER->userid;
     }
     if ($style != 'mini' && $style != 'cif') {
         $params = array();
         $params[0] = $this->nodeid;
         $params[1] = $this->nodeid;
         $params[2] = $currentuser;
         $resArray = $DB->select($HUB_SQL->DATAMODEL_NODE_EXTERNAL_CONNECTIONS, $params);
         if ($resArray !== false) {
             if (count($resArray) > 0) {
                 $this->otheruserconnections = $resArray[0]['connectedness'];
             } else {
                 $this->otheruserconnections = 0;
             }
         }
         $this->userfollow = "N";
         //load the current user's following status for this node if any
         $params = array();
         $params[0] = $currentuser;
         $params[1] = $this->nodeid;
         $resArray = $DB->select($HUB_SQL->DATAMODEL_NODE_USER_FOLLOW, $params);
         if ($resArray !== false) {
             if (count($resArray) > 0) {
                 $this->userfollow = "Y";
             }
         }
     }
     if ($style == 'long' || $style == 'full' || $style == 'cif') {
         $this->loadWebsites($style);
     }
     if ($style == 'long' || $style == 'full') {
         $this->loadTags();
         $this->loadGroups();
         $this->loadVotes();
         $this->loadProperties();
         $this->loadViewCount();
     }
     if ($style == 'full' || $style == 'shortactivity') {
         $this->activity = getAllNodeActivity($this->nodeid, 0, 0, -1);
         $this->votes = getVotes($this->nodeid);
     }
     //load comments, pro count and con count if Solution.
     /*if ($this->role->name == "Solution") {
     			$this->haschildren = 'N';
     			$conSetKids = getConnectionsByNode($this->nodeid,0,0,'date','ASC', 'all', '', 'Pro,Con,Comment');
     			if (!$conSetKids instanceof Error) {
     				if ($conSetKids->totalno > 0) {
     					$this->haschildren = 'Y';
     				}
     			} else {
     				return database_error();
     			}
     		}*/
     return $this;
 }
Beispiel #5
0
/**
 * Return an object with the Debate participation stats.
 *
 * @param nodeid the nodeid of the Issue node to get the participation stats for.
 * @param style, the style of node to return - how much data it has (defaults to 'mini' can also be 'long' or 'short')
 * @return 	debateparticipationstats class containing properties: peoplecount.
 *  or an Error.
 */
function getDebateParticipationStats($nodeid, $style = 'mini')
{
    $node = getNode($nodeid, 'mini');
    $consSet = getDebate($nodeid, $style);
    $cons = $consSet->connections;
    $count = count($cons);
    $userCheck = array();
    array_push($userCheck, $node->users[0]->userid);
    for ($i = 0; $i < $count; $i++) {
        $next = $cons[$i];
        $from = $next->from;
        $to = $next->to;
        if (!in_array($from->users[0]->userid, $userCheck)) {
            array_push($userCheck, $from->users[0]->userid);
        }
        if (!in_array($to->users[0]->userid, $userCheck)) {
            array_push($userCheck, $to->users[0]->userid);
        }
        if (!in_array($next->userid, $userCheck)) {
            array_push($userCheck, $next->users[0]->userid);
        }
        $votesObj = getVotes($next->connid);
        //error_log(print_r($votesObj, true));
        if (!$votesObj instanceof Error) {
            $posvotes = $votesObj->positivevoteslist;
            $negvotes = $votesObj->negativevoteslist;
            $count2 = count($posvotes);
            for ($j = 0; $j < $count2; $j++) {
                $vote = $posvotes[$j];
                if (!in_array($vote->userid, $userCheck)) {
                    array_push($userCheck, $vote->userid);
                }
            }
            $count3 = count($negvotes);
            for ($j = 0; $j < $count3; $j++) {
                $vote = $negvotes[$j];
                if (!in_array($vote->userid, $userCheck)) {
                    array_push($userCheck, $vote->userid);
                }
            }
        }
        $votesObj = getVotes($from->nodeid);
        //error_log(print_r($votesObj, true));
        if (!$votesObj instanceof Error) {
            $posvotes = $votesObj->positivevoteslist;
            $negvotes = $votesObj->negativevoteslist;
            $lemonvotes = $votesObj->lemonvoteslist;
            $count4 = count($posvotes);
            for ($j = 0; $j < $count4; $j++) {
                $vote = $posvotes[$j];
                if (!in_array($vote->userid, $userCheck)) {
                    array_push($userCheck, $vote->userid);
                }
            }
            $count5 = count($negvotes);
            for ($j = 0; $j < $count5; $j++) {
                $vote = $negvotes[$j];
                if (!in_array($vote->userid, $userCheck)) {
                    array_push($userCheck, $vote->userid);
                }
            }
            $count6 = count($lemonvotes);
            for ($j = 0; $j < $count6; $j++) {
                $vote = $lemonvotes[$j];
                if (!in_array($vote->userid, $userCheck)) {
                    array_push($userCheck, $vote->userid);
                }
            }
        }
    }
    class debateparticipationstats
    {
        public $peoplecount = 0;
    }
    $stats = new debateparticipationstats();
    $stats->peoplecount = count($userCheck);
    return $stats;
}
Beispiel #6
0
     $nodeid = required_param('nodeid', PARAM_ALPHANUMEXT);
     $response = deleteNodeVote($nodeid, $vote);
     break;
 case "connectionvote":
     $vote = required_param('vote', PARAM_TEXT);
     $connid = required_param('connid', PARAM_ALPHANUMEXT);
     $response = connectionVote($connid, $vote);
     break;
 case "deleteconnectionvote":
     $vote = required_param('vote', PARAM_TEXT);
     $connid = required_param('connid', PARAM_ALPHANUMEXT);
     $response = deleteConnectionVote($connid, $vote);
     break;
 case "getvotes":
     $itemid = required_param('itemid', PARAM_ALPHANUMEXT);
     $response = getVotes($itemid);
     break;
     /** FOLLOWING **/
 /** FOLLOWING **/
 case "addfollowing":
     $itemid = required_param('itemid', PARAM_ALPHANUMEXT);
     $response = addFollowing($itemid);
     break;
 case "deletefollowing":
     $itemid = required_param('itemid', PARAM_ALPHANUMEXT);
     $response = deleteFollowing($itemid);
     break;
 case "deletecomment":
     $nodeid = required_param('nodeid', PARAM_ALPHANUMEXT);
     $parentconnid = optional_param('parentconnid', "", PARAM_ALPHANUMEXT);
     $response = deleteComment($nodeid, $parentconnid);
Beispiel #7
0
function pullRating($media, $id, $show5 = false, $showPerc = false, $showVotes = false, $static = NULL)
{
    $sql = "SELECT * FROM media_rating WHERE media_id = '{$id}' AND media_type = '{$media}' AND user_id = '{$user}'";
    $query = @mysql_query($sql);
    $count = @mysql_num_rows($query);
    if ($count > 0) {
        $msg = " --  You have voted all ready!";
        exit;
        $text = '';
        if ($show5 || $showPerc || $showVotes) {
            $text .= '<div class="rated_text">';
        }
        if ($show5) {
            $text .= '<b>Rated:&nbsp;</b><span id="outOfFive_' . $id . '" class="out5Class">' . outOfFive($id) . '</span>/5';
        }
        if ($showPerc) {
            $text .= '(<span id="percentage_' . $id . '" class="percentClass">' . getRating($media, $id) . '</span>)';
        }
        if ($showVotes) {
            $text .= '(<span id="showvotes_' . $id . '" class="votesClass">' . getVotes($media, $id) . '</span>)';
        }
        if ($show5 || $showPerc || $showVotes) {
            $text .= '';
        }
        return $text . '
		  <span class="inline-rating">
			<ul class="star-rating2" id="rater_' . $id . '">
			<li class="current-rating" style="width:' . getRating($media, $id) . ';" id="ul_' . $id . '"></li>
			<li><a onclick="return false;" title="1 star out of 5 ' . $msg . '" class="one-star">1</a></li>
			<li><a onclick="return false;" title="2 stars out of 5 ' . $msg . '" class="two-stars">2</a></li>
			<li><a onclick="return false;" title="3 stars out of 5 ' . $msg . '" class="three-stars">3</a></li>
			<li><a onclick="return false;" title="4 stars out of 5 ' . $msg . '" class="four-stars">4</a></li>
			<li><a onclick="return false;" title="5 stars out of 5 ' . $msg . '" class="five-stars">5</a></li>
			</ul>
		  </span>
			</div>
			<div id="loading_' . $id . '"></div>';
        exit;
    } else {
        $sel = mysql_query("SELECT user_id FROM media_rating WHERE IP = '" . $_SERVER['REMOTE_ADDR'] . "' AND media_type = '{$media}' AND media_id = '{$id}'");
        if (mysql_num_rows($sel) > 0 || $static == 'novote' || $_COOKIE['has_voted_' . $media . '_' . $id]) {
            if ($static == 'novote') {
                $msg = " Please Login to vote";
                $text = '';
            } else {
                $msg = " --  You have voted for this item";
                $text = '';
            }
            if ($show5 || $showPerc || $showVotes) {
                $text .= '<div class="rated_text">';
            }
            if ($show5) {
                $text .= '<b>Rated:&nbsp;</b> <span id="outOfFive_' . $id . '" class="out5Class">' . outOfFive($media, $id) . '</span>/5';
            }
            if ($showPerc) {
                $text .= ' (<span id="percentage_' . $id . '" class="percentClass">' . getRating($media, $id) . '</span>)';
            }
            if ($showVotes) {
                $text .= ' (<span id="showvotes_' . $id . '" class="votesClass">' . getVotes($media, $id) . '</span>)';
            }
            if ($show5 || $showPerc || $showVotes) {
                $text .= '';
            }
            return $text . '
			<span class="inline-rating">
			<ul class="star-rating2" id="rater_' . $id . '">
				<li class="current-rating" style="width:' . getRating($media, $id) . ';" id="ul_' . $id . '"></li>
				<li><a onclick="return false;" title="1 star out of 5 ' . $msg . '" class="one-star">1</a></li>
				<li><a onclick="return false;" title="2 stars out of 5 ' . $msg . '" class="two-stars">2</a></li>
				<li><a onclick="return false;" title="3 stars out of 5 ' . $msg . '" class="three-stars">3</a></li>
				<li><a onclick="return false;" title="4 stars out of 5 ' . $msg . '" class="four-stars">4</a></li>
				<li><a onclick="return false;" title="5 stars out of 5 ' . $msg . '" class="five-stars">5</a></li>
			</ul>
			</span>
			</div>
			<div id="loading_' . $id . '"></div>';
        } else {
            if ($show5 || $showPerc || $showVotes) {
                $text .= '<div class="rated_text">';
            }
            if ($show5) {
                $show5bool = 'true';
                $text .= '<b>Rated:&nbsp;</b><span id="outOfFive_' . $id . '" class="out5Class">' . outOfFive($media, $id) . '</span>/5';
            } else {
                $show5bool = 'false';
            }
            if ($showPerc) {
                $showPercbool = 'true';
                $text .= ' (<span id="percentage_' . $id . '" class="percentClass">' . getRating($media, $id) . '</span>)';
            } else {
                $showPercbool = 'false';
            }
            if ($showVotes) {
                $showVotesbool = 'true';
                $text .= ' (<span id="showvotes_' . $id . '" class="votesClass">' . getVotes($media, $id) . '</span>)';
            } else {
                $showVotesbool = 'false';
            }
            if ($show5 || $showPerc || $showVotes) {
                $text .= '';
            }
            return $text . '
			<span class="inline-rating">
			<ul class="star-rating" id="rater_' . $id . '">
				<li class="current-rating" style="width:' . getRating($media, $id) . ';" id="ul_' . $id . '"></li>
				<li><a onclick="rate(\'' . $media . '\',\'1\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?media=' . $media . '&amp;id=' . $id . '&amp;rating=1" title="1 star out of 5" class="one-star" >1</a></li>
				<li><a onclick="rate(\'' . $media . '\',\'2\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?media=' . $media . '&amp;id=' . $id . '&amp;rating=2" title="2 stars out of 5" class="two-stars">2</a></li>
				<li><a onclick="rate(\'' . $media . '\',\'3\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?media=' . $media . '&amp;id=' . $id . '&amp;rating=3" title="3 stars out of 5" class="three-stars">3</a></li>
				<li><a onclick="rate(\'' . $media . '\',\'4\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?media=' . $media . '&amp;id=' . $id . '&amp;rating=4" title="4 stars out of 5" class="four-stars">4</a></li>
				<li><a onclick="rate(\'' . $media . '\',\'5\',\'' . $id . '\',' . $show5bool . ',' . $showPercbool . ',' . $showVotesbool . '); return false;" href="includes/rating_process.php?media=' . $media . '&amp;id=' . $id . '&amp;rating=5" title="5 stars out of 5" class="five-stars">5</a></li>
			</ul>
			</span>
			</div>
			<div id="loading_' . $id . '"></div>';
        }
    }
}
Beispiel #8
0
    }
    return $result;
}
if (isset($_GET["suggestion"])) {
    $suggestion = $_GET["suggestion"];
    $motivation = "";
    $verification = "";
    if (isset($_GET["motivation"])) {
        $motivation = $_GET["motivation"];
    }
    if (isset($verification)) {
        $verification = $_GET["verification"];
    } else {
        header("Content-Type: application/json;charset=utf-8");
        die(json_encode(array("error" => "Missing validation")));
    }
    header("Content-Type: application/json;charset=utf-8");
    echo json_encode(array("result" => addSuggestion($suggestion, $verification, $motivation)));
}
if (isset($_GET["list"])) {
    header("Content-Type: application/json;charset=utf-8");
    echo json_encode(getSuggestions());
}
if (isset($_GET["vote"])) {
    header("Content-Type: application/json;charset=utf-8");
    echo json_encode(vote(filter_var($_GET["id"], FILTER_SANITIZE_NUMBER_INT)));
}
if (isset($_GET["votes"])) {
    header("Content-Type: application/json;charset=utf-8");
    echo json_encode(getVotes());
}