예제 #1
0
 protected function getFieldValue(kScope $scope = null)
 {
     if (!$scope) {
         $scope = new kScope();
     }
     return $scope->getTime() + $this->offset;
 }
 protected function internalFulfilled(kScope $scope)
 {
     if (!$scope instanceof kEventScope) {
         return false;
     }
     $event = $scope->getEvent();
     if (!$event instanceof kObjectChangedEvent) {
         return false;
     }
     $trigerColumns = explode(',', $this->modifiedColumns);
     $modifiedColumns = $event->getModifiedColumns();
     $object = $event->getObject();
     if (method_exists($object, 'getCustomDataOldValues')) {
         $customDataOldValues = $object->getCustomDataOldValues();
         foreach ($customDataOldValues as $customDataField => $customDataValue) {
             if ($customDataField) {
                 $modifiedColumns[] = $customDataField;
             }
         }
         if (isset($customDataOldValues[''])) {
             foreach ($customDataOldValues[''] as $customDataField => $customDataValue) {
                 $modifiedColumns[] = $customDataField;
             }
         }
     }
     $foundColumns = array_intersect($modifiedColumns, $trigerColumns);
     KalturaLog::debug("Triger columns [" . print_r($trigerColumns, true) . "]");
     KalturaLog::debug("Found columns [" . print_r($foundColumns, true) . "]");
     return count($foundColumns) > 0;
 }
 protected function getFieldValue(kScope $scope = null)
 {
     if (!$scope) {
         $scope = new kScope();
     }
     return $scope->getIp();
 }
예제 #4
0
 protected function getFieldValue(kScope $scope = null)
 {
     kApiCache::addExtraField(kApiCache::ECF_USER_AGENT);
     if (!$scope) {
         $scope = new kScope();
     }
     return $scope->getUserAgent();
 }
예제 #5
0
 protected function getFieldValue(kScope $scope = null)
 {
     kApiCache::addExtraField(kApiCache::ECF_IP);
     if (!$scope) {
         $scope = new kScope();
     }
     return $scope->getIp();
 }
예제 #6
0
 protected function getFieldValue(kScope $scope = null)
 {
     if (!$scope) {
         $scope = new kScope();
     }
     $kuser = kuserPeer::getKuserByPartnerAndUid($scope->getKs()->partner_id, $scope->getKs()->user);
     return $kuser->getEmail();
 }
예제 #7
0
 protected function getMessage(kScope $scope)
 {
     if ($scope instanceof kEventScope) {
         $object = $scope->getObject();
     }
     // prepare vars as configured by user in admin console
     $objectType = $this->getApiObjectType();
     $format = $this->getObjectFormat();
     return call_user_func(kCurrentContext::$serializeCallback, $object, $objectType, $format);
 }
예제 #8
0
 protected function getFieldValue(kScope $scope = null)
 {
     kApiCache::addExtraField(kApiCache::ECF_COORDINATES);
     if (!$scope) {
         $scope = new kScope();
     }
     $ip = $scope->getIp();
     $ipGeo = kGeoCoderManager::getGeoCoder($this->getGeoCoderType());
     $coordinates = $ipGeo->getCoordinates($ip);
     return implode(",", $coordinates);
 }
예제 #9
0
 protected function getFieldValue(kScope $scope = null)
 {
     kApiCache::addExtraField(kApiCache::ECF_COUNTRY);
     if (!$scope) {
         $scope = new kScope();
     }
     $ip = $scope->getIp();
     $ipGeo = kGeoCoderManager::getGeoCoder($this->getGeoCoderType());
     $country = $ipGeo->getCountry($ip);
     return trim(strtolower($country), " \n\r\t");
 }
예제 #10
0
파일: kRule.php 프로젝트: DBezemer/server
 /**
  * @return bool
  */
 protected function isInContext()
 {
     if (!is_array($this->contexts) || !count($this->contexts)) {
         return true;
     }
     foreach ($this->contexts as $context) {
         if ($this->scope->isInContext($context)) {
             return true;
         }
     }
     return false;
 }
