function __construct() { parent::__construct(); $this->pggrouprank = JRequest::getInt('pggrouprank', 0); $option = JRequest::getCmd('option'); $mainframe = JFactory::getApplication(); $this->predictionGameID = JRequest::getInt('prediction_id', 0); if (JRequest::getVar("view") == 'predictionranking') { // Get pagination request variables $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); // In case limit has been changed, adjust it $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0; $this->setState('limit', $limit); $this->setState('limitstart', $limitstart); } //$mainframe->enqueueMessage(JText::_('PredictionRanking __construct limit -> '.'<pre>'.print_r($limit ,true).'</pre>' ),''); //$mainframe->enqueueMessage(JText::_('PredictionRanking__construct view-> '.'<pre>'.print_r(JRequest::getVar( "view"),true).'</pre>' ),''); }
function savePredictions($allowedAdmin = false) { global $mainframe, $option; $document =& JFactory::getDocument(); $mainframe =& JFactory::getApplication(); $result = true; $show_debug = $this->getDebugInfo(); $post = JRequest::get('post'); if ($show_debug) { echo '<br />savePredictions post<pre>~' . print_r($post, true) . '~</pre><br />'; } //$mainframe->enqueueMessage(JText::_('post -> <pre> '.print_r($post,true).'</pre><br>' ),'Notice'); $pids = JRequest::getVar('pids', array(), 'post', 'array'); JArrayHelper::toInteger($pids); $cids = JRequest::getVar('cids', array(), 'post', 'array'); $prids = JRequest::getVar('prids', array(), 'post', 'array'); $homes = JRequest::getVar('homes', array(), 'post', 'array'); $aways = JRequest::getVar('aways', array(), 'post', 'array'); $tipps = JRequest::getVar('tipps', array(), 'post', 'array'); $jokers = JRequest::getVar('jokers', array(), 'post', 'array'); $mID = JRequest::getVar('memberID', 0, 'post', 'int'); $RoundID = JRequest::getVar('r', 0, 'post', 'int'); $ProjectID = JRequest::getVar('pjID', 0, 'post', 'int'); //echo '<br /><pre>~' . print_r($jokers,true) . '~</pre><br />'; $predictionGameID = JRequest::getVar('prediction_id', '', 'post', 'int'); $joomlaUserID = JRequest::getVar('user_id', '', 'post', 'int'); //$mainframe->enqueueMessage(JText::_('predictionGameID -> '.$predictionGameID),''); //$mainframe->enqueueMessage(JText::_('joomlaUserID -> '.$joomlaUserID),''); //$mainframe->enqueueMessage(JText::_('predictionMemberID -> '.$mID),''); // _predictionMember $configavatar = JoomleagueModelPrediction::getPredictionTemplateConfig('predictionusers'); $predictionMemberInfo = $this->getPredictionMember($configavatar); //$mainframe->enqueueMessage(JText::_('predictionMemberInfo -> <pre> '.print_r($predictionMemberInfo,true).'</pre><br>' ),'Notice'); //$mainframe->enqueueMessage(JText::_('predictionMember reminder -> '.$predictionMemberInfo->reminder),''); //$mainframe->enqueueMessage(JText::_('predictionMember email -> '.$predictionMemberInfo->email),''); $changedResultArray = array(); for ($x = 0; $x < count($pids); $x++) { for ($y = 0; $y < count($cids[$pids[$x]]); $y++) { //echo 'PredictionGameID:~'.$predictionGameID.'~ '; $dProjectID = $pids[$x]; //echo 'PredictionProjectID:~'.$dProjectID.'~ '; $dMatchID = $cids[$pids[$x]][$y]; //echo 'MatchID:~'.$dMatchID.'~ '; $dprID = $prids[$pids[$x]][$dMatchID]; //echo 'prID:~'.$dprID.'~ '; $dHome = $homes[$pids[$x]][$cids[$pids[$x]][$y]]; $tmp_dHome = $dHome; if (!isset($homes[$pids[$x]][$cids[$pids[$x]][$y]]) || trim($dHome == '')) { $dHome = "NULL"; } else { $dHome = "'" . $dHome . "'"; } //echo 'Home:~'.$dHome.'~ '; $dAway = $aways[$pids[$x]][$cids[$pids[$x]][$y]]; $tmp_dAway = $dAway; if (!isset($aways[$pids[$x]][$cids[$pids[$x]][$y]]) || trim($dAway == '')) { $dAway = "NULL"; } else { $dAway = "'" . $dAway . "'"; } //echo 'Away:~'.$dAway.'~ '; /* $dJoker = ( isset($jokers[$pids[$x]][$cids[$pids[$x]][$y]]) && !empty($jokers[$pids[$x]][$cids[$pids[$x]][$y]])) ? "'1'" : 'NULL'; */ $dJoker = isset($jokers[$pids[$x]][$cids[$pids[$x]][$y]]) ? "'1'" : 'NULL'; //echo 'Joker:~'.$dJoker.'~ '; $dTipp = $tipps[$pids[$x]][$cids[$pids[$x]][$y]]; $tmp_dTipp = $dTipp; if (!isset($tipps[$pids[$x]][$cids[$pids[$x]][$y]]) || trim($dTipp == '')) { $dTipp = "NULL"; } else { $dTipp = "'" . $dTipp . "'"; } //echo 'Tipp:~'.$dTipp.'~ '; //echo '<br />'; if (isset($homes[$pids[$x]][$cids[$pids[$x]][$y]]) && trim($dHome) != "NULL" && isset($aways[$pids[$x]][$cids[$pids[$x]][$y]]) && trim($dAway) != "NULL" || $dTipp != "NULL") { if ($dTipp == "NULL") { if ($tmp_dHome > $tmp_dAway) { $dTipp = "'1'"; } elseif ($tmp_dHome < $tmp_dAway) { $dTipp = "'2'"; } else { $dTipp = "'0'"; } } if (!empty($dprID)) { $query = "\tUPDATE #__joomleague_prediction_result\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\t\ttipp={$dTipp},\n\t\t\t\t\t\t\t\t\t\t\ttipp_home={$dHome},\n\t\t\t\t\t\t\t\t\t\t\ttipp_away={$dAway},\n\t\t\t\t\t\t\t\t\t\t\tjoker={$dJoker}\n\t\t\t\t\t\t\t\t\t\tWHERE id='{$dprID}'\n\t\t\t\t\t\t\t\t\t"; } else { $query = "INSERT IGNORE INTO #__joomleague_prediction_result\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\tprediction_id,\n\t\t\t\t\t\t\t\t\t\tuser_id,\n\t\t\t\t\t\t\t\t\t\tproject_id,\n\t\t\t\t\t\t\t\t\t\tmatch_id,\n\t\t\t\t\t\t\t\t\t\ttipp,\n\t\t\t\t\t\t\t\t\t\ttipp_home,\n\t\t\t\t\t\t\t\t\t\ttipp_away,\n\t\t\t\t\t\t\t\t\t\tjoker\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t'{$predictionGameID}',\n\t\t\t\t\t\t\t\t\t\t'{$joomlaUserID}',\n\t\t\t\t\t\t\t\t\t\t'{$dProjectID}',\n\t\t\t\t\t\t\t\t\t\t'{$dMatchID}',\n\t\t\t\t\t\t\t\t\t\t{$dTipp},\n\t\t\t\t\t\t\t\t\t\t{$dHome},\n\t\t\t\t\t\t\t\t\t\t{$dAway},\n\t\t\t\t\t\t\t\t\t\t{$dJoker}\n\t\t\t\t\t\t\t\t\t)"; } //echo $query . '<br />'; /**/ $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); $result = false; //echo '<br />ERROR~' . $query . '~<br />'; } /**/ } else { $query = 'DELETE FROM #__joomleague_prediction_result WHERE prediction_id=' . $predictionGameID; $query .= ' AND user_id=' . $joomlaUserID; $query .= ' AND project_id=' . $pids[$x]; $query .= ' AND match_id=' . $cids[$pids[$x]][$y]; //echo '<br />~' . $query . '~<br />'; /**/ $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); $result = false; //echo '<br />ERROR~' . $query . '~<br />'; } /**/ } } } $query = "UPDATE #__joomleague_prediction_member SET last_tipp='" . date('Y-m-d H:i:s') . "' WHERE id={$mID}"; //echo $query . '<br />'; $this->_db->setQuery($query); if (!$this->_db->query()) { $this->setError($this->_db->getErrorMsg()); $result = false; //echo '<br />ERROR~' . $query . '~<br />'; } // email mit tippergebnissen senden if ($predictionMemberInfo->reminder) { $this->sendMemberTipResults($mID, $predictionGameID, $RoundID, $ProjectID, $joomlaUserID); } return $result; }
function __construct() { parent::__construct(); }