File: dav_prop_edit.vsp

package info (click to toggle)
virtuoso-opensource 6.1.6%2Bdfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 260,992 kB
  • ctags: 125,220
  • sloc: ansic: 652,748; sql: 458,419; xml: 282,834; java: 61,031; sh: 40,031; cpp: 36,890; cs: 25,240; php: 12,692; yacc: 9,523; lex: 7,018; makefile: 6,157; jsp: 4,484; awk: 1,643; perl: 1,013; ruby: 1,003; python: 326
file content (234 lines) | stat: -rw-r--r-- 7,431 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
<?vsp 
--
--  $Id$
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2012 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
--  
--  

 adm_pre_page(lines);

--no_c_escapes-
declare name, tp, pvalue, stat, err, pname, _sid varchar;
declare id, isf, idx, is_group, _u_id integer;


--dbg_obj_print ('dav_prop_edit.vsp: ', params);

_u_id := DB.DBA.adm_dav_check_auth (lines);
if (_u_id <> 1)
  {
    http_request_status ('HTTP/1.1 401 Unauthorized');
    http ( concat ('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">',
	  '<HTML><HEAD>',
	  '<TITLE>401 Unauthorized</TITLE>',
	  '</HEAD><BODY><H1>Unauthorized</H1>',
	  'Access to page is forbidden.</BODY></HTML>'));
    return (0);
  }

_sid := adm_get_sesid (params);

id := atoi (get_keyword ('id', params, '0'));
is_group := atoi (get_keyword ('group', params, '0'));
tp := get_keyword ('tp', params, '');

if (id = 0 or tp = '')
  {
    err := 'No resource or collection specified';
    goto erret;
  }

name := '';

if (tp = 'C')
  name := coalesce ((select WS.WS.COL_PATH (COL_ID) from WS.WS.SYS_DAV_COL where COL_ID = id), '');
else if (tp = 'R')
  name := coalesce ((select RES_FULL_PATH from WS.WS.SYS_DAV_RES where RES_ID = id), '');

if (name = '')
  {
    err := sprintf ('No such resource or collection with ID', id);
    goto erret;
  }

if ('' <> get_keyword ('set', params, ''))
  {
    idx := 0;
    while (pname := adm_next_checkbox ('CP_', params, idx))
      {
        pvalue := get_keyword (pname, params, '');
	{
	 declare exit handler for sqlstate '*' { goto endser1; };
	    if (isarray (xml_tree (pvalue, 0)))
	      pvalue := serialize (xml_tree (pvalue, 0));
	 endser1:;
	}
	update WS.WS.SYS_DAV_PROP set PROP_VALUE = pvalue
	    where PROP_NAME = pname and PROP_PARENT_ID = id and PROP_TYPE = tp;
      }
  }
else if ('' <> get_keyword ('remove', params, ''))
  {
    idx := 0;
    while (pname := adm_next_checkbox ('CB_', params, idx))
      {
	delete from WS.WS.SYS_DAV_PROP where PROP_NAME = pname and PROP_PARENT_ID = id and PROP_TYPE = tp;
      }
  }
else if ('' <> get_keyword ('add', params, ''))
  {
    pvalue := get_keyword ('new_value', params, '');
    pname := get_keyword ('new_prop', params, '');
    if (pname = '')
      {
        err := 'Property name should be supplied';
        goto erret;
      }

    if (exists (select 1 from WS.WS.SYS_DAV_PROP
	  where PROP_NAME = pname and PROP_PARENT_ID = id and PROP_TYPE = tp))
      {
        err :=
	 sprintf ('The property "%s" of "%s" already exists.\nYou can remove or update existing', pname, name);
        goto erret;
      }

    {
     declare exit handler for sqlstate '*' { goto endser; };
     if (isarray (xml_tree (pvalue, 0)))
       pvalue := serialize (xml_tree (pvalue, 0));
     endser:;
    }

    insert soft WS.WS.SYS_DAV_PROP  (PROP_ID, PROP_NAME, PROP_VALUE, PROP_TYPE, PROP_PARENT_ID)
	values (WS.WS.GETID('P'), pname, pvalue, tp, id);
  }

?>
<HTML>
<HEAD>
    <LINK rel="stylesheet" type="text/css" href="<?=adm_what_css()?>">
    <script language="javascript" src="../admin_utils.js"></script>
    <META name="AUTHOR" content="OpenLink Software">
    <META name="DESCRIPTION" content="WebDAV property editor">
