Minahito
minah****@users*****
2006年 1月 26日 (木) 20:13:26 JST
Index: xoops2jp/html/modules/user/forms/AvatarEditForm.class.php diff -u /dev/null xoops2jp/html/modules/user/forms/AvatarEditForm.class.php:1.1.2.1 --- /dev/null Thu Jan 26 20:13:26 2006 +++ xoops2jp/html/modules/user/forms/AvatarEditForm.class.php Thu Jan 26 20:13:26 2006 @@ -0,0 +1,77 @@ +<?php + +require_once XOOPS_ROOT_PATH . "/class/XCube_ActionForm.class.php"; + +/** + * This class is generated by makeActionForm tool. + */ +class User_AvatarEditForm extends XCube_ActionForm +{ + var $mOldAvatarFilename = null; + var $mFormFile = null; + + var $mWidth; + var $mHeight; + + function getTokenName() + { + return "module.user.AvatarEditForm.TOKEN"; + } + + function prepare($width, $height, $maxfilesize) + { + $this->mWidth = $width; + $this->mHeight = $height; + + // + // Set form properties + // + $this->mFormProperties['uid'] =& new XCube_IntProperty('uid'); + $this->mFormProperties['uploadavatar'] =& new XCube_ImageFileProperty('uploadavatar'); + + // + // Set field properties + // + $this->mFieldProperties['uploadavatar'] =& new XCube_FieldProperty($this); + $this->mFieldProperties['uploadavatar']->setDependsByArray(array('extension,maxfilesize')); + $this->mFieldProperties['uploadavatar']->addMessage('extension', _MD_USER_ERROR_AVATAR_EXTENSION); + $this->mFieldProperties['uploadavatar']->addVar('extension', "jpg,gif,png"); + $this->mFieldProperties['uploadavatar']->addMessage('maxfilesize', _MD_USER_ERROR_AVATAR_MAXFILESIZE); + $this->mFieldProperties['uploadavatar']->addVar('maxfilesize', $maxfilesize); + } + + function validateUploadavatar() + { + if ($this->get('uploadavatar') != null) { + $formfile = $this->get('uploadavatar'); + if ($formfile->getWidth() > $this->mWidth) { + $this->addErrorMessage(_MD_USER_ERROR_AVATAR_SIZE); + } + elseif ($formfile->getHeight() > $this->mHeight) { + $this->addErrorMessage(_MD_USER_ERROR_AVATAR_SIZE); + } + } + } + + function load(&$obj) + { + $this->setVar('uid', $obj->get('uid')); + $this->mOldAvatarFilename = $obj->get('user_avatar'); + } + + function update(&$obj) + { + $obj->setVar('uid', $this->get('uid')); + + $this->mFormFile = $this->get('uploadavatar'); + + $this->mFormFile->setRandomToBodyName('cavt'); + + $filename = $this->mFormFile->getFileName(); + $this->mFormFile->setBodyName(substr($filename, 0, 25)); + + $obj->setVar('user_avatar', $this->mFormFile->getFileName()); //< TODO + } +} + +?> Index: xoops2jp/html/modules/user/forms/AvatarUploadForm.class.php diff -u xoops2jp/html/modules/user/forms/AvatarUploadForm.class.php:1.1.2.3 xoops2jp/html/modules/user/forms/AvatarUploadForm.class.php:removed --- xoops2jp/html/modules/user/forms/AvatarUploadForm.class.php:1.1.2.3 Thu Jan 19 21:13:45 2006 +++ xoops2jp/html/modules/user/forms/AvatarUploadForm.class.php Thu Jan 26 20:13:26 2006 @@ -1,77 +0,0 @@ -<?php - -require_once XOOPS_ROOT_PATH . "/class/XCube_ActionForm.class.php"; - -/** - * This class is generated by makeActionForm tool. - */ -class AvatarUploadForm extends XCube_ActionForm -{ - var $mOldAvatarFilename = null; - var $mFormFile = null; - - var $mWidth; - var $mHeight; - - function getTokenName() - { - return "module.user.AvatarUploadForm.TOKEN"; - } - - function prepare($width, $height, $maxfilesize) - { - $this->mWidth = $width; - $this->mHeight = $height; - - // - // Set form properties - // - $this->mFormProperties['uid'] =& new XCube_IntProperty('uid'); - $this->mFormProperties['uploadavatar'] =& new XCube_ImageFileProperty('uploadavatar'); - - // - // Set field properties - // - $this->mFieldProperties['uploadavatar'] =& new XCube_FieldProperty($this); - $this->mFieldProperties['uploadavatar']->setDependsByArray(array('extension,maxfilesize')); - $this->mFieldProperties['uploadavatar']->addMessage('extension', _MD_USER_ERROR_AVATAR_EXTENSION); - $this->mFieldProperties['uploadavatar']->addVar('extension', "jpg,gif,png"); - $this->mFieldProperties['uploadavatar']->addMessage('maxfilesize', _MD_USER_ERROR_AVATAR_MAXFILESIZE); - $this->mFieldProperties['uploadavatar']->addVar('maxfilesize', $maxfilesize); - } - - function validateUploadavatar() - { - if ($this->get('uploadavatar') != null) { - $formfile = $this->get('uploadavatar'); - if ($formfile->getWidth() > $this->mWidth) { - $this->addErrorMessage(_MD_USER_ERROR_AVATAR_SIZE); - } - elseif ($formfile->getHeight() > $this->mHeight) { - $this->addErrorMessage(_MD_USER_ERROR_AVATAR_SIZE); - } - } - } - - function load(&$obj) - { - $this->setVar('uid', $obj->get('uid')); - $this->mOldAvatarFilename = $obj->get('user_avatar'); - } - - function update(&$obj) - { - $obj->setVar('uid', $this->get('uid')); - - $this->mFormFile = $this->get('uploadavatar'); - - $this->mFormFile->setRandomToBodyName('cavt'); - - $filename = $this->mFormFile->getFileName(); - $this->mFormFile->setBodyName(substr($filename, 0, 25)); - - $obj->setVar('user_avatar', $this->mFormFile->getFileName()); //< TODO - } -} - -?>