public function postUpdate(PropelPDO $con = null) { if (!$this->wasObjectSaved()) { return; } if ($this->alreadyInSave) { return parent::postUpdate($con); } $objectUpdated = $this->isModified(); $objectDeleted = false; if ($this->isColumnModified(entryPeer::STATUS) && $this->getStatus() == entryStatus::DELETED) { $objectDeleted = true; } $trackColumns = array(entryPeer::STATUS, entryPeer::MODERATION_STATUS, entryPeer::KUSER_ID, entryPeer::CREATOR_KUSER_ID, entryPeer::ACCESS_CONTROL_ID); $changedProperties = array(); foreach ($trackColumns as $trackColumn) { if ($this->isColumnModified($trackColumn)) { $column = entryPeer::translateFieldName($trackColumn, BasePeer::TYPE_COLNAME, BasePeer::TYPE_STUDLYPHPNAME); $previousValue = $this->getColumnsOldValue($trackColumn); $newValue = $this->getByName($trackColumn, BasePeer::TYPE_COLNAME); $changedProperties[] = "{$column} [{$previousValue}]->[{$newValue}]"; } } $ret = parent::postUpdate($con); if ($objectDeleted) { kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); myStatisticsMgr::deleteEntry($this); $trackEntry = new TrackEntry(); $trackEntry->setEntryId($this->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_DELETED_ENTRY); $trackEntry->setChangedProperties(implode("\n", $changedProperties)); $trackEntry->setDescription(__METHOD__ . "[" . __LINE__ . "]"); TrackEntry::addTrackEntry($trackEntry); } if ($objectUpdated) { kEventsManager::raiseEvent(new kObjectUpdatedEvent($this)); if (!$objectDeleted && count($changedProperties)) { $trackEntry = new TrackEntry(); $trackEntry->setEntryId($this->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPDATE_ENTRY); $trackEntry->setChangedProperties(implode("\n", $changedProperties)); $trackEntry->setDescription(__METHOD__ . "[" . __LINE__ . "]"); TrackEntry::addTrackEntry($trackEntry); } } return $ret; }
public function postUpdate(PropelPDO $con = null) { if (!$this->wasObjectSaved()) { return; } if ($this->alreadyInSave) { return parent::postUpdate($con); } $objectUpdated = $this->isModified(); $objectDeleted = false; if ($this->isColumnModified(entryPeer::STATUS) && $this->getStatus() == entryStatus::DELETED) { $objectDeleted = true; } if ($this->isColumnModified(entryPeer::DATA) && $this->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $partner = $this->getPartner(); if ($partner) { $dataArr = explode('.', $this->getData()); $id = $this->getId(); if ($id == $partner->getAudioThumbEntryId()) { $partner->setAudioThumbEntryVersion($dataArr[0]); $partner->save(); } if ($id == $partner->getLiveThumbEntryId()) { $partner->setLiveThumbEntryVersion($dataArr[0]); $partner->save(); } } } $trackColumns = $this->getTrackColumns(); $changedProperties = array(); foreach ($trackColumns as $namespace => $trackColumn) { if (is_array($trackColumn)) { if (isset($this->oldCustomDataValues[$namespace])) { foreach ($trackColumn as $trackCustomData) { if (isset($this->oldCustomDataValues[$namespace][$trackCustomData])) { $column = $trackCustomData; if ($namespace) { $column = "{$namespace}.{$trackCustomData}"; } $previousValue = $this->oldCustomDataValues[$namespace][$trackCustomData]; $previousValue = is_scalar($previousValue) ? $previousValue : $this->getTrackEntryString($namespace, $trackCustomData, $previousValue); $newValue = $this->getFromCustomData($trackCustomData, $namespace); $newValue = is_scalar($newValue) ? $newValue : $this->getTrackEntryString($namespace, $trackCustomData, $newValue); $changedProperties[] = "{$column} [{$previousValue}]->[{$newValue}]"; } } } } elseif ($this->isColumnModified($trackColumn)) { $column = entryPeer::translateFieldName($trackColumn, BasePeer::TYPE_COLNAME, BasePeer::TYPE_STUDLYPHPNAME); $previousValue = $this->getColumnsOldValue($trackColumn); $newValue = $this->getByName($trackColumn, BasePeer::TYPE_COLNAME); $changedProperties[] = "{$column} [{$previousValue}]->[{$newValue}]"; } } if ($this->getRedirectEntryId() && array_key_exists('', $this->oldCustomDataValues) && array_key_exists('redirectEntryId', $this->oldCustomDataValues[''])) { $redirectEntry = entryPeer::retrieveByPK($this->getRedirectEntryId()); if ($redirectEntry) { $redirectEntry->setModerationStatus($this->getModerationStatus()); $redirectEntry->save(); } } $ret = parent::postUpdate($con); if ($objectDeleted) { kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); myStatisticsMgr::deleteEntry($this); $trackEntry = new TrackEntry(); $trackEntry->setEntryId($this->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_DELETED_ENTRY); $trackEntry->setChangedProperties(implode("\n", $changedProperties)); $trackEntry->setDescription(__METHOD__ . "[" . __LINE__ . "]"); TrackEntry::addTrackEntry($trackEntry); //In case this entry has sub streams assigned to it we should delete them as well $subStreamEntries = entryPeer::retrieveChildEntriesByEntryIdAndPartnerId($this->id, $this->partner_id); foreach ($subStreamEntries as $subStreamEntry) { myEntryUtils::deleteEntry($subStreamEntry); } } if ($objectUpdated) { kEventsManager::raiseEvent(new kObjectUpdatedEvent($this)); if (!$objectDeleted && count($changedProperties)) { $trackEntry = new TrackEntry(); $trackEntry->setEntryId($this->getId()); $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPDATE_ENTRY); $trackEntry->setChangedProperties(implode("\n", $changedProperties)); $trackEntry->setDescription(__METHOD__ . "[" . __LINE__ . "]"); TrackEntry::addTrackEntry($trackEntry); } } return $ret; }
public function save(PropelPDO $con = null) { $is_new = false; if ($this->isNew()) { $this->setId(self::calculateId()); // start by setting the modified_at to the current time $this->setModifiedAt(time()); $this->setModerationCount(0); if (is_null($this->getAccessControlId())) { $partner = $this->getPartner(); if ($partner) { $this->setAccessControlId($partner->getDefaultAccessControlId()); } } // only media clips should increments - not roughcuts or backgrounds if ($this->type == entryType::MEDIA_CLIP) { myStatisticsMgr::addEntry($this); } $is_new = true; } if ($this->isColumnModified(entryPeer::STATUS) && $this->previous_status != $this->getStatus()) { // add a track for when the status changed $track_entry = new TrackEntry(); $track_entry->setEntryId($this->getId()); $track_entry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPDATE_ENTRY); $track_entry->setChangedProperties("status [{$this->previous_status}]->[{$this->getStatus()}]"); if ($this->previous_status != entryStatus::DELETED && $this->getStatus() == entryStatus::DELETED) { myStatisticsMgr::deleteEntry($this); $track_entry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_DELETED_ENTRY); } TrackEntry::addTrackEntry($track_entry); } if ($this->type == entryType::MIX) { // some of the properties should be copied to the kshow $kshow = $this->getkshow(); if ($kshow) { $modified = false; if ($kshow->getRank() != $this->getRank()) { $kshow->setRank($this->getRank()); $modified = true; } if ($kshow->getLengthInMsecs() != $this->getLengthInMsecs()) { $kshow->setLengthInMsecs($this->getLengthInMsecs()); $modified = true; } if ($modified) { $kshow->save(); } } else { $this->log("entry [" . $this->getId() . "] does not have a real kshow with id [" . $this->getKshowId() . "]", Propel::LOG_WARNING); } } myPartnerUtils::setPartnerIdForObj($this); if ($this->getType() != entryType::PLAYLIST) { mySearchUtils::setDisplayInSearch($this); } mySearchUtils::setSearchTextDiscreteForEntry($this); // update the admin_tags per partner ktagword::updateAdminTags($this); // same for puserId ... $this->getPuserId(true); // make sure this entry is saved before calling updateAllMetadataVersionsRelevantForEntry, since fixMetadata retrieves the entry from the DB // and checks its data path which was modified above. $res = parent::save($con); if ($is_new) { // when retrieving the entry - ignore thr filter - when in partner has moderate_content =1 - the entry will have status=3 and will fail the retrieveByPk entryPeer::setUseCriteriaFilter(false); $obj = entryPeer::retrieveByPk($this->getId()); $this->setIntId($obj->getIntId()); entryPeer::setUseCriteriaFilter(true); } if ($this->should_call_set_data_content) { // calling the funciton with null will cause it to use the $this->data_content $this->setDataContent(null); $res = parent::save($con); } // the fix should be done whether the status is READY or ERROR_CONVERTING if ($this->getStatus() == entryStatus::READY || $this->getStatus() == entryStatus::ERROR_CONVERTING) { // fire some stuff due to the new status $version_to_update = $this->getUpdateWhenReady(); if ($version_to_update) { try { myMetadataUtils::updateAllMetadataVersionsRelevantForEntry($this); $this->resetUpdateWhenReady(); $res = parent::save($con); } catch (Exception $e) { KalturaLog::err($e->getMessage()); } } } $this->syncCategories(); return $res; }