1: <?php
2:
3: if (!defined('XOOPS_ROOT_PATH')) exit();
4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17: class Profile_ActionFrame
18: {
19: var $mActionName = null;
20: var $mAction = null;
21: var $mAdminFlag = null;
22:
23: 24: 25:
26: var $mCreateAction = null;
27:
28: function Profile_ActionFrame($admin)
29: {
30: $this->mAdminFlag = $admin;
31: $this->mCreateAction =new XCube_Delegate();
32: $this->mCreateAction->register('Profile_ActionFrame.CreateAction');
33: $this->mCreateAction->add(array(&$this, '_createAction'));
34: }
35:
36: function setActionName($name)
37: {
38: $this->mActionName = $name;
39:
40:
41:
42:
43: $root =& XCube_Root::getSingleton();
44: $root->mContext->setAttribute('actionName', $name);
45: $root->mContext->mModule->setAttribute('actionName', $name);
46: }
47:
48: function _createAction(&$actionFrame)
49: {
50: if (is_object($this->mAction)) {
51: return;
52: }
53:
54:
55:
56:
57: $className = "Profile_" . ucfirst($actionFrame->mActionName) . "Action";
58: $fileName = ucfirst($actionFrame->mActionName) . "Action";
59: if ($actionFrame->mAdminFlag) {
60: $fileName = XOOPS_MODULE_PATH . "/profile/admin/actions/${fileName}.class.php";
61: }
62: else {
63: $fileName = XOOPS_MODULE_PATH . "/profile/actions/${fileName}.class.php";
64: }
65:
66: if (!file_exists($fileName)) {
67: die("file_exists on _createAction");
68: }
69:
70: require_once $fileName;
71:
72: if (XC_CLASS_EXISTS($className)) {
73: $actionFrame->mAction =new $className($actionFrame->mAdminFlag);
74: }
75: }
76:
77: function execute(&$controller)
78: {
79: if (!preg_match("/^\w+$/", $this->mActionName)) {
80: die();
81: }
82:
83:
84:
85:
86: $this->mCreateAction->call(new XCube_Ref($this));
87:
88: if (!(is_object($this->mAction) && is_a($this->mAction, 'Profile_Action'))) {
89: die();
90: }
91:
92: if ($this->mAction->isSecure() && !is_object($controller->mRoot->mContext->mXoopsUser)) {
93:
94:
95:
96:
97: $controller->executeForward(XOOPS_URL . '/');
98: }
99:
100: $this->mAction->prepare($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModuleConfig);
101:
102: if (!$this->mAction->hasPermission($controller, $controller->mRoot->mContext->mXoopsUser, $controller->mRoot->mContext->mModuleConfig)) {
103:
104:
105:
106:
107: $controller->executeForward(XOOPS_URL . '/');
108: }
109:
110: if (xoops_getenv("REQUEST_METHOD") == "POST") {
111: $viewStatus = $this->mAction->execute($controller, $controller->mRoot->mContext->mXoopsUser);
112: }
113: else {
114: $viewStatus = $this->mAction->getDefaultView($controller, $controller->mRoot->mContext->mXoopsUser);
115: }
116:
117: $render = $controller->mRoot->mContext->mModule->getRenderTarget();
118: $render->setAttribute('xoops_pagetitle', $this->mAction->getPagetitle());
119: echo ($viewStatus); die;
120: switch($viewStatus) {
121: case PROFILE_FRAME_VIEW_SUCCESS:
122: $this->mAction->executeViewSuccess($render);
123: break;
124:
125: case PROFILE_FRAME_VIEW_ERROR:
126: $this->mAction->executeViewError($controller, $controller->mRoot->mContext->mXoopsUser, $render);
127: break;
128:
129: case PROFILE_FRAME_VIEW_INDEX:
130: $this->mAction->executeViewIndex($controller, $controller->mRoot->mContext->mXoopsUser, $render);
131: break;
132:
133: case PROFILE_FRAME_VIEW_INPUT:
134: $this->mAction->executeViewInput($controller, $controller->mRoot->mContext->mXoopsUser, $render);
135: break;
136:
137: case PROFILE_FRAME_VIEW_PREVIEW:
138: $this->mAction->executeViewPreview($controller, $controller->mRoot->mContext->mXoopsUser, $render);
139: break;
140:
141: case PROFILE_FRAME_VIEW_CANCEL:
142: $this->mAction->executeViewCancel($controller, $controller->mRoot->mContext->mXoopsUser, $render);
143: break;
144: }
145: }
146: }
147:
148: class Profile_Action
149: {
150: function Profile_Action()
151: {
152: }
153:
154: function isSecure()
155: {
156: return false;
157: }
158:
159: 160: 161: 162: 163: 164: 165:
166: protected function _getPageAction()
167: {
168: return null;
169: }
170:
171: 172: 173: 174: 175: 176: 177:
178: protected function _getPagetitle()
179: {
180: return null;
181: }
182:
183: public function getPageTitle()
184: {
185: return Legacy_Utils::formatPagetitle(XCube_Root::getSingleton()->mContext->mModule->mXoopsModule->get('name'), $this->_getPagetitle(), $this->_getPageAction());
186: }
187:
188: function hasPermission(&$controller, &$xoopsUser, $moduleConfig)
189: {
190: return true;
191: }
192:
193: function prepare(&$controller, &$xoopsUser, &$moduleConfig)
194: {
195: }
196:
197: function getDefaultView(&$controller, &$xoopsUser)
198: {
199: return PROFILE_FRAME_VIEW_NONE;
200: }
201:
202: function execute(&$controller, &$xoopsUser)
203: {
204: return PROFILE_FRAME_VIEW_NONE;
205: }
206:
207: function executeViewSuccess( &$render)
208: {
209: }
210:
211: function executeViewError(&$render)
212: {
213: }
214:
215: function executeViewInde(&$render)
216: {
217: }
218:
219: function executeViewInput(&$render)
220: {
221: }
222:
223: function executeViewPreview(&$render)
224: {
225: }
226:
227: function executeViewCancel(&$render)
228: {
229: }
230: }
231:
232: ?>
233: