<?xml version="1.0" encoding="UTF-8"?>
<?python
  import template
?>
<html xmlns:py="http://purl.org/kid/ns#"
      py:layout="template">

<div py:def="body(_)">
<?python
  try:
    rows=int(REQ.get("rows", SHOW_ROWS))
    lng=REQ.get("lang", LANG)
    if (rows!=SHOW_ROWS) or (lng!=LANG):
      # store rows
      DB.execute("UPDATE webaccess SET showrows=%s, lang=%s",
                 [rows, lng])
      SHOW_ROWS=rows
      LANG=lng
    
    error = change_passwd(
              DB,
              REMOTE_LOGIN,
              REQ.get('old'),
              REQ.get('new'),
              REQ.get('retyped'),
              LANG
            )
  except Exception, e:
    error = e
    print "settings.kid:", e
?>

<form action="settings.kid" method="post">
<table style="width: 50%">
<tr>
  <td colspan="2" style="text-align: center">
    <h1 style="text-align: center">${_('User settings')}</h1></td>
</tr>
<tr py:if="error">
<td colspan="2" style="text-align: center"><hr/>${error}</td>
</tr>
<tr><td colspan="2"><hr/></td></tr>
<tr>
  <td colspan="2" style="text-align: center">
    <h3 style="text-align: center">${_('Password change')}</h3></td>
</tr>
<tr>
  <td style="text-align: right">${_('Old password:')}</td>
  <td><input type="password" name="old"/></td>
</tr>
<tr>
  <td style="text-align: right">${_('New password:')}</td>
  <td><input type="password" name="new"/></td>
</tr>
<tr>
  <td style="text-align: right">${_('Retype new password:')}</td>
  <td><input type="password" name="retyped"/></td>
</tr>
<tr><td colspan="2"><hr/></td></tr>
<tr>
  <td colspan="2" style="text-align: center">
    <h3 style="text-align: center">${_('Other settings')}</h3></td>
</tr>
<tr><td style="text-align: right">${_('Language:')}</td><td>
<select name="lang">
<span py:for="lng in LANGS" py:strip="">
<?python
  if lng==LANG:
    attrs={"selected": "selected"}
  else:
    attrs={}
?>
<option value="${lng}" py:attrs="attrs">${lng}</option>
</span>
</select>
</td></tr>
<tr>
  <td style="text-align: right">${_('Show rows:')}</td>
  <td><input type="text" name="rows" size="3" value="${SHOW_ROWS}"/></td>
</tr>
<tr><td colspan="2"><hr/></td></tr>
<tr><td colspan="2" style="text-align: center"><input type="submit" value="Save settings" class="submit"/></td></tr>
</table>
</form>
</div>

</html>
