xaseco-weekly-challenge/plugin.weekly-tracklist.php

41 lines
1.1 KiB
PHP
Raw Normal View History

2021-04-06 17:07:12 +02:00
<?php
/**
* This plugin loads a tracklist from the connected database and
* adjusts the playlist accordingly.
* The tracklist in DB should be saved as following:
*
* table: challenges
* - CalenderWeek // The week this challenge is online
* - FileName // The filename of the track relative to
* // $trackdir
*
* @author Fanyx
* @version 0.1.0
*
* Dependencies: requires plugin.localdatabase.php
*/
Aseco::registerEvent('onStartup', 'updatePlaylist');
function updatePlaylist($aseco) {
global $ldb_settings;
// get today's calender week
$week = date('W');
// read stored playlist from database at current CalenderWeek
$query = "SELECT Id, CalenderWeek, FileName FROM `challenges`
WHERE CalenderWeek=" . quotedString($week);
mysql_query($query);
if (mysql_affected_rows() == 0){
trigger_error('No Tracks were found for the current week. (' . mysql_error() . ')' . CRLF . 'sql = ' . $query, E_USER_WARNING);
} else {
while ($row = mysql_fetch_row()) {
$aseco->client->query('AddChallenge', $trackdir);
}
}
}
?>