public function postSave(PropelPDO $con = null) { if ($this->roleIdsChanged) { // delete old roles $c = new Criteria(); $c->addAnd(KuserToUserRolePeer::KUSER_ID, $this->getId(), Criteria::EQUAL); KuserToUserRolePeer::doDelete($c); // add new roles $idsArray = explode(',', $this->roleIds); foreach ($idsArray as $id) { if (!is_null($id) && $id != '') { $kuserToRole = new KuserToUserRole(); $kuserToRole->setUserRoleId($id); $kuserToRole->setKuserId($this->getId()); $kuserToRole->save(); } } } $this->roleIdsChanged = false; //update all categoryKuser object with kuser if (categoryKuserPeer::isCategroyKuserExistsForKuser($this->getId())) { $featureStatusToRemoveIndex = new kFeatureStatus(); $featureStatusToRemoveIndex->setType(IndexObjectType::CATEGORY_USER); $featureStatusesToRemove = array(); $featureStatusesToRemove[] = $featureStatusToRemoveIndex; $filter = new categoryKuserFilter(); $filter->setUserIdEqual($this->getPuserId()); kJobsManager::addIndexJob($this->getPartnerId(), IndexObjectType::CATEGORY_USER, $filter, true, $featureStatusesToRemove); } return parent::postSave(); }
public function postUpdate(PropelPDO $con = null) { if ($this->alreadyInSave) { return parent::postUpdate($con); } $objectUpdated = $this->isModified(); $objectDeleted = false; if ($this->isColumnModified(kuserPeer::STATUS) && $this->getStatus() == KuserStatus::DELETED) { $objectDeleted = true; } $oldLoginDataId = null; if ($this->isColumnModified(kuserPeer::LOGIN_DATA_ID)) { $oldLoginDataId = $this->oldColumnsValues[kuserPeer::LOGIN_DATA_ID]; } if ($this->isColumnModified(kuserPeer::EMAIL) && $this->getIsAccountOwner() && isset($this->oldColumnsValues[kuserPeer::EMAIL]) && !is_null($this->oldColumnsValues[kuserPeer::EMAIL])) { myPartnerUtils::emailChangedEmail($this->getPartnerId(), $this->oldColumnsValues[kuserPeer::EMAIL], $this->getEmail(), $this->getPartner()->getName(), PartnerPeer::KALTURAS_PARTNER_EMAIL_CHANGE); } if ($this->getIsAccountOwner() && ($this->isColumnModified(kuserPeer::EMAIL) || $this->isColumnModified(kuserPeer::FIRST_NAME) || $this->isColumnModified(kuserPeer::LAST_NAME))) { $partner = $this->getPartner(); $partner->setAccountOwnerKuserId($this->getId(), false); $partner->save(); } if ($this->isColumnModified(kuserPeer::SCREEN_NAME) && categoryKuserPeer::isCategroyKuserExistsForKuser($this->getId())) { $featureStatusToRemoveIndex = new kFeatureStatus(); $featureStatusToRemoveIndex->setType(IndexObjectType::CATEGORY_USER); $featureStatusesToRemove = array(); $featureStatusesToRemove[] = $featureStatusToRemoveIndex; $filter = new categoryKuserFilter(); $filter->setUserIdEqual($this->getPuserId()); kJobsManager::addIndexJob($this->getPartnerId(), IndexObjectType::CATEGORY_USER, $filter, true, $featureStatusesToRemove); } $ret = parent::postUpdate($con); if ($objectDeleted) { kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); // if user is deleted - check if shoult also delete login data UserLoginDataPeer::notifyOneLessUser($this->getLoginDataId()); } if ($objectUpdated) { kEventsManager::raiseEvent(new kObjectUpdatedEvent($this)); if (!$objectDeleted && !is_null($oldLoginDataId) && is_null($this->getLoginDataId())) { // if login was disabled - check if should also delete login data UserLoginDataPeer::notifyOneLessUser($oldLoginDataId); } } return $ret; }
public function addIndexCategoryInheritedTreeJob($fullIdsStartsWithCategoryId) { $featureStatusToRemoveIndex = new kFeatureStatus(); $featureStatusToRemoveIndex->setType(IndexObjectType::CATEGORY); $featureStatusesToRemove = array(); $featureStatusesToRemove[] = $featureStatusToRemoveIndex; $filter = new categoryFilter(); $filter->setFullIdsStartsWith($fullIdsStartsWithCategoryId); $filter->setInheritanceTypeEqual(InheritanceType::INHERIT); $c = KalturaCriteria::create(categoryPeer::OM_CLASS); $filter->attachToCriteria($c); KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); $categories = categoryPeer::doSelect($c); KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY); if (count($categories)) { kJobsManager::addIndexJob($this->getPartnerId(), IndexObjectType::CATEGORY, $filter, true, $featureStatusesToRemove); } }
protected function addIndexCategoryKuserJob($categoryId = null, $shouldUpdate = true) { $featureStatusToRemoveIndex = new kFeatureStatus(); $featureStatusToRemoveIndex->setType(IndexObjectType::CATEGORY_USER); $featureStatusesToRemove = array(); $featureStatusesToRemove[] = $featureStatusToRemoveIndex; $filter = new categoryKuserFilter(); $filter->setCategoryIdEqual($categoryId); kJobsManager::addIndexJob($this->getPartnerId(), IndexObjectType::CATEGORY_USER, $filter, $shouldUpdate, $featureStatusesToRemove); }
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; }
public function objectDataChanged(BaseObject $object, $previousVersion = null, BatchJob $raisedJob = null) { // updated in the indexing server (sphinx) $relatedObject = kMetadataManager::getObjectFromPeer($object); if ($relatedObject && $relatedObject instanceof IIndexable) { $relatedObject->setUpdatedAt(time()); $relatedObject->save(); $relatedObject->indexToSearchIndex(); } /** @var Metadata $object */ if ($object->getObjectType() == MetadataObjectType::DYNAMIC_OBJECT && !$object->isLikeNew()) { /** * when dynamic object is modified, we need to reindex the metadata and the objects (users, entries) * that are referencing it */ $profileFields = MetadataProfileFieldPeer::retrieveByPartnerAndRelatedMetadataProfileId($object->getPartnerId(), $object->getMetadataProfileId()); $relatedMetadataProfiles = array(); foreach ($profileFields as $profileField) { /** @var MetadataProfileField $profileField */ if (in_array($profileField->getMetadataProfileId(), $relatedMetadataProfiles)) { continue; } $filter = new MetadataFilter(); $filter->set('_eq_metadata_profile_id', $profileField->getMetadataProfileId()); $indexObjectType = kPluginableEnumsManager::apiToCore('IndexObjectType', MetadataPlugin::getApiValue(MetadataIndexObjectType::METADATA)); kJobsManager::addIndexJob($object->getPartnerId(), $indexObjectType, $filter, true); $relatedMetadataProfiles[] = $profileField->getMetadataProfileId(); } } if ($relatedObject instanceof entry) { kStorageExporter::reExportEntry($relatedObject); } return true; }