public function execute($filterChain) { // Execute this filter only once if ($this->isFirstCall()) { if ($this->getParameter("enable") == TRUE) { if ($this->getParameter("health_check") == TRUE) { $this->healthCheck(); } if ($this->getParameter("security") == TRUE) { $this->secureRequest(); } } $request = $this->getContext()->getRequest(); $partner_id = $request->getParameter("partner_id"); if (!$partner_id) { $partner_id = $request->getParameter("p"); } if ($partner_id == -1) { // add an extra logfile for specific partners - the directory will be the same as the kaltura_prod // the name will be p_<partner_id>.log $log_path = sfConfig::get("sf_log_dir"); $logger = sfLogger::getInstance(); $log = new sfFileLogger(); $log->initialize(array('file' => $log_path . "/p_{$partner_id}.log")); $logger->registerLogger($log); } } // Execute next filter $filterChain->execute(); // use this point to flush all the modified objects in mystatisticsMgr myStatisticsMgr::saveAllModified(); }
public function save(PropelPDO $con = null) { if ($this->isNew()) { myStatisticsMgr::addSubscriber($this); } parent::save($con); }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $obj_type = $this->getPM("obj_type"); $obj_id = $this->getPM("obj_id"); $command = $this->getPM("command"); $value = $this->getP("value"); $extra_info = $this->getP("extra_info"); if ($obj_type == "entry") { $entry = entryPeer::retrieveByPK($obj_id); if ($command == "view") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_VIEWS); myStatisticsMgr::incEntryViews($entry); } elseif ($command == "play") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_PLAYS); myStatisticsMgr::incEntryPlays($entry); } } elseif ($obj_type == "kshow") { $kshow = kshowPeer::retrieveByPK($obj_id); if ($command == "view") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_VIEWS); myStatisticsMgr::incKshowViews($kshow); } elseif ($command == "play") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_PLAYS); myStatisticsMgr::incKshowPlays($kshow); } } $this->addMsg("collectedStats", "{$obj_type}, {$obj_id}, {$command}, {$value}, {$extra_info}"); }
public function save(PropelPDO $con = null) { if ($this->isNew()) { $this->statistics_results = myStatisticsMgr::addKvote($this, $this->getRank()); } return parent::save($con); }
public function save(PropelPDO $con = null) { if ($this->isNew()) { $this->statistics_results = myStatisticsMgr::addKvote($this); } else { if (in_array(kvotePeer::STATUS, $this->modifiedColumns)) { $this->statistics_results = myStatisticsMgr::modifyEntryVotesBykVote($this); } } return parent::save($con); }
public function save(PropelPDO $con = null) { if ($this->isNew()) { $this->statistics_results = myStatisticsMgr::addKvote($this); } else { if (in_array(kvotePeer::STATUS, $this->modifiedColumns)) { $this->statistics_results = myStatisticsMgr::modifyEntryVotesBykVote($this); } } KalturaLog::debug("kvote status before save: " . $this->getStatus()); return parent::save($con); }
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 incViews($should_save = true) { myStatisticsMgr::incKuserViews($this); /* $v = $this->getViews ( ); if ( ! is_numeric( $v ) ) $v=0; $this->setViews( $v + 1 ); if ( $should_save) $this->save(); */ }
public function execute() { requestUtils::handleConditionalGet(); // set the memory size to be able to serve big files in a single chunk ini_set("memory_limit", "64M"); // set the execution time to be able to serve big files in a single chunk ini_set("max_execution_time", 240); $meta = $this->getRequestParameter("meta", false); $file_info = $this->getRequestParameter("file_info"); $this->entry_id = 0; $this->kshow_id = 0; $version = $this->getRequestParameter("version", null); // returned the version feature to allow rollback $addPadding = false; if (!empty($file_info)) { $file_info_arr = explode("-", $file_info); // the format of file_info is assumed <kshow_id>-<video|audio|voice>-<1|2|3> // OR // e<entry_id>-<video|audio|voice>-<1|2|3> if (count($file_info_arr) == 0) { $this->error = "Invalid request format [{$file_info}]"; return sfView::ERROR; } if ($file_info_arr[0][0] == 'e') { $this->entry_id = substr($file_info_arr[0], 1); } else { $this->kshow_id = $file_info_arr[0]; } if (count($file_info_arr) == 1) { // on this case we assume that the single info parameter is an entry id // we redirect to it ! $entry = entryPeer::retrieveByPK($this->entry_id); if (!$entry) { // very bad - no such entry !! echo "no entry " . $this->entry_id; die; } $dataKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); // replaced__getDataPath $path = kFileSyncUtils::getReadyLocalFilePathForKey($dataKey); $host = requestUtils::getHost(); $this->redirect($host . $path); } $this->timeline = $file_info_arr[1]; if (count($file_info_arr) > 2) { // this migth include a .flv suffix $last_token = $file_info_arr[2]; $last_token_srr = explode(".", $last_token); $this->streamNum = $last_token_srr[0]; if (count($file_info_arr) > 3) { $version = $file_info_arr[3]; } if (count($file_info_arr) > 4 && $file_info_arr[4] == "padding") { $addPadding = true; } } else { $this->streamNum = 3; } } else { $this->kshow_id = @$_GET["kshow_id"]; $this->entry_id = @$_GET["entry_id"]; $this->timeline = @$_GET["timeline"]; $this->streamNum = $this->getRequestParameter('num', 3); } $entry = null; if ($this->entry_id) { $entry = entryPeer::retrieveByPK($this->entry_id); if (!$entry) { $this->error = "No such entry " . $this->entry_id; return sfView::ERROR; } $this->kshow_id = $entry->getKshowId(); } $kshow = kshowPeer::retrieveByPK($this->kshow_id); if (!$kshow) { $this->error = "No such kshow " . $this->kshow_id; return sfView::ERROR; } if (!$entry) { // if we received only the kshow (old widgets) retrieve the entry $entry = entryPeer::retrieveByPK($kshow->getShowEntryId()); } if (!$entry) { $this->error = "No such entry for kshow " . $this->kshow_id; return sfView::ERROR; } // update the widget log only for video && stream 1 if ($this->timeline == "video" && $this->streamNum == 1) { $referer = @$_SERVER['HTTP_REFERER']; //since we're using a cdn this is useless //$kshow->incPlays(); //WidgetLog::incPlaysIfExists( $this->kshow_id , $this->entry_id ); } $dataKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version); // replaced__getDataPath $path = kFileSyncUtils::getReadyLocalFilePathForKey($dataKey); $this->flv_streamer = new myFlvStreamer($path, $this->timeline, $this->streamNum, $addPadding); $this->total_length = $this->flv_streamer->getTotalLength(true); // $total_length; //$this->getController()->setRenderMode ( sfView::RENDER_CLIENT ); myStatisticsMgr::saveAllModified(); //if ( $meta ) return "Meta"; return sfView::SUCCESS; }
public function incPlays() { myStatisticsMgr::incKshowPlays($this); }
public static function saveAllModified() { foreach (self::$s_dirty_objects as $id => $dirty_obj) { self::log("saving: [{$id}]"); $dirty_obj->save(); } // free all the object - create a new empty array self::$s_dirty_objects = array(); }
public static function setMetadata($content, $kshow, $show_entry, $ignore_current = false, $version_info = null) { $xml_content = ""; $show_entry_data_key = $show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); $current_content = $show_entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW ? "" : kFileSyncUtils::file_get_contents($show_entry_data_key); if ($ignore_current) { $current_content = ""; } $update_kshow = false; // compare the content and store only if different if ($content != $current_content) { $show_entry->setData("metadata.xml"); // re-create data key (to get latest version) $show_entry_data_key = $show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); //$version = myContentStorage::getVersion($file_name); //$comments = "file path: " . $file_name . "\n"; $comments = "version: " . $show_entry_data_key->version . "\n"; $total_duration = 0; $editor_type = null; $content = myFlvStreamer::fixMetadata($content, $show_entry_data_key->version, $total_duration, $editor_type); // TODO - make fixMetadata a more generic funciton to return the editorType as well // save info file about the version if (isset($version_info)) { $content = self::addVersionInfo($content, $version_info); } //fixme $content = myFlvStreamer::modifiedByKeditor ( $content ); // total_duration is in seconds with 2 digits after the decimal point $show_entry->setLengthInMsecs($total_duration * 1000); $show_entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW); $show_entry->setEditorType($editor_type); $show_entry->setModifiedAt(time()); // update the modified_at date $show_entry->save(); kFileSyncUtils::file_put_contents($show_entry_data_key, $content, true); $xml_content = kFileSyncUtils::file_get_contents($show_entry_data_key); // replaced__getFileContent $update_kshow = true; $show_entry_id = $show_entry->getId(); // update the roughcut_entry table $all_entries_for_roughcut = self::getAllEntries($content); roughcutEntry::updateRoughcut($show_entry->getId(), $show_entry->getVersion(), $show_entry->getKshowId(), $all_entries_for_roughcut); $xml_content = $content; } else { $xml_content = $current_content; $comments = "old and new files are the same"; } if (!$kshow->getHasRoughcut() && $kshow->getIntroId() != $show_entry->getId()) { $kshow->setHasRoughcut(true); $update_kshow = true; } myStatisticsMgr::incKshowUpdates($kshow); $kshow->save(); return array($xml_content, $comments, $update_kshow); }
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 incViews($should_save = true) { myStatisticsMgr::incEntryViews($this); }