<?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
 -
-->
<v:page name="acl-sharing"
        fast-render="1"
        xmlns:vm="http://www.openlinksw.com/vspx/ods/"
        xmlns:v="http://www.openlinksw.com/vspx/"
        style="index.xsl"
        doctype="-//W3C//DTD XHTML 1.0 Transitional//EN"
        doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <v:before-data-bind>
    <![CDATA[
      select deserialize (WAUI_ACL)
        into self.iAcl
        FROM DB.DBA.WA_USER_INFO
       where WAUI_U_ID = self.u_id;
    ]]>
  </v:before-data-bind>
  <v:variable name="iAcl" type="any" default="null" persist="0" />
  <h3>Profile Sharing</h3>
  <table>
    <tr>
      <td width="100%">
        <table id="s_tbl" class="listing" style="width: 100%;" cellspacing="0">
          <thead>
            <tr class="listing_header_row">
              <th width="1%" nowrap="nowrap">Access Type</th>
              <th nowrap="nowrap">WebID</th>
              <th width="1%" align="center" nowrap="nowrap">ACL: (R)ead, (W)rite</th>
              <th width="1%">Action</th>
            </tr>
          </thead>
          <tbody id="s_tbody">
          <tr id="s_tr_no"><td colspan="4"><b>No WebID Security</b></td></tr>
    		  <![CDATA[
    		    <script type="text/javascript">
            <?vsp
              declare N integer;

              for (N := 0; N < length (self.iAcl); N := N + 1)
              {
                  http (sprintf ('ODSInitArray.push(function(){TBL.createRow("s", null, {fld_1: {mode: 50, value: "%s", onchange: function(){TBL.changeCell50(this);}}, fld_2: {mode: 51, className: "_validate_ _webid_", value: %s, readOnly: %s, imgCssText: "%s"}, fld_3: {mode: 52, value: [%d, %d, %d], tdCssText: "width: 1%%; text-align: center;"}});});', self.iacl[N][2], ODS..obj2json (self.iacl[N][1]), case when self.iacl[N][2] = 'public' then 'true' else 'false' end, case when self.iacl[N][2] = 'public' then 'display: none;' else '' end, self.iacl[N][3], self.iacl[N][4], self.iacl[N][5]));
              }
            ?>
    		    </script>
    		  ]]>
          </tbody>
        </table>
      </td>
      <td valign="top" nowrap="nowrap">
        <span class="button pointer" onclick="javascript: TBL.createRow('s', null, {fld_1: {mode: 50, onchange: function(){TBL.changeCell50(this);}}, fld_2: {mode: 51, className: '_validate_ _webid_'}, fld_3: {mode: 52, value: [1, 0, 0], tdCssText: 'width: 1%; text-align: center;'}});"><img src="/ods/images/icons/add_16.png" border="0" class="button" alt="Add Security" title="Add Security" /> Add</span><br /><br />
      </td>
    </tr>
  </table>
  <v:button name="btn_acl_update" action="simple" value="Update" xhtml_class="form-button">
    <v:on-post>
      <![CDATA[
        declare exit handler for SQLSTATE '*'
        {
          -- dbg_obj_print ('__SQL_MESSAGE', __SQL_MESSAGE);
          if (__SQL_STATE = 'TEST')
          {
            self.vc_error_message := ODRIVE.WA.test_clear (__SQL_MESSAGE);
            self.vc_is_valid := 0;
            return;
          }
          resignal;
        };

        -- validate ACL rules
        DB.DBA.wa_aci_validate (DB.DBA.wa_aci_params (e.ve_params));

        self.iAcl := DB.DBA.wa_aci_params (e.ve_params);
        WA_USER_EDIT (self.u_name, 'WAUI_ACL', serialize (self.iAcl));

        self.vc_data_bind(e);
      ]]>
    </v:on-post>
  </v:button>

</v:page>
