1: <?php
2: if (!defined('XOOPS_ROOT_PATH')) exit();
3:
4: class viewAction extends AbstractAction
5: {
6: private $inout = 'inbox';
7: private $msgdata = null;
8:
9: public function __construct()
10: {
11: parent::__construct();
12: }
13:
14: public function execute()
15: {
16: if ( $this->root->mContext->mRequest->getRequest('inout') == 'in' ) {
17: $this->inout = 'inbox';
18: } else {
19: $this->inout = 'outbox';
20: }
21:
22: $boxid = intval($this->root->mContext->mRequest->getRequest($this->inout));
23: $modHand = xoops_getmodulehandler($this->inout);
24: $modObj = $modHand->get($boxid);
25: if ( !is_object($modObj) ) {
26: $this->setErr(_MD_MESSAGE_ACTIONMSG1);
27: return;
28: }
29:
30: if ( $modObj->get('uid') != $this->root->mContext->mXoopsUser->get('uid') ) {
31: $this->setErr(_MD_MESSAGE_ACTIONMSG8);
32: return;
33: }
34:
35: if ( $this->inout == 'inbox' ) {
36: if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
37: if ( $this->root->mContext->mRequest->getRequest('cmd') == 'lock' ) {
38: if ( intval($this->root->mContext->mRequest->getRequest('lock')) == 1 ) {
39: $modObj->set('is_read', 2);
40: } else {
41: $modObj->set('is_read', 1);
42: }
43: $modHand->insert($modObj);
44: } elseif ( $this->root->mContext->mRequest->getRequest('cmd') == 'mail' ) {
45: $this->send_mail($modObj);
46: }
47: } elseif ( $modObj->get('is_read') == 0 ) {
48: $modObj->set('is_read', 1);
49: $modHand->insert($modObj, true);
50: }
51: }
52:
53: foreach ( array_keys($modObj->gets()) as $var_name ) {
54: $this->msgdata[$var_name] = $modObj->getShow($var_name);
55: }
56: if ( $this->inout == 'inbox' ) {
57: $this->msgdata['fromname'] = $this->getLinkUnameFromId($this->msgdata['from_uid'], $this->msgdata['uname']);
58: } else {
59: $this->msgdata['toname'] = $this->getLinkUnameFromId($this->msgdata['to_uid'], $this->root->mContext->mXoopsConfig['anonymous']);
60: }
61: }
62:
63: private function send_mail(&$obj)
64: {
65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76:
77: $mailer = $this->getMailer();
78: $mailer->setFromName($this->root->mContext->mXoopsConfig['sitename']);
79: $mailer->setFromEmail($this->root->mContext->mXoopsConfig['adminmail']);
80: $mailer->setToEmails($this->root->mContext->mXoopsUser->get('email'));
81: $mailer->setSubject($obj->get('title'));
82: $mailer->setBody($obj->get('message'));
83: $mailer->send();
84:
85: }
86:
87: public function executeView(&$render)
88: {
89: if ( $this->inout == 'inbox' ) {
90: $render->setTemplateName('message_inboxview.html');
91: } else {
92: $render->setTemplateName('message_outboxview.html');
93: }
94: $render->setAttribute('msgdata', $this->msgdata);
95: }
96: }
97: ?>
98: