liste les modules en json

This commit is contained in:
fredtempez 2021-03-05 18:33:03 +01:00
parent 5bcb36c23d
commit 7dc0b4caf8
2 changed files with 24 additions and 1 deletions

View File

@ -37,7 +37,8 @@ class download extends common {
'statsDeleteAll' => self::GROUP_MODERATOR, 'statsDeleteAll' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR, 'index' => self::GROUP_VISITOR,
'rss' => self::GROUP_VISITOR, 'rss' => self::GROUP_VISITOR,
'downloadFile' => self::GROUP_VISITOR 'downloadFile' => self::GROUP_VISITOR,
'list' =>self::GROUP_VISITOR
]; ];
public static $items = []; public static $items = [];
@ -904,4 +905,25 @@ class download extends common {
]); ]);
} }
} }
/***
* Retourne une chaîne json contenant la liste des téléchargements disponibles
*/
public function list() {
$itemIdsPublishedOns = helper::arrayCollumn($this->getData(['module', $this->getUrl(0),'items']), 'publishedOn', 'SORT_DESC');
$itemIdsStates = helper::arrayCollumn($this->getData(['module', $this->getUrl(0), 'items']), 'state', 'SORT_DESC');
$itemIds = [];
foreach($itemIdsPublishedOns as $itemId => $itemPublishedOn) {
if($itemPublishedOn <= time() AND $itemIdsStates[$itemId]) {
$itemIds[] = $itemId;
}
}
foreach ($itemIds as $key) {
self::$items[$key] = $this->getData(['module', $this->getUrl(0), 'items', $key]);
}
$this->addOutput([
'display' => self::DISPLAY_JSON,
'content' => self::$items
]);
}
} }

View File

@ -0,0 +1 @@
<!-- rien -->