00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00036 if (is_object($this)) {
00037
00038 if (is_array($this->newData["tt_poll"])) {
00039
00040
00041 list($uid,)=each($this->newData["tt_poll"]);
00042
00043 $cookieName = "t3_tt_poll_voted_".$uid;
00044
00045
00046 if (((!isset($GLOBALS["HTTP_COOKIE_VARS"][$cookieName])) OR ($GLOBALS["TSFE"]->beUserLogin)) && ($this->newData["tt_poll"][$uid]["vote"])) {
00047
00048
00049 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_poll', 'uid='.intval($uid));
00050 $actPoll = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00051
00052
00053 if (is_array ($actPoll)) {
00054
00055
00056 if ($submittedVote = $this->newData["tt_poll"][$uid]["vote"]) {
00057 $answers = explode("\n",$actPoll["answers"]);
00058 $newAnswers = array();
00059 $votesTotal = 0;
00060 reset($answers);
00061 while(list(,$value)=each($answers)) {
00062 list($votes,$answer) = explode("|",$value);
00063 $answer=trim($answer);
00064 $votes=intval($votes);
00065 if (md5($answer) == $submittedVote) {
00066 $votes++;
00067 }
00068 $newAnswers[] = $votes."|".$answer;
00069 $votesTotal += $votes;
00070 }
00071
00072 $this->newData["tt_poll"][$uid]["votes"] = $votesTotal;
00073 $this->newData["tt_poll"][$uid]["answers"] = implode("\n",$newAnswers);
00074
00075
00076 $updateFields = array();
00077 unset($this->newData["tt_poll"][$uid]["uid"]);
00078 unset($this->newData["tt_poll"][$uid]["pid"]);
00079 $this->newData["tt_poll"][$uid]["tstamp"] = time();
00080
00081 while(list($f,$v)=each($this->newData["tt_poll"][$uid])) {
00082 if (t3lib_div::inList("tstamp",$f) || isset($GLOBALS["TCA"]["tt_poll"]["columns"][$f])) {
00083 $updateFields[$f] = $v;
00084 }
00085 }
00086
00087 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tt_poll', 'uid='.intval($uid), $updateFields);
00088
00089
00090 setcookie($cookieName,$submittedVote,time()+(3600*24*10));
00091
00092
00093 if ($id = t3lib_div::_GP("clearCachePid")) {
00094 $this->clear_cacheCmd(intval($id));
00095 }
00096 if ($id = t3lib_div::_GP("clearCacheTargetPid")) {
00097 $this->clear_cacheCmd(intval($id));
00098 }
00099 }
00100 }
00101 } else {
00102
00103 }
00104 }
00105 }
00106
00107
00108
00109
00110 ?>