Ejemplo n.º 1
0
 /**
  * Return parent category
  *
  * @param void
  * @return DocumentCategory
  */
 function getCategory()
 {
     if ($this->category === false) {
         $this->category = DocumentCategories::findByDocument($this);
     }
     // if
     return $this->category->getId();
 }
 /**
  * Quick add document category
  *
  * @param void
  * @return null
  */
 function quick_add()
 {
     if ($this->request->isSubmitted() && $this->request->isAsyncCall()) {
         if (!DocumentCategory::canAdd($this->logged_user)) {
             $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
         }
         // if
         $document_category = new DocumentCategory();
         $document_category->setAttributes($this->request->post('document_category'));
         $save = $document_category->save();
         if ($save && !is_error($save)) {
             print $document_category->getId();
             die;
         } else {
             $this->serveData($save);
         }
         // if
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }
Ejemplo n.º 3
0
 /**
  * Paginate documents by category
  *
  * @param DocumentCategory $category
  * @param integer	$min_visibility
  * @param integer $page
  * @param integer $per_page
  * @return array
  */
 function paginateByCategory($category, $min_visibility = VISIBILITY_PRIVATE, $page = 1, $per_page = 30)
 {
     return Documents::paginate(array('conditions' => array('category_id = ? AND visibility >= ?', $category->getId(), $min_visibility), 'order' => 'is_pinned DESC, name'), $page, $per_page);
 }
Ejemplo n.º 4
0
 /**
  * Filter the query by a related DocumentCategory object
  *
  * @param   DocumentCategory|PropelObjectCollection $documentCategory The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 DocumentQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByDocumentCategory($documentCategory, $comparison = null)
 {
     if ($documentCategory instanceof DocumentCategory) {
         return $this->addUsingAlias(DocumentPeer::DOCUMENT_CATEGORY_ID, $documentCategory->getId(), $comparison);
     } elseif ($documentCategory instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(DocumentPeer::DOCUMENT_CATEGORY_ID, $documentCategory->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByDocumentCategory() only accepts arguments of type DocumentCategory or PropelCollection');
     }
 }
Ejemplo n.º 5
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param DocumentCategory $obj A DocumentCategory object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         DocumentCategoryPeer::$instances[$key] = $obj;
     }
 }
Ejemplo n.º 6
0
 /**
  * Exclude object from result
  *
  * @param   DocumentCategory $documentCategory Object to remove from the list of results
  *
  * @return DocumentCategoryQuery The current query, for fluid interface
  */
 public function prune($documentCategory = null)
 {
     if ($documentCategory) {
         $this->addUsingAlias(DocumentCategoryPeer::ID, $documentCategory->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Ejemplo n.º 7
0
 /**
  * Declares an association between this object and a DocumentCategory object.
  *
  * @param                  DocumentCategory $v
  * @return Document The current object (for fluent API support)
  * @throws PropelException
  */
 public function setDocumentCategory(DocumentCategory $v = null)
 {
     if ($v === null) {
         $this->setDocumentCategoryId(NULL);
     } else {
         $this->setDocumentCategoryId($v->getId());
     }
     $this->aDocumentCategory = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the DocumentCategory object, it will not be re-added.
     if ($v !== null) {
         $v->addDocument($this);
     }
     return $this;
 }