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