NobuNobu
nobun****@users*****
2007年 4月 30日 (月) 16:38:01 JST
Index: xoops2jp/html/modules/user/actions/AvatarEditAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/AvatarEditAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/AvatarEditAction.class.php Mon Apr 30 16:38:00 2007 @@ -0,0 +1,270 @@ +<?php +/** + * @package user + * @version $Id: AvatarEditAction.class.php,v 1.1.4.1 2007/04/30 07:38:00 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_ROOT_PATH . "/core/XCube_PageNavigator.class.php"; + +require_once XOOPS_MODULE_PATH . "/user/class/AbstractEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/user/forms/AvatarEditForm.class.php"; +require_once XOOPS_MODULE_PATH . "/user/forms/AvatarSelectForm.class.php"; +require_once XOOPS_MODULE_PATH . "/user/forms/AvatarFilterForm.class.php"; + +/** + * This action handles the uploaded avatar image file. + * + * Users who are allowed to upload, can upload custom avatars and select system + * avatars. So this action has to implement both of uploading and selecting. + * In the case of GET request, this action shows two forms to changing a avatar + * for specified user. One of form shows upload-form. Anther form shows the list + * of system avatars and the page navigator of the list. + * + * @see User_AvatarEditForm + * @see User_AvatarSelectForm + */ +class User_AvatarEditAction extends User_AbstractEditAction +{ + /** + * @var int + */ + var $mAvatarWidth = 0; + + /** + * @var int + */ + var $mAvatarHeight = 0; + + /** + * @var int + */ + var $mAvatarMaxfilesize = 0; + + /** + * @var int + */ + var $_mMinPost = 0; + + /** + * @var bool + */ + var $_mAllowUpload = false; + + /** + * @var User_AvatarFilterForm + */ + var $mFilter; + + /** + * Preset avatar object collection. + */ + var $mSystemAvatars = array(); + + /** + * Other action form for AvatarSelect. + * @var User_AvatarSelectForm + */ + var $mAvatarSelectForm = null; + + /** + * Fetch conditions from $moduleConfig and set these to member properties. + * And, by the member property mConfig of the base class, any member + * functions of this class can access $moduleConfig. + * + * @todo The limit may be not completed, yet. + */ + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + $this->mAvatarWidth = $moduleConfig['avatar_width']; + $this->mAvatarHeight = $moduleConfig['avatar_height']; + $this->mAvatarMaxfilesize = $moduleConfig['avatar_maxsize']; + + $this->_mMinPost = $moduleConfig['avatar_minposts']; + $this->_mAllowUpload = $moduleConfig['avatar_allow_upload']; + + parent::prepare($controller, $xoopsUser, $moduleConfig); + } + + function _getId() + { + return isset($_REQUEST['uid']) ? intval(xoops_getrequest('uid')) : 0; + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('users', 'user'); + return $handler; + } + + /** + * This class uses AvatarUploadForm class. It requests three condition + * which are width limit, height limit and filesize limit. + * + * @todo We may have to hand three parameters to constructor. + */ + function _setupActionForm() + { + $this->mActionForm =& new User_AvatarEditForm(); + $this->mActionForm->prepare($this->mAvatarWidth, $this->mAvatarHeight, $this->mAvatarMaxfilesize); + } + + function isEnableCreate() + { + return false; + } + + /** + * Return true. This action should not be used by a guest user. + */ + function isSecure() + { + return true; + } + + /** + * Check whether a current user can access this action. + * 1) A specified user has to exist. + * 2) A current user has to equal the specified user, or a current user has + * to be a administrator. + */ + function hasPermission(&$controller, &$xoopsUser, $moduleConfig) + { + if (!is_object($this->mObject)) { + return false; + } + + if ($controller->mRoot->mContext->mUser->isInRole('Module.user.Admin')) { + return true; + } + elseif ($this->mObject->get('uid') == $xoopsUser->get('uid')) { + return ($this->mObject->get('posts') >= $this->_mMinPost); + } + + return false; + } + + /** + * This override method looks like the same method of ListAction, and tries + * to get system avatars. After, it will call base class. + */ + function getDefaultView(&$controller, &$xoopsUser) + { + $navi =& new XCube_PageNavigator(XOOPS_URL . "/edituser.php?op=avatarform&uid=" . $xoopsUser->get('uid'), XCUBE_PAGENAVI_START); + $handler =& xoops_getmodulehandler('avatar', 'user'); + + $this->mSystemAvatars[] =& $handler->createNoavatar(); + + $this->mFilter =& new User_AvatarFilterForm($navi, $handler); + $this->mFilter->fetch(); + + $criteria = $this->mFilter->getCriteria(); + $t_avatarArr =& $handler->getObjects($criteria); + foreach (array_keys($t_avatarArr) as $key) { + $this->mSystemAvatars[] =& $t_avatarArr[$key]; + } + + $this->mAvatarSelectForm =& new User_AvatarSelectForm(); + $this->mAvatarSelectForm->prepare(); + + $this->mAvatarSelectForm->load($this->mObject); + + return parent::getDefaultView($controller, $xoopsUser); + } + + function execute(&$controller, &$xoopsUser) + { + if ($this->mObject == null) { + return USER_FRAME_VIEW_ERROR; + } + + $this->mActionForm->load($this->mObject); + + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + + if($this->mActionForm->hasError()) { + return $this->getDefaultView($controller, $xoopsUser); + } + + $this->mActionForm->update($this->mObject); + + return $this->_doExecute($this->mObject) ? USER_FRAME_VIEW_SUCCESS + : USER_FRAME_VIEW_ERROR; + } + + /** + * 1) Save avatar file which has been uploaded. + * 2) If old avatar file exists, remove it. + * 3) Insert a data to DB with calling base class method. + */ + function _doExecute() + { + if ($this->mActionForm->mFormFile != null) { + if (!$this->mActionForm->mFormFile->saveAs(XOOPS_UPLOAD_PATH)) { + return false; + } + } + + if ($this->mActionForm->mOldAvatarFilename != null && $this->mActionForm->mOldAvatarFilename != "blank.gif") { + $avatarHandler =& xoops_getmodulehandler('avatar', 'user'); + $criteria =& new Criteria('avatar_file', $this->mActionForm->mOldAvatarFilename); + $avatarArr =& $avatarHandler->getObjects($criteria); + if (count($avatarArr) > 0 && is_object($avatarArr[0]) && $avatarArr[0]->get('avatar_type') == 'C') { + $avatarHandler->delete($avatarArr[0]); + } + } + + if (parent::_doExecute()) { + $avatar =& $this->mActionForm->createAvatar(); + if ($avatar != null) { + $avatar->set('avatar_name', $this->mObject->get('uname')); + $avatarHandler =& xoops_getmodulehandler('avatar', 'user'); + $avatarHandler->insert($avatar); + + $linkHandler =& xoops_getmodulehandler('avatar_user_link', 'user'); + $linkHandler->deleteAllByUser($this->mObject); + + $link =& $linkHandler->create(); + $link->set('user_id', $this->mObject->get('uid')); + $link->set('avatar_id', $avatar->get('avatar_id')); + + $linkHandler->insert($link); + } + + return true; + } + else { + return false; + } + } + + function executeViewInput(&$controller,&$xoopsUser,&$render) + { + $render->setTemplateName("user_avatar_edit.html"); + $render->setAttribute("actionForm", $this->mActionForm); + $render->setAttribute("thisUser", $this->mObject); + + $render->setAttribute("allowUpload", $this->_mAllowUpload); + $render->setAttribute("avatarWidth", $this->mAvatarWidth); + $render->setAttribute("avatarHeight", $this->mAvatarHeight); + $render->setAttribute("avatarMaxfilesize", $this->mAvatarMaxfilesize); + + $render->setAttribute("pageNavi", $this->mFilter->mNavi); + $render->setAttribute("systemAvatars", $this->mSystemAvatars); + $render->setAttribute("avatarSelectForm", $this->mAvatarSelectForm); + } + + function executeViewSuccess(&$controller, &$xoopsUser, $render) + { + $controller->executeForward(XOOPS_URL . "/userinfo.php?uid=" . $this->mActionForm->get('uid')); + } + + function executeViewError(&$controller,&$xoopsUser,&$render) + { + $controller->executeRedirect(XOOPS_URL . "/userinfo.php?uid=" . $this->mActionForm->get('uid'), 1, _MD_ERROR_DBUPDATE_FAILED); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/user/actions/AvatarSelectAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/AvatarSelectAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/AvatarSelectAction.class.php Mon Apr 30 16:38:00 2007 @@ -0,0 +1,144 @@ +<?php +/** + * @package user + * @version $Id: AvatarSelectAction.class.php,v 1.1.4.1 2007/04/30 07:38:00 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/user/class/AbstractEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/user/forms/AvatarSelectForm.class.php"; + +/** + * When the request is POST, this class fetches avatar_id and set it to user + * object. This class always kicks out GET request. + * + * @see User_AvatarSelectForm + */ +class User_AvatarSelectAction extends User_AbstractEditAction +{ + var $mOldAvatar = null; + + function prepare(&$controller, &$xoopsUser, &$moduleConfig) + { + parent::prepare($controller, $xoopsUser, $moduleConfig); + + $handler =& xoops_getmodulehandler('avatar', 'user'); + $criteria =& new Criteria('avatar_file', $xoopsUser->get('user_avatar')); + $avatarArr =& $handler->getObjects($criteria); + if (count($avatarArr) > 0) { + $this->mOldAvatar =& $avatarArr[0]; + } + } + + function _getId() + { + return isset($_REQUEST['uid']) ? intval(xoops_getrequest('uid')) : 0; + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('users', 'user'); + return $handler; + } + + function _setupActionForm() + { + $this->mActionForm =& new User_AvatarSelectForm(); + $this->mActionForm->prepare(); + } + + /** + * Return false. + * If a user requests dummy uid, kick out him! + */ + function isEnableCreate() + { + return false; + } + + /** + * Return true. + * This action should not be used by a guest user. + */ + function isSecure() + { + return true; + } + + /** + * Check whether a current user can access this action. + * 1) A specified user has to exist. + * 2) A current user has to equal the specified user, or a current user has + * to be a administrator. + */ + function hasPermission(&$controller, &$xoopsUser, $moduleConfig) + { + if (!is_object($this->mObject)) { + return false; + } + + if ($controller->mRoot->mContext->mUser->isInRole('Module.user.Admin')) { + return true; + } + elseif ($this->mObject->get('uid') == $xoopsUser->get('uid')) { + return ($this->mObject->get('posts') >= $this->_mMinPost); + } + + return false; + } + + function _doExecute() + { + if ($this->mObjectHandler->insert($this->mObject)) { + $avatarHandler =& xoops_getmodulehandler('avatar', 'user'); + + // + // If old avatar is a cutom avatar, delete it. + // + if ($this->mOldAvatar != null && $this->mOldAvatar->get('avatar_type') == 'C') { + $avatarHandler->delete($this->mOldAvatar); + } + + // + // Delete all of links about this user from avatar_user_link. + // + $linkHandler =& xoops_getmodulehandler('avatar_user_link', 'user'); + $linkHandler->deleteAllByUser($this->mObject); + + // + // Insert new link. + // + $criteria =& new Criteria('avatar_file', $this->mObject->get('user_avatar')); + $avatarArr =& $avatarHandler->getObjects($criteria); + if (is_array($avatarArr) && is_object($avatarArr[0])) { + $link =& $linkHandler->create(); + $link->set('avatar_id', $avatarArr[0]->get('avatar_id')); + $link->set('user_id', $this->mObject->get('uid')); + $linkHandler->insert($link); + } + + return true; + } + } + + /** + * This action always kicks out GET request. + */ + function getDefaultView(&$controller, &$xoopsUser) + { + $controller->executeForward(XOOPS_URL . "/edituser.php?op=avatarform&uid=" . $this->mObject->get('uid')); + } + + function executeViewSuccess(&$controller,&$xoopsUser,&$renderSystem) + { + $controller->executeForward(XOOPS_URL . "/userinfo.php?op=avatarform&uid=" . $this->mActionForm->get('uid')); + } + + function executeViewError(&$controller,&$xoopsUser,&$renderSystem) + { + $controller->executeRedirect(XOOPS_URL . "/userinfo.php?op=avatarform&uid=" . $this->mActionForm->get('uid'), 1, _MD_ERROR_DBUPDATE_FAILED); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/user/actions/DefaultAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/DefaultAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/DefaultAction.class.php Mon Apr 30 16:38:00 2007 @@ -0,0 +1,50 @@ +<?php +/** + * @package legacy + * @version $Id: DefaultAction.class.php,v 1.1.4.1 2007/04/30 07:38:00 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +/** + * This action shows two forms for login and lostpass. If the current user is + * logined, forward to the userinfo page. + */ +class User_DefaultAction extends User_Action +{ + var $_mAllowRegister = false; + + function isSecure() + { + return false; + } + + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + parent::prepare($controller, $xoopsUser, $moduleConfig); + $this->_mAllowRegister = $moduleConfig['allow_register']; + } + + function getDefaultView(&$controller, &$xoopsUser) + { + return is_object($xoopsUser) ? USER_FRAME_VIEW_ERROR : USER_FRAME_VIEW_INPUT; + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("user_default.html"); + $render->setAttribute('allowRegister', $this->_mAllowRegister); + if (!empty($_GET['xoops_redirect'])) { + $root =& $controller->mRoot; + $textFilter =& $root->getTextFilter(); + $render->setAttribute('redirect_page', $textFilter->toShow(xoops_getrequest('xoops_redirect'))); + } + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward("index.php?action=UserInfo&uid=" . $xoopsUser->get('uid')); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/user/actions/EditUserAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/EditUserAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/EditUserAction.class.php Mon Apr 30 16:38:00 2007 @@ -0,0 +1,161 @@ +<?php +/** + * @package user + * @version $Id: EditUserAction.class.php,v 1.1.4.1 2007/04/30 07:38:00 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/user/class/AbstractEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/user/forms/EditUserForm.class.php"; + +define ('USER_COOKIE_KEEP_TIME', 31536000); + +/** + * @see User_EditUserForm + */ +class User_EditUserAction extends User_AbstractEditAction +{ + /** + * @var string + */ + var $mUserCookie = ""; + + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + parent::prepare($controller, $xoopsUser, $moduleConfig); + $this->mUserCookie = $moduleConfig['usercookie']; + } + + function _getId() + { + $root =& XCube_Root::getSingleton(); + $uid = is_object($root->mContext->mXoopsUser) ? $root->mContext->mXoopsUser->get('uid') : 0; + + return isset($_REQUEST['uid']) ? intval(xoops_getrequest('uid')) : $uid; + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('users', 'user'); + return $handler; + } + + /** + * Because editable fields are decided by the module config, this member + * function hands the config to the constructor of the action form. + * + * @see User_AbstractUserEditForm + */ + function _setupActionForm() + { + $this->mActionForm =& new User_EditUserForm($this->mConfig); + $this->mActionForm->prepare(); + } + + function isEnableCreate() + { + return false; + } + + function isSecure() + { + return true; + } + + /** + * Allow Conditions: + * + * 1) The current user is the target user. + * 2) The current user is administrators. + */ + function hasPermission(&$controller, &$xoopsUser, $moduleConfig) + { + if (!is_object($this->mObject)) { + return false; + } + + if ($controller->mRoot->mContext->mUser->isInRole('Module.user.Admin')) { + return true; + } + + return ($this->mObject->get('uid') == $xoopsUser->get('uid')); + } + + function _doExecute() + { + if ($this->mObjectHandler->insert($this->mObject)) { + if ($this->mActionForm->get('usercookie')) { + setcookie($this->mUserCookie, $this->mObject->getShow('uname'), time() + USER_COOKIE_KEEP_TIME); + } + else { + setcookie($this->mUserCookie); + } + + return true; + } + else { + return false; + } + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("user_edituser.html"); + $render->setAttribute("actionForm", $this->mActionForm); + $render->setAttribute("thisUser", $this->mObject); + $render->setAttribute("currentUser", $xoopsUser); + $render->setAttribute("allow_chgmail", $this->mConfig['allow_chgmail']); + + $handler =& xoops_gethandler('timezone'); + $timezoneArr =& $handler->getObjects(); + $render->setAttribute('timezones', $timezoneArr); + + // + // umode option + // + $umodeOptions = array("nest" => _NESTED, "flat" => _FLAT, "thread" => _THREADED); + $render->setAttribute('umodeOptions', $umodeOptions); + + // + // uorder option + // + $uorderOptions = array(0 => _OLDESTFIRST, 1 => _NEWESTFIRST); + $render->setAttribute('uorderOptions', $uorderOptions); + + // + // notify option + // + + // + // TODO Because abstract message catalog style is not decided, we load directly. + // + $root =& XCube_Root::getSingleton(); + $root->mLanguageManager->loadPageTypeMessageCatalog('notification'); + require_once XOOPS_ROOT_PATH . "/include/notification_constants.php"; + + $methodOptions = array(XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE, + XOOPS_NOTIFICATION_METHOD_PM => _NOT_METHOD_PM, + XOOPS_NOTIFICATION_METHOD_EMAIL => _NOT_METHOD_EMAIL + ); + $render->setAttribute('notify_methodOptions', $methodOptions); + + $modeOptions = array(XOOPS_NOTIFICATION_MODE_SENDALWAYS => _NOT_MODE_SENDALWAYS, + XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE, + XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT => _NOT_MODE_SENDONCEPERLOGIN + ); + $render->setAttribute('notify_modeOptions', $modeOptions); + } + + function executeViewSuccess(&$controller,&$xoopsUser,&$render) + { + $controller->executeForward(XOOPS_URL . '/userinfo.php?uid=' . $this->mObject->getShow('uid')); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect(XOOPS_URL . '/', 1, _MD_USER_ERROR_DBUPDATE_FAILED); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/user/actions/LostPassAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/LostPassAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/LostPassAction.class.php Mon Apr 30 16:38:00 2007 @@ -0,0 +1,130 @@ +<?php +/** + * @package user + * @version $Id: LostPassAction.class.php,v 1.1.4.1 2007/04/30 07:38:00 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/user/forms/LostPassEditForm.class.php"; +require_once XOOPS_MODULE_PATH . "/user/class/LostPassMailBuilder.class.php"; + +/** + * The process of lostpass. This action sends a mail even if the input mail + * address isn't registered in the site. Because displaying error message in + * such case shows the part of the personal information. We will discuss about + * this spec. + */ +class User_LostPassAction extends User_Action +{ + /** + * @var User_LostPassEditForm + */ + var $mActionForm = null; + + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + $this->mActionForm =& new User_LostPassEditForm(); + $this->mActionForm->prepare(); + } + + function isSecure() + { + return false; + } + + /** + * Allow anonymous users only. + */ + function hasPermission(&$controller, &$xoopsUser, $moduleConfig) + { + return !$controller->mRoot->mContext->mUser->mIdentity->isAuthenticated(); + } + + function getDefaultView(&$controller, &$xoopsUser) + { + if ((!isset($_REQUEST['code'])) || (!isset($_REQUEST['email']))) { + return USER_FRAME_VIEW_INPUT; + } else { + return $this->_updatePassword($controller); + } + } + + function _updatePassword(&$controller) { + $this->mActionForm->fetch(); + + $userHandler =& xoops_gethandler('user'); + $lostUserArr =& $userHandler->getObjects(new Criteria('email', $this->mActionForm->get('email'))); + if (is_array($lostUserArr) && count($lostUserArr) > 0) { + $lostUser =& $lostUserArr[0]; + } + else { + return USER_FRAME_VIEW_ERROR; + } + + $newpass = xoops_makepass(); + $extraVars['newpass'] = $newpass; + $builder =& new User_LostPass2MailBuilder(); + $director =& new User_LostPassMailDirector($builder, $lostUser, $controller->mRoot->mContext->getXoopsConfig(), $extraVars); + $director->contruct(); + $xoopsMailer =& $builder->getResult(); + if (!$xoopsMailer->send()) { + // $xoopsMailer->getErrors(); + return USER_FRAME_VIEW_ERROR; + } + $lostUser->set('pass',md5($newpass), true); + $userHandler->insert($lostUser, true); + + return USER_FRAME_VIEW_SUCCESS; + } + + function execute(&$controller, &$xoopsUser) + { + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + + if ($this->mActionForm->hasError()) { + return USER_FRAME_VIEW_INPUT; + } + + $userHandler =& xoops_gethandler('user'); + $lostUserArr =& $userHandler->getObjects(new Criteria('email', $this->mActionForm->get('email'))); + + if (is_array($lostUserArr) && count($lostUserArr) > 0) { + $lostUser =& $lostUserArr[0]; + } + else { + return USER_FRAME_VIEW_ERROR; + } + + $builder =& new User_LostPass1MailBuilder(); + $director =& new User_LostPassMailDirector($builder, $lostUser, $controller->mRoot->mContext->getXoopsConfig()); + $director->contruct(); + $xoopsMailer =& $builder->getResult(); + + if (!$xoopsMailer->send()) { + // $xoopsMailer->getErrors(); + return USER_FRAME_VIEW_ERROR; + } + + return USER_FRAME_VIEW_SUCCESS; + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("user_lostpass.html"); + $render->setAttribute("actionForm", $this->mActionForm); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect(XOOPS_URL . '/', 3, _MD_USER_MESSAGE_SEND_PASSWORD); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect(XOOPS_URL . '/', 3, _MD_USER_ERROR_SEND_MAIL); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/user/actions/MiscOnlineAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/MiscOnlineAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/MiscOnlineAction.class.php Mon Apr 30 16:38:00 2007 @@ -0,0 +1,50 @@ +<?php +/** + * @package Legacy + * @version $Id: MiscOnlineAction.class.php,v 1.1.4.1 2007/04/30 07:38:00 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/user/class/AbstractListAction.class.php"; +require_once XOOPS_MODULE_PATH . "/user/forms/OnlineFilterForm.class.php"; + +class User_MiscOnlineAction extends User_AbstractListAction +{ + function prepare(&$controller, &$xoopsUser, &$moduleConfig) + { + $controller->mRoot->mLanguageManager->loadModuleMessageCatalog('user'); + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('online', 'user'); + return $handler; + } + + function &_getFilterForm() + { + $filter =& new User_OnlineFilterForm($this->_getPageNavi(), $this->_getHandler()); + return $filter; + } + + function _getBaseUrl() + { + return "./misc.php?type=online"; + } + + function executeViewIndex(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("user_misc_online.html"); + + foreach (array_keys($this->mObjects) as $key) { + $this->mObjects[$key]->loadModule(); + } + + $render->setAttribute("objects", $this->mObjects); + $render->setAttribute("pageNavi", $this->mFilter->mNavi); + $render->setAttribute('enableViewIP', $controller->mRoot->mContext->mUser->isInRole('Module.user.Admin')); + } +} + +?> Index: xoops2jp/html/modules/user/actions/UserActivateAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/UserActivateAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/UserActivateAction.class.php Mon Apr 30 16:38:00 2007 @@ -0,0 +1,79 @@ +<?php +/** + * @package user + * @version $Id: UserActivateAction.class.php,v 1.1.4.1 2007/04/30 07:38:00 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/user/class/AbstractEditAction.class.php"; +require_once XOOPS_MODULE_PATH . "/user/class/RegistMailBuilder.class.php"; + +class User_UserActivateAction extends User_AbstractEditAction +{ + function _getId() + { + return isset($_REQUEST['uid']) ? intval(xoops_getrequest('uid')) : 0; + } + + function &_getHandler() + { + $handler =& xoops_getmodulehandler('users', 'user'); + return $handler; + } + + /** + * Return false. + * If a user requests dummy uid, kick out him! + */ + function isEnableCreate() + { + return false; + } + + /** + * Return false. + * This action would be used by a guest user. + */ + function isSecure() + { + return false; + } + + function getDefaultView(&$controller, &$xoopsUser) + { + if ((!isset($_REQUEST['actkey'])) || (!$this->mObject)) { + $controller->executeForward(XOOPS_URL . '/'); + } + + if ($this->mObject->get('actkey') != xoops_getrequest('actkey')) { + $controller->executeRedirect(XOOPS_URL . '/', 3, _MD_USER_MESSAGE_ACTKEYNOT); + } + + if ($this->mObject->get('level') > 1) { + $controller->executeRedirect(XOOPS_URL . '/user.php', 3, _MD_USER_MESSAGE_ACONTACT); + } + + $this->mObject->set('level', '1'); + + // + // Force update with GET request + // + $this->mObjectHandler->insert($this->mObject, true); + + if ($this->mConfig['activation_type'] == 2) { + $builder =& new User_RegistAdminCommitMailBuilder(); + $director =& new User_UserRegistMailDirector($builder, $this->mObject, $controller->mRoot->mContext->getXoopsConfig(), $this->mConfig); + $director->contruct(); + $mailer=&$builder->getResult(); + if ($mailer->send()) { + $controller->executeRedirect(XOOPS_URL . '/', 5, sprintf(_MD_USER_MESSAGE_ACTVMAILOK, $this->mObject->get('uname'))); + } else { + $controller->executeRedirect(XOOPS_URL . '/', 5, sprintf(_MD_USER_MESSAGE_ACTVMAILNG, $this->mObject->get('uname'))); + } + } else { + $controller->executeRedirect(XOOPS_URL . '/user.php', 5, _MD_USER_MESSAGE_ACTLOGIN); + } + } +} +?> Index: xoops2jp/html/modules/user/actions/UserDeleteAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/UserDeleteAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/UserDeleteAction.class.php Mon Apr 30 16:38:00 2007 @@ -0,0 +1,125 @@ +<?php +/** + * @package user + * @version $Id: UserDeleteAction.class.php,v 1.1.4.1 2007/04/30 07:38:00 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/user/forms/UserDeleteForm.class.php"; + +/** + * This action is for self delete function. + * + * Site owner want various procedure to this action. Therefore, this action may + * have to implement main logic with Delegate only. + */ +class User_UserDeleteAction extends User_Action +{ + var $mActionForm = null; + var $mObject = null; + + var $mSelfDelete = false; + var $mSelfDeleteConfirmMessage = ""; + + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + $this->mSelfDelete = $moduleConfig['self_delete']; + $this->mSelfDeleteConfirmMessage = $moduleConfig['self_delete_confirm']; + + $this->mActionForm =& new User_UserDeleteForm(); + $this->mActionForm->prepare(); + + // + // pre condition check + // + if (!$this->mSelfDelete) { + $controller->executeForward(XOOPS_URL . '/'); + } + + if (is_object($xoopsUser)) { + $handler =& xoops_getmodulehandler('users', 'user'); + $this->mObject =& $handler->get($xoopsUser->get('uid')); + } + } + + function isSecure() + { + return true; + } + + function hasPermission(&$controller, &$xoopsUser, $moduleConfig) + { + if ($xoopsUser->get('uid') == 1) { + return false; + } + + return true; + } + + function getDefaultView(&$controller, &$xoopsUser) + { + return USER_FRAME_VIEW_INPUT; + } + + /** + * FIXME: Need FORCE LOGOUT here? + */ + function execute(&$controller, &$xoopsUser) + { + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + + if ($this->mActionForm->hasError()) { + return $this->getDefaultView($controller, $xoopsUser); + } + + if ($this->_doDelete($controller, $xoopsUser)) { + XCube_DelegateUtils::call('Legacy.Event.UserDelete', new XCube_Ref($this->mObject)); + + return USER_FRAME_VIEW_SUCCESS; + } + + return USER_FRAME_VIEW_ERROR; + } + + /** + * Exection deleting. + * + * @return bool + */ + function _doDelete(&$controller, &$xoopsUser) + { + $handler =& xoops_gethandler('member'); + if ($handler->deleteUser($xoopsUser)) { + $handler =& xoops_gethandler('online'); + $handler->destroy($this->mObject->get('uid')); + xoops_notification_deletebyuser($this->mObject->get('uid')); + + return true; + } + + return false; + } + + function executeViewInput(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("user_delete.html"); + $render->setAttribute('object', $this->mObject); + $render->setAttribute('actionForm', $this->mActionForm); + $render->setAttribute('self_delete_message', $this->mSelfDeleteConfirmMessage); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("user_delete_success.html"); + $render->setAttribute("object", $this->mObject); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeRedirect(XOOPS_URL . '/', 3, _MD_USER_ERROR_DBUPDATE_FAILED); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/user/actions/UserInfoAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/UserInfoAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/UserInfoAction.class.php Mon Apr 30 16:38:00 2007 @@ -0,0 +1,139 @@ +<?php +/** + * @package user + * @version $Id: UserInfoAction.class.php,v 1.1.4.1 2007/04/30 07:38:00 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +define ('USER_USERINFO_MAXHIT', 5); + +/** + * This action shows a information of the target user which is specified by + * $uid. And display posts of the user with the global search service. + * + * [Warning] + * Now, the global search service can't work because the design of XCube is + * changed. + * + * @todo The global search service can't work. + */ +class User_UserInfoAction extends User_Action +{ + var $mObject = null; + var $mRankObject = null; + var $mSearchResults = null; + + var $mSelfDelete = false; + + var $mPmliteURL = null; + + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + $this->mSelfDelete = $moduleConfig['self_delete']; + } + + function isSecure() + { + return false; + } + + function getDefaultView(&$controller, &$xoopsUser) + { + $uid = isset($_GET['uid']) ? intval(xoops_getrequest('uid')) : 0; + + $handler =& xoops_gethandler('user'); + $this->mObject =& $handler->get($uid); + + if (!is_object($this->mObject)) { + return USER_FRAME_VIEW_ERROR; + } + + $t_rank = xoops_getrank($this->mObject->get('rank'), $this->mObject->get('posts')); + + $rankHandler =& xoops_getmodulehandler('ranks', 'user'); + $this->mRankObject =& $rankHandler->get($t_rank['id']); + + $root =& $controller->mRoot; + + $service =& $root->mServiceManager->getService('privateMessage'); + if ($service != null) { + $client =& $root->mServiceManager->createClient($service); + $this->mPmliteURL = $client->call('getPmliteUrl', array('fromUid' => is_object($xoopsUser) ? $xoopsUser->get('uid') : 0, 'toUid' => $uid)); + } + unset($service); + + $service =& $root->mServiceManager->getService("LegacySearch"); + if ($service != null) { + $this->mSearchResults = array(); + + $client =& $root->mServiceManager->createClient($service); + + $moduleArr = $client->call('getActiveModules', array()); + + foreach ($moduleArr as $t_module) { + $module = array(); + $module['name'] = $t_module['name']; + $module['mid'] = $t_module['mid']; + + $params['mid'] = $t_module['mid']; + $params['uid'] = $this->mObject->get('uid'); + $params['maxhit'] = USER_USERINFO_MAXHIT; + $params['start'] = 0; + + $module['results'] = $client->call('searchItemsOfUser', $params); + + if (count($module['results']) > 0) { + $module['has_more'] = (count($module['results']) >= USER_USERINFO_MAXHIT) ? true : false; + $this->mSearchResults[] = $module; + } + } + } + + return USER_FRAME_VIEW_SUCCESS; + } + + /** + * [Notice] + * Because XCube_Service class group are changed now, this member function + * can't get the result of user posts. + */ + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $render->setTemplateName("user_userinfo.html"); + $render->setAttribute("thisUser", $this->mObject); + $render->setAttribute("rank", $this->mRankObject); + + $render->setAttribute('pmliteUrl', $this->mPmliteURL); + + $userSignature = $this->mObject->getShow('user_sig'); + + $render->setAttribute('user_signature', $userSignature); + + $render->setAttribute("searchResults", $this->mSearchResults); + + // + // set flags. + // + $user_ownpage = (is_object($xoopsUser) && $xoopsUser->get('uid') == $this->mObject->get('uid')); + $render->setAttribute("user_ownpage", $user_ownpage); + + // + // About 'SELF DELETE' + // + $render->setAttribute('self_delete', $this->mSelfDelete); + if ($user_ownpage && $this->mSelfDelete) { + $render->setAttribute('enableSelfDelete', true); + } + else { + $render->setAttribute('enableSelfDelete', false); + } + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $controller->executeForward(XOOPS_URL . '/user.php'); + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/user/actions/UserRegisterAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/UserRegisterAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/UserRegisterAction.class.php Mon Apr 30 16:38:00 2007 @@ -0,0 +1,91 @@ +<?php +/** + * @package user + * @version $Id: UserRegisterAction.class.php,v 1.1.4.1 2007/04/30 07:38:00 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/user/forms/UserRegisterEditForm.class.php"; + +/** + * This action uses the special technic to realize confirming. It set the + * register action form to Session through serialize(), then forward to the + * confirm action. Because the confirm action can't work without the register + * action form which it fetches from Session, the confim action doesn't need + * to check the permission to register. + */ +class User_UserRegisterAction extends User_Action +{ + var $mActionForm = null; + var $mConfig; + var $mEnableAgreeFlag = false; + + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + $this->mConfig = $moduleConfig; + + if(is_object($xoopsUser)) { + // + // If user is registered, kick to his information page. + // + $controller->executeForward(XOOPS_URL . "/user.php"); + } + if (empty($this->mConfig['allow_register'])) { + $controller->executeRedirect(XOOPS_URL . '/', 6, _MD_USER_LANG_NOREGISTER); + } + } + + function execute(&$controller, &$xoopsUser) + { + $this->_processActionForm(); + $this->mActionForm->fetch(); + $this->mActionForm->validate(); + + if ($this->mActionForm->hasError()) { + return USER_FRAME_VIEW_INPUT; + } else { + $_SESSION['user_register_actionform'] = serialize($this->mActionForm); + $controller->executeForward('./register.php?action=confirm'); + } + } + + function getDefaultView(&$controller,&$xoopsUser) + { + $this->_processActionForm(); + return USER_FRAME_VIEW_INPUT; + } + + function _processActionForm() + { + if ($this->mConfig['reg_dispdsclmr'] != 0 && $this->mConfig['reg_disclaimer'] != null) { + $this->mEnableAgreeFlag = true; + $this->mActionForm =& new User_RegisterAgreeEditForm($this->mConfig); + } else { + $this->mActionForm =& new User_RegisterEditForm($this->mConfig); + } + + $this->mActionForm->prepare(); + + $root =& XCube_Root::getSingleton(); + $this->mActionForm->set('timezone_offset', $root->mContext->getXoopsConfig('default_TZ')); + } + + function executeViewInput(&$controller,&$xoopsUser,&$renderSystem) + { + $renderSystem->setTemplateName("user_register_form.html"); + // + // Get some objects for input form. + // + $tzoneHandler =& xoops_gethandler('timezone'); + $timezones =& $tzoneHandler->getObjects(); + $renderSystem->setAttribute('timezones', $timezones); + $renderSystem->setAttribute("actionForm", $this->mActionForm); + $renderSystem->setAttribute("enableAgree", $this->mEnableAgreeFlag); + if($this->mEnableAgreeFlag) { + $renderSystem->setAttribute("disclaimer", $this->mConfig['reg_disclaimer']); + } + } +} + +?> \ No newline at end of file Index: xoops2jp/html/modules/user/actions/UserRegister_confirmAction.class.php diff -u /dev/null xoops2jp/html/modules/user/actions/UserRegister_confirmAction.class.php:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/UserRegister_confirmAction.class.php Mon Apr 30 16:38:01 2007 @@ -0,0 +1,169 @@ +<?php +/** + * @package user + * @version $Id: UserRegister_confirmAction.class.php,v 1.1.4.1 2007/04/30 07:38:01 nobunobu Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +require_once XOOPS_MODULE_PATH . "/user/forms/UserConfirmForm.class.php"; +require_once XOOPS_MODULE_PATH . "/user/forms/UserRegisterEditForm.class.php"; +require_once XOOPS_MODULE_PATH . "/user/class/RegistMailBuilder.class.php"; + +/** + * This action uses the special technic to realize confirming. It gets the + * register action form which has been inputted in UserRegister, through + * unserialize(). And, it uses a simple action form to confirm lastly. + */ +class User_UserRegister_confirmAction extends User_Action +{ + var $mActionForm = null; + var $mRegistForm = null; + var $mConfig = null; + + var $mNewUser = null; + + var $mRedirectMessage = null; + + /** + * TODO this member function uses the old style delegate. + */ + function prepare(&$controller, &$xoopsUser, $moduleConfig) + { + $this->mConfig = $moduleConfig; + + $this->_getRegistForm($controller); + $this->_processActionForm(); + } + + function execute(&$controller, &$xoopsUser) + { + $memberHandler =& xoops_gethandler('member'); + $this->mNewUser =& $memberHandler->createUser(); + $this->mRegistForm->update($this->mNewUser); + $this->mNewUser->set('uorder', $controller->mRoot->mContext->getXoopsConfig('com_order'), true); + $this->mNewUser->set('umode', $controller->mRoot->mContext->getXoopsConfig('com_mode'), true); + if ($this->mConfig['activation_type'] == 1) { + $this->mNewUser->set('level', 1, true); + } + + if (!$memberHandler->insertUser($this->mNewUser)) { + $this->mRedirectMessage = _MD_USER_LANG_REGISTERNG; + return USER_FRAME_VIEW_ERROR; + } + + if (!$memberHandler->addUserToGroup(XOOPS_GROUP_USERS, $this->mNewUser->get('uid'))) { + $this->mRedirectMessage = _MD_USER_LANG_REGISTERNG; + return USER_FRAME_VIEW_ERROR; + } + + $this->_clearRegistForm($controller); + + $this->_processMail($controller); + $this->_eventNotifyMail($controller); + + XCube_DelegateUtils::call('Legacy.Event.RegistUser.Success', new XCube_Ref($this->mNewUser)); + + return USER_FRAME_VIEW_SUCCESS; + } + + function getDefaultView(&$controller, &$xoopsUser) + { + return USER_FRAME_VIEW_INPUT; + } + + /** + * Get regist actionform from Session and set it to the member property. + * @access private + */ + function _getRegistForm(&$controller) + { + $this->mRegistForm = unserialize($_SESSION['user_register_actionform']); + if (!is_object($this->mRegistForm)) { + $controller->executeForward('./register.php?action=UserRegister'); + } + } + + /** + * Clear session. + * @access private + */ + function _clearRegistForm(&$controller) + { + unset($_SESSION['user_register_actionform']); + } + + function _processMail(&$controller) + { + $activationType = $this->mConfig['activation_type']; + + if($activationType == 1) { + return; + } + + // Wmm.. + $builder = ($activationType == 0) ? new User_RegistUserActivateMailBuilder() + : new User_RegistUserAdminActivateMailBuilder(); + + $director =& new User_UserRegistMailDirector($builder, $this->mNewUser, $controller->mRoot->mContext->getXoopsConfig(), $this->mConfig); + $director->contruct(); + $mailer =& $builder->getResult(); + + if (!$mailer->send()) { + } // TODO CHECKS and use '_MD_USER_ERROR_YOURREGMAILNG' + } + + function _eventNotifyMail(&$controller) + { + if($this->mConfig['new_user_notify'] == 1 && !empty($this->mConfig['new_user_notify_group'])) { + $builder =& new User_RegistUserNotifyMailBuilder(); + $director =& new User_UserRegistMailDirector($builder, $this->mNewUser, $controller->mRoot->mContext->getXoopsConfig(), $this->mConfig); + $director->contruct(); + $mailer =& $builder->getResult(); + $mailer->send(); + } + } + + function _processActionForm() + { + $this->mActionForm =& new User_UserConfirmForm(); + $this->mActionForm->prepare(); + } + + function executeViewError(&$controller, &$xoopsUser, &$render) + { + $execute->executeRedirect(XOOPS_URL . '/', 1, $this->mRedirectMessage); + } + + function executeViewInput(&$controller,&$xoopsUser,&$render) + { + $render->setTemplateName("user_register_confirm.html"); + $render->setAttribute("actionForm", $this->mActionForm); + $render->setAttribute("registForm", $this->mRegistForm); + } + + function executeViewSuccess(&$controller, &$xoopsUser, &$render) + { + $activationType = $this->mConfig['activation_type']; + + if ($activationType == 0) { + $render->setTemplateName("user_register_finish.html"); + $render->setAttribute("complete_message", _MD_USER_MESSAGE_YOURREGISTERED); + } + elseif ($activationType == 1) { + $controller->executeRedirect(XOOPS_URL . '/', 4, _MD_USER_MESSAGE_ACTLOGIN); + } + elseif($activationType == 2) { + $render->setTemplateName("user_register_finish.html"); + $render->setAttribute("complete_message", _MD_USER_MESSAGE_YOURREGISTERED2); + } + else { + // + // This case is never. + // + $render->setTemplateName("user_register_finish.html"); + $render->setAttribute("complete_message", _MD_USER_MESSAGE_YOURREGISTERED2); + } + } +} +?> \ No newline at end of file Index: xoops2jp/html/modules/user/actions/index.html diff -u /dev/null xoops2jp/html/modules/user/actions/index.html:1.1.4.1 --- /dev/null Mon Apr 30 16:38:01 2007 +++ xoops2jp/html/modules/user/actions/index.html Mon Apr 30 16:38:01 2007 @@ -0,0 +1 @@ + <script>history.go(-1);</script> \ No newline at end of file