[xoops-cvslog 4665] CVS update: xoops2jp/html/modules/base/preload/Primary

Back to archive index

Minahito minah****@users*****
2006年 9月 28日 (木) 14:03:56 JST


Index: xoops2jp/html/modules/base/preload/Primary/SiteClose.class.php
diff -u xoops2jp/html/modules/base/preload/Primary/SiteClose.class.php:1.1.2.6 xoops2jp/html/modules/base/preload/Primary/SiteClose.class.php:1.1.2.6.2.1
--- xoops2jp/html/modules/base/preload/Primary/SiteClose.class.php:1.1.2.6	Tue Sep 26 12:18:12 2006
+++ xoops2jp/html/modules/base/preload/Primary/SiteClose.class.php	Thu Sep 28 14:03:56 2006
@@ -1,161 +1,185 @@
 <?php
+/**
+ * @package Legacy
+ * @version $Id: SiteClose.class.php,v 1.1.2.6.2.1 2006/09/28 05:03:56 minahito Exp $
+ */
 
 if (!defined('XOOPS_ROOT_PATH')) exit();
 
+/**
+ * The action filter for the site close procedure.
+ */
 class Legacy_SiteClose extends XCube_ActionFilter
 {
 	function preBlockFilter()
 	{
-        if(($this->mController->mConfig['closesite']==1)||is_array(XCube_Utils::checkSystemModules())) {
-			$this->mController->mRoot->mDelegateManager->add("Site.Login", array(&$this, "callbackSiteLogin"), XCUBE_DELEGATE_PRIORITY_FINAL);
-			$this->mController->mRoot->mDelegateManager->add("Site.CheckLogin.Success",array(&$this,"callbackCheckLoginSuccess"));
+		if (($this->mController->mConfig['closesite'] == 1) || is_array(Legacy_Utils::checkSystemModules())) {
+			$this->mController->mSetupUser->add("Legacy_Controller.SetupUser", "Legacy_SiteClose::callbackSetupUser", XCUBE_DELEGATE_PRIORITY_FINAL);
+			$this->mRoot->mDelegateManager->add("Site.CheckLogin.Success", array(&$this, "callbackCheckLoginSuccess"));
 		}
 	}
 
-	function callbackSiteLogin(&$xoopsUser)
+	/**
+	 * 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 = XCube_Utils::checkSystemModules();
-	    $accessAllowFlag = false;
+		$retArray = XCube_Utils::checkSystemModules();
+		$accessAllowFlag = false;
 		
-		if(!empty($_POST['xoops_login'])) {
-            if (is_array($retArray)) {
-    			define('XOOPS_CPFUNC_LOADED',1);
-    		}
+		if (!empty($_POST['xoops_login'])) {
+			if (is_array($retArray)) {
+				define('XOOPS_CPFUNC_LOADED', 1);
+			}
 
-			$this->mController->checkLogin();
+			$controller->checkLogin();
 			return;
-	    } elseif(is_object($this->mController->mXoopsUser)) {
-			foreach ($this->mController->mXoopsUser->getGroups() as $group) {
-				if (in_array($group, $this->mController->mConfig['closesite_okgrp']) || XOOPS_GROUP_ADMIN == $group) {
+		} elseif (is_object($controller->mXoopsUser)) {
+			foreach ($controller->mXoopsUser->getGroups() as $group) {
+				if (in_array($group, $controller->mConfig['closesite_okgrp']) || XOOPS_GROUP_ADMIN == $group) {
 					$accessAllowFlag = true;
 					break;
 				}
 			}
 		}
 		
-        // @todo Devide following lines to another preload file
-        if ($accessAllowFlag) {
-            if (is_array($retArray)) {
-               if (in_array(XOOPS_GROUP_ADMIN, $this->mController->mXoopsUser->getGroups())) {
-                    $GLOBALS['xoopsUser'] = $this->mController->mXoopsUser;
-                    if (!empty($_POST['cube_module_install'])) { //@todo use Ticket
-                        require_once XOOPS_BASE_PATH."/admin/class/ModuleInstaller.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'])) {
-                                    $installer = new Legacy_ModuleInstaller($module);
-                                    $installer->execute();
-                                }
-                            }
-                        }
-                        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','base');
-                            $objects = $handler->getObjects();
-                            $optionModules = array();
-                            foreach($objects as $module) {
-                                if (!in_array($module->getVar('dirname'), $retArray['uninstalled'])) {
-                                    $optionModules[] = $module->getVar('dirname');
-                                }
-                            }
-                            foreach($_POST['option_modules'] as $module) {
-                                $module = basename($module);
-                                if (in_array($module, $optionModules)) {
-                                    $installer = new Legacy_ModuleInstaller($module);
-                                    $installer->execute();
-                                }
-                            }
-                        }
-                        $this->mController->executeRedirect(XOOPS_URL . '/',1);
-                    } else if (!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($this->mController->mConfig['sitename']),
-                                       'xoops_themecss' => xoops_getcss(),
-                                       'xoops_imageurl' => XOOPS_THEME_URL.'/'.$this->mController->mConfig['theme_set'].'/',
-                                       ));
-                        ///< @todo filebase template with absolute file path
-                        $xoopsTpl->compile_check = true;
-                        $xoopsTpl->display(XOOPS_ROOT_PATH.'/modules/base/templates/legacy_uninstall_modules.html');
-                        exit();
-                    } else if (!empty($_POST['cube_module_uninstallok'])) { //@todo use Ticket
-                        require_once XOOPS_BASE_PATH."/admin/class/ModuleUninstaller.class.php";
-                        $module = basename($_POST['cube_module_uninstallok']);
-                        if (in_array($module, $retArray['disabled'])) {
-                            $uninstaller = new Legacy_ModuleUninstaller($module);
-                            $uninstaller->execute();
-                        }
-                        $this->mController->executeRedirect(XOOPS_URL . '/',1);
-                    } else {
-                        $handler =& xoops_getmodulehandler('non_installation_module','base');
-                        $objects = $handler->getObjects();
-                        $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($this->mController->mConfig['sitename']),
-                                       'xoops_themecss' => xoops_getcss(),
-                                       'xoops_imageurl' => XOOPS_THEME_URL.'/'.$this->mController->mConfig['theme_set'].'/',
-                                       ));
-                        ///< @todo filebase template with absolute file path
-                        $xoopsTpl->compile_check = true;
-                        $xoopsTpl->display(XOOPS_ROOT_PATH.'/modules/base/templates/legacy_install_modules.html');
-                        exit();
-                    }
-               } else {
-                    $accessAllowFlag = false;
-               }
-            }
-        }
-
-	    if (!$accessAllowFlag) {
-	        require_once XOOPS_ROOT_PATH.'/class/template.php';
-	        $xoopsTpl = new XoopsTpl();
-	        $xoopsTpl->assign( array('xoops_sitename' => htmlspecialchars($this->mController->mConfig['sitename']),
-	                                   'xoops_themecss' => xoops_getcss(),
-	                                   'xoops_imageurl' => XOOPS_THEME_URL.'/'.$this->mController->mConfig['theme_set'].'/',
-	                                   'lang_login' => _LOGIN,
-	                                   'lang_username' => _USERNAME,
-	                                   'lang_password' => _PASSWORD,
-	                                   'lang_siteclosemsg' => $this->mController->mConfig['closesite_text']));
-            $xoopsTpl->compile_check = true;
-            // @todo filebase template with absolute file path
-            $xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/base/templates/legacy_site_closed.html');
-	        exit();
-	    }
+		// @todo Devide following lines to another preload file
+		if ($accessAllowFlag && is_array($retArray)) {
+			if (in_array(XOOPS_GROUP_ADMIN, $controller->mXoopsUser->getGroups())) {
+				$GLOBALS['xoopsUser'] = $controller->mXoopsUser;
+				if (!empty($_POST['cube_module_install'])) { //@todo use Ticket
+					require_once XOOPS_BASE_PATH . "/admin/class/ModuleInstaller.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'])) {
+								$installer =& new Legacy_ModuleInstaller($module);
+								$installer->execute();
+							}
+						}
+					}
+					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', 'base');
+						$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)) {
+								$installer =& new Legacy_ModuleInstaller($module);
+								$installer->execute();
+							}
+						}
+					}
+					$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($controller->mConfig['sitename']),
+								   'xoops_themecss' => xoops_getcss(),
+								   'xoops_imageurl' => XOOPS_THEME_URL . '/' . $controller->mConfig['theme_set'] . '/',
+								   ));
+					///< @todo filebase template with absolute file path
+					$xoopsTpl->compile_check = true;
+					$xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/base/templates/legacy_uninstall_modules.html');
+					exit();
+				}
+				elseif (!empty($_POST['cube_module_uninstallok'])) { //@todo use Ticket
+					require_once XOOPS_BASE_PATH . "/admin/class/ModuleUninstaller.class.php";
+					$module = basename($_POST['cube_module_uninstallok']);
+					if (in_array($module, $retArray['disabled'])) {
+						$uninstaller =& new Legacy_ModuleUninstaller($module);
+						$uninstaller->execute();
+					}
+					$controller->executeRedirect(XOOPS_URL . '/',1);
+				}
+				else {
+					$handler =& xoops_getmodulehandler('non_installation_module','base');
+					$objects = $handler->getObjects();
+					$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($controller->mConfig['sitename']),
+								   'xoops_themecss' => xoops_getcss(),
+								   'xoops_imageurl' => XOOPS_THEME_URL . '/' . $controller->mConfig['theme_set'] . '/'
+								   ));
+					///< @todo filebase template with absolute file path
+					$xoopsTpl->compile_check = true;
+					$xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/base/templates/legacy_install_modules.html');
+					exit();
+				}
+		   } else {
+				$accessAllowFlag = false;
+		   }
+		}
+
+		if (!$accessAllowFlag) {
+			require_once XOOPS_ROOT_PATH . '/class/template.php';
+			$xoopsTpl =& new XoopsTpl();
+			$xoopsTpl->assign(array('xoops_sitename' => htmlspecialchars($controller->mConfig['sitename']),
+									   'xoops_themecss' => xoops_getcss(),
+									   'xoops_imageurl' => XOOPS_THEME_URL . '/' . $controller->mConfig['theme_set'] . '/',
+									   'lang_login' => _LOGIN,
+									   'lang_username' => _USERNAME,
+									   'lang_password' => _PASSWORD,
+									   'lang_siteclosemsg' => $controller->mConfig['closesite_text']
+									   ));
+									   
+			$xoopsTpl->compile_check = true;
+			
+			// @todo filebase template with absolute file path
+			$xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/base/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)
 	{
 		//


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