XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
AbstractEditAction.class.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
15class Profile_AbstractEditAction extends Profile_AbstractAction
16{
17 public $mObject = null;
18 public $mObjectHandler = null;
19 public $mActionForm = null;
20
24 public function _getId()
25 {
26 }
27
31 public function &_getHandler()
32 {
33 }
34
38 public function _setupActionForm()
39 {
40 }
41
45 public function _setupObject()
46 {
47 $id = $this->_getId();
48
49 $this->mObjectHandler =& $this->_getHandler();
50
51 $this->mObject =& $this->mObjectHandler->get($id);
52
53 if (null == $this->mObject && $this->_isEnableCreate()) {
54 $this->mObject =& $this->mObjectHandler->create();
55 }
56 }
57
61 public function _isEnableCreate()
62 {
63 return true;
64 }
65
69 public function prepare()
70 {
71 $this->_setupObject();
72 $this->_setupActionForm();
73 }
74
78 public function getDefaultView()
79 {
80 if (null == $this->mObject) {
81 return PROFILE_FRAME_VIEW_ERROR;
82 }
83
84 $this->mActionForm->load($this->mObject);
85
86 return PROFILE_FRAME_VIEW_INPUT;
87 }
88
92 public function execute()
93 {
94 if (null == $this->mObject) {
95 return PROFILE_FRAME_VIEW_ERROR;
96 }
97
98 if (null != xoops_getrequest('_form_control_cancel')) {
99 return PROFILE_FRAME_VIEW_CANCEL;
100 }
101
102 $this->mActionForm->load($this->mObject);
103
104 $this->mActionForm->fetch();
105 $this->mActionForm->validate();
106
107 if ($this->mActionForm->hasError()) {
108 return PROFILE_FRAME_VIEW_INPUT;
109 }
110
111 $this->mActionForm->update($this->mObject);
112
113 return $this->_doExecute();
114 }
115
119 public function _doExecute()
120 {
121 if ($this->mObjectHandler->insert($this->mObject)) {
122 return PROFILE_FRAME_VIEW_SUCCESS;
123 }
124
125 return PROFILE_FRAME_VIEW_ERROR;
126 }
127}