コード例 #1
0
ファイル: event_handler.php プロジェクト: tammyrocks/mailbox
 public function onAttachmentUpload(OW_Event $event)
 {
     $params = $event->getParams();
     if ($params['pluginKey'] != 'mailbox') {
         return;
     }
     //mailbox_dialog_{convId}_{opponentId}_{hash}
     $uidParams = explode('_', $params['uid']);
     if (count($uidParams) != 5) {
         return;
     }
     if ($uidParams[0] != 'mailbox') {
         return;
     }
     if ($uidParams[1] != 'dialog') {
         return;
     }
     $conversationId = $uidParams[2];
     $userId = OW::getUser()->getId();
     //        $opponentId = $uidParams[3];
     $files = $params['files'];
     if (!empty($files)) {
         $conversation = $this->service->getConversation($conversationId);
         try {
             $message = $this->service->createMessage($conversation, $userId, OW::getLanguage()->text('mailbox', 'attachment'));
             $this->service->addMessageAttachments($message->id, $files);
         } catch (InvalidArgumentException $e) {
         }
     }
 }