function SaveRegPlayer() { $post = JRequest::get('post'); $row = new JTablePlayer($this->db); $row->registered = 1; $user = JFactory::getUser(); $istlogo = JRequest::getVar('istlogo', 0, 'post', 'int'); $post['def_img'] = JRequest::getVar('ph_default', 0, 'post', 'int'); if ($user->get('guest')) { JError::raiseError(403, JText::_('Access Forbidden')); return; } $row->usr_id = $user->id; 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(); $curid = $row->id; $this->usrnew = $curid; if (!$istlogo && !$row->id) { $query = "DELETE FROM #__bl_assign_photos WHERE cat_type='1' AND cat_id=" . $curid; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } $query = "DELETE FROM #__bl_assign_photos WHERE cat_type = 1 AND cat_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (isset($_POST['photos_id']) && count($_POST['photos_id'])) { for ($i = 0; $i < count($_POST['photos_id']); $i++) { $photo_id = intval($_POST['photos_id'][$i]); $photo_name = addslashes(strval($_POST['ph_names'][$i])); $query = "INSERT IGNORE INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $photo_id . "," . $row->id . ",1)"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $query = "UPDATE #__bl_photos SET ph_name = '" . $photo_name . "' WHERE id = " . $photo_id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } if (isset($_FILES['player_photo_1']['name']) && $_FILES['player_photo_1']['tmp_name'] != '' && isset($_FILES['player_photo_1']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_1']['name']); $ext = pathinfo($_FILES['player_photo_1']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); //echo $bl_filename; if ($this->uploadFile($_FILES['player_photo_1']['tmp_name'], $bl_filename)) { $post1['ph_filename'] = $bl_filename; $img1 = new JTablePhotos($this->db); $img1->id = 0; if (!$img1->bind($post1)) { JError::raiseError(500, $img1->getError()); } if (!$img1->check()) { JError::raiseError(500, $img1->getError()); } // if new item order last in appropriate group if (!$img1->store()) { JError::raiseError(500, $img1->getError()); } $img1->checkin(); $query = "INSERT IGNORE INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img1->id . "," . $row->id . ",1)"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } else { if ($_FILES['player_photo_1']['error'] == 1) { $this->mainframe->redirect('index.php?option=com_joomsport&task=regplayer&cid[]=' . $row->id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } } /*if(isset($img1)){ $query = "INSERT IGNORE INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(".$img1->id.",".$row->id.",1)"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } }*/ //-------extra fields-----------// if (isset($_POST['extraf']) && count($_POST['extraf'])) { foreach ($_POST['extraf'] as $p => $dummy) { if (intval($_POST['extra_id'][$p])) { $query = "SELECT season_related FROM `#__bl_extra_filds` WHERE id='" . intval($_POST['extra_id'][$p]) . "'"; $this->db->setQuery($query); $season_related = $this->db->loadResult(); $db_season = $season_related ? $this->sid : 0; $query = "DELETE FROM #__bl_extra_values WHERE f_id = " . intval($_POST['extra_id'][$p]) . " AND uid = " . $row->id . " AND season_id='" . $db_season . "'"; $this->db->setQuery($query); $this->db->query(); if ($_POST['extra_ftype'][$p] == '2') { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue_text,season_id) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . addslashes($_POST['extraf'][$p]) . "',{$db_season})"; } else { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue,season_id) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . $_POST['extraf'][$p] . "',{$db_season})"; } $this->db->setQuery($query); $this->db->query(); } } } }
public function savePlayer() { $mainframe = JFactory::getApplication(); $post = JRequest::get('post'); $post['about'] = JRequest::getVar('about', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['def_img'] = JRequest::getVar('ph_default', 0, 'post', 'int'); $seasf_id = JRequest::getVar('seasf_id', 0, 'post', 'int'); $usr_admins = JRequest::getVar('in_teams', array(0), '', 'array'); JArrayHelper::toInteger($usr_admins, array(0)); $row = new JTablePlayer($this->db); 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(); $query = "SELECT p.id FROM #__bl_assign_photos as ph, #__bl_photos as p WHERE p.id = ph.photo_id AND ph.cat_type = 1 AND ph.cat_id = " . $row->id; $this->db->setQuery($query); $in_id = $this->db->loadColumn(); $query = "DELETE FROM #__bl_assign_photos WHERE cat_type = 1 AND cat_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); if (isset($_POST['photos_id']) && count($_POST['photos_id'])) { for ($i = 0; $i < count($_POST['photos_id']); $i++) { $photo_id = intval($_POST['photos_id'][$i]); $photo_name = addslashes(strval($_POST['ph_names'][$i])); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $photo_id . "," . $row->id . ",1)"; $this->db->setQuery($query); $this->db->query(); $query = "UPDATE #__bl_photos SET ph_name = '" . $photo_name . "' WHERE id = " . $photo_id; $this->db->setQuery($query); $this->db->query(); $key = array_search($_POST['photos_id'][$i], $in_id); //print_r($key);die; if (is_int($key)) { unset($in_id[$key]); } } } if (count($in_id)) { $query = "DELETE FROM #__bl_photos WHERE id IN(" . implode(',', $in_id) . ")"; $this->db->setQuery($query); $this->db->query(); } if ($_FILES['player_photo_1']['size']) { if (isset($_FILES['player_photo_1']['name']) && $_FILES['player_photo_1']['tmp_name'] != '' && isset($_FILES['player_photo_1']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_1']['name']); $ext = pathinfo($_FILES['player_photo_1']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); //echo $bl_filename; if ($this->uploadFile($_FILES['player_photo_1']['tmp_name'], $bl_filename)) { $post1['ph_filename'] = $bl_filename; $img1 = new JTablePhotos($this->db); $img1->id = 0; if (!$img1->bind($post1)) { JError::raiseError(500, $img1->getError()); } if (!$img1->check()) { JError::raiseError(500, $img1->getError()); } // if new item order last in appropriate group if (!$img1->store()) { JError::raiseError(500, $img1->getError()); } $img1->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img1->id . "," . $row->id . ",1)"; $this->db->setQuery($query); $this->db->query(); } } } else { if ($_FILES['player_photo_1']['error'] == 1) { $mainframe->redirect('index.php?option=com_joomsport&task=player_edit&cid[]=' . $row->id, JText::_('BLBE_WRNGPHOTO'), 'warning'); } } if ($_FILES['player_photo_2']['size']) { if (isset($_FILES['player_photo_2']['name']) && $_FILES['player_photo_2']['tmp_name'] != '' && isset($_FILES['player_photo_2']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_2']['name']); $ext = pathinfo($_FILES['player_photo_2']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); if ($this->uploadFile($_FILES['player_photo_2']['tmp_name'], $bl_filename)) { $post2['ph_filename'] = $bl_filename; $img2 = new JTablePhotos($this->db); $img2->id = 0; if (!$img2->bind($post2)) { JError::raiseError(500, $img2->getError()); } if (!$img2->check()) { JError::raiseError(500, $img2->getError()); } // if new item order last in appropriate group if (!$img2->store()) { JError::raiseError(500, $img2->getError()); } $img2->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img2->id . "," . $row->id . ",1)"; $this->db->setQuery($query); $this->db->query(); } } } else { if ($_FILES['player_photo_2']['error'] == 1) { $mainframe->redirect('index.php?option=com_joomsport&task=player_edit&cid[]=' . $row->id, JText::_('BLBE_WRNGPHOTO'), 'warning'); } } //-------extra fields-----------// if (isset($_POST['extraf']) && count($_POST['extraf'])) { foreach ($_POST['extraf'] as $p => $dummy) { if (intval($_POST['extra_id'][$p])) { $query = "SELECT season_related FROM `#__bl_extra_filds` WHERE id='" . intval($_POST['extra_id'][$p]) . "'"; $this->db->setQuery($query); $season_related = $this->db->loadResult(); $db_season = $season_related ? $seasf_id : 0; $query = "DELETE FROM #__bl_extra_values WHERE f_id = " . intval($_POST['extra_id'][$p]) . " AND uid = " . $row->id . " AND season_id='" . $db_season . "'"; $this->db->setQuery($query); $this->db->query(); if ($_POST['extra_ftype'][$p] == '2') { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue_text,season_id) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . addslashes($_POST['extraf'][$p]) . "',{$db_season})"; } else { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue,season_id) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . addslashes($_POST['extraf'][$p]) . "',{$db_season})"; } $this->db->setQuery($query); $this->db->query(); } } } //-------Bonuses points----// if (isset($_POST['sids']) && count($_POST['sids'])) { for ($p = 0; $p < count($_POST['sids']); $p++) { $query = "UPDATE #__bl_season_players SET bonus_point = " . intval($_POST['bonuses'][$p]) . " WHERE season_id=" . $_POST['sids'][$p] . " AND player_id=" . $row->id; $this->db->setQuery($query); $this->db->query(); } } if ($seasf_id) { $query = "DELETE FROM #__bl_players_team WHERE confirmed='0' AND player_id = " . $row->id . " AND season_id=" . $seasf_id; $this->db->setQuery($query); $this->db->query(); if (count($usr_admins)) { foreach ($usr_admins as $usrz) { $query = "INSERT INTO #__bl_players_team(team_id,player_id,season_id) VALUES(" . $usrz . "," . $row->id . "," . $seasf_id . ")"; $this->db->setQuery($query); $this->db->query(); } } } $this->_id = $row->id; }
public function saveVenue() { $mainframe = JFactory::getApplication(); $post = JRequest::get('post'); $post['v_descr'] = JRequest::getVar('v_descr', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['v_defimg'] = JRequest::getVar('ph_default', 0, 'post', 'int'); $row = new JTableVenue($this->db); 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(); $query = "DELETE FROM #__bl_assign_photos WHERE cat_type = 5 AND cat_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); if (isset($_POST['photos_id']) && count($_POST['photos_id'])) { for ($i = 0; $i < count($_POST['photos_id']); $i++) { $photo_id = intval($_POST['photos_id'][$i]); $photo_name = addslashes(strval($_POST['ph_names'][$i])); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $photo_id . "," . $row->id . ",5)"; $this->db->setQuery($query); $this->db->query(); $query = "UPDATE #__bl_photos SET ph_name = '" . $photo_name . "' WHERE id = " . $photo_id; $this->db->setQuery($query); $this->db->query(); } } if ($_FILES['player_photo_1']['size']) { if (isset($_FILES['player_photo_1']['name']) && $_FILES['player_photo_1']['tmp_name'] != '' && isset($_FILES['player_photo_1']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_1']['name']); $ext = pathinfo($_FILES['player_photo_1']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); //echo $bl_filename; if ($this->uploadFile($_FILES['player_photo_1']['tmp_name'], $bl_filename)) { $post1['ph_filename'] = $bl_filename; $img1 = new JTablePhotos($this->db); $img1->id = 0; if (!$img1->bind($post1)) { JError::raiseError(500, $img1->getError()); } if (!$img1->check()) { JError::raiseError(500, $img1->getError()); } // if new item order last in appropriate group if (!$img1->store()) { JError::raiseError(500, $img1->getError()); } $img1->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img1->id . "," . $row->id . ",5)"; $this->db->setQuery($query); $this->db->query(); } } } else { if ($_FILES['player_photo_1']['error'] == 1) { $mainframe->redirect('index.php?option=com_joomsport&task=venue_edit&cid[]=' . $row->id, JText::_('BLBE_WRNGPHOTO'), 'warning'); } } if ($_FILES['player_photo_2']['size']) { if (isset($_FILES['player_photo_2']['name']) && $_FILES['player_photo_2']['tmp_name'] != '' && isset($_FILES['player_photo_2']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_2']['name']); $ext = pathinfo($_FILES['player_photo_2']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); if ($this->uploadFile($_FILES['player_photo_2']['tmp_name'], $bl_filename)) { $post2['ph_filename'] = $bl_filename; $img2 = new JTablePhotos($this->db); $img2->id = 0; if (!$img2->bind($post2)) { JError::raiseError(500, $img2->getError()); } if (!$img2->check()) { JError::raiseError(500, $img2->getError()); } // if new item order last in appropriate group if (!$img2->store()) { JError::raiseError(500, $img2->getError()); } $img2->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img2->id . "," . $row->id . ",5)"; $this->db->setQuery($query); $this->db->query(); } } } else { if ($_FILES['player_photo_2']['error'] == 1) { $mainframe->redirect('index.php?option=com_joomsport&task=venue_edit&cid[]=' . $row->id, JText::_('BLBE_WRNGPHOTO'), 'warning'); } } $this->_id = $row->id; }
function saveAdmmatch() { $post = JRequest::get('post'); $post['match_descr'] = JRequest::getVar('match_descr', '', 'post', 'string', JREQUEST_ALLOWRAW); if ($this->acl != 1) { $tid = JRequest::getVar('tid', 0, '', 'int'); unset($post['m_id']); if (!$this->_lists['jsmr_mark_played']) { unset($post['m_played']); } } $row = new JTableMatch($this->db); if (!$row->bind($post)) { JError::raiseError(500, $row->getError()); } if (isset($_POST['penwin']) && count($_POST['penwin'])) { //var_dump($_POST['penwin']);die(); $row->p_winner = intval($_POST['penwin'][0]); } else { $row->p_winner = 0; } if (!$row->check()) { JError::raiseError(500, $row->getError()); } if (!$row->store()) { JError::raiseError(500, $row->getError()); } $row->checkin(); $me_arr = array(); $row->load($row->id); if ($this->acl == 2) { $edit_comp = $this->getJS_Config("moder_edit_competitor"); $teams_season_moder = $this->teamsToModer(); } $query = "SELECT s_id FROM #__bl_matchday as md, #__bl_match as m WHERE md.id=m.m_id AND m.id = " . $row->id; $this->db->setQuery($query); $season_id = $this->db->loadResult(); $this->season_id = $season_id; if ($this->season_id != -1) { $query = "SELECT s.s_id as id, CONCAT(t.name,' ',s.s_name) as name,t.t_single FROM #__bl_tournament as t, #__bl_seasons as s WHERE s.s_id = " . $season_id . " AND s.t_id = t.id"; $this->db->setQuery($query); $tourn = $this->db->loadObjectList(); //$lt_type = $tourn[0]->t_type; $lt_type = $this->_lists['t_type']; } else { $lt_type = 0; } if ($lt_type == 1 || $lt_type == 2) { $team_win = $row->score1 > $row->score2 ? $row->team1_id : $row->team2_id; $team_loose = $row->score1 > $row->score2 ? $row->team2_id : $row->team1_id; $query = "UPDATE #__bl_match SET team1_id=" . $team_win . " WHERE m_id = " . $row->m_id . " AND k_stage > " . $row->k_stage . " AND team1_id = " . $team_loose; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $query = "UPDATE #__bl_match SET team2_id=" . $team_win . " WHERE m_id = " . $row->m_id . " AND k_stage > " . $row->k_stage . " AND team2_id = " . $team_loose; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if ($row->m_played == 0) { $query = "UPDATE #__bl_match SET m_played = '0' WHERE m_id = " . $row->m_id . " AND k_stage > " . $row->k_stage . " AND (team1_id = " . $row->team1_id . " OR team2_id = " . $row->team1_id . " OR team1_id = " . $row->team2_id . " OR team2_id = " . $row->team2_id . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $query = "UPDATE #__bl_match SET team1_id = '0' WHERE m_id = " . $row->m_id . " AND k_stage > " . $row->k_stage . " AND (team1_id = " . $row->team1_id . " OR team1_id = " . $row->team2_id . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $query = "UPDATE #__bl_match SET team2_id = '0' WHERE m_id = " . $row->m_id . " AND k_stage > " . $row->k_stage . " AND (team2_id = " . $row->team1_id . " OR team2_id = " . $row->team2_id . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } $eordering = 0; $me_arr = array(); if (isset($_POST['new_eventid']) && count($_POST['new_eventid'])) { for ($i = 0; $i < count($_POST['new_eventid']); $i++) { if (!isset($_POST['em_id'][$i]) || !intval($_POST['em_id'][$i])) { $new_event = $_POST['new_eventid'][$i]; $plis = explode('*', $_POST['new_player'][$i]); $query = "INSERT INTO #__bl_match_events(e_id,player_id,match_id,ecount,minutes,t_id,eordering) VALUES(" . $new_event . "," . intval($plis[0]) . "," . $row->id . "," . intval($_POST['e_countval'][$i]) . "," . intval($_POST['e_minuteval'][$i]) . "," . intval($plis[1]) . "," . $eordering . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $me_arr[] = $this->db->insertid(); } else { $query = "SELECT * FROM #__bl_match_events WHERE id=" . intval($_POST['em_id'][$i]); $this->db->setQuery($query); $event_bl = $this->db->loadObjectList(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (count($event_bl)) { $query = "UPDATE #__bl_match_events SET minutes=" . intval($_POST['e_minuteval'][$i]) . ", ecount=" . intval($_POST['e_countval'][$i]) . ", eordering=" . $eordering . " WHERE id=" . intval($_POST['em_id'][$i]); $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $me_arr[] = intval($_POST['em_id'][$i]); } } $eordering++; } } $eordering_t = 0; $me_arr_t = array(); if (isset($_POST['new_teventid']) && count($_POST['new_teventid'])) { for ($i = 0; $i < count($_POST['new_teventid']); $i++) { if (!isset($_POST['et_id'][$i]) || !intval($_POST['et_id'][$i])) { $new_event = $_POST['new_teventid'][$i]; $query = "INSERT INTO #__bl_match_events(e_id,t_id,match_id,ecount,minutes,eordering) VALUES(" . $new_event . "," . $_POST['new_tplayer'][$i] . "," . $row->id . "," . intval($_POST['et_countval'][$i]) . ",'0'," . $eordering_t . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $me_arr_t[] = $this->db->insertid(); } else { $query = "SELECT * FROM #__bl_match_events WHERE id=" . intval($_POST['et_id'][$i]); $this->db->setQuery($query); $event_bl = $this->db->loadObjectList(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (count($event_bl)) { $query = "UPDATE #__bl_match_events SET ecount=" . intval($_POST['et_countval'][$i]) . ", eordering=" . $eordering_t . " WHERE id=" . intval($_POST['et_id'][$i]); $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $me_arr_t[] = intval($_POST['et_id'][$i]); } } $eordering_t++; } } /// $me_arr_n = array(); if (isset($_POST['em_id_n']) && count($_POST['em_id_n'])) { for ($i = 0; $i < count($_POST['em_id_n']); $i++) { $me_arr_n[] = $_POST['em_id_n'][$i]; } } /////////////DELETE $query = "DELETE FROM #__bl_match_events WHERE match_id = " . $row->id; if (count($me_arr)) { $query .= " AND id NOT IN (" . implode(',', $me_arr) . ")"; } if (count($me_arr_t)) { $query .= " AND id NOT IN (" . implode(',', $me_arr_t) . ")"; } if (count($me_arr_n)) { $query .= " AND id NOT IN (" . implode(',', $me_arr_n) . ")"; } if ($this->acl == 2 && $edit_comp == 0 && !in_array($row->team1_id, $teams_season_moder)) { $query .= " AND t_id != " . $row->team1_id; } if ($this->acl == 2 && $edit_comp == 0 && !in_array($row->team2_id, $teams_season_moder)) { $query .= " AND t_id != " . $row->team2_id; } $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $query = "DELETE FROM #__bl_assign_photos WHERE cat_type = 3 AND cat_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); if (isset($_POST['photos_id']) && count($_POST['photos_id'])) { for ($i = 0; $i < count($_POST['photos_id']); $i++) { $photo_id = intval($_POST['photos_id'][$i]); $photo_name = addslashes(strval($_POST['ph_names'][$i])); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $photo_id . "," . $row->id . ",3)"; $this->db->setQuery($query); $this->db->query(); $query = "UPDATE #__bl_photos SET ph_name = '" . $photo_name . "' WHERE id = " . $photo_id; $this->db->setQuery($query); $this->db->query(); } } if (isset($_FILES['player_photo_1']['name']) && $_FILES['player_photo_1']['tmp_name'] != '' && isset($_FILES['player_photo_1']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_1']['name']); $ext = pathinfo($_FILES['player_photo_1']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); //echo $bl_filename; if ($this->uploadFile($_FILES['player_photo_1']['tmp_name'], $bl_filename)) { $post1['ph_filename'] = $bl_filename; $img1 = new JTablePhotos($this->db); $img1->id = 0; if (!$img1->bind($post1)) { JError::raiseError(500, $img1->getError()); } if (!$img1->check()) { JError::raiseError(500, $img1->getError()); } // if new item order last in appropriate group if (!$img1->store()) { JError::raiseError(500, $img1->getError()); } $img1->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img1->id . "," . $row->id . ",3)"; $this->db->setQuery($query); $this->db->query(); } } else { if ($_FILES['player_photo_1']['error'] == 1) { if ($this->acl == 1) { $this->mainframe->redirect('index.php?option=com_joomsport&task=edit_match&controller=admin&tid=' . $tid . '&cid[]=' . $row->id . '&sid=' . $this->season_id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } else { if ($this->acl == 2) { $this->mainframe->redirect('index.php?option=com_joomsport&task=edit_match&controller=moder&tid=' . $tid . '&cid[]=' . $row->id . '&sid=' . $this->season_id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } } } } if (isset($_FILES['player_photo_2']['name']) && $_FILES['player_photo_2']['tmp_name'] != '' && isset($_FILES['player_photo_2']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_2']['name']); $ext = pathinfo($_FILES['player_photo_2']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); if ($this->uploadFile($_FILES['player_photo_2']['tmp_name'], $bl_filename)) { $post2['ph_filename'] = $bl_filename; $img2 = new JTablePhotos($this->db); $img2->id = 0; if (!$img2->bind($post2)) { JError::raiseError(500, $img2->getError()); } if (!$img2->check()) { JError::raiseError(500, $img2->getError()); } // if new item order last in appropriate group if (!$img2->store()) { JError::raiseError(500, $img2->getError()); } $img2->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img2->id . "," . $row->id . ",3)"; $this->db->setQuery($query); $this->db->query(); } } else { if ($_FILES['player_photo_2']['error'] == 1) { if ($this->acl == 1) { $this->mainframe->redirect('index.php?option=com_joomsport&task=edit_match&controller=admin&tid=' . $tid . '&cid[]=' . $row->id . '&sid=' . $this->season_id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } else { if ($this->acl == 2) { $this->mainframe->redirect('index.php?option=com_joomsport&task=edit_match&controller=moder&tid=' . $tid . '&cid[]=' . $row->id . '&sid=' . $this->season_id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } } } } //-------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->id; $this->db->setQuery($query); $this->db->query(); if ($_POST['extra_ftype'][$p] == '2') { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue_text) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . addslashes($_POST['extraf'][$p]) . "')"; } else { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . addslashes($_POST['extraf'][$p]) . "')"; } $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } //-----SQUARD--------/// if ($this->acl != 3) { if ($this->acl == 2 && $edit_comp == 0 && ($this->getJS_Config("jsmr_edit_squad_opposite") == 0 && !in_array($row->team1_id, $teams_season_moder) || $this->getJS_Config("jsmr_edit_squad_yours") == 0 && in_array($row->team1_id, $teams_season_moder))) { } else { $query = "DELETE FROM #__bl_squard WHERE team_id = " . $row->team1_id . " AND match_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (isset($_POST['t1_squard']) && count($_POST['t1_squard'])) { for ($i = 0; $i < count($_POST['t1_squard']); $i++) { $new_event = $_POST['t1_squard'][$i]; $query = "INSERT INTO #__bl_squard(match_id,team_id,player_id,mainsquard) VALUES(" . $row->id . "," . $row->team1_id . "," . $new_event . ",'1')"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } if (isset($_POST['t1_squard_res']) && count($_POST['t1_squard_res'])) { for ($i = 0; $i < count($_POST['t1_squard_res']); $i++) { $new_event = $_POST['t1_squard_res'][$i]; $query = "INSERT INTO #__bl_squard(match_id,team_id,player_id,mainsquard) VALUES(" . $row->id . "," . $row->team1_id . "," . $new_event . ",'0')"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } //subs in $query = "DELETE FROM #__bl_subsin WHERE team_id = " . $row->team1_id . " AND match_id=" . $row->id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (isset($_POST['playersq1_id_arr']) && count($_POST['playersq1_id_arr'])) { for ($i = 0; $i < count($_POST['playersq1_id_arr']); $i++) { $player_in = intval($_POST['playersq1_id_arr'][$i]); $player_out = intval($_POST['playersq1_out_id_arr'][$i]); $minutes = intval($_POST['minutes1_arr'][$i]); $query = "INSERT INTO #__bl_subsin(match_id,team_id,player_in,player_out,minutes,season_id) VALUES(" . $row->id . "," . $row->team1_id . "," . $player_in . "," . $player_out . ",'" . $minutes . "'," . $season_id . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } } if ($this->acl == 2 && $edit_comp == 0 && ($this->getJS_Config("jsmr_edit_squad_opposite") == 0 && !in_array($row->team2_id, $teams_season_moder) || $this->getJS_Config("jsmr_edit_squad_yours") == 0 && in_array($row->team2_id, $teams_season_moder))) { } else { $query = "DELETE FROM #__bl_squard WHERE team_id = " . $row->team2_id . " AND match_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (isset($_POST['t2_squard']) && count($_POST['t2_squard'])) { for ($i = 0; $i < count($_POST['t2_squard']); $i++) { $new_event = $_POST['t2_squard'][$i]; $query = "INSERT INTO #__bl_squard(match_id,team_id,player_id,mainsquard) VALUES(" . $row->id . "," . $row->team2_id . "," . $new_event . ",'1')"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } if (isset($_POST['t2_squard_res']) && count($_POST['t2_squard_res'])) { for ($i = 0; $i < count($_POST['t2_squard_res']); $i++) { $new_event = $_POST['t2_squard_res'][$i]; $query = "INSERT INTO #__bl_squard(match_id,team_id,player_id,mainsquard) VALUES(" . $row->id . "," . $row->team2_id . "," . $new_event . ",'0')"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } //subs in $query = "DELETE FROM #__bl_subsin WHERE team_id = " . $row->team2_id . " AND match_id=" . $row->id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (isset($_POST['playersq2_id_arr']) && count($_POST['playersq2_id_arr'])) { for ($i = 0; $i < count($_POST['playersq2_id_arr']); $i++) { $player_in = intval($_POST['playersq2_id_arr'][$i]); $player_out = intval($_POST['playersq2_out_id_arr'][$i]); $minutes = intval($_POST['minutes2_arr'][$i]); $query = "INSERT INTO #__bl_subsin(match_id,team_id,player_in,player_out,minutes,season_id) VALUES(" . $row->id . "," . $row->team2_id . "," . $player_in . "," . $player_out . ",'" . $minutes . "'," . $season_id . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } } } $query = "DELETE FROM #__bl_mapscore WHERE m_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (isset($_POST['mapid']) && count($_POST['mapid'])) { for ($i = 0; $i < count($_POST['mapid']); $i++) { $new_event = $_POST['mapid'][$i]; $query = "INSERT INTO #__bl_mapscore(m_id,map_id,m_score1,m_score2) VALUES(" . $row->id . "," . $new_event . "," . intval($_POST['t1map'][$i]) . "," . intval($_POST['t2map'][$i]) . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } $this->id = $row->id; $this->m_id = $row->m_id; $this->s_id = $season_id; if ($this->acl == 2) { $this->tid = $tid; } }
function SaveAdmTeam() { $post = JRequest::get('post'); if ($this->acl == 1) { if (!$this->getJS_Config("jssa_editteam")) { JError::raiseError(500, ''); } $s_id = JRequest::getVar('sid', 0, '', 'int'); } else { $post['id'] = JRequest::getVar('tid', 0, 'post', 'int'); } $msg = ''; $post['t_descr'] = JRequest::getVar('t_descr', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['def_img'] = JRequest::getVar('ph_default', 0, 'post', 'int'); $row = new JTableTeams($this->db); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $istlogo = JRequest::getVar('istlogo', 0, 'post', 'int'); if (!$istlogo) { $post['t_emblem'] = ''; } if (isset($_FILES['t_logo']['name']) && $_FILES['t_logo']['tmp_name'] != '' && isset($_FILES['t_logo']['tmp_name'])) { $bl_filename = strtolower($_FILES['t_logo']['name']); $ext = pathinfo($_FILES['t_logo']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); if ($this->uploadFile($_FILES['t_logo']['tmp_name'], $bl_filename)) { $post['t_emblem'] = $bl_filename; } } if (!$row->bind($post)) { JError::raiseError(500, $row->getError()); } $pzt = 1; if (!$row->id) { if ($this->acl == 2) { return JError::raiseError(500, $error); } else { $pzt = 0; } } if (!$row->check()) { JError::raiseError(500, $row->getError()); } if (!$row->store()) { JError::raiseError(500, $row->getError()); } $row->checkin(); if (!$pzt) { $query = "INSERT INTO #__bl_season_teams(season_id,team_id) VALUES(" . $s_id . "," . $row->id . ")"; $this->db->setQuery($query); $this->db->query(); } $query = "DELETE FROM #__bl_assign_photos WHERE cat_type = 2 AND cat_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (isset($_POST['photos_id']) && count($_POST['photos_id'])) { for ($i = 0; $i < count($_POST['photos_id']); $i++) { $photo_id = intval($_POST['photos_id'][$i]); $photo_name = addslashes(strval($_POST['ph_names'][$i])); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $photo_id . "," . $row->id . ",2)"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $query = "UPDATE #__bl_photos SET ph_name = '" . $photo_name . "' WHERE id = " . $photo_id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } if (isset($_FILES['player_photo_1']['name']) && $_FILES['player_photo_1']['tmp_name'] != '' && isset($_FILES['player_photo_1']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_1']['name']); $ext = pathinfo($_FILES['player_photo_1']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); if ($this->uploadFile($_FILES['player_photo_1']['tmp_name'], $bl_filename)) { $post1['ph_filename'] = $bl_filename; $img1 = new JTablePhotos($this->db); $img1->id = 0; if (!$img1->bind($post1)) { JError::raiseError(500, $img1->getError()); } if (!$img1->check()) { JError::raiseError(500, $img1->getError()); } if (!$img1->store()) { JError::raiseError(500, $img1->getError()); } $img1->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img1->id . "," . $row->id . ",2)"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } else { if ($_FILES['player_photo_1']['error'] == 1) { if ($this->acl == 1) { $this->mainframe->redirect('index.php?option=com_joomsport&task=team_edit&controller=admin&cid[]=' . $row->id . '&sid=' . $this->season_id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } else { if ($this->acl == 2) { $this->mainframe->redirect('index.php?option=com_joomsport&task=team_edit&controller=moder&tid=' . $row->id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } } } } if (isset($_FILES['player_photo_2']['name']) && $_FILES['player_photo_2']['tmp_name'] != '' && isset($_FILES['player_photo_2']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_2']['name']); $ext = pathinfo($_FILES['player_photo_2']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); if ($this->uploadFile($_FILES['player_photo_2']['tmp_name'], $bl_filename)) { $post2['ph_filename'] = $bl_filename; $img2 = new JTablePhotos($this->db); $img2->id = 0; if (!$img2->bind($post2)) { JError::raiseError(500, $img2->getError()); } if (!$img2->check()) { JError::raiseError(500, $img2->getError()); } if (!$img2->store()) { JError::raiseError(500, $img2->getError()); } $img2->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img2->id . "," . $row->id . ",2)"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } else { if ($_FILES['player_photo_2']['error'] == 1) { if ($this->acl == 1) { $this->mainframe->redirect('index.php?option=com_joomsport&task=team_edit&controller=admin&cid[]=' . $row->id . '&sid=' . $this->season_id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } else { if ($this->acl == 2) { $this->mainframe->redirect('index.php?option=com_joomsport&task=team_edit&controller=moder&tid=' . $row->id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } } } } if ($this->acl == 2) { $seasf_id = $this->mainframe->getUserStateFromRequest('com_joomsport.moderseason', 'moderseason', 0, 'int'); $query = "SELECT CONCAT(tr.name,' ',s.s_name) as t_name,s.s_id as id FROM #__bl_season_teams as t,#__bl_seasons as s,#__bl_tournament as tr WHERE s.published=1 AND tr.id=s.t_id AND s.s_id=t.season_id AND t.team_id=" . $row->id . " ORDER BY s.s_id desc"; $this->db->setQuery($query); $seass = $this->db->loadObjectList(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (!$seasf_id) { $seasf_id = $seass[0]->id; } $s_id = $seasf_id; } //-------extra fields-----------// if (isset($_POST['extraf']) && count($_POST['extraf'])) { foreach ($_POST['extraf'] as $p => $dummy) { $query = "SELECT season_related FROM #__bl_extra_filds WHERE id='" . intval($_POST['extra_id'][$p]) . "'"; $this->db->setQuery($query); $seas_relat = $this->db->loadResult(); $query = "DELETE FROM #__bl_extra_values WHERE f_id = " . $_POST['extra_id'][$p] . " AND uid = " . $row->id . " " . ($seas_relat ? " AND season_id=" . intval($s_id) : ""); $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $fld = $_POST['extra_ftype'][$p] == 2 ? 'fvalue_text' : 'fvalue'; $inserted_seas = $seas_relat ? $s_id : 0; $query = "INSERT INTO #__bl_extra_values(f_id,uid,`" . $fld . "`,season_id) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . addslashes($_POST['extraf'][$p]) . "'," . $inserted_seas . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } //-------Players----// if ($this->acl == 1) { if ($s_id && $row->id) { $query = "DELETE FROM #__bl_players_team WHERE team_id=" . $row->id . " AND season_id=" . $s_id; $this->db->setQuery($query); $this->db->query(); if (isset($_POST['teampl']) && count($_POST['teampl'])) { for ($p = 0; $p < count($_POST['teampl']); $p++) { $query = "INSERT IGNORE INTO #__bl_players_team(team_id,player_id,season_id) VALUES(" . $row->id . "," . intval($_POST['teampl'][$p]) . "," . $s_id . ")"; $this->db->setQuery($query); $this->db->query(); } } } $this->season_id = $s_id; } else { $inviteoradd = $this->getJS_Config('esport_invite_player'); if ($seasf_id) { $plzold = array(); if (isset($_POST['teampl']) && count($_POST['teampl'])) { for ($p = 0; $p < count($_POST['teampl']); $p++) { if (intval($_POST['teampl'][$p])) { $query = "SELECT player_id FROM #__bl_players_team WHERE player_id = " . intval($_POST['teampl'][$p]) . " AND team_id = {$row->id} AND season_id = {$seasf_id}"; $this->db->setQuery($query); $plzold[] = intval($_POST['teampl'][$p]); if (!$this->db->loadResult()) { $query = "INSERT IGNORE INTO #__bl_players_team(team_id,player_id,season_id,confirmed) VALUES(" . $row->id . "," . intval($_POST['teampl'][$p]) . "," . $seasf_id . "," . ($inviteoradd ? 1 : 0) . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } //invite if ($inviteoradd) { mt_srand((double) microtime()); $gen = mt_rand() . "prI" . microtime(); $gen = str_replace(" ", "", $gen); $this->InvitePlayer(intval($_POST['teampl'][$p]), $row->t_name, $seasf_id, $gen); $query = "UPDATE #__bl_players_team SET invitekey='" . $gen . "' WHERE team_id = " . $row->id . " AND player_id = " . intval($_POST['teampl'][$p]) . " AND season_id = " . $seasf_id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } } } } else { $query = "DELETE FROM #__bl_players_team WHERE team_id=" . $row->id . " AND season_id=" . $seasf_id . " AND player_join='0'"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } if (count($plzold)) { $sql = count($plzold) > 1 ? "player_id NOT IN (" . implode(",", $plzold) . ")" : "player_id != " . $plzold[0]; $query = "DELETE FROM #__bl_players_team WHERE " . $sql . " AND team_id=" . $row->id . " AND season_id=" . $seasf_id . " AND player_join='0'"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } //invite unregs if (isset($_POST['emlinv']) && count($_POST['emlinv']) && $row->id) { for ($p = 0; $p < count($_POST['emlinv']); $p++) { mt_srand((double) microtime()); $gen = mt_rand() . "prI" . microtime(); $gen = str_replace(" ", "", $gen); $query = "INSERT IGNORE INTO #__bl_players_team(team_id,player_id,season_id,confirmed,invitekey) VALUES(" . $row->id . ",0," . $seasf_id . ",'1','" . $gen . "')"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $this->InviteUnreg($_POST['emlinv'][$p], $row->t_name, $seasf_id, $gen); } } //action with players join team if (isset($_POST['appr_pl']) && count($_POST['appr_pl']) && $row->id) { for ($p = 0; $p < count($_POST['appr_pl']); $p++) { $ids = $_POST['appr_pl'][$p]; switch ($_POST['action_' . $ids]) { case 1: $this->Pl_Approve($ids, $row->t_name, $row->id, $seasf_id); break; case 2: $this->Pl_Reject($ids, $row->t_name, $row->id, $seasf_id); break; } $query = "INSERT IGNORE INTO #__bl_players_team(team_id,player_id,season_id,confirmed,invitekey) VALUES(" . $row->id . ",0," . $seasf_id . ",'1','" . $gen . "')"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $this->InviteUnreg($_POST['emlinv'][$p], $row->t_name, $seasf_id, $gen); } } } $this->id = $row->id; }
public function saveMatch() { $mainframe = JFactory::getApplication(); $post = JRequest::get('post'); $post['match_descr'] = JRequest::getVar('match_descr', '', 'post', 'string', JREQUEST_ALLOWRAW); $row = new JTableMatch($this->db); $row->m_date = JRequest::getVar('m_date', '', 'post', 'string', JREQUEST_ALLOWRAW); $row->m_time = JRequest::getVar('d_time', '', 'post', 'string', JREQUEST_ALLOWRAW); if (!$row->bind($post)) { JError::raiseError(500, $row->getError()); } if (isset($_POST['penwin']) && count($_POST['penwin'])) { //var_dump($_POST['penwin']);die(); $row->p_winner = intval($_POST['penwin'][0]); } else { $row->p_winner = 0; } 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(); $query = "SELECT s_id FROM #__bl_matchday as md, #__bl_match as m WHERE md.id=m.m_id AND m.id = " . $row->id; $this->db->setQuery($query); $season_id = $this->db->loadResult(); $tourn = $this->getSeasAttr($season_id); $lt_type = $this->_lists['t_type']; $row->load($row->id); if ($lt_type == 1 || $lt_type == 2) { $team_win = $row->score1 > $row->score2 ? $row->team1_id : $row->team2_id; $team_loose = $row->score1 > $row->score2 ? $row->team2_id : $row->team1_id; if (!empty($row->p_winner)) { $team_win = $row->p_winner == $row->team1_id ? $row->team1_id : $row->team2_id; $team_loose = $team_win == $row->team1_id ? $row->team2_id : $row->team1_id; } if ($row->is_extra) { $team_win = $row->aet1 > $row->aet2 ? $row->team1_id : $row->team2_id; $team_loose = $row->aet1 > $row->aet2 ? $row->team2_id : $row->team1_id; } $query = "UPDATE #__bl_match SET team1_id=" . $team_win . " WHERE m_id = " . $row->m_id . " AND k_stage > " . $row->k_stage . " AND team1_id = " . $team_loose; $this->db->setQuery($query); $this->db->query(); $query = "UPDATE #__bl_match SET team2_id=" . $team_win . " WHERE m_id = " . $row->m_id . " AND k_stage > " . $row->k_stage . " AND team2_id = " . $team_loose; $this->db->setQuery($query); $this->db->query(); if ($row->m_played == 0) { $query = "UPDATE #__bl_match SET m_played = '0' WHERE m_id = " . $row->m_id . " AND k_stage > " . $row->k_stage . " AND (team1_id = " . $row->team1_id . " OR team2_id = " . $row->team1_id . " OR team1_id = " . $row->team2_id . " OR team2_id = " . $row->team2_id . ")"; $this->db->setQuery($query); $this->db->query(); $query = "UPDATE #__bl_match SET team1_id = '0' WHERE m_id = " . $row->m_id . " AND k_stage > " . $row->k_stage . " AND (team1_id = " . $row->team1_id . " OR team1_id = " . $row->team2_id . ")"; $this->db->setQuery($query); $this->db->query(); $query = "UPDATE #__bl_match SET team2_id = '0' WHERE m_id = " . $row->m_id . " AND k_stage > " . $row->k_stage . " AND (team2_id = " . $row->team1_id . " OR team2_id = " . $row->team2_id . ")"; $this->db->setQuery($query); $this->db->query(); } } $eordering = 0; $me_arr = array(); if (isset($_POST['new_eventid']) && count($_POST['new_eventid'])) { for ($i = 0; $i < count($_POST['new_eventid']); $i++) { if (!intval($_POST['em_id'][$i])) { $new_event = $_POST['new_eventid'][$i]; $plis = explode('*', $_POST['new_player'][$i]); $query = "INSERT INTO #__bl_match_events(e_id,player_id,match_id,ecount,minutes,t_id,eordering) VALUES(" . $new_event . "," . intval($plis[0]) . "," . $row->id . "," . intval($_POST['e_countval'][$i]) . "," . floatval($_POST['e_minuteval'][$i]) . "," . intval($plis[1]) . "," . $eordering . ")"; $this->db->setQuery($query); $this->db->query(); $me_arr[] = $this->db->insertid(); } else { $query = "SELECT * FROM #__bl_match_events WHERE id=" . intval($_POST['em_id'][$i]); $this->db->setQuery($query); $event_bl = $this->db->loadObjectList(); if (count($event_bl)) { $query = "UPDATE #__bl_match_events SET minutes=" . floatval($_POST['e_minuteval'][$i]) . ",ecount=" . intval($_POST['e_countval'][$i]) . ",eordering=" . $eordering . " WHERE id=" . intval($_POST['em_id'][$i]); $this->db->setQuery($query); $this->db->query(); $me_arr[] = intval($_POST['em_id'][$i]); } } $eordering++; } } ///////////// $eordering_t = 0; $me_arr_t = array(); if (isset($_POST['new_teventid']) && count($_POST['new_teventid'])) { for ($i = 0; $i < count($_POST['new_teventid']); $i++) { if (!intval($_POST['et_id'][$i])) { $new_event = $_POST['new_teventid'][$i]; $query = "INSERT INTO #__bl_match_events(e_id,t_id,match_id,ecount,minutes,eordering) VALUES(" . $new_event . "," . $_POST['new_tplayer'][$i] . "," . $row->id . "," . intval($_POST['et_countval'][$i]) . ",'0'," . $eordering . ")"; $this->db->setQuery($query); $this->db->query(); $me_arr_t[] = $this->db->insertid(); } else { $query = "SELECT * FROM #__bl_match_events WHERE id=" . intval($_POST['et_id'][$i]); $this->db->setQuery($query); $event_bl = $this->db->loadObjectList(); if (count($event_bl)) { $query = "UPDATE #__bl_match_events SET ecount=" . intval($_POST['et_countval'][$i]) . ",eordering=" . $eordering_t . " WHERE id=" . intval($_POST['et_id'][$i]); $this->db->setQuery($query); $this->db->query(); $me_arr_t[] = intval($_POST['et_id'][$i]); } } $eordering_t++; } } $query = "DELETE FROM #__bl_match_events WHERE match_id = " . $row->id; if (count($me_arr)) { $query .= " AND id NOT IN (" . implode(',', $me_arr) . ")"; } if (count($me_arr_t)) { $query .= " AND id NOT IN (" . implode(',', $me_arr_t) . ")"; } $this->db->setQuery($query); $this->db->query(); //////////// $query = "SELECT p.id FROM #__bl_assign_photos as ph, #__bl_photos as p WHERE p.id = ph.photo_id AND ph.cat_type = 3 AND ph.cat_id = " . $row->id; $this->db->setQuery($query); $in_id = $this->db->loadColumn(); $query = "DELETE FROM #__bl_assign_photos WHERE cat_type = 3 AND cat_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); if (isset($_POST['photos_id']) && count($_POST['photos_id'])) { for ($i = 0; $i < count($_POST['photos_id']); $i++) { $photo_id = intval($_POST['photos_id'][$i]); $photo_name = addslashes(strval($_POST['ph_names'][$i])); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $photo_id . "," . $row->id . ",3)"; $this->db->setQuery($query); $this->db->query(); $query = "UPDATE #__bl_photos SET ph_name = '" . $photo_name . "' WHERE id = " . $photo_id; $this->db->setQuery($query); $this->db->query(); $key = array_search($_POST['photos_id'][$i], $in_id); //print_r($key);die; if (is_int($key)) { unset($in_id[$key]); } } } if (count($in_id)) { $query = "DELETE FROM #__bl_photos WHERE id IN(" . implode(',', $in_id) . ")"; $this->db->setQuery($query); $this->db->query(); } if ($_FILES['player_photo_1']['size']) { if (isset($_FILES['player_photo_1']['name']) && $_FILES['player_photo_1']['tmp_name'] != '' && isset($_FILES['player_photo_1']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_1']['name']); $ext = pathinfo($_FILES['player_photo_1']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); //echo $bl_filename; if ($this->uploadFile($_FILES['player_photo_1']['tmp_name'], $bl_filename)) { $post1['ph_filename'] = $bl_filename; $img1 = new JTablePhotos($this->db); $img1->id = 0; if (!$img1->bind($post1)) { JError::raiseError(500, $img1->getError()); } if (!$img1->check()) { JError::raiseError(500, $img1->getError()); } // if new item order last in appropriate group if (!$img1->store()) { JError::raiseError(500, $img1->getError()); } $img1->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img1->id . "," . $row->id . ",3)"; $this->db->setQuery($query); $this->db->query(); } } } else { if ($_FILES['player_photo_1']['error'] == 1) { $mainframe->redirect('index.php?option=com_joomsport&task=match_edit&cid[]=' . $row->id, JText::_('BLBE_WRNGPHOTO'), 'warning'); } } if ($_FILES['player_photo_2']['size']) { if (isset($_FILES['player_photo_2']['name']) && $_FILES['player_photo_2']['tmp_name'] != '' && isset($_FILES['player_photo_2']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_2']['name']); $ext = pathinfo($_FILES['player_photo_2']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); if ($this->uploadFile($_FILES['player_photo_2']['tmp_name'], $bl_filename)) { $post2['ph_filename'] = $bl_filename; $img2 = new JTablePhotos($this->db); $img2->id = 0; if (!$img2->bind($post2)) { JError::raiseError(500, $img2->getError()); } if (!$img2->check()) { JError::raiseError(500, $img2->getError()); } // if new item order last in appropriate group if (!$img2->store()) { JError::raiseError(500, $img2->getError()); } $img2->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img2->id . "," . $row->id . ",3)"; $this->db->setQuery($query); $this->db->query(); } } } else { if ($_FILES['player_photo_2']['error'] == 1) { $mainframe->redirect('index.php?option=com_joomsport&task=match_edit&cid[]=' . $row->id, JText::_('BLBE_WRNGPHOTO'), 'warning'); } } //-------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->id; $this->db->setQuery($query); $this->db->query(); if ($_POST['extra_ftype'][$p] == '2') { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue_text) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . addslashes($_POST['extraf'][$p]) . "')"; } else { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . addslashes($_POST['extraf'][$p]) . "')"; } $this->db->setQuery($query); $this->db->query(); } } //-----SQUARD--------/// $query = "DELETE FROM #__bl_squard WHERE match_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); if (isset($_POST['t1_squard']) && count($_POST['t1_squard'])) { for ($i = 0; $i < count($_POST['t1_squard']); $i++) { $new_event = $_POST['t1_squard'][$i]; $query = "INSERT INTO #__bl_squard(match_id,team_id,player_id,mainsquard) VALUES(" . $row->id . "," . $row->team1_id . "," . $new_event . ",'1')"; $this->db->setQuery($query); $this->db->query(); } } if (isset($_POST['t2_squard']) && count($_POST['t2_squard'])) { for ($i = 0; $i < count($_POST['t2_squard']); $i++) { $new_event = $_POST['t2_squard'][$i]; $query = "INSERT INTO #__bl_squard(match_id,team_id,player_id,mainsquard) VALUES(" . $row->id . "," . $row->team2_id . "," . $new_event . ",'1')"; $this->db->setQuery($query); $this->db->query(); } } if (isset($_POST['t1_squard_res']) && count($_POST['t1_squard_res'])) { for ($i = 0; $i < count($_POST['t1_squard_res']); $i++) { $new_event = $_POST['t1_squard_res'][$i]; $query = "INSERT INTO #__bl_squard(match_id,team_id,player_id,mainsquard) VALUES(" . $row->id . "," . $row->team1_id . "," . $new_event . ",'0')"; $this->db->setQuery($query); $this->db->query(); } } if (isset($_POST['t2_squard_res']) && count($_POST['t2_squard_res'])) { for ($i = 0; $i < count($_POST['t2_squard_res']); $i++) { $new_event = $_POST['t2_squard_res'][$i]; $query = "INSERT INTO #__bl_squard(match_id,team_id,player_id,mainsquard) VALUES(" . $row->id . "," . $row->team2_id . "," . $new_event . ",'0')"; $this->db->setQuery($query); $this->db->query(); } } //subs in $query = "DELETE FROM #__bl_subsin WHERE match_id=" . $row->id; $this->db->setQuery($query); $this->db->query(); if (isset($_POST['playersq1_id_arr']) && count($_POST['playersq1_id_arr'])) { for ($i = 0; $i < count($_POST['playersq1_id_arr']); $i++) { $player_in = intval($_POST['playersq1_id_arr'][$i]); $player_out = intval($_POST['playersq1_out_id_arr'][$i]); $minutes = intval($_POST['minutes1_arr'][$i]); $query = "INSERT INTO #__bl_subsin(match_id,team_id,player_in,player_out,minutes,season_id) VALUES(" . $row->id . "," . $row->team1_id . "," . $player_in . "," . $player_out . ",'" . $minutes . "'," . $season_id . ")"; $this->db->setQuery($query); $this->db->query(); } } if (isset($_POST['playersq2_id_arr']) && count($_POST['playersq2_id_arr'])) { for ($i = 0; $i < count($_POST['playersq2_id_arr']); $i++) { $player_in = intval($_POST['playersq2_id_arr'][$i]); $player_out = intval($_POST['playersq2_out_id_arr'][$i]); $minutes = intval($_POST['minutes2_arr'][$i]); $query = "INSERT INTO #__bl_subsin(match_id,team_id,player_in,player_out,minutes,season_id) VALUES(" . $row->id . "," . $row->team2_id . "," . $player_in . "," . $player_out . ",'" . $minutes . "'," . $season_id . ")"; $this->db->setQuery($query); $this->db->query(); } } //-- $query = "DELETE FROM #__bl_mapscore WHERE m_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); if (isset($_POST['mapid']) && count($_POST['mapid'])) { for ($i = 0; $i < count($_POST['mapid']); $i++) { $new_event = $_POST['mapid'][$i]; $query = "INSERT INTO #__bl_mapscore(m_id,map_id,m_score1,m_score2) VALUES(" . $row->id . "," . $new_event . "," . intval($_POST['t1map'][$i]) . "," . intval($_POST['t2map'][$i]) . ")"; $this->db->setQuery($query); $this->db->query(); } } $this->_id = $row->id; }
function savAdmPlayer() { $post = JRequest::get('post'); $post['about'] = JRequest::getVar('about', '', 'post', 'string', JREQUEST_ALLOWRAW); $post['def_img'] = JRequest::getVar('ph_default', 0, 'post', 'int'); $s_id = JRequest::getVar('sid', 0, '', 'int'); $tid = JRequest::getVar('tid', 0, '', 'int'); $row = new JTablePlayer($this->db); $user = JFactory::getUser(); $row->created_by = $user->id; if ($this->acl == 2) { $canmore = $post['id'] ? true : false; $query = "SELECT COUNT(*) FROM #__bl_players WHERE created_by=" . $user->id; $this->db->setQuery($query); $curcap = $this->db->loadResult(); $teams_per_account = $this->getJS_Config('players_per_account'); if ($curcap < $teams_per_account) { $canmore = true; } if (!$canmore) { JError::raiseError(403, JText::_('Access Forbidden')); return; } } if (!$row->bind($post)) { JError::raiseError(500, $row->getError()); } if ($this->acl == 1 && $row->id && $this->_lists["jssa_editplayer"]) { 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()); } if ($this->acl == 1) { $topt = $this->getTournOpt($s_id); if ($topt->t_single) { $query = "INSERT IGNORE INTO #__bl_season_players(season_id,player_id) VALUES(" . $s_id . "," . $row->id . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } elseif (!$post["id"] && intval($post["teams_seas"])) { $query = "INSERT IGNORE INTO #__bl_players_team(team_id,player_id,season_id) VALUES(" . intval($post["teams_seas"]) . "," . $row->id . "," . $s_id . ")"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } $row->checkin(); $query = "DELETE FROM #__bl_assign_photos WHERE cat_type = 1 AND cat_id = " . $row->id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (isset($_POST['photos_id']) && count($_POST['photos_id'])) { for ($i = 0; $i < count($_POST['photos_id']); $i++) { $photo_id = intval($_POST['photos_id'][$i]); $photo_name = addslashes(strval($_POST['ph_names'][$i])); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $photo_id . "," . $row->id . ",1)"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } $query = "UPDATE #__bl_photos SET ph_name = '" . $photo_name . "' WHERE id = " . $photo_id; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } if (isset($_FILES['player_photo_1']['name']) && $_FILES['player_photo_1']['tmp_name'] != '' && isset($_FILES['player_photo_1']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_1']['name']); $ext = pathinfo($_FILES['player_photo_1']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); //echo $bl_filename; if ($this->uploadFile($_FILES['player_photo_1']['tmp_name'], $bl_filename)) { $post1['ph_filename'] = $bl_filename; $img1 = new JTablePhotos($this->db); $img1->id = 0; if (!$img1->bind($post1)) { JError::raiseError(500, $img1->getError()); } if (!$img1->check()) { JError::raiseError(500, $img1->getError()); } // if new item order last in appropriate group if (!$img1->store()) { JError::raiseError(500, $img1->getError()); } $img1->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img1->id . "," . $row->id . ",1)"; $this->db->setQuery($query); $this->db->query(); } } else { if ($_FILES['player_photo_1']['error'] == 1) { //$this->mainframe->redirect( 'index.php?option=com_joomsport&task=adplayer_edit&controller=moder&tid='.$tid.'&cid[]='.$row->id,JText::_( 'BLBE_WRNGPHOTO' ),'warning'); if ($this->acl == 1) { $this->mainframe->redirect('index.php?option=com_joomsport&task=adplayer_edit&controller=admin&sid=' . $this->season_id . '&cid[]=' . $row->id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } else { if ($this->acl == 2) { $this->mainframe->redirect('index.php?option=com_joomsport&task=adplayer_edit&controller=moder&tid=' . $tid . '&cid[]=' . $row->id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } } } } if (isset($_FILES['player_photo_2']['name']) && $_FILES['player_photo_2']['tmp_name'] != '' && isset($_FILES['player_photo_2']['tmp_name'])) { $bl_filename = strtolower($_FILES['player_photo_2']['name']); $ext = pathinfo($_FILES['player_photo_2']['name']); $bl_filename = "bl" . time() . rand(0, 3000) . '.' . $ext['extension']; $bl_filename = str_replace(" ", "", $bl_filename); if ($this->uploadFile($_FILES['player_photo_2']['tmp_name'], $bl_filename)) { $post2['ph_filename'] = $bl_filename; $img2 = new JTablePhotos($this->db); $img2->id = 0; if (!$img2->bind($post2)) { JError::raiseError(500, $img2->getError()); } if (!$img2->check()) { JError::raiseError(500, $img2->getError()); } // if new item order last in appropriate group if (!$img2->store()) { JError::raiseError(500, $img2->getError()); } $img2->checkin(); $query = "INSERT INTO #__bl_assign_photos(photo_id,cat_id,cat_type) VALUES(" . $img2->id . "," . $row->id . ",1)"; $this->db->setQuery($query); $this->db->query(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } } } else { if ($_FILES['player_photo_2']['error'] == 1) { if ($this->acl == 1) { $this->mainframe->redirect('index.php?option=com_joomsport&task=adplayer_edit&controller=admin&sid=' . $this->season_id . '&cid[]=' . $row->id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } else { if ($this->acl == 2) { $this->mainframe->redirect('index.php?option=com_joomsport&task=adplayer_edit&controller=moder&tid=' . $tid . '&cid[]=' . $row->id, JText::_('BLBA_WRNGPHOTO'), 'warning'); } } } } if ($this->acl == 2) { $s_id = $this->mainframe->getUserStateFromRequest('com_joomsport.moderseason', 'moderseason', 0, 'int'); $query = "SELECT CONCAT(tr.name,' ',s.s_name) as t_name,s.s_id as id FROM #__bl_season_teams as t,#__bl_seasons as s,#__bl_tournament as tr WHERE s.published=1 AND tr.id=s.t_id AND s.s_id=t.season_id AND t.team_id=" . $tid . " ORDER BY s.s_id desc"; $this->db->setQuery($query); $seass = $this->db->loadObjectList(); $error = $this->db->getErrorMsg(); if ($error) { return JError::raiseError(500, $error); } if (!$s_id) { $s_id = $seass[0]->id; } } //-------extra fields-----------// if (isset($_POST['extraf']) && count($_POST['extraf'])) { foreach ($_POST['extraf'] as $p => $dummy) { if (intval($_POST['extra_id'][$p])) { $query = "SELECT season_related FROM `#__bl_extra_filds` WHERE id='" . intval($_POST['extra_id'][$p]) . "'"; $this->db->setQuery($query); $season_related = $this->db->loadResult(); $db_season = $season_related ? $s_id : 0; $query = "DELETE FROM #__bl_extra_values WHERE f_id = " . intval($_POST['extra_id'][$p]) . " AND uid = " . $row->id . " AND season_id='" . $db_season . "'"; $this->db->setQuery($query); $this->db->query(); if ($_POST['extra_ftype'][$p] == '2') { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue_text,season_id) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . addslashes($_POST['extraf'][$p]) . "',{$db_season})"; } else { $query = "INSERT INTO #__bl_extra_values(f_id,uid,fvalue,season_id) VALUES(" . $_POST['extra_id'][$p] . "," . $row->id . ",'" . addslashes($_POST['extraf'][$p]) . "',{$db_season})"; } $this->db->setQuery($query); $this->db->query(); } } } $this->id = $row->id; $this->season_id = $s_id; $this->tid = $tid; $this->is_first = $post['id'] ? 1 : 0; }