1: <?php
2: if (!defined('XOOPS_ROOT_PATH')) exit();
3:
4: class Message_Service extends XCube_Service
5: {
6: public $mServiceName = 'Message_Service';
7: public $mNameSpace = 'Message';
8: public $mClassName = 'Message_Service';
9:
10: public function prepare()
11: {
12: $this->addFunction(S_PUBLIC_FUNC('string getPmInboxUrl(int uid)'));
13: $this->addFunction(S_PUBLIC_FUNC('string getPmliteUrl(int fromUid, int toUid)'));
14: $this->addFunction(S_PUBLIC_FUNC('int getCountUnreadPM(int uid)'));
15: }
16:
17: public function getPmInboxUrl()
18: {
19: $root = XCube_Root::getSingleton();
20: $uid = $root->mContext->mRequest->getRequest('uid');
21:
22: if ($uid > 0) {
23: return XOOPS_URL.'/modules/message/index.php';
24: }
25:
26: return "";
27: }
28:
29: public function getPmliteUrl()
30: {
31: $root = XCube_Root::getSingleton();
32:
33: $fromUid = $root->mContext->mRequest->getRequest('fromUid');
34: $toUid = $root->mContext->mRequest->getRequest('toUid');
35:
36: if ($fromUid > 0 && $toUid > 0) {
37: return XOOPS_URL.'/modules/message/index.php?action=new&to_userid='.$toUid;
38: }
39:
40: return "";
41: }
42:
43: public function getCountUnreadPM()
44: {
45: $root = XCube_Root::getSingleton();
46: $uid = $root->mContext->mRequest->getRequest('uid');
47:
48: if ($uid > 0) {
49: $modHand = xoops_getmodulehandler('inbox', 'message');
50: return $modHand->getCountUnreadByFromUid($uid);
51: }
52:
53: return 0;
54: }
55: }
56: ?>