Commit 05b5662d authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Merge branch 'master' of labs.maarch.org:maarch/archivesCourrier

parents 60a4059e 2f79e53e
......@@ -34,8 +34,8 @@ class content
* Recherche d'un contenu d'archive
* @param string $query
* @param bool $hasParent
* @param date $sentDateFrom
* @param date $sentDateTo
* @param date $dateFrom
* @param date $dateTo
* @param string $originatorOrgRegNumber
*
* @return Array Array of archive description
......@@ -43,8 +43,8 @@ class content
public function find(
$query = null,
$hasParent = false,
$sentDateFrom = null,
$sentDateTo = null,
$dateFrom = null,
$dateTo = null,
$originatorOrgRegNumber = null)
{
$queryParts = array();
......@@ -63,31 +63,46 @@ class content
$queryParts['term'] = "<?SQL text @@ to_tsquery('".implode(' & ', $tokens)."') ?>";
}
// content description
if ($sentDateFrom && $sentDateTo) {
$queryParams['sentDateFrom'] = $sentDateFrom;
$queryParams['sentDateTo'] = $sentDateTo;
$queryParts['date'] = "sentDateTo >= :sentDateFrom AND sentDateFrom <= :sentDateTo";
} elseif ($sentDateFrom) {
$queryParams['sentDateFrom'] = $sentDateFrom;
$queryParts['date'] = "sentDateFrom >= :sentDateFrom";
} elseif ($sentDateTo) {
$queryParams['sentDateTo'] = $sentDateTo;
$queryParts['date'] = "sentDateTo <= :sentDateTo";
}
if ($originatorOrgRegNumber) {
$queryParams['originatorOrgRegNumber'] = $originatorOrgRegNumber;
$queryParts['originatorOrgRegNumber'] = "originatorOrgRegNumber = :originatorOrgRegNumber";
}
if ($hasParent === true) {
$queryParts['hasParent'] = "parentArchiveId!=null";
}
// Search forlders
if ($hasParent === false) {
$queryParts['hasParent'] = "parentArchiveId=null";
if ($dateFrom && $dateTo) {
$queryParams['dateFrom'] = $dateFrom;
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "endDate >= :dateFrom AND startDate <= :dateTo";
} elseif ($dateFrom) {
$queryParams['dateFrom'] = $dateFrom;
$queryParts['date'] = "endDate >= :dateFrom";
} elseif ($dateTo) {
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "startDate <= :dateTo";
}
}
// Search mails and attachments
if ($hasParent === true) {
$queryParts['hasParent'] = "parentArchiveId!=null";
if ($dateFrom && $dateTo) {
$queryParams['dateFrom'] = $dateFrom;
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "sentDate >= :dateFrom AND sentDate <= :dateTo";
} elseif ($dateFrom) {
$queryParams['dateFrom'] = $dateFrom;
$queryParts['date'] = "sentDate >= :dateFrom";
} elseif ($dateTo) {
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "sentDate <= :dateTo";
}
}
$queryString = \laabs\implode(' AND ', $queryParts);
......
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle archivesCourrier.
*
* Bundle archivesCourrier is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle archivesCourrier is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle archivesCourrier. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\archivesCourrier\bundle\archivesCourrier;
/**
* Interface pour l'index des courriers archivés
*
* @package ArchivesCourrier
* @author Cyril Vazquez <cyril.vazquez@maarch.org>
*/
interface contentInterface
{
/**
* Recherche d'un contenu d'archive
* @param string $query
* @param bool $hasParent
* @param date $dateFrom
* @param date $dateTo
* @param string $originatorOrgRegNumber
*
* @action archivesCourrier/content/find
*
* @return Array Array of archive description
*/
public function readSearch(
$query = null,
$hasParent = false,
$dateFrom = null,
$dateTo = null,
$originatorOrgRegNumber = null
);
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment