function getData() { $cid = JRequest::getVar('cid', array(0), '', 'array'); JArrayHelper::toInteger($cid, array(0)); $db = JFactory::getDBO(); $row = new JTableTourn($db); $row->load($cid[0]); $this->_data = $row; $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $published = $row->id ? $row->published : 1; $this->_lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $published, JText::_("JPUBLISHED"), JText::_("JUNPUBLISHED")); $type_single = array(); $type_single[] = JHTML::_('select.option', 0, JText::_('BLBE_SELTOURNTEAM'), 'id', 'name'); $type_single[] = JHTML::_('select.option', 1, JText::_('BLBE_SELTOURNSING'), 'id', 'name'); $this->_lists['t_single'] = JHTML::_('select.genericlist', $type_single, 't_single', 'class="inputbox" size="1"', 'id', 'name', $row->t_single); $type_tourn = array(); $type_tourn[] = JHTML::_('select.option', 0, JText::_('BLBE_SELTOURNGROUP'), 'id', 'name'); $type_tourn[] = JHTML::_('select.option', 1, JText::_('BLBE_SELTOURNKO'), 'id', 'name'); //$this->_lists['t_type'] = JHTML::_('select.genericlist', $type_tourn, 't_type', 'class="inputbox" size="1"', 'id', 'name', $row->t_type ); $this->_lists["post_max_size"] = $this->getValSettingsServ("post_max_size"); }
function saveSeason() { $post = JRequest::get('post'); $post['s_enbl_extra'] = JRequest::getVar('s_enbl_extra', 0, 'post', 'int'); $post['s_descr'] = JRequest::getVar('s_descr', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['s_rules'] = JRequest::getVar('s_rules', '', 'post', 'string', JREQUEST_ALLOWRAW); $row = new JTableSeason($this->db); $opt_columns = JRequest::getVar('opt_columns', array(0), 'post', 'array'); $soptions = JRequest::getVar('soptions', array(0), 'post', 'array'); if (!$row->bind($post)) { JError::raiseError(500, $row->getError()); } if (!$row->check()) { JError::raiseError(500, $row->getError()); } // if new item order last in appropriate group if (!$row->store()) { JError::raiseError(500, $row->getError()); } $row->checkin(); $tour_row = new JTableTourn($this->db); $tour_row->load($row->t_id); $teams_season = JRequest::getVar('teams_season', array(0), '', 'array'); JArrayHelper::toInteger($teams_season, array(0)); if ($tour_row->t_single) { $arr_new = array(); if (count($teams_season)) { foreach ($teams_season as $teams) { $query = "INSERT IGNORE INTO #__bl_season_players(season_id,player_id) VALUES(" . $row->s_id . "," . $teams . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $arr_new[] = $teams; } } if (count($arr_new)) { $query = "DELETE FROM #__bl_season_players WHERE season_id = " . $row->s_id . " AND player_id NOT IN (" . implode(',', $arr_new) . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } else { //$query = "DELETE FROM #__bl_season_teams WHERE season_id = ".$row->s_id; //$this->db->setQuery($query); //$this->db->query(); $arr_new = array(); if (count($teams_season)) { foreach ($teams_season as $teams) { $query = "INSERT IGNORE INTO #__bl_season_teams(season_id,team_id) VALUES(" . $row->s_id . "," . $teams . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $arr_new[] = $teams; $query = "SELECT * FROM #__bl_players_team WHERE season_id = -1 AND team_id = " . $teams; $this->db->setQuery($query); $pl_comb = $this->db->loadObjectList(); //print_R($pl_comb); echo "<hr/>"; if (count($pl_comb)) { foreach ($pl_comb as $comb) { $query = "INSERT IGNORE INTO #__bl_players_team(team_id,player_id,confirmed,season_id,invitekey,player_join) VALUES(" . $comb->team_id . "," . $comb->player_id . "," . $comb->confirmed . "," . $row->s_id . "," . ($comb->invitekey ? $comb->invitekey : "''") . "," . $comb->player_join . ")"; $this->db->setQuery($query); $this->db->query(); } } } } //die; if (count($arr_new)) { $query = "SELECT team_id FROM #__bl_season_teams WHERE season_id = " . $row->s_id . " AND team_id NOT IN (" . implode(',', $arr_new) . ")"; $this->db->setQuery($query); $old_part = $this->db->loadColumn(); if (count($old_part)) { //$query = "DELETE FROM #__bl_season_teams"; } $query = "DELETE FROM #__bl_season_teams WHERE season_id = " . $row->s_id . " AND team_id NOT IN (" . implode(',', $arr_new) . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } ///------------access--- $query = "DELETE FROM #__bl_feadmins WHERE season_id = " . $row->s_id; $this->db->setQuery($query); $this->db->query(); $usr_admins = JRequest::getVar('usr_admins', array(0), '', 'array'); JArrayHelper::toInteger($usr_admins, array(0)); if (count($usr_admins)) { foreach ($usr_admins as $usrz) { $query = "INSERT INTO #__bl_feadmins(season_id,user_id) VALUES(" . $row->s_id . "," . $usrz . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } ///------------MAPS--- $query = "DELETE FROM #__bl_seas_maps WHERE season_id = " . $row->s_id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $maps = JRequest::getVar('maps_s', array(0), '', 'array'); JArrayHelper::toInteger($maps, array(0)); if (count($maps)) { foreach ($maps as $map) { $query = "INSERT INTO #__bl_seas_maps(season_id,map_id) VALUES(" . $row->s_id . "," . $map . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } //season params $query = "DELETE FROM #__bl_season_option WHERE s_id = " . intval($row->s_id); $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $ord = 0; if (count($opt_columns)) { foreach ($opt_columns as $opt) { $value = isset($post[$opt . "_name"]) ? 1 : 0; //print_r($value); $query = "INSERT INTO #__bl_season_option(s_id,opt_name,opt_value,ordering) VALUES({$row->s_id},'" . stripslashes($opt) . "','" . $value . "','" . $ord . "')"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $ord++; } } //print_r($soptions);echo count($soptions);die; if (count($soptions)) { foreach ($soptions as $key => $value) { if ($key) { $query = "INSERT INTO #__bl_season_option(s_id,opt_name,opt_value) VALUES({$row->s_id}," . stripslashes($key) . ",'" . $value . "')"; $this->db->setQuery($query); $this->db->query(); } } } ///-------------colors---------// $query = "DELETE FROM #__bl_tblcolors WHERE s_id=" . intval($row->s_id); $this->db->setQuery($query); $this->db->query(); $rowcount = JRequest::getVar('col_count', 0, 'post', 'int'); for ($z = 1; $z < $rowcount + 1; $z++) { if ($_POST['place_' . $z] && $_POST['input_field_' . $z]) { $query = "INSERT INTO #__bl_tblcolors(s_id,place,color) VALUES(" . $row->s_id . ",'" . $_POST['place_' . $z] . "','" . $_POST['input_field_' . $z] . "')"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } ///--------------Ranking sort---------------//// $query = "DELETE FROM #__bl_ranksort WHERE seasonid = " . intval($row->s_id); $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $i = 0; $sortfield = JRequest::getVar('sortfield', array(0), '', 'array'); JArrayHelper::toInteger($sortfield, array(0)); if (count($sortfield)) { foreach ($sortfield as $usrz) { if ($usrz) { $query = "INSERT INTO #__bl_ranksort(seasonid,sort_field,sort_way,ordering) VALUES(" . $row->s_id . ",'" . $usrz . "','" . intval($_POST['sortway'][$i]) . "'," . $i . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $i++; } } } //-------extra fields-----------// if (isset($_POST['extraf']) && count($_POST['extraf'])) { foreach ($_POST['extraf'] as $p => $dummy) { $query = "DELETE FROM #__bl_extra_values WHERE f_id = " . $_POST['extra_id'][$p] . " AND uid = " . $row->s_id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if ($_POST['extra_ftype'][$p] == '2') { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue_text) VALUES(" . $_POST['extra_id'][$p] . "," . $row->s_id . ",'" . addslashes($_POST['extraf'][$p]) . "')"; } else { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue) VALUES(" . $_POST['extra_id'][$p] . "," . $row->s_id . ",'" . addslashes($_POST['extraf'][$p]) . "')"; } $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } $this->_id = $row->s_id; }