foaf_user/commit
Initial version of account manager package
author | Jan Wielemaker |
---|---|
Mon Nov 8 15:19:25 2010 +0100 | |
committer | Jan Wielemaker |
Mon Nov 8 15:19:25 2010 +0100 | |
commit | c18ffdf4d709a03145673eb59d428c76fb952a3c |
tree | 618d2ca35ed74102ef5c90e27454166f33c2f57d |
parent |
Diff style: patch stat
diff --git a/applications/user_account.pl b/applications/user_account.pl new file mode 100644 index 0000000..5cea6f2 --- /dev/null +++ b/applications/user_account.pl @@ -0,0 +1,89 @@ +/* Part of ClioPatria SeRQL and SPARQL server + + Author: Jan Wielemaker + E-mail: J.Wielemaker@cs.vu.nl + WWW: http://www.swi-prolog.org + Copyright (C): 2010, University of Amsterdam, + VU University Amsterdam + + This program 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. + + 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 library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + As a special exception, if you link this library with other files, + compiled with a Free Software compiler, to produce an executable, this + library does not by itself cause the resulting executable to be covered + by the GNU General Public License. This exception does not however + invalidate any other reasons why the executable file might be covered by + the GNU General Public License. +*/ + +:- module(user_account, []). +:- use_bundle(html_page). +:- use_module(user(user_db)). + +:- http_handler(root('user/edit_user'), edit_user_form, []). +:- http_handler(api(update_user), update_user, []). + +/** <module> User account management +*/ + +edit_user_form(Request) :- + http_parameters(Request, + [ r(UserURI, + [ description('OpenID URI of the user') + ]) + ]), + authorized(write(user, UserURI)), + reply_html_page(cliopatria(user), + title('Edit user info'), + [ h1('Edit user info'), + \user_form(UserURI) + ]). + + +user_form(UserURI) --> + { user_property(User, uri(UserURI)), + user_property(User, realname(RealName)) + }, + html(form(action(location_by_id(update_user)), + table(class(form), + [ \hidden(r, UserURI), + \form_input('Real name', + input([ disabled, + value(RealName), + name(realname), + size(50) + ])), + \form_submit('Update account') + ]))). + + + /******************************* + * API * + *******************************/ + +update_user(Request) :- + http_parameters(Request, + [ r(UserURI, + [ description('OpenID URI of the user') + ]), + realname(_RealName, + [ optional(true), + description('Real name of the user') + ]) + ]), + authorized(write(user, UserURI)). + + + diff --git a/config-available/DEFAULTS b/config-available/DEFAULTS new file mode 100644 index 0000000..c97fbcb --- /dev/null +++ b/config-available/DEFAULTS @@ -0,0 +1 @@ +config(account, link). diff --git a/config-available/account.pl b/config-available/account.pl new file mode 100644 index 0000000..32442e8 --- /dev/null +++ b/config-available/account.pl @@ -0,0 +1,13 @@ +:- module(conf_account, []). +:- use_module(account(applications/user_account)). +:- use_module(user(user_db)). +:- use_module(cliopatria(hooks)). + +/** <module> Manage user accounts +*/ + +cliopatria:menu_popup_order(cpack, 250). +cliopatria:menu_label(cpack, 'CPACK'). + +cliopatria:menu_item(250=current_user/edit_user_form, 'My account') :- + logged_on(_).