Commit d51d3710 authored by Ghislain Loas's avatar Ghislain Loas

Merge branch 'hotline#84158_probleme_d_affichage_des_articles_de_l_agenda' into 'hotline'

hotline #84158 getArticlesByPreferences : fix filter by day when a month date is given

See merge request !2955
parents b4eebb71 7a51ed8f
Pipeline #5944 passed with stage
in 31 minutes and 13 seconds
- ticket #84158 : Boite agenda : correction de l'affichage des articles avec des jours récurrents sélectionnés.
\ No newline at end of file
......@@ -368,12 +368,16 @@ class ArticleLoader extends Storm_Model_Loader {
->_orderAndLimit()
->_getSelect();
$articles = Class_Article::getLoader()->findAll($select);
$articles = $this->_sortArticles(
$this->_filterByDay($this->_event_date,
$this->_filterByCustomFields(
Class_Article::getLoader()->findAll($select),
$this->_custom_fields)));
if ($this->_custom_fields)
$articles = $this->_filterByCustomFields($articles,
$this->_custom_fields);
if ((new ZendAfi_Validate_DateFormat)->isValid($this->_event_date))
$articles = $this->_filterByDay($this->_event_date, $articles);
$articles = $this->_sortArticles($articles);
if (
($this->_sort_order == 'Selection')
......
......@@ -99,8 +99,8 @@ class Class_TimeSource {
return (int)($this->hoursFrom($time) / 24);
}
public function hoursFrom($time) {
return (int)(($this->time() - $time) / 3660);
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH 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 AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Validate_DateFormat extends Zend_Validate_Abstract {
public function isValid($string, $format = 'Y-m-d') {
if (!$string)
return false;
$date = DateTime::createFromFormat($format, $string);
return $date && ($date->format($format) === $string);
}
}
\ No newline at end of file
......@@ -715,7 +715,11 @@ class ArticleLoaderFilterByDayTest extends ArticleLoaderGetArticlesByPreferences
$this->assertEquals([18, 55, 57],
$this->_getArticlesId(['event_date' => '2011-09-04']));
}
}
?>
/** @test */
public function withMonthShouldGetAllArticles() {
$this->assertEquals([23, 18, 55, 57],
$this->_getArticlesId(['event_date' => '2011-09']));
}
}
Markdown is supported
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