+dotLRN Admin: Edit a User
+@context_bar@
+
+You're editing @first_names@ @last_name@.
+
+
+
+You're asking to change the level of access of this user. This has strong repercussions. Are you user about this?
+
+
+
+
+
Index: openacs-4/packages/dotlrn/www/admin/user-edit.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/user-edit.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn/www/admin/user-edit.adp 10 Dec 2001 23:58:31 -0000 1.1
@@ -0,0 +1,11 @@
+
+dotLRN Admin: Edit a User
+@context_bar@
+
+You're editing @first_names@ @last_name@.
+
+
+
+
+
+
Index: openacs-4/packages/dotlrn/www/admin/user-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/user-edit.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn/www/admin/user-edit.tcl 10 Dec 2001 23:58:31 -0000 1.1
@@ -0,0 +1,117 @@
+
+ad_page_contract {
+ Edit a User
+
+ @author Ben Adida (ben@openforce.net)
+ @creation-date 2001-12-10
+} {
+ user_id
+}
+
+form create edit_user
+
+element create edit_user user_id \
+ -label "User ID" -datatype integer -widget hidden -value $user_id
+
+element create edit_user type_id \
+ -label "User Type" -datatype text -widget select -options [dotlrn::get_user_types]
+
+element create edit_user rel_type \
+ -label "Access" -datatype text -widget select -options {{{Limited Access} dotlrn_user_rel} {{Full Access} dotlrn_full_user_rel}}
+
+element create edit_user read_private_data_p \
+ -label "Can Access Private Information?" -datatype text -widget select -options {{Yes t} {No f}}
+
+
+# Create a form of hidden vars
+form create verif_edit_user
+
+element create verif_edit_user user_id -label "User ID" -datatype integer -widget hidden
+element create verif_edit_user type_id -label "Type ID" -datatype integer -widget hidden
+element create verif_edit_user rel_type -label "Relationship Type" -datatype text -widget hidden
+element create verif_edit_user read_private_data_p -label "Can Read Private Data?" -datatype text -widget hidden
+
+set context_bar {{users Users} {Edit}}
+set dotlrn_package_id [dotlrn::get_package_id]
+
+# We verified everything, now we make the change
+if {[form is_valid verif_edit_user]} {
+ ns_log Notice "BENLOG - verif_edit_user is VALID!"
+
+ template::form get_values verif_edit_user user_id type_id rel_type read_private_data_p
+
+ set rel_id [db_string select_rel_id "select rel_id from dotlrn_users where user_id=:user_id"]
+
+ db_transaction {
+ # remove the user
+ dotlrn::user_remove $user_id
+
+ # add the user
+ dotlrn::user_add -rel_type $rel_type -user_id $user_id -type_id $type_id
+
+ # Update permissions
+ acs_privacy::set_user_read_private_data -user_id $user_id -object_id [dotlrn::get_package_id] -value $read_private_data_p
+ }
+
+ ad_returnredirect "users"
+ return
+}
+
+
+if {[form is_valid edit_user]} {
+ ns_log Notice "BENLOG - edit_user is VALID!"
+ template::form get_values edit_user user_id type_id rel_type read_private_data_p
+ ns_log Notice "BENLOG - immediate read_private_data_p is $read_private_data_p"
+
+ # Do something
+ set new_rel_type $rel_type
+ db_1row select_limited_user_info "select first_names,last_name,object_type as old_rel_type from dotlrn_users, acs_objects where dotlrn_users.user_id= :user_id and dotlrn_users.rel_id= acs_objects.object_id"
+
+ set old_rel_type [db_string select_rel_type "select 'dotlrn_full_user_rel' from dual where exists (select 1 from dotlrn_full_users where user_id=:user_id)" -default "dotlrn_user_rel"]
+
+ if {$new_rel_type == $old_rel_type} {
+ ns_log Notice "BENLOG - new_type is the same!"
+
+ # Simply update things
+
+ db_transaction {
+ # Update straight user info
+ db_dml update_user {}
+
+ # Update permissions
+ ns_log Notice "BENLOG - read_private_data set to $read_private_data_p"
+ acs_privacy::set_user_read_private_data -user_id $user_id -object_id [dotlrn::get_package_id] -value $read_private_data_p
+ }
+ } else {
+ ns_log Notice "BENLOG - new_type is different!"
+ # Warn about the change
+
+ element set_properties verif_edit_user user_id -value $user_id
+ element set_properties verif_edit_user type_id -value $type_id
+ element set_properties verif_edit_user rel_type -value $rel_type
+ element set_properties verif_edit_user read_private_data_p -value $read_private_data_p
+
+ ad_return_template "user-edit-verify"
+ return
+ }
+
+ # redirect
+ ad_returnredirect "users"
+ return
+}
+
+db_1row select_user_info {}
+
+# set some values
+element set_properties edit_user type_id -value $type_id
+
+if {$limited_access_p == "t"} {
+ element set_properties edit_user rel_type -value dotlrn_user_rel
+} else {
+ element set_properties edit_user rel_type -value dotlrn_full_user_rel
+}
+
+element set_properties edit_user read_private_data_p -value $read_private_data_p
+
+ad_return_template
+
Index: openacs-4/packages/dotlrn/www/admin/user-edit.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/Attic/user-edit.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn/www/admin/user-edit.xql 10 Dec 2001 23:58:31 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+update dotlrn_user_rels set
+type_id= :type_id
+where rel_id = (select rel_id from dotlrn_users where user_id= :user_id)
+
+
+
+
Index: openacs-4/packages/dotlrn/www/admin/user-new-2.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/user-new-2.adp,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/dotlrn/www/admin/user-new-2.adp 1 Dec 2001 23:16:27 -0000 1.3
+++ openacs-4/packages/dotlrn/www/admin/user-new-2.adp 10 Dec 2001 23:58:31 -0000 1.4
@@ -1,4 +1,4 @@
-
+
dotLRN Admin: Add a User
You've chosen to add @first_names@ @last_name@.
Index: openacs-4/packages/dotlrn/www/admin/user-new-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/user-new-2.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/dotlrn/www/admin/user-new-2.tcl 1 Dec 2001 23:16:27 -0000 1.4
+++ openacs-4/packages/dotlrn/www/admin/user-new-2.tcl 10 Dec 2001 23:58:31 -0000 1.5
@@ -19,12 +19,19 @@
element create add_user rel_type \
-label "Access" -datatype text -widget select -options {{{Limited Access} dotlrn_user_rel} {{Full Access} dotlrn_full_user_rel}}
+element create add_user read_private_data_p \
+ -label "Can Access Private Information?" -datatype text -widget select -options {{Yes t} {No f}}
+
if {[form is_valid add_user]} {
- template::form get_values add_user user_id type_id rel_type
+ template::form get_values add_user user_id type_id rel_type read_private_data_p
- # add the user
- dotlrn::user_add -rel_type $rel_type -user_id $user_id -type_id $type_id
+ db_transaction {
+ # add the user
+ dotlrn::user_add -rel_type $rel_type -user_id $user_id -type_id $type_id
+ acs_privacy::set_user_read_private_data -user_id $user_id -object_id [dotlrn::get_package_id] -value $read_private_data_p
+ }
+
# redirect
ad_returnredirect "users"
return
Index: openacs-4/packages/dotlrn/www/admin/users-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/Attic/users-oracle.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn/www/admin/users-oracle.xql 10 Dec 2001 23:58:31 -0000 1.1
@@ -0,0 +1,12 @@
+
+
+
+oracle8.1.6
+
+
+
+select user_id, first_names, last_name, email, type, case when dotlrn_full_user_rels.rel_id is NULL then 't' else 'f' end as limited_access_p, acs_permission.permission_p(:dotlrn_package_id, user_id, 'read_private_data') as read_private_data_p from dotlrn_users, dotlrn_full_user_rels where dotlrn_users.rel_id= dotlrn_full_user_rels.rel_id(+) order by last_name
+
+
+
+
Index: openacs-4/packages/dotlrn/www/admin/users.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/users.adp,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/dotlrn/www/admin/users.adp 1 Dec 2001 23:16:27 -0000 1.4
+++ openacs-4/packages/dotlrn/www/admin/users.adp 10 Dec 2001 23:58:31 -0000 1.5
@@ -3,12 +3,40 @@
@context_bar@
dotLRN users
-
+
+
+
+
+
+
+User |
+Type |
+Access |
+Read Private Data? |
+
+
+<% set i 0 %>
-- @users.last_name@, @users.first_names@ (@users.email@) - @users.type@
+
+<%
+if {$i == 0} {set bgcolor white} else {set bgcolor #cccccc}
+set i [expr 1 - $i]
+%>
+
+
+@users.last_name@, @users.first_names@ (@users.email@) |
+@users.type@ |
+LimitedFull |
+YESNO |
+
-
+
+ |
+
+
+
+
Index: openacs-4/packages/dotlrn/www/admin/users.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/users.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/dotlrn/www/admin/users.tcl 29 Nov 2001 06:05:37 -0000 1.2
+++ openacs-4/packages/dotlrn/www/admin/users.tcl 10 Dec 2001 23:58:31 -0000 1.3
@@ -8,6 +8,8 @@
} {
}
+set dotlrn_package_id [dotlrn::get_package_id]
+
# Currently, just present a list of dotLRN users
db_multirow users select_dotlrn_users {}
Index: openacs-4/packages/dotlrn/www/admin/users.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/users.xql,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/dotlrn/www/admin/users.xql 1 Dec 2001 23:16:27 -0000 1.3
+++ openacs-4/packages/dotlrn/www/admin/users.xql 10 Dec 2001 23:58:31 -0000 1.4
@@ -4,7 +4,7 @@
-select first_names, last_name, email, type from dotlrn_users order by last_name
+select first_names, last_name, email, type, case when theme_id is NULL then 1 else 0 end as limited_access_p, acs_permission__permission_p(:dotlrn_package_id, user_id, 'read_private_data') as read_private_data_p from dotlrn_users left join dotlrn_full_user_rels on dotlrn_users.rel_id= dotlrn_full_user_rels.rel_id order by last_name