XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
MiscFriendAction.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 exit();
14}
15
16require_once XOOPS_MODULE_PATH . '/legacy/class/AbstractListAction.class.php';
17require_once XOOPS_MODULE_PATH . '/legacy/forms/MiscFriendForm.class.php';
18
19class Legacy_MiscFriendAction extends Legacy_Action
20{
21 public $mActionForm = null;
22 public $mMailer = null;
23
24 public function hasPermission(&$controller, &$xoopsUser)
25 {
26 return is_object($xoopsUser);
27 }
28
29 public function prepare(&$controller, &$xoopsUser)
30 {
31 $this->mActionForm =new Legacy_MiscFriendForm();
32 $this->mActionForm->prepare();
33 }
34
35 public function getDefaultView(&$controller, &$xoopsUser)
36 {
37 $this->mActionForm->load($xoopsUser);
38 return LEGACY_FRAME_VIEW_INPUT;
39 }
40
41 public function execute(&$controller, &$xoopsUser)
42 {
43 $this->mActionForm->fetch();
44 $this->mActionForm->validate();
45
46 if ($this->mActionForm->hasError()) {
47 return LEGACY_FRAME_VIEW_INPUT;
48 }
49
50 $root =& XCube_Root::getSingleton();
51
52 $this->mMailer =& getMailer();
53 $this->mMailer->setTemplate('tellfriend.tpl');
54 $this->mMailer->assign('SITENAME', $root->mContext->getXoopsConfig('sitename'));
55 $this->mMailer->assign('ADMINMAIL', $root->mContext->getXoopsConfig('adminmail'));
56 $this->mMailer->assign('SITEURL', XOOPS_URL . '/');
57
58 $this->mActionForm->update($this->mMailer);
59
60 $root->mLanguageManager->loadPageTypeMessageCatalog('misc');
61
62 $this->mMailer->setSubject(sprintf(_MSC_INTSITE, $root->mContext->getXoopsConfig('sitename')));
63
64 return $this->mMailer->send() ? LEGACY_FRAME_VIEW_SUCCESS : LEGACY_FRAME_VIEW_ERROR;
65 }
66
67 public function executeViewInput(&$controller, &$xoopsUser, &$render)
68 {
69 $render->setTemplateName('legacy_misc_friend.html');
70 $render->setAttribute('actionForm', $this->mActionForm);
71 }
72
73 public function executeViewSuccess(&$controller, &$xoopsUser, &$render)
74 {
75 $render->setTemplateName('legacy_misc_friend_success.html');
76 }
77
78 public function executeViewError(&$controller, &$xoopsUser, &$render)
79 {
80 $render->setTemplateName('legacy_misc_friend_error.html');
81 $render->setAttribute('xoopsMailer', $this->mMailer);
82 }
83}