Exemplo n.º 1
0
function show_dashboard()
{
    global $xoopsModule;
    //RMFunctions::create_toolbar();
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = 'SELECT * FROM ' . $db->prefix('modules');
    $result = $db->query($sql);
    $installed_mods = array();
    while ($row = $db->fetchArray($result)) {
        $installed_mods[] = $row['dirname'];
    }
    require_once XOOPS_ROOT_PATH . "/class/xoopslists.php";
    $dirlist = XoopsLists::getModulesList();
    $available_mods = array();
    $module_handler =& xoops_gethandler('module');
    $i = 0;
    foreach ($dirlist as $file) {
        if ($i > 5) {
            break;
        }
        clearstatcache();
        $file = trim($file);
        if (!in_array($file, $installed_mods)) {
            $module =& $module_handler->create();
            if (!$module->loadInfo($file, false)) {
                continue;
            }
            $available_mods[] = $module;
        }
        $i++;
    }
    $donateButton = '<form id="paypal-form" name="_xclick" action="https://www.paypal.com/fr/cgi-bin/webscr" method="post">
                    <input type="hidden" name="cmd" value="_xclick">
                    <input type="hidden" name="business" value="*****@*****.**">
                    <input type="hidden" name="item_name" value="Common Utilities Support">
                    <input type="hidden" name="amount" value=0>
                    <input type="hidden" name="currency_code" value="USD">
                    <img src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" onclick="$(\'#paypal-form\').submit()" alt="PayPal - The safer, easier way to pay online!" />
    </form>';
    $installed_modules = get_modules_list();
    xoops_cp_header();
    RMTemplate::get()->add_style('dashboard.css', 'rmcommon');
    RMTemplate::get()->add_script('dashboard.js', 'rmcommon', array('footer' => 1));
    RMTemplate::get()->add_style('pagenav.css', 'rmcommon');
    RMTemplate::get()->add_help(__('Dashboard Help', 'rmcommon'), 'http://www.xoopsmexico.net/docs/common-utilities/uso-de-common-utilities/standalone/1/#dashboard');
    include RMTemplate::get()->get_template('rmc-dashboard.php', 'module', 'rmcommon');
    xoops_cp_footer();
}
Exemplo n.º 2
0
function show_dashboard()
{
    global $xoopsModule, $cuSettings, $cuIcons;
    //RMFunctions::create_toolbar();
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = 'SELECT * FROM ' . $db->prefix('modules');
    $result = $db->query($sql);
    $installed_mods = array();
    while ($row = $db->fetchArray($result)) {
        $installed_mods[] = $row['dirname'];
    }
    require_once XOOPS_ROOT_PATH . "/class/xoopslists.php";
    $dirlist = XoopsLists::getModulesList();
    $available_mods = array();
    $module_handler =& xoops_gethandler('module');
    foreach ($dirlist as $file) {
        clearstatcache();
        $file = trim($file);
        if (!in_array($file, $installed_mods)) {
            $module =& $module_handler->create();
            if (!$module->loadInfo($file, false)) {
                continue;
            }
            $available_mods[] = $module;
        }
    }
    $installed_modules = get_modules_list();
    // Modules counter
    $counterModules = new Common\Widgets\Counter(['id' => 'counter-modules', 'color' => 'red', 'icon' => 'svg-rmcommon-module', 'class' => 'animated bounceIn']);
    $counterModules->addCell(__('Modules', 'rmcommon'), count($available_mods) + count($installed_modules));
    $counterModules->addCell(__('Installed', 'rmcommon'), count($installed_modules));
    $counterModules->addCell(__('Available', 'rmcommon'), count($available_mods));
    // Users counter
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("users") . " WHERE level > 0";
    list($active) = $db->fetchRow($db->query($sql));
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("users") . " WHERE level <= 0";
    list($inactive) = $db->fetchRow($db->query($sql));
    $counterUsers = new Common\Widgets\Counter(['id' => 'counter-users', 'color' => 'blue', 'icon' => 'svg-rmcommon-users2', 'class' => 'animated bounceIn']);
    $total = $active + $inactive;
    $counterUsers->addCell(__('Users', 'rmcommon'), $total);
    $counterUsers->addCell(__('Active', 'rmcommon'), $active);
    $counterUsers->addCell(__('Inactive', 'rmcommon'), $inactive);
    $ratio = $active / ($active + $inactive);
    if ($ratio < 1) {
        $ratio = number_format($ratio, 2);
    }
    $counterUsers->addCell(__('Ratio', 'rmcommon'), $ratio * 100 . '%');
    // Comments counter
    $counterComments = new Common\Widgets\Counter(['id' => 'counter-comments', 'color' => 'green', 'icon' => 'svg-rmcommon-comments', 'class' => 'animated bounceIn']);
    list($approved) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("mod_rmcommon_comments") . " WHERE status = 'approved'"));
    list($waiting) = $db->fetchRow($db->query("SELECT COUNT(*) FROM " . $db->prefix("mod_rmcommon_comments") . " WHERE status != 'approved'"));
    $counterComments->addCell(__('Comments', 'rmcommon'), $approved > 0 || $waiting > 0 ? $approved + $waiting : '0');
    $counterComments->addCell(__('Approved', 'rmcommon'), $approved);
    $counterComments->addCell(__('Waiting', 'rmcommon'), $waiting);
    $ratio = $approved / ($approved + $waiting);
    if ($ratio < 1) {
        $ratio = number_format($ratio, 2);
    }
    $counterComments->addCell(__('Ratio', 'rmcommon'), $ratio * 100 . '%');
    $counterSystem = new Common\Widgets\Counter(['id' => 'counter-system', 'color' => 'deep-orange', 'icon' => 'svg-rmcommon-rmcommon', 'class' => 'animated bounceIn']);
    $counterSystem->addCell(__('Current Version', 'rmcommon'), RMModules::get_module_version('rmcommon', false));
    $counterSystem->addCell('XOOPS', str_replace('XOOPS ', '', XOOPS_VERSION));
    $version = explode('-', phpversion());
    $counterSystem->addCell('PHP', $version[0]);
    unset($version);
    if (method_exists($db, 'getServerVersion')) {
        $version = explode("-", $db->getServerVersion());
    } else {
        $version = '--';
    }
    $counterSystem->addCell('MySQL', $version[0]);
    // Management Tools
    $managementTools[] = (object) ['caption' => __('Modules', 'rmcommon'), 'link' => 'modules.php', 'icon' => 'svg-rmcommon-module', 'color' => 'pink'];
    $managementTools[] = (object) ['caption' => __('Blocks', 'rmcommon'), 'link' => 'blocks.php', 'icon' => 'svg-rmcommon-blocks', 'color' => 'blue'];
    $managementTools[] = (object) ['caption' => __('Users', 'rmcommon'), 'link' => 'users.php', 'icon' => 'svg-rmcommon-user2', 'color' => 'deep-orange'];
    $managementTools[] = (object) ['caption' => __('Groups', 'rmcommon'), 'link' => 'groups.php', 'icon' => 'svg-rmcommon-users2', 'color' => 'green'];
    $managementTools[] = (object) ['caption' => __('Images', 'rmcommon'), 'link' => 'images.php', 'icon' => 'svg-rmcommon-images', 'color' => 'purple'];
    $managementTools[] = (object) ['caption' => __('Comments', 'rmcommon'), 'link' => 'comments.php', 'icon' => 'svg-rmcommon-comments', 'color' => 'red'];
    $managementTools[] = (object) ['caption' => __('Plugins', 'rmcommon'), 'link' => 'plugins.php', 'icon' => 'svg-rmcommon-plug', 'color' => 'orange'];
    $managementTools[] = (object) ['caption' => __('Updates', 'rmcommon'), 'link' => 'updates.php', 'icon' => 'svg-rmcommon-update', 'color' => 'teal'];
    $managementTools[] = (object) ['caption' => __('Preferences', 'rmcommon'), 'link' => 'settings.php?action=configure&mod=rmcommon', 'icon' => 'svg-rmcommon-wrench', 'color' => 'light-blue'];
    $managementTools = RMEvents::get()->trigger('rmcommon.get.system.tools', $managementTools);
    // Load recent comments
    $sql = "SELECT * FROM " . $db->prefix("mod_rmcommon_comments") . " ORDER BY `posted` DESC LIMIT 0, 5";
    $result = $db->query($sql);
    $comments = [];
    while ($row = $db->fetchArray($result)) {
        $com = new RMComment();
        $com->assignVars($row);
        // Editor data
        if (!isset($ecache[$com->getVar('user')])) {
            $ecache[$com->getVar('user')] = new RMCommentUser($com->getVar('user'));
        }
        $editor = $ecache[$com->getVar('user')];
        if ($editor->getVar('xuid') > 0) {
            if (!isset($ucache[$editor->getVar('xuid')])) {
                $ucache[$editor->getVar('xuid')] = new XoopsUser($editor->getVar('xuid'));
            }
            $user = $ucache[$editor->getVar('xuid')];
            $poster = (object) array('id' => $user->getVar('uid'), 'name' => $user->getVar('uname'), 'email' => $user->getVar('email'), 'posts' => $user->getVar('posts'), 'avatar' => $user->getVar('image') != '' && $user->getVar('image') != 'blank.gif' ? XOOPS_UPLOAD_URL . '/' . $user->getVar('image') : RMCURL . '/images/avatar.gif', 'rank' => $user->rank());
        } else {
            $poster = (object) array('id' => 0, 'name' => $editor->getVar('name'), 'email' => $editor->getVar('email'), 'posts' => 0, 'avatar' => RMCURL . '/images/avatar.gif', 'rank' => '');
        }
        // Get item
        $cpath = XOOPS_ROOT_PATH . '/modules/' . $row['id_obj'] . '/class/' . $row['id_obj'] . 'controller.php';
        if (is_file($cpath)) {
            if (!class_exists(ucfirst($row['id_obj']) . 'Controller')) {
                include_once $cpath;
            }
            $class = ucfirst($row['id_obj']) . 'Controller';
            $controller = new $class();
            $item = $controller->get_item($row['params'], $com);
            if (method_exists($controller, 'get_item_url')) {
                $item_url = $controller->get_item_url($row['params'], $com);
            }
        } else {
            $item = __('Unknow', 'rmcommon');
            $item_url = '';
        }
        $text = TextCleaner::getInstance()->clean_disabled_tags(TextCleaner::getInstance()->popuplinks(TextCleaner::getInstance()->nofollow(TextCleaner::getInstance()->truncate($com->getVar('content'), 100))));
        $comments[] = (object) array('id' => $row['id_com'], 'text' => $text, 'poster' => $poster, 'date' => formatTimestamp($com->getVar('posted'), 'l'), 'ip' => $com->getVar('ip'), 'item' => $item, 'item_url' => $item_url, 'module' => $row['id_obj'], 'status' => $com->getVar('status'));
    }
    // Get dashboard widgets
    $dashboardPanels = [];
    $dashboardPanels = RMEvents::get()->trigger('rmcommon.dashboard.panels', $dashboardPanels);
    RMTemplate::getInstance()->add_body_class('dashboard');
    xoops_cp_header();
    //RMTemplate::get()->add_style('dashboard.min.css', 'rmcommon');
    RMTemplate::get()->add_style('pagenav.css', 'rmcommon');
    RMTemplate::get()->add_help(__('Dashboard Help', 'rmcommon'), 'http://www.xoopsmexico.net/docs/common-utilities/uso-de-common-utilities/standalone/1/#dashboard');
    include RMTemplate::get()->path('rmc-dashboard.php', 'module', 'rmcommon');
    xoops_cp_footer();
}
Exemplo n.º 3
0
<?php