<TITLE>WebDAV properties of <?=name?></TITLE>
</HEAD>
<?vsp adm_page_header(concat('WebDAV properties of ', name), NULL); ?>

<p>To add new WebDAV property fill "New property definition" form and press "Add new" button.</p>

<p>To edit existing property value, enter it in "Value" field of "Actual properties" form and press "Set" button</p>
<p>To remove an existing property, select it and press "Remove selected" button.</p>

<p>To add, remove or change properties of <b>more than one</b> resources (and/or collections) use "Properties" button of <a href="admin_dav_documents.vsp?sid=<?=_sid?>">"Content management"</a> page.</p>

<FORM method=POST name=p_form action="dav_prop_edit.vsp">
    <input type=hidden name=sid value="<?=_sid?>">
    <input type=hidden name=id value="<?=id?>">
    <input type=hidden name=tp value="<?=tp?>">
<table CLASS="genlist" BORDER="0" CELLPADDING="0">
<TR><TD CLASS="adm_pages_title" COLSPAN="4"><b>New property definition</b></TD></TR>
<tr>
	<td CLASS="genlistheadt" colspan=2>&nbsp;</td>
	<td CLASS="genlistheadt">Name</td>
	<td CLASS="genlistheadt">Value</td>
</tr>
<tr>
    <td CLASS="gendata" colspan=2>&nbsp;</td>
    <td CLASS="gendata">
        <input type=text name="new_prop" value="" size="20%">
    </td>
    <td CLASS="gendata">
        <input type=text name="new_value" value="" size="60%">
    </td>
</tr>

<TR><TD COLSPAN="4">&nbsp;</TD></TR>

<TR><TD CLASS="adm_pages_title" COLSPAN="4"><b>Actual properties</b></TD></TR>
<tr>
	<td CLASS="genlistheadt">Sel</td>
	<td CLASS="genlistheadt">&nbsp;</td>
	<td CLASS="genlistheadt">Name</td>
	<td CLASS="genlistheadt">Value</td>
</tr>
<?vsp
    isf := 1;
    for select PROP_NAME, PROP_ID, blob_to_string (PROP_VALUE) as PROP_VALUE from WS.WS.SYS_DAV_PROP where PROP_PARENT_ID = id and PROP_TYPE = tp
      do {
      declare crs , wocr int;
      isf := 0;
      crs := 1;
      pvalue := deserialize (PROP_VALUE);
      if (isarray (pvalue))
	{
	  declare ses any;
          ses := string_output ();
          http_value (xml_tree_doc (pvalue), null, ses);
          pvalue := string_output_string (ses);
	}
      else if (isstring (PROP_VALUE))
	pvalue := PROP_VALUE;
      else
	pvalue := '';
      wocr := replace (pvalue, '\n', '');
      crs := crs + (length (pvalue) - length (wocr));
?>

<tr>
    <td CLASS="gendata"><input type=checkbox name="CB_<?=PROP_NAME?>"></td>
    <td CLASS="gendata">&nbsp;</td>
    <td CLASS="gendata"><?=PROP_NAME?></td>
    <td CLASS="gendata">
        <input type=hidden name="CP_<?=PROP_NAME?>" value="on">
	<?vsp if (PROP_NAME = 'xml-sql') { ?>
        <textarea name="<?=PROP_NAME?>" rows="<?= crs ?>" cols="70"><?=pvalue?></textarea>
	<?vsp } else { ?>
        <input type=text name="<?=PROP_NAME?>" value="<?=pvalue?>" size="60%">
	<?vsp } ?>
    </td>
</tr>

<?vsp } if (isf) http ('<tr><td colspan=4>*** no properties found ***</td></tr>'); ?>

<TR><TD COLSPAN="4">&nbsp;</TD></TR>
<tr>
   <td colspan=3>
       <input type=button name=selall value="Select All" onClick="selectAllCheckboxes(this.form, this)">
   </td>
   <td align=right>
       <input type=button name=cancel value="Back" onClick="location.replace ('admin_dav_documents.vsp?sid=<?=_sid?>')">
       <input type=submit name=add value="Add new">
       <input type=submit name=set value="Set">
       <input type=submit name=remove value="Remove selected">
   </td>
</tr>

</table>
</FORM>
<?vsp adm_page_footer(); ?>
</HTML>

<?vsp
-- Error exit
return (0);
erret:
?>
<?include error.vsp ?>