Exemple #1
0
function m_send_team_data()
{
    $id = rmc_server_var($_GET, 'id', 0);
    if ($id <= 0) {
        response_error(__('No team id has been provided!', 'match'));
    }
    $team = new MCHTeam($id);
    if ($team->isNew()) {
        response_error(__('Specified team does not exists', 'match'));
    }
    $ret = array('id' => $team->id(), 'name' => $team->getVar('name'), 'logo' => MCH_UP_URL . '/' . $team->getVar('logo'));
    echo json_encode($ret);
    die;
}
 /**
  * Create field code
  */
 public function render()
 {
     if ($this->selected > 0) {
         $team = new MCHTeam($this->selected);
     }
     $rtn = '<div class="mch_teams_field" id="teams-container-' . $this->getName() . '" title="' . __('Click to select a new team', 'match') . '">';
     if ($this->selected > 0 && !$team->isNew()) {
         $tf = new RMTimeFormatter(0, __('%M% %d%, %Y%', 'match'));
         $rtn .= '<img src="' . MCH_UP_URL . '/' . $team->getVar('logo') . '" class="logo" alt="' . $team->getVar('name') . '" />';
         $rtn .= '<strong>' . $team->getVar('name') . '</strong>';
         $rtn .= '<span>' . $tf->format($team->getVar('created')) . '</span>';
     } else {
         $rtn .= '<img src="' . MCH_URL . '/images/add.png" alt="' . __('Add team', 'match') . '" /><span class="noselected">' . __('Select one team...', 'match') . '</span>';
     }
     $rtn .= '</div><div id="mch-teams-loader-' . $this->getName() . '" class="mch_teams_pop"></div>';
     $rtn .= '<input type="hidden" name="' . $this->getName() . '" id="mch-tf-value-' . $this->getName() . '" value="' . ($this->selected > 0 && !$team->isNew() ? $this->selected : '') . '" />';
     return $rtn;
 }
 /**
  * Get results
  */
 public function latest_results($cat = 0, $c = 0, $limit = 0)
 {
     if ($c <= 0) {
         $champ = self::current_championship();
     } else {
         $champ = new MCHChampionship($c);
     }
     if (!is_object($champ)) {
         $champ = self::last_championship();
     }
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $tbr = $db->prefix("mch_role");
     $tbs = $db->prefix("mch_score");
     $sql = "SELECT a.*, s.item, s.local as loc, s.visitor as vis, s.win, s.champ FROM {$tbr} as a, {$tbs} as s WHERE a.champ='" . $champ->id() . "' AND a.time<" . time();
     if ($cat > 0) {
         $sql .= " AND a.category='" . $cat . "'";
     }
     $sql .= " AND s.item=a.id_role ORDER BY a.time DESC LIMIT 0, {$limit}";
     $result = $db->query($sql);
     $tf = new RMTimeFormatter();
     while ($row = $db->fetchArray($result)) {
         $local = new MCHTeam($row['local']);
         $visitor = new MCHTeam($row['visitor']);
         $category = new MCHCategory($row['category']);
         $field = new MCHField($row['field']);
         $data[] = array('local' => array('id' => $local->id(), 'name' => $local->getVar('name'), 'logo' => XOOPS_UPLOAD_URL . '/teams/' . $local->getVar('logo'), 'score' => $row['loc']), 'visitor' => array('id' => $visitor->id(), 'name' => $visitor->getVar('name'), 'logo' => XOOPS_UPLOAD_URL . '/teams/' . $visitor->getVar('logo'), 'score' => $row['vis']), 'day' => $tf->format($row['time'], __('%M% %d%', 'match')), 'hour' => $tf->format($row['time'], __('%h%:%i%', 'match')), 'category' => array('name' => $category->getVar('name'), 'link' => $category->permalink()), 'field' => $field->getVar('name'), 'win' => $row['win']);
     }
     return $data;
 }
Exemple #4
0
/**
* Deleting a category
*/
function m_delete_teams()
{
    global $xoopsModule, $xoopsSecurity;
    $ids = rmc_server_var($_POST, 'ids', array());
    //Verificamos que nos hayan proporcionado una categoría para eliminar
    if (empty($ids)) {
        redirectMsg('./teams.php', __('No teams selected!', 'match'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('./teams.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(__('Team id "%s" is not valid!', 'match'), $k);
            continue;
        }
        //Verificamos si la categoría existe
        $team = new MCHTeam($k);
        if ($team->isNew()) {
            $errors .= sprintf(__('Team "%s" does not exists!', 'match'), $k);
            continue;
        }
        RMEvents::get()->run_event('match.delete.team', $cat);
        $file = MCH_UP_PATH . '/' . $team->getVar('logo');
        if (!$team->delete()) {
            $errors .= sprintf(__('Team "%s" could not be deleted!', 'match'), $k);
        } else {
            if (is_file($file)) {
                unlink($file);
            }
        }
    }
    if ($errors != '') {
        redirectMsg('./teams.php', __('Errors ocurred while trying to delete teams', 'match') . '<br />' . $errors, 1);
        die;
    } else {
        redirectMsg('./teams.php', __('Database updated successfully!', 'match'), 0);
        die;
    }
}
Exemple #5
0
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}&amp;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> &raquo; " . __('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();
}
Exemple #6
0
}
// 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
$data = MCHFunctions::next_matches($category->id(), $champ->id(), 0, $id_team);
$xoopsTpl->assign('roleplay', $data);
$categories = array();
MCHFunctions::categories_tree($categories);
foreach ($categories as $k => $cat) {
    $categories[$k]['guion'] = str_repeat("&#151;", $cat['indent']);
}
$xoopsTpl->assign('categories', $categories);
// Championships
$xoopsTpl->assign('champs', MCHFunctions::all_championships());
// Constants
$xoopsTpl->assign('mch_upurl', MCH_UP_URL);