public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     $partnerId = $this->getPartnerId();
     if (!EventNotificationPlugin::isAllowedPartner($partnerId)) {
         throw new KalturaAPIException(KalturaErrors::FEATURE_FORBIDDEN, EventNotificationPlugin::PLUGIN_NAME);
     }
     $this->applyPartnerFilterForClass('EventNotificationTemplate');
 }
Ejemplo n.º 2
0
 public static function isAllowedPartner($partnerId)
 {
     $partner = PartnerPeer::retrieveByPK($partnerId);
     if ($partner) {
         // check that both the push plugin and the event notification plugin are enabled
         return $partner->getPluginEnabled(self::PLUGIN_NAME) && EventNotificationPlugin::isAllowedPartner($partnerId);
     }
     return false;
 }
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     $partnerId = $this->getPartnerId();
     if (!EventNotificationPlugin::isAllowedPartner($partnerId)) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_FORBIDDEN, "{$this->serviceName}->{$this->actionName}");
     }
     if ($partnerId != Partner::ADMIN_CONSOLE_PARTNER_ID && $partnerId != Partner::BATCH_PARTNER_ID) {
         myPartnerUtils::addPartnerToCriteria(new EventNotificationTemplatePeer(), $partnerId, $this->private_partner_data, $this->partnerGroup());
     }
 }
 public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob)
 {
     if ($dbBatchJob->getJobType() != EventNotificationPlugin::getBatchJobTypeCoreValue(EventNotificationBatchType::EVENT_NOTIFICATION_HANDLER)) {
         return false;
     }
     if ($dbBatchJob->getJobSubType() != BusinessProcessNotificationPlugin::getBusinessProcessNotificationTemplateTypeCoreValue(BusinessProcessNotificationTemplateType::BPM_START)) {
         return false;
     }
     if ($dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_FINISHED) {
         return false;
     }
     return true;
 }
 /**
  * @param int $eventNotificationType
  * @param kEventNotificationDispatchJobData $jobData
  * @param string $partnerId
  * @param string $entryId
  * @param BatchJob $parentJob
  * @return BatchJob
  */
 protected function addEventNotificationDispatchJob($eventNotificationType, kEventNotificationDispatchJobData $jobData, $partnerId = null, $entryId = null, BatchJob $parentJob = null)
 {
     $jobType = EventNotificationPlugin::getBatchJobTypeCoreValue(EventNotificationBatchType::EVENT_NOTIFICATION_HANDLER);
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild($jobType, $eventNotificationType, false);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         if (!$partnerId) {
             $partnerId = kCurrentContext::getCurrentPartnerId();
         }
         $batchJob->setPartnerId($partnerId);
     }
     KalturaLog::log("Creating event notification dispatch job on template id [" . $jobData->getTemplateId() . "] engine[{$eventNotificationType}]");
     $batchJob->setObjectId($entryId);
     $batchJob->setObjectType(BatchJobObjectType::ENTRY);
     $batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
     $batchJob = kJobsManager::addJob($batchJob, $jobData, $jobType, $eventNotificationType);
     $jobData->setJobId($batchJob->getId());
     $batchJob->setData($jobData);
     return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
 }
 public function shouldConsumeEvent(KalturaEvent $event)
 {
     $this->notificationTemplates = array();
     $scope = $event->getScope();
     if ($scope->getPartnerId() <= 0 || !EventNotificationPlugin::isAllowedPartner($scope->getPartnerId())) {
         return false;
     }
     $eventType = self::getEventType($event);
     $eventObjectClassName = self::getEventObjectType($event);
     $notificationTemplates = self::getNotificationTemplates($eventType, $eventObjectClassName, $scope->getPartnerId());
     if (!count($notificationTemplates)) {
         return false;
     }
     foreach ($notificationTemplates as $notificationTemplate) {
         /* @var $notificationTemplate EventNotificationTemplate */
         $scope->resetDynamicValues();
         $notificationParameters = $notificationTemplate->getContentParameters();
         foreach ($notificationParameters as $notificationParameter) {
             /* @var $notificationParameter kEventNotificationParameter */
             if (!is_null($notificationParameter->getValue())) {
                 $scope->addDynamicValue($notificationParameter->getKey(), $notificationParameter->getValue());
             }
         }
         $notificationParameters = $notificationTemplate->getUserParameters();
         foreach ($notificationParameters as $notificationParameter) {
             /* @var $notificationParameter kEventNotificationParameter */
             if (!is_null($notificationParameter->getValue())) {
                 $scope->addDynamicValue($notificationParameter->getKey(), $notificationParameter->getValue());
             }
         }
         if ($notificationTemplate->fulfilled($scope)) {
             $this->notificationTemplates[] = $notificationTemplate;
         }
     }
     return count($this->notificationTemplates);
 }
