Ticket #2718: job-queue.diff

File job-queue.diff, 16.7 KB (added by jeff@…, 19 years ago)

Patch for job queue buttons

  • mythweb/modules/tv/tmpl/default/recorded.php

     
    236236    $prev_group = '';
    237237    $cur_group  = '';
    238238
     239    $rows_per_entry = $_SESSION['recorded_descunder'] ? 3 : 2;
     240    $buttons_under = TRUE;
     241
    239242    foreach ($All_Shows as $show) {
    240243
    241244    // Print a dividing row if grouping changes
     
    266269
    267270        echo "<tr id=\"inforow_$row\" class=\"recorded\">\n";
    268271        if ($group_field != "")
    269             echo "\t<td class=\"list\" rowspan=\"".($_SESSION['recorded_descunder'] ? 3 : 2)."\">&nbsp;</td>\n";
     272            echo "\t<td class=\"list\" rowspan=\"".$rows_per_entry."\">&nbsp;</td>\n";
    270273        if ($_SESSION['recorded_pixmaps']) {
    271             echo "\t<td rowspan=\"".($_SESSION['recorded_descunder'] ? 3 : 2).'">';
     274            echo "\t<td rowspan=\"".$rows_per_entry.'">';
    272275            if (file_exists(cache_dir.'/'.basename($show->filename).'.png')) {
    273276                list($width, $height, $type, $attr) = getimagesize(cache_dir.'/'.basename($show->filename).'.png');
    274277                echo "<a href=\"$show->url\" name=\"$row\">"
     
    297300    <td nowrap align="center"><?php echo strftime($_SESSION['date_recorded'], $show->starttime) ?></td>
    298301    <td nowrap><?php echo nice_length($show->length) ?></td>
    299302    <td nowrap><?php echo nice_filesize($show->filesize) ?></td>
    300 <?php   if ($show->endtime > time()) { ?>
     303<?php
     304    if (!$buttons_under) {
     305        if ($show->endtime > time()) { ?>
    301306    <td width="5%">currently recording</td>
    302307<?php   } else { ?>
    303     <td width="5%" rowspan="<?php echo $_SESSION['recorded_descunder'] ? 2 : 1 ?>" class="command command_border_l command_border_t command_border_b command_border_r" align="center">
     308    <td width="5%" rowspan="<?php echo $rows_per_entry - 1 ?>" class="command command_border_l command_border_t command_border_b command_border_r" align="center">
    304309        <a id="delete_<?php echo $row ?>"
    305310            href="<?php echo root ?>tv/recorded?delete=yes&chanid=<?php echo $show->chanid ?>&starttime=<?php echo $show->recstartts ?>"
    306311            js_href="javascript:confirm_delete(<?php echo $row ?>, false)";
     
    308313            ><?php echo t('Delete') ?></a>
    309314    </td>
    310315<?php   }
     316    }
    311317
    312318        if ($_SESSION['recorded_descunder'])
    313319            echo("</tr><tr id=\"descunderrow_".$row."\" class=\"recorded\">\n\t<td colspan=\"" . (6 + $recgroup_cols) . "\">".$show->description."</td>\n");
    314320?>
    315 </tr><tr id="statusrow_<?php echo $row ?>" class="recorded">
    316     <td nowrap colspan="<?php echo 6 + ($_SESSION['recorded_descunder'] ? 0 : 1) + $recgroup_cols ?>" align="center">
    317         <span style="padding-right: 25px"><?php echo t('has commflag') ?>:&nbsp;
    318             <b><?php echo $show->has_commflag ? t('Yes') : t('No') ?></b></span>
    319         <span style="padding-right: 25px"><?php echo t('has cutlist') ?>:&nbsp;
    320             <b><?php echo $show->has_cutlist ? t('Yes') : t('No') ?></b></span>
    321         <span style="padding-right: 25px"><?php echo t('is editing') ?>:&nbsp;
    322             <b><?php echo $show->is_editing ? t('Yes') : t('No') ?></b></span>
    323         <span style="padding-right: 25px"><?php echo t('auto-expire') ?>:&nbsp;
     321 </tr><tr id="statusrow_<?php echo $row ?>" class="recorded"><td colspan="<?php echo 6 + ($_SESSION['recorded_descunder'] ? 0 : 1) + $recgroup_cols ?>">
     322 <table width="100%" cellspacing="2" cellpadding="1"><tr>
     323     <td align="center"><?php echo t('has commflag') ?>:&nbsp;
     324             <b><?php echo $show->has_commflag ? t('Yes') : t('No') ?></b></td>
     325     <td align="center"><?php echo t('has cutlist') ?>:&nbsp;
     326             <b><?php echo $show->has_cutlist ? t('Yes') : t('No') ?></b></td>
     327     <td align="center"><?php echo t('is editing') ?>:&nbsp;
     328             <b><?php echo $show->is_editing ? t('Yes') : t('No') ?></b></td>
     329     <td align="center"><?php echo t('auto-expire') ?>:&nbsp;
    324330            <input type="checkbox" id="autoexpire_<?php echo $show->chanid, '.', $show->recstartts ?>"
    325331             name="autoexpire_<?php echo $show->chanid, '.', $show->recstartts ?>"
    326332             <?php if ($show->auto_expire) echo ' CHECKED' ?> onclick="set_autoexpire(<?php echo $row ?>)" />
    327             </span>
    328         <span style="padding-right: 25px"><?php echo t('has bookmark') ?>:&nbsp;
    329             <b><?php echo $show->bookmark ? t('Yes') : t('No') ?></b></span>
    330         <?php echo t('has been watched') ?>:&nbsp;
    331             <b><?php echo $show->is_watched ? t('Yes') : t('No') ?></b>
    332         </td>
     333             </td>
     334     <td align="center"><?php echo t('has bookmark') ?>:&nbsp;
     335             <b><?php echo $show->bookmark ? t('Yes') : t('No') ?></b></td>
     336      <td align="center"><?php echo t('has been watched') ?>:&nbsp;
     337            <b><?php echo $show->is_watched ? t('Yes') : t('No') ?></b></td>
     338 
     339 <?php
     340     if ($buttons_under) {
     341         foreach ($jobs as $k => $desc) {
     342 ?>
     343         <td class="command command_border_l command_border_t command_border_b command_border_r" align="center">
     344             <a id="<?php echo $k.'_'.$row ?>"
     345                href="<?php echo root ?>tv/recorded?job=<?php echo $k; ?>&chanid=<?php echo $show->chanid;
     346                        ?>&starttime=<?php echo $show->starttime; ?>"
     347                ><?php echo $desc ?></a></td>
     348 <?php
     349        }
     350 
     351         if ($show->endtime > time()) { ?>
     352     <td width="10%">currently recording</td>
     353 <?php   } else { ?>
     354     <td width="5%" class="command command_border_l command_border_t command_border_b command_border_r" align="center">
     355         <a id="delete_<?php echo $row ?>"
     356             href="<?php echo root ?>tv/recorded?delete=yes&chanid=<?php echo $show->chanid ?>&starttime=<?php echo $show->recstartts ?>"
     357             js_href="javascript:confirm_delete(<?php echo $row ?>, false)";
     358             title="<?php echo html_entities(t('Delete $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>"
     359             ><?php echo t('Delete') ?></a>
     360     </td>
     361     <td width="5%" class="command command_border_l command_border_t command_border_b command_border_r" align="center">
     362         <a id="delete_rerecord_<?php echo $row ?>"
     363             href="<?php echo root ?>tv/recorded?delete=yes&chanid=<?php echo $show->chanid ?>&starttime=<?php echo $show->recstartts ?>&forget_old"
     364             js_href="javascript:confirm_delete(<?php echo $row ?>, true)";
     365             title="<?php echo html_entities(t('Delete and rerecord $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>"
     366             ><?php echo t('Delete + Rerecord') ?></a></td>
     367     </td>
     368 <?php   }
     369     }
     370 ?>
     371     </tr>
     372 </table>
     373 </td>
     374 <?php
     375     if (!$buttons_under) { ?>
    333376    <td width="5%" class="command command_border_l command_border_t command_border_b command_border_r" align="center">
    334377        <a id="delete_rerecord_<?php echo $row ?>"
    335378            href="<?php echo root ?>tv/recorded?delete=yes&chanid=<?php echo $show->chanid ?>&starttime=<?php echo $show->recstartts ?>&forget_old"
     
    337380            title="<?php echo html_entities(t('Delete and rerecord $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>"
    338381            ><?php echo t('Delete + Rerecord') ?></a></td>
    339382    </td>
     383<?php } ?>
    340384</tr><?php
    341385        $prev_group = $cur_group;
    342386    // Keep track of how many shows are visible in each section
  • mythweb/modules/tv/tmpl/compact/recorded.php

     
    236236    $prev_group = '';
    237237    $cur_group  = '';
    238238
     239    $rows_per_entry = $_SESSION['recorded_descunder'] ? 3 : 2;
     240    $buttons_under = TRUE;
     241
    239242    foreach ($All_Shows as $show) {
    240243
    241244    // Print a dividing row if grouping changes
     
    266269
    267270        echo "<tr id=\"inforow_$row\" class=\"recorded\">\n";
    268271        if ($group_field != "")
    269             echo "\t<td class=\"list\" rowspan=\"".($_SESSION['recorded_descunder'] ? 3 : 2)."\">&nbsp;</td>\n";
     272            echo "\t<td class=\"list\" rowspan=\"".$rows_per_entry."\">&nbsp;</td>\n";
    270273        if ($_SESSION['recorded_pixmaps']) {
    271             echo "\t<td rowspan=\"".($_SESSION['recorded_descunder'] ? 3 : 2).'">';
     274            echo "\t<td rowspan=\"".$rows_per_entry.'">';
    272275            if (file_exists(cache_dir.'/'.basename($show->filename).'.png')) {
    273276                list($width, $height, $type, $attr) = getimagesize(cache_dir.'/'.basename($show->filename).'.png');
    274277                echo "<a href=\"$show->url\" name=\"$row\">"
     
    297300    <td nowrap align="center"><?php echo strftime($_SESSION['date_recorded'], $show->starttime) ?></td>
    298301    <td nowrap><?php echo nice_length($show->length) ?></td>
    299302    <td nowrap><?php echo nice_filesize($show->filesize) ?></td>
    300 <?php   if ($show->endtime > time()) { ?>
     303<?php
     304    if (!$buttons_under) {
     305        if ($show->endtime > time()) { ?>
    301306    <td width="5%">currently recording</td>
    302307<?php   } else { ?>
    303     <td width="5%" rowspan="<?php echo $_SESSION['recorded_descunder'] ? 2 : 1 ?>" class="command command_border_l command_border_t command_border_b command_border_r" align="center">
     308    <td width="5%" rowspan="<?php echo $rows_per_entry - 1 ?>" class="command command_border_l command_border_t command_border_b command_border_r" align="center">
    304309        <a id="delete_<?php echo $row ?>"
    305310            href="<?php echo root ?>tv/recorded?delete=yes&chanid=<?php echo $show->chanid ?>&starttime=<?php echo $show->recstartts ?>"
    306311            js_href="javascript:confirm_delete(<?php echo $row ?>, false)";
     
    308313            ><?php echo t('Delete') ?></a>
    309314    </td>
    310315<?php   }
     316    }
    311317
    312318        if ($_SESSION['recorded_descunder'])
    313319            echo("</tr><tr id=\"descunderrow_".$row."\" class=\"recorded\">\n\t<td colspan=\"" . (6 + $recgroup_cols) . "\">".$show->description."</td>\n");
    314320?>
    315 </tr><tr id="statusrow_<?php echo $row ?>" class="recorded">
    316     <td nowrap colspan="<?php echo 6 + ($_SESSION['recorded_descunder'] ? 0 : 1) + $recgroup_cols ?>" align="center">
    317         <span style="padding-right: 25px"><?php echo t('has commflag') ?>:&nbsp;
    318             <b><?php echo $show->has_commflag ? t('Yes') : t('No') ?></b></span>
    319         <span style="padding-right: 25px"><?php echo t('has cutlist') ?>:&nbsp;
    320             <b><?php echo $show->has_cutlist ? t('Yes') : t('No') ?></b></span>
    321         <span style="padding-right: 25px"><?php echo t('is editing') ?>:&nbsp;
    322             <b><?php echo $show->is_editing ? t('Yes') : t('No') ?></b></span>
    323         <span style="padding-right: 25px"><?php echo t('auto-expire') ?>:&nbsp;
     321 </tr><tr id="statusrow_<?php echo $row ?>" class="recorded"><td colspan="<?php echo 6 + ($_SESSION['recorded_descunder'] ? 0 : 1) + $recgroup_cols ?>">
     322 <table width="100%" cellspacing="2" cellpadding="1"><tr>
     323     <td align="center"><?php echo t('has commflag') ?>:&nbsp;
     324             <b><?php echo $show->has_commflag ? t('Yes') : t('No') ?></b></td>
     325     <td align="center"><?php echo t('has cutlist') ?>:&nbsp;
     326             <b><?php echo $show->has_cutlist ? t('Yes') : t('No') ?></b></td>
     327     <td align="center"><?php echo t('is editing') ?>:&nbsp;
     328             <b><?php echo $show->is_editing ? t('Yes') : t('No') ?></b></td>
     329     <td align="center"><?php echo t('auto-expire') ?>:&nbsp;
    324330            <input type="checkbox" id="autoexpire_<?php echo $show->chanid, '.', $show->recstartts ?>"
    325331             name="autoexpire_<?php echo $show->chanid, '.', $show->recstartts ?>"
    326332             <?php if ($show->auto_expire) echo ' CHECKED' ?> onclick="set_autoexpire(<?php echo $row ?>)" />
    327             </span>
    328         <span style="padding-right: 25px"><?php echo t('has bookmark') ?>:&nbsp;
    329             <b><?php echo $show->bookmark ? t('Yes') : t('No') ?></b></span>
    330         <?php echo t('has been watched') ?>:&nbsp;
    331             <b><?php echo $show->is_watched ? t('Yes') : t('No') ?></b>
    332         </td>
     333             </td>
     334     <td align="center"><?php echo t('has bookmark') ?>:&nbsp;
     335             <b><?php echo $show->bookmark ? t('Yes') : t('No') ?></b></td>
     336      <td align="center"><?php echo t('has been watched') ?>:&nbsp;
     337            <b><?php echo $show->is_watched ? t('Yes') : t('No') ?></b></td>
     338 
     339 <?php
     340     if ($buttons_under) {
     341         foreach ($jobs as $k => $desc) {
     342 ?>
     343         <td class="command command_border_l command_border_t command_border_b command_border_r" align="center">
     344             <a id="<?php echo $k.'_'.$row ?>"
     345                href="<?php echo root ?>tv/recorded?job=<?php echo $k; ?>&chanid=<?php echo $show->chanid;
     346                        ?>&starttime=<?php echo $show->starttime; ?>"
     347                ><?php echo $desc ?></a></td>
     348 <?php
     349        }
     350 
     351         if ($show->endtime > time()) { ?>
     352     <td width="10%">currently recording</td>
     353 <?php   } else { ?>
     354     <td width="5%" class="command command_border_l command_border_t command_border_b command_border_r" align="center">
     355         <a id="delete_<?php echo $row ?>"
     356             href="<?php echo root ?>tv/recorded?delete=yes&chanid=<?php echo $show->chanid ?>&starttime=<?php echo $show->recstartts ?>"
     357             js_href="javascript:confirm_delete(<?php echo $row ?>, false)";
     358             title="<?php echo html_entities(t('Delete $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>"
     359             ><?php echo t('Delete') ?></a>
     360     </td>
     361     <td width="5%" class="command command_border_l command_border_t command_border_b command_border_r" align="center">
     362         <a id="delete_rerecord_<?php echo $row ?>"
     363             href="<?php echo root ?>tv/recorded?delete=yes&chanid=<?php echo $show->chanid ?>&starttime=<?php echo $show->recstartts ?>&forget_old"
     364             js_href="javascript:confirm_delete(<?php echo $row ?>, true)";
     365             title="<?php echo html_entities(t('Delete and rerecord $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>"
     366             ><?php echo t('Delete + Rerecord') ?></a></td>
     367     </td>
     368 <?php   }
     369     }
     370 ?>
     371     </tr>
     372 </table>
     373 </td>
     374 <?php
     375     if (!$buttons_under) { ?>
    333376    <td width="5%" class="command command_border_l command_border_t command_border_b command_border_r" align="center">
    334377        <a id="delete_rerecord_<?php echo $row ?>"
    335378            href="<?php echo root ?>tv/recorded?delete=yes&chanid=<?php echo $show->chanid ?>&starttime=<?php echo $show->recstartts ?>&forget_old"
     
    337380            title="<?php echo html_entities(t('Delete and rerecord $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>"
    338381            ><?php echo t('Delete + Rerecord') ?></a></td>
    339382    </td>
     383<?php } ?>
    340384</tr><?php
    341385        $prev_group = $cur_group;
    342386    // Keep track of how many shows are visible in each section
  • mythweb/modules/tv/recorded.php

     
    1313 *
    1414/**/
    1515
     16    require_once 'includes/jobqueue.php';
     17
    1618// Populate the $Channels array
    1719    load_all_channels();
    1820
     
    5355        }
    5456    }
    5557
     58    $q = '';
     59    for ($i = 1; $i < 5; ++$i) {
     60        $q .= ', \'UserJob'.$i.'\', \'UserJobDesc'.$i.'\'';
     61    }
     62
     63    $jobs = array();
     64
     65    $sh = $db->query('SELECT value, data
     66                        FROM settings
     67                        WHERE hostname IS NULL
     68                        AND value IN ('.substr($q, 2).')
     69                        ORDER BY value');
     70
     71    while (list($value, $data) = $sh->fetch_row()) {
     72        $jobs[$value] = $data;
     73    }
     74
     75    for ($i = 1; $i < 5; ++$i) {
     76        if ($jobs['UserJob'.$i])
     77            $jobs[JOB_USERJOBS * $i] = $jobs['UserJobDesc'.$i];
     78        unset($jobs['UserJobDesc'.$i]);
     79        unset($jobs['UserJob'.$i]);
     80    }
     81
     82    $jobs[JOB_TRANSCODE] = t('Transcode');
     83    $jobs[JOB_COMMFLAG] = t('Flag commercials');
     84
     85    ksort($jobs);
     86
    5687// Load the sorting routines
    5788    require_once "includes/sorting.php";
    5889
     
    75106        /** @todo need some sort of handler here for the non-ajax stuff */
    76107    }
    77108
     109// Queue a job?
     110    isset($_GET['job'])    or $_GET['job'] = $_POST['job'];
     111    if ($_GET['job'] && $_GET['chanid'] && $_GET['starttime']) {
     112        $sh = $db->query('INSERT jobqueue SET chanid=?, starttime=FROM_UNIXTIME(?), inserttime=NOW(),
     113                            type=?, hostname=?, args=\'\',
     114                            status='.JOB_QUEUED.', statustime=NOW(),
     115                            comment=\'Queued by MythWeb\',
     116                            flags='.JOB_USE_CUTLIST,
     117                         $_GET['chanid'],
     118                         $_GET['starttime'],
     119                         $_GET['job'],
     120                         hostname
     121                        );
     122    }
     123
    78124// Delete a program?
    79125    isset($_GET['forget_old']) or $_GET['forget_old'] = $_POST['forget_old'];
    80126    isset($_GET['delete'])     or $_GET['delete']     = $_POST['delete'];