public function getCriteria() { $oQuery = LinkCategoryQuery::create(); if (!Session::getSession()->getUser()->getIsAdmin() || Settings::getSetting('admin', 'hide_externally_managed_link_categories', true)) { return $oQuery->filterByIsExternallyManaged(false); } return $oQuery; }
public function getCriteria() { $oQuery = LinkCategoryQuery::create()->distinct(); if ($this->bExcludeExternallyManaged) { $oQuery->filterByIsExternallyManaged(false); } return $oQuery; }
public function listCategories() { $oQuery = LinkCategoryQuery::create()->orderByName(); if (Settings::getSetting('admin', 'hide_externally_managed_link_categories', true)) { $oQuery->filterByIsExternallyManaged(false); } $aResult = array(); foreach ($oQuery->select(array('Id', 'Name'))->find() as $aData) { $aResult[] = array('key' => $aData['Id'], 'value' => $aData['Name']); } return $aResult; }
public static function getCategoryOptions() { $oQuery = LinkCategoryQuery::create()->orderByName(); if (!Session::getSession()->getUser()->getIsAdmin() || Settings::getSetting('admin', 'hide_externally_managed_link_categories', true)) { $oQuery->filterByIsExternallyManaged(false); } $aResult = $oQuery->select(array('Id', 'Name'))->find()->toKeyValue('Id', 'Name'); if (count($aResult) > 0 && !Settings::getSetting('admin', 'list_allows_multiple_categories', true)) { $aResult = array('' => ' ---- ') + $aResult; } return $aResult; }
public function externalLinks() { $aResult = array(); foreach (LinkCategoryQuery::create()->filterByHasLinks()->orderByName()->find() as $oLinkCategory) { foreach (LinkQuery::create()->filterByLinkCategoryId($oLinkCategory->getId())->orderByName()->find() as $oLink) { $aResult[$oLinkCategory->getName()][$oLink->getId()] = $oLink->getName(); } } $sWithoutCategory = TranslationPeer::getString('wns.links.select_without_title'); foreach (LinkQuery::create()->filterByLinkCategoryId(null, Criteria::ISNULL)->orderByName()->find() as $oLink) { $aResult[$sWithoutCategory][$oLink->getId()] = $oLink->getName(); } return $aResult; }
public function saveData($aLinkCategoryData) { if ($this->iLinkCategoryId === null) { $oLinkCategory = new LinkCategory(); } else { $oLinkCategory = LinkCategoryQuery::create()->findPk($this->iLinkCategoryId); } $this->validate($aLinkCategoryData); if (!Flash::noErrors()) { throw new ValidationException(); } $oLinkCategory->setName($aLinkCategoryData['name']); $oLinkCategory->setIsExternallyManaged($aLinkCategoryData['is_externally_managed']); $oLinkCategory->save(); $oResult = new stdClass(); if ($this->iLinkCategoryId === null) { $oResult->inserted = true; } else { $oResult->updated = true; } $oResult->id = $this->iLinkCategoryId = $oLinkCategory->getId(); return $oResult; }
public function getLinkCategoryName() { $oLinkCategory = LinkCategoryQuery::create()->findPk($this->oDelegateProxy->getLinkCategoryId()); if ($oLinkCategory) { return $oLinkCategory->getName(); } if ($this->oDelegateProxy->getLinkCategoryId() === CriteriaListWidgetDelegate::SELECT_WITHOUT) { return TranslationPeer::getString('wns.links.without_category'); } return $this->oDelegateProxy->getLinkCategoryId(); }
/** * Get the associated LinkCategory object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return LinkCategory The associated LinkCategory object. * @throws PropelException */ public function getLinkCategory(PropelPDO $con = null, $doQuery = true) { if ($this->aLinkCategory === null && $this->link_category_id !== null && $doQuery) { $this->aLinkCategory = LinkCategoryQuery::create()->findPk($this->link_category_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->aLinkCategory->addLinks($this); */ } return $this->aLinkCategory; }
/** * Returns the number of related LinkCategory objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related LinkCategory objects. * @throws PropelException */ public function countLinkCategorysRelatedByUpdatedBy(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collLinkCategorysRelatedByUpdatedByPartial && !$this->isNew(); if (null === $this->collLinkCategorysRelatedByUpdatedBy || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collLinkCategorysRelatedByUpdatedBy) { return 0; } if ($partial && !$criteria) { return count($this->getLinkCategorysRelatedByUpdatedBy()); } $query = LinkCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByUserRelatedByUpdatedBy($this)->count($con); } return count($this->collLinkCategorysRelatedByUpdatedBy); }
/** * 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(LinkCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = LinkCategoryQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // referenceable behavior if (ReferencePeer::hasReference($this)) { throw new PropelException("Exception in " . __METHOD__ . ": tried removing an instance from the database even though it is still referenced.", new StillReferencedException($this)); } // denyable behavior if (!(LinkCategoryPeer::isIgnoringRights() || $this->mayOperate("delete"))) { throw new PropelException(new NotPermittedException("delete.by_role", array("role_key" => "links"))); } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * 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(LinkCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $ret = $this->preDelete($con); if ($ret) { LinkCategoryQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (PropelException $e) { $con->rollBack(); throw $e; } }