コード例 #1
0
 /**
  * Returns a new CcPlaylistQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return    CcPlaylistQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof CcPlaylistQuery) {
         return $criteria;
     }
     $query = new CcPlaylistQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
コード例 #2
0
ファイル: BaseCcSubjs.php プロジェクト: nidzix/Airtime
 /**
  * Returns the number of related CcPlaylist objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related CcPlaylist objects.
  * @throws     PropelException
  */
 public function countCcPlaylists(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if (null === $this->collCcPlaylists || null !== $criteria) {
         if ($this->isNew() && null === $this->collCcPlaylists) {
             return 0;
         } else {
             $query = CcPlaylistQuery::create(null, $criteria);
             if ($distinct) {
                 $query->distinct();
             }
             return $query->filterByCcSubjs($this)->count($con);
         }
     } else {
         return count($this->collCcPlaylists);
     }
 }
コード例 #3
0
 /**
  * Finds the related CcPlaylist objects and keep them for later
  *
  * @param PropelPDO $con A connection object
  */
 protected function findRelatedCcPlaylists($con)
 {
     $criteria = clone $this;
     if ($this->useAliasInSQL) {
         $alias = $this->getModelAlias();
         $criteria->removeAlias($alias);
     } else {
         $alias = '';
     }
     $this->ccPlaylists = CcPlaylistQuery::create()->joinCcPlaylistcontents($alias)->mergeWith($criteria)->find($con);
 }
コード例 #4
0
ファイル: BaseCcPlaylist.php プロジェクト: nidzix/Airtime
 /**
  * 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(CcPlaylistPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $ret = $this->preDelete($con);
         if ($ret) {
             CcPlaylistQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
コード例 #5
0
 /**
  * Get the associated CcPlaylist object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     CcPlaylist The associated CcPlaylist object.
  * @throws     PropelException
  */
 public function getCcPlaylist(PropelPDO $con = null)
 {
     if ($this->aCcPlaylist === null && $this->playlist_id !== null) {
         $this->aCcPlaylist = CcPlaylistQuery::create()->findPk($this->playlist_id, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aCcPlaylist->addCcPlaylistcontentss($this);
         		 */
     }
     return $this->aCcPlaylist;
 }
コード例 #6
0
ファイル: Playlist.php プロジェクト: romansavrulin/Airtime
 public function setPLMetaData($category, $value)
 {
     $cat = $this->categories[$category];
     $row = CcPlaylistQuery::create()->findPK($this->id);
     $method = 'set' . $cat;
     $row->{$method}($value);
     $row->save();
     return TRUE;
 }
コード例 #7
0
 private static function playlistsNotOwnedByUser($p_ids, $p_userId)
 {
     $ownedByUser = CcPlaylistQuery::create()->filterByDbCreatorId($p_userId)->find()->getData();
     $selectedPls = $p_ids;
     $ownedPls = array();
     foreach ($ownedByUser as $pl) {
         if (in_array($pl->getDbId(), $selectedPls)) {
             $ownedPls[] = $pl->getDbId();
         }
     }
     $leftOvers = array_diff($selectedPls, $ownedPls);
     return $leftOvers;
 }
コード例 #8
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();
     }
 }