コード例 #1
0
 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');
 }
コード例 #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());
     }
 }
コード例 #4
0
 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);
 }
 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);
 }