Minahito
minah****@users*****
2006年 3月 8日 (水) 19:21:50 JST
Index: xoops2jp/html/modules/user/admin/actions/AvatarEditAction.class.php diff -u xoops2jp/html/modules/user/admin/actions/AvatarEditAction.class.php:1.1.2.2 xoops2jp/html/modules/user/admin/actions/AvatarEditAction.class.php:1.1.2.3 --- xoops2jp/html/modules/user/admin/actions/AvatarEditAction.class.php:1.1.2.2 Thu Jan 26 20:11:18 2006 +++ xoops2jp/html/modules/user/admin/actions/AvatarEditAction.class.php Wed Mar 8 19:21:50 2006 @@ -29,10 +29,30 @@ if (!$this->mActionForm->mFormFile->saveAs(XOOPS_UPLOAD_PATH)) { return false; } - } - - if ($this->mActionForm->mOldFileName != null && $this->mActionForm->mOldFileName != "blank.gif") { + + if ($this->mActionForm->mOldFileName != null && $this->mActionForm->mOldFileName != "blank.gif") { @unlink(XOOPS_UPLOAD_PATH . "/" . $this->mActionForm->mOldFileName); + + // + // Change user_avatar of all users who are setting this avatar. + // + if (!$this->mObject->isNew()) { + $linkHandler =& xoops_getmodulehandler('avatar_user_link'); + $criteria =& new Criteria('avatar_id', $this->mObject->get('avatar_id')); + $linkArr =& $linkHandler->getObjects($criteria); + + $userHandler =& xoops_gethandler('user'); + foreach ($linkArr as $link) { + $user =& $userHandler->get($link->get('user_id')); + + if (is_object($user)) { + $user->set('user_avatar', $this->mObject->get('avatar_file')); + $userHandler->insert($user); + } + unset($user); + } + } + } } return parent::_doExecute();