1: <?php
2: if (!defined('XOOPS_ROOT_PATH')) die();
3:
4: class Message_Preload extends XCube_ActionFilter
5: {
6: public function postFilter()
7: {
8: $confhand = xoops_gethandler('config');
9: $conf = $confhand->getConfigsByDirname('message');
10: if ($this->mRoot->mContext->mUser->isInRole('Site.RegisteredUser')) {
11: require_once XOOPS_MODULE_PATH.'/message/service/Service.class.php';
12: $service = new Message_Service();
13: $service->prepare();
14:
15: $this->mRoot->mServiceManager->addService('privateMessage', $service);
16: if ( $conf['newalert'] == 1 ) {
17: $this->mRoot->mDelegateManager->add('Myfriend.NewAlert', 'Message_Preload::getNewMessage');
18: }
19: $this->mRoot->mDelegateManager->add('Legacypage.Viewpmsg.Access', 'Message_Preload::accessToReadpmsg');
20: $this->mRoot->mDelegateManager->add('Legacypage.Readpmsg.Access', 'Message_Preload::accessToReadpmsg');
21: $this->mRoot->mDelegateManager->add('Legacypage.Pmlite.Access', 'Message_Preload::accessToReadpmsg');
22: }
23: 24: 25: 26: 27:
28: $this->mRoot->mDelegateManager->add('Legacy.Event.GetHandler', 'Message_Preload::makeHandler');
29: $this->mRoot->mDelegateManager->add('Legacy_RenderSystem.SetupXoopsTpl', 'Message_Preload::addFilter');
30: }
31:
32: public static function addFilter(&$xoopsTpl)
33: {
34: $xoopsTpl->plugins_dir[] = XOOPS_MODULE_PATH.'/message/smarty';
35: }
36:
37: public static function getNewMessage(&$arrays)
38: {
39: $root = XCube_Root::getSingleton();
40: if ($root->mContext->mUser->isInRole('Site.RegisteredUser')) {
41: $uid = $root->mContext->mXoopsUser->get('uid');
42: $modHand = xoops_getmodulehandler('inbox', 'message');
43: $num = $modHand->getCountUnreadByFromUid($uid);
44: if ( $num > 0 ) {
45: $root->mLanguageManager->loadModuleMessageCatalog('message');
46: $arrays[] = array(
47: 'url' => XOOPS_MODULE_URL.'/message/index.php',
48: 'title' => XCube_Utils::formatString(_MD_MESSAGE_NEWMESSAGE, $num)
49: );
50: }
51: }
52: }
53:
54: public static function _createAction(&$actionFrame)
55: {
56: if (is_object($actionFrame->mAction)) {
57: return;
58: }
59:
60: switch (ucfirst($actionFrame->mActionName)) {
61: case 'UserInfo':
62: require XOOPS_MODULE_PATH.'/message/actions/userinfoAction.class.php';
63: $actionFrame->mAction = new UserinfoAction();
64: break;
65: }
66: }
67:
68: public static function accessToReadpmsg()
69: {
70: $root = XCube_Root::getSingleton();
71: $root->mController->executeForward(XOOPS_MODULE_URL.'/message/');
72: }
73:
74: public static function makeHandler(&$handler, $name, $optional)
75: {
76: if ( $name == 'privmessage' ) {
77: $handler = xoops_getmodulehandler('inbox', 'message', $optional);
78: }
79: }
80: }
81: ?>
82: