1: <?php
2: if (!defined('XOOPS_ROOT_PATH')) exit();
3: require _MY_MODULE_PATH.'forms/MessageSettingsForm.class.php';
4:
5: class settingsAction extends AbstractAction
6: {
7: private $mActionForm;
8:
9: public function __construct()
10: {
11: parent::__construct();
12: $this->mActionForm = new MessageSettingsForm();
13: $this->mActionForm->prepare();
14: }
15:
16: public function execute()
17: {
18: $modHand = xoops_getmodulehandler('settings', _MY_DIRNAME);
19: $modObj = $modHand->get($this->root->mContext->mXoopsUser->get('uid'));
20: if ( !is_object($modObj) ) {
21: $modObj = $modHand->create();
22: }
23: $this->mActionForm->load($modObj);
24: if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
25: $this->mActionForm->fetch();
26: $this->mActionForm->validate();
27: if ($this->mActionForm->hasError()) {
28: $this->setErr($this->mActionForm->getErrorMessages());
29: } else {
30: $this->setUrl('index.php?action=settings');
31: $this->mActionForm->update($modObj);
32: if ( !$modHand->insert($modObj) ) {
33: $this->setErr(_MD_MESSAGE_SETTINGS_MSG4);
34: } else {
35: $this->setErr(_MD_MESSAGE_SETTINGS_MSG3);
36: }
37: }
38: }
39: }
40:
41: public function executeView(&$render)
42: {
43: $render->setTemplateName('message_settings.html');
44: $render->setAttribute('mActionForm', $this->mActionForm);
45: }
46: }
47: ?>
48: