File: users_select.vspx

package info (click to toggle)
virtuoso-opensource 7.2.5.1%2Bdfsg1-0.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 285,240 kB
  • sloc: ansic: 641,220; sql: 490,413; xml: 269,570; java: 83,893; javascript: 79,900; cpp: 36,927; sh: 31,653; cs: 25,702; php: 12,690; yacc: 10,227; lex: 7,601; makefile: 7,129; jsp: 4,523; awk: 1,697; perl: 1,013; ruby: 1,003; python: 326
file content (324 lines) | stat: -rw-r--r-- 15,231 bytes parent folder | download | duplicates (2)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
<?xml version="1.0" encoding="UTF-8"?>
<!--
 -
 -  $Id$
 -
 -  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 -  project.
 -
 -  Copyright (C) 1998-2018 OpenLink Software
 -
 -  This project is free software; you can redistribute it and/or modify it
 -  under the terms of the GNU General Public License as published by the
 -  Free Software Foundation; only version 2 of the License, dated June 1991.
 -
 -  This program is distributed in the hope that it will be useful, but
 -  WITHOUT ANY WARRANTY; without even the implied warranty of
 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 -  General Public License for more details.
 -
 -  You should have received a copy of the GNU General Public License along
 -  with this program; if not, write to the Free Software Foundation, Inc.,
 -  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 -
-->
<script type="text/javascript" src="/ods/users_select.js"></script>
<script type="text/javascript" src="/ods/oat/loader.js"></script>
<v:page name="users_select"
        style="index.xsl"
        fast-render="1"
        xmlns:v="http://www.openlinksw.com/vspx/"
        xmlns:vm="http://www.openlinksw.com/vspx/ods/"
        doctype="-//W3C//DTD XHTML 1.0 Transitional//EN">

  <vm:page>
    <vm:header>
      <vm:title>Select user/group</vm:title>
  <link rel="stylesheet" type="text/css" href="default.css" />
<style type="text/css">
div.boxHeader {
  background-color: #EFEFEF;
  margin: 0 0 0.5em 0;
  padding: 2px;
  border: 1px solid #7F94A5;
  vertical-align: middle;
}
      </style>
      <script type="text/javascript">
      	window.onkeyup = function (event) {
      		if (event.keyCode == 27) {
      			window.close ();
}
}
      </script>
    </vm:header>

  <v:method name="sortChange" arglist="in columnName varchar">
    <![CDATA[
        if (columnName <> '')
        {
      self.ds.vc_reset();
          if (self.v_order = columnName)
          {
        self.v_direction := either(equ(self.v_direction, 'asc'), 'desc', 'asc');
      } else {
        self.v_direction := 'asc';
      self.v_order := columnName;
          }
        }
    ]]>
  </v:method>

  <v:method name="isMultiple" arglist="in dst any">
    <![CDATA[
        return case when isnull (strstr (self.v_dst, 'm')) then 0 else 1 end;
    ]]>
  </v:method>

    <v:before-data-bind>
      <![CDATA[
        if (self.v_mode = 'g')
        {
          self.v_filter := 'g';
        }
        else if (self.v_mode = 'u')
        {
          self.v_filter := 'u';
        }
        else if (self.v_mode like 's_%')
        {
          self.v_filter := 'u';
        }
      ]]>
    </v:before-data-bind>

    <vm:pagewrapper odsbar="no" >

    <vm:variables>
      <v:variable name="v_params" param-name="params" type="varchar"/>
      <v:variable name="v_mode" persist="0" param-name="mode" type="varchar" default="''"/>
        <v:variable name="v_filter" persist="0" type="varchar" default="''"/>
      <v:variable name="v_value" persist="0" type="varchar" default="''"/>
      <v:variable name="v_mask" persist="0" type="varchar" default="''"/>
      <v:variable name="v_how" persist="0" type="varchar" default="'1'"/>
      <v:variable name="v_order" persist="0" type="varchar" default="'U_NAME'" />
      <v:variable name="v_direction" persist="0" type="varchar" default="'asc'" />
        <v:variable name="v_nrows" persist="0" param-name="nrows" type="varchar" default="'10'" />
        <v:variable name="v_src" persist="0" param-name="src" type="varchar" default="''" />
        <v:variable name="v_dst" persist="0" param-name="dst" type="varchar" default="'sc'" />
        <v:variable name="v_s1" persist="0" param-name="s1" type="varchar" default="''" />
        <v:variable name="v_s2" persist="0" param-name="s2" type="varchar" default="''" />
    </vm:variables>
  <vm:body>
        <vm:login redirect="index.vspx"/>
        <?vsp http(sprintf('<input type="hidden" name="nrows" id="nrows" value="%s"/>', get_keyword('nrows', self.vc_page.vc_event.ve_params, '10'))); ?>
      <?vsp http(sprintf('<input type="hidden" name="sid"   id="sid"   value="%s"/>', get_keyword('sid', self.vc_page.vc_event.ve_params))); ?>
      <?vsp http(sprintf('<input type="hidden" name="realm" id="realm" value="%s"/>', get_keyword('realm', self.vc_page.vc_event.ve_params))); ?>
        <?vsp http(sprintf('<input type="hidden" name="form"  id="form"  value="%s"/>', get_keyword('form', self.vc_page.vc_event.ve_params, 'page_form'))); ?>
      <?vsp http(sprintf('<input type="hidden" name="src"   id="src"   value="%s"/>', get_keyword('src', self.vc_page.vc_event.ve_params, ''))); ?>
      <?vsp http(sprintf('<input type="hidden" name="dst"   id="dst"   value="%s"/>', get_keyword('dst', self.vc_page.vc_event.ve_params, 'sc'))); ?>
      <?vsp http(sprintf('<input type="hidden" name="s1"    id="s1"    value="%s"/>', get_keyword('s1', self.vc_page.vc_event.ve_params, ''))); ?>
      <?vsp http(sprintf('<input type="hidden" name="s2"    id="s2"    value="%s"/>', get_keyword('s2', self.vc_page.vc_event.ve_params, ''))); ?>
      <v:text name="params" type="hidden" value="--self.v_params"/>
        <div style="padding: 0.2em;">
        <div style="padding: 0 0 0.5em 0;">
            <span class="button pointer" onclick="javascript: if (opener != null) opener.focus(); window.close();"><img class="button" src="/ods/images/icons/close_16.png" border="0" alt="Close" title="Close" /> Close</span>
        </div>
        <div class="boxHeader">
            Show
          <v:select-list name="filter" value="--self.v_filter" enabled="-- case when (self.v_mode = '') then 1 else 0 end">
            <v:item name="Users & Groups" value="" />
              <v:item name="Users" value="u" />
            <v:item name="Groups" value="g" />
          </v:select-list>
            <v:label value="--case self.v_mode when 'u' then ' users' when 'g' then ' groups' else '' end" enabled="-- case when (self.v_mode = '') then 0 else 1 end"/>
          <v:select-list name="how" value="--self.v_how">
            <v:item name="Starting with" value="1" />
            <v:item name="Containing" value="2" />
            <v:item name="Ending with" value="3" />
            <v:item name="Exact match" value="4" />
          </v:select-list>
          <v:text name="value" value="--self.v_value" xhtml_size="15"/>
          <v:button action="simple" value="Filter" xhtml_class="button">
            <v:on-post>
              <![CDATA[
                  self.v_filter := get_keyword('filter', e.ve_params, self.v_filter);
                self.v_how := self.how.ufl_value;
                self.v_value := trim(self.value.ufl_value);

                  self.ds.vc_reset();
                self.vc_data_bind (e);
              ]]>
            </v:on-post>
          </v:button>
          <v:button name="reset" action="simple" value="Clear" xhtml_class="button">
            <v:on-post>
              <![CDATA[
                self.v_how := '1';
                self.v_value := '';

                  self.ds.vc_reset();
                self.vc_data_bind (e);
              ]]>
            </v:on-post>
          </v:button>
            <label>
            <v:check-box auto-submit="1" name="show_all_cbx" xhtml_id="show_all_cbx" initial-checked="--0" value="--1"/>
              Show all
            </label>
        </div>
          <v:data-source name="dsrc" expression-type="sql" nrows="0" initial-offset="0">
          <v:before-data-bind>
            <![CDATA[
              declare user_sql, group_sql varchar;


              self.v_mask := case self.v_how
                               when '1' then self.v_value || '%'
                               when '2' then '%' || self.v_value || '%'
                               when '3' then '%' || self.v_value
                               else self.v_value end;
              if (self.v_mask = '')
                self.v_mask := '%';
              self.v_mask := replace(self.v_mask, '%%', '%');

              user_sql := '';
              group_sql := '';
              if (self.v_filter <> 'u')
              {
                  if (DB.DBA.wa_user_is_dba (connection_get ('vspx_user'), null) = 1)
                  {
                    group_sql := sprintf('select ''Group'' U_TYPE, a.U_NAME, coalesce(a.U_FULL_NAME, a.U_NAME) U_FULL_NAME from DB.DBA.SYS_USERS a where (a.U_IS_ROLE=1) and (upper(a.U_NAME) like upper(\'%s\') and (U_ID<>5) and (U_ID<>6))', self.v_mask);
                  } else {
                    group_sql := sprintf('select ''Group'' U_TYPE, a.U_NAME, coalesce(a.U_FULL_NAME, a.U_NAME) U_FULL_NAME from DB.DBA.SYS_USERS a, DB.DBA.WA_GROUPS b, DB.DBA.SYS_USERS c where (a.U_ID=b.WAG_GROUP_ID) and (a.U_IS_ROLE=1) and (b.WAG_USER_ID=c.U_ID) and (c.U_NAME=\'%s\') and (upper(a.U_NAME) like upper(\'%s\') and (a.U_ID<>5) and (a.U_ID<>6))', self.u_name, self.v_mask);
                  }
              }
              if (self.v_filter <> 'g')
              {
                  if (self.v_mode = 's_bmk')
                  {
                    user_sql := sprintf('select ''User'' U_TYPE, b.U_NAME, coalesce(b.U_FULL_NAME, \'\') U_FULL_NAME from BMK..GRANTS_VIEW a, DB.DBA.SYS_USERS b where (b.U_ACCOUNT_DISABLED=0) and upper(b.U_NAME) like upper(\'%s\') and a.GW_ID = %d and a.U_ID = b.U_ID', self.v_mask, self.u_id);
                  } else {
                user_sql := sprintf('select ''User'' U_TYPE, U_NAME, coalesce(U_FULL_NAME, \'\') U_FULL_NAME from WS.WS.SYS_DAV_USER where (U_ACCOUNT_DISABLED=0) and (upper(U_NAME) like upper(\'%s\') and (U_ID<>5) and (U_ID<>6))', self.v_mask);
              }
                }
                if (user_sql = '')
                {
                control.ds_sql := group_sql;
                }
                else if (group_sql = '')
                {
                control.ds_sql := user_sql;
                }
                else
                {
                  control.ds_sql := concat('select U_TYPE, U_NAME, U_FULL_NAME from (', user_sql, ' union ' , group_sql, ') x ');
              }
              self.sortChange(get_keyword('sortColumn', e.ve_params, ''));
              control.ds_sql := concat(control.ds_sql, ' order by ', self.v_order, ' ', self.v_direction);
                if (get_keyword('show_all_cbx', self.vc_page.vc_event.ve_params, 0))
                {
                  self.ds.vc_reset();
                  control.ds_nrows := 1000;
                  control.ds_rows_fetched := 0;
                  control.ds_rows_offs := 0;
                }
                else
                {
                  control.ds_nrows := cast (self.v_nrows as integer);
                }
            ]]>
          </v:before-data-bind>
            <v:after-data-bind>
              control.ds_make_statistic ();
            </v:after-data-bind>
        </v:data-source>
        <v:data-set name="ds" data-source="self.dsrc" scrollable="1">
            <v:template name="ds_header" type="simple" name-to-remove="table" set-to-remove="bottom">
              <table class="ODS_grid">
                <thead>
                  <tr>
                  <vm:if test="self.isMultiple(self.v_dst)">
                      <th class="checkbox">
                      <input type="checkbox" name="cb_all" value="Select All" onclick="selectAllCheckboxes(this, 'cb_item'); updateChecked(this, 'cb_item'); "/>
                    </th>
                  </vm:if>
                  <vm:if test="self.v_mode = ''">
                      <th>Type</th>
                  </vm:if>
                    <?vsp http (DB.DBA.wa_show_column_header('Name', 'U_NAME', self.v_order, self.v_direction, 'width="50%"')); ?>
                    <?vsp http (DB.DBA.wa_show_column_header('Description', 'U_FULL_NAME', self.v_order, self.v_direction, 'width="50%"')); ?>
                </tr>
                </thead>
            </table>
          </v:template>

          <v:template name="ds_repeat" type="repeat" name-to-remove="" set-to-remove="">

            <v:template name="ds_empty" type="if-not-exists" name-to-remove="table" set-to-remove="both">
              <table>
                <tr align="center">
                    <td colspan="<?V either(equ(self.v_mode,''),3,2)+self.isMultiple(self.v_dst) ?>">
                      No records
                    </td>
                </tr>
              </table>
            </v:template>

            <v:template name="ds_browse" type="browse" name-to-remove="table" set-to-remove="both">
                <table>
                  <tr onclick="rowSelected(this);" class="pointer">
                    <vm:if test="self.isMultiple(self.v_dst)">
                      <td class="checkbox">
                      <?vsp
                        declare S, name any;

                          name := (control as vspx_row_template).te_column_value('U_NAME');
                          S := case when isnull (strstr(self.v_s1, concat(name, ','))) then '' else 'checked="checked"' end;
                          http (sprintf ('<input type="checkbox" name="cb_item" value="%s" %s onclick="javascript: updateChecked(this, ''cb_item'', event); " />', name, S));
                      ?>
                    </td>
                    </vm:if>
                    <vm:if test="self.v_mode = ''">
                    <td nowrap="nowrap">
                        <v:label value="--(control.vc_parent as vspx_row_template).te_column_value('U_TYPE')" format="%s"/>
                    </td>
                    </vm:if>
                    <td width="50%" nowrap="nowrap">
                      <input name="s1_item" type="hidden" value="<?V (control as vspx_row_template).te_column_value('U_NAME') ?>" />
                    <v:label value="--(control.vc_parent as vspx_row_template).te_column_value('U_NAME')" format="%s"/>
                  </td>
                    <td width="50%" nowrap="nowrap">
                      <input name="s2_item" type="hidden" value="<?V (control as vspx_row_template).te_column_value('U_FULL_NAME') ?>" />
                    <v:label value="--(control.vc_parent as vspx_row_template).te_column_value('U_FULL_NAME')" format="%s"/>
                  </td>
                </tr>
              </table>
            </v:template>

          </v:template>

          <v:template type="simple" name-to-remove="table" set-to-remove="top">
            <table>
                <tfoot>
                  <tr>
                    <td style="text-align: right;" colspan="<?V either(equ(self.v_mode,''),3,2)+self.isMultiple(self.v_dst) ?>">
                      <vm:ds-navigation data-set="ds"/>
                  </td>
              </tr>
                </tfoot>
            </table>
          </v:template>

        </v:data-set>
          <vm:if test="self.isMultiple(self.v_dst)">
          <div style="padding: 0 0 0.5em 0;">
            <hr />
              <a href="#" onclick="javascript: return addChecked(document.forms['page_form'], 'cb_item', 'No users were selected for addition. No groups were selected for addition.');" class="navi-button">&amp;nbsp;Add selected</a>
          </div>
          </vm:if>
      </div>
  </vm:body>
    </vm:pagewrapper>
 </vm:page>
</v:page>