Index: openacs-4/packages/dotfolio/catalog/dotfolio.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotfolio/catalog/dotfolio.en_US.ISO-8859-1.xml,v diff -u -r1.5 -r1.6 --- openacs-4/packages/dotfolio/catalog/dotfolio.en_US.ISO-8859-1.xml 19 May 2005 15:19:32 -0000 1.5 +++ openacs-4/packages/dotfolio/catalog/dotfolio.en_US.ISO-8859-1.xml 27 May 2005 05:01:19 -0000 1.6 @@ -16,9 +16,13 @@ No groups have been created. Group Members (Admin) Members of group: %group_name% + Creating dotFOLIO site for Non-members that can be added to group: %group_name% Nuke You have been added as a user to %system_name% at %system_url% + You have been added as a user to %system_name% at %system_url%. + Login: %user_email% + Password: %user_password% Enter a valid username. The username will be used to create the dotfolio space. Successfully created a dotfolio space for %username% Error creating a dotfolio space for %username% @@ -38,6 +42,9 @@ Edit dotFOLIO properties for this user. Email + Return to + Some of the emails failed. Those users had random passwords generated for them, however. The best way to proceed is to have these users log in and ask them to click on 'I have forgotten my password'. + <p>Database error while trying to create the last user in the list above!<br> The transaction has been aborted, no users have been entered, and no e-mail notifications have been sent.<p> Screen name Registration date Last Visit @@ -49,6 +56,7 @@ Message Users User ID + User Management General Information Administrative Actions Update this user's password @@ -64,13 +72,31 @@ %change_password_url% Error sending email to %email% from password-update-2.tcl + emailing this user failed! Error sending email There was an error sending email to %email%. Update + Creating user Create A New User Search Users Bulk Upload + Bulk uploading in progress. + Upload + User %user_username% created.... + User %user_username% already exists... storing user_id + <p>CSV file must include at least the first_names, last_name, email, username, and type fields. The password field is optional.<p> + Example File + Here you can create several users at once using a correctly formatted CSV (comma-separated values) file. You can create a spreadsheet and save it as a CSV file to import here. + Be sure to use valid email addresses since the process will send the new user's password to the given email address. No Users + Fields + Required + Upload Formatted CSV File + Optional field that defaults to the following value: random value + Field must have one of the following values: + CSV File Format + First Line + The first line of the file must have the following header line: Adviser Guest Owner Index: openacs-4/packages/dotfolio/tcl/dotfolio-users-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotfolio/tcl/dotfolio-users-procs-postgresql.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/dotfolio/tcl/dotfolio-users-procs-postgresql.xql 26 May 2005 03:06:34 -0000 1.4 +++ openacs-4/packages/dotfolio/tcl/dotfolio-users-procs-postgresql.xql 27 May 2005 05:01:20 -0000 1.5 @@ -47,4 +47,10 @@ + + + SELECT user_id FROM dotfolio_users WHERE username = :username + + + Index: openacs-4/packages/dotfolio/tcl/dotfolio-users-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotfolio/tcl/dotfolio-users-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotfolio/tcl/dotfolio-users-procs.tcl 19 May 2005 15:19:32 -0000 1.3 +++ openacs-4/packages/dotfolio/tcl/dotfolio-users-procs.tcl 27 May 2005 05:01:20 -0000 1.4 @@ -145,4 +145,17 @@ return [db_string dotfolio_url {} -default ""] } + ad_proc get_user_id_from_username { + -username + } { + Returns the user_id for the user with the specified username. + Otherwise an empty string is returned. + + @param username The username for a user. + @return Returns the user_id for the user that matches the given + username. + } { + return [db_string select_user_id {} -default ""] + } + } Index: openacs-4/packages/dotfolio/www/admin/users-bulk-upload-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotfolio/www/admin/users-bulk-upload-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotfolio/www/admin/users-bulk-upload-2.tcl 27 May 2005 05:01:20 -0000 1.1 @@ -0,0 +1,146 @@ +# +# Copyright (C) 2005 Nick Carroll +# +# This file is part of dotFOLIO. +# +# dotFOLIO 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. +# +# dotFOLIO 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. +# + +ad_page_contract { + Process the upload + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2005-05-27 + @version $Id: users-bulk-upload-2.tcl,v 1.1 2005/05/27 05:01:20 ncarroll Exp $ +} + +# Pages in this directory are only runnable by dotfolio-wide admins. +dotfolio::require_admin + +# get location of the file +set file_location [ns_queryget users_csv_file.tmpfile] + +# Prepare stuff +set headers {first_names last_name email username} + +set admin_user_id [ad_conn user_id] +set admin_email [db_string select_admin_email { + select email + from parties + where party_id = :admin_user_id +}] + +doc_body_append "[_ dotfolio.bulk_uploading]

