Skip to content

Commit

Permalink
Setup setting support for recommendation engine
Browse files Browse the repository at this point in the history
  • Loading branch information
kormoc committed Apr 7, 2013
1 parent ff50f84 commit f660af4
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 2 deletions.
15 changes: 13 additions & 2 deletions includes/db_update.php
Expand Up @@ -9,7 +9,7 @@
/**/

// What *should* the database version be?
define('WebDBSchemaVer', 3);
define('WebDBSchemaVer', 4);

// What version does the database think it is?
$db_vers = intval(setting('WebDBSchemaVer'));
Expand All @@ -26,6 +26,7 @@
// Older database that needs to be upgraded
if ($db_vers < WebDBSchemaVer) {
switch ($db_vers) {

// No version, no database
case 0:
$db->query('DROP TABLE IF EXISTS mythweb_sessions');
Expand All @@ -36,10 +37,12 @@
INDEX (modified)
)');
setting('WebDBSchemaVer', null, ++$db_vers, false);

// Moving settings into the database
case 1:
setting('WebPrefer_Channum', null, 1, false);
setting('WebDBSchemaVer', null, ++$db_vers, false);

// Add default width for recording details if they have not been set yet
case 2:
$width = intval(setting('WebFLV_w'));
Expand All @@ -49,8 +52,16 @@
setting('WebFLV_w', null, 160, false);
}
setting('WebDBSchemaVer', null, ++$db_vers, false);

case 3:
setting('recommend_enabled', null, false);
setting('recommend_server', null, 'http://myth-recommendations.aws.af.cm/');
setting('recommend_key', null, 'REQUIRED');

This comment has been minimized.

Copy link
@dreamcat4

dreamcat4 Jul 24, 2014

@kormoc those 3 lines of code can sometimes results in this bug:

https://code.mythtv.org/trac/ticket/12220#comment:12

Please help if you can. Many thanks.

setting('WebDBSchemaVer', null, ++$db_vers, false);

// All other numbers should run their changes sequentially
#case 3:
#case N:
# # do something to upgrade the database here
# $db_vers++;
}
Expand Down
1 change: 1 addition & 0 deletions modules/mythweb/init.php
Expand Up @@ -14,6 +14,7 @@
'choices' => array('session' => t('My Session'),
'defaults' => t('MythWeb Defaults'),
'flvplayer' => t('Video Playback'),
'recommend' => t('Recommend Videos'),
),
'default' => 'session',
);
20 changes: 20 additions & 0 deletions modules/mythweb/set_recommend.php
@@ -0,0 +1,20 @@
<?php
/**
* Display/save recommendation settings
*
* @license GPL
*
* @package MythWeb
* @subpackage Settings
*
/**/

// Save?
if ($_POST['save']) {
setting('recommend_enabled', null, (bool)$_POST['recommend_enabled']);
setting('recommend_server', null, $_POST['recommend_server']);
setting('recommend_key', null, $_POST['recommend_key']);
}

// These settings are limited to MythWeb itself
$Settings_Hosts = 'MythWeb';
55 changes: 55 additions & 0 deletions modules/mythweb/tmpl/default/set_recommend.php
@@ -0,0 +1,55 @@
<?php
/**
* Configure MythWeb Recommendation settings
*
* @license GPL
*
* @package MythWeb
* @subpackage Settings
*
/**/
?>

<form class="form" method="post" action="<?php echo form_action ?>">

<table border="0" cellspacing="0" cellpadding="0">

<tr>
<th><?php echo t('Enable') ?>:</th>
<td>
<input class="radio"
type="checkbox"
name="recommend_enabled"
title="<?php echo t('Enable') ?>"
<?php if (setting('recommend_enabled')) echo ' CHECKED'; ?>>
</td>
</tr>

<tr>
<th><?php echo t('API Server') ?>:</th>
<td>
<input type="text"
name="recommend_server"
title="<?php echo t('API Server') ?>"
value="<?php echo html_entities(setting('recommend_server')) ?>" />
</td>
</tr>

<tr>
<th><?php echo t('API Key') ?>:</th>
<td>
<input type="text"
name="recommend_key"
title="<?php echo t('API Server') ?>"
value="<?php echo html_entities(setting('recommend_key')) ?>" />
</td>
</tr>

<tr>
<td align="right"><input type="reset" class="submit" value="<?php echo t('Reset') ?>"></td>
<td align="center"><input type="submit" class="submit" name="save" value="<?php echo t('Save') ?>"></td>
</tr>

</table>

</form>

0 comments on commit f660af4

Please sign in to comment.