1: <?php
2: 3: 4: 5:
6:
7: if (!defined('XOOPS_ROOT_PATH')) exit();
8:
9: require_once XOOPS_MODULE_PATH . "/user/class/AbstractDeleteAction.class.php";
10: require_once XOOPS_MODULE_PATH . "/user/admin/forms/AvatarAdminDeleteForm.class.php";
11:
12: class User_AvatarDeleteAction extends User_AbstractDeleteAction
13: {
14: function _getId()
15: {
16: return xoops_getrequest('avatar_id');
17: }
18:
19: function &_getHandler()
20: {
21: $handler =& xoops_getmodulehandler('avatar');
22: return $handler;
23: }
24:
25: function _setupActionForm()
26: {
27: $this->mActionForm =new User_AvatarAdminDeleteForm();
28: $this->mActionForm->prepare();
29: }
30:
31: function _doExecute()
32: {
33: $linkHandler =& xoops_getmodulehandler('avatar_user_link');
34: $criteria =new Criteria('avatar_id', $this->mObject->get('avatar_id'));
35: $linkArr =& $linkHandler->getObjects($criteria);
36:
37: if ($this->mObjectHandler->delete($this->mObject)) {
38:
39:
40:
41: if (count($linkArr) > 0) {
42: $userHandler =& xoops_gethandler('user');
43: foreach ($linkArr as $link) {
44: $user =& $userHandler->get($link->get('user_id'));
45:
46: if (is_object($user)) {
47: $user->set('user_avatar', 'blank.gif');
48: $userHandler->insert($user);
49: }
50: unset($user);
51: }
52: }
53:
54: return true;
55: }
56: else {
57: return false;
58: }
59: }
60:
61: function executeViewInput(&$controller, &$xoopsUser, &$render)
62: {
63: $render->setTemplateName("avatar_delete.html");
64: $render->setAttribute('actionForm', $this->mActionForm);
65: $render->setAttribute('object', $this->mObject);
66: }
67:
68: function executeViewSuccess(&$controller, &$xoopsUser, &$render)
69: {
70: $controller->executeForward("./index.php?action=AvatarList");
71: }
72:
73: function executeViewError(&$controller, &$xoopsUser, &$render)
74: {
75: $controller->executeRedirect("./index.php?action=AvatarList", 1, _MD_USER_ERROR_DBUPDATE_FAILED);
76: }
77:
78: function executeViewCancel(&$controller, &$xoopsUser, &$render)
79: {
80: $controller->executeForward("./index.php?action=AvatarList");
81: }
82: }
83:
84: ?>
85: