public function teams()
 {
     if (empty($this->teams)) {
         $result = $this->db->query("SELECT * FROM " . $this->db->prefix("coach_teams") . " WHERE cat='" . $this->id() . "'");
         while ($row = $this->db->fetchArray($result)) {
             $team = new TCTeam();
             $team->assignVars($row);
             $this->teams[] = $team;
         }
     }
     return $this->teams;
 }
function tc_block_players_edit($options, &$form)
{
    $form->addElement(new RMSubTitle(_AS_BKM_BOPTIONS, 1));
    // Equipos
    $ele = new RMSelect(_BK_TC_TEAM, 'options[0]');
    $ele->addOption(0, _BK_TC_ALLTEAM, $options[0] > 0 ? 0 : 1);
    $db =& XoopsDatabaseFactory::getDatabaseConnection();
    $result = $db->query("SELECT * FROM " . $db->prefix("coach_teams") . " ORDER BY name");
    while ($row = $db->fetchArray($result)) {
        $team = new TCTeam();
        $team->assignVars($row);
        $cat = $team->category(true);
        $ele->addOption($row['id_team'], $row['name'] . " (" . $cat->name() . ")", $row['id_team'] == $options[0] ? 1 : 0);
    }
    $form->addElement($ele);
    $form->addElement(new RMText(_BK_TC_NUMBER, 'options[1]', 10, 3, $options[1]));
    $form->addElement(new RMText(_BK_TC_COLNUMBER, 'options[2]', 10, 3, $options[2]));
    return $form;
}
Exemple #3
0
function formCoachs($edit = 0)
{
    global $xoopsModule, $db, $mc, $xoopsConfig;
    if ($edit) {
        $id = TCFunctions::get('id');
        if ($id <= 0) {
            redirectMsg('coachs.php', __('Id no válido', 'admin_team'), 1);
            die;
        }
        $coach = new TCCoach($id);
        if ($coach->isNew()) {
            redirectMsg('coachs.php', __('El entrenador especificado no existe', 'admin_team'), 1);
            die;
        }
    }
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./coachs.php'>" . __('Entrenadores', 'admin_team') . "</a> &raquo; " . ($edit ? __('Editar entrenador', 'admin_team') : __('Crear entrenador', 'admin_team')));
    $cHead = '<link href="' . TC_URL . '/styles/admin.css" media="all" rel="stylesheet" type="text/css" />';
    xoops_cp_header($cHead);
    $form = new RMForm($edit ? __('Editar Entrenador', 'admin_team') : __('Crear Entrenador', 'admin_team'), 'frmNew', 'coachs.php', 'post');
    $form->oddClass('oddForm');
    $form->setExtra('enctype="multipart/form-data"');
    $form->addElement(new RMFormText(__('Nombre', 'admin_team'), 'name', 50, 150, $edit ? $coach->name() : ''), true);
    if ($edit) {
        $form->addElement(new RMFormText(__('Nombre corto', 'admin_team'), 'nameid', 50, 150, $coach->nameId()));
    }
    $form->addElement(new RMFormText(__('Cargo', 'admin_team'), 'role', 50, 150, $edit ? $coach->role() : ''), true);
    $form->addElement(new RMFormFile(__('Imagen', 'admin_team'), 'image', 45, $mc['filesize'] * 1024));
    if ($edit && $coach->image() != '') {
        $form->addElement(new RMFormLabel(__('Imagen actual', 'admin_team'), "<img src='" . XOOPS_URL . "/uploads/teams/coachs/ths/" . $coach->image() . "' alt='' />"));
    }
    $form->addElement(new RMFormEditor(__('Biografía', 'admin_team'), 'bio', '90%', '300px', $edit ? $coach->bio('e') : ''));
    $form->addElement(new RMFormSubTitle(__('Equipos', 'admin_team'), 1));
    $ele = new RMFormCheck(__('Seleccionar equipos', 'admin_team'));
    $ele->asTable(3);
    $sql = "SELECT * FROM " . $db->prefix("coach_teams") . " ORDER BY name";
    $result = $db->query($sql);
    if ($edit) {
        $teams = $coach->teams(false);
    }
    while ($row = $db->fetchArray($result)) {
        $team = new TCTeam();
        $team->assignVars($row);
        $cat =& $team->category(true);
        $ele->addOption($team->name() . " <span class='coachNameCat'>(" . $cat->name() . ")</span>", 'teams[]', $team->id(), $edit ? in_array($team->id(), $teams) ? 1 : 0 : 0);
    }
    $form->addElement($ele);
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', __('Enviar', 'admin_team'), 'submit');
    $ele->addButton('cancel', __('Cancelar', 'admin_team'), 'button', 'onclick="window.location=\'coachs.php\';"');
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $id));
    }
    $form->display();
    xoops_cp_footer();
}
Exemple #4
0
if ($xoopsDB->getRowsNum($result) == 1) {
    $row = $xoopsDB->fetchArray($result);
    $link = XOOPS_URL . "/modules/team/" . ($mc['urlmode'] ? "t/{$row['nameid']}/" : "team.php?id={$row['nameid']}");
    header('Location: ' . $link);
    die;
}
$xoopsOption['template_main'] = "coach_index.html";
include 'header.php';
$tpl->assign('coach_title', _MS_TC_TITLE);
$tpl->assign('lang_comment', _MS_TC_COMMENT);
// Categorías
$tpl->assign('lang_categos', _MS_TC_CATTITLE);
$result = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix("coach_categos") . " ORDER BY name");
$cats = array();
while ($row = $xoopsDB->fetchArray($result)) {
    $cat = new TCCategory();
    $cat->assignVars($row);
    $cats[$cat->id()] = $cat;
    $link = TC_URL . '/' . ($mc['urlmode'] ? 'cat/' . $cat->nameId() . '/' : 'category.php?id=' . $cat->id());
    $tpl->append('categos', array('id' => $cat->id(), 'name' => $cat->name(), 'desc' => $cat->desc(), 'link' => $link));
}
// Equipos
$tpl->assign('lang_teams', _MS_TC_TEAMSTITLE);
$result = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix("coach_teams") . " ORDER BY name");
while ($row = $xoopsDB->fetchArray($result)) {
    $team = new TCTeam();
    $team->assignVars($row);
    $link = TC_URL . '/' . ($mc['urlmode'] ? 't/' . $team->nameId() . '/' : 'team.php?id=' . $team->id());
    $tpl->append('teams', array('id' => $team->id(), 'name' => $team->name() . " <em>(" . $cats[$team->category(false)]->name() . ")</em>", 'link' => $link));
}
include 'footer.php';
Exemple #5
0
}
$xoopsOption['template_main'] = "coach_player.html";
include 'header.php';
$tpl->assign('coach_title', $player->name() . " (#" . $player->number() . ")");
$tpl->assign('lang_comment', _MS_TC_COMMENT);
$tpl->assign('lang_data', _MS_TC_DATA);
$tpl->assign('lang_name', _MS_TC_NAME);
$tpl->assign('lang_number', _MS_TC_NUMBER);
$tpl->assign('lang_team', _MS_TC_TEAM);
$tpl->assign('lang_age', _MS_TC_AGE);
$tpl->assign('lang_date', _MS_TC_DATE);
$tpl->assign('lang_bio', _MS_TC_BIO);
$tpl->assign('lang_link', _MS_TC_LINK);
$link = TC_URL . '/' . ($mc['urlmode'] ? 'player/' . $player->nameId() . '/' : 'player.php?id=' . $player->id());
$tpl->assign('player', array('id' => $player->id(), 'name' => $player->name(), 'image' => $player->image(), 'number' => $player->number(), 'age' => $player->age(), 'date' => formatTimestamp($player->date(), 'c'), 'bio' => $player->bio(), 'link' => $link));
$team = new TCTeam($player->team());
$tpl->assign('xoops_pagetitle', sprintf(_MS_TC_PTITLE, $team->name(), $player->number()));
$tlink = TC_URL . '/' . ($mc['urlmode'] ? 't/' . $team->nameId() . '/' : 'team.php?id=' . $team->id());
$location = "<a href='" . TC_URL . "'>" . $xoopsModule->name() . "</a> &raquo; <a href='{$tlink}'>" . $team->name() . "</a> &raquo; " . $player->name();
$tpl->assign('coach_location', $location);
$tpl->assign('team', array('id' => $team->id(), 'name' => $team->name(), 'link' => $tlink));
$tpl->assign('lang_players', sprintf(_MS_TC_PLAYERS, $team->name()));
// Integrantes
$players = $team->players(true, 'RAND()');
$i = 1;
foreach ($players as $player) {
    if ($i > 4) {
        break;
    }
    $link = TC_URL . '/' . ($mc['urlmode'] ? 'player/' . $player->nameId() . '/' : 'player.php?id=' . $player->id());
    $tpl->append('players', array('id' => $player->id(), 'name' => $player->name(), 'image' => $player->image(), 'number' => $player->number(), 'link' => $link));
Exemple #6
0
function deleteTeams()
{
    global $db;
    $teams = TCFunctions::request('teams');
    if (empty($teams)) {
        redirectMsg('teams.php', __('No has seleccionado ningún equipo', 'admin_team'), 1);
        die;
    }
    foreach ($teams as $k) {
        $team = new TCTeam($k);
        $team->delete();
    }
    redirectMsg('teams.php', __('Base de datos actualizada correctamente', 'admin_team'), 0);
}
 /**
  * @desc Devuelve los equipos a los que pertenece el entrenador
  * @return array Objetos {@link TCTeam}
  */
 public function teams($obj = true)
 {
     if (empty($this->_teams)) {
         $this->_teams = array();
         $this->_teamsid = array();
         $tbl1 = $this->db->prefix("coach_teams");
         $tbl2 = $this->db->prefix("coach_teamcoach");
         $sql = "SELECT a.* FROM {$tbl1} a, {$tbl2} b WHERE b.id_coach='" . $this->id() . "' AND a.id_team=b.id_team";
         $result = $this->db->query($sql);
         while ($row = $this->db->fetchArray($result)) {
             $team = new TCTeam();
             $team->assignVars($row);
             $this->_teams[] = $team;
             $this->_teamsid[] = $team->id();
         }
     }
     return $obj ? $this->_teams : $this->_teamsid;
 }
Exemple #8
0
function savePlayer($edit = 0)
{
    global $db, $mc, $xoopsSecurity;
    $nameid = '';
    $teams = array();
    $idteam = 0;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    if (!$xoopsSecurity->validateToken()) {
        redirectMsg('players.php?team=' . $idteam . ($edit ? "&op=edit&id={$id}" : "&op=new"), __('El identificador se sesión ha expirado', 'admin_team'), 1);
        break;
    }
    $idteam = TCFunctions::request('team');
    if ($idteam <= 0) {
        redirectMsg('teams.php', __('No se ha especificado un equipo', 'admin_team'), 1);
        die;
    }
    $team = new TCTeam($idteam);
    if ($team->isNew()) {
        redirectMsg('teams.php', __('El equipo especificado no existe', 'admin_team'), 1);
        die;
    }
    if ($edit) {
        $id = TCFunctions::post('id');
        if ($id <= 0) {
            redirectMsg('players.php?team=' . $idteam, __('No se ha especificado un jugador para editar', 'admin_team'), 1);
            die;
        }
        $player = new TCPLayer($id);
        if ($player->isNew()) {
            redirectMsg('players.php?team=' . $idteam, __('El jugador especificado no existe', 'admin_team'), 1);
            die;
        }
        $i = 0;
        do {
            $nameid = $nameid != '' && $i == 0 ? $nameid : $util->sweetstring($name) . ($i > 0 ? $i : '');
            $sql = "SELECT COUNT(*) FROM " . $db->prefix("coach_players") . " WHERE nameid='{$nameid}' AND id_play<>'" . $player->id() . "'";
            list($num) = $db->fetchRow($db->query($sql));
            $i++;
        } while ($num > 0);
        $sql = "SELECT COUNT(*) FROM " . $db->prefix("coach_players") . " WHERE name='{$name}' AND id_play<>'" . $player->id() . "'";
        list($num) = $db->fetchRow($db->query($sql));
        if ($num > 0) {
            redirectMsg('players.php?team=' . $idteam . '&op=edit&id=' . $player->id(), __('Ya existe otro jugador con el mismo nombre', 'admin_team'), 1);
            die;
        }
    } else {
        $player = new TCPlayer();
        $i = 0;
        do {
            $nameid = TextCleaner::getInstance()->sweetstring($name) . ($i > 0 ? $i : '');
            $sql = "SELECT COUNT(*) FROM " . $db->prefix("coach_players") . " WHERE nameid='{$nameid}'";
            list($num) = $db->fetchRow($db->query($sql));
            $i++;
        } while ($num > 0);
        $sql = "SELECT COUNT(*) FROM " . $db->prefix("coach_players") . " WHERE name='{$name}'";
        list($num) = $db->fetchRow($db->query($sql));
        if ($num > 0) {
            redirectMsg('players.php?team=' . $idteam . '&op=new&id=' . $cat->id(), __('Ya existe otro jugador con el mismo nombre', 'admin_team'), 1);
            die;
        }
    }
    // Cargamos la imágen
    include_once RMCPATH . '/class/uploader.php';
    $up = new RMFileUploader(XOOPS_UPLOAD_PATH . '/teams/players', $mc['filesize'] * 1024, array('jpg', 'png', 'gif'));
    if ($up->fetchMedia('image')) {
        if (!$up->upload()) {
            if ($edit) {
                redirectMsg('./players.php?team=' . $idteam . '&op=edit&id=' . $player->id(), $up->getErrors(), 1);
                die;
            } else {
                redirectMsg('./players.php?team=' . $idteam . '&op=new', $up->getErrors(), 1);
                die;
            }
        }
        if ($edit && $player->image() != '') {
            @unlink(XOOPS_UPLOAD_PATH . '/teams/players/' . $player->image());
            @unlink(XOOPS_UPLOAD_PATH . '/teams/players/ths/' . $player->image());
        }
        $filename = $up->getSavedFileName();
        $fullpath = $up->getSavedDestination();
        // Redimensionamos la imagen
        $redim = new RMImageResizer($fullpath, $fullpath);
        $redim->resizeWidth($mc['img_size']);
        $redim->setTargetFile(XOOPS_UPLOAD_PATH . "/teams/players/ths/{$filename}");
        switch ($mc['resize_method']) {
            case 1:
                //Recortar miniatura
                $redim->resizeAndCrop($mc['th_size'], $mc['th_size']);
                break;
            case 0:
                $redim->resizeWidth($mc['th_size']);
                break;
        }
    } else {
        $filename = $edit ? $player->image() : '';
    }
    $player->setName($name);
    $player->setNameId($nameid);
    $player->setBirth($birth);
    $player->setBio($bio);
    if (!$edit) {
        $player->setDate(time());
    }
    $player->setTeam($idteam);
    $player->setNumber($number);
    $player->setImage($filename);
    $player->setVar('dohtml', isset($dohtml) ? 1 : 0);
    $player->setVar('doxcode', isset($doxcode) ? 1 : 0);
    $player->setVar('doimage', isset($doimage) ? 1 : 0);
    $player->setVar('dosmiley', isset($dosmiley) ? 1 : 0);
    $player->setVar('dobr', isset($dobr) ? 1 : 0);
    if ($player->save()) {
        redirectMsg('players.php?team=' . $idteam, __('Base de datos actualizada correctamente', 'admin_team'), 0);
    } else {
        redirectMsg('players.php?team=' . $idteam . '&op=' . ($edit ? 'edit&id=' . $player->id() : 'new'), __('Ocurrieron errores al intentar actualizar la base de datos', 'admin_team') . '<br />' . $player->errors(), 0);
    }
}
Exemple #9
0
// Un modulo sencillo para el manejo de equipos
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
define('TC_LOCATION', 'teams');
include '../../mainfile.php';
$id = TCFunctions::get('id');
if ($id == '') {
    redirect_header(XOOPS_URL . '/modules/team/', 1, _MS_TC_ERRID);
    die;
}
$myts =& MyTextSanitizer::getInstance();
$id = $myts->addSlashes($id);
$id = str_replace("/", "", $id);
$team = new TCTeam($id);
if ($team->isNew()) {
    redirect_header(XOOPS_URL . '/modules/team/', 1, _MS_TC_ERRNOEXISTIS);
    die;
}
$xoopsOption['template_main'] = "coach_team.html";
include 'header.php';
$cat = $team->category(true);
$tpl->assign('coach_title', $team->name() . " <em>(" . $cat->name() . ")</em>");
$tpl->assign('lang_comment', _MS_TC_COMMENT);
$tpl->assign('lang_players', _MS_TC_PLAYERS);
$tpl->assign('lang_info', _MS_TC_INFO);
$tpl->assign('lang_coachs', _MS_TC_COACHS);
$tpl->assign('team', array('id' => $team->id(), 'desc' => $team->desc()));
// Integrantes
$players = $team->players(true);