public function get_ranking($champ, $category) { function sort_teams($a, $b) { if ($a == $b) { return 0; } return $a < $b ? 1 : -1; } $teams = MCHFunctions::all_teams(true, "category={$category}"); $tranking = array(); foreach ($teams as $team) { $tranking[$team->id()] = array('wons' => $team->won_games($champ), 'id' => $team->id(), 'name' => $team->getVar('name'), 'logo' => $team->getVar('logo')); } $ord = array(); foreach ($tranking as $r) { $ord[$r['id']] = $r['wons']; } uasort($ord, 'sort_teams'); $ranking = array(); foreach ($ord as $k => $v) { $ranking[] = $tranking[$k]; } unset($tranking); $ranking = self::ranking_verified($ranking, $champ); return $ranking; }
<?php // $Id$ // -------------------------------------------------------------- // Matches // Module to publish and manage sports matches // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- include '../admin/header.php'; // Deactivate the logger error_reporting(0); $xoopsLogger->activated = false; if (!$xoopsSecurity->checkReferer()) { echo "Error:" . __('Session token invalid!', 'match'); die; } $q = rmc_server_var($_GET, 'q', ''); $teams = MCHFunctions::all_teams(false, "name LIKE '%{$q}%'"); if ($q != '') { foreach ($teams as $team) { echo $team['id_team'] . '. ' . $team['name'] . " <em>(" . $team['category_object']['name'] . ")</em>\r\n"; } die; } include RMTemplate::get()->get_template('mch_teams_field.php', 'module', 'match');
function m_show_roster() { global $xoopsModule, $xoopsSecurity; $db = XoopsDatabaseFactory::getDatabaseConnection(); $id = rmc_server_var($_REQUEST, 'id', 0); if ($id > 0) { MCHFunctions::page_from_item($id, 'player'); } $page = rmc_server_var($_REQUEST, 'page', 1); $page = $page <= 0 ? 1 : $page; $limit = 15; $team = rmc_server_var($_REQUEST, 'team', 0); $search = rmc_server_var($_REQUEST, 'search', ''); $filters = false; //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('mch_coaches'); if ($team > 0 || $search != '') { $sql .= " WHERE "; $filters = true; } $and = false; if ($team > 0) { $sql .= " team={$team}"; $and = true; $t = new MCHTeam($team); if (!$t->isNew()) { $team_data = array('name' => $t->getVar('name')); } unset($t); } if ($search != '') { $sql .= $and ? ' AND ' : ''; $sql .= "(name LIKE '%{$search}%' OR lastname LIKE '%{$search}%' OR surname LIKE '%{$search}%')"; } list($num) = $db->fetchRow($db->query($sql)); $tpages = ceil($num / $limit); $page = $page > $tpages ? $tpages : $page; $start = $num <= 0 ? 0 : ($page - 1) * $limit; $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url('coaches.php?page={PAGE_NUM}&team=' . $team); $coaches = array(); $sql = str_replace('COUNT(*)', '*', $sql); $sql .= ' ORDER BY ' . ($team > 0 ? 'charge,lastname,surname,name' : 'lastname,surname,name'); $result = $db->query($sql); $cache_team = array(); $timef = new RMTimeFormatter('', "%M% %d%, %Y%"); while ($row = $db->fetchArray($result)) { $coach = new MCHCoach(); $coach->assignVars($row); if (isset($cache_team[$coach->getVar('team')])) { $t = $cache_team[$coach->getVar('team')]; } else { $cache_team[$coach->getVar('team')] = new MCHTeam($coach->getVar('team')); $t = $cache_team[$coach->getVar('team')]; } $coaches[] = array('id' => $coach->id(), 'link' => $coach->permalink(), 'name' => $coach->getVar('name'), 'lastname' => $coach->getVar('lastname'), 'surname' => $coach->getVar('surname'), 'nameid' => $coach->getVar('nameid'), 'created' => $timef->format($coach->getVar('created')), 'charge' => MCHFunctions::charge_name($coach->getVar('charge')), 'team' => array('id' => $t->id(), 'name' => $t->getVar('name'), 'link' => $t->permalink())); } // Categories $teams = MCHFunctions::all_teams(false); // Event $coaches = RMEvents::get()->run_event('match.list.coaches', $coaches); MCHFunctions::toolbar(); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » " . __('Coaches', 'match')); RMTemplate::get()->assign('xoops_pagetitle', __('Coaches', 'match')); RMTemplate::get()->add_style('admin.css', 'match'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js'); RMTemplate::get()->add_local_script('admin_match.js', 'match'); RMTemplate::get()->add_head("<script type='text/javascript'>\nvar mch_message='" . __('Do you really want to delete selected coaches?', 'match') . "';\n\n var mch_select_message = '" . __('You must select some coach before to execute this action!', 'match') . "';</script>"); xoops_cp_header(); $match_extra_options = RMEvents::get()->run_event('match.more.options'); include RMTemplate::get()->get_template("admin/mch_coaches.php", 'module', 'match'); xoops_cp_footer(); }
function m_show_roleplay() { global $xoopsModule, $xoopsModuleConfig, $xoopsSecurity; $champ = rmc_server_var($_REQUEST, 'champ', 0); $category = rmc_server_var($_REQUEST, 'category', 0); $team = rmc_server_var($_REQUEST, 'team', 0); $sday = rmc_server_var($_REQUEST, 'sday', 0); $db = XoopsDatabaseFactory::getDatabaseConnection(); $champs = MCHFunctions::all_championships(); // Select role item if ($champ > 0 && $category > 0) { $sql = "SELECT * FROM " . $db->prefix("mch_role") . " WHERE champ='" . $champ . "' AND category='" . $category . "'"; if ($team > 0) { $sql .= " AND (local='{$team}' OR visitor='{$team}')"; } if ($sday > 0) { $sql .= " AND time<={$sday} AND time>=" . ($sday - 86400); } $sql .= " ORDER BY `time`"; $result = $db->query($sql); $role = array(); $tcache = array(); $fcache = array(); $tf = new RMTimeFormatter('', __('%M% %d%, %Y% - %h%:%i%', 'match')); $i = 0; $days = array(); $pday = 0; while ($row = $db->fetchArray($result)) { $item = new MCHRoleItem(); $item->assignVars($row); if (isset($tcache[$item->getVar('local')])) { $local = $tcache[$item->getVar('local')]; } else { $tcache[$item->getVar('local')] = new MCHTeam($item->getVar('local')); $local = $tcache[$item->getVar('local')]; } if (isset($tcache[$item->getVar('visitor')])) { $visitor = $tcache[$item->getVar('visitor')]; } else { $tcache[$item->getVar('visitor')] = new MCHTeam($item->getVar('visitor')); $visitor = $tcache[$item->getVar('visitor')]; } if (isset($fcache[$item->getVar('field')])) { $field = $fcache[$item->getVar('field')]; } else { $fcache[$item->getVar('field')] = new MCHField($item->getVar('field')); $field = $fcache[$item->getVar('field')]; } $role[$i] = array('id' => $item->id(), 'local' => array('id' => $local->id(), 'logo' => MCH_UP_URL . '/' . $local->getVar('logo'), 'name' => $local->getVar('name')), 'visitor' => array('id' => $visitor->id(), 'logo' => MCH_UP_URL . '/' . $visitor->getVar('logo'), 'name' => $visitor->getVar('name')), 'date' => $tf->format($item->getVar('time')), 'hour' => $tf->format($item->getVar('time'), '%h%:%i%'), 'time' => $item->getVar('time'), 'field' => array('id' => $field->id(), 'name' => $field->getVar('name')), 'past' => $item->getVar('time') < time() ? true : false); if ($role[$i]['past']) { $score = new MCHScoreItem(); $score->byRole($item->id()); $role[$i]['local']['score'] = $score->getVar('local'); $role[$i]['visitor']['score'] = $score->getVar('visitor'); } // Add days to combo if ($pday <= 0) { $pday = mktime(0, 0, 1, date("m", $item->getVar('time')), date("d", $item->getVar('time')), date('Y', $item->getVar('time'))); $days[] = $pday; } $now = mktime(23, 59, 0, date("m", $item->getVar('time')), date("d", $item->getVar('time')), date('Y', $item->getVar('time'))); if ($now > $pday + 86400) { $pday = $now; $days[] = $pday; } $i++; } } // Charge days if incomplete if ($champ > 0 && $category > 0 && $sday > 0) { $sql = "SELECT * FROM " . $db->prefix("mch_role") . " WHERE champ='" . $champ . "' AND category='" . $category . "'"; if ($team > 0) { $sql .= " AND (local='{$team}' OR visitor='{$team}')"; } $sql .= " ORDER BY `time`"; $result = $db->query($sql); $days = array(); $pday = 0; while ($row = $db->fetchArray($result)) { $item = new MCHRoleItem(); $item->assignVars($row); // Add days to combo if ($pday <= 0) { $pday = mktime(0, 0, 1, date("m", $item->getVar('time')), date("d", $item->getVar('time')), date('Y', $item->getVar('time'))); $days[] = $pday; } $now = mktime(23, 59, 0, date("m", $item->getVar('time')), date("d", $item->getVar('time')), date('Y', $item->getVar('time'))); if ($now > $pday + 86400) { $pday = $now; $days[] = $pday; } } } // Categories $categories = array(); MCHFunctions::categories_tree($categories); // Teams $teams = MCHFunctions::all_teams(false, 'category=' . $category); // Fields $fields = MCHFunctions::all_fields(); // Date field $form = new RMForm('', '', ''); $datetime = new RMFormDate('', 'date', '', '', 1); $datetime->options('stepMinute: 15'); MCHFunctions::toolbar(); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » " . __('Role Play', 'match')); RMTemplate::get()->assign('xoops_pagetitle', __('Coaches', 'match')); RMTemplate::get()->add_style('admin.css', 'match'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js'); RMTemplate::get()->add_local_script('admin_match.js', 'match'); RMTemplate::get()->add_head("<script type='text/javascript'>\nvar mch_message='" . __('Do you really want to delete selected items?', 'match') . "';\n\n var mch_select_message = '" . __('You must select some role item before to execute this action!', 'match') . "';</script>"); xoops_cp_header(); $match_extra_options = RMEvents::get()->run_event('match.more.options'); include RMTemplate::get()->get_template("admin/mch_roleplay.php", 'module', 'match'); xoops_cp_footer(); }