Minahito
minah****@users*****
2006年 3月 8日 (水) 19:19:20 JST
Index: xoops2jp/html/modules/user/actions/AvatarEditAction.class.php diff -u xoops2jp/html/modules/user/actions/AvatarEditAction.class.php:1.1.2.2 xoops2jp/html/modules/user/actions/AvatarEditAction.class.php:1.1.2.3 --- xoops2jp/html/modules/user/actions/AvatarEditAction.class.php:1.1.2.2 Sat Jan 28 03:33:54 2006 +++ xoops2jp/html/modules/user/actions/AvatarEditAction.class.php Wed Mar 8 19:19:20 2006 @@ -153,10 +153,36 @@ } if ($this->mActionForm->mOldAvatarFilename != null && $this->mActionForm->mOldAvatarFilename != "blank.gif") { - @unlink(XOOPS_UPLOAD_PATH . "/" . $this->mActionForm->mOldAvatarFilename); + $avatarHandler =& xoops_getmodulehandler('avatar'); + $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]); + } } - return parent::_doExecute(); + if (parent::_doExecute()) { + $avatar =& $this->mActionForm->createAvatar(); + if ($avatar != null) { + $avatar->set('avatar_name', $this->mObject->get('uname')); + $avatarHandler =& xoops_getmodulehandler('avatar'); + $avatarHandler->insert($avatar); + + $linkHandler =& xoops_getmodulehandler('avatar_user_link'); + $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)