Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/poll/pollAdd.inc.php
<?php
	if(ADMIN & $cbPerms) {
		if(isset($modanswers)) {
			if(isset($delbox)) {
				$updateAnswer = mysql_query("DELETE FROM ".TABLE."_pollsanswer WHERE id = '$oid'");
				$messageList[] = $poll["optionDeleted"];
			} else {
				$updateAnswer = mysql_query("UPDATE ".TABLE."_pollsanswer SET answer = '$answer' WHERE id = '$oid'");
				$messageList[] = $poll["optionModified"];
			}
		}
		
		if(isset($pollUpdate)) {
			$valid_from = $from_year."-".$from_month."-".$from_day." ".$from_hour.":".$from_min.":".$from_sec;
			$valid_to   = $to_year."-".$to_month."-".$to_day." ".$to_hour.":".$to_min.":".$to_sec;
			if($sub == 1) {
				$insertPoll = mysql_query("INSERT INTO ".TABLE."_pollsquery (query, description, valid_from, valid_until, type, active) VALUES ('$question', '$description', '$valid_from', '$valid_to', '$type', 'no')");
				$id = mysql_insert_id();			
				$messageList[] = $poll["pollAdded"];
				$sub = 2;
			} else {
				$updatePoll = mysql_query("UPDATE ".TABLE."_pollsquery SET query = '$question', description = '$description', valid_from = '$valid_from', valid_until = '$valid_to', type = '$type' WHERE id = '$id'");			
				$messageList[] = $poll["pollModified"];
			}	
		}
		
		$pollData = array();
		$pollData['pollID'] = $id;
		
		if($sub == 1) {
			$date = date("Y-m-d-H-i-s");
			$date = explode("-", $date);
			$from = array();
			$from['year']  = $date['0'];
			$from['month'] = $date['1'];
			$from['day']   = $date['2'];
			$from['hour']  = $date['3'];
			$from['min']   = $date['4'];
			$from['sec']   = $date['5'];
			$to = array();
			$to['year']  = $date['0'];
			$to['month'] = $date['1'];
			$to['day']   = $date['2'];
			$to['hour']  = $date['3'];
			$to['min']   = $date['4'];
			$to['sec']   = $date['5'];
		} elseif ($sub == 2 && ereg("(^[1-9]?[0-9]*$)", $id)) {
			$getPoll  = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_pollsquery WHERE id = '$id'"));
			$question    = $getPoll->query;
			$description = $getPoll->description;
			if($getPoll->type == "option") {
				$optSelect = 1;
			} else {
				$chkSelect = 1;
			}
			$dateTime = explode(" ", $getPoll->valid_from);
			$date     = explode("-", $dateTime[0]);
			$time     = explode(":", $dateTime[1]);
			$from = array();
			$from['year']  = $date['0'];
			$from['month'] = $date['1'];
			$from['day']   = $date['2'];
			$from['hour']  = $time['0'];
			$from['min']   = $time['1'];
			$from['sec']   = $time['2'];
			$dateTime = explode(" ", $getPoll->valid_until);
			$date     = explode("-", $dateTime[0]);
			$time     = explode(":", $dateTime[1]);
			$to = array();
			$to['year']  = $date['0'];
			$to['month'] = $date['1'];
			$to['day']   = $date['2'];
			$to['hour']  = $time['0'];
			$to['min']   = $time['1'];
			$to['sec']   = $time['2'];
		}
		
		$pollData['from']        = $from;
		$pollData['to']          = $to;
		$pollData['question']    = $question;
		$pollData['description'] = $description;
		$pollData['optSelect']   = $optSelect;
		$pollData['chkSelect']   = $chkSelect;
		
		if($sub == 2) {
			$tpl->assign("poll_add_answer_set", "1");
			
			$c = 0;
			$getAnswerQuery  = mysql_query("SELECT * FROM ".TABLE."_pollsanswer WHERE poll = '$id'");
			while($pollAnswer = mysql_fetch_object($getAnswerQuery)) {
				++$c;
				$pollData['answerList'][$c]['nr']     = $c;
				$pollData['answerList'][$c]['id']     = $pollAnswer->id;
				$pollData['answerList'][$c]['answer'] = $pollAnswer->answer;
			}
			/*
			$tpl->addVars("answer_list", 
				array(  "TXT_ADD_ANSWER" => $poll["option"]));
			*/
			if($c != 0) { 
				$tpl->assign("poll_answer_set", "1"); 
			}
		}
		
		$tpl->assign("pollData", $pollData);
		$tpl->assign("pollQuery_set", "1");
		
		$mainPluginContent[]  = $tpl->fetch($config['templates']."add.template", null, "pluginPoll".$cbUserID);
	}
?>
Return current item: Content*Builder