Пример #1
0
 protected function validateEntry($entry)
 {
     myPlaylistUtils::validatePlaylist($entry);
     // this is a small hack - to use this hook to update the count, countDate & the lengthInMsecs for the playlist
     // only if set "update_stats"
     if ($this->getP("update_stats")) {
         myPlaylistUtils::updatePlaylistStatistics($entry->getPartnerId(), $entry);
     }
 }
 protected function validateEntry($entry)
 {
     myPlaylistUtils::validatePlaylist($entry);
     // this is a small hack - to use this hook to update the count, countDate & the lengthInMsecs for the playlist
     // only if set "update_stats"
     $update_stats = $this->getP("update_stats");
     if ($update_stats == "false" || $update_stats === "0") {
         $update_stats = false;
     }
     if ($update_stats) {
         myPlaylistUtils::updatePlaylistStatistics($entry->getPartnerId(), $entry);
     }
     $entry->setDisplayInSearch(2);
     // make all the playlist entries PUBLIC !
 }
Пример #3
0
 /**
  * Update existing playlist
  * Note - you cannot change playlist type. updated playlist must be of the same type.
  *
  * @action update
  * @param string $id
  * @param KalturaPlaylist $playlist
  * @param bool $updateStats
  * @return KalturaPlaylist
  *
  * @throws APIErrors::INVALID_ENTRY_ID
  * @throws APIErrors::INVALID_PLAYLIST_TYPE
  * @validateUser entry id edit
  *
  * @disableRelativeTime $playlist
  */
 function updateAction($id, KalturaPlaylist $playlist, $updateStats = false)
 {
     $dbPlaylist = entryPeer::retrieveByPK($id);
     if (!$dbPlaylist) {
         throw new KalturaAPIException(APIErrors::INVALID_ENTRY_ID, "Playlist", $id);
     }
     if ($dbPlaylist->getType() != entryType::PLAYLIST) {
         throw new KalturaAPIException(APIErrors::INVALID_PLAYLIST_TYPE);
     }
     $playlist->playlistType = $dbPlaylist->getMediaType();
     // Added the following 2 lines in order to make the permission verifications in toUpdatableObject work on the actual db object
     // TODO: the following use of autoFillObjectFromObject should be replaced by a normal toUpdatableObject
     $playlistUpdate = clone $dbPlaylist;
     $playlistUpdate = $playlist->toUpdatableObject($playlistUpdate);
     $this->checkAndSetValidUserUpdate($playlist, $dbPlaylist);
     $this->checkAdminOnlyUpdateProperties($playlist);
     $this->validateAccessControlId($playlist);
     $this->validateEntryScheduleDates($playlist, $dbPlaylist);
     $allowEmpty = true;
     // TODO - what is the policy  ?
     if ($playlistUpdate->getMediaType() && $playlistUpdate->getMediaType() != $dbPlaylist->getMediaType()) {
         throw new KalturaAPIException(APIErrors::INVALID_PLAYLIST_TYPE);
     } else {
         $playlistUpdate->setMediaType($dbPlaylist->getMediaType());
         // incase  $playlistUpdate->getMediaType() was empty
     }
     // copy properties from the playlistUpdate to the $dbPlaylist
     baseObjectUtils::autoFillObjectFromObject($playlistUpdate, $dbPlaylist, $allowEmpty);
     // after filling the $dbPlaylist from  $playlist - make sure the data content is set properly
     if (!is_null($playlistUpdate->getDataContent(true)) && $playlistUpdate->getDataContent(true) != $dbPlaylist->getDataContent()) {
         $dbPlaylist->setDataContent($playlistUpdate->getDataContent(true));
         myPlaylistUtils::validatePlaylist($dbPlaylist);
     }
     if ($updateStats) {
         myPlaylistUtils::updatePlaylistStatistics($this->getPartnerId(), $dbPlaylist);
     }
     //, $extra_filters , $detailed );
     $dbPlaylist->save();
     $playlist->fromObject($dbPlaylist, $this->getResponseProfile());
     return $playlist;
 }