Minahito
minah****@users*****
2006年 1月 18日 (水) 02:26:02 JST
Index: xoops2jp/html/modules/user/forms/UserRegisterEditForm.class.php diff -u /dev/null xoops2jp/html/modules/user/forms/UserRegisterEditForm.class.php:1.1.2.1 --- /dev/null Wed Jan 18 02:26:01 2006 +++ xoops2jp/html/modules/user/forms/UserRegisterEditForm.class.php Wed Jan 18 02:26:01 2006 @@ -0,0 +1,82 @@ +<?php + +require_once dirname(__FILE__) . "/AbstractUserEditForm.class.php"; + +/** + * This class is generated by makeActionForm tool. + */ +class UserRegisterEditForm extends User_AbstractUserEditForm +{ + function getTokenName() + { + return "module.user.UserRegisterEditForm.TOKEN"; + } + + function prepare() + { + // + // Set form properties + // + $this->mFormProperties['uname'] =& new XCube_StringProperty('uname'); + $this->mFormProperties['email'] =& new XCube_StringProperty('email'); + $this->mFormProperties['user_viewemail'] =& new XCube_BoolProperty('user_viewemail'); + $this->mFormProperties['url'] =& new XCube_StringProperty('url'); + $this->mFormProperties['timezone_offset'] =& new XCube_FloatProperty('timezone_offset'); + $this->mFormProperties['pass'] =& new XCube_StringProperty('pass'); + $this->mFormProperties['vpass'] =& new XCube_StringProperty('vpass'); + $this->mFormProperties['user_mailok'] =& new XCube_BoolProperty('user_mailok'); + $this->mFormProperties['agree'] =& new XCube_BoolProperty('agree'); + + // + // Set field properties + // + $this->mFieldProperties['uname'] =& new XCube_FieldProperty($this); + $this->mFieldProperties['uname']->setDependsByArray(array('required','maxlength')); + $this->mFieldProperties['uname']->addMessage('required', _MD_USER_ERROR_REQUIRED, _MD_USER_LANG_UNAME, '25'); + $this->mFieldProperties['uname']->addMessage('maxlength', _MD_USER_ERROR_MAXLENGTH, _MD_USER_LANG_UNAME, '25'); + $this->mFieldProperties['uname']->addVar('maxlength', 25); + + $this->mFieldProperties['email'] =& new XCube_FieldProperty($this); + $this->mFieldProperties['email']->setDependsByArray(array('maxlength')); + $this->mFieldProperties['email']->addMessage('maxlength', _MD_USER_ERROR_MAXLENGTH, _MD_USER_LANG_EMAIL, '60'); + $this->mFieldProperties['email']->addVar('maxlength', 60); + + $this->mFieldProperties['url'] =& new XCube_FieldProperty($this); + $this->mFieldProperties['url']->setDependsByArray(array('maxlength')); + $this->mFieldProperties['url']->addMessage('maxlength', _MD_USER_ERROR_MAXLENGTH, _MD_USER_LANG_URL, '100'); + $this->mFieldProperties['url']->addVar('maxlength', 100); + + $this->mFieldProperties['pass'] =& new XCube_FieldProperty($this); + $this->mFieldProperties['pass']->setDependsByArray(array('maxlength')); + $this->mFieldProperties['pass']->addMessage('maxlength', _MD_USER_ERROR_MAXLENGTH, _MD_USER_LANG_PASS, '32'); + $this->mFieldProperties['pass']->addVar('maxlength', 32); + + $this->mFieldProperties['vpass'] =& new XCube_FieldProperty($this); + $this->mFieldProperties['vpass']->setDependsByArray(array('maxlength')); + $this->mFieldProperties['vpass']->addMessage('maxlength', _MD_USER_ERROR_MAXLENGTH, _MD_USER_LANG_PASS, '32'); + $this->mFieldProperties['vpass']->addVar('maxlength', 32); + + $this->mFieldProperties['timezone_offset'] =& new XCube_FieldProperty($this); + $this->mFieldProperties['timezone_offset']->setDependsByArray(array('required')); + $this->mFieldProperties['timezone_offset']->addMessage('required', _MD_USER_ERROR_REQUIRED, _MD_USER_LANG_TIMEZONE_OFFSET); + } + + function load(&$obj) + { + } + + function update(&$obj) + { + $obj->setVar('uname', $this->get('uname')); + $obj->setVar('email', $this->get('email')); + $obj->setVar('user_viewemail', $this->get('user_viewemail')); + $obj->setVar('url', $this->get('url')); + $obj->setVar('timezone_offset', $this->get('timezone_offset')); + $obj->setVar('pass', $this->get('pass')); + $obj->setVar('vpass', $this->get('vpass')); + $obj->setVar('user_mailok', $this->get('user_mailok')); + $obj->setVar('agree', $this->get('agree')); + } +} + +?> Index: xoops2jp/html/modules/user/forms/AbstractUserEditForm.class.php diff -u /dev/null xoops2jp/html/modules/user/forms/AbstractUserEditForm.class.php:1.1.2.1 --- /dev/null Wed Jan 18 02:26:01 2006 +++ xoops2jp/html/modules/user/forms/AbstractUserEditForm.class.php Wed Jan 18 02:26:01 2006 @@ -0,0 +1,86 @@ +<?php + +require_once XOOPS_ROOT_PATH . "/class/XCube_ActionForm.class.php"; + +/** + * This class is generated by makeActionForm tool. + */ +class User_AbstractUserEditForm extends XCube_ActionForm +{ + var $mConfig = array(); + + function validateUname() + { + if($this->getVar('uname')) { + + // + // uname unique check + // + $userHandler=&xoops_gethandler('user'); + $count=$userHandler->getCount(new Criteria('uname',$this->getVar('uname'))); + if($count!=0) { + $this->addErrorMessage(_US_NICKNAMETAKEN); + } + + // + // Check allow uname string pattern. + // + $regex=""; + switch($this->mConfig['uname_test_level']) { + case 0: + $regex="/[^a-zA-Z0-9\_\-]/"; + break; + + case 1: + $regex="/[^a-zA-Z0-9\_\-\<\>\,\.\$\%\#\@\!\\\'\"]/"; + break; + + case 2: + $regex="//[\000-\040]/"; + break; + } + if(preg_match($regex,$this->getVar('uname'))) { + $this->addErrorMessage(_US_INVALIDNICKNAME); + } + + + // + // Check bad uname patterns. + // + foreach(explode("|",$this->mConfig['bad_unames']) as $pattern) { + if(!empty($pattern)&&preg_match("/".$pattern."/i",$this->getVar('uname'))) { + $this->addErrorMessage(_US_NAMERESERVED); + break; + } + } + } + } + + function validateTimezone_offset() + { + $handler =& xoops_getmodulehandler('timezone'); + $obj =& $handler->get($this->get('timezone_offset')); + if (!is_object($obj)) { + $this->addErrorMessage(_MD_USER_ERROR_TIMEZONE); + } + } + + function validateEmail() + { + if ($this->get('email') != null && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$this->get('email'))) { + $this->addErrorMessage(_MD_USER_ERROR_EMAIL_FORMAT); + } + } + + function validatePass() + { + if(strlen($this->getVar('pass'))>0||strlen($this->getVar('vpass'))>0) + if($this->getVar('pass')!=$this->getVar('vpass')) { + $this->addErrorMessage(_MD_USER_ERROR_PASSWORD); + $this->setVar('pass',null); // reset + $this->setVar('vpass',null); + } + } +} + +?>