XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
index.php
Go to the documentation of this file.
1 <?php
2 // $Id: index.php 954 2012-05-15 03:25:53Z i.bitcero $
3 // --------------------------------------------------------------
4 // Red México Common Utilities
5 // A framework for Red México Modules
6 // Author: Eduardo Cortés <i.bitcero@gmail.com>
7 // Email: i.bitcero@gmail.com
8 // License: GPL 2.0
9 // --------------------------------------------------------------
10 
11 define('RMCLOCATION','dashboard');
12 include_once '../../include/cp_header.php';
13 
14 function get_modules_ajax(){
15 
16  XoopsLogger::getInstance()->activated = false;
17  XoopsLogger::getInstance()->renderingEnabled = false;
18 
19  $db = XoopsDatabaseFactory::getDatabaseConnection();
20  $sql = "SELECT COUNT(*) FROM ".$db->prefix("modules");
21  $page = rmc_server_var($_POST, 'page', 1);
22  $limit = RMFunctions::configs('mods_number');
23  list($num) = $db->fetchRow($db->query($sql));
24 
25  $tpages = ceil($num / $limit);
27 
28  $start = $num<=0 ? 0 : ($page - 1) * $limit;
29  $nav = new RMPageNav($num, $limit, $page, 5);
30  $nav->target_url('javascript:;" onclick="get_mods_page({PAGE_NUM})');
31 
32  $sql = 'SELECT * FROM ' . $db->prefix('modules')." ORDER BY mid, weight LIMIT $start,$limit";
33  $result = $db->query($sql);
34  $installed_mods = array();
35  while($row = $db->fetchArray($result)){
36  $mod = new XoopsModule();
37  $mod->assignVars($row);
38  $installed_mods[] = $mod;
39  }
40 
41  include RMTemplate::get()->get_template('rmc_mods_installed.php', 'module', 'rmcommon');
42  die();
43 
44 }
45 
46 function show_dashboard(){
47  global $xoopsModule;
48 
50 
51  $db = XoopsDatabaseFactory::getDatabaseConnection();
52  $sql = 'SELECT * FROM ' . $db->prefix('modules');
53  $result = $db->query($sql);
54  $installed_mods = array();
55  while($row = $db->fetchArray($result)){
56  $installed_mods[] = $row['dirname'];
57  }
58 
59  require_once XOOPS_ROOT_PATH . "/class/xoopslists.php";
60  $dirlist = XoopsLists::getModulesList();
61  $available_mods = array();
62  $module_handler =& xoops_gethandler('module');
63  $i = 0;
64  foreach ($dirlist as $file) {
65  if ($i>5) break;
66  clearstatcache();
67  $file = trim($file);
68  if (!in_array($file, $installed_mods)) {
69  $module =& $module_handler->create();
70  if (!$module->loadInfo($file, false)) {
71  continue;
72  }
73  $available_mods[] = $module;
74  }
75  $i++;
76  }
77 
78  xoops_cp_header();
79 
80  RMTemplate::get()->add_style('dashboard.css', 'rmcommon');
81  RMTemplate::get()->add_script(RMCURL.'/include/js/dashboard.js');
82  RMTemplate::get()->add_style('pagenav.css', 'rmcommon');
83  RMTemplate::get()->add_help(__('Dashboard Help','rmcommon'),'http://www.xoopsmexico.net/docs/common-utilities/uso-de-common-utilities/standalone/1/#dashboard');
84  include RMTemplate::get()->get_template('rmc_dashboard.php', 'module', 'rmcommon');
85 
86  xoops_cp_footer();
87 }
88 
89 
90 function rm_change_theme(){
91  global $xoopsModule;
92 
93  $theme = rmc_server_var($_GET,'theme','');
94 
95  if (is_file(RMCPATH.'/themes/'.$theme.'/admin_gui.php')){
96  $db = XoopsDatabaseFactory::getDatabaseConnection();
97  $sql = "UPDATE ".$db->prefix("config")." SET conf_value='$theme' WHERE conf_name='theme' AND conf_modid='".$xoopsModule->mid()."'";
98  if ($db->queryF($sql)){
99  redirectMsg('index.php', __('Theme changed successfully!','rmcommon'), 0);
100  die();
101  } else {
102  redirectMsg('index.php', __('Theme could not be changed!','rmcommon').'<br />'.$db->error(), 0);
103  die();
104  }
105  }
106 
107  redirectMsg('index.php', __('Specified theme does not exist!','rmcommon'), 1);
108  die();
109 
110 }
111 
112 
113 $action = rmc_server_var($_REQUEST, 'action', '');
114 
115 switch($action){
116  case 'list':
118  die();
119  case 'theme':
120  rm_change_theme();
121  break;
122  default:
123  show_dashboard();
124  break;
125 }