Пример #1
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this CcFiles is new, it will return
  * an empty collection; or if this CcFiles has previously
  * been saved, it will retrieve related CcBlockcontentss 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 CcFiles.
  *
  * @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 CcBlockcontents[] List of CcBlockcontents objects
  */
 public function getCcBlockcontentssJoinCcBlock($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = CcBlockcontentsQuery::create(null, $criteria);
     $query->joinWith('CcBlock', $join_behavior);
     return $this->getCcBlockcontentss($query, $con);
 }
Пример #2
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(CcBlockcontentsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $ret = $this->preDelete($con);
         if ($ret) {
             CcBlockcontentsQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Пример #3
0
 public function shuffleSmartBlock()
 {
     // if it here that means it's static pl
     $this->saveType("static");
     $contents = CcBlockcontentsQuery::create()->filterByDbBlockId($this->id)->orderByDbPosition()->find();
     $shuffledPos = range(0, count($contents) - 1);
     shuffle($shuffledPos);
     foreach ($contents as $item) {
         $item->setDbPosition(array_shift($shuffledPos));
         $item->save();
     }
     return array("result" => 0);
 }
 /**
  * Returns a new CcBlockcontentsQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return    CcBlockcontentsQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof CcBlockcontentsQuery) {
         return $criteria;
     }
     $query = new CcBlockcontentsQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Пример #5
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();
     }
 }