get_preferences(); foreach ($preferences as $preference) { $name = 'localplay_' . $type . '_' . $preference['name']; /* Check for an existing record */ $sql = "SELECT id FROM preferences WHERE name = '" . sql_escape($name) . "'"; $db_results = mysql_query($sql, dbh()); if (mysql_num_rows($db_results)) { continue; } insert_preference($name,$preference['description'],$preference['default'],'25',$preference['type'],'streaming'); } // end foreach preferences /* Fix everyones preferences */ $sql = "SELECT * FROM `user`"; $db_results = Dba::query($sql); $temp_user = new User(); $temp_user->fix_preferences('-1'); while ($r = mysql_fetch_assoc($db_results)) { $temp_user->fix_preferences($r['username']); } // end while return true; } // insert_localplay_preferences /** * remove_localplay_preferences * This function has two uses, if it is called with a specific type then it * just removes the preferences for that type, however it if its called with * nothing then it removes any set of preferences where the module no longer * exists */ function remove_localplay_preferences($type=0) { /* If we've gotten a type wipe and go! */ if ($type) { $sql = "DELETE FROM preferences WHERE name LIKE 'localplay_" . sql_escape($type) . "_%'"; $db_results = mysql_query($sql, dbh()); return true; } /* Select everything but our two built-in ones $sql = "SELECT * FROM preferences WHERE name != 'localplay_level' AND name != 'localplay_controller' AND name LIKE 'localplay_%'"; $db_results = mysql_query($sql, dbh()); $results = array(); /* We need to organize by module to make it easy * to figure out which modules no longer exist * and wack the preferences... unless we've * specified a name then just wack those * preferences */ while ($r = mysql_fetch_assoc($db_results)) { $name = $r['name']; preg_match("/localplay_([\w\d\-\]+)_.+/",$name,$matches); $key = $matches['1']; $results[$key] = $r; } // end while /* If we've got a type */ //FIXME!!! } // remove_localplay_preferences /** * This function stores the Localplay object * It checks to see what access level you have * and creates the localplay object based on that * @package Local Play */ function init_localplay($reload=0) { static $localplay; if ($GLOBALS['user']->prefs['localplay_level'] == '0') { return false; } if (!strlen($GLOBALS['user']->prefs['localplay_controller'])) { return false; } if ($GLOBALS['user']->prefs['localplay_level'] == '1' AND !is_object($localplay)) { $localplay = new Localplay(conf('localplay_controller')); $localplay->connect(); } if ($GLOBALS['user']->prefs['localplay_level'] == '2' AND !is_object($localplay)) { $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); $localplay->connect(); } return $localplay; } // function init_localplay ?>