예제 #11
0
 protected function internalFulfilled(kScope $scope)
 {
     $hashes = $scope->getHashes();
     if (is_array($hashes) && isset($hashes[$this->hashName])) {
         $sentHash = $hashes[$this->hashName];
         $compareHash = md5($this->hashSecret . kCurrentContext::$ks);
         if ($sentHash === $compareHash) {
             KalturaLog::info("Correct hash sent");
             return false;
         }
     }
     KalturaLog::info("Incorrect hash sent");
     return true;
 }
 /**
  * @param kScope $scope
  * @return bool
  */
 protected function internalFulfilled(kScope $scope)
 {
     // no properties defined, the condition is fulfilled
     if (count($this->getProperties()) == 0) {
         return true;
     }
     $entryId = $scope->getEntryId();
     $entryAssets = assetPeer::retrieveReadyByEntryId($scope->getEntryId());
     foreach ($entryAssets as $asset) {
         $assetFulfilled = $this->assetFulfilled($asset);
         if ($assetFulfilled) {
             return true;
         }
     }
     return false;
 }
예제 #13
0
 public function getFieldValue(kScope $scope)
 {
     $profileId = $this->profileId;
     if (!$profileId) {
         if (!$this->profileSystemName) {
             KalturaLog::err("No metadata profile id and system-name supplied");
             return null;
         }
         $profile = MetadataProfilePeer::retrieveBySystemName($this->profileSystemName, kCurrentContext::getCurrentPartnerId());
         if (!$profile) {
             KalturaLog::notice("Metadata profile with system-name [{$this->profileSystemName}] not found");
             return null;
         }
         $profileId = $profile->getId();
     }
     $metadata = null;
     if ($scope instanceof accessControlScope || $scope instanceof kStorageProfileScope) {
         $metadata = MetadataPeer::retrieveByObject($profileId, MetadataObjectType::ENTRY, $scope->getEntryId());
     } elseif ($scope instanceof kEventScope) {
         $object = $scope->getEvent()->getObject();
         if (kMetadataManager::isMetadataObject($object)) {
             $objectType = kMetadataManager::getTypeNameFromObject($object);
             $metadata = MetadataPeer::retrieveByObject($profileId, $objectType, $object->getId());
         } else {
             if ($object instanceof Metadata) {
                 $metadata = $object;
             } elseif ($scope->getEvent()->getObject() instanceof categoryEntry) {
                 $profileObject = kMetadataManager::getObjectTypeName($profile->getObjectType());
                 $getter = "get{$profileObject}Id";
                 KalturaLog::info("Using {$getter} in order to retrieve the metadata object ID");
                 $categoryEntry = $scope->getEvent()->getObject();
                 $objectId = $categoryEntry->{$getter}();
                 $metadata = MetadataPeer::retrieveByObject($profileId, $profile->getObjectType(), $objectId);
             } elseif ($object instanceof asset) {
                 $metadata = MetadataPeer::retrieveByObject($profileId, MetadataObjectType::ENTRY, $object->getEntryId());
             }
         }
     }
     if ($metadata) {
         return kMetadataManager::parseMetadataValues($metadata, $this->xPath);
     }
     KalturaLog::notice("Metadata object not found for scope [" . get_class($scope) . "]");
     return null;
 }
