Exemple #1
0
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 next matches
  * 
  * @param int Category identifier
  * @param int Number of items per category
  * @param int Championship identifier. If not is provided or 0 is provided then will be used the current championship.
  * @return array
  */
 public function next_matches($cat = 0, $c = 0, $limit = 0, $team = 0)
 {
     if ($c <= 0) {
         $champ = self::current_championship();
     } else {
         $champ = new MCHChampionship($c);
     }
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     $sql = "SELECT * FROM " . $db->prefix("mch_role") . " WHERE champ='" . $champ->id() . "' AND time>=" . time();
     if ($cat > 0) {
         $sql .= " AND category='" . $cat . "'";
     }
     if ($team > 0) {
         $sql .= " AND (local={$team} OR visitor={$team})";
     }
     $sql .= " ORDER BY time";
     if ($limit > 0) {
         $sql .= " LIMIT 0,{$limit}";
     }
     $result = $db->query($sql);
     $data = array();
     $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('name' => $local->getVar('name'), 'logo' => XOOPS_UPLOAD_URL . '/teams/' . $local->getVar('logo'), 'id' => $local->id()), 'visitor' => array('name' => $visitor->getVar('name'), 'logo' => XOOPS_UPLOAD_URL . '/teams/' . $visitor->getVar('logo'), 'id' => $visitor->id()), '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'));
     }
     return $data;
 }
Exemple #3
0
// Matches
// Module to publish and manage sports matches
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// 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) {