Пример #1
0
 /**
  * Class constructor
  */
 private function __construct()
 {
     $this->conversationDao = MAILBOX_BOL_ConversationDao::getInstance();
     $this->lastMessageDao = MAILBOX_BOL_LastMessageDao::getInstance();
     $this->messageDao = MAILBOX_BOL_MessageDao::getInstance();
     $this->attachmentDao = MAILBOX_BOL_AttachmentDao::getInstance();
 }
Пример #2
0
 public function sendReport($params)
 {
     $userId = OW::getUser()->getId();
     if (!$userId) {
         throw new ApiResponseErrorException();
     }
     if (empty($params['entityId']) || empty($params['entityType']) || !isset($params['reason'])) {
         throw new ApiResponseErrorException();
     }
     $entityId = $params['entityId'];
     $entityType = $params['entityType'];
     $userService = BOL_UserService::getInstance();
     $lang = OW::getLanguage();
     $reasons = array(0 => 'spam', 1 => 'offensive', 2 => 'illegal');
     $reason = $lang->text('skadateios', $reasons[$params['reason']]);
     $user = $userService->findUserById($userId);
     $assigns = array('reason' => $reason, 'reportedUserUrl' => OW_URL_HOME . 'user/' . $user->getUsername());
     switch ($entityType) {
         case 'photo':
             if (!is_numeric($entityId)) {
                 $name = substr($entityId, strrpos($entityId, '/') + 1);
                 $parts = explode("_", $name);
                 $entityId = $parts[1];
             }
             $ownerId = PHOTO_BOL_PhotoService::getInstance()->findPhotoOwner($entityId);
             $reportedUser = $userService->findUserById($ownerId);
             if (!$reportedUser) {
                 throw new ApiResponseErrorException();
             }
             $assigns['userUrl'] = OW_URL_HOME . 'photo/view/' . $entityId . '/latest';
             break;
         case 'avatar':
             $ownerId = $entityId;
             $reportedUser = $userService->findUserById($ownerId);
             if (!$reportedUser) {
                 throw new ApiResponseErrorException();
             }
             $assigns['userUrl'] = OW_URL_HOME . 'user/' . $reportedUser->getUsername();
             break;
         case 'attachment':
             $attachment = MAILBOX_BOL_AttachmentDao::getInstance()->findById($entityId);
             $ext = UTIL_File::getExtension($attachment->fileName);
             $attachmentPath = MAILBOX_BOL_ConversationService::getInstance()->getAttachmentFilePath($attachment->id, $attachment->hash, $ext, $attachment->fileName);
             $assigns['userUrl'] = OW::getStorage()->getFileUrl($attachmentPath);
             break;
         default:
         case 'profile':
             $ownerId = $entityId;
             $reportedUser = $userService->findUserById($ownerId);
             if (!$reportedUser) {
                 throw new ApiResponseErrorException();
             }
             $assigns['userUrl'] = OW_URL_HOME . 'user/' . $reportedUser->getUsername();
             break;
     }
     $subject = $lang->text('skadateios', 'user_reported_subject');
     $text = $lang->text('skadateios', 'user_reported_notification_text', $assigns);
     $html = $lang->text('skadateios', 'user_reported_notification_html', $assigns);
     try {
         $email = OW::getConfig()->getValue('base', 'site_email');
         $mail = OW::getMailer()->createMail()->addRecipientEmail($email)->setTextContent($text)->setHtmlContent($html)->setSubject($subject);
         OW::getMailer()->send($mail);
     } catch (Exception $e) {
         throw new ApiResponseErrorException();
     }
 }
Пример #3
0
 public function findConversationsWithAttachmentFromConversationList($conversationIdList)
 {
     $condition = $this->dbo->mergeInClause($conversationIdList);
     $sql = "SELECT `m`.`conversationId` FROM `" . MAILBOX_BOL_AttachmentDao::getInstance()->getTableName() . "` as a\nINNER JOIN `" . MAILBOX_BOL_MessageDao::getInstance()->getTableName() . "` as m ON `m`.`id` = `a`.`messageId`\nWHERE conversationId IN ({$condition})\nGROUP BY `m`.`conversationId`";
     return $this->dbo->queryForColumnList($sql);
 }