function m_delete_championships() { global $xoopsModule, $xoopsSecurity; $ids = rmc_server_var($_POST, 'ids', array()); //Verificamos que nos hayan proporcionado una categoría para eliminar if (empty($ids)) { redirectMsg('./champ.php', __('No championships selected!', 'match'), 1); die; } if (!$xoopsSecurity->check()) { redirectMsg('./champ.php', __('Session token expired!', 'match'), 1); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); $errors = ''; foreach ($ids as $k) { //Verificamos si la categoría es válida if ($k <= 0) { $errors .= sprintf(__('Championship id "%s" is not valid!', 'match'), $k); continue; } //Verificamos si la categoría existe $champ = new MCHChampionship($k); if ($champ->isNew()) { $errors .= sprintf(__('Championship "%s" does not exists!', 'match'), $k); continue; } RMEvents::get()->run_event('match.delete.championship', $cat); if (!$champ->delete()) { $errors .= sprintf(__('Championship "%s" could not be deleted!', 'match'), $champ->getVar('name')); } } if ($errors != '') { redirectMsg('./champ.php', __('Errors ocurred while trying to delete championships', 'match') . '<br />' . $errors, 1); die; } else { redirectMsg('./champ.php', __('Database updated successfully!', 'match'), 0); die; } }
/** * Get championships list */ public function all_championships() { $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("mch_champs") . " ORDER BY start DESC"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $ch = new MCHChampionship(); $ch->assignVars($row); $champs[$ch->id()] = array('id' => $ch->id(), 'name' => $ch->getVar('name'), 'nameid' => $ch->getVar('nameid'), 'start' => $ch->getVar('start'), 'end' => $ch->getVar('end'), 'current' => $ch->getVar('end') <= time() ? false : $ch->getVar('current')); unset($ch); } return $champs; }
// License: GPL 2.0 // -------------------------------------------------------------- include 'header.php'; $xoopsOption['template_main'] = "mch_rol.html"; $xoopsOption['module_subpage'] = 'index'; include XOOPS_ROOT_PATH . '/header.php'; // Get current match $id_champ = rmc_server_var($_REQUEST, 'ch', 0); if ($id_champ <= 0) { $champ = MCHFunctions::current_championship(); } else { $champ = new MCHChampionship($id_champ); } // Time Formatter $tf = new RMTimeFormatter(0, __('%M% %d%, %Y%', 'match')); $xoopsTpl->assign('champ', array('id' => $champ->id(), 'name' => $champ->getVar('name'), 'start' => $tf->format($champ->getVar('start')), 'end' => $tf->format($champ->getVar('end')))); // Get category $id_cat = rmc_server_var($_REQUEST, 'cat', 0); if ($id_cat > 0) { $category = new MCHCategory($id_cat); } else { $category = MCHFunctions::first_category(); } $xoopsTpl->assign('category', array('id' => $category->id(), 'name' => $category->getVar('name'), 'desc' => $category->getVar('description'))); // Get category $id_team = rmc_server_var($_REQUEST, 'team', 0); if ($id_team > 0) { $team = new MCHTeam($id_team); $xoopsTpl->assign('team', array('id' => $team->id(), 'name' => $team->getVar('name'), 'desc' => $team->getVar('info'))); } // Role