예제 #14
0
 protected function internalFulfilled(kScope $scope)
 {
     $referrer = $scope->getReferrer();
     if ($this->getNot() === true && !$this->globalWhitelistDomainsAppended && strpos($referrer, "kwidget") === false && kConf::hasParam("global_whitelisted_domains")) {
         $ks = $scope->getKs();
         if (!$ks || !in_array($ks->partner_id, kConf::get('global_whitelisted_domains_exclude'))) {
             $this->globalWhitelistDomainsAppended = true;
             $globalWhitelistedDomains = kConf::get("global_whitelisted_domains");
             if (!is_array($globalWhitelistedDomains)) {
                 $globalWhitelistedDomains = explode(',', $globalWhitelistedDomains);
             }
             foreach ($globalWhitelistedDomains as $globalWhitelistedDomain) {
                 $this->values[] = new kStringValue($globalWhitelistedDomain);
             }
         }
     }
     kApiCache::addExtraField(kApiCache::ECF_REFERRER, kApiCache::COND_SITE_MATCH, $this->getStringValues($scope));
     return parent::internalFulfilled($scope);
 }
 protected function internalFulfilled(kScope $scope)
 {
     $profileId = $this->profileId;
     if (!$profileId) {
         if (!$this->profileSystemName) {
             return null;
         }
         $profile = MetadataProfilePeer::retrieveBySystemName($this->profileSystemName, kCurrentContext::getCurrentPartnerId());
         if (!$profile) {
             return null;
         }
         $profileId = $profile->getId();
     }
     $metadata = null;
     if ($scope instanceof accessControlScope) {
         $metadata = MetadataPeer::retrieveByObject($profileId, MetadataObjectType::ENTRY, $scope->getEntryId());
     } elseif ($scope instanceof kEventScope && $scope->getEvent() instanceof kApplicativeEvent) {
         $object = $scope->getEvent()->getObject();
         if ($object instanceof Metadata) {
             $metadata = $object;
         } elseif (kMetadataManager::isMetadataObject($object)) {
             $objectType = kMetadataManager::getTypeNameFromObject($object);
             $metadata = MetadataPeer::retrieveByObject($profileId, $objectType, $object->getId());
         }
     }
     if (!$metadata) {
         return false;
     }
     if ($this->versionA) {
         $valuesA = kMetadataManager::parseMetadataValues($metadata, $this->xPath, $this->versionA);
     }
     $valuesB = kMetadataManager::parseMetadataValues($metadata, $this->xPath, $this->versionB);
     if (!$valuesA || !count($valuesA)) {
         //previous MD version does not exist
         $changedValues = $valuesB;
     } else {
         $changedValues = array_diff($valuesA, $valuesB);
     }
     return count($changedValues) > 0;
 }
 protected function dispatchJob(kScope $scope, kEventNotificationDispatchJobData $jobData, $eventNotificationType = null)
 {
     $entryId = null;
     $parentJob = null;
     if ($scope instanceof kEventScope) {
         $event = $scope->getEvent();
         if ($event instanceof kApplicativeEvent) {
             $parentJob = $event->getRaisedJob();
         }
         $object = $scope->getObject();
         if ($object instanceof entry) {
             $entryId = $object->getId();
         } elseif (method_exists($object, 'getEntryId')) {
             $entryId = $object->getEntryId();
         }
     }
     if (!$eventNotificationType) {
         $eventNotificationType = $this->getType();
     }
     $job = $this->addEventNotificationDispatchJob($eventNotificationType, $jobData, $scope->getPartnerId(), $entryId, $parentJob);
     return $job->getId();
 }
예제 #17
0
 public function getFieldValue(kScope $scope)
 {
     $profileId = $this->profileId;
     if (!$profileId) {
         if (!$this->profileSystemName) {
             return null;
         }
         $profile = MetadataProfilePeer::retrieveBySystemName($this->profileSystemName, kCurrentContext::getCurrentPartnerId());
         if (!$profile) {
             return null;
         }
         $profileId = $profile->getId();
     }
     $metadata = null;
     if ($scope instanceof accessControlScope || $scope instanceof kStorageProfileScope) {
         $metadata = MetadataPeer::retrieveByObject($profileId, MetadataObjectType::ENTRY, $scope->getEntryId());
     } elseif ($scope instanceof kEventScope && $scope->getEvent() instanceof kApplicativeEvent) {
         $object = $scope->getEvent()->getObject();
         if (kMetadataManager::isMetadataObject($object)) {
             $objectType = kMetadataManager::getTypeNameFromObject($object);
             $metadata = MetadataPeer::retrieveByObject($profileId, $objectType, $object->getId());
         } else {
             if ($object instanceof Metadata) {
                 $metadata = $object;
             }
         }
     }
     if (!$metadata) {
         return null;
     }
     $values = kMetadataManager::parseMetadataValues($metadata, $this->xPath);
     if (is_null($values)) {
         return null;
     }
     return array_map('intval', $values);
 }
예제 #18
0
 protected function internalFulfilled(kScope $scope)
 {
     if (!$scope->getKs() || !$scope->getKs() instanceof ks) {
         return false;
     }
     if ($scope->getKs()->isAdmin()) {
         return true;
     }
     KalturaLog::debug(print_r($this->privileges, true));
     foreach ($this->privileges as $privilege) {
         if (is_object($privilege)) {
             $privilege = $privilege->getValue();
         }
         KalturaLog::debug("Checking privilege [{$privilege}] with entry [" . $scope->getEntryId() . "]");
         if ($scope->getKs()->verifyPrivileges($privilege, $scope->getEntryId())) {
             KalturaLog::debug("Privilege [{$privilege}] verified");
             return true;
         }
     }
     KalturaLog::debug("No privilege verified");
     return false;
 }
예제 #19
0
 /**
  * @param KalturaEvent $v
  */
 public function __construct(KalturaEvent $v = null)
 {
     parent::__construct();
     $this->event = $v;
 }
예제 #20
0
 public function __construct()
 {
     parent::__construct();
     $this->setContexts(array(ContextType::PLAY));
 }
 public function setScope(kScope $scope)
 {
     $this->data = http_build_query($scope->getDynamicValues());
 }