Minahito
minah****@users*****
2006年 3月 8日 (水) 19:20:22 JST
Index: xoops2jp/html/modules/user/actions/AvatarSelectAction.class.php diff -u xoops2jp/html/modules/user/actions/AvatarSelectAction.class.php:1.1.2.2 xoops2jp/html/modules/user/actions/AvatarSelectAction.class.php:1.1.2.3 --- xoops2jp/html/modules/user/actions/AvatarSelectAction.class.php:1.1.2.2 Wed Mar 8 16:52:45 2006 +++ xoops2jp/html/modules/user/actions/AvatarSelectAction.class.php Wed Mar 8 19:20:22 2006 @@ -9,6 +9,20 @@ */ class User_AvatarSelectAction extends User_AbstractEditAction { + var $mOldAvatar = null; + + function prepare(&$controller, &$xoopsUser, &$moduleConfig) + { + parent::prepare($controller, $xoopsUser, $moduleConfig); + + $handler =& xoops_getmodulehandler('avatar'); + $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($_REQUEST['uid']) : 0; @@ -69,18 +83,24 @@ function _doExecute() { if ($this->mObjectHandler->insert($this->mObject)) { + $avatarHandler =& xoops_getmodulehandler('avatar'); + + // + // 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'); - $criteria =& new Criteria('user_id', $this->mObject->get('uid')); - $linkHandler->deleteAll($criteria); + $linkHandler->deleteAllByUser($this->mObject); // // Insert new link. // - $avatarHandler =& xoops_getmodulehandler('avatar'); $criteria =& new Criteria('avatar_file', $this->mObject->get('user_avatar')); $avatarArr =& $avatarHandler->getObjects($criteria); if (is_array($avatarArr) && is_object($avatarArr[0])) {