//Pages
add_apage(array('code' => 'modules_panel', 'title' => 'Модули', 'rule' => 'admin_modules, admin_settings', 'category' => 'admin', 'priority' => 15, 'function' => function () {
    set_glob_content(array('pagi' => true, 'limit' => 10, 'all' => get_modules_count(), 'handler' => function () {
        global $PAGE;
        return array('body' => get_modules_list($PAGE->content['limit'], $PAGE->content['offset']));
    }));
    get_template('modules/panel.php');
}));
//Others
add_action(array('code' => 'ajax_deactivate_module', 'rule' => 'admin_ajax', 'category' => 'admin', 'function' => function ($params = null) {
    if (isset($params['button']['pre']['value'])) {
        $params = $params['button']['pre']['value'];
    }
    if ($params && deactivate_module($params)) {
        echo ajax_make_res('reload', "Модуль {$params} успешно деактивирован", 'Успех!');
    } else {
        echo ajax_make_res('error', 'Произошла неизвестная ошибка', 'Ошибка!');
    }
}));
add_action(array('code' => 'ajax_activate_module', 'rule' => 'admin_ajax', 'category' => 'admin', 'function' => function ($params = null) {
    if (isset($params['button']['pre']['value'])) {
        $params = $params['button']['pre']['value'];
    }
    if ($params && activate_module($params)) {
        echo ajax_make_res('reload', "Модуль {$params} успешно активирован", 'Успех!');
    } else {
        echo ajax_make_res('error', 'Произошла неизвестная ошибка', 'Ошибка!');
    }
}));
Exemplo n.º 4
0
echo form_label(lang('POSITION'), '_positions_rid');
?>
</div>
<div class="column span-8">
	<?php 
echo form_dropdown('_positions_rid', get_positions_list(), set_value('_positions_rid', $ds->_positions_rid), 'id="_positions_rid" class="text" readonly="readonly" ');
?>
</div>
<div class="column span-4">
	<?php 
echo form_label(lang('MODULE'), '_modules_rid');
?>
</div>
<div class="column span-8 last">
	<?php 
echo form_dropdown('_modules_rid', get_modules_list(), set_value('_modules_rid', $ds->_modules_rid), 'id="_modules_rid" class="text part-5" readonly="readonly" ');
?>
</div>

<div class="column span-4">
	<?php 
echo form_label(lang('ITEM_NAME'), 'item_name');
?>
</div>
<div class="column span-8">
	<?php 
echo form_input('item_name', set_value('item_name', $ds->item_name), 'id="item_name" class="text part-5" readonly="readonly" ');
?>
</div>

<div class="column span-4">