Пример #1
0
/**
* @desc Visualiza todas las imágenes existentes
**/
function showImages()
{
    global $xoopsModule, $tpl, $xoopsConfig, $xoopsSecurity, $xoopsUser;
    $db = Database::getInstance();
    $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
    $page = $page <= 0 ? 1 : $page;
    $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15;
    $limit = $limit <= 0 ? 15 : $limit;
    $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
    $owner = isset($_REQUEST['owner']) ? $_REQUEST['owner'] : '';
    $mindate = isset($_REQUEST['mindate']) ? $_REQUEST['mindate'] : '';
    $maxdate = isset($_REQUEST['maxdate']) ? $_REQUEST['maxdate'] : '';
    $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'created';
    $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 1;
    $mode = $mode == '' ? 1 : $mode;
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_images');
    $sql1 = '';
    $words = array();
    if ($search != '') {
        //Separamos en palabras
        $words = explode(" ", $search);
        foreach ($words as $k) {
            $k = trim($k);
            if (strlen($k) <= 2) {
                continue;
            }
            $sql1 .= $sql1 == '' ? " WHERE (title LIKE '%{$k}%')" : " OR (title LIKE '%{$k}%')";
        }
    }
    if ($owner > 0) {
        $sql1 .= $search != '' ? " AND owner='{$owner}'" : " WHERE owner='{$owner}'";
    }
    if ($mindate != '') {
        $maxdate = $maxdate != '' ? $maxdate : time();
        $sql1 .= $search != '' || $owner > 0 ? " AND " : " WHERE ";
        $sql1 .= "(created>='{$mindate}' AND created<='{$maxdate}')";
    }
    list($num) = $db->fetchRow($db->query($sql . $sql1));
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $tpages = ceil($num / $limit);
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url("images.php?page={PAGE_NUM}&amp;limit={$limit}&amp;search={$search}&amp;owner={$owner}&amp;mindate={$mindate}&amp;maxdate={$maxdate}&amp;sort={$sort}&amp;mode={$mode}");
    $showmax = $start + $limit;
    $showmax = $showmax > $num ? $num : $showmax;
    //Fin de barra de navegación
    $sql = "SELECT * FROM " . $db->prefix('gs_images');
    $sql2 = " ORDER BY {$sort} " . ($mode ? "DESC" : "ASC");
    $sql2 .= " LIMIT {$start},{$limit}";
    $result = $db->query($sql . $sql1 . $sql2);
    $users = array();
    $images = array();
    while ($rows = $db->fetchArray($result)) {
        $title = '';
        foreach ($words as $k) {
            $title = eregi_replace("({$k})", "<span class='searchResalte'>\\1</span>", $rows['title']);
        }
        $img = new GSImage();
        $img->assignVars($rows);
        if (!isset($users[$img->owner()])) {
            $users[$img->owner()] = new GSUser($img->owner(), 1);
        }
        $link = $users[$img->owner()]->userURL() . "img/" . $img->id();
        $xu = $users[$img->owner()];
        $images[] = array('id' => $img->id(), 'title' => $title ? $title : $img->title(), 'desc' => substr($img->desc(), 0, 150), 'image' => $users[$img->owner()]->filesURL() . '/ths/' . $img->image(), 'created' => formatTimeStamp($img->created(), 'c'), 'owner' => $xu->uname(), 'public' => $img->isPublic(), 'link' => $link);
    }
    $form = new RMForm('', 'frmNav', '');
    $ele = new RMFormUser('', 'owner', false, $owner > 0 ? array($owner) : array(0), 50, null, null, 1);
    $ele->setForm('frmNav');
    $tpl->assign('user_field', $ele->render());
    $ele = new RMFormDate('', 'mindate', $mindate == null ? null : $mindate, 1);
    $tpl->assign('mindate_field', $ele->render());
    $ele = new RMFormDate('', 'maxdate', $maxdate == null ? null : $maxdate, 1);
    $tpl->assign('maxdate_field', $ele->render());
    GSFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Images Management', 'galleries'));
    RMTemplate::get()->assign('xoops_pagetitle', __('Images', 'galleries'));
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_local_script('images.js', 'galleries');
    RMTemplate::get()->add_local_script('gsscripts.php?file=sets&form=frm-images&p=' . TextCleaner::getInstance()->encrypt($xoopsUser->uid() . '|' . GS_URL . '/admin/images.php' . '|' . $xoopsSecurity->createToken(), true), 'galleries');
    RMTemplate::get()->add_head("<script type='text/javascript'>\nvar delete_warning='" . __('Do you really wish to delete selected images?', 'galleries') . "';\n</script>");
    xoops_cp_header();
    include RMTemplate::get()->get_template("admin/gs_images.php", 'module', 'galleries');
    xoops_cp_footer();
}
Пример #2
0
/**
* Shows all registered users in a list with filter and manage options
*/
function show_users()
{
    global $xoopsSecurity, $rmTpl;
    define('RMCSUBLOCATION', 'allusers');
    RMTemplate::get()->add_style('users.css', 'rmcommon');
    RMTemplate::get()->add_style('js-widgets.css');
    //Scripts
    RMTemplate::get()->add_script('users.js', 'rmcommon', array('directory' => 'include'));
    RMTemplate::get()->add_script('jquery.checkboxes.js', 'rmcommon', array('directory' => 'include'));
    RMTemplate::get()->add_head('<script type="text/javascript">var rmcu_select_message = "' . __('You have not selected any user!', 'rmcommon') . '";
        var rmcu_message = "' . __('Dou you really wish to delete selected users?', 'rmcommon') . '";</script>');
    $form = new RMForm('', '', '');
    // Date Field
    $login1 = new RMFormDate('', 'login1', '');
    $login1->addClass('form-control');
    $login2 = new RMFormDate('', 'login2', '');
    $login2->addClass('form-control');
    // Registered Field
    $register1 = new RMFormDate('', 'registered1', '');
    $register1->addClass('form-control');
    $register2 = new RMFormDate('', 'registered2', '');
    $register2->addClass('form-control');
    RMBreadCrumb::get()->add_crumb(__('Users Management', 'rmcommon'));
    $rmTpl->assign('xoops_pagetitle', __('Users Management', 'rmcommon'));
    RMFunctions::create_toolbar();
    // Show the theme
    xoops_cp_header();
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("users") . " " . formatSQL();
    $page = rmc_server_var($_REQUEST, 'pag', 1);
    $limit = rmc_server_var($_REQUEST, 'limit', 15);
    $order = rmc_server_var($_GET, 'order', 'uid');
    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('users.php?limit=' . $limit . '&order=' . $order . '&pag={PAGE_NUM}');
    $sql = str_replace("COUNT(*)", '*', $sql);
    $sql .= "ORDER BY {$order} LIMIT {$start}, {$limit}";
    $result = $db->query($sql);
    $users = array();
    $t = array();
    // Temporary
    while ($row = $db->fetchArray($result)) {
        $user = new RMUser();
        $user->assignVars($row);
        $t = $user->getValues();
        $t['groups'] = $user->getGroups();
        $t = RMEvents::get()->run_event('rmcommon.loading.users.list', $t);
        $users[] = $t;
        $t = array();
    }
    $xgh = new XoopsGroupHandler($db);
    $users = RMEvents::get()->run_event('rmcommon.users.list.loaded', $users);
    // Users template
    include RMTemplate::get()->get_template('rmc-users.php', 'module', 'rmcommon');
    xoops_cp_footer();
}
Пример #3
0
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> &raquo; " . __('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();
}