<?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="user_edit_buss"
        doctype="-//W3C//DTD XHTML 1.0 Transitional//EN"
        fast-render="1" xmlns:v="http://www.openlinksw.com/vspx/"
        style="index.xsl"
        xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:vm="http://www.openlinksw.com/vspx/ods/"
        xmlns:v="http://www.openlinksw.com/vspx/">

  <v:method name="ldap2_value" arglist="inout data any">
    <![CDATA[
      return case when isstring (data) then data else data[0] end;
	  ]]>
	</v:method>

  <v:method name="ldap2_pattern" arglist="in maps any, in pattern any">
    <![CDATA[
      declare N integer;

      for (N := 0; N < length (maps); N := N + 2)
        if (maps [N+1] = pattern)
          return maps [N];

      return '';
	  ]]>
	</v:method>

  <v:method name="ldap2_data" arglist="inout data any, in pattern any">
    <![CDATA[
      declare M integer;

      for (M := 0; M < length (data); M := M + 2)
        if (data[M] = pattern)
          return self.ldap2_value (data[M+1]);

      return null;
	  ]]>
	</v:method>

  <v:method name="check_title" arglist="inout title any">
    <![CDATA[
      declare M integer;
      declare V any;

      V := vector ('Mr', 'Mrs', 'Dr', 'Ms', 'Sir');
      for (M := 0; M < length (V); M := M + 1)
        if (lcase (title) like (lcase (V[M])|| '%'))
          return V[M];

      return '';
	  ]]>
	</v:method>

  <v:method name="show_data" arglist="inout data any, inout labels any">
    <![CDATA[
      declare N, M integer;
      declare format varchar;
      declare value any;

      for (N := 0; N < length (data); N := N + 1)
  	  {
  	    format := '%s';
        for (M := 0; M < length (labels); M := M + 1)
    	  {
    	    value := get_keyword (labels[M], data[N]);
    	    if (length (value))
    	    {
     	      http (sprintf (format, value));
    	      format := ' (%s)';
    	    }
   	    }
 	      http ('<br />');
  	  }
	  ]]>
	</v:method>

  <v:method name="data2string" arglist="inout items any, inout labels any">
    <![CDATA[
      declare S, delimiter1, delimiter2 varchar;
      declare value any;

      S := '';
	    delimiter1 := '';
      foreach (any item in items) do
  	  {
  	    delimiter2 := '';
        foreach (any label in labels) do
    	  {
    	    value := get_keyword (label, item);
    	    if (length (value))
    	    {
            S := S || delimiter2 || value;
    	      delimiter2 := ';';
    	    }
   	    }
        S := S || '\n';
  	  }
  	  return S;
	  ]]>
	</v:method>

  <v:method name="savePersonal_0" arglist="">
    <![CDATA[
      declare params any;

      params := self.vc_page.vc_event.ve_params;
      if (self.vc_is_valid = 0)
        return;

      if (self.iMode = 0)
      {
        commit work;
        if (self.i_source_0.ufl_selected or (self.iLDAP = 0))
        {
          declare data any;

          self.i_source := 0;
          data := ODS.ODS_API.getFOAFDataArray (self.foaf_url.ufl_value);
          if (length (data) = 0)
          {
            self.vc_error_message := 'The specified URL doesn\'t contains personal FOAF profile.';
            self.vc_is_valid := 0;
            return;
          }
          self.iPhoto := get_keyword ('depiction', data);
          self.iTitle := get_keyword ('title', data);
          self.iNick := get_keyword ('nick', data);
          self.iName := get_keyword ('name', data);
          self.iFirstName := coalesce (get_keyword ('firstName', data), get_keyword ('givenName', data));
          self.iFamily_name := get_keyword ('family_name', data);
          self.iMbox := get_keyword ('mbox', data);
          self.iGender := get_keyword ('gender', data);
          self.iBirthday := get_keyword ('birthday', data);
          self.iLat := get_keyword ('lat', data);
          self.iLng := get_keyword ('lng', data);
          self.iIcqChatID := get_keyword ('icqChatID', data);
          self.iSkypeChatID := get_keyword ('skypeChatID', data);
          self.iMsnChatID := get_keyword ('msnChatID', data);
          self.iAimChatID := get_keyword ('aimChatID', data);
          self.iYahooChatID := get_keyword ('yahooChatID', data);
          self.iWorkplaceHomepage := get_keyword ('workplaceHomepage', data);
          self.iHomepage := get_keyword ('homepage', data);
          self.iPhone := get_keyword ('phone', data);
          self.iResume := get_keyword ('resume', data);
          self.iInterests := get_keyword ('interest', data);
          self.iTopicInterests := get_keyword ('topic_interest', data);
          self.iOnlineAccounts := get_keyword ('onlineAccounts', data);
          self.iSameAs := get_keyword ('sameAs', data);
          self.iKnows := get_keyword ('knows', data);
          self.iTags := get_keyword ('tags', data);

          self.iHCounty := get_keyword ('country', data);
          self.iHState := get_keyword ('region', data);
          self.iHCyty := get_keyword ('locality', data);
          self.iHCode := get_keyword ('pobox', data);
          self.iHAddress1 := get_keyword ('street', data);
          self.iHAddress2 := get_keyword ('extadd', data);

          self.iMode := 1;
          self.vc_data_bind (self.vc_page.vc_event);
        }
        else if (self.i_source_1.ufl_selected)
        {
          self.i_source := 1;

          declare N, M integer;
          declare tmp, data, V, i_lHost, i_lPort, i_lBase_dn, i_lBind_dn, i_lPassword, i_lMaps, i_lSearch, i_lData any;

          self.i_lName := self.f_lName.ufl_value;
          if (self.i_lName <> '')
          {
            select LS_HOST,
                   LS_PORT,
                   LS_BASE_DN,
                   LS_BIND_DN,
                   LS_PASSWORD,
                   deserialize (LS_MAPS)
              into i_lHost,
                   i_lPort,
                   i_lBase_dn,
                   i_lBind_dn,
                   i_lPassword,
                   i_lMaps
              from LDAP..LDAP_SERVERS
             where LS_NAME = self.i_lName
               and LS_USER_ID = self.u_id;

            connection_set ('LDAP_VERSION', 2);
            tmp := split_and_decode (i_lBind_dn, 0, '\0\0\,');
            i_lSearch := '(cn=*)';
            if (length (tmp) > 0)
              i_lSearch := tmp[0];

            i_lData := ldap_search ('ldap://' || i_lHost || ':' || i_lPort, 0, i_lBase_dn, i_lSearch, i_lBind_dn, i_lPassword);
            for (N := 0; N < length (i_lData); N := N + 2)
            {
      	      if (i_lData [N] = 'entry')
      	      {
      	        data := i_lData [N+1];

                self.iTitle := self.check_title (self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_TITLE')));
                self.iNick := null;
                self.iName := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_FULL_NAME'));
                self.iFirstName := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_FIRST_NAME'));;
                self.iFamily_name := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_LAST_NAME'));;
                self.iMbox := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_MAIL'));;
                self.iGender := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_GENDER'));;
                self.iLat := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_H_LAT'));;
                self.iLng := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_H_LNG'));;
                self.iIcqChatID := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_ICQ'));;
                self.iSkypeChatID := null;
                self.iMsnChatID := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_MSN'));;
                self.iAimChatID := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_AIM'));;
                self.iYahooChatID := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_YAHOO'));;
                self.iWorkplaceHomepage := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_B_WEB'));;
                self.iHomepage := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_WEB'));;
                self.iPhone := self.ldap2_data (data, self.ldap2_pattern (i_lMaps, 'P_H_PHONE'));;
                self.iResume := null;
                self.iInterests := null;
                self.iTopicInterests := null;
                self.iOnlineAccounts := null;
                self.iSameAs := null;
                self.iTags := null;

                self.iHCounty := null;
                self.iHState := null;
                self.iHCyty := null;
                self.iHCode := null;
                self.iHAddress1 := null;
                self.iHAddress2 := null;

                self.iMode := 2;
                goto _exit2;
              }
            }
          }
        _exit2:;
          if (self.iMode = 0)
          {
            self.vc_is_valid := 0;
            self.vc_error_message := 'The specified LDAP server doesn\'t contains personal data.';
          }
          else
          {
            self.vc_data_bind (self.vc_page.vc_event);
          }
        }
        if (not isnull (self.iNick) and exists (select 1 from WA_USER_INFO where WAUI_U_ID <> self.u_id and WAUI_NICK = self.iNick))
          self.iNick := null;

        if (not isnull (self.iMbox) and exists (select 1 from WA_SETTINGS where WS_UNIQUE_MAIL = 1) and exists (select 1 from SYS_USERS where U_E_MAIL = self.iMbox and U_ID <> self.u_id))
          self.iMbox := null;

      }
      else
      {
        if (
            (get_keyword ('cb_item_iMBox', params, '0') = '1') and
            exists (select 1 from WA_SETTINGS where WS_UNIQUE_MAIL = 1) and
            exists (select 1 from SYS_USERS where U_E_MAIL = self.iMBox and U_ID <> self.u_id)
           )
        {
          self.vc_error_message := 'This e-mail address is already registered.';
          self.vc_is_valid := 0;
          return;
        }
        --DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_BIRTHDAY', dt);
        if (get_keyword ('cb_item_iPhoto', params, '0') = '1')
          ODS.ODS_API."user.update.field" (self.u_name, 'WAUI_PHOTO_URL', self.iPhoto);
        if (get_keyword ('cb_item_iTitle', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_TITLE', self.iTitle);
        if (get_keyword ('cb_item_iNick', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_NICK', self.iNick);
        if (get_keyword ('cb_item_iFirstName', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_FIRST_NAME', self.iFirstName);
        if (get_keyword ('cb_item_iFamily_name', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_LAST_NAME', self.iFamily_name);
        if (get_keyword ('cb_item_iName', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_FULL_NAME', self.iName);
        if (get_keyword ('cb_item_iMBox', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'E_MAIL', self.iMBox);
        if (get_keyword ('cb_item_iGender', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_GENDER', self.iGender);
        if (get_keyword ('cb_item_iHomepage', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_WEBPAGE', self.iHomepage);

        if (get_keyword ('cb_item_iIcqChatID', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_ICQ', self.iIcqChatID);
        if (get_keyword ('cb_item_iSkypeChatID', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_SKYPE', self.iSkypeChatID);
        if (get_keyword ('cb_item_iAimChatID', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_AIM', self.iAimChatID);
        if (get_keyword ('cb_item_iMsnChatID', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_MSN', self.iMsnChatID);
        if (get_keyword ('cb_item_iYahooChatID', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_YAHOO', self.iYahooChatID);

        if (get_keyword ('cb_item_iWorkplaceHomepage', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_BORG_HOMEPAGE', self.iWorkplaceHomepage);
        if (get_keyword ('cb_item_iPhone', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_HPHONE', self.iPhone);
        if (get_keyword ('cb_item_iLng', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_LAT', self.iLat);
        if (get_keyword ('cb_item_iLng', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_LNG', self.iLng);
        if (get_keyword ('cb_item_iTags', params, '0') = '1')
        {
          if (not isnull (self.iTags))
          {
            self.iTags := DB.DBA.WA_TAG_PREPARE(self.iTags);
            if (DB.DBA.WA_VALIDATE_TAGS(self.iTags))
              WA_USER_TAG_SET(http_nobody_uid(), self.u_id, self.iTags);
          }
        }
        if (get_keyword ('cb_item_iSameAs', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_FOAF', self.data2string (self.iSameAs, vector ('value')));
        if (get_keyword ('cb_item_iResume', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_RESUME', self.iResume);
        if (get_keyword ('cb_item_iInterests', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_INTERESTS', self.data2string (self.iInterests, vector ('value', 'label')));
        if (get_keyword ('cb_item_iTopicInterests', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_INTEREST_TOPICS', self.data2string (self.iTopicInterests, vector ('value', 'label')));
        if (get_keyword ('cb_item_iOnlineAccounts', params, '0') = '1')
        {
          if (length (self.iOnlineAccounts))
          {
            declare fld1, fld2 any;

            delete from DB.DBA.WA_USER_OL_ACCOUNTS where WUO_U_ID = self.u_id;
            foreach (any item in self.iOnlineAccounts) do
        	  {
              fld1 := get_keyword ('value', item);
        	    if (length (fld1))
        	    {
                fld2 := get_keyword ('url', item);
                insert into DB.DBA.WA_USER_OL_ACCOUNTS ( WUO_NAME, WUO_URL, WUO_U_ID, WUO_TYPE)
                  values (fld1, fld2, self.u_id, 'P');
        	    }
        	  }
          }
        }
        if (get_keyword ('cb_item_iKnows', params, '0') = '1')
        {
          if (length (self.iKnows))
          {
            declare fld1, fld2 any;

            delete from DB.DBA.WA_USER_OL_ACCOUNTS where WUO_U_ID = self.u_id;
            foreach (any item in self.iKnows) do
        	  {
              fld1 := get_keyword ('value', item);
        	    if (length (fld1))
        	    {
                if (not exists (select 1 from DB.DBA.WA_USER_KNOWS where WUK_U_ID = self.u_id and WUK_URI = fld1))
                {
                  fld2 := get_keyword ('nick', item, get_keyword ('name', item, ''));
                  insert into DB.DBA.WA_USER_KNOWS (WUK_U_ID, WUK_FLAG, WUK_URI, WUK_LABEL)
                    values (self.u_id, '1', fld1, fld2);
                }
        	    }
        	  }
          }
        }
        if (get_keyword ('cb_item_iHCounty', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_HCOUNTRY', self.iHCounty);

        if (get_keyword ('cb_item_iHState', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_HSTATE', self.iHState);

        if (get_keyword ('cb_item_iHCyty', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_HCITY', self.iHCyty);

        if (get_keyword ('cb_item_iHCode', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_HCODE', self.iHCode);

        if (get_keyword ('cb_item_iHAddress1', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_HADDRESS1', self.iHAddress1);

        if (get_keyword ('cb_item_iHAddress2', params, '0') = '1')
          DB.DBA.WA_USER_EDIT (self.u_name, 'WAUI_HADDRESS2', self.iHAddress2);

        commit work;
        self.iMode := 0;
      }
    ]]>
  </v:method>

  <v:variable name="iMode" type="integer" default="0"/>
  <v:variable name="iLDAP" type="integer" default="0"/>

  <v:variable name="iPhoto" type="varchar" default="null" />
  <v:variable name="iTitle" type="varchar" default="null" />
  <v:variable name="iNick" type="varchar" default="null" />
  <v:variable name="iName" type="varchar" default="null" />
  <v:variable name="iFirstName" type="varchar" default="null" />
  <v:variable name="iFamily_name" type="varchar" default="null" />
  <v:variable name="iMbox" type="varchar" default="null" />
  <v:variable name="iGender" type="varchar" default="null" />
  <v:variable name="iBirthday" type="varchar" default="null" />
  <v:variable name="iLat" type="varchar" default="null" />
  <v:variable name="iLng" type="varchar" default="null" />

  <v:variable name="iIcqChatID" type="varchar" default="null" />
  <v:variable name="iSkypeChatID" type="varchar" default="null" />
  <v:variable name="iMsnChatID" type="varchar" default="null" />
  <v:variable name="iAimChatID" type="varchar" default="null" />
  <v:variable name="iYahooChatID" type="varchar" default="null" />
  <v:variable name="iWorkplaceHomepage" type="varchar" default="null" />
  <v:variable name="iHomepage" type="varchar" default="null" />
  <v:variable name="iPhone" type="varchar" default="null" />
  <v:variable name="iResume" type="varchar" default="null" />
  <v:variable name="iInterests" type="any" default="null" />
  <v:variable name="iTopicInterests" type="any" default="null" />
  <v:variable name="iOnlineAccounts" type="any" default="null" />
  <v:variable name="iSameAs" type="any" default="null" />
  <v:variable name="iKnows" type="any" default="null" />
  <v:variable name="iTags" type="varchar" default="null" />

  <v:variable name="iHCounty" type="varchar" default="null" />
  <v:variable name="iHState" type="varchar" default="null" />
  <v:variable name="iHCyty" type="varchar" default="null" />
  <v:variable name="iHCode" type="varchar" default="null" />
  <v:variable name="iHAddress1" type="varchar" default="null" />
  <v:variable name="iHAddress2" type="varchar" default="null" />

  <v:variable name="i_source" type="any" default="-1" />
  <v:variable name="i_lName" type="varchar" default="''" />

  <v:before-data-bind>
    <![CDATA[
      declare tmp any;

      if (e.ve_is_post and e.ve_button = self.page_form)
      {
        self.usr_personal_0.vc_focus := 1;
        self.usr_personal_0.vc_set_childs_focus(1, e);
      }
      self.iLDAP := (select count(*) from LDAP..LDAP_SERVERS where LS_USER_ID = self.u_id);
    ]]>
  </v:before-data-bind>

  <v:form name="usr_personal_0" type="simple" method="POST" action="uiedit.vspx?page=2">
    <div>
      <v:template name="iTemplate_00" type="simple" condition="equ(self.iMode,0)">
        <table class="ctl_grp">
          <tr>
            <td nowrap="nowrap">
              <label>
                <v:radio-button name="i_source_0" xhtml_id="i_source_0" group-name="i_source" value="0" xhtml_style="--case when self.iLDAP > 0 then '' else 'display: none' end">
                <v:before-render>
                  <![CDATA[
                    control.ufl_selected := either (lte(self.i_source, 0), 1, 0);
                  ]]>
                </v:before-render>
              </v:radio-button>
                Profile Document URL
              </label>
            </td>
            <td>
              <v:text name="foaf_url" xhtml_id="foaf_url" value="" xhtml_onfocus="javascript: $(\'i_source_0\').checked=true;" xhtml_size="70"/>
            </td>
          </tr>
          <v:template name="iTemplate_x" type="simple" condition="self.iLDAP">
          <tr>
            <td nowrap="nowrap">
                <label>
              <v:radio-button name="i_source_1" xhtml_id="i_source_1" group-name="i_source" value="1">
                <v:before-render>
                  <![CDATA[
                    control.ufl_selected := either (equ(self.i_source, 1), 1, 0);
                  ]]>
                </v:before-render>
              </v:radio-button>
                  <b>LDAP Server</b>
                </label>
            </td>
            <td>
              <v:data-list name="f_lName"
                           value="--self.i_lName"
                           key-column="LS_NAME"
                           value-column="LS_NAME"
                           sql="select '' as LS_NAME from SYS_USERS where U_ID = 0 union all select LS_NAME from LDAP..LDAP_SERVERS where LS_USER_ID = self.u_id"
                             xhtml_onfocus="javascript: $(\'i_source_1\').checked=true;" />
            </td>
          </tr>
          </v:template>
        </table>
      </v:template>
      <v:template name="iTemplate_0" type="simple" condition="self.iMode">
        <fieldset>
          Please confirm importing of the following data in your personal profile.<br />
          The corresponding existing data will be replaced.
        </fieldset>
        <br />
        <table class="listing">
          <tr class="listing_header_row">
            <th width="1%"><input type="checkbox" name="cb_all" value="Select All" onclick="selectAllCheckboxes(this, 'cb_item')" /></th>
            <th>Field</th>
            <th>Value</th>
          </tr>
          <v:template name="iTemplate_01" type="simple" condition="length (self.iPhoto)">
            <tr>
              <td valign="top"><input type="checkbox" name="cb_item_iPhoto" id="cb_item_iPhoto" value="1" /></td>
              <td valign="top">Photo</td>
              <td><img src="<?V self.iPhoto ?>"/></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_02" type="simple" condition="length (self.iTitle)">
            <tr>
              <td><input type="checkbox" name="cb_item_iTitle" id="cb_item_iTitle" value="1" /></td>
              <td>Title</td>
              <td><?V self.iTitle ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_03" type="simple" condition="length (self.iNick)">
            <tr>
              <td><input type="checkbox" name="cb_item_iNick" id="cb_item_iNick" value="1" /></td>
              <td>Nick</td>
              <td><?V wa_utf8_to_wide (self.iNick) ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_04" type="simple" condition="length (self.iFirstName)">
            <tr>
              <td><input type="checkbox" name="cb_item_iFirstName" id="cb_item_iFirstName" value="1" /></td>
              <td>First Name</td>
              <td><?V wa_utf8_to_wide (self.iFirstName) ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_05" type="simple" condition="length (self.iFamily_name)">
            <tr>
              <td><input type="checkbox" name="cb_item_iFamily_name" id="cb_item_iFamily_name" value="1" /></td>
              <td>Family Name</td>
              <td><?V wa_utf8_to_wide (self.iFamily_name) ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_06" type="simple" condition="length (self.iName)">
            <tr>
              <td><input type="checkbox" name="cb_item_iName" id="cb_item_iName" value="1" /></td>
              <td>Full Name</td>
              <td><?V wa_utf8_to_wide (self.iName) ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_07" type="simple" condition="length (self.iMBox)">
            <tr>
              <td><input type="checkbox" name="cb_item_iMBox" id="cb_item_iMBox" value="1" /></td>
              <td>E-mail</td>
              <td><?V self.iMBox ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_08" type="simple" condition="length (self.iGender)">
            <tr>
              <td><input type="checkbox" name="cb_item_iGender" id="cb_item_iGender" value="1" /></td>
              <td>Gender</td>
              <td><?V self.iGender ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_09" type="simple" condition="length (self.iBirthday)">
            <tr>
              <td><input type="checkbox" name="cb_item_iBirthday" id="cb_item_iBirthday" value="1" /></td>
              <td>Birthday</td>
              <td><?V self.iBirthday ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_10" type="simple" condition="length (self.iLng)">
            <tr>
              <td><input type="checkbox" name="cb_item_iLng" id="cb_item_iLng" value="1" /></td>
              <td>Geo position</td>
              <td><?V self.iLat ?>; <?V self.iLng ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_11" type="simple" condition="length (self.iIcqChatID)">
            <tr>
              <td><input type="checkbox" name="cb_item_iIcqChatID" id="cb_item_iIcqChatID" value="1" /></td>
              <td>ICQ</td>
              <td><?V wa_utf8_to_wide (self.iIcqChatID) ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_12" type="simple" condition="length (self.iSkypeChatID)">
            <tr>
              <td><input type="checkbox" name="cb_item_iSkypeChatID" id="cb_item_iSkypeChatID" value="1" /></td>
              <td>Skype</td>
              <td><?V wa_utf8_to_wide (self.iSkypeChatID) ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_13" type="simple" condition="length (self.iMsnChatID)">
            <tr>
              <td><input type="checkbox" name="cb_item_iMsnChatID" id="cb_item_iMsnChatID" value="1" /></td>
              <td>MSN</td>
              <td><?V wa_utf8_to_wide (self.iMsnChatID) ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_14" type="simple" condition="length (self.iAimChatID)">
            <tr>
              <td><input type="checkbox" name="cb_item_iAimChatID" id="cb_item_iAimChatID" value="1" /></td>
              <td>AIM</td>
              <td><?V wa_utf8_to_wide (self.iAimChatID) ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_15" type="simple" condition="length (self.iYahooChatID)">
            <tr>
              <td><input type="checkbox" name="cb_item_iYahooChatID" id="cb_item_iYahooChatID" value="1" /></td>
              <td>Yahoo</td>
              <td><?V wa_utf8_to_wide (self.iYahooChatID) ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_16" type="simple" condition="length (self.iWorkplaceHomepage)">
            <tr>
              <td><input type="checkbox" name="cb_item_iWorkplaceHomepage" id="cb_item_iWorkplaceHomepage" value="1" /></td>
              <td>Workplace Homepage</td>
              <td><?V self.iWorkplaceHomepage ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_17" type="simple" condition="length (self.iHomepage)">
            <tr>
              <td><input type="checkbox" name="cb_item_iHomepage" id="cb_item_iHomepage" value="1" /></td>
              <td>Homepage</td>
              <td><?V self.iHomepage ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_18" type="simple" condition="length (self.iPhone)">
            <tr>
              <td><input type="checkbox" name="cb_item_iPhone" id="cb_item_iPhone" value="1" /></td>
              <td>Phone</td>
              <td><?V self.iPhone ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_19" type="simple" condition="length (self.iHCounty)">
            <tr>
              <td><input type="checkbox" name="cb_item_iHCounty" id="cb_item_iHCounty" value="1" /></td>
              <td>Address - Country</td>
              <td><?V self.iHCounty ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_20" type="simple" condition="length (self.iHState)">
            <tr>
              <td><input type="checkbox" name="cb_item_iHState" id="cb_item_iHState" value="1" /></td>
              <td>Address - State/Province</td>
              <td><?V self.iHState ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_21" type="simple" condition="length (self.iHCyty)">
            <tr>
              <td><input type="checkbox" name="cb_item_iHCyty" id="cb_item_iHCyty" value="1" /></td>
              <td>Address - City/Town</td>
              <td><?V self.iHCyty ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_22" type="simple" condition="length (self.iHCode)">
            <tr>
              <td><input type="checkbox" name="cb_item_iHCode" id="cb_item_iHCode" value="1" /></td>
              <td>Address - Zip/Postal Code</td>
              <td><?V self.iHCode ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_23" type="simple" condition="length (self.iHAddress1)">
            <tr>
              <td><input type="checkbox" name="cb_item_iHAddress1" id="cb_item_iHAddress1" value="1" /></td>
              <td>Address - Address 1</td>
              <td><?V self.iHAddress1 ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_24" type="simple" condition="length (self.iHAddress2)">
            <tr>
              <td><input type="checkbox" name="cb_item_iHAddress2" id="cb_item_iHAddress2" value="1" /></td>
              <td>Address - Address 2</td>
              <td><?V self.iHAddress2 ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_25" type="simple" condition="length (self.iResume)">
            <tr>
              <td><input type="checkbox" name="cb_item_iResume" id="cb_item_iResume" value="1" /></td>
              <td>Resume</td>
              <td><?V self.iResume ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_26" type="simple" condition="length (self.iTags)">
            <tr>
              <td><input type="checkbox" name="cb_item_iTags" id="cb_item_iTags" value="1" /></td>
              <td>Tags</td>
              <td><?V self.iTags ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_27" type="simple" condition="length (self.iSameAs)">
            <tr>
              <td valign="top"><input type="checkbox" name="cb_item_iSameAs" id="cb_item_iSameAs" value="1" /></td>
              <td valign="top">Other Personal URIs (WebIDs)</td>
              <td><?vsp self.show_data (self.iSameAs, vector ('value')); ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_28" type="simple" condition="length (self.iInterests)">
            <tr>
              <td valign="top"><input type="checkbox" name="cb_item_iInterests" id="cb_item_iInterests" value="1" /></td>
              <td valign="top">Resource URI indicating thing of interest</td>
              <td><?vsp self.show_data (self.iInterests, vector ('value', 'label')); ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_29" type="simple" condition="length (self.iTopicInterests)">
            <tr>
              <td valign="top"><input type="checkbox" name="cb_item_iTopicInterests" id="cb_item_iTopicInterests" value="1" /></td>
              <td valign="top">Web page URL indicating a topic of interest   </td>
              <td><?vsp self.show_data (self.iTopicInterests, vector ('value', 'label')); ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_30" type="simple" condition="length (self.iOnlineAccounts)">
            <tr>
              <td valign="top"><input type="checkbox" name="cb_item_iOnlineAccounts" id="cb_item_iOnlineAccounts" value="1" /></td>
              <td valign="top">Online Accounts</td>
              <td><?vsp self.show_data (self.iOnlineAccounts, vector ('value', 'url')); ?></td>
            </tr>
          </v:template>
          <v:template name="iTemplate_31" type="simple" condition="length (self.iKnows)">
            <tr>
              <td valign="top"><input type="checkbox" name="cb_item_iKnows" id="cb_item_iKnows" value="1" /></td>
              <td valign="top">Knows URIs</td>
              <td><?vsp self.show_data (self.iKnows, vector ('value', 'name')); ?></td>
            </tr>
          </v:template>
        </table>
      </v:template>
      <br />
      <div class="fm_btn_row clearfix">
        <v:button name="user_c_personal_0" value="Cancel" action="simple" xhtml_onclick="javascript: return initLoadProfile();">
          <v:on-post>
            self.vc_redirect (sprintf ('uhome.vspx?ufname=%U&amp;l=1', self.u_name));
          </v:on-post>
        </v:button>
        <v:button name="user_s_personal_0" value="--case when (self.iMode = 0) then 'Import' else 'Save' end" action="simple" xhtml_onclick="return validateInputs(this);">
          <v:on-post>
            <![CDATA[
              self.savePersonal_0();
              if (self.iMode = 0)
   		          self.vc_redirect ('uiedit.vspx?page=1&tabNo=0');
            ]]>
          </v:on-post>
        </v:button>
        <v:button name="user_sn_personal_0" value="--case when (self.iMode = 0) then 'Next' else 'Save and Next' end" action="simple" xhtml_onclick="return validateInputs(this);">
          <v:on-post>
            <![CDATA[
              if (self.iMode = 0)
   		          self.vc_redirect ('uiedit.vspx?page=1&tabNo=1');
              self.savePersonal_0();
              if (self.vc_is_valid)
   		          self.vc_redirect ('uiedit.vspx?page=1&tabNo=1');
            ]]>
          </v:on-post>
        </v:button>
      </div>
    </div>
  </v:form>
</v:page>