" + +set list_of_user_ids [list] +set list_of_addresses_and_passwords [list] + +set fail_p 0 + +# Do the stuff +# We can't do this too generically, so we'll just do the CSV stuff right here +db_transaction { + + oacs_util::csv_foreach -file $file_location -array_name row { + + # First make sure the required data is there + if { ![info exists row(first_names)] || ![info exists row(last_name)] || ![info exists row(email)] || ![info exists row(username)] || ![info exists row(type)] } { + doc_body_append [_ dotfolio.csv_file_must_include] + db_abort_transaction + return + } + + ns_log Debug "Bulk upload: Email = $row(email)" + + # Need to generate a random password if one was not supplied. + if {![info exists row(password)] || [empty_string_p $row(password)]} { + set password [ad_generate_random_string] + } else { + set password $row(password) + } + + # Check if this user already exists based on username. + # Note: Usernames must be unique in dotFOLIO. + set user_id [dotfolio::user::get_user_id_from_username \ + -username $row(username)] + + if {![empty_string_p $user_id]} { + + doc_body_append [_ dotfolio.user_username_already_exists \ + [list user_username $row(username)]] + + lappend list_of_user_ids $user_id + + } else { + + set user_id [db_nextval acs_object_id_seq] + + ns_log Debug "Bulk upload: user_id = $user_id" + + auth::create_user \ + -user_id $user_id \ + -username $row(username) \ + -email $row(email) \ + -first_names $row(first_names) \ + -last_name $row(last_name) \ + -password $password + + lappend list_of_user_ids $user_id + + doc_body_append "[_ dotfolio.creating_user] $row(username)...." + + # Now we make them a dotFOLIO user + dotfolio::user_add -user_id $user_id -id $row(username) -type $row(type) + + # If user is an owner, then create a dotfolio site using their + # username. + if {$row(type) == "owner"} { + doc_body_append "[_ dotfolio.creating_dotfolio_site] $row(username)...." + dotfolio::create_dotfolio_for_user -username $row(username) + } + + doc_body_append [_ dotfolio.user_username_created \ + [list user_username $row(username)]] + + set msg_subst_list [list system_name [ad_system_name] \ + system_url [ad_parameter -package_id [ad_acs_kernel_id] SystemURL] \ + user_email $row(email) \ + user_password $password] + set message [_ dotfolio.user_add_confirm_email_body \ + $msg_subst_list] + + set subject [_ dotfolio.user_add_confirm_email_subject \ + $msg_subst_list] + + # Send note to new user + if [catch {ns_sendmail "$row(email)" "$admin_email" "$subject" "$message"} errmsg] { + doc_body_append "[_ dotfolio.emailing_this_user_failed]" + set fail_p 1 + } else { + lappend list_of_addresses_and_passwords $row(email) $password + } + + } + + doc_body_append "
" + + } +} on_error { + ns_log Error "The database choked while trying to create the last user in the list above! The transaction has been aborted, no users have been entered, and no e-mail notifications have been sent." + doc_body_append [_ dotfolio.database_choked] + ad_script_abort +} + +if {$fail_p} { + doc_body_append "

[_ dotfolio.some_of_the_emails_failed]

" +} + +doc_body_append "

[_ dotfolio.return_to] [_ dotfolio.user_management]." Index: openacs-4/packages/dotfolio/www/admin/users-bulk-upload.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotfolio/www/admin/users-bulk-upload.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotfolio/www/admin/users-bulk-upload.adp 27 May 2005 05:01:20 -0000 1.1 @@ -0,0 +1,101 @@ +<% + +# +# Copyright (C) 2005 Nick Carroll +# +# This file is part of dotFOLIO. +# +# dotFOLIO 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. +# +# dotFOLIO 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. +# + +%> + + + + +#dotfolio.bulk_upload# +@context_bar@ + +#dotfolio.create_several_users_at_once# + +

+ +#dotfolio.use_valid_email_address# + +

+ +

#dotfolio.csv_file_format#
+ +

+ + #dotfolio.first_line# + +

+ #dotfolio.first_line_of_file_must_be# + +

+ first_names,last_name,email,username,password,type +
+

+ +

+ +

+ + #dotfolio.fields# + +

+ +

+ +

+ + #dotfolio.example_file# + +

+    first_names,last_name,email,username,password,type
+    Joe,Student,joe@_somewhere_.net,joestue,4jfe3,student
+    Albert,Einstein,al@_school_.edu,al,,adviser
+    Systems,Hacker,syshacker@_company_.com,syshackr,,guest
+  
+ +

+ +

+ +

#dotfolio.upload_formatted_csv#
+ +

+ +

+ +
+
+ +
+

+

\ No newline at end of file Index: openacs-4/packages/dotfolio/www/admin/users-bulk-upload.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotfolio/www/admin/users-bulk-upload.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotfolio/www/admin/users-bulk-upload.tcl 27 May 2005 05:01:20 -0000 1.1 @@ -0,0 +1,33 @@ +# +# Copyright (C) 2005 Nick Carroll +# +# This file is part of dotFOLIO. +# +# dotFOLIO 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. +# +# dotFOLIO 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. +# + +ad_page_contract { + + Allows for bulk upload of users from a CSV file. + + @author Nick Carroll (nick.c@rroll.net) + @creation-date 2005-01-02 + @version $Id: users-bulk-upload.tcl,v 1.1 2005/05/27 05:01:20 ncarroll Exp $ + +} + + +#Pages in this directory are only runnable by dotfolio-wide admins. +dotfolio::require_admin + +set context_bar [list [list users [_ dotfolio.users]] [_ dotfolio.bulk_upload]] + +ad_return_template Index: openacs-4/packages/dotfolio/www/admin/users.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotfolio/www/admin/users.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotfolio/www/admin/users.tcl 5 May 2005 08:51:32 -0000 1.1 +++ openacs-4/packages/dotfolio/www/admin/users.tcl 27 May 2005 05:01:20 -0000 1.2 @@ -1,5 +1,5 @@ # -# Copyright (C) 2001, 2002 WEG +# Copyright (C) 2005 WEG # # This file is part of dotFOLIO. #