diff options
Diffstat (limited to 'pages')
-rw-r--r-- | pages/Makefile | 2 | ||||
-rw-r--r-- | pages/edit_recording.ecpp | 162 | ||||
-rw-r--r-- | pages/edit_user.ecpp | 6 | ||||
-rw-r--r-- | pages/recordings.ecpp | 34 |
4 files changed, 195 insertions, 9 deletions
diff --git a/pages/Makefile b/pages/Makefile index c70ecb6..f4f1583 100644 --- a/pages/Makefile +++ b/pages/Makefile @@ -20,7 +20,7 @@ OBJS = menu.o recordings.o schedule.o multischedule.o screenshot.o \ searchepg.o login.o ibox.o xmlresponse.o play_recording.o \ pause_recording.o stop_recording.o ffw_recording.o \ rwd_recording.o setup.o content.o epginfo.o timerconflicts.o \ - recstream.o users.o edit_user.o + recstream.o users.o edit_user.o edit_recording.o ### Default rules: diff --git a/pages/edit_recording.ecpp b/pages/edit_recording.ecpp new file mode 100644 index 0000000..a6862ba --- /dev/null +++ b/pages/edit_recording.ecpp @@ -0,0 +1,162 @@ +<%pre> +#include <vdr/recording.h> +#include <vdr/config.h> +#include <vdr/i18n.h> +#include "exception.h" +#include "tools.h" +#include "epg_events.h" +#include "recman.h" +#include "setup.h" +#include "i18n.h" +#include "livefeatures.h" +#include "users.h" + +using namespace std; +using namespace vdrlive; + +</%pre> +<%args> + // input parameters + string recid; + string async; + // form parameters + string name = ""; + string directory = ""; + string deletions[]; +</%args> +<%session scope="global"> +bool logged_in(false); +string edit_rec_referer; +</%session> +<%request scope="page"> +const cRecording* recording; +</%request> +<%include>page_init.eh</%include> +<%cpp> + if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); + + if (!cUser::CurrentUserHasRightTo(UR_EDITRECS)) + throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") ); + + bool ajaxReq = !async.empty() && (lexical_cast<int>(async) != 0); + + string message; + + recording = NULL; + if (!recid.empty()) { + recording = LiveRecordingsManager()->GetByMd5Hash(recid); + if (!recording) + throw HtmlError(tr("Couldn't find recording. Maybe you mistyped your request?")); + } + + if (request.getMethod() == "POST") { + if (name.empty()) + message = tr("Please set a name for the recording!"); + else if (recording) { + for (deletions_type::const_iterator it = deletions.begin(); it != deletions.end(); ++it) { + if (*it == "resume") + LiveRecordingsManager()->DeleteResume(recording); + else if (*it == "marks") + LiveRecordingsManager()->DeleteMarks(recording); + } + deletions.clear(); + string filename = directory.empty() ? name : StringReplace(directory, "/", "~") + "~" + name; + if (LiveRecordingsManager()->RenameRecording(recording, FileSystemExchangeChars(filename, true))) + return reply.redirect(!edit_rec_referer.empty() ? edit_rec_referer : "recordings.html"); + else + message = tr("Cannot rename or move the recording."); + } + } + + if (message.empty()) + edit_rec_referer = request.getHeader("Referer:", "recordings.html"); + + if (recording) { + string path = recording->Name(); + size_t found = path.find_last_of("~"); + + if (found != string::npos) { + directory = StringReplace(path.substr(0, found), "~", "/"); + name = path.substr(found + 1); + } + else { + directory = ""; + name = path; + } + } +</%cpp> +<& pageelems.doc_type &> +<html> + <head> + <title>VDR Live - <$ tr("Edit recording") $></title> +<%cpp> + if (!ajaxReq) { +</%cpp> + <& pageelems.stylesheets &> + <& pageelems.ajax_js &> +<%cpp> + } +</%cpp> + </head> + <body> +<%cpp> + if (!ajaxReq) { +</%cpp> + <& pageelems.logo &> + <& menu active=("recordings") &> +<%cpp> + } +</%cpp> + <div class="inhalt"> + <form method="post" name="edit_recording" id="<$ recid $>" action="edit_recording.ecpp"> + <input type="hidden" name="recid" value="<$ recid $>"/> + <table class="formular" cellpadding="0" cellspacing="0"> + <tr class="head"> + <td class="toprow leftcol rightcol" colspan="2"><div class="boxheader"><div><div class="caption"><$ tr("Edit recording") $></div></div></div></td> + </tr> + <tr> + <td class="label leftcol"><div class="withmargin"><$ tr("Name") $>:</div></td> + <td class="rightcol"><input type="text" name="name" value="<$ name $>" size="80"/></td> + </tr> + <tr> + <td class="label leftcol"><div class="withmargin"><$ tr("Directory") $>:</div></td> + <td class="rightcol"> + <select name="directory" size="1" id="directory" style="margin-top: 5px"> +<%cpp> + DirectoryListPtr dirList(LiveRecordingsManager()->GetDirectoryList()); + DirectoryList::DirVecType::const_iterator dir; + + for (dir = dirList->begin(); dir != dirList->end(); ++dir) { +</%cpp> + <option value="<$ *dir $>"<$ (*dir == directory) ? "selected=\"selected\"" : "" $>><$ *dir $></option> +<%cpp> + } +</%cpp> + </select> + </td> + </tr> + <tr> + <td class="label leftcol"><div class="withmargin"><$ tr("Delete resume information") $>:</div></td> + <td class="rightcol"><input type="checkbox" name="deletions" value="resume"/></td> + </tr> + <tr> + <td class="label leftcol"><div class="withmargin"><$ tr("Delete marks information") $>:</div></td> + <td class="rightcol"><input type="checkbox" name="deletions" value="marks"/></td> + </tr> + <tr> + <td class="buttonpanel leftcol rightcol bottomrow" colspan="2"> + <div class="withmargin"> + <button class="green" type="submit"><$ tr("Save") $></button> + <button class="red" type="button" onclick="history.back()"><$ tr("Cancel") $></button> + </div> + </td> + </tr> + </table> + </form> + <div style="color: red; margin: 0 auto;"> + <$ message $> + </div> + </div> + </body> +</html> +<%include>page_exit.eh</%include> diff --git a/pages/edit_user.ecpp b/pages/edit_user.ecpp index 2ae510a..e1d977c 100644 --- a/pages/edit_user.ecpp +++ b/pages/edit_user.ecpp @@ -24,6 +24,7 @@ using namespace vdrlive; bool ur_switchchnl = false; bool ur_addstimers = false; bool ur_delstimers = false; + bool ur_editrecs = false; </%args> <%session scope="global"> bool logged_in(false); @@ -65,6 +66,7 @@ cUser* editUser; if (ur_switchchnl) editUser->SetRight(UR_SWITCHCHNL); if (ur_addstimers) editUser->SetRight(UR_EDITSTIMERS); if (ur_delstimers) editUser->SetRight(UR_DELSTIMERS); + if (ur_editrecs) editUser->SetRight(UR_EDITRECS); Users.Save(); @@ -89,6 +91,7 @@ cUser* editUser; ur_switchchnl = User->HasRightTo(UR_SWITCHCHNL); ur_addstimers = User->HasRightTo(UR_EDITSTIMERS); ur_delstimers = User->HasRightTo(UR_DELSTIMERS); + ur_editrecs = User->HasRightTo(UR_EDITRECS); editUser = User; } else @@ -102,6 +105,7 @@ cUser* editUser; ur_switchchnl = true; ur_addstimers = true; ur_delstimers = true; + ur_editrecs = true; } </%cpp> <& pageelems.doc_type &> @@ -158,6 +162,8 @@ cUser* editUser; <%cpp> } </%cpp> + <input type="checkbox" name="ur_editrecs" value="1" <{ CHECKIF(ur_editrecs) }> /> + <label for="ur_editrecs"><$ tr("Edit recordings") $></label><br> </td> </tr> <tr> diff --git a/pages/recordings.ecpp b/pages/recordings.ecpp index b5272b9..b6630d1 100644 --- a/pages/recordings.ecpp +++ b/pages/recordings.ecpp @@ -24,6 +24,7 @@ using namespace std; <%args> string todel; string diskinfo; + string deletions[]; </%args> <%session scope="global"> bool logged_in(false); @@ -37,14 +38,20 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); pageTitle = tr("Recordings"); +deleteResult = ""; if (!todel.empty()) { - RemoveRecordingTask task(todel); + deletions.push_back(todel); +} +for (deletions_type::const_iterator it = deletions.begin(); it != deletions.end(); ++it) { + RemoveRecordingTask task(*it); LiveTaskManager().Execute(task); if (!task.Result()) - deleteResult = string() + tr("ERROR:") + " " + task.Error(); + deleteResult += string() + tr("ERROR:") + " " + task.Error() + "<br/>"; else - deleteResult = string() + tr("Deleted recording:") + " " + StringReplace(task.RecName(), "~", "/"); + deleteResult += string() + tr("Deleted recording:") + " " + StringReplace(task.RecName(), "~", "/") + "<br/>"; } +deletions.clear(); + int FreeMB, UsedMB; int Percent = VideoDiskSpace(&FreeMB, &UsedMB); int Minutes = int(double(FreeMB) / MB_PER_MINUTE); @@ -82,11 +89,14 @@ if (! deleteResult.empty()) { <%cpp> } else { </%cpp> + <form method="post" name="recordings" action="recordings.ecpp"> <div class="recordings"> <ul class="recordingslist" style="display: block;"> <& recordings.recordings_item &> </ul> </div> + <div class="withmargin"><button class="red" type="submit"><$ tr("Delete selected") $></button></div> + </form> <%cpp> } </%cpp> @@ -165,6 +175,16 @@ for (iter = recordingsTree->begin(path); iter != end; ++iter) { <# ---------------------------------------------------------------------- #> +<%def edit_rec> +<%args> + string id; +</%args> +<%cpp> { </%cpp><a href="edit_recording.html?recid=<$ id $>"><img src="<$ LiveSetup().GetThemedLink("img", "edit.png") $>" alt="" <& tooltip.hint text=(tr("Edit recording")) &> /></a><%cpp> } </%cpp> +</%def> + +<# ---------------------------------------------------------------------- #> + + <%def rec_tools> <%args> string id; @@ -173,6 +193,7 @@ for (iter = recordingsTree->begin(path); iter != end; ++iter) { <& pageelems.ajax_action_href action="play_recording" param=(id) tip=(tr("play this recording.")) image="play.png" alt="" &> <& pageelems.vlc_stream_recording recid=(id) &> <& pageelems.imdb_info_href title=(title) &> +<& recordings.edit_rec id=(id) &> <& recordings.del_rec id=(id) &> </%def> @@ -226,7 +247,7 @@ for (iter = recordingsTree->begin(path); iter != end; ++iter) { char const * recFormatStr( tr("%a %x %X") ); </%cpp> <div class="recording_item"> - <div class="recording_imgs"><%cpp> reply.out() << StringRepeat(level + 1, "<img src=\"img/transparent.png\" alt=\"\" width=\"16px\" height=\"16px\" />"); </%cpp><%cpp> if (!archived.empty()) { </%cpp><img src="<$ LiveSetup().GetThemedLink("img", "on_dvd.png") $>" alt="on_dvd" <& tooltip.hint text=(archived) &> /><%cpp> } else { </%cpp><img src="<$ LiveSetup().GetThemedLink("img", "movie.png") $>" alt="movie" /><%cpp> } </%cpp></div> + <div class="recording_imgs"><%cpp> reply.out() << StringRepeat(level + 1, "<img src=\"img/transparent.png\" alt=\"\" width=\"16px\" height=\"16px\" />"); </%cpp><%cpp> if (!archived.empty()) { </%cpp><img src="<$ LiveSetup().GetThemedLink("img", "on_dvd.png") $>" alt="on_dvd" <& tooltip.hint text=(archived) &> /><%cpp> } else { </%cpp><input type="checkbox" name="deletions" value="<$ id $>" /><%cpp> } </%cpp></div> <div class="recording_spec"> <div class="recording_day"><$ FormatDateTime(recFormatStr, startTime) $></div> <div class="recording_duration"><$ duration $></div> @@ -246,9 +267,6 @@ for (iter = recordingsTree->begin(path); iter != end; ++iter) { <%cpp> } </%cpp> - <!-- not supported yet ... - <img src="<$ LiveSetup().GetThemedLink("img", "edit.png") $>" alt="" /> - --> </div> <%cpp> if (! archived.empty()) { @@ -263,5 +281,5 @@ for (iter = recordingsTree->begin(path); iter != end; ++iter) { <# ---------------------------------------------------------------------- #> <%def delete_error> -<%cpp> { </%cpp><$ deleteResult $><%cpp> } </%cpp> +<%cpp> { reply.out() << deleteResult; } </%cpp> </%def> |