XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
AbstractAction.class.php
1<?php
12
13if (!defined('XOOPS_ROOT_PATH')) {
14 exit();
15}
16
17define('_USE_XOOPSMAILER', false);
18
19abstract class AbstractAction
20{
21 protected $isError = false;
22 protected $errMsg = '';
23 protected $root;
24 protected $url = 'index.php';
25 protected $unamelink = [];
26
27 public function __construct()
28 {
29 $this->root = XCube_Root::getSingleton();
30 }
31
32 protected function setUrl($url)
33 {
34 $this->url = $url;
35 }
36
37 public function getUrl()
38 {
39 return $this->url;
40 }
41
42 protected function setErr($msg)
43 {
44 $this->isError = true;
45 $this->errMsg = $msg;
46 }
47
48 public function getisError()
49 {
50 return $this->isError;
51 }
52
53 public function geterrMsg()
54 {
55 return $this->errMsg;
56 }
57
58 public function chk_use($uid = 0)
59 {
60 $modObj = $this->getSettings($uid);
61 return 1 === $modObj->get('usepm');
62 }
63
64 public function getSettings($uid = 0)
65 {
66 if (0 === $uid) {
67 $uid = $this->root->mContext->mXoopsUser->get('uid');
68 }
69
70 $modHand = xoops_getmodulehandler('settings', _MY_DIRNAME);
71 $modObj = $modHand->get($uid);
72 if (!is_object($modObj)) {
73 $modObj = $modHand->create();
74 $modObj->set('uid', $uid);
75 }
76 return $modObj;
77 }
78
79 public function getLinkUnameFromId($uid, $uname = '')
80 {
81 $uid = (int)$uid;
82
83 if ($uid > 0) {
84 if (isset($this->unamelink[$uid])) {
85 return $this->unamelink[$uid];
86 }
87 $mhandler = xoops_gethandler('member');
88 $user = $mhandler->getUser($uid);
89 if (is_object($user)) {
90 $this->unamelink[$uid] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$uid.'">'. $user->getVar('uname').'</a>';
91 return $this->unamelink[$uid];
92 }
93 return $this->root->mContext->mXoopsConfig['anonymous'];
94 }
95
96 return $uname;
97 }
98
99 protected function getMailer()
100 {
101 $classname = 'XoopsMailer';
102 if (_USE_XOOPSMAILER == true) {
103 require_once XOOPS_ROOT_PATH.'/class/xoopsmailer.php';
104 if (is_file(XOOPS_ROOT_PATH.'/language/'.$this->root->mLanguageManager->mLanguageName.'/xoopsmailerlocal.php')) {
105 require_once XOOPS_ROOT_PATH.'/language/'.$this->root->mLanguageManager->mLanguageName.'/xoopsmailerlocal.php';
106 if (XC_CLASS_EXISTS('XoopsMailerLocal')) {
107 $classname = 'XoopsMailerLocal';
108 }
109 }
110 } else {
111 require XOOPS_ROOT_PATH .'/class/mail/phpmailer/src/PHPMailer.php';
112 require_once _MY_MODULE_PATH.'class/MyMailer.class.php';
113 $classname = 'My_Mailer';
114 }
115 return new $classname();
116 }
117
118 abstract public function execute();
119 abstract public function executeView(&$render);
120}