Exemplo n.º 1
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return     void
  * @throws     PropelException
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(CcPlaylistcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $ret = $this->preDelete($con);
         if ($ret) {
             CcPlaylistcontentsQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Exemplo n.º 2
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this CcPlaylist is new, it will return
  * an empty collection; or if this CcPlaylist has previously
  * been saved, it will retrieve related CcPlaylistcontentss from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in CcPlaylist.
  *
  * @param      Criteria $criteria optional Criteria object to narrow the query
  * @param      PropelPDO $con optional connection object
  * @param      string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return     PropelCollection|array CcPlaylistcontents[] List of CcPlaylistcontents objects
  */
 public function getCcPlaylistcontentssJoinCcFiles($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = CcPlaylistcontentsQuery::create(null, $criteria);
     $query->joinWith('CcFiles', $join_behavior);
     return $this->getCcPlaylistcontentss($query, $con);
 }
Exemplo n.º 3
0
 /**
  * Change cueIn/cueOut values for playlist element
  *
  * @param int $pos
  * 		position of audioclip in playlist
  * @param string $cueIn
  * 		new value in ss.ssssss or extent format
  * @param string $cueOut
  * 		new value in ss.ssssss or extent format
  * @return boolean or pear error object
  */
 public function changeClipLength($pos, $cueIn, $cueOut)
 {
     $errArray = array();
     $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
     if (is_null($cueIn) && is_null($cueOut)) {
         $errArray["error"] = "Cue in and cue out are null.";
         return $errArray;
     }
     if (is_null($pos) || $pos < 0 || $pos >= $this->getNextPos()) {
         $errArray["error"] = "Invalid position.";
         return $errArray;
     }
     $row = CcPlaylistcontentsQuery::create()->joinWith(CcFilesPeer::OM_CLASS)->filterByDbPlaylistId($this->id)->filterByDbPosition($pos)->findOne();
     $oldCueIn = $row->getDBCuein();
     $oldCueOut = $row->getDbCueout();
     $fadeIn = $row->getDbFadein();
     $fadeOut = $row->getDbFadeout();
     $file = $row->getCcFiles();
     $origLength = $file->getDbLength();
     if (!is_null($cueIn) && !is_null($cueOut)) {
         if ($cueOut === "") {
             $cueOut = $origLength;
         }
         $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
         $r = $con->query($sql);
         if ($r->fetchColumn(0)) {
             $errArray["error"] = "Can't set cue in to be larger than cue out.";
             return $errArray;
         }
         $sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
         $r = $con->query($sql);
         if ($r->fetchColumn(0)) {
             $errArray["error"] = "Can't set cue out to be greater than file length.";
             return $errArray;
         }
         $sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
         $r = $con->query($sql);
         $cliplength = $r->fetchColumn(0);
         $row->setDbCuein($cueIn);
         $row->setDbCueout($cueOut);
         $row->setDBCliplength($cliplength);
     } else {
         if (!is_null($cueIn)) {
             $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
             $r = $con->query($sql);
             if ($r->fetchColumn(0)) {
                 $errArray["error"] = "Can't set cue in to be larger than cue out.";
                 return $errArray;
             }
             $sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'";
             $r = $con->query($sql);
             $cliplength = $r->fetchColumn(0);
             $row->setDbCuein($cueIn);
             $row->setDBCliplength($cliplength);
         } else {
             if (!is_null($cueOut)) {
                 if ($cueOut === "") {
                     $cueOut = $origLength;
                 }
                 $sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
                 $r = $con->query($sql);
                 if ($r->fetchColumn(0)) {
                     $errArray["error"] = "Can't set cue out to be smaller than cue in.";
                     return $errArray;
                 }
                 $sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
                 $r = $con->query($sql);
                 if ($r->fetchColumn(0)) {
                     $errArray["error"] = "Can't set cue out to be greater than file length.";
                     return $errArray;
                 }
                 $sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'";
                 $r = $con->query($sql);
                 $cliplength = $r->fetchColumn(0);
                 $row->setDbCueout($cueOut);
                 $row->setDBCliplength($cliplength);
             }
         }
     }
     $cliplength = $row->getDbCliplength();
     $sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
     $r = $con->query($sql);
     if ($r->fetchColumn(0)) {
         $fadeIn = $cliplength;
         $row->setDbFadein($fadeIn);
     }
     $sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
     $r = $con->query($sql);
     if ($r->fetchColumn(0)) {
         $fadeOut = $cliplength;
         $row->setDbFadein($fadeOut);
     }
     $row->save();
     return array("cliplength" => $cliplength, "cueIn" => $cueIn, "cueOut" => $cueOut, "length" => $this->getLength(), "fadeIn" => $fadeIn, "fadeOut" => $fadeOut);
 }
Exemplo n.º 4
0
 /**
  * Delete all files from playlist
  * @param int $p_playlistId
  */
 public function deleteAllFilesFromPlaylist()
 {
     // get only the files from the playlist
     // we are about to clear out
     $itemsToDelete = CcPlaylistcontentsQuery::create()->filterByDbPlaylistId($this->id)->filterByDbFileId(null, Criteria::NOT_EQUAL)->find();
     CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete();
     // update is_playlist flag in cc_files
     Application_Model_StoredFile::setIsPlaylist($itemsToDelete, 'playlist', false);
     $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
     $this->pl->save($this->con);
     $this->con->commit();
 }
Exemplo n.º 5
0
 public function updateBlockLengthInAllPlaylist()
 {
     $blocks = CcPlaylistcontentsQuery::create()->filterByDbBlockId($this->id)->find();
     $blocks->getFirst();
     $iterator = $blocks->getIterator();
     while ($iterator->valid()) {
         $length = $this->getUnformatedLength();
         if (!preg_match("/^[0-9]{2}:[0-9]{2}:[0-9]{2}/", $length)) {
             $iterator->current()->setDbClipLength(null);
         } else {
             $iterator->current()->setDbClipLength($length);
         }
         $iterator->current()->save();
         $iterator->next();
     }
 }
Exemplo n.º 6
0
 /**
  * Delete stored virtual file
  *
  * @param boolean $p_deleteFile
  *
  */
 public function delete()
 {
     $filepath = $this->getFilePath();
     // Check if the file is scheduled to be played in the future
     if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->getId())) {
         throw new DeleteScheduledFileException();
     }
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $user = new Application_Model_User($userInfo->id);
     $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
     if (!$isAdminOrPM && $this->getFileOwnerId() != $user->getId()) {
         throw new FileNoPermissionException();
     }
     $music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory());
     $type = $music_dir->getType();
     if (file_exists($filepath) && $type == "stor") {
         $data = array("filepath" => $filepath, "delete" => 1);
         try {
             Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
         } catch (Exception $e) {
             Logging::error($e->getMessage());
             return;
         }
     }
     // set hidden flag to true
     $this->_file->setDbHidden(true);
     $this->_file->save();
     // need to explicitly update any playlist's and block's length
     // that contains the file getting deleted
     $fileId = $this->_file->getDbId();
     $plRows = CcPlaylistcontentsQuery::create()->filterByDbFileId()->find();
     foreach ($plRows as $row) {
         $pl = CcPlaylistQuery::create()->filterByDbId($row->getDbPlaylistId($fileId))->findOne();
         $pl->setDbLength($pl->computeDbLength(Propel::getConnection(CcPlaylistPeer::DATABASE_NAME)));
         $pl->save();
     }
     $blRows = CcBlockcontentsQuery::create()->filterByDbFileId($fileId)->find();
     foreach ($blRows as $row) {
         $bl = CcBlockQuery::create()->filterByDbId($row->getDbBlockId())->findOne();
         $bl->setDbLength($bl->computeDbLength(Propel::getConnection(CcBlockPeer::DATABASE_NAME)));
         $bl->save();
     }
 }
Exemplo n.º 7
0
 /**
  * Delete all files from playlist
  * @param int $p_playlistId
  */
 public function deleteAllFilesFromPlaylist()
 {
     CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete();
 }