Ticket #3788: expire_not_delete.3.diff

File expire_not_delete.3.diff, 11.2 KB (added by skamithi, 7 years ago)

patch i've been using for the last couple of weeks.

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

     
    337337        if ($show->can_delete) { 
    338338        ?><a onclick="javascript:confirm_delete(<?php echo $row ?>, false)" 
    339339            title="<?php echo html_entities(t('Delete $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>" 
    340             ><?php echo t('Delete') ?></a> 
     340            ><?php if (get_backend_setting('AutoExpireInsteadOfDelete') > 0 && 
     341                       $show->recgroup == 'Deleted') 
     342                        echo t('Delete Forever'); 
     343                    else 
     344                        echo t('Delete'); 
     345              ?></a> 
    341346        <a onclick="javascript:confirm_delete(<?php echo $row ?>, true)" 
    342347            title="<?php echo html_entities(t('Delete and allow rerecord: $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>" 
    343348            ><?php echo t('Delete + Rerecord') ?></a> 
     349 
     350<?php       if ($show->recgroup == 'Deleted') { 
     351                echo '<a href="', root, 'tv/recorded?undelete=yes&chanid=', $show->chanid, 
     352                    '&starttime=', $show->starttime, '" ' ?> 
     353                title="<?php echo html_entities(t('Undelete: $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>" 
     354                <?php echo '>' , t('Undelete') ?></a> 
     355<?php       } ?> 
    344356<?php   } ?> 
    345357        </td> 
    346358</tr><tr id="statusrow_<?php echo $row ?>" class="recorded"> 
  • mythplugins/mythweb/modules/tv/recorded.php

     
    1919// Load the sorting routines 
    2020    require_once 'includes/sorting.php'; 
    2121 
    22 // Delete a program? 
     22// Delete or undelete a program? 
    2323    isset($_GET['forget_old']) or $_GET['forget_old'] = $_POST['forget_old']; 
    2424    isset($_GET['delete'])     or $_GET['delete']     = $_POST['delete']; 
    2525    isset($_GET['file'])       or $_GET['file']       = $_POST['file']; 
    26     if ($_GET['delete']) { 
     26    if ($_GET['delete'] || $_GET['undelete']) { 
     27        if ($_GET['delete']) 
     28          $backendstr = 'DELETE_RECORDING'; 
     29        else  
     30          $backendstr = 'UNDELETE_RECORDING'; 
    2731    // Keep a previous-row counter to return to after deleting 
    2832        $prev_row = -2; 
    2933    // We need to scan through the available recordings to get at the additional information required by the DELETE_RECORDING query 
     
    3539            if ($row[4] != $_GET['chanid'] || $row[26] != $_GET['starttime']) 
    3640                continue; 
    3741        // Delete the recording 
    38             backend_command(array('FORCE_DELETE_RECORDING', implode(backend_sep, $row), '0')); 
     42            backend_command(array($backendstr, implode(backend_sep, $row), '0')); 
    3943        // Forget all knowledge of old recordings? 
    4044            if (isset($_GET['forget_old'])) { 
    4145                backend_command(array('FORGET_RECORDING', implode(backend_sep, $row), '0')); 
     
    105109        // keep track of their names and how many episodes we have recorded 
    106110            $Total_Programs++; 
    107111            $Groups[$record[30]]++; 
    108         // Hide LiveTV recordings from the title list 
    109             if (($_GET['recgroup'] && $_GET['recgroup'] == $record[30]) || (!$_GET['recgroup'] && $record[30] != 'LiveTV')) 
     112        // Hide LiveTV  and Deleted recordings from the title list 
     113            if (($_GET['recgroup'] && $_GET['recgroup'] == $record[30]) || (!$_GET['recgroup'] && $record[30] != 'LiveTV' && $record[30] != 'Deleted')) 
    110114                $Program_Titles[$record[0]]++; 
    111115        // Skip files with no chanid 
    112116            if (!$record[4]) 
     
    116120                continue; 
    117121            if ($_GET['recgroup'] && $_GET['recgroup'] != $record[30]) 
    118122                continue; 
    119         // Hide livetv recordings from the default view 
    120             if (empty($_GET['recgroup']) && $record[30] == 'LiveTV') 
     123        // Hide LiveTV recordings from the default view 
     124            if (empty($_GET['recgroup']) && ($record[30] == 'LiveTV' || $record[30] == 'Deleted')) 
    121125                continue; 
    122126        // Make sure that everything we're dealing with is an array 
    123127            if (!is_array($Programs[$record[0]])) 
  • mythtv/programs/mythfrontend/playbackbox.cpp

     
    16641664            p = *i; 
    16651665            if ((((p->recgroup == recGroup) || 
    16661666                  ((recGroup == "All Programs") && 
     1667                   (p->recgroup != "Deleted") && 
    16671668                   (p->recgroup != "LiveTV" || LiveTVInAllPrograms))) && 
    16681669                 (recGroupPassword == curGroupPassword)) || 
    16691670                ((recGroupType[recGroup] == "category") && 
     
    23042305    if (!curitem) 
    23052306        return; 
    23062307 
    2307     if ((curitem->availableStatus != asPendingDelete) && 
     2308    bool undelete_possible = 
     2309            gContext->GetNumSetting("AutoExpireInsteadOfDelete", 0); 
     2310 
     2311    if (curitem->recgroup != "Deleted" && undelete_possible) 
     2312        doRemove(curitem, false, false); 
     2313    else if ((curitem->availableStatus != asPendingDelete) && 
    23082314        (REC_CAN_BE_DELETED(curitem))) 
    23092315        remove(curitem); 
    23102316    else 
     
    31743180    popup->addButton(tr("Job Options"), this, SLOT(showJobPopup())); 
    31753181 
    31763182    if (!(m_player && m_player->IsSameProgram(curitem))) 
    3177         popup->addButton(tr("Delete"), this, SLOT(askDelete())); 
     3183    { 
     3184        if (curitem->recgroup == "Deleted") 
     3185        { 
     3186            popup->addButton(tr("Undelete"), this, 
     3187                        SLOT(doUndelete())); 
     3188            popup->addButton(tr("Delete Forever"), this, 
     3189                        SLOT(doDelete())); 
     3190        } 
     3191        else 
     3192        { 
     3193            popup->addButton(tr("Delete"), this, 
     3194                        SLOT(askDelete())); 
     3195        } 
     3196    } 
    31783197 
    31793198    popup->ShowPopup(this, SLOT(doCancel())); 
    31803199 
     
    35223541    playList.clear(); 
    35233542} 
    35243543 
     3544void PlaybackBox::doUndelete(void) 
     3545{ 
     3546    if (!expectingPopup) 
     3547    { 
     3548        previewSuspend = false; 
     3549        return;  
     3550    } 
     3551 
     3552    cancelPopup(); 
     3553    RemoteUndeleteRecording(curitem); 
     3554} 
     3555 
    35253556void PlaybackBox::doDelete(void) 
    35263557{ 
    35273558    if (!expectingPopup) 
  • mythtv/programs/mythfrontend/globalsettings.cpp

     
    577577    return bs; 
    578578}; 
    579579 
     580static GlobalCheckBox *AutoExpireInsteadOfDelete() 
     581{ 
     582    GlobalCheckBox *cb = new GlobalCheckBox("AutoExpireInsteadOfDelete"); 
     583    cb->setLabel(QObject::tr("Auto Expire Instead of Delete Recording")); 
     584    cb->setValue(false); 
     585    cb->setHelpText(QObject::tr("Instead of deleting a recording, " 
     586                                "move recording to the 'Deleted' recgroup " 
     587                                "and turn on autoexpire.")); 
     588    return cb; 
     589} 
     590 
    580591static GlobalComboBox *AutoExpireMethod() 
    581592{ 
    582593    GlobalComboBox *bc = new GlobalComboBox("AutoExpireMethod"); 
     
    38233834    autoexp->addChild(AutoExpireLiveTVMaxAge()); 
    38243835    autoexp->addChild(RerecordWatched()); 
    38253836    autoexp->addChild(AutoExpireExtraSpace()); 
     3837    autoexp->addChild(AutoExpireInsteadOfDelete()); 
    38263838    addChild(autoexp); 
    38273839 
    38283840    VerticalConfigurationGroup* jobs = new VerticalConfigurationGroup(false); 
  • mythtv/programs/mythfrontend/playbackbox.h

     
    160160    void doEditScheduled(); 
    161161 
    162162    void askDelete(); 
     163    void doUndelete(); 
    163164    void doDelete(); 
    164165    void doDeleteForgetHistory(); 
    165166    void doForceDelete(); 
  • mythtv/programs/mythbackend/mainserver.h

     
    8080                               bool forceMetadataDelete); 
    8181    void DoHandleDeleteRecording(ProgramInfo *pginfo, PlaybackSock *pbs, 
    8282                                 bool forceMetadataDelete); 
     83    void HandleUndeleteRecording(QStringList &slist, PlaybackSock *pbs); 
     84    void DoHandleUndeleteRecording(ProgramInfo *pginfo, PlaybackSock *pbs); 
    8385    void HandleForgetRecording(QStringList &slist, PlaybackSock *pbs); 
    8486    void HandleRescheduleRecordings(int recordid, PlaybackSock *pbs); 
    8587    void HandleQueryFreeSpace(PlaybackSock *pbs, bool allBackends); 
  • mythtv/programs/mythbackend/mainserver.cpp

     
    396396    { 
    397397        HandleDeleteRecording(listline, pbs, true); 
    398398    } 
     399    else if (command == "UNDELETE_RECORDING") 
     400    { 
     401        HandleUndeleteRecording(listline, pbs); 
     402    } 
    399403    else if (command == "RESCHEDULE_RECORDINGS") 
    400404    { 
    401405        if (tokens.size() != 2) 
     
    19161920    if (pbs) 
    19171921        pbssock = pbs->getSocket(); 
    19181922 
     1923    bool justexpire =  
     1924            (gContext->GetNumSetting("AutoExpireInsteadOfDelete") && 
     1925            (pginfo->recgroup != "Deleted") && (pginfo->recgroup != "LiveTV")); 
     1926 
     1927    if (justexpire && !forceMetadataDelete) 
     1928    { 
     1929        pginfo->ApplyRecordRecGroupChange("Deleted"); 
     1930        pginfo->SetAutoExpire(kDeletedAutoExpire); 
     1931        if (pginfo->recstatus == rsRecording) 
     1932            DoHandleStopRecording(pginfo, pbs); 
     1933        else 
     1934            delete pginfo; 
     1935        QStringList outputlist = QString::number(0); 
     1936        SendResponse(pbssock, outputlist); 
     1937        MythEvent me("RECORDING_LIST_CHANGE"); 
     1938        gContext->dispatch(me); 
     1939        return; 
     1940    } 
     1941 
    19191942    QString filename = pginfo->GetPlaybackURL(); 
    19201943 
    19211944    // If this recording was made by a another recorder, and that 
     
    20382061    delete pginfo; 
    20392062} 
    20402063 
     2064void MainServer::HandleUndeleteRecording(QStringList &slist, PlaybackSock *pbs) 
     2065{ 
     2066    ProgramInfo *pginfo  = new ProgramInfo(); 
     2067    pginfo->FromStringList(slist, 1); 
     2068 
     2069    DoHandleUndeleteRecording(pginfo, pbs); 
     2070} 
     2071 
     2072void MainServer::DoHandleUndeleteRecording(ProgramInfo *pginfo, PlaybackSock *pbs) 
     2073{ 
     2074    bool ret = -1; 
     2075    bool undelete_possible =  
     2076            gContext->GetNumSetting("AutoExpireInsteadOfDelete", 0); 
     2077    MythSocket *pbssock = NULL; 
     2078    if (pbs) 
     2079        pbssock = pbs->getSocket(); 
     2080 
     2081    if (undelete_possible) 
     2082    { 
     2083        pginfo->ApplyRecordRecGroupChange("Default"); 
     2084        pginfo->UpdateLastDelete(false); 
     2085        pginfo->SetAutoExpire(kDisableAutoExpire); 
     2086        delete pginfo; 
     2087        ret = 0; 
     2088        MythEvent me("RECORDING_LIST_CHANGE"); 
     2089        gContext->dispatch(me); 
     2090    } 
     2091 
     2092    QStringList outputlist = QString::number(ret); 
     2093    SendResponse(pbssock, outputlist); 
     2094} 
     2095 
    20412096void MainServer::HandleRescheduleRecordings(int recordid, PlaybackSock *pbs) 
    20422097{ 
    20432098    QStringList result;