XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
NotifyDeleteAction.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 exit();
14}
15
16require_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
17
18require_once XOOPS_MODULE_PATH . '/legacy/forms/NotifyDeleteForm.class.php';
19
20/***
21 * @internal
22 * List up notifications. This action is like notifications.php (when $op is
23 * 'list').
24 */
25class Legacy_NotifyDeleteAction extends Legacy_Action
26{
27 public $mModules = [];
28 public $mActionForm = null;
29
30 public $mErrorMessage = null;
31
32 public function prepare(&$controller, &$xoopsUser)
33 {
34 $controller->mRoot->mLanguageManager->loadPageTypeMessageCatalog('notification');
35 $controller->mRoot->mLanguageManager->loadModuleMessageCatalog('legacy');
36
37 $this->mActionForm =new Legacy_NotifyDeleteForm();
38 $this->mActionForm->prepare();
39 }
40
41 public function hasPermission(&$controller, &$xoopsUser)
42 {
43 return is_object($xoopsUser);
44 }
45
53 public function execute(&$contoller, &$xoopsUser)
54 {
55 $this->mActionForm->fetch();
56 $this->mActionForm->validate();
57
58 //
59 // If input values are error, the action form returns fatal error flag.
60 // If it's not fatal, display confirm form.
61 //
62 if ($this->mActionForm->hasError()) {
63 return $this->mActionForm->mFatalError ? LEGACY_FRAME_VIEW_ERROR : LEGACY_FRAME_VIEW_INPUT;
64 }
65
66 //
67 // Execute deleting.
68 //
69 $successFlag = true;
70 $handler =& xoops_gethandler('notification');
71 foreach ($this->mActionForm->mNotifiyIds as $t_idArr) {
72 $t_notify =& $handler->get($t_idArr['id']);
73 if (is_object($t_notify) && $t_notify->get('not_uid') == $xoopsUser->get('uid') && $t_notify->get('not_modid') == $t_idArr['modid']) {
74 $successFlag = $successFlag & $handler->delete($t_notify);
75 }
76 }
77
78 return $successFlag ? LEGACY_FRAME_VIEW_SUCCESS : LEGACY_FRAME_VIEW_ERROR;
79 }
80
81 public function executeViewInput(&$controller, &$xoopsUser, &$render)
82 {
83 $render->setTemplateName('legacy_notification_delete.html');
84 $render->setAttribute('actionForm', $this->mActionForm);
85 }
86
87 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
88 {
89 $controller->executeForward(XOOPS_URL . '/notifications.php');
90 }
91
92 public function executeViewError(&$controller, &$xoopsUser, &$render)
93 {
94 $controller->executeRedirect(XOOPS_URL . '/notifications.php', 2, _NOT_NOTHINGTODELETE);
95 }
96}
execute(&$contoller, &$xoopsUser)