XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
Preload.class.php
1<?php
12
13if (!defined('XOOPS_ROOT_PATH')) {
14 die();
15}
16
18{
19 public function postFilter()
20 {
21 $confhand = xoops_gethandler('config');
22 $conf = $confhand->getConfigsByDirname('message');
23 if ($this->mRoot->mContext->mUser->isInRole('Site.RegisteredUser')) {
24 require_once XOOPS_MODULE_PATH.'/message/service/Service.class.php';
25 $service = new Message_Service();
26 $service->prepare();
27
28 $this->mRoot->mServiceManager->addService('privateMessage', $service);
29 if (1 == $conf['newalert']) {
30 $this->mRoot->mDelegateManager->add('Myfriend.NewAlert', 'Message_Preload::getNewMessage');
31 }
32 $this->mRoot->mDelegateManager->add('Legacypage.Viewpmsg.Access', 'Message_Preload::accessToReadpmsg');
33 $this->mRoot->mDelegateManager->add('Legacypage.Readpmsg.Access', 'Message_Preload::accessToReadpmsg');
34 $this->mRoot->mDelegateManager->add('Legacypage.Pmlite.Access', 'Message_Preload::accessToReadpmsg');
35 }
36 /*
37 if ( $conf['userinfo'] == 1 ) {
38 $this->mRoot->mDelegateManager->add('User_ActionFrame.CreateAction', 'Message_Preload::_createAction', XCUBE_DELEGATE_PRIORITY_FIRST);
39 }
40 */
41 $this->mRoot->mDelegateManager->add('Legacy.Event.GetHandler', 'Message_Preload::makeHandler');
42 $this->mRoot->mDelegateManager->add('Legacy_RenderSystem.SetupXoopsTpl', 'Message_Preload::addFilter');
43 }
44
45 public static function addFilter(&$xoopsTpl)
46 {
47 $xoopsTpl->plugins_dir[] = XOOPS_MODULE_PATH.'/message/smarty';
48 }
49
50 public static function getNewMessage(&$arrays)
51 {
52 $root = XCube_Root::getSingleton();
53 if ($root->mContext->mUser->isInRole('Site.RegisteredUser')) {
54 $uid = $root->mContext->mXoopsUser->get('uid');
55 $modHand = xoops_getmodulehandler('inbox', 'message');
56 $num = $modHand->getCountUnreadByFromUid($uid);
57 if ($num > 0) {
58 $root->mLanguageManager->loadModuleMessageCatalog('message');
59 $arrays[] = [
60 'url' => XOOPS_MODULE_URL.'/message/index.php',
61 'title' => XCube_Utils::formatString(_MD_MESSAGE_NEWMESSAGE, $num)
62 ];
63 }
64 }
65 }
66
67 public static function _createAction(&$actionFrame)
68 {
69 if (is_object($actionFrame->mAction)) {
70 return;
71 }
72
73 switch (ucfirst($actionFrame->mActionName)) {
74 case 'UserInfo':
75 require XOOPS_MODULE_PATH.'/message/actions/userinfoAction.class.php';
76 $actionFrame->mAction = new UserinfoAction();
77 break;
78 }
79 }
80
81 public static function accessToReadpmsg()
82 {
83 $root = XCube_Root::getSingleton();
84 $root->mController->executeForward(XOOPS_MODULE_URL.'/message/');
85 }
86
87 public static function makeHandler(&$handler, $name, $optional)
88 {
89 if ('privmessage' == $name) {
90 $handler = xoops_getmodulehandler('inbox', 'message', $optional);
91 }
92 }
93}
postFilter()
[Abstract] Executes the logic, when the controller executes postFilter().
static formatString()
[Static] Formats string with special care for international.