Ejemplo n.º 1
0
 public function objectChanged(BaseObject $object, array $modifiedColumns)
 {
     if ($object instanceof entry && in_array(entryPeer::STATUS, $modifiedColumns) && ($object->getStatus() == entryStatus::READY || $object->getStatus() == entryStatus::ERROR_CONVERTING) && $object->getReplacedEntryId()) {
         kFlowHelper::handleEntryReplacement($object);
         return true;
     }
     if ($object instanceof UploadToken && in_array(UploadTokenPeer::STATUS, $modifiedColumns) && $object->getStatus() == UploadToken::UPLOAD_TOKEN_FULL_UPLOAD) {
         kFlowHelper::handleUploadFinished($object);
         return true;
     }
     if ($object instanceof BatchJob && $object->getJobType() == BatchJobType::BULKUPLOAD && $object->getStatus() == BatchJob::BATCHJOB_STATUS_ABORTED && in_array(BatchJobPeer::STATUS, $modifiedColumns) && in_array($object->getColumnsOldValue(BatchJobPeer::STATUS), BatchJobPeer::getClosedStatusList())) {
         $partner = $object->getPartner();
         if ($partner->getEnableBulkUploadNotificationsEmails()) {
             kFlowHelper::sendBulkUploadNotificationEmail($object, MailType::MAIL_TYPE_BULKUPLOAD_ABORTED, array($partner->getAdminName(), $object->getId(), kFlowHelper::createBulkUploadLogUrl($object)));
         }
         return true;
     }
     if ($object instanceof UserRole && in_array(UserRolePeer::PERMISSION_NAMES, $modifiedColumns)) {
         $filter = new kuserFilter();
         $filter->set('_eq_role_ids', $object->getId());
         kJobsManager::addIndexJob($object->getPartnerId(), IndexObjectType::USER, $filter, false);
         return true;
     }
     if ($object instanceof FileSync) {
         $c = new Criteria();
         $c->add(BatchJobLockPeer::OBJECT_ID, $object->getId());
         $c->add(BatchJobLockPeer::OBJECT_TYPE, BatchJobObjectType::FILE_SYNC);
         $c->add(BatchJobLockPeer::JOB_TYPE, BatchJobType::FILESYNC_IMPORT);
         $c->add(BatchJobLockPeer::STATUS, array(BatchJob::BATCHJOB_STATUS_RETRY, BatchJob::BATCHJOB_STATUS_PENDING), Criteria::IN);
         $fileSyncImportJobs = BatchJobLockPeer::doSelect($c);
         foreach ($fileSyncImportJobs as $fileSyncImportJob) {
             kJobsManager::abortDbBatchJob(BatchJobPeer::retrieveByPK($fileSyncImportJob->getId()));
         }
         return true;
     }
     if (!$object instanceof flavorAsset || !in_array(assetPeer::STATUS, $modifiedColumns)) {
         return true;
     }
     $entry = entryPeer::retrieveByPKNoFilter($object->getEntryId());
     KalturaLog::info("Asset id [" . $object->getId() . "] isOriginal [" . $object->getIsOriginal() . "] status [" . $object->getStatus() . "]");
     if ($object->getIsOriginal()) {
         return true;
     }
     if ($object->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_VALIDATING) {
         $postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_FLAVOR;
         $offset = $entry->getThumbOffset();
         // entry getThumbOffset now takes the partner DefThumbOffset into consideration
         $syncKey = $object->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey, false);
         if (!$fileSync) {
             return true;
         }
         $srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
         if ($srcFileSyncLocalPath) {
             kJobsManager::addPostConvertJob(null, $postConvertAssetType, $srcFileSyncLocalPath, $object->getId(), null, $entry->getCreateThumb(), $offset);
         }
     } elseif ($object->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
         // If we get a ready flavor and the entry is in no content
         if ($entry->getStatus() == entryStatus::NO_CONTENT) {
             $entry->setStatus(entryStatus::PENDING);
             // we change the entry to pending
             $entry->save();
         }
     }
     return true;
 }