NobuNobu
nobun****@users*****
2007年 4月 30日 (月) 16:31:42 JST
Index: xoops2jp/html/modules/legacy/class/AbstractDeleteAction.class.php diff -u /dev/null xoops2jp/html/modules/legacy/class/AbstractDeleteAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/AbstractDeleteAction.class.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,20 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/legacy/class/AbstractEditAction.class.php"; + +class Legacy_AbstractDeleteAction extends Legacy_AbstractEditAction +{ + function isEnableCreate() + { + return false; + } + + function _doExecute() + { + return $this->mObjectHandler->delete($this->mObject); + } +} + +?> Index: xoops2jp/html/modules/legacy/class/AbstractEditAction.class.php diff -u /dev/null xoops2jp/html/modules/legacy/class/AbstractEditAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/AbstractEditAction.class.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,93 @@ +<?php +/** + * @package Legacy + * @version $Id: AbstractEditAction.class.php,v 1.1.4.1 2007/04/30 07:31:41 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class Legacy_AbstractEditAction extends Legacy_Action +{ + var $mObject = null; + var $mObjectHandler = null; + var $mActionForm = null; + + function _getId() + { + } + + function &_getHandler() + { + } + + function _setupActionForm() + { + } + + function _setupObject() + { + $id = $this->_getId(); + + $this->mObjectHandler =& $this->_getHandler(); + + $this->mObject =& $this->mObjectHandler->get($id); + + if ($this->mObject == null && $this->isEnableCreate()) { + $this->mObject =& $this->mObjectHandler->create(); + } + } + + function isEnableCreate() + { + return true; + } + + function prepare(&$controller, &$xoopsUser) + { + $this->_setupObject(); + $this->_setupActionForm(); + } + + function getDefaultView(&$controller, &$xoopsUser) + { + if ($this->mObject == null) { + return LEGACY_FRAME_VIEW_ERROR; + } + + $this->mActionForm->load($this->mObject); + + return LEGACY_FRAME_VIEW_INPUT; + } + + function execute(&$controller, &$xoopsUser) + { + if ($this->mObject == null) { + return LEGACY_FRAME_VIEW_ERROR; + } + + if (xoops_getrequest('_form_control_cancel') != null) { + return LEGACY_FRAME_VIEW_CANCEL; + } + + $this->mActionForm->load($this->mObject); + + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + + if($this->mActionForm->hasError()) { + return LEGACY_FRAME_VIEW_INPUT; + } + + $this->mActionForm->update($this->mObject); + + return $this->_doExecute($this->mObject) ? LEGACY_FRAME_VIEW_SUCCESS + : LEGACY_FRAME_VIEW_ERROR; + } + + function _doExecute() + { + return $this->mObjectHandler->insert($this->mObject); + } +} + +?> Index: xoops2jp/html/modules/legacy/class/AbstractFilterForm.class.php diff -u /dev/null xoops2jp/html/modules/legacy/class/AbstractFilterForm.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/AbstractFilterForm.class.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,76 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class Legacy_AbstractFilterForm +{ + var $mSort = 0; + var $mSortKeys = array(); + var $_mCriteria = null; + var $mNavi = null; + + var $_mHandler = null; + + function Legacy_AbstractFilterForm(&$navi, &$handler) + { + $this->mNavi =& $navi; + $this->_mHandler =& $handler; + + $this->_mCriteria =& new CriteriaCompo(); + + $this->mNavi->mGetTotalItems->add(array(&$this, 'getTotalItems')); + } + + function getDefaultSortKey() + { + } + + function getTotalItems(&$total) + { + $total = $this->_mHandler->getCount($this->getCriteria()); + } + + function fetchSort() + { + $root =& XCube_Root::getSingleton(); + $this->mSort = intval($root->mContext->mRequest->getRequest('sort')); + + if (!isset($this->mSortKeys[abs($this->mSort)])) { + $this->mSort = $this->getDefaultSortKey(); + } + + $this->mNavi->mSort['sort'] = $this->mSort; + } + + function fetch() + { + $this->mNavi->fetch(); + $this->fetchSort(); + } + + function getSort() + { + $sortkey = abs($this->mNavi->mSort['sort']); + return isset($this->mSortKeys[$sortkey]) ? $this->mSortKeys[$sortkey] : null; + } + + function getOrder() + { + return ($this->mSort < 0) ? "DESC" : "ASC"; + } + + function getCriteria($start = null, $limit = null) + { + $t_start = ($start === null) ? $this->mNavi->getStart() : intval($start); + $t_limit = ($limit === null) ? $this->mNavi->getPerpage() : intval($limit); + + $criteria = $this->_mCriteria; + + $criteria->setStart($t_start); + $criteria->setLimit($t_limit); + + return $criteria; + } +} + +?> Index: xoops2jp/html/modules/legacy/class/AbstractListAction.class.php diff -u /dev/null xoops2jp/html/modules/legacy/class/AbstractListAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/AbstractListAction.class.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,43 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_ROOT_PATH . "/core/XCube_PageNavigator.class.php"; + +class Legacy_AbstractListAction extends Legacy_Action +{ + var $mObjects = array(); + + var $mFilter = null; + + function &_getHandler() + { + } + + function &_getFilterForm() + { + } + + function _getBaseUrl() + { + } + + function &_getPageNavi() + { + $navi =& new XCube_PageNavigator($this->_getBaseUrl(), XCUBE_PAGENAVI_START); + return $navi; + } + + function getDefaultView(&$controller, &$xoopsUser) + { + $this->mFilter =& $this->_getFilterForm(); + $this->mFilter->fetch(); + + $handler =& $this->_getHandler(); + $this->mObjects =& $handler->getObjects($this->mFilter->getCriteria()); + + return LEGACY_FRAME_VIEW_INDEX; + } +} + +?> Index: xoops2jp/html/modules/legacy/class/ActionFrame.class.php diff -u /dev/null xoops2jp/html/modules/legacy/class/ActionFrame.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/ActionFrame.class.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,243 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +define ("LEGACY_FRAME_PERFORM_SUCCESS", 1); +define ("LEGACY_FRAME_PERFORM_FAIL", 2); +define ("LEGACY_FRAME_INIT_SUCCESS", 3); + +define ("LEGACY_FRAME_VIEW_NONE", 1); +define ("LEGACY_FRAME_VIEW_SUCCESS", 2); +define ("LEGACY_FRAME_VIEW_ERROR", 3); +define ("LEGACY_FRAME_VIEW_INDEX", 4); +define ("LEGACY_FRAME_VIEW_INPUT", 5); +define ("LEGACY_FRAME_VIEW_PREVIEW", 6); +define ("LEGACY_FRAME_VIEW_CANCEL", 7); + +// +// Constatns for the mode of the frame. +// +define ("LEGACY_FRAME_MODE_MISC", "Misc"); +define ("LEGACY_FRAME_MODE_NOTIFY", "Notify"); +define ("LEGACY_FRAME_MODE_IMAGE", "Image"); +define ("LEGACY_FRAME_MODE_SEARCH", "Search"); + +class Legacy_ActionFrame +{ + var $mActionName = null; + var $mAction = null; + var $mAdminFlag = null; + + /** + * Mode. The rule refers this property to load a file and create an + * instance in execute(). + * + * @var string + */ + var $mMode = null; + + /** + * @var XCube_Delegate + */ + var $mCreateAction = null; + + function Legacy_ActionFrame($admin) + { + $this->mAdminFlag = $admin; + $this->mCreateAction =& new XCube_Delegate(); + $this->mCreateAction->register('Legacy_ActionFrame.CreateAction'); + $this->mCreateAction->add(array(&$this, '_createAction')); + } + + function setActionName($name) + { + $this->mActionName = $name; + + // + // Temp FIXME! + // + $root =& XCube_Root::getSingleton(); + $root->mContext->setAttribute('actionName', $name); + $root->mContext->mModule->setAttribute('actionName', $name); + } + + /** + * Set mode. + * + * @param string $mode Use constants (LEGACY_FRAME_MODE_MISC and more...) + */ + function setMode($mode) + { + $this->mMode = $mode; + } + + function _createAction(&$actionFrame) + { + if (is_object($actionFrame->mAction)) { + return; + } + + // + // Create action object by mActionName + // + $className = "Legacy_" . ucfirst($actionFrame->mActionName) . "Action"; + $fileName = ucfirst($actionFrame->mActionName) . "Action"; + if ($actionFrame->mAdminFlag) { + $fileName = XOOPS_MODULE_PATH . "/legacy/admin/actions/${fileName}.class.php"; + } + else { + $fileName = XOOPS_MODULE_PATH . "/legacy/actions/${fileName}.class.php"; + } + + if (!file_exists($fileName)) { + die(); + } + + require_once $fileName; + + if (class_exists($className)) { + $actionFrame->mAction =& new $className($actionFrame->mAdminFlag); + } + } + + function execute(&$controller) + { + if (strlen($this->mActionName) > 0 && !preg_match("/^\w+$/", $this->mActionName)) { + die(); + } + + // + // Actions of the public side in this module are hook type. So it's + // necessary to load catalog here. + // + if (!$this->mAdminFlag) { + $controller->mRoot->mLanguageManager->loadModuleMessageCatalog('legacy'); + } + + // + // Add mode. + // + $this->setActionName($this->mMode . $this->mActionName); + + // + // Create action object by mActionName + // + $this->mCreateAction->call(new XCube_Ref($this)); + + if (!(is_object($this->mAction) && is_a($this->mAction, 'Legacy_Action'))) { + die(); //< TODO + } + + if ($this->mAction->prepare($controller, $controller->mRoot->mContext->mXoopsUser) === false) { + die(); //< TODO + } + + if (!$this->mAction->hasPermission($controller, $controller->mRoot->mContext->mXoopsUser)) { + if ($this->mAdminFlag) { + $controller->executeForward(XOOPS_URL . "/admin.php"); + } + else { + $controller->executeForward(XOOPS_URL); + } + } + + if (xoops_getenv("REQUEST_METHOD") == "POST") { + $viewStatus = $this->mAction->execute($controller, $controller->mRoot->mContext->mXoopsUser); + } + else { + $viewStatus = $this->mAction->getDefaultView($controller, $controller->mRoot->mContext->mXoopsUser); + } + + switch($viewStatus) { + case LEGACY_FRAME_VIEW_SUCCESS: + $this->mAction->executeViewSuccess($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + + case LEGACY_FRAME_VIEW_ERROR: + $this->mAction->executeViewError($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + + case LEGACY_FRAME_VIEW_INDEX: + $this->mAction->executeViewIndex($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + + case LEGACY_FRAME_VIEW_INPUT: + $this->mAction->executeViewInput($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + + case LEGACY_FRAME_VIEW_PREVIEW: + $this->mAction->executeViewPreview($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + + case LEGACY_FRAME_VIEW_CANCEL: + $this->mAction->executeViewCancel($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModule->getRenderTarget()); + break; + } + } +} + +class Legacy_Action +{ + /** + * @access private + */ + var $_mAdminFlag = false; + + function Legacy_Action($adminFlag = false) + { + $this->_mAdminFlag = $adminFlag; + } + + function hasPermission(&$controller, &$xoopsUser) + { + if ($this->_mAdminFlag) { + return $controller->mRoot->mContext->mUser->isInRole('Module.legacy.Admin'); + } + else { + // + // TODO Really? + // + return true; + } + } + + function prepare(&$controller, &$xoopsUser) + { + } + + function getDefaultView(&$controller, &$xoopsUser) + { + return LEGACY_FRAME_VIEW_NONE; + } + + function execute(&$controller, &$xoopsUser) + { + return LEGACY_FRAME_VIEW_NONE; + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewIndex(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewPreview(&$controller, &$xoopsUser, &$render) + { + } + + function executeViewCancel(&$controller, &$xoopsUser, &$render) + { + } +} + +?> Index: xoops2jp/html/modules/legacy/class/Legacy_Debugger.class.php diff -u /dev/null xoops2jp/html/modules/legacy/class/Legacy_Debugger.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/Legacy_Debugger.class.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,170 @@ +<?php +// $Id: Legacy_Debugger.class.php,v 1.1.4.1 2007/04/30 07:31:41 nobunobu Exp $ +// ------------------------------------------------------------------------ // +// XOOPS - PHP Content Management System // +// Copyright (c) 2000 XOOPS.org // +// <http://www.xoops.org/> // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_ROOT_PATH . "/class/errorhandler.php"; + +define("XOOPS_DEBUG_OFF",0); +define("XOOPS_DEBUG_PHP",1); +define("XOOPS_DEBUG_MYSQL",2); +define("XOOPS_DEBUG_SMARTY",3); + +class Legacy_DebuggerManager +{ + /** + Create XoopsDebugger instance. + You must not communicate with this method directly. + */ + function createInstance(&$instance, $debug_mode) + { + if (is_object($instance)) { + return; + } + + switch($debug_mode) { + case XOOPS_DEBUG_PHP: + $instance = new Legacy_PHPDebugger(); + break; + + case XOOPS_DEBUG_MYSQL: + $instance = new Legacy_MysqlDebugger(); + break; + + case XOOPS_DEBUG_SMARTY: + $instance = new Legacy_SmartyDebugger(); + break; + + case XOOPS_DEBUG_OFF: + default: + $instance = new Legacy_NonDebugger(); + break; + } + } +} + +class Legacy_AbstractDebugger +{ + function Legacy_AbstractDebugger() + { + } + + function prepare() + { + } + + function isDebugRenderSystem() + { + return false; + } + + /** + * @return string Log as html code. + */ + function renderLog() + { + } + + function displayLog() + { + } +} + +class Legacy_NonDebugger extends Legacy_AbstractDebugger +{ +} + +/** +This class works for "PHP debugging mode". +*/ +class Legacy_PHPDebugger extends Legacy_AbstractDebugger +{ + function prepare() + { + error_reporting(E_ALL); + $GLOBALS['xoopsErrorHandler'] =& XoopsErrorHandler::getInstance(); + $GLOBALS['xoopsErrorHandler']->activate(true); + } +} + +/** +This class works for "Mysql debugging mode". +*/ +class Legacy_MysqlDebugger extends Legacy_AbstractDebugger +{ + function prepare() + { + $GLOBALS['xoopsErrorHandler'] =& XoopsErrorHandler::getInstance(); + $GLOBALS['xoopsErrorHandler']->activate(true); + } + + function renderLog() + { + $xoopsLogger =& XoopsLogger::instance(); + return $xoopsLogger->dumpAll(); + } + + function displayLog() + { + echo '<script type="text/javascript"> + <!--// + debug_window = openWithSelfMain("", "xoops_debug", 680, 600, true); + '; + $content = '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'" /><meta http-equiv="content-language" content="'._LANGCODE.'" /><title>'.htmlspecialchars($GLOBALS['xoopsConfig']['sitename']).'</title><link rel="stylesheet" type="text/css" media="all" href="'.getcss($GLOBALS['xoopsConfig']['theme_set']).'" /></head><body>'.$this->renderLog().'<div style="text-align:center;"><input class="formButton" value="'._CLOSE.'" type="button" onclick="javascript:window.close();" /></div></body></html>'; + $lines = preg_split("/(\r\n|\r|\n)( *)/", $content); + foreach ($lines as $line) { + echo 'debug_window.document.writeln("'.str_replace('"', '\"', $line).'");'; + } + echo ' + debug_window.document.close(); + //--> + </script>'; + } +} + + +/** +This class works for "Smarty debugging mode". +*/ +class Legacy_SmartyDebugger extends Legacy_AbstractDebugger +{ + function prepare() + { + $GLOBALS['xoopsErrorHandler'] =& XoopsErrorHandler::getInstance(); + $GLOBALS['xoopsErrorHandler']->activate(true); + } + + function isDebugRenderSystem() + { + $root =& XCube_Root::getSingleton(); + $user =& $root->mContext->mXoopsUser; + + return is_object($user) ? $user->isAdmin(0) : false; + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/legacy/class/Legacy_Utils.class.php diff -u /dev/null xoops2jp/html/modules/legacy/class/Legacy_Utils.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/Legacy_Utils.class.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,175 @@ +<?php +/** + * @file + * @brief Defines the utility function class of Legacy. + * @package Legacy + * @version $Id: Legacy_Utils.class.php,v 1.1.4.1 2007/04/30 07:31:41 nobunobu Exp $ + */ + +/** + * @brief The collection of static utility functions for Legacy. + */ +class Legacy_Utils +{ + /** + * Checks whether must modules have been installed. + * @static + * @return mixed Returns hashmap including the list of uninstalled, + * disabled and recommended modules, basically. But, if there is no problem, + * returns true. + */ + function checkSystemModules() + { + $root=&XCube_Root::getSingleton(); + $systemModules = array_map('trim', explode(',', $root->getSiteConfig('Cube', 'SystemModules'))); + $recommendedModules = array_map('trim', explode(',', $root->getSiteConfig('Cube',' RecommendedModules'))); + $moduleHandler =& xoops_gethandler('module'); + $uninstalledModules = array(); + $disabledModules = array(); + foreach ($systemModules as $systemModule) { + if (!empty($systemModule)) { + if (!($moduleObject =& $moduleHandler->getByDirname($systemModule))) { + $uninstalledModules[] = $systemModule; + } + elseif (!$moduleObject->get('isactive')) { + $disabledModules[] = $systemModule; + } + } + } + if (count($uninstalledModules) == 0 && count($disabledModules) == 0) { + return true; + } + else { + return array('uninstalled' =>$uninstalledModules, 'disabled'=>$disabledModules, 'recommended'=>$recommendedModules); + } + } + + /** + * Creates a instance of the module with the generating convention. And, + * returns it. + * @param XoopsModule $module + * @return Legacy_Module + */ + function &createModule($module) + { + $instance = null; + + // + // TODO need cache here? + // + XCube_DelegateUtils::call('Legacy_Utils.CreateModule', new XCube_Ref($instance), $module); + + if (is_object($instance) && is_a($instance, 'Legacy_AbstractModule')) { + return $instance; + } + + $dirname = $module->get('dirname'); + + // + // IMPORTANT CONVENTION + // + $className = ucfirst($dirname) . "_Module"; + if (!class_exists($className)) { + $filePath = XOOPS_ROOT_PATH . "/modules/${dirname}/class/Module.class.php"; + if (file_exists($filePath)) { + require_once $filePath; + } + } + + if (class_exists($className)) { + $instance =& new $className($module); + } + else { + $instance =& new Legacy_ModuleAdapter($module); + } + + return $instance; + } + + /** + * Creates a instance of the block procedure with the generating convention. + * And, returns it. + * @static + * @return Legacy_BlockProcedure + */ + function &createBlockProcedure(&$block) + { + // + // IMPORTANT CONVENTION + // + $retBlock = null; + + // + // TODO need cache here? + // + XCube_DelegateUtils::call('Legacy_Utils.CreateBlockProcedure', new XCube_Ref($retBlock), $block); + + if (is_object($retBlock) && is_a($retBlock, 'Legacy_AbstractBlockProcedure')) { + return $retBlock; + } + + $func = $block->get('show_func'); + if (substr($func, 0, 4) == 'cl::') { + $className = ucfirst($block->get('dirname')) . '_' . substr($func, 4); + if (!class_exists($className)) { + $filePath = XOOPS_ROOT_PATH . '/modules/' . $block->get('dirname') . '/blocks/' . $block->get('func_file'); + if (!file_exists($filePath)) { + $retBlock =& new Legacy_BlockProcedureAdapter($block); + return $retBlock; + } + + require_once $filePath; + + if (!class_exists($className)) { + $retBlock =& new Legacy_BlockProcedureAdapter($block); + return $retBlock; + } + } + + $retBlock =& new $className($block); + } + else { + $retBlock =& new Legacy_BlockProcedureAdapter($block); + } + + return $retBlock; + } + + /** + * Calls user controll event. + */ + function raiseUserControlEvent() + { + $root =& XCube_Root::getSingleton(); + foreach (array_keys($_REQUEST) as $key) { + if (strpos($key, 'Legacy_Event_User_') === 0) { + $eventName = substr($key, 18); + XCube_DelegateUtils::call('Legacy.Event.User.' . $eventName); + $root->mContext->mAttributes['userEvent'][$eventName] = true; + } + } + } + + /** + * Converts the version of the module from $modversion value to interger + * number. + * @param string $version + * @return int + */ + function convertVersionFromModinfoToInt($version) + { + return round(100 * floatval($version)); + } + + /** + * Converts the version of the module from DB value to float. + * @param int $version + * @return float + */ + function convertVersionIntToFloat($version) + { + return round(floatval(intval($version) / 100), 2); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/legacy/class/Legacy_Validator.class.php diff -u /dev/null xoops2jp/html/modules/legacy/class/Legacy_Validator.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/Legacy_Validator.class.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,31 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_ROOT_PATH . "/core/XCube_Validator.class.php"; + +class XCube_ObjectExistValidator extends XCube_Validator +{ + function isValid(&$form, $vars) + { + if ($form->isNull()) { + return true; + } + else { + $handleName = $vars['handler']; + $moduleName = isset($vars['module']) ? $vars['module'] : null; + + if ($moduleName == null) { + $handler =& xoops_gethandler($handleName); + } + else { + $handler =& xoops_getmodulehandler($handleName, $moduleName); + } + $obj =& $handler->get($form->getValue()); + + return is_object($obj); + } + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/legacy/class/Module.class.php diff -u /dev/null xoops2jp/html/modules/legacy/class/Module.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/Module.class.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,25 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class Legacy_Module extends Legacy_ModuleAdapter +{ + function Legacy_Module(&$xoopsModule) + { + parent::Legacy_ModuleAdapter($xoopsModule); + $this->mGetAdminMenu =& new XCube_Delegate(); + $this->mGetAdminMenu->register('Legacy_Module.getAdminMenu'); + } + + function getAdminMenu() + { + $menu = parent::getAdminMenu(); + $this->mGetAdminMenu->call(new XCube_Ref($menu)); + + ksort($menu); + + return $menu; + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/legacy/class/block_module_link.php diff -u /dev/null xoops2jp/html/modules/legacy/class/block_module_link.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/block_module_link.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,21 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyBlock_module_linkObject extends XoopsSimpleObject +{ + function LegacyBlock_module_linkObject() + { + $this->initVar('block_id', XOBJ_DTYPE_INT, '0', true); + $this->initVar('module_id', XOBJ_DTYPE_INT, '0', true); + } +} + +class LegacyBlock_module_linkHandler extends XoopsObjectGenericHandler +{ + var $mTable = "block_module_link"; + var $mPrimary = "block_id"; + var $mClass = "LegacyBlock_module_linkObject"; +} + +?> Index: xoops2jp/html/modules/legacy/class/blockctype.php diff -u /dev/null xoops2jp/html/modules/legacy/class/blockctype.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/blockctype.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,77 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyBlockctypeObject extends XoopsSimpleObject +{ + function LegacyBlockctypeObject() + { + $this->initVar('type', XOBJ_DTYPE_STRING, '', true); + $this->initVar('label', XOBJ_DTYPE_STRING, '', true, 255); + } +} + +class LegacyBlockctypeHandler extends XoopsObjectHandler +{ + var $_mResults = array(); + + function LegacyBlockctypeHandler(&$db) + { + $t_arr = array ( + 'H' => _AD_LEGACY_LANG_CTYPE_HTML, + 'P' => _AD_LEGACY_LANG_CTYPE_PHP, + 'S' => _AD_LEGACY_LANG_CTYPE_WITH_SMILIES, + 'T' => _AD_LEGACY_LANG_CTYPE_WITHOUT_SMILIES + ); + + foreach ($t_arr as $id => $name) { + $this->_mResults[$id] =& $this->create(); + $this->_mResults[$id]->setVar('type', $id); + $this->_mResults[$id]->setVar('label', $name); + } + } + + function &create() + { + $ret =& new LegacyBlockctypeObject(); + return $ret; + } + + function &get($id) + { + if (isset($this->_mResults[$id])) { + return $this->_mResults[$id]; + } + + $ret = null; + return $ret; + } + + function &getObjects($criteria = null, $id_as_key = false) + { + if ($id_as_key) { + return $this->_mResults; + } + else { + $ret = array(); + + foreach (array_keys($this->_mResults) as $key) { + $ret[] =& $this->_mResults[$key]; + } + + return $ret; + } + } + + function insert(&$obj) + { + return false; + } + + function delete(&$obj) + { + return false; + } +} + +?> Index: xoops2jp/html/modules/legacy/class/columnside.php diff -u /dev/null xoops2jp/html/modules/legacy/class/columnside.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/columnside.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,80 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_ROOT_PATH . '/include/comment_constants.php'; + +class LegacyColumnsideObject extends XoopsSimpleObject +{ + function LegacyColumnsideObject() + { + $this->initVar('id', XOBJ_DTYPE_INT, '', true); + $this->initVar('name', XOBJ_DTYPE_STRING, '', true, 255); + } +} + +class LegacyColumnsideHandler extends XoopsObjectHandler +{ + var $_mResults = array(); + + function LegacyColumnsideHandler(&$db) + { + $t_arr = array ( + 0 => _AD_LEGACY_LANG_SIDE_BLOCK_LEFT, + 1 => _AD_LEGACY_LANG_SIDE_BLOCK_RIGHT, + 3 => _AD_LEGACY_LANG_CENTER_BLOCK_LEFT, + 4 => _AD_LEGACY_LANG_CENTER_BLOCK_RIGHT, + 5 => _AD_LEGACY_LANG_CENTER_BLOCK_CENTER + ); + + foreach ($t_arr as $id => $name) { + $this->_mResults[$id] =& $this->create(); + $this->_mResults[$id]->setVar('id', $id); + $this->_mResults[$id]->setVar('name', $name); + } + } + + function &create() + { + $ret =& new LegacyColumnsideObject(); + return $ret; + } + + function &get($id) + { + if (isset($this->_mResults[$id])) { + return $this->_mResults[$id]; + } + + $ret = null; + return $ret; + } + + function &getObjects($criteria = null, $id_as_key = false) + { + if ($id_as_key) { + return $this->_mResults; + } + else { + $ret = array(); + + foreach (array_keys($this->_mResults) as $key) { + $ret[] =& $this->_mResults[$key]; + } + + return $ret; + } + } + + function insert(&$obj) + { + return false; + } + + function delete(&$obj) + { + return false; + } +} + +?> Index: xoops2jp/html/modules/legacy/class/comment.php diff -u /dev/null xoops2jp/html/modules/legacy/class/comment.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/comment.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,145 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyCommentObject extends XoopsSimpleObject +{ + var $mUser = null; + var $mModule = null; + var $mStatus = null; + + function LegacyCommentObject() + { + $this->initVar('com_id', XOBJ_DTYPE_INT, '', true); + $this->initVar('com_pid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('com_rootid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('com_modid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('com_itemid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('com_icon', XOBJ_DTYPE_STRING, '', true, 25); + $this->initVar('com_created', XOBJ_DTYPE_INT, '0', true); + $this->initVar('com_modified', XOBJ_DTYPE_INT, '0', true); + $this->initVar('com_uid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('com_ip', XOBJ_DTYPE_STRING, '', true, 15); + $this->initVar('com_title', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('com_text', XOBJ_DTYPE_TEXT, '', true); + $this->initVar('com_sig', XOBJ_DTYPE_BOOL, '0', true); + $this->initVar('com_status', XOBJ_DTYPE_INT, '1', true); + $this->initVar('com_exparams', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('dohtml', XOBJ_DTYPE_BOOL, '0', true); + $this->initVar('dosmiley', XOBJ_DTYPE_BOOL, '1', true); + $this->initVar('doxcode', XOBJ_DTYPE_BOOL, '1', true); + $this->initVar('doimage', XOBJ_DTYPE_BOOL, '1', true); + $this->initVar('dobr', XOBJ_DTYPE_BOOL, '1', true); + } + + /** + * Load a user object who wrote this comment to $mUser. + */ + function loadUser() + { + $handler =& xoops_gethandler('member'); + $this->mUser =& $handler->getUser($this->get('com_uid')); + } + + /** + * Load a module object to $mModule. + */ + function loadModule() + { + $handler =& xoops_gethandler('module'); + $this->mModule =& $handler->get($this->get('com_modid')); + } + + function loadStatus() + { + $handler =& xoops_getmodulehandler('commentstatus', 'legacy'); + $this->mStatus =& $handler->get($this->get('com_status')); + } + + function getVar($key) + { + if ($key == 'com_text') { + $ts =& MyTextSanitizer::getInstance(); + return $ts->displayTarea($this->get($key), $this->get('dohtml'), $this->get('dosmiley'), $this->get('doxcode'), $this->get('doimage'), $this->get('dobr')); + } + else { + return parent::getVar($key); + } + } +} + +class LegacyCommentHandler extends XoopsObjectGenericHandler +{ + var $mTable = "xoopscomments"; + var $mPrimary = "com_id"; + var $mClass = "LegacyCommentObject"; + + /** + * @var XCube_Delegate + */ + var $mUpdateSuccess; + + /** + * @var XCube_Delegate + */ + var $mDeleteSuccess; + + function LegacyCommentHandler(&$db) + { + parent::XoopsObjectGenericHandler($db); + + $this->mUpdateSuccess =& new XCube_Delegate(); + $this->mDeleteSuccess =& new XCube_Delegate(); + } + + function insert(&$comment, $force = false) + { + if (parent::insert($comment, $force)) { + $this->mUpdateSuccess->call($comment); + return true; + } + else { + return false; + } + } + + /** + * Delete $comment and childlen of $comment. + */ + function delete(&$comment, $force = false) + { + $criteria =& new Criteria('com_pid', $comment->get('com_id')); + $this->deleteAll($criteria); + + if (parent::delete($comment, $force)) { + $this->mDeleteSuccess->call($comment); + return true; + } + else{ + return false; + } + } + + /** + * + * Return array of module id that comments are written. + * + * @return array + */ + function getModuleIds() + { + $ret = array(); + + $sql = "SELECT DISTINCT com_modid FROM " . $this->mTable; + $res = $this->db->query($sql); + if ($res) { + while ($row = $this->db->fetchArray($res)) { + $ret[] = $row['com_modid']; + } + } + + return $ret; + } +} + +?> Index: xoops2jp/html/modules/legacy/class/commentstatus.php diff -u /dev/null xoops2jp/html/modules/legacy/class/commentstatus.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/commentstatus.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,82 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_ROOT_PATH . '/include/comment_constants.php'; + +class LegacyCommentstatusObject extends XoopsSimpleObject +{ + function LegacyCommentstatusObject() + { + $this->initVar('id', XOBJ_DTYPE_INT, '', true); + $this->initVar('name', XOBJ_DTYPE_STRING, '', true, 255); + } +} + +class LegacyCommentstatusHandler extends XoopsObjectHandler +{ + var $_mResults = array(); + + function LegacyCommentstatusHandler(&$db) + { + $root =& XCube_Root::getSingleton(); + $language = $root->mContext->getXoopsConfig('language'); + $root->mLanguageManager->loadPageTypeMessageCatalog('comment'); + + $this->_mResults[XOOPS_COMMENT_PENDING] =& $this->create(); + $this->_mResults[XOOPS_COMMENT_PENDING]->setVar('id', XOOPS_COMMENT_PENDING); + $this->_mResults[XOOPS_COMMENT_PENDING]->setVar('name', _CM_PENDING); + + $this->_mResults[XOOPS_COMMENT_ACTIVE] =& $this->create(); + $this->_mResults[XOOPS_COMMENT_ACTIVE]->setVar('id', XOOPS_COMMENT_ACTIVE); + $this->_mResults[XOOPS_COMMENT_ACTIVE]->setVar('name', _CM_ACTIVE); + + $this->_mResults[XOOPS_COMMENT_HIDDEN] =& $this->create(); + $this->_mResults[XOOPS_COMMENT_HIDDEN]->setVar('id', XOOPS_COMMENT_HIDDEN); + $this->_mResults[XOOPS_COMMENT_HIDDEN]->setVar('name', _CM_HIDDEN); + } + + function &create() + { + $ret =& new LegacyCommentstatusObject(); + return $ret; + } + + function &get($id) + { + if (isset($this->_mResults[$id])) { + return $this->_mResults[$id]; + } + + $ret = null; + return $ret; + } + + function &getObjects($criteria = null, $id_as_key = false) + { + if ($id_as_key) { + return $this->_mResults; + } + else { + $ret = array(); + + foreach (array_keys($this->_mResults) as $key) { + $ret[] =& $this->_mResults[$key]; + } + + return $ret; + } + } + + function insert(&$obj) + { + return false; + } + + function delete(&$obj) + { + return false; + } +} + +?> Index: xoops2jp/html/modules/legacy/class/group_permission.php diff -u /dev/null xoops2jp/html/modules/legacy/class/group_permission.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/group_permission.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,56 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyGroup_permissionObject extends XoopsSimpleObject +{ + function LegacyGroup_permissionObject() + { + $this->initVar('gperm_id', XOBJ_DTYPE_INT, '', true); + $this->initVar('gperm_groupid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('gperm_itemid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('gperm_modid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('gperm_name', XOBJ_DTYPE_STRING, '', true, 50); + } +} + +class LegacyGroup_permissionHandler extends XoopsObjectGenericHandler +{ + var $mTable = "group_permission"; + var $mPrimary = "gperm_id"; + var $mClass = "LegacyGroup_permissionObject"; + + /** + * Gets array of roles by array of group ID. + * @param int $mid + * @param array $groups + * @return array + */ + function getRolesByModule($mid, $groups) + { + $retRoles = array(); + + $sql = "SELECT gperm_name FROM " . $this->mTable . " WHERE gperm_modid=" . intval($mid) . " AND gperm_itemid=0 AND "; + $groupSql = array(); + + foreach ($groups as $gid) { + $groupSql[] = "gperm_groupid=" . intval($gid); + } + + $sql .= "(" . implode(' OR ', $groupSql) . ")"; + + $result = $this->db->query($sql); + + if (!$result) { + return $retRoles; + } + + while ($row = $this->db->fetchArray($result)) { + $retRoles[] = $row['gperm_name']; + } + + return $retRoles; + } +} + +?> Index: xoops2jp/html/modules/legacy/class/image.php diff -u /dev/null xoops2jp/html/modules/legacy/class/image.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/image.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,102 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyImageObject extends XoopsSimpleObject +{ + var $mImageCategory = null; + var $_mImageCategoryLoadedFlag = false; + var $mImageBody = null; + var $_mImageBodyLoadedFlag = false; + + function LegacyImageObject() + { + $this->initVar('image_id', XOBJ_DTYPE_INT, '', false); + $this->initVar('image_name', XOBJ_DTYPE_STRING, '', true, 30); + $this->initVar('image_nicename', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('image_mimetype', XOBJ_DTYPE_STRING, '', true, 30); + $this->initVar('image_created', XOBJ_DTYPE_INT, time(), true); + $this->initVar('image_display', XOBJ_DTYPE_BOOL, '1', true); + $this->initVar('image_weight', XOBJ_DTYPE_INT, '0', true); + $this->initVar('imgcat_id', XOBJ_DTYPE_INT, '0', true); + } + + function loadImagecategory() + { + if ($this->_mImageCategoryLoadedFlag == false) { + $handler =& xoops_getmodulehandler('imagecategory', 'legacy'); + $this->mImageCategory =& $handler->get($this->get('imgcat_id')); + $this->_mImageCategoryLoadedFlag = true; + } + } + + function loadImagebody() + { + if ($this->_mImageBodyLoadedFlag == false) { + $handler =& xoops_getmodulehandler('imagebody', 'legacy'); + $this->mImageBody =& $handler->get($this->get('image_id')); + $this->_mImageBodyLoadedFlag = true; + } + } + + function &createImagebody() + { + $handler =& xoops_getmodulehandler('imagebody', 'legacy'); + $obj =& $handler->create(); + $obj->set('image_id', $this->get('image_id')); + return $obj; + } +} + +class LegacyImageHandler extends XoopsObjectGenericHandler +{ + var $mTable = "image"; + var $mPrimary = "image_id"; + var $mClass = "LegacyImageObject"; + + function insert(&$obj, $force = false) + { + if (parent::insert($obj, $force)) { + if (is_object($obj->mImageBody)) { + $obj->mImageBody->set('image_id', $obj->get('image_id')); + $handler =& xoops_getmodulehandler('imagebody', 'legacy'); + return $handler->insert($obj->mImageBody, $force); + } + + return true; + } + + return false; + } + + /** + * + * Delete object and image file. + * + * @param $obj LegacyImageObject + * @param $force boolean + * @return boolean + */ + function delete(&$obj, $force = false) + { + $obj->loadImagebody(); + + if (parent::delete($obj, $force)) { + $filepath = XOOPS_UPLOAD_PATH . "/" . $obj->get('image_name'); + if (file_exists($filepath)) { + @unlink($filepath); + } + + if (is_object($obj->mImageBody)) { + $handler =& xoops_getmodulehandler('imagebody', 'legacy'); + $handler->delete($obj->mImageBody, $force); + } + + return true; + } + + return false; + } +} + +?> Index: xoops2jp/html/modules/legacy/class/imagebody.php diff -u /dev/null xoops2jp/html/modules/legacy/class/imagebody.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/imagebody.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,21 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyImagebodyObject extends XoopsSimpleObject +{ + function LegacyImagebodyObject() + { + $this->initVar('image_id', XOBJ_DTYPE_INT, '', false); + $this->initVar('image_body', XOBJ_DTYPE_TEXT, '', true); + } +} + +class LegacyImagebodyHandler extends XoopsObjectGenericHandler +{ + var $mTable = "imagebody"; + var $mPrimary = "image_id"; + var $mClass = "LegacyImagebodyObject"; +} + +?> Index: xoops2jp/html/modules/legacy/class/imagecategory.php diff -u /dev/null xoops2jp/html/modules/legacy/class/imagecategory.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/imagecategory.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,247 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyImagecategoryObject extends XoopsSimpleObject +{ + var $mImage = array(); + var $_mImageLoadedFlag = false; + + /** + * Array of group objects which are allowed to read files of this category. + */ + var $mReadGroups = array(); + var $_mReadGroupsLoadedFlag = false; + + /** + * Array of group objects which are allowed to upload a file to this category. + */ + var $mUploadGroups = array(); + var $_mUploadGroupsLoadedFlag = false; + + + function LegacyImagecategoryObject() + { + $this->initVar('imgcat_id', XOBJ_DTYPE_INT, '', false); + $this->initVar('imgcat_name', XOBJ_DTYPE_STRING, '', true, 100); + $this->initVar('imgcat_maxsize', XOBJ_DTYPE_INT, '50000', true); + $this->initVar('imgcat_maxwidth', XOBJ_DTYPE_INT, '120', true); + $this->initVar('imgcat_maxheight', XOBJ_DTYPE_INT, '120', true); + $this->initVar('imgcat_display', XOBJ_DTYPE_BOOL, '1', true); + $this->initVar('imgcat_weight', XOBJ_DTYPE_INT, '0', true); + $this->initVar('imgcat_type', XOBJ_DTYPE_STRING, 'C', true, 1); + $this->initVar('imgcat_storetype', XOBJ_DTYPE_STRING, 'file', true, 5); + } + + function loadImage() + { + if ($this->_mImageLoadedFlag == false) { + $handler =& xoops_getmodulehandler('image', 'legacy'); + $this->mImage =& $handler->getObjects(new Criteria('imagecat_id', $this->get('imagecat_id'))); + $this->_mImageLoadedFlag = true; + } + } + + function &createImage() + { + $handler =& xoops_getmodulehandler('image', 'legacy'); + $obj =& $handler->create(); + $obj->set('imagecat_id', $this->get('imagecat_id')); + return $obj; + } + + function getImageCount() + { + $handler =& xoops_getmodulehandler('image', 'legacy'); + return $handler->getCount(new Criteria('imgcat_id', $this->get('imgcat_id'))); + } + + function loadReadGroups() + { + if ($this->_mReadGroupsLoadedFlag) { + return; + } + + $handler =& xoops_gethandler('groupperm'); + $gidArr = $handler->getGroupIds('imgcat_read', $this->get('imgcat_id')); + + $handler =& xoops_gethandler('group'); + foreach ($gidArr as $gid) { + $object =& $handler->get($gid); + + if (is_object($object)) { + $this->mReadGroups[] =& $object; + } + + unset($object); + } + + $this->_mReadGroupsLoadedFlag = true; + } + + function isLoadedReadGroups() + { + return $this->_mReadGroupsLoadedFlag; + } + + /** + * If $groups has the permission of reading this object, return true. + */ + function hasReadPerm($groups) + { + $this->loadReadGroups(); + foreach (array_keys($this->mReadGroups) as $key) { + foreach ($groups as $group) { + if ($this->mReadGroups[$key]->get('groupid') == $group) { + return true; + } + } + } + + return false; + } + + function loadUploadGroups() + { + if ($this->_mUploadGroupsLoadedFlag) { + return; + } + + $handler =& xoops_gethandler('groupperm'); + $gidArr = $handler->getGroupIds('imgcat_write', $this->get('imgcat_id')); + + $handler =& xoops_gethandler('group'); + foreach ($gidArr as $gid) { + $object =& $handler->get($gid); + + if (is_object($object)) { + $this->mUploadGroups[] =& $object; + } + + unset($object); + } + + $this->_mUploadGroupsLoadedFlag = true; + } + + function isLoadedUploadGroups() + { + return $this->_mUploadGroupsLoadedFlag; + } + + function hasUploadPerm($groups) + { + $this->loadUploadGroups(); + foreach (array_keys($this->mUploadGroups) as $key) { + foreach ($groups as $group) { + if ($this->mUploadGroups[$key]->get('groupid') == $group) { + return true; + } + } + } + + return false; + } +} + +class LegacyImagecategoryHandler extends XoopsObjectGenericHandler +{ + var $mTable = "imagecategory"; + var $mPrimary = "imgcat_id"; + var $mClass = "LegacyImagecategoryObject"; + + function insert(&$obj, $force = false) + { + $returnFlag = parent::insert($obj, $force); + + $handler =& xoops_getmodulehandler('group_permission', 'legacy'); + + // + // If the object has groups which are allowed to read. + // + if ($obj->isLoadedReadGroups()) { + $criteria =& new CriteriaCompo(); + $criteria->add(new Criteria('gperm_itemid', $obj->get('imgcat_id'))); + $criteria->add(new Criteria('gperm_modid', 1)); + $criteria->add(new Criteria('gperm_name', 'imgcat_read')); + $handler->deleteAll($criteria); + + foreach ($obj->mReadGroups as $group) { + $perm =& $handler->create(); + $perm->set('gperm_groupid', $group->get('groupid')); + $perm->set('gperm_itemid', $obj->get('imgcat_id')); + $perm->set('gperm_modid', 1); + $perm->set('gperm_name', 'imgcat_read'); + + $returnFlag &= $handler->insert($perm, $force); + } + } + + // + // If the object has groups which are allowed to upload. + // + if ($obj->isLoadedUploadGroups()) { + $criteria =& new CriteriaCompo(); + $criteria->add(new Criteria('gperm_itemid', $obj->get('imgcat_id'))); + $criteria->add(new Criteria('gperm_modid', 1)); + $criteria->add(new Criteria('gperm_name', 'imgcat_write')); + $handler->deleteAll($criteria); + + foreach ($obj->mUploadGroups as $group) { + $perm =& $handler->create(); + $perm->set('gperm_groupid', $group->get('groupid')); + $perm->set('gperm_itemid', $obj->get('imgcat_id')); + $perm->set('gperm_modid', 1); + $perm->set('gperm_name', 'imgcat_write'); + + $returnFlag &= $handler->insert($perm, $force); + } + } + + return $returnFlag; + } + + function &getObjectsWithReadPerm($groups = array(), $display = null) + { + $criteria = new CriteriaCompo(); + if ($display != null) { + $criteria->add(new Criteria('imgcat_display', $display)); + } + $criteria->setSort('imgcat_weight'); + $objs =& $this->getObjects($criteria); + unset($criteria); + + $ret = array(); + foreach (array_keys($objs) as $key) { + if ($objs[$key]->hasReadPerm($groups)) { + $ret[] =& $objs[$key]; + } + } + + return $ret; + } + + function delete(&$obj, $force = false) + { + $handler =& xoops_getmodulehandler('image', 'legacy'); + $handler->deleteAll(new Criteria('imgcat_id', $obj->get('imgcat_id'))); + unset($handler); + + $handler =& xoops_gethandler('group_permission', 'legacy'); + $criteria =& new CriteriaCompo(); + $criteria->add(new Criteria('gperm_itemid', $obj->get('imgcat_id'))); + $criteria->add(new Criteria('gperm_modid', 1)); + + $nameCriteria =& new CriteriaCompo(); + $nameCriteria->add(new Criteria('gperm_name', 'imgcat_read')); + $nameCriteria->add(new Criteria('gperm_name', 'imgcat_write'), 'OR'); + + $criteria->add($nameCriteria); + + $handler->deleteAll($criteria); + + return parent::delete($obj, $force); + } +} + +?> Index: xoops2jp/html/modules/legacy/class/index.html diff -u /dev/null xoops2jp/html/modules/legacy/class/index.html:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/index.html Mon Apr 30 16:31:41 2007 @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file Index: xoops2jp/html/modules/legacy/class/newblocks.php diff -u /dev/null xoops2jp/html/modules/legacy/class/newblocks.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/newblocks.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,128 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacyNewblocksObject extends XoopsSimpleObject +{ + var $mModule = null; + + /** + * Array of group objects who can access this object. + * It need lazy loading to access. + */ + var $mGroup = array(); + + var $mBmodule = array(); + + var $mColumn = null; + + var $mCachetime = null; + + function LegacyNewblocksObject() + { + $this->initVar('bid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('mid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('func_num', XOBJ_DTYPE_INT, '0', true); + $this->initVar('options', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('name', XOBJ_DTYPE_STRING, '', true, 150); + $this->initVar('title', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('content', XOBJ_DTYPE_TEXT, '', true); + $this->initVar('side', XOBJ_DTYPE_INT, '0', true); + $this->initVar('weight', XOBJ_DTYPE_INT, '0', true); + $this->initVar('visible', XOBJ_DTYPE_BOOL, '0', true); + $this->initVar('block_type', XOBJ_DTYPE_STRING, '', true, 1); + $this->initVar('c_type', XOBJ_DTYPE_STRING, '', true, 1); + $this->initVar('isactive', XOBJ_DTYPE_BOOL, '0', true); + $this->initVar('dirname', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('func_file', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('show_func', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('edit_func', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('template', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('bcachetime', XOBJ_DTYPE_INT, '0', true); + $this->initVar('last_modified', XOBJ_DTYPE_INT, time(), true); + } + + function loadModule() + { + $handler =& xoops_gethandler('module'); + $this->mModule =& $handler->get($this->get('mid')); + } + + /** + * Load group objects who can access this object. And, set the objects to mGroup. + * + * TODO Need lock double loading. + */ + function loadGroup() + { + $handler =& xoops_gethandler('groupperm'); + $criteria =& new CriteriaCompo(); + $criteria->add(new Criteria('gperm_modid', 1)); + $criteria->add(new Criteria('gperm_itemid', $this->get('bid'))); + $criteria->add(new Criteria('gperm_name', 'block_read')); + + $gpermArr =& $handler->getObjects($criteria); + + $handler =& xoops_gethandler('group'); + foreach ($gpermArr as $gperm) { + $this->mGroup[] =& $handler->get($gperm->get('gperm_groupid')); + } + } + + function loadBmodule() + { + $handler =& xoops_getmodulehandler('block_module_link', 'legacy'); + $criteria =& new Criteria('block_id', $this->get('bid')); + + $this->mBmodule =& $handler->getObjects($criteria); + } + + function loadColumn() + { + $handler =& xoops_getmodulehandler('columnside', 'legacy'); + $this->mColumn =& $handler->get($this->get('side')); + } + + function loadCachetime() + { + $handler =& xoops_gethandler('cachetime'); + $this->mCachetime =& $handler->get($this->get('bcachetime')); + } +} + +class LegacyNewblocksHandler extends XoopsObjectGenericHandler +{ + var $mTable = "newblocks"; + var $mPrimary = "bid"; + var $mClass = "LegacyNewblocksObject"; + + function delete(&$obj, $force = false) + { + if (parent::delete($obj, $force)) { + // + // Delete related data from block_module_link. + // + $handler =& xoops_getmodulehandler('block_module_link', 'legacy'); + $handler->deleteAll(new Criteria('block_id'), $obj->get('bid')); + + // + // Delete related permissions from groupperm. + // + $handler =& xoops_gethandler('groupperm'); + + $criteria =& new CriteriaCompo(); + $criteria->add(new Criteria('gperm_modid', 1)); + $criteria->add(new Criteria('gperm_itemid', $obj->get('bid'))); + $criteria->add(new Criteria('gperm_name', 'block_read')); + + $handler->deleteAll($criteria); + + return true; + } + else { + return false; + } + } +} + +?> Index: xoops2jp/html/modules/legacy/class/non_installation_module.php diff -u /dev/null xoops2jp/html/modules/legacy/class/non_installation_module.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/non_installation_module.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,95 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +/** + * This handler handles XoopsModule objects without DB. So it doesn't implement + * some methods for difficult query. Only override methods are usable. + */ +class LegacyNon_installation_moduleHandler extends XoopsObjectHandler +{ + /** + * object cache. + * + * @var Array + */ + var $_mXoopsModules = array(); + + /** + * readonly property + */ + var $_mExclusions = array(".", "..", "CVS"); + + function LegacyNon_installation_moduleHandler(&$db) + { + parent::XoopsObjectHandler($db); + $this->_setupObjects(); + } + + /** + * Once, load module objects to a member property from XOOPS_MODULE_PATH. + */ + function _setupObjects() + { + if (count($this->_mXoopsModules) == 0) { + if ($handler = opendir(XOOPS_MODULE_PATH)) { + while (($dir = readdir($handler)) !== false) { + if (!in_array($dir, $this->_mExclusions) && is_dir(XOOPS_MODULE_PATH . "/" . $dir)) { + $module =& $this->get($dir); + if ($module !== false ) { + $this->_mXoopsModules[] =& $module; + } + unset($module); + } + } + } + } + } + + /** + * Return module object by $dirname that is specified module directory. + * If specified module has been installed or doesn't keep xoops_version, not return it. + * @param $dirname string + * @param XoopsModule or false + */ + function &get($dirname) + { + $ret = false; + + if (!file_exists(XOOPS_MODULE_PATH . "/" . $dirname . "/xoops_version.php")) { + return $ret; + } + + $moduleHandler =& xoops_gethandler('module'); + + $check =& $moduleHandler->getByDirname($dirname); + if (is_object($check)) { + return $ret; + } + + $module =& $moduleHandler->create(); + $module->loadInfoAsVar($dirname); + + return $module; + } + + function &getObjects($criteria=null) + { + return $this->_mXoopsModules; + } + + function &getObjectsFor2ndInstaller() + { + $ret = array(); + + foreach (array_keys($this->_mXoopsModules) as $key) { + if (empty($this->_mXoopsModules[$key]->modinfo['disable_legacy_2nd_installer'])) { + $ret[] =& $this->_mXoopsModules[$key]; + } + } + + return $ret; + } +} + +?> Index: xoops2jp/html/modules/legacy/class/smiles.php diff -u /dev/null xoops2jp/html/modules/legacy/class/smiles.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/smiles.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,31 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class LegacySmilesObject extends XoopsSimpleObject +{ + function LegacySmilesObject() + { + $this->initVar('id', XOBJ_DTYPE_INT, '', true); + $this->initVar('code', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('smile_url', XOBJ_DTYPE_STRING, '', true, 100); + $this->initVar('emotion', XOBJ_DTYPE_STRING, '', true, 75); + $this->initVar('display', XOBJ_DTYPE_BOOL, '0', true); + } +} + +class LegacySmilesHandler extends XoopsObjectGenericHandler +{ + var $mTable = "smiles"; + var $mPrimary = "id"; + var $mClass = "LegacySmilesObject"; + + function delete(&$obj) + { + @unlink(XOOPS_UPLOAD_PATH . "/" . $obj->get('smile_url')); + + return parent::delete($obj); + } +} + +?> Index: xoops2jp/html/modules/legacy/class/theme.php diff -u /dev/null xoops2jp/html/modules/legacy/class/theme.php:1.1.4.1 --- /dev/null Mon Apr 30 16:31:41 2007 +++ xoops2jp/html/modules/legacy/class/theme.php Mon Apr 30 16:31:41 2007 @@ -0,0 +1,103 @@ +<?php + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_ROOT_PATH . '/include/comment_constants.php'; + +class LegacyThemeObject extends XoopsSimpleObject +{ + function LegacyThemeObject() + { + $this->initVar('name', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('dirname', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('screenshot', XOBJ_DTYPE_STRING, '', false, 255); + $this->initVar('description', XOBJ_DTYPE_STRING, '', false, 255); + $this->initVar('format', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('render_system', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('version', XOBJ_DTYPE_STRING, '', true, 32); + $this->initVar('author', XOBJ_DTYPE_STRING, '', true, 64); + $this->initVar('url', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('licence', XOBJ_DTYPE_STRING, '', true, 255); + } +} + +class LegacyThemeHandler extends XoopsObjectHandler +{ + var $_mResults = array(); + + /** + * @var XCube_Delegate + */ + var $mGetInstalledThemes = null; + + function LegacyThemeHandler(&$db) + { + $this->mGetInstalledThemes =& new XCube_Delegate(); + $this->mGetInstalledThemes->register('LegacyThemeHandler.GetInstalledThemes'); + } + + function &create() + { + $ret =& new LegacyThemeObject(); + return $ret; + } + + function &get($name) + { + $ret = null; + $this->_makeCache(); + + foreach (array_keys($this->_mResults) as $key) { + if ($this->_mResults[$key]->get('dirname') == $name) { + return $this->_mResults[$key]; + } + } + + return $ret; + } + + function &getObjects($criteria = null, $id_as_key = false) + { + $this->_makeCache(); + return $this->_mResults; + } + + /** + * Create cache at $this->mResult by Delegate, if cache is empty. + */ + function _makeCache() + { + if (count($this->_mResults) == 0) { + $t_themeArr = array(); + $this->mGetInstalledThemes->call(new XCube_Ref($t_themeArr)); + + foreach ($t_themeArr as $theme) { + $obj =& $this->create(); + $obj->set('name', $theme->mName); + $obj->set('dirname', $theme->mDirname); + $obj->set('screenshot', $theme->mScreenShot); + $obj->set('description', $theme->mDescription); + $obj->set('format', $theme->mFormat); + $obj->set('render_system', $theme->mRenderSystemName); + $obj->set('version', $theme->mVersion); + $obj->set('author', $theme->mAuthor); + $obj->set('url', $theme->mUrl); + $obj->set('licence', $theme->mLicence); + $this->_mResults[] =& $obj; + unset($obj); + } + } + } + + function insert(&$obj, $force = false) + { + return false; + } + + function delete(&$obj, $force = false) + { + return false; + } +} + +?>