create plugin.weekly-tracklist.php
This commit is contained in:
parent
cd26674fe6
commit
827de6373e
|
@ -0,0 +1,41 @@
|
||||||
|
<?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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue