/**
  * Return the contrains
  *
  * @param Tx_Extbase_Persistence_QueryInterface $query The filter the references must apply to
  * @param Tx_Typo3Agencies_Domain_Model_Filter $filter The filter the references must apply to
  * @return array The references
  */
 protected function getConstraints(Tx_Extbase_Persistence_QueryInterface $query, Tx_Typo3Agencies_Domain_Model_Filter $filter)
 {
     $constrains = array();
     // Special case: remove certain type of record from the result set
     $_constrains = array();
     $_constrains[] = $query->logicalNot($query->equals('first_name', ''));
     $_constrains[] = $query->logicalNot($query->equals('last_name', ''));
     $_constrains[] = $query->logicalNot($query->equals('name', ''));
     $constrains[] = $query->logicalOr($_constrains);
     // Membership case
     $members = $filter->getMembers();
     if (!empty($members)) {
         $_constrains = array();
         foreach ($members as $member) {
             $_constrains[] = $query->equals('member', $member);
         }
         $constrains[] = $query->logicalOr($_constrains);
     } else {
         // get all membershiptypes
         $constrains[] = $query->greaterThan('member', 0);
     }
     // Service case
     if ($filter->getTrainingService()) {
         $constrains[] = $query->equals('training_service', $filter->getTrainingService());
     }
     if ($filter->getHostingService()) {
         $constrains[] = $query->equals('hosting_service', $filter->getHostingService());
     }
     if ($filter->getDevelopmentService()) {
         $constrains[] = $query->equals('development_service', $filter->getDevelopmentService());
     }
     // Country case
     if ($filter->getCountry()) {
         $constrains[] = $query->equals('country', $filter->getCountry());
     }
     if ($filter->getFeUser()) {
         $constrains[] = $query->logicalOr($query->equals('administrator', $filter->getFeUser()), $query->logicalAnd($query->equals('approved', true), $query->logicalOr($query->equals('payed_until_date', 0), $query->greaterThanOrEqual('payed_until_date', time()))));
     } else {
         $constrains[] = $query->logicalAnd($query->equals('approved', true), $query->logicalOr($query->equals('payed_until_date', 0), $query->greaterThanOrEqual('payed_until_date', time())));
     }
     return $constrains;
 }
示例#2
0
 /**
  * Builds and returns the constraint for multi value properties.
  *
  * @param Tx_Extbase_Persistence_QueryInterface $query
  * @param Tx_Extbase_DomainObject_DomainObjectInterface $parentObject
  * @param string $propertyName
  * @param string $fieldValue
  * @param array $relationTableMatchFields
  * @return Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint
  */
 protected function getConstraint(Tx_Extbase_Persistence_QueryInterface $query, Tx_Extbase_DomainObject_DomainObjectInterface $parentObject, $propertyName, $fieldValue = '', $relationTableMatchFields = array())
 {
     $columnMap = $this->getDataMap(get_class($parentObject))->getColumnMap($propertyName);
     if ($columnMap->getParentKeyFieldName() !== NULL) {
         $constraint = $query->equals($columnMap->getParentKeyFieldName(), $parentObject);
         if ($columnMap->getParentTableFieldName() !== NULL) {
             $constraint = $query->logicalAnd($constraint, $query->equals($columnMap->getParentTableFieldName(), $this->getDataMap(get_class($parentObject))->getTableName()));
         }
     } else {
         $constraint = $query->in('uid', t3lib_div::intExplode(',', $fieldValue));
     }
     if (count($relationTableMatchFields) > 0) {
         foreach ($relationTableMatchFields as $relationTableMatchFieldName => $relationTableMatchFieldValue) {
             $constraint = $query->logicalAnd($constraint, $query->equals($relationTableMatchFieldName, $relationTableMatchFieldValue));
         }
     }
     return $constraint;
 }