File: users.ecpp

package info (click to toggle)
vdr-plugin-live 3.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,128 kB
  • sloc: cpp: 12,995; javascript: 3,234; makefile: 241; sh: 40
file content (101 lines) | stat: -rw-r--r-- 3,175 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<%pre>

#include <users.h>
#include <setup.h>

using namespace vdrlive;

</%pre>
<%args>
  // input parameters
  std::string userid;
  std::string action;
</%args>
<%session scope="global">
bool logged_in(false);
</%session>
<%include>page_init.eh</%include>
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) {
  cToSvConcat targetUrl = "/login.html?redirect=";
  targetUrl.appendUrlEscaped(request.getQuery());
  return reply.redirect(targetUrl.data());
}
</%cpp>
<%cpp>
  pageTitle = tr("Users");
  if ( !userid.empty() ) {
    if (action == "delete")
    {
      cUser* user = Users.GetByUserId( userid );
      if (user) {
        // invalid userid may occur if page is reloaded
        Users.Del(user);
        Users.Save();
      }
    }
  }
</%cpp>
<& pageelems.doc_type &>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>VDR-Live - <$ pageTitle $></title>
    <& pageelems.stylesheets &>
    <& pageelems.ajax_js &>
  </head>
  <body onpagehide="saveScrollPosition('content')" onpageshow="restoreScrollPosition()">
    <& pageelems.logo &>
    <& menu active=("users") component=("users.user_actions")>
    <div id="content">
      <div class="spacebar"><# spacer with fade-out effect #></div>
      <table class="listing users" cellspacing="0" cellpadding="0">
        <tr class="head">
          <td colspan="3">
            <div class="boxheader"><div class="caption"><$ pageTitle $></div></div>
          </td>
        </tr>
%       if (Users.Count() > 0) {
        <tr class="description">
          <td class="action leftcol" ><div class="withmargin"><$ tr("Name") $></div></td>
          <td class="rightcol" colspan="2"/>
        </tr>
<%cpp>
          cUser* user = Users.First();
          while (user)
          {
            bool bottom = (Users.Next(user) == NULL);
            if (user)
            {
</%cpp>
          <tr class="account">
            <td class="leftcol <? bottom ? "bottomrow" ?>"><div class="withmargin"><$ user->Name() $></div></td>
            <td class="rightcol <? bottom ? "bottomrow" ?>">
              <div class="user_actions">
                <a href="edit_user.html?userid=<$ user->Id() $>"><img class="icon" src="<$ LiveSetup().GetThemedLink("img", "edit.png") $>" alt="" <& tooltip.hint text=(tr("Edit user")) &> /></a>
                <a href="users.html?userid=<$ user->Id() $>&action=delete"><img class="icon" src="<$ LiveSetup().GetThemedLink("img", "del.png") $>" alt="" <& tooltip.hint text=(tr("Delete user")) &> /></a>
              </div></td>
            </td>
          </tr>
<%cpp>
            }
            user = Users.Next(user);
          }
        } else {
</%cpp>
          <tr class="account">
            <td class="message leftcol bottomrow"><div class="withmargin"><$ tr("No users configured") $></div></td>
            <td class="bottomrow"></td>
            <td class="rightcol bottomrow"></td>
          </tr>
%       }
      </table>
      <div class="spacebar"><# spacer with fade-out effect #></div>
    </div>
  </body>
</html>
<%include>page_exit.eh</%include>

<%def user_actions>
<a href="edit_user.html"><$ tr("New user") $></a>
</%def>