Minahito
minah****@users*****
2006年 7月 13日 (木) 19:45:42 JST
Index: xoops2jp/html/modules/user/admin/actions/MailjobSendAction.class.php diff -u xoops2jp/html/modules/user/admin/actions/MailjobSendAction.class.php:1.1.2.2 xoops2jp/html/modules/user/admin/actions/MailjobSendAction.class.php:1.1.2.3 --- xoops2jp/html/modules/user/admin/actions/MailjobSendAction.class.php:1.1.2.2 Wed May 24 18:44:11 2006 +++ xoops2jp/html/modules/user/admin/actions/MailjobSendAction.class.php Thu Jul 13 19:45:42 2006 @@ -9,11 +9,7 @@ var $mMailjob = null; var $mActionForm = null; - function User_MailjobSendAction() - { - } - - function prepare(&$controller, &$xoopsUser) + function prepare(&$controller, &$xoopsUser, $moduleConfig) { $id = intval(xoops_getrequest('mailjob_id')); @@ -35,7 +31,7 @@ } // - // + // lazy load // $this->mMailjob->loadUser(); @@ -57,11 +53,11 @@ $root =& XCube_Root::getSingleton(); if ($this->mMailjob->get('is_pm')) { - $root->mEventManager->add("Module.User.Mailjob.Send", new XCube_InstanceDelegate($this, "sendPM")); + $this->mMailjob->mSend->add(array(&$this, "sendPM")); } if ($this->mMailjob->get('is_mail')) { - $root->mEventManager->add("Module.User.Mailjob.Send", new XCube_InstanceDelegate($this, "sendMail")); + $this->mMailjob->mSend->add(array(&$this, "sendMail")); } $this->mMailjob->send($xoopsUser); @@ -78,11 +74,7 @@ function executeViewError(&$controller, &$xoopsUser, &$render) { - XCube_Utils::redirectHeader('./index.php?action=MailjobList', 1, _AD_USER_ERROR_MAILJOB_SEND_FAIL); - } - - function executeViewIndex(&$controller, &$xoopsUser, &$render) - { + $controller->executeRedirect('./index.php?action=MailjobList', 1, _AD_USER_ERROR_MAILJOB_SEND_FAIL); } function executeViewInput(&$controller, &$xoopsUser, &$render) @@ -92,35 +84,26 @@ $render->setAttribute('actionForm', $this->mActionForm); } - function sendPM(&$sender, &$eventArgs) + /** + * [Notice] + * Until private message will come to implement Service, we use pm object + * directly. + */ + function sendPM(&$mailjob, &$to_user, &$from_user) { - $root =& XCube_Root::getSingleton(); - $serviceMgr =& $root->getServiceManager(); - $pmService =& $serviceMgr->searchXCubeService('PrivateMessage'); + $handler =& xoops_gethandler('privmessage'); - $pmClient =& new XCube_ServiceClient($pmService); + $pm =& $handler->create(); - // - // Convert body message. - // - $replaceEventArgs = array(); - $replaceEventArgs['body'] = $eventArgs['mailjob']->get('body'); - $replaceEventArgs['to_user'] =& $eventArgs['to_user']; - $replaceEventArgs['from_user'] =& $eventArgs['from_user']; - $replaceEventArgs['mailjob'] =& $eventArgs['mailjob']; - $root->mEventManager->raiseEvent('Module.User.Mailjob.ReplaceBody', $this, $replaceEventArgs); + $pm->set('subject', $mailjob->getReplaceTitle($to_user, $from_user)); + $pm->set('msg_text', $mailjob->getReplaceBody($to_user, $from_user)); + $pm->set('from_userid', $from_user->get('uid')); + $pm->set('to_userid', $to_user->get('uid')); - $param = array( - 'to_uid' => $eventArgs['to_user']->get('uid'), - 'from_uid' => $eventArgs['from_user']->get('uid'), - 'subject' => $eventArgs['mailjob']->get('title'), - 'message' => $replaceEventArgs['body'] - ); - - $result =& $pmClient->call('send', $param); + $handler->insert($pm); } - function sendMail(&$sender, &$eventArgs) + function sendMail(&$mailjob, $to_user, $from_user) { $xoopsMailer =& getMailer(); $xoopsMailer->useMail(); @@ -128,27 +111,16 @@ // // Set To // - $xoopsMailer->setToUsers($eventArgs['to_user']); + $xoopsMailer->setToUsers($to_user); // // Set From // - $xoopsMailer->setFromEmail($eventArgs['mailjob']->get('from_email')); - $xoopsMailer->setFromName($eventArgs['mailjob']->get('from_name')); + $xoopsMailer->setFromEmail($mailjob->get('from_email')); + $xoopsMailer->setFromName($mailjob->get('from_name')); - // - // Convert body message. - // - $replaceEventArgs = array(); - $replaceEventArgs['body'] = $eventArgs['mailjob']->get('body'); - $replaceEventArgs['to_user'] =& $eventArgs['to_user']; - $replaceEventArgs['from_user'] =& $eventArgs['from_user']; - $replaceEventArgs['mailjob'] =& $eventArgs['mailjob']; - - $root =& XCube_Root::getSingleton(); - $root->mEventManager->raiseEvent('Module.User.Mailjob.ReplaceBody', $this, $replaceEventArgs); - - $xoopsMailer->setBody($replaceEventArgs['body']); + $xoopsMailer->setSubject($mailjob->getReplaceTitle($to_user, $from_user)); + $xoopsMailer->setBody($mailjob->getReplaceBody($to_user, $from_user)); // // TODO Error handling.