mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 03:52:15 +09:00
Move admin dashboard to Dashboard controller
This commit is contained in:
parent
93947a7f51
commit
c93dea90e0
5 changed files with 351 additions and 332 deletions
|
|
@ -11,337 +11,6 @@
|
||||||
*/
|
*/
|
||||||
class AdminAdminView extends Admin
|
class AdminAdminView extends Admin
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* layout list
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
var $layout_list;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* easy install check file
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
var $easyinstallCheckFile = './files/env/easyinstall_last';
|
|
||||||
|
|
||||||
function __construct()
|
|
||||||
{
|
|
||||||
Context::set('xe_default_url', Context::getDefaultUrl());
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initilization
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function init()
|
|
||||||
{
|
|
||||||
// forbit access if the user is not an administrator
|
|
||||||
if (!$this->user->isAdmin())
|
|
||||||
{
|
|
||||||
throw new Rhymix\Framework\Exceptions\NotPermitted('admin.msg_is_not_administrator');
|
|
||||||
}
|
|
||||||
|
|
||||||
// change into administration layout
|
|
||||||
$this->setTemplatePath($this->module_path . 'tpl');
|
|
||||||
$this->setLayoutPath($this->getTemplatePath());
|
|
||||||
$this->setLayoutFile('layout.html');
|
|
||||||
|
|
||||||
$this->makeGnbUrl();
|
|
||||||
|
|
||||||
// Check system configuration
|
|
||||||
$this->checkSystemConfiguration();
|
|
||||||
|
|
||||||
// Retrieve the list of installed modules
|
|
||||||
$this->checkEasyinstall();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* check system configuration
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function checkSystemConfiguration()
|
|
||||||
{
|
|
||||||
$changed = false;
|
|
||||||
|
|
||||||
// Check encryption keys.
|
|
||||||
if (config('crypto.encryption_key') === null)
|
|
||||||
{
|
|
||||||
config('crypto.encryption_key', Rhymix\Framework\Security::getRandom(64, 'alnum'));
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
if (config('crypto.authentication_key') === null)
|
|
||||||
{
|
|
||||||
config('crypto.authentication_key', Rhymix\Framework\Security::getRandom(64, 'alnum'));
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
if (config('crypto.session_key') === null)
|
|
||||||
{
|
|
||||||
config('crypto.session_key', Rhymix\Framework\Security::getRandom(64, 'alnum'));
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
if (config('file.folder_structure') === null)
|
|
||||||
{
|
|
||||||
config('file.folder_structure', 1);
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save new configuration.
|
|
||||||
if ($changed)
|
|
||||||
{
|
|
||||||
Rhymix\Framework\Config::save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* check easy install
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function checkEasyinstall()
|
|
||||||
{
|
|
||||||
$lastTime = (int) FileHandler::readFile($this->easyinstallCheckFile);
|
|
||||||
if($lastTime > $_SERVER['REQUEST_TIME'] - 60 * 60 * 24 * 30)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$oAutoinstallAdminModel = getAdminModel('autoinstall');
|
|
||||||
$config = $oAutoinstallAdminModel->getAutoInstallAdminModuleConfig();
|
|
||||||
|
|
||||||
$oAutoinstallModel = getModel('autoinstall');
|
|
||||||
$params = array();
|
|
||||||
$params["act"] = "getResourceapiLastupdate";
|
|
||||||
$body = XmlGenerater::generate($params);
|
|
||||||
$buff = FileHandler::getRemoteResource($config->download_server, $body, 3, "POST", "application/xml");
|
|
||||||
$xml_lUpdate = new XeXmlParser();
|
|
||||||
$lUpdateDoc = $xml_lUpdate->parse($buff);
|
|
||||||
$updateDate = $lUpdateDoc->response->updatedate->body;
|
|
||||||
|
|
||||||
if(!$updateDate)
|
|
||||||
{
|
|
||||||
$this->_markingCheckEasyinstall();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$item = $oAutoinstallModel->getLatestPackage();
|
|
||||||
if(!$item || $item->updatedate < $updateDate)
|
|
||||||
{
|
|
||||||
$oController = getAdminController('autoinstall');
|
|
||||||
$oController->_updateinfo();
|
|
||||||
}
|
|
||||||
$this->_markingCheckEasyinstall();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* update easy install file content
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function _markingCheckEasyinstall()
|
|
||||||
{
|
|
||||||
$currentTime = $_SERVER['REQUEST_TIME'];
|
|
||||||
FileHandler::writeFile($this->easyinstallCheckFile, $currentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Include admin menu php file and make menu url
|
|
||||||
* Setting admin logo, newest news setting
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function makeGnbUrl($module = 'admin')
|
|
||||||
{
|
|
||||||
global $lang;
|
|
||||||
|
|
||||||
// Check is_shortcut column
|
|
||||||
$oDB = DB::getInstance();
|
|
||||||
if(!$oDB->isColumnExists('menu_item', 'is_shortcut'))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$lang->menu_gnb_sub = Rhymix\Modules\Admin\Models\AdminMenu::getAdminMenuLang();
|
|
||||||
$result = Rhymix\Modules\Admin\Models\AdminMenu::checkAdminMenu();
|
|
||||||
include $result->php_file;
|
|
||||||
|
|
||||||
$oModuleModel = getModel('module');
|
|
||||||
|
|
||||||
// get current menu's subMenuTitle
|
|
||||||
$moduleActionInfo = $oModuleModel->getModuleActionXml($module);
|
|
||||||
$currentAct = Context::get('act');
|
|
||||||
$subMenuTitle = '';
|
|
||||||
|
|
||||||
foreach((array)$moduleActionInfo->menu as $key => $value)
|
|
||||||
{
|
|
||||||
if(is_array($value->acts) && in_array($currentAct, $value->acts))
|
|
||||||
{
|
|
||||||
$subMenuTitle = $value->title;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get current menu's srl(=parentSrl)
|
|
||||||
$parentSrl = 0;
|
|
||||||
foreach((array) $menu->list as $parentKey => $parentMenu)
|
|
||||||
{
|
|
||||||
if(!is_array($parentMenu['list']) || !count($parentMenu['list']))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if($parentMenu['href'] == '#' && count($parentMenu['list']))
|
|
||||||
{
|
|
||||||
$firstChild = current($parentMenu['list']);
|
|
||||||
$menu->list[$parentKey]['href'] = $firstChild['href'];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($parentMenu['list'] as $childKey => $childMenu)
|
|
||||||
{
|
|
||||||
if($subMenuTitle == $childMenu['text'] && $parentSrl == 0)
|
|
||||||
{
|
|
||||||
$parentSrl = $childMenu['parent_srl'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get list of favorite
|
|
||||||
$output = Rhymix\Modules\Admin\Models\Favorite::getFavorites(true);
|
|
||||||
Context::set('favorite_list', $output->get('favoriteList'));
|
|
||||||
|
|
||||||
Context::set('subMenuTitle', $subMenuTitle);
|
|
||||||
Context::set('gnbUrlList', $menu->list);
|
|
||||||
Context::set('parentSrl', $parentSrl);
|
|
||||||
Context::set('gnb_title_info', $gnbTitleInfo ?? null);
|
|
||||||
Context::addBrowserTitle($subMenuTitle ? $subMenuTitle : 'Dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display Super Admin Dashboard
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function dispAdminIndex()
|
|
||||||
{
|
|
||||||
// Get statistics
|
|
||||||
$args = new stdClass();
|
|
||||||
$args->date = date("Ymd000000", $_SERVER['REQUEST_TIME'] - 60 * 60 * 24);
|
|
||||||
$today = date("Ymd");
|
|
||||||
|
|
||||||
// Member Status
|
|
||||||
$oMemberAdminModel = getAdminModel('member');
|
|
||||||
$status = new stdClass();
|
|
||||||
$status->member = new stdClass();
|
|
||||||
$status->member->todayCount = $oMemberAdminModel->getMemberCountByDate($today);
|
|
||||||
$status->member->totalCount = $oMemberAdminModel->getMemberCountByDate();
|
|
||||||
|
|
||||||
// Document Status
|
|
||||||
$oDocumentAdminModel = getAdminModel('document');
|
|
||||||
$statusList = array('PUBLIC', 'SECRET');
|
|
||||||
$status->document = new stdClass();
|
|
||||||
$status->document->todayCount = $oDocumentAdminModel->getDocumentCountByDate($today, array(), $statusList);
|
|
||||||
$status->document->totalCount = $oDocumentAdminModel->getDocumentCountByDate('', array(), $statusList);
|
|
||||||
|
|
||||||
Context::set('status', $status);
|
|
||||||
|
|
||||||
// Latest Document
|
|
||||||
$oDocumentModel = getModel('document');
|
|
||||||
$columnList = array('document_srl', 'module_srl', 'category_srl', 'title', 'nick_name', 'member_srl');
|
|
||||||
$args->list_count = 5;
|
|
||||||
$output = $oDocumentModel->getDocumentList($args, FALSE, FALSE, $columnList);
|
|
||||||
Context::set('latestDocumentList', $output->data);
|
|
||||||
unset($args, $output, $columnList);
|
|
||||||
|
|
||||||
// Latest Comment
|
|
||||||
$oCommentModel = getModel('comment');
|
|
||||||
$columnList = array('comment_srl', 'module_srl', 'document_srl', 'content', 'nick_name', 'member_srl');
|
|
||||||
$args = new stdClass();
|
|
||||||
$args->list_count = 5;
|
|
||||||
$output = $oCommentModel->getNewestCommentList($args, $columnList);
|
|
||||||
if(is_array($output))
|
|
||||||
{
|
|
||||||
foreach($output AS $key => $value)
|
|
||||||
{
|
|
||||||
$value->content = strip_tags($value->content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Context::set('latestCommentList', $output);
|
|
||||||
unset($args, $output, $columnList);
|
|
||||||
|
|
||||||
// Get list of modules
|
|
||||||
$oModuleModel = getModel('module');
|
|
||||||
$module_list = $oModuleModel->getModuleList();
|
|
||||||
$addTables = false;
|
|
||||||
$wrongPaths = [];
|
|
||||||
$needUpdate = false;
|
|
||||||
if(is_array($module_list))
|
|
||||||
{
|
|
||||||
$priority = array(
|
|
||||||
'module' => 1000000,
|
|
||||||
'member' => 100000,
|
|
||||||
'document' => 10000,
|
|
||||||
'comment' => 1000,
|
|
||||||
'file' => 100,
|
|
||||||
);
|
|
||||||
usort($module_list, function($a, $b) use($priority) {
|
|
||||||
$a_priority = isset($priority[$a->module]) ? $priority[$a->module] : 0;
|
|
||||||
$b_priority = isset($priority[$b->module]) ? $priority[$b->module] : 0;
|
|
||||||
if ($a_priority == 0 && $b_priority == 0)
|
|
||||||
{
|
|
||||||
return strcmp($a->module, $b->module);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return $b_priority - $a_priority;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
foreach($module_list as $value)
|
|
||||||
{
|
|
||||||
if($value->need_install)
|
|
||||||
{
|
|
||||||
$addTables = TRUE;
|
|
||||||
}
|
|
||||||
if($value->need_update)
|
|
||||||
{
|
|
||||||
$needUpdate = TRUE;
|
|
||||||
}
|
|
||||||
if (!preg_match('/^[a-z0-9_]+$/i', $value->module))
|
|
||||||
{
|
|
||||||
$wrongPaths[] = $value->module;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get need update from easy install
|
|
||||||
//$oAutoinstallAdminModel = getAdminModel('autoinstall');
|
|
||||||
//$needUpdateList = $oAutoinstallAdminModel->getNeedUpdateList();
|
|
||||||
$needUpdateList = array();
|
|
||||||
|
|
||||||
// Check counter addon
|
|
||||||
$site_module_info = Context::get('site_module_info');
|
|
||||||
$oAddonAdminModel = getAdminModel('addon');
|
|
||||||
$counterAddonActivated = $oAddonAdminModel->isActivatedAddon('counter');
|
|
||||||
if(!$counterAddonActivated)
|
|
||||||
{
|
|
||||||
$columnList = array('member_srl', 'nick_name', 'user_name', 'user_id', 'email_address');
|
|
||||||
$args = new stdClass;
|
|
||||||
$args->page = 1;
|
|
||||||
$args->list_count = 5;
|
|
||||||
$output = executeQuery('member.getMemberList', $args, $columnList);
|
|
||||||
Context::set('latestMemberList', $output->data);
|
|
||||||
unset($args, $output, $columnList);
|
|
||||||
}
|
|
||||||
|
|
||||||
Context::set('module_list', $module_list);
|
|
||||||
Context::set('needUpdate', false);
|
|
||||||
Context::set('addTables', $addTables);
|
|
||||||
Context::set('wrongPaths', $wrongPaths);
|
|
||||||
Context::set('needUpdate', $needUpdate);
|
|
||||||
Context::set('newVersionList', $needUpdateList);
|
|
||||||
Context::set('counterAddonActivated', $counterAddonActivated);
|
|
||||||
|
|
||||||
$oSecurity = new Security();
|
|
||||||
$oSecurity->encodeHTML('module_list..', 'module_list..author..', 'newVersionList..');
|
|
||||||
|
|
||||||
Context::set('layout', 'none');
|
|
||||||
$this->setTemplateFile('index');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display General Settings page
|
* Display General Settings page
|
||||||
* @return void
|
* @return void
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<actions>
|
<actions>
|
||||||
<action name="getSiteAllList" type="model" permission="root" />
|
<action name="getSiteAllList" type="model" permission="root" />
|
||||||
|
|
||||||
<action name="dispAdminIndex" type="view" index="true" />
|
<action name="dispAdminIndex" class="Controllers\Dashboard" index="true" />
|
||||||
<action name="dispAdminConfigGeneral" type="view" menu_name="adminConfigurationGeneral" menu_index="true" />
|
<action name="dispAdminConfigGeneral" type="view" menu_name="adminConfigurationGeneral" menu_index="true" />
|
||||||
<action name="dispAdminConfigNotification" type="view" menu_name="adminConfigurationGeneral" />
|
<action name="dispAdminConfigNotification" type="view" menu_name="adminConfigurationGeneral" />
|
||||||
<action name="dispAdminConfigSecurity" type="view" menu_name="adminConfigurationGeneral" />
|
<action name="dispAdminConfigSecurity" type="view" menu_name="adminConfigurationGeneral" />
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,149 @@
|
||||||
|
|
||||||
namespace Rhymix\Modules\Admin\Controllers;
|
namespace Rhymix\Modules\Admin\Controllers;
|
||||||
|
|
||||||
|
use Context;
|
||||||
|
use DB;
|
||||||
|
use Rhymix\Framework\Config;
|
||||||
|
use Rhymix\Framework\Security;
|
||||||
|
use Rhymix\Framework\Exceptions\NotPermitted;
|
||||||
|
use Rhymix\Modules\Admin\Models\AdminMenu as AdminMenuModel;
|
||||||
|
use Rhymix\Modules\Admin\Models\Favorite as FavoriteModel;
|
||||||
|
|
||||||
class Base extends \ModuleObject
|
class Base extends \ModuleObject
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Initilization
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
// Only allow administrators.
|
||||||
|
if (!$this->user->isAdmin())
|
||||||
|
{
|
||||||
|
throw new NotPermitted('admin.msg_is_not_administrator');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the default URL.
|
||||||
|
Context::set('xe_default_url', Context::getDefaultUrl());
|
||||||
|
|
||||||
|
// Set the layout and template path.
|
||||||
|
$this->setTemplatePath($this->module_path . 'tpl');
|
||||||
|
$this->setLayoutPath($this->getTemplatePath());
|
||||||
|
$this->setLayoutFile('layout.html');
|
||||||
|
|
||||||
|
// Check system configuration.
|
||||||
|
$this->checkSystemConfiguration();
|
||||||
|
|
||||||
|
// Load the admin menu.
|
||||||
|
$this->loadAdminMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check system configuration.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function checkSystemConfiguration()
|
||||||
|
{
|
||||||
|
$changed = false;
|
||||||
|
|
||||||
|
// Check encryption keys.
|
||||||
|
if (config('crypto.encryption_key') === null)
|
||||||
|
{
|
||||||
|
config('crypto.encryption_key', Security::getRandom(64, 'alnum'));
|
||||||
|
$changed = true;
|
||||||
|
}
|
||||||
|
if (config('crypto.authentication_key') === null)
|
||||||
|
{
|
||||||
|
config('crypto.authentication_key', Security::getRandom(64, 'alnum'));
|
||||||
|
$changed = true;
|
||||||
|
}
|
||||||
|
if (config('crypto.session_key') === null)
|
||||||
|
{
|
||||||
|
config('crypto.session_key', Security::getRandom(64, 'alnum'));
|
||||||
|
$changed = true;
|
||||||
|
}
|
||||||
|
if (config('file.folder_structure') === null)
|
||||||
|
{
|
||||||
|
config('file.folder_structure', 1);
|
||||||
|
$changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save new configuration.
|
||||||
|
if ($changed)
|
||||||
|
{
|
||||||
|
Config::save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the admin menu.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function loadAdminMenu($module = 'admin')
|
||||||
|
{
|
||||||
|
global $lang;
|
||||||
|
|
||||||
|
// Check is_shortcut column
|
||||||
|
$oDB = DB::getInstance();
|
||||||
|
if (!$oDB->isColumnExists('menu_item', 'is_shortcut'))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$lang->menu_gnb_sub = AdminMenuModel::getAdminMenuLang();
|
||||||
|
$result = AdminMenuModel::checkAdminMenu();
|
||||||
|
include $result->php_file;
|
||||||
|
|
||||||
|
$oModuleModel = getModel('module');
|
||||||
|
|
||||||
|
// get current menu's subMenuTitle
|
||||||
|
$moduleActionInfo = $oModuleModel->getModuleActionXml($module);
|
||||||
|
$currentAct = Context::get('act');
|
||||||
|
$subMenuTitle = '';
|
||||||
|
|
||||||
|
foreach((array)$moduleActionInfo->menu as $value)
|
||||||
|
{
|
||||||
|
if(is_array($value->acts) && in_array($currentAct, $value->acts))
|
||||||
|
{
|
||||||
|
$subMenuTitle = $value->title;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get current menu's srl(=parentSrl)
|
||||||
|
$parentSrl = 0;
|
||||||
|
foreach ((array)$menu->list as $parentKey => $parentMenu)
|
||||||
|
{
|
||||||
|
if (!is_array($parentMenu['list']) || !count($parentMenu['list']))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($parentMenu['href'] == '#' && count($parentMenu['list']))
|
||||||
|
{
|
||||||
|
$firstChild = current($parentMenu['list']);
|
||||||
|
$menu->list[$parentKey]['href'] = $firstChild['href'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($parentMenu['list'] as $childMenu)
|
||||||
|
{
|
||||||
|
if ($subMenuTitle == $childMenu['text'] && $parentSrl == 0)
|
||||||
|
{
|
||||||
|
$parentSrl = $childMenu['parent_srl'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get list of favorite
|
||||||
|
$output = FavoriteModel::getFavorites(true);
|
||||||
|
Context::set('favorite_list', $output->get('favoriteList'));
|
||||||
|
|
||||||
|
Context::set('subMenuTitle', $subMenuTitle);
|
||||||
|
Context::set('gnbUrlList', $menu->list);
|
||||||
|
Context::set('parentSrl', $parentSrl);
|
||||||
|
Context::set('gnb_title_info', $gnbTitleInfo ?? null);
|
||||||
|
Context::addBrowserTitle($subMenuTitle ? $subMenuTitle : 'Dashboard');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
198
modules/admin/controllers/Dashboard.php
Normal file
198
modules/admin/controllers/Dashboard.php
Normal file
|
|
@ -0,0 +1,198 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rhymix\Modules\Admin\Controllers;
|
||||||
|
|
||||||
|
use Context;
|
||||||
|
use FileHandler;
|
||||||
|
use AddonAdminModel;
|
||||||
|
use DocumentAdminModel;
|
||||||
|
use DocumentModel;
|
||||||
|
use CommentModel;
|
||||||
|
use MemberAdminModel;
|
||||||
|
use ModuleModel;
|
||||||
|
|
||||||
|
class Dashboard extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Easy install flag file
|
||||||
|
*/
|
||||||
|
const EASYINSTALL_FLAG_FILE = 'files/env/easyinstall_last';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the dashboard.
|
||||||
|
*/
|
||||||
|
function dispAdminIndex()
|
||||||
|
{
|
||||||
|
// Get statistics
|
||||||
|
$args = new \stdClass;
|
||||||
|
$args->date = date('Ymd000000', \RX_TIME - 60 * 60 * 24);
|
||||||
|
$today = date('Ymd');
|
||||||
|
|
||||||
|
// Member Status
|
||||||
|
$oMemberAdminModel = MemberAdminModel::getInstance();
|
||||||
|
$status = new \stdClass;
|
||||||
|
$status->member = new \stdClass;
|
||||||
|
$status->member->todayCount = $oMemberAdminModel->getMemberCountByDate($today);
|
||||||
|
$status->member->totalCount = $oMemberAdminModel->getMemberCountByDate();
|
||||||
|
|
||||||
|
// Document Status
|
||||||
|
$oDocumentAdminModel = DocumentAdminModel::getInstance();
|
||||||
|
$statusList = array('PUBLIC', 'SECRET');
|
||||||
|
$status->document = new \stdClass;
|
||||||
|
$status->document->todayCount = $oDocumentAdminModel->getDocumentCountByDate($today, array(), $statusList);
|
||||||
|
$status->document->totalCount = $oDocumentAdminModel->getDocumentCountByDate('', array(), $statusList);
|
||||||
|
|
||||||
|
Context::set('status', $status);
|
||||||
|
|
||||||
|
// Latest Document
|
||||||
|
$args->list_count = 5;
|
||||||
|
$columnList = array('document_srl', 'module_srl', 'category_srl', 'title', 'nick_name', 'member_srl');
|
||||||
|
$output = DocumentModel::getDocumentList($args, false, false, $columnList);
|
||||||
|
Context::set('latestDocumentList', $output->data);
|
||||||
|
unset($args, $output, $columnList);
|
||||||
|
|
||||||
|
// Latest Comment
|
||||||
|
$args = new \stdClass;
|
||||||
|
$args->list_count = 5;
|
||||||
|
$columnList = array('comment_srl', 'module_srl', 'document_srl', 'content', 'nick_name', 'member_srl');
|
||||||
|
$output = CommentModel::getNewestCommentList($args, $columnList);
|
||||||
|
if (is_array($output))
|
||||||
|
{
|
||||||
|
foreach ($output as $key => $value)
|
||||||
|
{
|
||||||
|
$value->content = strip_tags($value->content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Context::set('latestCommentList', $output);
|
||||||
|
unset($args, $output, $columnList);
|
||||||
|
|
||||||
|
// Get list of modules
|
||||||
|
$module_list = ModuleModel::getModuleList();
|
||||||
|
$addTables = false;
|
||||||
|
$wrongPaths = [];
|
||||||
|
$needUpdate = false;
|
||||||
|
if (is_array($module_list))
|
||||||
|
{
|
||||||
|
$priority = array(
|
||||||
|
'module' => 1000000,
|
||||||
|
'member' => 100000,
|
||||||
|
'document' => 10000,
|
||||||
|
'comment' => 1000,
|
||||||
|
'file' => 100,
|
||||||
|
);
|
||||||
|
usort($module_list, function($a, $b) use($priority) {
|
||||||
|
$a_priority = isset($priority[$a->module]) ? $priority[$a->module] : 0;
|
||||||
|
$b_priority = isset($priority[$b->module]) ? $priority[$b->module] : 0;
|
||||||
|
if ($a_priority == 0 && $b_priority == 0)
|
||||||
|
{
|
||||||
|
return strcmp($a->module, $b->module);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $b_priority - $a_priority;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
foreach ($module_list as $value)
|
||||||
|
{
|
||||||
|
if ($value->need_install)
|
||||||
|
{
|
||||||
|
$addTables = TRUE;
|
||||||
|
}
|
||||||
|
if ($value->need_update)
|
||||||
|
{
|
||||||
|
$needUpdate = TRUE;
|
||||||
|
}
|
||||||
|
if (!preg_match('/^[a-z0-9_]+$/i', $value->module))
|
||||||
|
{
|
||||||
|
$wrongPaths[] = $value->module;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the list of installed modules
|
||||||
|
$this->checkEasyInstall();
|
||||||
|
|
||||||
|
// Get need update from easy install
|
||||||
|
//$oAutoinstallAdminModel = getAdminModel('autoinstall');
|
||||||
|
//$needUpdateList = $oAutoinstallAdminModel->getNeedUpdateList();
|
||||||
|
$needUpdateList = array();
|
||||||
|
|
||||||
|
// Check counter addon
|
||||||
|
$oAddonAdminModel = AddonAdminModel::getInstance();
|
||||||
|
$counterAddonActivated = $oAddonAdminModel->isActivatedAddon('counter');
|
||||||
|
if(!$counterAddonActivated)
|
||||||
|
{
|
||||||
|
$columnList = array('member_srl', 'nick_name', 'user_name', 'user_id', 'email_address');
|
||||||
|
$args = new \stdClass;
|
||||||
|
$args->page = 1;
|
||||||
|
$args->list_count = 5;
|
||||||
|
$output = executeQuery('member.getMemberList', $args, $columnList);
|
||||||
|
Context::set('latestMemberList', $output->data);
|
||||||
|
unset($args, $output, $columnList);
|
||||||
|
}
|
||||||
|
|
||||||
|
Context::set('module_list', $module_list);
|
||||||
|
Context::set('needUpdate', false);
|
||||||
|
Context::set('addTables', $addTables);
|
||||||
|
Context::set('wrongPaths', $wrongPaths);
|
||||||
|
Context::set('needUpdate', $needUpdate);
|
||||||
|
Context::set('newVersionList', $needUpdateList);
|
||||||
|
Context::set('counterAddonActivated', $counterAddonActivated);
|
||||||
|
|
||||||
|
$oSecurity = new \Security();
|
||||||
|
$oSecurity->encodeHTML('module_list..', 'module_list..author..', 'newVersionList..');
|
||||||
|
|
||||||
|
Context::set('layout', 'none');
|
||||||
|
$this->setTemplateFile('index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check easy install.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function checkEasyInstall()
|
||||||
|
{
|
||||||
|
$lastTime = intval(FileHandler::readFile(self::EASYINSTALL_FLAG_FILE));
|
||||||
|
if($lastTime > $_SERVER['REQUEST_TIME'] - 60 * 60 * 24 * 30)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$oAutoinstallAdminModel = getAdminModel('autoinstall');
|
||||||
|
$config = $oAutoinstallAdminModel->getAutoInstallAdminModuleConfig();
|
||||||
|
|
||||||
|
$oAutoinstallModel = getModel('autoinstall');
|
||||||
|
$params = array();
|
||||||
|
$params["act"] = "getResourceapiLastupdate";
|
||||||
|
$body = \XmlGenerater::generate($params);
|
||||||
|
$buff = FileHandler::getRemoteResource($config->download_server, $body, 3, "POST", "application/xml");
|
||||||
|
$xml_lUpdate = new \XeXmlParser();
|
||||||
|
$lUpdateDoc = $xml_lUpdate->parse($buff);
|
||||||
|
$updateDate = $lUpdateDoc->response->updatedate->body;
|
||||||
|
|
||||||
|
if(!$updateDate)
|
||||||
|
{
|
||||||
|
$this->_updateEasyInstallFlagFile();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item = $oAutoinstallModel->getLatestPackage();
|
||||||
|
if(!$item || $item->updatedate < $updateDate)
|
||||||
|
{
|
||||||
|
$oController = getAdminController('autoinstall');
|
||||||
|
$oController->_updateinfo();
|
||||||
|
}
|
||||||
|
$this->_updateEasyInstallFlagFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the easy install flag file.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function _updateEasyInstallFlagFile()
|
||||||
|
{
|
||||||
|
FileHandler::writeFile(self::EASYINSTALL_FLAG_FILE, \RX_TIME);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
modules/admin/controllers/Update.php
Normal file
10
modules/admin/controllers/Update.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Rhymix\Modules\Admin\Controllers;
|
||||||
|
|
||||||
|
use Rhymix\Framework\DB;
|
||||||
|
|
||||||
|
class Update extends Base
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue