public function getCriteria() { $oQuery = DocumentTypeQuery::create(); if ($this->oDelegateProxy->getDocumentKind() !== CriteriaListWidgetDelegate::SELECT_ALL) { $oQuery->filterByMimetype($this->oDelegateProxy->getDocumentKind() . '/%', Criteria::LIKE); } return $oQuery; }
public static function getDocumentKindsAssoc($bWithDocumentsOnly = false) { $aResult = array(); $oQuery = DocumentTypeQuery::create(); if ($bWithDocumentsOnly) { $oQuery->joinDocument(); } foreach ($oQuery->find() as $oDocumentType) { $aKind = explode('/', $oDocumentType->getMimeType()); $aResult[$aKind[0]] = self::getDocumentKindName($aKind[0]); } asort($aResult); return $aResult; }
public function saveData($aDocumentTypeData) { if ($this->iTypeId === null) { $oType = new DocumentType(); } else { $oType = DocumentTypeQuery::create()->findPk($this->iTypeId); } $this->validate($aDocumentTypeData, $oType); if (!Flash::noErrors()) { throw new ValidationException(); } $oType->setExtension($aDocumentTypeData['extension']); $oType->setMimetype($aDocumentTypeData['mimetype']); return $oType->save(); }
public function __construct($aRequestPath) { parent::__construct($aRequestPath); if (!isset($this->aPath[0])) { throw new Exception("Error in DocumentTypePreviewFileModule->__construct: no type given"); } $this->oDocumentType = DocumentTypeQuery::create()->findPk($this->aPath[0]); if ($this->oDocumentType === null) { throw new Exception("Error in DocumentTypePreviewFileModule->__construct: type invalid: {$this->aPath[0]}"); } $this->iSize = 512; if (isset($_REQUEST['size'])) { $this->iSize = min($this->iSize, (int) $_REQUEST['size']); } }
/** * Returns the number of related DocumentType objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related DocumentType objects. * @throws PropelException */ public function countDocumentTypesRelatedByUpdatedBy(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collDocumentTypesRelatedByUpdatedByPartial && !$this->isNew(); if (null === $this->collDocumentTypesRelatedByUpdatedBy || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collDocumentTypesRelatedByUpdatedBy) { return 0; } if ($partial && !$criteria) { return count($this->getDocumentTypesRelatedByUpdatedBy()); } $query = DocumentTypeQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByUserRelatedByUpdatedBy($this)->count($con); } return count($this->collDocumentTypesRelatedByUpdatedBy); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @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(DocumentTypePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = DocumentTypeQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // denyable behavior if (!(DocumentTypePeer::isIgnoringRights() || $this->mayOperate("delete"))) { throw new PropelException(new NotPermittedException("delete.by_role", array("role_key" => "documents"))); } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Get the associated DocumentType object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return DocumentType The associated DocumentType object. * @throws PropelException */ public function getDocumentType(PropelPDO $con = null, $doQuery = true) { if ($this->aDocumentType === null && $this->document_type_id !== null && $doQuery) { $this->aDocumentType = DocumentTypeQuery::create()->findPk($this->document_type_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->aDocumentType->addDocuments($this); */ } return $this->aDocumentType; }