Commit f400df0b authored by Malte Sussdorff's avatar Malte Sussdorff

Added new files

parent 00ac8462
<master>
<property name=title>Merge account system</property>
<property name="context">@context;noquote@</property>
<h2>Confirm Merge</h2>
<center>
<p/>
<b>
The user @from_first_names@ @from_last_name@ (@from_email@) will be deleted.
<b/>
<p/>
<b style="color:red">
These accounts will be merged and the <u>good and final account</u> will be:
<p/>
<img border=2 width="80" height="80" src="@to_img_src@" alt="Portrait of @to_user_id@" />
<br/>
<span style="font-size:14pt;">@to_first_names@ @to_last_name@ (@to_email@)</span>
<p/>
</b>
<p/>
<b>WARNING:</b> Are you are absolutely sure to merge these accounts?
<p/>
<form action=merge-final method=get>
<table>
<tr>
<td>
<input type=radio name=merge_p value=1 />
</td>
<td>
Yes, I'm sure that I don't need the account @from_email@ anymore!.
</td>
</tr>
<tr>
<td>
<input checked=checked type=radio name=merge_p value=0 >
</td>
<td>
No, I'm not sure.
</td>
</tr>
<tr>
<td colspan=2 align=center>
<input type=hidden name=from_user_id value="@from_user_id@">
<input type=hidden name=to_user_id value="@to_user_id@">
<input type=submit value="OK">
</td>
</tr>
</table>
</form>
</center>
\ No newline at end of file
ad_page_contract {
Merge two users accounts
TODO: Support to merge more than two accounts at the same time
@cvs-id $Id$
} {
to_user_id:integer
from_user_id:integer
merge_action
} -properties {
context:onevalue
} -validate {
if_diff_authority {
set from_authority_id [db_string gettoa "select authority_id from cc_users where user_id = :from_user_id"]
set to_authority_id [db_string getfroma "select authority_id from cc_users where user_id = :to_user_id"]
if { ![string equal $from_authority_id $to_authority_id] } {
ad_complain "Merge only works for users from the same authority"
}
}
}
if { [string equal $merge_action "0"] } {
set tempid $from_user_id
set from_user_id $to_user_id
set to_user_id $tempid
}
set current_user_id [ad_conn user_id]
set context [list [list "./" "Merge"] "Merge"]
# information of from_user_id
db_1row from_get_info { *SQL* }
# information of to_user_id
db_1row to_get_info { *SQL* }
# information of user_id one
if { [db_0or1row to_user_portrait { *SQL* }] } {
set to_img_src "[subsite::get_element -element url]shared/portrait-bits.tcl?user_id=$to_user_id"
} else {
set to_img_src "/resources/acs-admin/not_available.gif"
}
\ No newline at end of file
<?xml version="1.0"?>
<queryset>
<fullquery name="from_get_info">
<querytext>
select
first_names as from_first_names,
last_name as from_last_name,
email as from_email
from cc_users
where user_id = :from_user_id
</querytext>
</fullquery>
<fullquery name="to_get_info">
<querytext>
select
first_names as to_first_names,
last_name as to_last_name,
email as to_email
from cc_users
where user_id = :to_user_id
</querytext>
</fullquery>
<fullquery name="to_user_portrait">
<querytext>
select c.item_id
from acs_rels a, cr_items c
where a.object_id_two = c.item_id
and a.object_id_one = :to_user_id
and a.rel_type = 'user_portrait_rel'
</querytext>
</fullquery>
</queryset>
<master>
<property name=title>Merging ... </property>
<property name="context">@context;noquote@</property>
<h2>Merging ...</h2>
<if @merge_p@ ne 0>
<p/>
@results;noquote@
<p/>
@msg@
</if>
ad_page_contract {
Merge two users accounts
TODO: Support to merge more than two accounts at the same time
@cvs-id $Id$
} {
to_user_id:integer
from_user_id:integer
merge_p
} -properties {
context:onevalue
} -validate {
if_diff_authority {
set from_authority_id [db_string gettoa "select authority_id from cc_users where user_id = :from_user_id"]
set to_authority_id [db_string getfroma "select authority_id from cc_users where user_id = :to_user_id"]
if { ![string equal $from_authority_id $to_authority_id] } {
ad_complain "Merge only works for users of the same authority"
}
}
if_the_logged_in_user_is_crazy {
# Just for security reasons...
set current_user_id [ad_conn user_id]
if { [string equal $current_user_id $to_user_id] || [string equal $current_user_id $from_user_id] } {
ad_complain "You can't merge yourself"
}
}
}
set context [list [list "./" "Merge"] "Merge"]
if { !$merge_p } {
ad_returnredirect "/acs-admin/users"
} else {
set final_results [callback merge::MergePackageUser -from_user_id $from_user_id -to_user_id $to_user_id]
set results "<ul>"
foreach item $final_results {
append results "<li>[lindex $item 0]<ul>"
for { set idx 1 } { $idx < [llength $item] } {incr idx} {
append results "<li>[lindex $item $idx] </li>"
}
append results "</ul></li>"
}
append results "</ul>"
merge::MergeUserInfo -from_user_id $from_user_id -to_user_id $to_user_id
set impl_id [auth::authority::get_element -authority_id $to_authority_id -element "auth_impl_id"]
set parameters [list $from_user_id $to_user_id $to_authority_id]
set user_res [acs_sc::invoke \
-error \
-contract "auth_authentication" \
-impl_id $impl_id \
-operation MergeUser \
-call_args $parameters]
# TODO: Add to the SC implementations of the SC
# an output to improve the msg's of the the final
# status of auth_authentication merge.
# It could be a list as we did with callbacks implementations.
# foreach item $user_res {
# append results "<li>[lindex $item 0]<ul>"
# for { set idx 1 } { $idx < [llength $item] } {incr idx} {
# append results "<li>[lindex $item $idx]</li>"
# }
# append results "</ul></li></ul>"
# }
# append results "</ul>"
set msg "Merge is done"
ns_log Notice $msg
}
<?xml version="1.0"?>
<queryset>
<rdbms><type>oracle</type><version>8.1.6</version></rdbms>
<fullquery name="one_user_contributions">
<querytext>
select
a.object_id,
at.pretty_name,
at.pretty_plural,
to_char(a.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date,
acs_object.name(a.object_id) as object_name
from acs_objects a, acs_object_types at
where a.object_type = at.object_type
and a.creation_user = :user_id
order by pretty_name,
creation_date desc,
object_name
</querytext>
</fullquery>
<fullquery name="two_user_contributions">
<querytext>
select
a.object_id,
at.pretty_name,
at.pretty_plural,
to_char(a.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date,
acs_object.name(a.object_id) as object_name
from acs_objects a, acs_object_types at
where a.object_type = at.object_type
and a.creation_user = :user_id_from_search
order by pretty_name,
creation_date desc,
object_name
</querytext>
</fullquery>
</queryset>
\ No newline at end of file
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.4</version></rdbms>
<fullquery name="one_user_contributions">
<querytext>
select
a.object_id,
at.pretty_name,
at.pretty_plural,
to_char(a.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date,
acs_object__name(a.object_id) as object_name
from acs_objects a, acs_object_types at
where a.object_type = at.object_type
and a.creation_user = :user_id
order by pretty_name,
creation_date desc,
object_name
</querytext>
</fullquery>
<fullquery name="two_user_contributions">
<querytext>
select
a.object_id,
at.pretty_name,
at.pretty_plural,
to_char(a.creation_date, 'YYYY-MM-DD HH24:MI:SS') as creation_date,
acs_object__name(a.object_id) as object_name
from acs_objects a, acs_object_types at
where a.object_type = at.object_type
and a.creation_user = :user_id_from_search
order by pretty_name,
creation_date desc,
object_name
</querytext>
</fullquery>
</queryset>
\ No newline at end of file
<master>
<property name="title">Merge account system</property>
<property name="context">@context;noquote@</property>
<property name="header_stuff">
<link rel="stylesheet" type="text/css" href="/resources/acs-admin/um-more-info.css" media="all">
</property>
<h2>User Account Merge</h2>
This is the user acccount merge wizard. You selected these accounts to merge:
<p/>
<table align="center">
<tr>
<td valign="top">
<table style="background-color:#006666;border-width:2px;">
<tr>
<td>
<table style="background-color:#D1FFFF">
<tr>
<td>
<center>
<b>ACCOUNT ONE</b>
<p/>
<img border="2" width="80" height="80" src="@one_img_src@" alt="Portrait of @user_id@" />
<h3>General Information of user one (<b>@one_email@</b>):</h3>
</center>
<ul>
<li>
Name:
<i>@one_first_names@ @one_last_name@</i>
</li>
<li>
Email:
<b><a href="mailto:@one_email@">@one_email@</a></b>
</li>
<li>
Scren name:
<b>@one_screen_name@</b>
</li>
<li>
Username:
<b>@one_username@</b>
</li>
<li>
User id:
@user_id@
</li>
<li>
URL:
@one_url@
</li>
<li>
Registration date:
@one_creation_date@
</li>
<li>
Registration IP:
@one_creation_ip@
</li>
<li>
Registration user:
@one_creation_user@
</li>
<li>
Last modified date:
@one_last_modified@
</li>
<li>
Modifying IP:
@one_modifying_ip@
</li>
<li>
Modifying user:
@one_modifying_user@
</li>
<li>
Last visit:
@one_last_visit@
</li>
<li>
Member state:
@one_member_state@
</li>
</ul>
<center>
(<a href="javascript:void(d=document);void(el=d.getElementsByTagName('div'));for(i=0;i&lt;el.length;i++){if(el[i].className=='um-more-info'){void(el[i].className='um-more-info-off')}else{if(el[i].className=='um-more-info-off'){void(el[i].className='um-more-info')}}};" class="off" title="Toggle Footer display">more information</a>)
</center>
<div class="um-adp-box-off">
<div class="um-more-info-off">
<multiple name="one_user_contributions">
<h2>@one_user_contributions.pretty_plural@</h2>
<ul>
<group column="pretty_name">
<li>@one_user_contributions.creation_date@: <a href="@one_user_contributions.one_item_object_url@" >@one_user_contributions.object_name@</a></li>
</group>
</ul>
</multiple>
@user_id_one_items_html;noquote@
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top">
<form action="merge-confirm" method="get">
<table>
<tr>
<td>
<center>
<b>Which is the good account?</b>
<p/>
<input type="radio" name="merge_action" value="0" />
<img src="/resources/acs-admin/left.gif" alt="left one" />
</center>
</td>
</tr>
<tr>
<td>
<center>
<input type="radio" name="merge_action" value="1" />
<img src="/resources/acs-admin/right.gif" alt="right one">
</center>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="from_user_id" value="@user_id@" />
<input type="hidden" name="to_user_id" value="@user_id_from_search@" />
<center>
<input type="submit" value="Continue"/>
</center>
</td>
</tr>
</table>
</form>
</td>
<td valign="top">
<table style="background-color:#FFA217">
<tr>
<td>
<table style="background-color:#FFE3B9">
<tr>
<td>
<center>
<b>ACCOUNT TWO</b>
<p/>
<img border="2" width="80" height="80" src="@two_img_src@" alt="Portrait of @user_id_from_search@" />
<h3>General Information of user two (<b>@two_email@</b>):</h3>
</center>
<ul>
<li>
Name:
<i>@two_first_names@ @two_last_name@</i>
</li>
<li>
Email:
<b><a href="mailto:@two_email@">@two_email@</a></b>
</li>
<li>
Scren name:
<b>@two_screen_name@</b>
</li>
<li>
Username:
<b>@two_username@</b>
</li>
<li>
User id:
@user_id_from_search@
</li>
<li>
URL:
@two_url@
</li>
<li>
Registration date:
@two_creation_date@
</li>
<li>
Registration IP:
@two_creation_ip@
</li>
<li>
Registration user:
@two_creation_user@
</li>
<li>
Last modified date:
@two_last_modified@
</li>
<li>
Modifying IP:
@two_modifying_ip@
</li>
<li>
Modifying user:
@two_modifying_user@
</li>
<li>
Last visit:
@two_last_visit@
</li>
<li>
Member state:
@two_member_state@
</li>
</ul>
<center>
(<a href="javascript:void(d=document);void(el=d.getElementsByTagName('div'));for(i=0;i&lt;el.length;i++){if(el[i].className=='um-more-info2'){void(el[i].className='um-more-info-off2')}else{if(el[i].className=='um-more-info-off2'){void(el[i].className='um-more-info2')}}};" class="off" title="Toggle Footer display">more information</a>)
</center>
<div class="um-adp-box-off2">
<div class="um-more-info-off2">
<multiple name="two_user_contributions">
<h2>@two_user_contributions.pretty_plural@</h2>
<ul>
<group column="pretty_name">
<li>@two_user_contributions.creation_date@: <a href="@two_user_contributions.two_item_object_url@"> @two_user_contributions.object_name@ </a></li>
</group>
</ul>
</multiple>
@user_id_two_items_html;noquote@
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
ad_page_contract { #
Merge two users accounts
TODO: Support to merge more than two accounts at the same time
@cvs-id $Id$
} {
user_id
user_id_from_search
} -properties {
context:onevalue
first_names:onevalue
last_name:onevalue
} -validate {
if_the_logged_in_user_is_crazy {
# Just for security reasons...
set current_user_id [ad_conn user_id]
if { [string equal $current_user_id $user_id] || [string equal $current_user_id $user_id_from_search] } {
ad_complain "You can't merge yourself"
}
}
}
set context [list [list "./" "Merge"] "Merge"]
#
# Information of user_id_one
#
if { [db_0or1row one_user_portrait { *SQL* }] } {
set one_img_src "[subsite::get_element -element url]shared/portrait-bits.tcl?user_id=$user_id"
} else {
set one_img_src "/resources/acs-admin/not_available.gif"
}
db_1row one_get_info { *SQL* }
db_multirow -extend {one_item_object_url} one_user_contributions one_user_contributions { *SQL* } {
set one_item_object_url "[site_node::get_url_from_object_id -object_id $object_id]"
}
set user_id_one_items [callback merge::MergeShowUserInfo -user_id $user_id ]
if { ![empty_string_p $user_id_one_items] } {
set user_id_one_items_html "<ul><li><b>Packages User Information </b><ul>"
foreach pkg_list $user_id_one_items {
append user_id_one_items_html "<li><i>[lindex $pkg_list 0]</i><ul>"
set length [llength $pkg_list]
for { set idx 1} { $idx < $length } { incr idx } {
append user_id_one_items_html "<li>[lindex $pkg_list $idx]</li>"
}
append user_id_one_items_html "</ul></li>"
}
append user_id_one_items_html "</ul></li></ul>"
} else {
set user_id_one_items_html ""
}
#
# Information of user_id_two
#
if { [db_0or1row two_user_portrait { *SQL* }] } {
set two_img_src "[subsite::get_element -element url]shared/portrait-bits.tcl?user_id=$user_id_from_search"
} else {
set two_img_src "/resources/acs-admin/not_available.gif"
}
db_1row two_get_info { *SQL* }
db_multirow -extend {two_item_object_url} two_user_contributions two_user_contributions { *SQL* } {
set two_item_object_url "[site_node::get_url_from_object_id -object_id $object_id]"
}
set user_id_two_items [callback merge::MergeShowUserInfo -user_id $user_id_from_search ]
if { ![empty_string_p $user_id_two_items] } {
set user_id_two_items_html "<ul><li><b>Packages User Information </b><ul>"
foreach pkg_list $user_id_two_items {
append user_id_two_items_html "<li><i>[lindex $pkg_list 0]</i><ul>"
set length [llength $pkg_list]
for { set idx 1} { $idx < $length } { incr idx } {
append user_id_two_items_html "<li>[lindex $pkg_list $idx]</li>"
}
append user_id_two_items_html "</ul></li>"
}
append user_id_two_items_html "</ul></li></ul>"
} else {
set user_id_two_items_html ""
}
<?xml version="1.0"?>
<queryset>
<fullquery name="one_user_portrait">
<querytext>
select
c.item_id
from acs_rels a, cr_items c
where a.object_id_two = c.item_id
and a.object_id_one = :user_id
and a.rel_type = 'user_portrait_rel'
</querytext>
</fullquery>
<fullquery name="one_get_info">
<querytext>
select
first_names as one_first_names,
last_name as one_last_name,
creation_user as one_creation_user,
to_char(creation_date,'month DD, yyyy') as one_creation_date,
creation_ip as one_creation_ip,
to_char(last_modified,'month DD, yyyy') as one_last_modified,
email as one_email,
url as one_url,
modifying_user as one_modifying_user,
modifying_ip as one_modifying_ip,
username as one_username,
screen_name as one_screen_name,
to_char(last_visit,'month DD, yyyy') as one_last_visit,
member_state as one_member_state
from cc_users
where user_id = :user_id
</querytext>
</fullquery>
<fullquery name="two_user_portrait">
<querytext>
select
c.item_id
from acs_rels a, cr_items c
where a.object_id_two = c.item_id
and a.object_id_one = :user_id_from_search
and a.rel_type = 'user_portrait_rel'
</querytext>
</fullquery>
<fullquery name="two_get_info">
<querytext>
select
first_names as two_first_names,
last_name as two_last_name,
creation_user as two_creation_user,
to_char(creation_date,'month DD, yyyy') as two_creation_date,
creation_ip as two_creation_ip,
to_char(last_modified,'month DD, yyyy') as two_last_modified,
email as two_email,
url as two_url,
modifying_user as two_modifying_user,
modifying_ip as two_modifying_ip,
username as two_username,
screen_name as two_screen_name,
to_char(last_visit,'month DD, yyyy') as two_last_visit,
member_state as two_member_state
from cc_users
where user_id = :user_id_from_search
</querytext>
</fullquery>
</queryset>
<master>
<property name=title>Add a batch of users</property>
@success_text;noquote@
<hr/>
@exception_text;noquote@
ad_page_contract {
Interface for specifying a list of users to sign up as a batch
@cvs-id $Id$
} -query {
userlist
from
subject
message:allhtml
} -properties {
title:onevalue
success_text:onevalue
exception_text:onevalue
}
# parse the notify_ids arguments
# ...
set exception_text ""
set success_text ""
set title "Adding new users in bulk"
# parse the userlist input a row at a time
# most errors stop the processing of the line but keep going on the
# bigger block
while {[regexp {(.[^\n]+)} $userlist match_fodder row] } {
# remove each row as it's handled
set remove_count [string length $row]
set userlist [string range $userlist [expr $remove_count + 1] end]
set row [split $row ,]
set email [string trim [lindex $row 0]]
set first_names [string trim [lindex $row 1]]
set last_name [string trim [lindex $row 2]]
if {![info exists email] || ![util_email_valid_p $email]} {
append exception_text "<li>Couldn't find a valid email address in ($row).</li>\n"
continue
} else {
set email_count [db_string unused "select count(email)
from parties where email = lower(:email)"]
if {$email_count > 0} {
append exception_text "<li> $email was already in the database.</li>\n"
continue
}
}
if {![info exists first_names] || [empty_string_p $first_names]} {
append exception_text "<li> No first name in ($row)</li>\n"
continue
}
if {![info exists last_name] || [empty_string_p $last_name]} {
append exception_text "<li> No last name in ($row)</li>\n"
continue
}
# We've checked everything.
set password [ad_generate_random_string]
array set auth_status_array [auth::create_user -email $email -first_names $first_names -last_name $last_name -password $password]
set user_id $auth_status_array(user_id)
append success_text "Created user $user_id for ($row)<br\>"
# if anything goes wrong here, stop the whole process
if { !$user_id } {
ad_return_error "Insert Failed" "We were unable to create a user record for ($row)."
ad_script_abort
}
# send email
set key_list [list first_names last_name email password]
set value_list [list $first_names $last_name $email $password]
set sub_message $message
foreach key $key_list value $value_list {
regsub -all "<$key>" $sub_message $value sub_message
}
if {[catch {ns_sendmail "$email" "$from" "$subject" "$sub_message"} errmsg]} {
ad_return_error "Mail Failed" "The system was unable to send email. Please notify the user personally. This problem is probably caused by a misconfiguration of your email system. Here is the error:
<blockquote><pre>
[ad_quotehtml $errmsg]
</pre></blockquote>"
return
}
}
ad_return_template
<master>
<property name=title>Add a batch of users</property>
<property name="context">@context;noquote@</property>
<form method="post" action="user-batch-add-2">
<p>Add these users to @system_name@, one user per line.</p>
<br /><textarea name=userlist rows=15 cols=50>
email, first name, last name
</textarea>
<p>Each user will get this email:
<br />From: <input name="from" value="@admin_email@">
<br />Subject: <input name=subject value="You have been added as a user to @system_name@ at @system_url@" size=50>
<p>Message:
<br /><textarea name="message" rows=10 cols=70 wrap=hard>
Dear &lt;first_names&gt; &lt;last_name&gt;,
You have been added as a user to @system_name@
at @system_url@
Login information:
Email: &lt;email&gt;
Password: &lt;password&gt;
(you may change your password after you log in)
Thank you,
@administration_name@
</textarea>
</p>
<center>
<input type="submit" value="Import List and Send Emails" />
</center>
</form>
</p>
ad_page_contract {
Interface for specifying a list of users to sign up as a batch
@cvs-id $Id$
} -properties {
context:onevalue
system_name:onevalue
system_url:onevalue
administration_name:onevalue
admin_email:onevalue
}
set admin_user_id [ad_conn user_id]
set admin_email [db_string unused "select email from
parties where party_id = :admin_user_id"]
set administration_name [db_string admin_name "select
first_names || ' ' || last_name from persons where person_id = :admin_user_id"]
set context [list [list "./" "Users"] "Notify added user"]
set system_name [ad_system_name]
set export_vars [export_form_vars email first_names last_name user_id]
set system_url [ad_parameter -package_id [ad_acs_kernel_id] SystemURL ""].
ad_return_template
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment