Plasma GitLab Archive
Projects Blog Knowledge

<?xml version="1.0" encoding="ISO-8859-1"?>

<!--
  - <COPYRIGHT>
  - Copyright 2003 Gerd Stolpmann
  -
  - <GPL>
  - This file is part of WTimer.
  - 
  - WTimer 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; either version 2 of the License, or
  - (at your option) any later version.
  -
  - WTimer 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 WDialog; if not, write to the Free Software
  - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  - </>
  -->

<!--  $Id: admin_accounts.ui,v 1.6 2003/03/23 11:59:13 gerd Exp $
   -  ======================================================================
   - 
  -->

<!-- This file defines the dialog "admin-accounts". -->

<ui:dialog name="admin-accounts" start-page="accounts">
  <ui:variable name="session" type="dialog"/>
    <!-- The session pseudo dialog, see session.ui -->

  <ui:variable name="scroll_position"/>
    <!-- See explanations in definitions.ui, basic-grid -->

  <!-- Account list: -->
  <ui:enumeration name="bool">
    <ui:enum internal="no"/>
    <ui:enum internal="yes"/>
  </ui:enumeration>

  <ui:enumeration name="login">
    <ui:enum internal="no-password"/>
    <ui:enum internal="disabled"/>
    <ui:enum internal="enabled"/>
  </ui:enumeration>

  <ui:variable name="admin" type="bool">
    <!-- Whether the current user has admin privileges -->
    <ui:enum-value><ui:enum-item internal="yes"/></ui:enum-value>
  </ui:variable>

  <ui:variable name="modified">
    <!-- Is there any unsaved modification of the data? yes/no/load -->
    <ui:string-value>load</ui:string-value>
  </ui:variable>

  <ui:variable name="checksum">
    <!-- The checksum of the contents as saved into the database. -->
  </ui:variable>

  <ui:variable name="acc-first-new-row">
    <!-- The first row that has been appended to the list of accounts -->
    <!--&admin-accounts-acc-first-new-row;-->        <!-- test data -->
    <ui:string-value>0</ui:string-value>
  </ui:variable>

  <ui:variable name="acc-delete" associative="yes" type="bool">
    <!-- Contains the variables for the "Del?" checkboxes. Keys are 
       - IDs from 0 to N-1, values are bool
      -->
    <!--&admin-accounts-acc-delete;-->               <!-- test data -->
  </ui:variable>

  <ui:variable name="acc-del-sheets" type="dynamic-enumerator" temporary="yes">
    <!-- To generate the confirmation dialog: This variable contains
       - the sheets that are implicitly deleted. Keys are sheet names,
       - values are descriptions.
      -->
  </ui:variable>


  <ui:variable name="acc-edit" associative="yes" type="bool">
    <!-- Whether a row can be edited -->
    <!--&admin-accounts-acc-edit;-->                 <!-- test data -->
  </ui:variable>

  <ui:variable name="acc-name"  associative="yes" type="string">
    <!-- Contains the variables for the "Login Name" boxes. Keys are 
       - IDs from 0 to N-1, values are strings
      -->
    <!--&admin-accounts-acc-name;-->                 <!-- test data -->
  </ui:variable>

  <ui:variable name="acc-comment"  associative="yes" type="string">
    <!-- Contains the variables for the "Comment" boxes. Keys are 
       - IDs from 0 to N-1, values are strings
      -->
    <!--&admin-accounts-acc-comment;-->              <!-- test data -->
 </ui:variable>

  <ui:variable name="acc-admin"  associative="yes" type="bool">
    <!-- Contains the variables for the "Admin?" checkboxes. Keys are 
       - IDs from 0 to N-1, values are bool
      -->
    <!--&admin-accounts-acc-admin;-->                <!-- test data -->
  </ui:variable>

  <ui:variable name="acc-login"  associative="yes" type="login">
    <!-- Contains the variables for the "Login?" checkboxes. Keys are 
       - IDs from 0 to N-1, values are "login" (triple-valued)
      -->
    <!--&admin-accounts-acc-login;-->                <!-- test data -->
  </ui:variable>


  <ui:enumeration name="message">
    <ui:enum internal="saved"
             external="The list has been saved into the database."/>
    <ui:enum internal="error-double-names"
             external="One of the login names is already used, either as name of another user or as name of another sheet."/>
    <ui:enum internal="warning-no-admin"
             external="At least one user must be administrator, and he/she must be allowed to log in."/>
  </ui:enumeration>


  <ui:variable name="message" type="message">
    <!-- Messages to display -->
    <!--&admin-accounts-message; -->
  </ui:variable>

  <ui:variable name="deferred-dialog" type="dialog"/>
    <!-- While the page "unsaved" is displayed, this variable stores the
       - dialog the user tried to call
      -->


  <ui:page name="accounts">
    <t:basic-grid have_scroll_position="yes">
      <p:nav-col>
	<t:admin-accounts-nav/>
      </p:nav-col>
      <p:headline>
	<t:admin-accounts-head/>
      </p:headline>
      <p:main-col>
	<div><a href="#help">Help</a></div>
	<ui:enumerate variable="message" template="message"/>
	<table class="accounts">
	  <tr bgcolor="#8B7E66">
	    <th class="accounts"><font color="white">Del?</font></th>
	    <th class="accounts"><font color="white">Login Name</font></th>
	    <th class="accounts"><font color="white">Comment or<br/>Real Name</font></th>
	    <th class="accounts"><font color="white">Admin?</font></th>
	    <th class="accounts"><font color="white">Login?</font></th>
	  </tr>
	  <ui:iterate variable="acc-comment" template="accounts-row"/>
	</table>
	<ui:ifvar variable="acc-login" value="no-password" op="mentions">
	  <t:vspacer size="20"/>
	  <div>
	    <i>password missing</i> means that login is not possible as there
	    is not any password yet for the account. You can set a password
	    on the page "Change Password".
	  </div>
	</ui:ifvar>

	<div class="help">
	  <a name="help"/>
	  <div>
	    This dialog allows you to create user accounts, to modify user 
	    accounts and to delete user accounts. A user account is necessary
	    to log into the application, and to own data sheets. Only the
	    administrator can create new accounts, but normal people can
	    modify and delete their own accounts.
	  </div>

	  <div>
	    To <em>create</em> a new account, press the button "New line",
	    fill out the new row, and press "Save". Press "OK" in the
	    confirmation dialog. 
	    <ui:cond>
	      <ui:if value1="&login-dialog;" value2="yes">
		Note that new accounts to not have a
		password, and it is necessary to set one in the "Change Password"
		dialog before the user can log in.
	      </ui:if>
	      <ui:true>
		Note that it might be necessary to change the user directory
		of the web server, too. A user can only log in if he is
		permitted by both the web server and this list of user
		accounts.
	      </ui:true>
	    </ui:cond>
	  </div>

	  <div>
	    To <em>delete</em> an account, select the account in the
	    "Del?" column, and press "Save". Press "OK" in the confirmation
	    dialog.
	  </div>

	  <div>
	    To <em>modify</em> an account, change the row in the table,
	    and press "Save". Press "OK" in the confirmation
	    dialog.
	  </div>

	  <div>
	    The column <em>Admin</em> is checked when the corresponding user is
	    an administrator.</div>

	  <div>
	    The column <em>Login</em> is checked when the corresponding user
	    is allowed to log in. (By removing the check the administrator
	    can temporarily disable a user account.)
	  </div>
	</div>

      </p:main-col>
    </t:basic-grid>
  </ui:page>


  <ui:page name="confirm">
    <!-- When somebody wants to save changes -->
    <t:basic-grid>
      <p:nav-col>
	<!-- empty nav-col: this is a modal dialog -->
      </p:nav-col>
      <p:headline>
	<t:admin-accounts-head/>
      </p:headline>
      <p:main-col>
	<q:message int="confirm-save">
	  <div>
	    Please confirm the following changes:
	  </div>
	  <ul>
	    <ui:if value1="$[acc-first-new-row]" value2="$[size(acc-name)]"
	           op="int-lt">
	      <li>These accounts are created:
		<t:accounts-confirm-new n="$[acc-first-new-row]"/><br/><br/>
		Note that login will be disabled until passwords are set.
		You can enter passwords on the page "Change Password".
		For every account a sheet will be created with the same
		name.
		<br/>&nbsp;
	      </li>
	    </ui:if>
	    <ui:ifvar variable="acc-delete" value="yes" op="mentions">
	      <li>These accounts are deleted:
		<ui:iterate variable="acc-delete"
		            template="accounts-confirm-del">
		  <ui:iter-separator> </ui:iter-separator>
		</ui:iterate>
		<br/>&nbsp;
	      </li>
	      <ui:ifvar variable="acc-del-sheets" value="1" op="size-ge">
		<li>These corresponding sheets are deleted (they would lose
		  their only owner):
		  <ui:enumerate variable="acc-del-sheets"
		                template="wd-ext">
		    <ui:iter-separator> </ui:iter-separator>
		  </ui:enumerate>
		  <br/>&nbsp;
		</li>
	      </ui:ifvar>
	    </ui:ifvar>
	    <li>Any changes of comments, or of admin or login
	      permissions, as requested</li>
	  </ul>
	  <div class="buttonbox">
	    <ui:button name="confirm-ok"      label="OK"/>
	    <ui:button name="confirm-cancel"  label="Cancel"/>
	  </div>
	</q:message>
      </p:main-col>
    </t:basic-grid>
  </ui:page>


  <ui:page name="unsaved">
    <!-- When somebody tries to leave the accounts list without saving -->
    <t:basic-grid>
      <p:nav-col>
	<!-- empty nav-col: this is a modal dialog -->
      </p:nav-col>
      <p:headline>
	<t:admin-accounts-head/>
      </p:headline>
      <p:main-col>
	<q:message int="confirm-unsaved">
	  <div>
	    You try to leave this page, but there are unsaved changes.
	    Do you want to save the accounts list now?
	  </div>
	  <div class="buttonbox">
	    <ui:button name="unsaved-save"    label="Save list" goto="accounts"/>
	    <ui:button name="unsaved-discard" label="Discard changes"/>
	    <ui:button name="unsaved-cancel"  label="Cancel"/>
	  </div>
	</q:message>
      </p:main-col>
    </t:basic-grid>
  </ui:page>



  <!-- ERROR HANDLING -->

  <!-- See also ocaml class error_behaviour that uses the following
       definitions
    -->

  <ui:variable name="runtime-error"/>

  <ui:page name="runtime-error">
    <t:basic-grid>
      <p:nav-col>
	<!-- empty nav-col: this is a modal dialog -->
      </p:nav-col>
      <p:headline>
	<t:admin-accounts-head/>
      </p:headline>
      <p:main-col>
	<t:error errid="$[runtime-error]"/>
	<ui:button name="cont-error" label="Continue"/>
      </p:main-col>
    </t:basic-grid>
  </ui:page>

