[xoops-cvslog 6035] CVS update: xoops2jp/html/modules/legacy/preload/Primary

Back to archive index

NobuNobu nobun****@users*****
2006年 12月 14日 (木) 21:59:53 JST


Index: xoops2jp/html/modules/legacy/preload/Primary/SiteClose.class.php
diff -u xoops2jp/html/modules/legacy/preload/Primary/SiteClose.class.php:1.1.2.7 xoops2jp/html/modules/legacy/preload/Primary/SiteClose.class.php:1.1.2.8
--- xoops2jp/html/modules/legacy/preload/Primary/SiteClose.class.php:1.1.2.7	Tue Nov 21 00:54:44 2006
+++ xoops2jp/html/modules/legacy/preload/Primary/SiteClose.class.php	Thu Dec 14 21:59:53 2006
@@ -1,7 +1,7 @@
 <?php
 /**
  * @package Legacy
- * @version $Id: SiteClose.class.php,v 1.1.2.7 2006/11/20 15:54:44 minahito Exp $
+ * @version $Id: SiteClose.class.php,v 1.1.2.8 2006/12/14 12:59:53 nobunobu Exp $
  */
 
 if (!defined('XOOPS_ROOT_PATH')) exit();
@@ -13,7 +13,7 @@
 {
 	function preBlockFilter()
 	{
-		if (($this->mRoot->mContext->getXoopsConfig('closesite') == 1) || is_array(Legacy_Utils::checkSystemModules())) {
+		if ($this->mRoot->mContext->getXoopsConfig('closesite') == 1) {
 			$this->mController->mSetupUser->add("Legacy_SiteClose::callbackSetupUser", XCUBE_DELEGATE_PRIORITY_FINAL);
 			$this->mRoot->mDelegateManager->add("Site.CheckLogin.Success", array(&$this, "callbackCheckLoginSuccess"));
 		}
@@ -27,15 +27,10 @@
 	 */
 	function callbackSetupUser(&$principal, &$controller, &$context)
 	{
-		$retArray = Legacy_Utils::checkSystemModules();
 		$accessAllowFlag = false;
 		$xoopsConfig = $controller->mRoot->mContext->getXoopsConfig();
 		
 		if (!empty($_POST['xoops_login'])) {
-			if (is_array($retArray)) {
-				define('XOOPS_CPFUNC_LOADED', 1);
-			}
-
 			$controller->checkLogin();
 			return;
 		} elseif (is_object($context->mXoopsUser)) {
@@ -46,140 +41,6 @@
 				}
 			}
 		}
-		
-		// @todo Devide following lines to another preload file
-		if ($accessAllowFlag && is_array($retArray)) {
-			if (in_array(XOOPS_GROUP_ADMIN, $context->mXoopsUser->getGroups())) {
-				$GLOBALS['xoopsUser'] = $context->mXoopsUser;
-				if (!empty($_POST['cube_module_install'])) { //@todo use Ticket
-					require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstaller.class.php";
-					require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstallUtils.class.php";
-					if (isset($_POST['uninstalled_modules']) && is_array($_POST['uninstalled_modules'])){
-						foreach ($_POST['uninstalled_modules'] as $module) {
-							$module = basename($module);
-							if (in_array($module, $retArray['uninstalled'])) {
-								$controller->mRoot->mLanguageManager->loadModuleAdminMessageCatalog('legacy');
-								
-								$handler =& xoops_gethandler('module');
-								$xoopsModule =& $handler->create();
-								$xoopsModule->set('weight', 1);
-								$xoopsModule->loadInfoAsVar($module);
-								
-								$installer =& Legacy_ModuleInstallUtils::createInstaller($xoopsModule->get('dirname'));
-								$installer->setForceMode(true);
-								$installer->setCurrentXoopsModule($xoopsModule);
-								$installer->executeInstall();
-							}
-						}
-					}
-					if (isset($_POST['disabled_modules']) && is_array($_POST['disabled_modules'])){
-						$moduleHandler =& xoops_gethandler('module');
-						foreach ($_POST['disabled_modules'] as $module) {
-							$module = basename($module);
-							if (in_array($module, $retArray['disabled'])) {
-								if ($moduleObject =& $moduleHandler->getByDirname($module)) {
-									$moduleObject->setVar('isactive', 1);
-									$moduleHandler->insert($moduleObject);
-								}
-							}
-						}
-					}
-					if (isset($_POST['option_modules']) && is_array($_POST['option_modules']) ){
-						$handler =& xoops_getmodulehandler('non_installation_module', 'legacy');
-						$objects = $handler->getObjects();
-						$optionModules = array();
-						foreach ($objects as $module) {
-							if (!in_array($module->get('dirname'), $retArray['uninstalled'])) {
-								$optionModules[] = $module->get('dirname');
-							}
-						}
-						foreach ($_POST['option_modules'] as $module) {
-							$module = basename($module);
-							if (in_array($module, $optionModules)) {
-								$controller->mRoot->mLanguageManager->loadModuleAdminMessageCatalog('legacy');
-								
-								$handler =& xoops_gethandler('module');
-								$xoopsModule =& $handler->create();
-								$xoopsModule->set('weight', 1);
-								$xoopsModule->loadInfoAsVar($module);
-								
-								$installer =& Legacy_ModuleInstallUtils::createInstaller($xoopsModule->get('dirname'));
-								$installer->setForceMode(true);
-								$installer->setCurrentXoopsModule($xoopsModule);
-								$installer->executeInstall();
-							}
-						}
-					}
-					$controller->executeRedirect(XOOPS_URL . '/', 1);
-				}
-				elseif (!empty($_GET['cube_module_uninstall'])) {
-					require_once XOOPS_ROOT_PATH . '/class/template.php';
-					$xoopsTpl =& new XoopsTpl();
-					$xoopsTpl->assign('cube_module_uninstall', htmlspecialchars($_GET['cube_module_uninstall'],ENT_QUOTES));
-					$xoopsTpl->assign( array(
-								   'xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']),
-								   'xoops_themecss' => xoops_getcss(),
-								   'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/',
-								   ));
-					///< @todo filebase template with absolute file path
-					$xoopsTpl->compile_check = true;
-					$xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_uninstall_modules.html');
-					exit();
-				}
-				elseif (!empty($_POST['cube_module_uninstallok'])) { //@todo use Ticket
-					require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleUninstaller.class.php";
-					require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstallUtils.class.php";
-					$module = basename($_POST['cube_module_uninstallok']);
-					if (in_array($module, $retArray['disabled'])) {
-						$controller->mRoot->mLanguageManager->loadModuleAdminMessageCatalog('legacy');
-								
-						$handler =& xoops_gethandler('module');
-						$xoopsModule =& $handler->getByDirname($module);
-						
-						$uninstaller =& Legacy_ModuleInstallUtils::createUninstaller($xoopsModule->get('dirname'));
-						$uninstaller->setForceMode(true);
-						$uninstaller->setCurrentXoopsModule($xoopsModule);
-						$uninstaller->executeUninstall();
-					}
-					$controller->executeRedirect(XOOPS_URL . '/',1);
-				}
-				else {
-					$handler =& xoops_getmodulehandler('non_installation_module','legacy');
-					$objects = $handler->getObjectsFor2ndInstaller();
-					$optionModules = array();
-					foreach ($objects as $module) {
-						$dirname = $module->getVar('dirname');
-						if (!in_array($dirname, $retArray['uninstalled'])) {
-							$optionModule['dirname']  = $dirname;
-							if (in_array($dirname, $retArray['recommended'])) {
-								$optionModule['checked']  = 'checked="checked"';
-								$optionModule['desc']  = _SYS_RECOMMENDED_MODULES;
-							} else {
-								$optionModule['checked']  = '';
-								$optionModule['desc']  = _SYS_OPTION_MODULES;
-							}
-							$optionModules[] = $optionModule;
-						}
-					}
-					require_once XOOPS_ROOT_PATH . '/class/template.php';
-					$xoopsTpl =& new XoopsTpl();
-					$xoopsTpl->assign('uninstalled',$retArray['uninstalled']);
-					$xoopsTpl->assign('disabled',$retArray['disabled']);
-					$xoopsTpl->assign('option',$optionModules);
-					$xoopsTpl->assign(array(
-								   'xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']),
-								   'xoops_themecss' => xoops_getcss(),
-								   'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/'
-								   ));
-					///< @todo filebase template with absolute file path
-					$xoopsTpl->compile_check = true;
-					$xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_install_modules.html');
-					exit();
-				}
-		   } else {
-				$accessAllowFlag = false;
-		   }
-		}
 
 		if (!$accessAllowFlag) {
 			require_once XOOPS_ROOT_PATH . '/class/template.php';
Index: xoops2jp/html/modules/legacy/preload/Primary/SystemModuleInstall.class.php
diff -u /dev/null xoops2jp/html/modules/legacy/preload/Primary/SystemModuleInstall.class.php:1.1.2.1
--- /dev/null	Thu Dec 14 21:59:53 2006
+++ xoops2jp/html/modules/legacy/preload/Primary/SystemModuleInstall.class.php	Thu Dec 14 21:59:53 2006
@@ -0,0 +1,214 @@
+<?php
+/**
+ * @package Legacy
+ * @version $Id: SystemModuleInstall.class.php,v 1.1.2.1 2006/12/14 12:59:53 nobunobu Exp $
+ */
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+/**
+ * The action filter for the site close procedure.
+ */
+class Legacy_SystemModuleInstall extends XCube_ActionFilter
+{
+	function preBlockFilter()
+	{
+		if (is_array(Legacy_Utils::checkSystemModules())) {
+			$this->mController->mSetupUser->add("Legacy_SystemModuleInstall::callbackSetupUser", XCUBE_DELEGATE_PRIORITY_FINAL-1);
+			$this->mRoot->mDelegateManager->add("Site.CheckLogin.Success", array(&$this, "callbackCheckLoginSuccess"));
+		}
+	}
+
+	/**
+	 * Checks whether the site is closed now, and whether all of must modules
+	 * have been installed. This function is called through delegates.
+	 * @var XoopsUser &$xoopsUser
+	 * @see preBlockFilter()
+	 */
+	function callbackSetupUser(&$principal, &$controller, &$context)
+	{
+		$retArray = Legacy_Utils::checkSystemModules();
+		$accessAllowFlag = false;
+		$xoopsConfig = $controller->mRoot->mContext->getXoopsConfig();
+		
+		if (!empty($_POST['xoops_login'])) {
+			define('XOOPS_CPFUNC_LOADED', 1);
+			$controller->checkLogin();
+			return;
+		} elseif (is_object($context->mXoopsUser)) {
+		    if (in_array(XOOPS_GROUP_ADMIN, $context->mXoopsUser->getGroups())) {
+				$accessAllowFlag = true;
+			}
+		}
+		
+		// @todo Devide following lines to another preload file
+		if ($accessAllowFlag) {
+			$GLOBALS['xoopsUser'] = $context->mXoopsUser;
+			if (!empty($_POST['cube_module_install'])) { //@todo use Ticket
+				require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstaller.class.php";
+				require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstallUtils.class.php";
+				if (isset($_POST['uninstalled_modules']) && is_array($_POST['uninstalled_modules'])){
+					foreach ($_POST['uninstalled_modules'] as $module) {
+						$module = basename($module);
+						if (in_array($module, $retArray['uninstalled'])) {
+							$controller->mRoot->mLanguageManager->loadModuleAdminMessageCatalog('legacy');
+							
+							$handler =& xoops_gethandler('module');
+							$xoopsModule =& $handler->create();
+							$xoopsModule->set('weight', 1);
+							$xoopsModule->loadInfoAsVar($module);
+							
+							$installer =& Legacy_ModuleInstallUtils::createInstaller($xoopsModule->get('dirname'));
+							$installer->setForceMode(true);
+							$installer->setCurrentXoopsModule($xoopsModule);
+							$installer->executeInstall();
+						}
+					}
+				}
+				if (isset($_POST['disabled_modules']) && is_array($_POST['disabled_modules'])){
+					$moduleHandler =& xoops_gethandler('module');
+					foreach ($_POST['disabled_modules'] as $module) {
+						$module = basename($module);
+						if (in_array($module, $retArray['disabled'])) {
+							if ($moduleObject =& $moduleHandler->getByDirname($module)) {
+								$moduleObject->setVar('isactive', 1);
+								$moduleHandler->insert($moduleObject);
+							}
+						}
+					}
+				}
+				if (isset($_POST['option_modules']) && is_array($_POST['option_modules']) ){
+					$handler =& xoops_getmodulehandler('non_installation_module', 'legacy');
+					$objects = $handler->getObjects();
+					$optionModules = array();
+					foreach ($objects as $module) {
+						if (!in_array($module->get('dirname'), $retArray['uninstalled'])) {
+							$optionModules[] = $module->get('dirname');
+						}
+					}
+					foreach ($_POST['option_modules'] as $module) {
+						$module = basename($module);
+						if (in_array($module, $optionModules)) {
+							$controller->mRoot->mLanguageManager->loadModuleAdminMessageCatalog('legacy');
+							
+							$handler =& xoops_gethandler('module');
+							$xoopsModule =& $handler->create();
+							$xoopsModule->set('weight', 1);
+							$xoopsModule->loadInfoAsVar($module);
+							
+							$installer =& Legacy_ModuleInstallUtils::createInstaller($xoopsModule->get('dirname'));
+							$installer->setForceMode(true);
+							$installer->setCurrentXoopsModule($xoopsModule);
+							$installer->executeInstall();
+						}
+					}
+				}
+				$controller->executeRedirect(XOOPS_URL . '/', 1);
+			}
+			elseif (!empty($_GET['cube_module_uninstall'])) {
+				require_once XOOPS_ROOT_PATH . '/class/template.php';
+				$xoopsTpl =& new XoopsTpl();
+				$xoopsTpl->assign('cube_module_uninstall', htmlspecialchars($_GET['cube_module_uninstall'],ENT_QUOTES));
+				$xoopsTpl->assign( array(
+							   'xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']),
+							   'xoops_themecss' => xoops_getcss(),
+							   'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/',
+							   ));
+				///< @todo filebase template with absolute file path
+				$xoopsTpl->compile_check = true;
+				$xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_uninstall_modules.html');
+				exit();
+			}
+			elseif (!empty($_POST['cube_module_uninstallok'])) { //@todo use Ticket
+				require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleUninstaller.class.php";
+				require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstallUtils.class.php";
+				$module = basename($_POST['cube_module_uninstallok']);
+				if (in_array($module, $retArray['disabled'])) {
+					$controller->mRoot->mLanguageManager->loadModuleAdminMessageCatalog('legacy');
+							
+					$handler =& xoops_gethandler('module');
+					$xoopsModule =& $handler->getByDirname($module);
+					
+					$uninstaller =& Legacy_ModuleInstallUtils::createUninstaller($xoopsModule->get('dirname'));
+					$uninstaller->setForceMode(true);
+					$uninstaller->setCurrentXoopsModule($xoopsModule);
+					$uninstaller->executeUninstall();
+				}
+				$controller->executeRedirect(XOOPS_URL . '/',1);
+			}
+			else {
+				$handler =& xoops_getmodulehandler('non_installation_module','legacy');
+				$objects = $handler->getObjectsFor2ndInstaller();
+				$optionModules = array();
+				foreach ($objects as $module) {
+					$dirname = $module->getVar('dirname');
+					if (!in_array($dirname, $retArray['uninstalled'])) {
+						$optionModule['dirname']  = $dirname;
+						if (in_array($dirname, $retArray['recommended'])) {
+							$optionModule['checked']  = 'checked="checked"';
+							$optionModule['desc']  = _SYS_RECOMMENDED_MODULES;
+						} else {
+							$optionModule['checked']  = '';
+							$optionModule['desc']  = _SYS_OPTION_MODULES;
+						}
+						$optionModules[] = $optionModule;
+					}
+				}
+				require_once XOOPS_ROOT_PATH . '/class/template.php';
+				$xoopsTpl =& new XoopsTpl();
+				$xoopsTpl->assign('uninstalled',$retArray['uninstalled']);
+				$xoopsTpl->assign('disabled',$retArray['disabled']);
+				$xoopsTpl->assign('option',$optionModules);
+				$xoopsTpl->assign(array(
+							   'xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']),
+							   'xoops_themecss' => xoops_getcss(),
+							   'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/'
+							   ));
+				///< @todo filebase template with absolute file path
+				$xoopsTpl->compile_check = true;
+				$xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_install_modules.html');
+				exit();
+			}
+		}
+
+		if (!$accessAllowFlag) {
+			require_once XOOPS_ROOT_PATH . '/class/template.php';
+			$xoopsTpl =& new XoopsTpl();
+			$xoopsTpl->assign(array('xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']),
+									   'xoops_themecss' => xoops_getcss(),
+									   'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/',
+									   'lang_login' => _LOGIN,
+									   'lang_username' => _USERNAME,
+									   'lang_password' => _PASSWORD,
+									   'lang_siteclosemsg' => $xoopsConfig['closesite_text']
+									   ));
+									   
+			$xoopsTpl->compile_check = true;
+			
+			// @todo filebase template with absolute file path
+			$xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_site_closed.html');
+			exit();
+		}
+	}
+	
+	/**
+	 * When the user logs in successfully, checks whether the user belongs to
+	 * the special group which is allowed to login. This function is called
+	 * through delegates.
+	 * @var XoopsUser &$xoopsUser
+	 * @see preBlockFilter
+	 */
+	function callbackCheckLoginSuccess(&$xoopsUser)
+	{
+		//
+		// This check is not needed. :)
+		//
+		if (!is_object($xoopsUser)) {
+			return;
+		}
+	    if (!in_array(XOOPS_GROUP_ADMIN,$xoopsUser->getGroups())) {echo "aaaa";
+			$this->mController->redirectHeader(XOOPS_URL . '/', 1, _NOPERM);
+		}
+	}
+}
+?>


xoops-cvslog メーリングリストの案内
Back to archive index