Beispiel #1
0
 /**
  * Returns class instance
  *
  * @return MAILBOX_BOL_AttachmentDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Beispiel #2
0
 /**
  *
  * @param array $conversationIdList
  * @return array<MAILBOX_BOL_Attachment>
  */
 public function deleteAttachmentsByConversationList(array $conversationIdList)
 {
     $attachmentList = $this->attachmentDao->findAttachmentstByConversationList($conversationIdList);
     foreach ($attachmentList as $attachment) {
         $ext = UTIL_File::getExtension($attachment['fileName']);
         $path = $this->getAttachmentFilePath($attachment['id'], $attachment['hash'], $ext);
         if (OW::getStorage()->removeFile($path)) {
             $this->attachmentDao->deleteById($attachment['id']);
         }
     }
 }
 public function deleteAttachmentFiles()
 {
     $attachDtoList = $this->attachmentDao->getAttachmentForDelete();
     foreach ($attachDtoList as $attachDto) {
         /* @var $attachDto MAILBOX_BOL_Attachment */
         $ext = UTIL_File::getExtension($attachDto->fileName);
         $attachmentPath = $this->getAttachmentFilePath($attachDto->id, $attachDto->hash, $ext, $attachDto->fileName);
         try {
             OW::getStorage()->removeFile($attachmentPath);
             $this->attachmentDao->deleteById($attachDto->id);
         } catch (Exception $ex) {
         }
     }
 }
Beispiel #4
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();
     }
 }
Beispiel #5
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);
 }