</ui:dialog>

<!-- ********************************************************************** -->

<ui:template name="admin-accounts-head">
  <!-- The head line -->
  <t:admin-head>
    <p:suffix>
      User accounts
      <t:head-modified-flag/>
    </p:suffix>
  </t:admin-head>
</ui:template>


<ui:template name="admin-accounts-nav">
  <!-- The navigation bar -->
  <t:admin-nav/>

  <q:nav-section head="Accounts">
    <ui:ifvar variable="admin" value="yes" op="contains">
      <q:nav-entry title="Add new line (ALT-N)">
	<q:applink label="New line" name="accounts-new-line" accesskey="N"/>
      </q:nav-entry>
    </ui:ifvar>
    <q:nav-entry title="Save changes in database (ALT-S)">
      <q:applink label="Save" name="accounts-save" accesskey="S"/>
    </q:nav-entry>
   <!--
    <q:nav-entry title="Test: Unsaved changes">
      <q:applink label="Test 1" name="access-test1" goto="unsaved"/>
    </q:nav-entry>
   -->
  </q:nav-section>

</ui:template>

<!-- ********************************************************************** -->

<ui:template name="accounts-row" from-caller="int">
  <!-- int: the list ID -->
  <tr bgcolor="#CDBA96">
    <td class="accounts">
      <ui:ifvar variable="acc-edit" index="$int" value="yes" op="contains">
	<ui:checkbox variable="acc-delete" index="$int" value="yes"
	             onchange="set_modified_flag()"/>
      </ui:ifvar>
      &nbsp;
    </td>
    <td class="accounts">
      <ui:cond>
	<ui:if value1="$int" value2="$[acc-first-new-row]" op="int-ge">
	  <ui:text variable="acc-name" index="$int" 
	           onchange="set_modified_flag()"/>
	</ui:if>
	<ui:true>
	  <ui:dynamic variable="acc-name" index="$int"/>
	</ui:true>
      </ui:cond>
    </td>
    <td class="accounts">
      <ui:cond>
	<ui:ifvar variable="acc-edit" index="$int" value="yes" op="contains">
	  <ui:text variable="acc-comment" index="$int" 
	           onchange="set_modified_flag()"/>
	</ui:ifvar>
	<ui:true>
	  <ui:dynamic variable="acc-comment" index="$int"/>
	</ui:true>
      </ui:cond>
    </td>
    <td class="accounts">
      <ui:cond>
	<ui:ifvar variable="admin" value="no" op="contains">
	  <ui:enumerate variable="acc-admin" index="$int" template="wd-ext"/>
	</ui:ifvar>
	<ui:ifvar variable="acc-edit" index="$int" value="yes" op="contains">
	  <ui:checkbox variable="acc-admin" index="$int" value="yes"
	               onchange="set_modified_flag()"/>
	</ui:ifvar>
	<ui:true>
	  <ui:enumerate variable="acc-admin" index="$int" template="wd-ext"/>
	</ui:true>
      </ui:cond>
    </td>
    <td class="accounts">
      <ui:cond>
	<ui:ifvar variable="acc-login" index="$int" value="no-password" 
	          op="contains">
	  <i>password missing</i>
	</ui:ifvar>
	<ui:true>
	  <ui:cond>
	    <ui:ifvar variable="acc-edit" index="$int" value="yes" op="contains">
	  
	      <ui:checkbox variable="acc-login" index="$int" value="enabled"
	                   onchange="set_modified_flag()"/>
	    </ui:ifvar>
	    <ui:true>
	      <ui:enumerate variable="acc-login" index="$int" template="wd-ext"/>
	    </ui:true>
	  </ui:cond>
	</ui:true>
      </ui:cond>
    </td>
  </tr>
</ui:template>

<!-- ********************************************************************** -->

<ui:template name="accounts-confirm-del" from-caller="int">
  <!-- int: The index of an elements of acc-delete
     - ext: "yes" or "no"
     - This template outputs the corresponding user name if ext is yes
    -->
  <ui:ifvar variable="acc-delete" index="$int" value="yes" op="contains">
    $[assoc(acc-name,$int)]
  </ui:ifvar>
</ui:template>

<ui:template name="accounts-confirm-new" from-caller="n">
  <!-- Outputs all user names whose index is >= n -->
  <!-- Assumption: No index number is skipped! -->
  <ui:if value1="$n" value2="$[size(acc-name)]" op="int-lt">
    <t:accounts-confirm-new-out n="$n"/> 
    <t:accounts-confirm-new n="$[add($n,1)]"/>
  </ui:if>
</ui:template>

<ui:template name="accounts-confirm-new-out" from-caller="n">
  $[nth(acc-name,$n)]
</ui:template>

<!-- ******************* For Emacs: ********************* -->
<!--
Local Variables:
mode: xml
sgml-parent-document: ("main.ui" "ui:application" "ui:dialog")
End:
-->

This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml