00001 <?php
00002
00015
00016
00017
00018 import('site.Version');
00019 import('site.VersionDAO');
00020 import('site.VersionCheck');
00021
00022 class AdminFunctionsHandler extends AdminHandler {
00023
00027 function systemInfo() {
00028 parent::validate();
00029 parent::setupTemplate(true);
00030
00031 $configData = &Config::getData();
00032
00033 $dbconn = &DBConnection::getConn();
00034 $dbServerInfo = $dbconn->ServerInfo();
00035
00036 $versionDao = &DAORegistry::getDAO('VersionDAO');
00037 $currentVersion = &$versionDao->getCurrentVersion();
00038 $versionHistory = &$versionDao->getVersionHistory();
00039
00040 $serverInfo = array(
00041 'admin.server.platform' => Core::serverPHPOS(),
00042 'admin.server.phpVersion' => Core::serverPHPVersion(),
00043 'admin.server.apacheVersion' => (function_exists('apache_get_version') ? apache_get_version() : Locale::translate('common.notAvailable')),
00044 'admin.server.dbDriver' => Config::getVar('database', 'driver'),
00045 'admin.server.dbVersion' => (empty($dbServerInfo['description']) ? $dbServerInfo['version'] : $dbServerInfo['description'])
00046 );
00047
00048 $templateMgr = &TemplateManager::getManager();
00049 $templateMgr->assign_by_ref('currentVersion', $currentVersion);
00050 $templateMgr->assign_by_ref('versionHistory', $versionHistory);
00051 $templateMgr->assign_by_ref('configData', $configData);
00052 $templateMgr->assign_by_ref('serverInfo', $serverInfo);
00053 if (Request::getUserVar('versionCheck')) {
00054 $latestVersionInfo = &VersionCheck::getLatestVersion();
00055 $latestVersionInfo['patch'] = VersionCheck::getPatch($latestVersionInfo);
00056 $templateMgr->assign_by_ref('latestVersionInfo', $latestVersionInfo);
00057 }
00058 $templateMgr->assign('helpTopicId', 'site.administrativeFunctions');
00059 $templateMgr->display('admin/systemInfo.tpl');
00060 }
00061
00065 function editSystemConfig() {
00066 parent::validate();
00067 parent::setupTemplate(true);
00068
00069 $templateMgr = &TemplateManager::getManager();
00070 $templateMgr->append('pageHierarchy', array(Request::url(null, 'admin', 'systemInfo'), 'admin.systemInformation'));
00071
00072 $configData = &Config::getData();
00073
00074 $templateMgr = &TemplateManager::getManager();
00075 $templateMgr->assign_by_ref('configData', $configData);
00076 $templateMgr->assign('helpTopicId', 'site.administrativeFunctions');
00077 $templateMgr->display('admin/systemConfig.tpl');
00078 }
00079
00083 function saveSystemConfig() {
00084 parent::validate();
00085 parent::setupTemplate(true);
00086
00087 $configData = &Config::getData();
00088
00089
00090 foreach ($configData as $sectionName => $sectionData) {
00091 $newData = Request::getUserVar($sectionName);
00092 foreach ($sectionData as $settingName => $settingValue) {
00093 if (isset($newData[$settingName])) {
00094 $newValue = $newData[$settingName];
00095 if (strtolower($newValue) == "true" || strtolower($newValue) == "on") {
00096 $newValue = "On";
00097 } else if (strtolower($newValue) == "false" || strtolower($newValue) == "off") {
00098 $newValue = "Off";
00099 }
00100 $configData[$sectionName][$settingName] = $newValue;
00101 }
00102 }
00103 }
00104
00105 $templateMgr = &TemplateManager::getManager();
00106
00107
00108 $configParser = &new ConfigParser();
00109 if (!$configParser->updateConfig(Config::getConfigFileName(), $configData)) {
00110
00111 $templateMgr->assign('errorMsg', 'admin.systemConfigFileReadError');
00112 $templateMgr->assign('backLink', Request::url(null, null, 'systemInfo'));
00113 $templateMgr->assign('backLinkLabel', 'admin.systemInformation');
00114 $templateMgr->display('common/error.tpl');
00115
00116 } else {
00117 $writeConfigFailed = false;
00118 $displayConfigContents = Request::getUserVar('display') == null ? false : true;
00119 $configFileContents = $configParser->getFileContents();
00120
00121 if (!$displayConfigContents) {
00122 if (!$configParser->writeConfig(Config::getConfigFileName())) {
00123 $writeConfigFailed = true;
00124 }
00125 }
00126
00127
00128 $templateMgr->assign('writeConfigFailed', $writeConfigFailed);
00129 $templateMgr->assign('displayConfigContents', $displayConfigContents);
00130 $templateMgr->assign('configFileContents', $configFileContents);
00131 $templateMgr->assign('helpTopicId', 'site.administrativeFunctions');
00132 $templateMgr->display('admin/systemConfigUpdated.tpl');
00133 }
00134 }
00135
00139 function phpinfo() {
00140 parent::validate();
00141 phpinfo();
00142 }
00143
00147 function expireSessions() {
00148 parent::validate();
00149 $sessionDao = &DAORegistry::getDAO('SessionDAO');
00150 $sessionDao->deleteAllSessions();
00151 Request::redirect(null, 'admin');
00152 }
00153
00157 function clearTemplateCache() {
00158 parent::validate();
00159 $templateMgr = &TemplateManager::getManager();
00160 $templateMgr->clearTemplateCache();
00161 Request::redirect(null, 'admin');
00162 }
00163
00167 function clearDataCache() {
00168 parent::validate();
00169
00170
00171 import('cache.CacheManager');
00172 $cacheManager =& CacheManager::getManager();
00173 $cacheManager->flush();
00174
00175
00176 $userDao =& DAORegistry::getDAO('UserDAO');
00177 $userDao->flushCache();
00178
00179 Request::redirect(null, 'admin');
00180 }
00181 }
00182
00183 ?>