Skip to content

Commit

Permalink
Respect visibility (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytehead committed May 11, 2023
1 parent fd30636 commit f7e0a89
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/Model/PointOfInterestModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@

namespace Oneup\Contao\ContaoPointsOfInterestBundle\Model;

use Contao\Date;
use Contao\Model;

class PointOfInterestModel extends Model
{
protected static $strTable = 'tl_point_of_interest';

public static function findPublishedByPid($intPid, array $arrOptions = [])
{
$t = static::$strTable;
$arrColumns = ["$t.pid=?"];

if (!static::isPreviewMode($arrOptions)) {
$time = Date::floorToMinute();
$arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')";
}

return static::findBy($arrColumns, $intPid, $arrOptions);
}
}
2 changes: 1 addition & 1 deletion src/PointsOfInterest/ResponseRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getResponse(Template $template, Model $model, Request $request):
return $template->getResponse();
}

$pois = PointOfInterestModel::findBy('pid', $poi->id);
$pois = PointOfInterestModel::findPublishedByPid($poi->id);

$fileModel = FilesModel::findByUuid($poi->singleSRC);

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/contao/dca/tl_point_of_interest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
'wizard' => [
['oneup_contao_points_of_interest.dca_helper', 'showPositionPicker'],
],
'sql' => "mediumtext NULL",
'sql' => 'mediumtext NULL',
],
'cssID' => [
'exclude' => true,
Expand Down

0 comments on commit f7e0a89

Please sign in to comment.