Ejemplo n.º 7
0
 /**
  * Needed in order to migrate old kEventFieldCondition that serialized before kCondition defined as parent class
  */
 public function __wakeup()
 {
     $this->setType(EventNotificationPlugin::getConditionTypeCoreValue(EventNotificationConditionType::EVENT_NOTIFICATION_FIELD));
 }
 public function shouldConsumeEvent(KalturaEvent $event)
 {
     $this->notificationTemplates = array();
     $scope = $event->getScope();
     if ($scope->getPartnerId() <= 0) {
         return;
     }
     if (!EventNotificationPlugin::isAllowedPartner($scope->getPartnerId())) {
         return;
     }
     $eventType = self::getEventType($event);
     $eventObjectType = self::getEventObjectType($event);
     $notificationTemplates = self::getNotificationTemplates($eventType, $eventObjectType, $scope->getPartnerId());
     if (!count($notificationTemplates)) {
         return false;
     }
     foreach ($notificationTemplates as $notificationTemplate) {
         /* @var $notificationTemplate EventNotificationTemplate */
         if ($this->notificationTemplatesConditionsFulfilled($notificationTemplate, $scope)) {
             $this->notificationTemplates[] = $notificationTemplate;
         }
     }
     return count($this->notificationTemplates);
 }
 public function __construct($not = false)
 {
     $this->setType(EventNotificationPlugin::getConditionTypeCoreValue(EventNotificationConditionType::EVENT_NOTIFICATION_OBJECT_CHANGED));
     parent::__construct($not);
 }
 /**
  * @return array
  */
 public static function getAdditionalDescriptions()
 {
     return array(EventNotificationPlugin::getApiValue(self::EVENT_NOTIFICATION_FIELD) => 'Evaluates boolean dynamic field according to scope.', EventNotificationPlugin::getApiValue(self::EVENT_NOTIFICATION_OBJECT_CHANGED) => 'Return true if object changed and defined columns modified.');
 }
Ejemplo n.º 11
0
 public static function loadObject($baseClass, $enumValue, array $constructorArgs = null)
 {
     if ($baseClass == 'KalturaJobData' && $enumValue == self::getApiValue(EventNotificationBatchType::EVENT_NOTIFICATION_HANDLER) && isset($constructorArgs['coreJobSubType'])) {
         return KalturaPluginManager::loadObject('KalturaEventNotificationDispatchJobData', $constructorArgs['coreJobSubType']);
     }
     if ($baseClass == 'KalturaCondition') {
         if ($enumValue == EventNotificationPlugin::getConditionTypeCoreValue(EventNotificationConditionType::EVENT_NOTIFICATION_FIELD)) {
             return new KalturaEventFieldCondition();
         }
         if ($enumValue == EventNotificationPlugin::getConditionTypeCoreValue(EventNotificationConditionType::EVENT_NOTIFICATION_OBJECT_CHANGED)) {
             return new KalturaEventObjectChangedCondition();
         }
     }
     return null;
 }