Esempio n. 1
0
 public static function addMailJob(BatchJob $parentJob = null, $entryId, $partnerId, $mailType, $mailPriority, $fromEmail, $fromName, $toEmail, array $bodyParams = array(), array $subjectParams = array(), $toName = null, $toId = null, $camaignId = null, $templatePath = null, $separator = null)
 {
     $jobData = new kMailJobData();
     $jobData->setMailPriority($mailPriority);
     $jobData->setMailType($mailType);
     $jobData->setFromEmail($fromEmail);
     $jobData->setFromName($fromName);
     if ($separator) {
         $jobData->setSeparator($separator);
     }
     $jobData->setBodyParamsArray($bodyParams);
     $jobData->setSubjectParamsArray($subjectParams);
     $jobData->setRecipientEmail($toEmail);
     $jobData->setRecipientName($toName);
     $jobData->setRecipientId($toId);
     $jobData->setCampaignId($camaignId);
     $jobData->setCampaignId($camaignId);
     $jobData->setTemplatePath($templatePath);
     $partner = PartnerPeer::retrieveByPK($partnerId);
     $jobData->setLanguage($partner->getLanguage());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(BatchJobType::MAIL, $mailType);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     return self::addJob($batchJob, $jobData, BatchJobType::MAIL, $mailType);
 }
Esempio n. 2
0
 public static function handleBulkDownloadFinished(BatchJob $dbBatchJob, kBulkDownloadJobData $data)
 {
     if ($dbBatchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED) {
         return $dbBatchJob;
     }
     $partner = PartnerPeer::retrieveByPK($dbBatchJob->getPartnerId());
     if (!$partner) {
         KalturaLog::err("Partner id [" . $dbBatchJob->getPartnerId() . "] not found, not sending mail");
         return $dbBatchJob;
     }
     $entryIds = explode(",", $data->getEntryIds());
     $flavorParamsId = $data->getFlavorParamsId();
     $links = array();
     foreach ($entryIds as $entryId) {
         $entry = entryPeer::retrieveByPK($entryId);
         if (is_null($entry)) {
             continue;
         }
         if ($entry->getType() != entryType::MEDIA_CLIP) {
             KalturaLog::info("This entry cannot be downloaded {$entryId}");
             continue;
         }
         $link = $entry->getDownloadAssetUrl($flavorParamsId);
         if (is_null($link)) {
             $link = "Failed to prepare";
         } else {
             $link = '<a href="' . $link . '">Download</a>';
         }
         $links[] = $entry->getName() . " - " . $link;
     }
     $linksHtml = implode("<br />", $links);
     // add mail job
     $jobData = new kMailJobData();
     $jobData->setIsHtml(true);
     $jobData->setMailPriority(kMailJobData::MAIL_PRIORITY_NORMAL);
     $jobData->setStatus(kMailJobData::MAIL_STATUS_PENDING);
     if (count($links) <= 1) {
         $jobData->setMailType(62);
     } else {
         $jobData->setMailType(63);
     }
     $jobData->setFromEmail(kConf::get("batch_download_video_sender_email"));
     $jobData->setFromName(kConf::get("batch_download_video_sender_name"));
     $adminName = $partner->getAdminName();
     $recipientEmail = $partner->getAdminEmail();
     $kuser = kuserPeer::getKuserByPartnerAndUid($dbBatchJob->getPartnerId(), $data->getPuserId());
     if ($kuser) {
         $recipientEmail = $kuser->getEmail();
         $adminName = $kuser->getFullName();
     }
     if (!$adminName) {
         $adminName = $recipientEmail;
     }
     $jobData->setSeparator(self::BULK_DOWNLOAD_EMAIL_PARAMS_SEPARATOR);
     $jobData->setBodyParamsArray(array($adminName, $linksHtml));
     $jobData->setRecipientEmail($recipientEmail);
     $jobData->setSubjectParamsArray(array());
     kJobsManager::addJob($dbBatchJob->createChild(BatchJobType::MAIL, $jobData->getMailType()), $jobData, BatchJobType::MAIL, $jobData->getMailType());
     return $dbBatchJob;
 }