function m_teams_form($edit = 0) { global $mc, $xoopsModule, $db; MCHFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Team', 'match') : __('Add Team', 'match')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n <a href='teams.php'>" . __('Teams', 'match') . '</a> » ' . ($edit ? __('Edit Team', 'match') : __('Add Team', 'match'))); xoops_cp_header(); $id = rmc_server_var($_REQUEST, 'id', 0); if ($edit) { //Verificamos si la categoría es válida if ($id <= 0) { redirectMsg('./teams.php', __('Provide a team ID!', 'match'), 1); die; } //Verificamos si la categoría existe $team = new MCHTeam($id); if ($team->isNew()) { redirectMsg('./teams.php', __('Specified team was not found!', 'match'), 1); die; } } $form = new RMForm($edit ? __('Edit Team', 'match') : __('Add Team', 'match'), 'frmNew', 'teams.php'); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new RMFormText(__('Name', 'match'), 'name', 50, 150, $edit ? $team->getVar('name') : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 150, $team->getVar('nameid')), true); } $form->addElement(new RMFormEditor(__('Team Information', 'match'), 'info', '100%', '250px', $edit ? $team->getVar('info', 'e') : '')); $sel_cats = new RMFormSelect(__('Category:', 'match'), 'category', 0, $edit ? array($team->getVar('category')) : 0); $categories = array(); MCHFunctions::categories_tree($categories, 0, 0, true, 0, '`name` ASC'); $sel_cats->addOption(0, __('Select category...', 'match'), $edit ? $team->getVar('category') == 0 ? 1 : 0 : 1); foreach ($categories as $catego) { $sel_cats->addOption($catego['id'], str_repeat('—', $catego['indent']) . ' ' . $catego['name']); } $form->addElement($sel_cats, true); $form->addElement(new RMFormYesNo(__('Active', 'match'), 'active', $edit ? $team->getVar('active') : 1)); $form->addElement(new RMFormDate(__('Registered on', 'match'), 'created', $edit ? $team->getVar('created') : time(), false)); $form->addElement(new RMFormFile(__('Team logo', 'match'), 'logo', 45)); if ($edit) { $form->addElement(new RMFormLabel(__('Current logo', 'match'), '<img src="' . MCH_UP_URL . '/' . $team->getVar('logo') . '" alt="' . $team->getVar('name') . '" />')); } $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $team->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'teams.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('match.form.teams', $form); $form->display(); xoops_cp_footer(); }
/** * Show the form to edit or create a category * @param int edit */ function m_categories_form($edit = 0) { global $mc, $xoopsModule, $db; MCHFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Category', 'match') : __('Add Category', 'match')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n <a href='categories.php'>" . __('Categories', 'match') . '</a> » ' . ($edit ? __('Edit Category', 'match') : __('Add Category', 'match'))); xoops_cp_header(); $id = rmc_server_var($_REQUEST, 'id', 0); if ($edit) { //Verificamos si la categoría es válida if ($id <= 0) { redirectMsg('./categories.php', __('Provide a category ID!', 'match'), 1); die; } //Verificamos si la categoría existe $cat = new MCHCategory($id); if ($cat->isNew()) { redirectMsg('./categories.php', __('Specified category was not found!', 'match'), 1); die; } } $form = new RMForm($edit ? __('Edit Category', 'match') : __('Add Category', 'match'), 'frmNew', 'categories.php'); $form->addElement(new RMFormText(__('Name', 'match'), 'name', 50, 150, $edit ? $cat->getVar('name') : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 150, $cat->getVar('nameid')), true); } $form->addElement(new RMFormEditor(__('Description', 'match'), 'desc', '100%', '250px', $edit ? $cat->getVar('description', 'e') : '')); $sel_cats = new RMFormSelect(__('Parent category:', 'match'), 'parent', 0, $edit ? $cat->getVar('parent') : 0); $categories = array(); MCHFunctions::categories_tree($categories, 0, 0, true, $edit ? $cat->id() : 0, '`name` ASC'); $sel_cats->addOption(0, __('Select category...', 'match'), $edit ? $cat->getVar('parent') == 0 ? 1 : 0 : 1); foreach ($categories as $catego) { $sel_cats->addOption($catego['id'], str_repeat('—', $catego['indent']) . ' ' . $catego['name']); } $form->addElement($sel_cats); $form->addElement(new RMFormYesNo(__('Enable category', 'match'), 'active', $edit ? $cat->getVar('active') : 1)); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $cat->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'categos.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('match.form.categories', $form); $form->display(); xoops_cp_footer(); }
function m_show_ranking() { global $xoopsModule; $champ = rmc_server_var($_REQUEST, 'champ', 0); $category = rmc_server_var($_REQUEST, 'category', 0); $champs = MCHFunctions::all_championships(); $categories = array(); MCHFunctions::categories_tree($categories); if ($champ > 0 && $category > 0) { $ranking = MCHFunctions::get_ranking($champ, $category); } 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_ranking.php", 'module', 'match'); xoops_cp_footer(); }
function m_field_form($edit = 0) { global $xoopsModule, $xoopsModuleConfig; MCHFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Field', 'match') : __('Add Field', 'match')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n <a href='fields.php'>" . __('Fields', 'match') . '</a> » ' . ($edit ? __('Edit Field', 'match') : __('Add Field', 'match'))); xoops_cp_header(); $id = rmc_server_var($_REQUEST, 'id', 0); if ($edit) { //Verificamos si la categoría es válida if ($id <= 0) { redirectMsg('./fields.php', __('Provide a field ID!', 'match'), 1); die; } //Verificamos si la categoría existe $field = new MCHField($id); if ($field->isNew()) { redirectMsg('./fields.php', __('Specified field was not found!', 'match'), 1); die; } } $form = new RMForm($edit ? __('Edit Field', 'match') : __('Add Field', 'match'), 'frmNew', 'fields.php'); $form->addElement(new RMFormText(__('Name', 'match'), 'name', 50, 200, $edit ? $field->getVar('name') : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 200, $field->getVar('nameid')), true); } $form->addElement(new RMFormEditor(__('Description', 'match'), 'description', '100%', '250px', $edit ? $field->getVar('description', 'e') : '')); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $field->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'fields.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('match.form.fields', $form); $form->display(); RMTemplate::get()->add_style('admin.css', 'match'); xoops_cp_footer(); }
/** * Form to create a new player * * @param int Create (0) or edit (1) a player */ function m_coaches_form($edit = 0) { global $xoopsModule, $xoopsModuleConfig; MCHFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Coach', 'match') : __('Add Coach', 'match')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n <a href='coaches.php'>" . __('Coaches', 'match') . '</a> » ' . ($edit ? __('Edit Coach', 'match') : __('Add Coach', 'match'))); xoops_cp_header(); $id = rmc_server_var($_REQUEST, 'id', 0); if ($edit) { //Verificamos si la categoría es válida if ($id <= 0) { redirectMsg('./coaches.php', __('Provide a coach ID!', 'match'), 1); die; } //Verificamos si la categoría existe $coach = new MCHCoach($id); if ($coach->isNew()) { redirectMsg('./coaches.php', __('Specified coach was not found!', 'match'), 1); die; } } $form = new RMForm($edit ? __('Edit Coach', 'match') : __('Add Coach', 'match'), 'frmNew', 'coaches.php'); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new RMFormText(__('Name(s)', 'match'), 'name', 50, 200, $edit ? $coach->getVar('name') : ''), true); $form->addElement(new RMFormText(__('Lastname', 'match'), 'lastname', 50, 200, $edit ? $coach->getVar('lastname') : ''), true); $form->addElement(new RMFormText(__('Surname', 'match'), 'surname', 50, 200, $edit ? $coach->getVar('surname') : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 200, $coach->getVar('nameid')), true); } $form->addElement(new RMFormEditor(__('Biography', 'match'), 'bio', '100%', '250px', $edit ? $coach->getVar('bio', 'e') : '')); $form->addElement(new MCHTeamsField(__('Team', 'match'), 'team', $edit ? $coach->getVar('team') : 0), true); $form->addElement(new RMFormDate(__('Registered', 'match'), 'created', $edit ? $coach->getVar('created') : time(), $xoopsModuleConfig['year_range']), 1); $charges = new RMFormSelect(__('Charge', 'match'), 'charge', 0, $edit ? array($coach->getVar('charge')) : 0); $charges->addOption(0, __('Select position...', 'match')); $charges->addOption(1, __('Manager', 'match')); $charges->addOption(2, __('Coach', 'match')); $charges->addOption(3, __('Assistant', 'match')); $form->addElement($charges); $form->addElement(new RMFormFile(__('Picture', 'match'), 'photo', 45)); if ($edit) { $form->addElement(new RMFormLabel(__('Current picture', 'match'), '<img src="' . MCH_UP_URL . '/coaches/ths/' . $coach->getVar('photo') . '" alt="' . $coach->getVar('name') . '" />')); } $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $coach->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'coaches.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('match.form.coaches', $form); $form->display(); RMTemplate::get()->add_style('admin.css', '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(); }