public function shouldConsumeCreatedEvent(BaseObject $object) { if ($object instanceof entry && $object->getSource() == VelocixPlugin::getEntrySourceTypeCoreValue(VelocixLiveEntrySourceType::VELOCIX_LIVE)) { return true; } return false; }
/** * Returns recommended objects which the user has not rated based on his/her * rating of other objects. * * This implementation is based on the * OpenSlopeOne project by Chaoqun Fu, http://code.google.com/p/openslopeone/. * * @param BaseObject $object The user for which to return the recommendations * @param string $model The name of the class for which to return recommendations * @param int $limit The number of recommendation objects which should be returned. * Use NULL for returning all recommended objects * @return array of sfRecommendationObject objects which wrap the recommended objects */ public function getRecommendations(BaseObject $object, $model, $limit = NULL) { $parser = new sfPropelSlopeOneSqlParser(); $slopeQuery = 'SELECT sf_slope_one.item2_id AS id, SUM((%ratings%.%rating% * sf_slope_one.times) - sf_slope_one.rating)/ SUM(sf_slope_one.times) AS rating FROM sf_slope_one, %ratings% WHERE %ratings%.%rater_id% = :rater_id AND %ratings%.%rateable_model% = :item_model AND %ratings%.%rateable_id% = sf_slope_one.item1_id AND %ratings%.%rateable_model% = sf_slope_one.item1_model AND sf_slope_one.item2_id NOT IN (SELECT %ratings%.%rateable_id% FROM %ratings% WHERE %ratings%.%rater_id% = :rater_id) GROUP BY item2_id ORDER BY rating DESC'; $slopeQuery .= isset($limit) ? ' LIMIT ' . $limit : ''; $connection = Propel::getConnection(); $statement = $connection->prepare($parser->parse($slopeQuery)); $statement->execute(array('rater_id' => $object->getId(), 'item_model' => $model)); $ratings = array(); while ($result = $statement->fetch()) { $ratings[$result['id']] = $result['rating']; } $modelObject = new $model(); $objects = call_user_func(array(get_class($modelObject->getPeer()), 'retrieveByPKs'), array_keys($ratings)); foreach ($objects as &$object) { $object = new sfSlopeOneRecommendation($object, $ratings[$object->getId()]); } return $objects; }
/** * @param BaseObject $object */ public function attachCreatedObject(BaseObject $object) { $dropFolderFile = DropFolderFilePeer::retrieveByPK($this->getDropFolderFileId()); $dropFolder = DropFolderPeer::retrieveByPK($dropFolderFile->getDropFolderId()); $entryId = $asset = null; // create import job for remote drop folder files if ($dropFolder instanceof RemoteDropFolder) { // get params if ($object instanceof asset) { $entryId = $object->getEntryId(); $asset = $object; } else { if ($object instanceof entry) { $entryId = $object->getId(); $asset = null; } else { return; } } $importUrl = $dropFolder->getFolderUrl(); $importUrl .= '/' . $dropFolderFile->getFileName(); $jobData = $dropFolder->getImportJobData(); $jobData->setDropFolderFileId($this->getDropFolderFileId()); // add job kJobsManager::addImportJob(null, $entryId, $dropFolderFile->getPartnerId(), $importUrl, $asset, $dropFolder->getFileTransferMgrType(), $jobData); // set file status to DOWNLOADING $dropFolderFile->setStatus(DropFolderFileStatus::DOWNLOADING); $dropFolderFile->save(); } }
public function objectAdded(BaseObject $object, BatchJob $raisedJob = null) { /* @var $object ExternalMediaEntry */ $object->setStatus(entryStatus::READY); $object->save(); return true; }
public function shouldConsumeCreatedEvent(BaseObject $object) { if ($object instanceof BatchJob && $object->getJobType() == BatchJobType::BULKUPLOAD) { return true; } return false; }
public function shouldConsumeCreatedEvent(BaseObject $object) { if ($object instanceof thumbAsset && $object->getStatus() == asset::FLAVOR_ASSET_STATUS_READY) { return true; } return false; }
/** * @param BaseObject $fromObject * @param BaseObject $toObject * @return bool true if should continue to the next consumer */ public function objectCopied(BaseObject $fromObject, BaseObject $toObject) { if ($fromObject instanceof Partner) { $this->copyDistributionProfiles($fromObject->getId(), $toObject->getId()); } return true; }
public static function deleteByObject(BaseObject $object) { $c = new Criteria(); $c->add(sfApprovalPeer::APPROVABLE_ID, $object->getPrimaryKey()); $c->add(sfApprovalPeer::APPROVABLE_MODEL, get_class($object)); $approval = sfApprovalPeer::doDelete($c); }
public function shouldConsumeCreatedEvent(BaseObject $object) { if ($object instanceof entry && $object->getSource() == LimeLightPlugin::getEntrySourceTypeCoreValue(LimeLightLiveEntrySourceType::LIMELIGHT_LIVE)) { return true; } return false; }
/** * Populates version properties and creates necessary entries in the resource_attribute_version table. * * @param BaseObject $resource * @param Array $withObjects Optional list of object classes to create and attach to the current resource */ public function populateFromObject(BaseObject $resource, $withObjects = array(), $withVersion = true) { $this->setResourceId($resource->getPrimaryKey()); $this->setResourceName(get_class($resource)); if ($withVersion) { $this->setNumber($resource->getVersion()); } foreach ($resource->getPeer()->getFieldNames() as $attribute_name) { $getter = sprintf('get%s', $attribute_name); $attribute_version = new ResourceAttributeVersion(); $attribute_version->setAttributeName($attribute_name); $attribute_version->setAttributeValue($resource->{$getter}()); $this->addResourceAttributeVersion($attribute_version); } foreach ($withObjects as $resourceName) { $getter = sprintf('get%s', $resourceName); $relatedResources = $resource->{$getter}(); if (!is_array($relatedResources)) { $relatedResources = array($relatedResources); } foreach ($relatedResources as $relatedResource) { $resourceVersion = new ResourceVersion(); $resourceVersion->populateFromObject($relatedResource, array(), false); $this->addResourceVersionRelatedByResourceVersionId($resourceVersion); } } }
/** * Returns objects of the same class and with similar ratings as the current rateable object. * * This implementation is based on the * OpenSlopeOne project by Chaoqun Fu, http://code.google.com/p/openslopeone/. * * @param BaseObject $object The rateable object for which to return other recommended object * @param int $limit The number of recommendation objects which should be returned. Use NULL for returning all recommended objects * @return array of sfRecommendationObject objects which wrap the recommended objects */ public function getRecommendations(BaseObject $object, $limit = NULL) { $parser = new sfPropelSlopeOneSqlParser(); $slopeQuery = 'SELECT item2_id AS id, SUM(rating/times) AS rating FROM sf_slope_one WHERE item1_id = :item_id AND item1_model = :item_model AND item1_model = item2_model GROUP BY item2_id ORDER BY rating DESC'; $slopeQuery .= isset($limit) ? ' LIMIT ' . $limit : ''; $connection = Propel::getConnection(); $statement = $connection->prepare($parser->parse($slopeQuery)); $statement->execute(array('item_id' => $object->getId(), 'item_model' => get_class($object))); $ratings = array(); while ($result = $statement->fetch()) { $ratings[$result['id']] = $result['rating']; } $objects = call_user_func(array(get_class($object->getPeer()), 'retrieveByPKs'), array_keys($ratings)); foreach ($objects as &$object) { $object = new sfSlopeOneRecommendation($object, $ratings[$object->getId()]); } return $objects; }
public function shouldConsumeChangedEvent(BaseObject $object, array $modifiedColumns) { if ($object instanceof LiveEntry && in_array(entryPeer::CUSTOM_DATA, $modifiedColumns) && $object->isCustomDataModified(null, 'mediaServers')) { return true; } return false; }
public function shouldConsumeCreatedEvent(BaseObject $object) { if ($object instanceof flavorParamsOutputWrap && $object->getType() == WidevinePlugin::getAssetTypeCoreValue(WidevineAssetType::WIDEVINE_FLAVOR) && $this->shouldSyncWidevineRepositoryForPartner($object->getPartnerId())) { return true; } else { return false; } }
/** * @param array $entity * @param BaseObject $caller */ public function __construct(array $entity, BaseObject $caller) { $this->entity = array("type" => $entity["type"], "id" => $entity["id"], "xml_id" => $entity["xml_id"]); $this->caller = $caller; $this->forum = $caller->getForum(); $this->initPermission(); $this->editOwn = \COption::GetOptionString("forum", "USER_EDIT_OWN_POST", "Y") == "Y"; }
public function objectCreated(BaseObject $fromObject) { if ($fromObject instanceof entry) { $liveEntryId = $fromObject->getRootEntryId(); $this->copyLiveMetadata($fromObject, $liveEntryId); } return true; }
public function getScope() { $scope = parent::getScope(); if (method_exists($this->object, 'getPartnerId')) { $scope->setPartnerId($this->object->getPartnerId()); } return $scope; }
/** * Return DDL for sequence modification (drop with subsequent create). * * @param BaseObject $target Target object. * @param string $dbType Database type (ORACLE only). * * @return array|string */ public function getModifyDdl(BaseObject $target, $dbType = '') { switch ($dbType) { case "ORACLE": return array($this->getDropDdl($dbType), $target->getCreateDdl($dbType)); default: return "// " . get_class($this) . ":getDropDdl for database type [" . $dbType . "] not implemented"; } }
/** * @param BaseObject $object * @return bool true if should continue to the next consumer */ public function objectDeleted(BaseObject $object) { if (!$object instanceof entry) { return true; } $solr = self::createSolrService(); $solr->deleteById($object->getIntId()); return true; }
public function mergeObject(BaseObject $source, array $properties = array()) { foreach ($source->getDataObject()->getProperties() as $key => $property) { if (count($properties) > 0 && !in_array($key, $properties)) { continue; } $this->_dataObject->addProperty($property); } }
public function objectDeleted(BaseObject $object, BatchJob $raisedJob = null) { $shortLinks = ShortLinkPeer::retrieveByKuserId($object->getId()); foreach ($shortLinks as $shortLink) { $shortLink->setStatus(ShortLinkStatus::DELETED); $shortLink->save(); } return true; }
public function objectDeleted(BaseObject $object) { if ($object instanceof kuser) { $shortLinks = ShortLinkPeer::retrieveByKuserId($object->getId()); foreach ($shortLinks as $shortLink) { $shortLink->setStatus(ShortLinkStatus::DELETED); $shortLink->save(); } } }
public function contribute(BaseObject $object, SimpleXMLElement $mrss, kMrssParameters $mrssParams = null) { if (!$object instanceof entry) { return; } $entryDistributions = EntryDistributionPeer::retrieveByEntryId($object->getId()); foreach ($entryDistributions as $entryDistribution) { $this->contributeDistribution($entryDistribution, $mrss); } }
/** * @param BaseObject $object * @param BatchJob $raisedJob * @return bool true if should continue to the next consumer */ public function objectDeleted(BaseObject $object, BatchJob $raisedJob = null) { if ($object instanceof asset && EdgeCastPlugin::isAllowedPartner($object->getPartnerId())) { self::purgeAssetFromEdgeCast($object); } if ($object instanceof entry && EdgeCastPlugin::isAllowedPartner($object->getPartnerId())) { self::purgeEntryFromEdgeCast($object); } return true; }
public function objectDeleted(BaseObject $object, BatchJob $raisedJob = null) { if ($object instanceof entry) { $this->entryDeleted($object->getId()); } if ($object instanceof CuePoint) { $this->cuePointDeleted($object); } return true; }
/** * @param BaseObject $object */ public function objectDeleted(BaseObject $object) { KalturaLog::debug("annotation objectDeleted"); if ($object instanceof entry) { $this->entryDeleted($object->getId()); } if ($object instanceof Annotation) { $this->annotationDeleted($object); } return true; }
/** * @param BaseObject $object * @return bool true if should continue to the next consumer */ public function objectAdded(BaseObject $object) { if ($object instanceof EntryDistribution) { $entry = entryPeer::retrieveByPK($object->getEntryId()); if ($entry) { // updated in the indexing server (sphinx) kEventsManager::raiseEvent(new kObjectUpdatedEvent($entry)); } } return true; }
public function getScope() { $scope = parent::getScope(); if ($this->raisedJob) { $scope->setPartnerId($this->raisedJob->getPartnerId()); $scope->setParentRaisedJob($this->raisedJob); } elseif (method_exists($this->object, 'getPartnerId')) { $scope->setPartnerId($this->object->getPartnerId()); } return $scope; }
/** * Retrieves an existing Star object, or return a new empty one * * @param BaseObject $object * @param integer $user_id * @return Star **/ protected static function getOrCreate(BaseObject $object, $user_id) { if ($object->isNew()) { throw new sfException('Unsaved objects cannot be starred'); } $c = new Criteria(); $c->add(StarPeer::STARRED_ID, $object->getPrimaryKey()); $c->add(StarPeer::STARRED_MODEL, get_class($object)); $c->add(StarPeer::USER_ID, $user_id); $ustar = StarPeer::doSelectOne($c); return is_null($ustar) ? new Star() : $ustar; }
/** * @param BaseObject $fromObject * @param BaseObject $toObject * @return bool true if should continue to the next consumer */ public function objectCopied(BaseObject $fromObject, BaseObject $toObject) { if ($fromObject instanceof assetParams) { self::mapIds('assetParams', $fromObject->getId(), $toObject->getId()); } if ($fromObject instanceof assetParamsOutput) { $flavorParamsId = self::getMappedId('assetParams', $fromObject->getFlavorParamsId()); if ($flavorParamsId) { $toObject->setFlavorParamsId($flavorParamsId); } } return true; }
/** * @param BaseObject $object */ public function objectDeleted(BaseObject $object) { if ($object instanceof entry) { $this->deleteMetadataObjects(Metadata::TYPE_ENTRY, $object->getId()); } if ($object instanceof Metadata) { $this->metadataDeleted($object); } if ($object instanceof MetadataProfile) { $this->metadataProfileDeleted($object); } return true; }