function tc_block_players($options) { global $xoopsModule; if ($xoopsModule && $xoopsModule->dirname() == 'team') { global $xoopsModuleConfig; $mc =& $xoopsModuleConfig; } else { $util =& RMUtils::getInstance(); $mc =& $util->moduleConfig('team'); } $db =& XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("coach_players"); if ($options[0] > 0) { $sql .= " WHERE team='" . $options[0] . "'"; } $sql .= " ORDER BY RAND() LIMIT 0,{$options['1']}"; $result = $db->query($sql); $block = array(); while ($row = $db->fetchArray($result)) { $rtn = array(); $player = new TCPlayer(); $player->assignVars($row); $rtn['link'] = XOOPS_URL . '/modules/team/' . ($mc['urlmode'] ? 'player/' . $player->nameId() . '/' : 'player.php?id=' . $player->id()); $rtn['name'] = $player->name(); $rtn['number'] = $player->number(); $rtn['image'] = $player->image(); $block['players'][] = $rtn; } $block['cols'] = $options[2]; return $block; }
function showPlayers() { global $xoopsModule, $mc, $adminTemplate, $tpl, $db; $gteam = TCFunctions::get('team'); $team = new TCTeam($gteam); // Equipos $tpl->assign('team', $team->isNew() ? 0 : $team->id()); $result = $db->query("SELECT * FROM " . $db->prefix("coach_teams") . " ORDER BY name"); $teams = array(); while ($row = $db->fetchArray($result)) { $ct = new TCTeam(); $ct->assignVars($row); $cat =& $ct->category(true); $teams[] = array('id' => $ct->id(), 'name' => $ct->name() . " (" . $cat->name() . ")"); } // Entrenadores $coachs = array(); if (!$team->isNew()) { foreach ($team->coachs(true) as $coach) { $coachs[] = array('id' => $coach->id(), 'name' => $coach->name(), 'image' => $coach->image()); } } // Jugadores $result = $db->query("SELECT * FROM " . $db->prefix("coach_players") . " WHERE team='" . $team->id() . "'"); $players = array(); while ($row = $db->fetchArray($result)) { $player = new TCPlayer(); $player->assignVars($row); $players[] = array('id' => $player->id(), 'name' => $player->name(), 'image' => $player->image(), 'number' => $player->number(), 'age' => $player->age(), 'date' => formatTimestamp($player->date(), 'c')); } xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . __('Jugadores', 'admin_team')); xoops_cp_header(); include RMTemplate::get()->get_template("admin/coach_players.php", 'module', 'team'); xoops_cp_footer(); }
public function players($obj = true, $order = '') { $sql = "SELECT * FROM " . $this->db->prefix("coach_players") . " WHERE team='" . $this->id() . "'"; if ($order != '') { $sql .= " ORDER BY {$order}"; } $result = $this->db->query($sql); $players = array(); while ($row = $this->db->fetchArray($result)) { if ($obj) { $player = new TCPlayer(); $player->assignVars($row); $players[] = $player; } else { $players[] = $row['id_play']; } } return $players; }