Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-simple-survey
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project-open
intranet-simple-survey
Commits
99497497
Commit
99497497
authored
Jun 04, 2018
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Working on simple survey invitation
parent
eed0ded6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
408 additions
and
0 deletions
+408
-0
invite-members-2.tcl
www/invite-members-2.tcl
+178
-0
invite-members.adp
www/invite-members.adp
+116
-0
invite-members.tcl
www/invite-members.tcl
+114
-0
No files found.
www/invite-members-2.tcl
0 → 100644
View file @
99497497
# /packages/intranet-forum/www/intranet-forum/forum/new-3.tcl
#
# Copyright (C
)
2003 - 2009
]
project-open
[
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract
{
Process invitation emails
@author frank.bergmann@project-open.com
}
{
notifyee_id:multiple,optional
object_id:integer
survey_id:integer
return_url
subject
message:allhtml
{
cancel
""
}
{
process_mail_queue_now_p 1
}
{
throttle_seconds 0
}
}
# ad_return_complaint 1 "notifyee_id=$notifyee_id<br>object_id=$object_id<br>survey_id=$survey_id<br>return_url=$return_url<br>subject=$subject<br>message=$message"
# ------------------------------------------------------------------
# Security, Parameters & Default
# ------------------------------------------------------------------
set
current_user_id
[
auth::require_login
]
set
system_url
[
im_system_url
]
set
object_found_p 0
db_0or1row object_info
"
select 1 as object_found_p,
o.object_type,
acs_object__name(o.object_id) as object_name,
(select min(bou.url) from im_biz_object_urls bou where bou.object_type = o.object_type and url_type = 'view') as object_base_url
from acs_objects o
where object_id = :object_id
"
if
{
!$object_found_p
}
{
ad_return_complaint 1
"Didn't find object #
$object
_id"
ad_script_abort
}
if
{
""
!=
$cancel
}
{
# The user pressed the
"Cancel"
button in the previous form
ad_returnredirect
$return
_url
ad_script_abort
}
${object_type}
_permissions
$current
_user_id
$object
_id view_p read_p write_p admin_p
if
{
!$write_p
}
{
ad_return_complaint 1
"Y don't have write permissions (project manager, object administrator, ...) on object
$object
_id ('
$object
_name')"
ad_script_abort
}
# Determine the sender address
set
sender_email
[
parameter::get -package_id
[
apm_package_id_from_key acs-kernel
]
-parameter
"SystemOwner"
-default
[
ad_system_owner
]]
if
{
"CurrentUser"
eq
[
parameter::get_from_package_key -package_key
"intranet-simple-survey"
-parameter
"SenderMail"
-default
"CurrentUser"
]}
{
set sender_email
[
db_string sender_email
"select email from parties where party_id = :current_user_id"
-default
$sender
_email
]
}
set found_sender_p 0
db_1row user_info
"
select pe.person_id as sender_user_id,
im_name_from_user_id(pe.person_id) as sender_name,
first_names as sender_first_names,
last_name as sender_last_name,
email as sender_email,
1 as found_sender_p
from persons pe,
parties pa
where pe.person_id = pa.party_id and
pe.person_id = :current_user_id
"
if
{
!$found_sender_p
}
{
ad_return_complaint 1
"Didn't find sender with user_id=
$current
_user_id"
ad_script_abort
}
# ---------------------------------------------------------------
# Send out messages
# ---------------------------------------------------------------
set
error_list
[
list
]
foreach
id
$notifyee
_id
{
ns_log Notice
"invite-members-2: Sending out email to user_id=
$id
"
set found_p 0
db_0or1row user_info
"
select pe.person_id as user_id,
im_name_from_user_id(pe.person_id) as name,
first_names,
last_name,
email,
1 as found_p
from persons pe,
parties pa
where pe.person_id = pa.party_id and
pa.party_id = :id
"
if
{
0 eq
$found
_p
}
{
continue
}
ns_log Notice
"invite-members-2: Sending out to email: '
$email
'"
set auto_login
[
im_generate_auto_login -user_id
$user
_id
]
set survey_url
[
export_vars -base
"
$system
_url/simple-survey/take"
{
survey_id
{
related_object_id
$object
_id
}}]
set object_url
"
$system
_url
$object
_base_url
$object
_id"
set survey_url_auto_login
[
export_vars -base
"
$system
_url/intranet/auto-login"
{
user_id
{
url
$survey
_url
}
auto_login
}]
set object_url_auto_login
[
export_vars -base
"
$system
_url/intranet/auto-login"
{
user_id
{
url
$object
_url
}
auto_login
}]
# Replace message %...% variables by user's variables
set substitution_list
[
list
\
name
$name
\
first_names
$first
_names
\
last_name
$last
_name
\
email
$email
\
auto_login
$auto
_login
\
sender_name
$sender
_name
\
sender_first_names
$sender
_first_names
\
sender_last_name
$sender
_last_name
\
sender_email
$sender
_email
\
user_id
$user
_id
\
object_url
$object
_url
\
survey_url
$survey
_url
\
object_url_auto_login
$object
_url_auto_login
\
survey_url_auto_login
$survey
_url_auto_login
\
]
set message_subst
[
lang::message::format
$message
$substitution
_list
]
# Remember the date of the last email
if
{[
im_column_exists persons last_email_sent
]}
{
db_dml update_last_email
"update persons set last_email_sent = now() where person_id = :user_id"
}
ns_log Notice
"invite-members-2: Sending out email to
$email:
subject=
$subject
"
ns_log Notice
"invite-members-2: Sending out email to
$email:
message=
$message
_subst"
if
{[
catch
{
acs_mail_lite::send
\
-send_immediately
\
-to_addr
$email
\
-from_addr
$sender
_email
\
-subject
$subject
\
-body
$message
_subst
# -file_ids
$attachment
_ci_id
}
errmsg
]}
{
ns_log Error
"member-notify: Error sending to
\"
$email
\"
:
$errmsg
"
lappend error_list
"<p>Error sending out mail to:
$email
</p><div><code>
[
ns_quotehtml
$errmsg
]
</code></div>"
}
if
{
$throttle
_seconds > 0
}
{
im_exec sleep
$throttle
_seconds
}
}
# ---------------------------------------------------------------
# Process the mail queue right now
# ---------------------------------------------------------------
if
{
$process
_mail_queue_now_p
}
{
acs_mail_process_queue
}
if
{[
llength
$error
_list
]
> 0
}
{
ad_return_complaint 1
"<b>Errors sending out invitations</b>:<br><ul><li>
[
join
$error
_list
"<li>"
]
</ul>"
ad_script_abort
}
db_release_unused_handles
ad_returnredirect
$return
_url
www/invite-members.adp
0 → 100644
View file @
99497497
<master>
<property name="doc(title)">@page_title;literal@</property>
<property name="context">@context_bar;literal@</property>
<property name="main_navbar_label"></property>
<h1>@page_title@</h1>
<if "" eq @survey_id@>
<!-- ------------------------------------------------------------------- -->
<!-- Just show a table to select the survey -->
<!-- ------------------------------------------------------------------- -->
<form name=alerts method=GET action=invite-members>
<%= [export_vars -form {object_id return_url}] %>
<table class="list">
<tr class="list-header">
<th class="list-narrow" colspan=2><%= [lang::message::lookup "" intranet-simple-survey.Select_Survey "Select Survey"] %></th>
</tr>
<tr class="list-odd">
<td>#intranet-simple-survey.Survey#</td>
<td class="list-narrow">
<%= [im_select -translate_p 0 -ad_form_option_list_style_p 1 survey_id $survey_options $survey_id] %>
</td>
</tr>
<tr class="list-even">
<td> </td>
<td class="list-narrow">
<input type="submit" value="<%= [lang::message::lookup "" intranet-simple-survey.Select_Survey "Select Survey"] %>">
</td>
</tr>
</table>
</form>
</if>
<else>
<!-- ------------------------------------------------------------------- -->
<!-- Allow the user to fine-tune the email and select receipients -->
<!-- ------------------------------------------------------------------- -->
<form name=alerts method=post action=invite-members-2>
<%= [export_vars -form {object_id survey_id return_url}] %>
<table class="list">
<tr class="list-header">
<th class="list-narrow" colspan=2><%= [lang::message::lookup "" intranet-simple-survey.Survey_Invitation "Survey Invitation"] %></th>
</tr>
<tr class="list-even">
<td>#intranet-forum.Subject#</td>
<td class="list-narrow">
<input type=text name=subject value='@subject@' size=60>
</td>
</tr>
<tr class="list-odd">
<td>#intranet-core.Message#</td>
<td class="list-narrow">
<textarea name=message rows=15 cols=80>@message;noquote@</textarea>
</td>
</tr>
</table>
<br>
<table class="list">
<tr class="list-header">
<th class="list-narrow">
<input type="checkbox" name="_dummy" onclick="acs_ListCheckAll('alerts', this.checked)" title="<%= [lang::message::lookup "" intranet-simple-survey.Check_Uncheck_all_rows "Check/Uncheck all rows"] %>" checked>
</th>
<th class="list-narrow"><%= [lang::message::lookup "" intranet-simple-survey.Email "Email"] %></th>
<th class="list-narrow"><%= [lang::message::lookup "" intranet-simple-survey.Name "Name"] %></th>
</tr>
<multiple name=stakeholders>
<if @stakeholders.rownum@ odd>
<tr class="list-odd">
</if> <else>
<tr class="list-even">
</else>
<td class="list-narrow">
<input type="checkbox" name="notifyee_id" value="@stakeholders.user_id@" id="alerts,@user_id@" @stakeholders.checked@>
</td>
<td class="list-narrow">
@stakeholders.email@
</td>
<td class="list-narrow">
<a href="/intranet/users/view?user_id=@stakeholders.user_id@">@stakeholders.name@</a>
</td>
</tr>
</multiple>
<tr>
<td colspan="3" align="right">
<input type="submit" value="<%= [lang::message::lookup "" intranet-simple-survey.Send_Email "Send Email"] %>">
<input type="submit" value="<%= [lang::message::lookup "" intranet-simple-survey.Cancel "Cancel"] %>" name="cancel">
</td>
</tr>
</table>
</form>
</else>
www/invite-members.tcl
0 → 100644
View file @
99497497
# /packages/intranet-simple-survey/www/invite-members.tcl
#
# Copyright (C
)
2003-2009
]
project-open
[
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract
{
Invite project members to take a survey
@author frank.bergmann@project-open.com
}
{
object_id:integer
{
survey_id:integer
""
}
{
return_url
""
}
}
# ------------------------------------------------------------------
# Security, Parameters & Default
# ------------------------------------------------------------------
set
current_user_id
[
auth::require_login
]
set
object_type
[
db_string acs_object_type
"select object_type from acs_objects where object_id = :object_id"
-default
""
]
set
page_title
[
lang::message::lookup
""
intranet-simple-survey.Invite_Members
"Invite Members for Survey"
]
set
context_bar
[
im_context_bar
[
list
/intranet-simple-survey/
$page
_title
]
$page
_title
]
set
locale
[
ad_conn locale
]
# ------------------------------------------------------------------
#
# ------------------------------------------------------------------
set
survey_options
[
im_survsimp_survey_options
]
if
{
1 eq
[
llength
$survey
_options
]}
{
set survey_tuple
[
lindex
$survey
_options 0
]
set survey_id
[
lindex
$survey
_tuple 1
]
}
set
survey_name
[
db_string survey_name
"select short_name from survsimp_surveys where survey_id = :survey_id"
-default
"undefined survey"
]
if
{
""
ne
$survey
_id &&
""
ne
$survey
_name
}
{
append page_title
":
$survey
_name"
}
# ad_return_complaint 1 "$survey_id<br>$survey_name"
# ---------------------------------------------------------------
# Determine message
# ---------------------------------------------------------------
lang::message::cache
set
subject
"
[
lang::message::lookup
""
intranet-simple-survey.Notification_Subject
"Invitation to Survey:"
]
$survey
_name"
set
message_key intranet-simple-survey.Notification_Message
set
message_exists_p
[
lang::message::message_exists_p
$locale
$message
_key
]
if
{
$message
_exists_p
}
{
set message
[
nsv_get lang_message_$locale
$message
_key
]
}
else
{
set message
"Dear %first_names%,
%sender_name% invites you to take the survey:
Survey name: %survey_name%
Please click on this link to take the survey:
%survey_url_auto_login%
The survey is related to: %object_name%
%object_url_auto_login%
Best regards
%sender_name%"
}
# ------------------------------------------------------------------
#
# ------------------------------------------------------------------
set
stakeholder_sql
"
select p.person_id as user_id,
pa.email,
im_name_from_user_id(p.person_id) as name
from acs_rels r,
im_biz_object_members bom,
persons p,
parties pa
where r.rel_id = bom.rel_id and
r.object_id_one = :object_id and
r.object_id_two = p.person_id and
p.person_id = pa.party_id and
p.person_id not in (
select u.user_id
from users u,
acs_rels r,
membership_rels mr
where r.rel_id = mr.rel_id and
r.object_id_two = u.user_id and
r.object_id_one = acs__magic_object_id('registered_users') and
mr.member_state != 'approved'
)
order by name
"
set
num_stakeholders 0
db_multirow -extend
{
checked
}
stakeholders stakeholder_query
$stakeholder
_sql
{
set checked
"checked"
# if {$current_user_id == $owner_id
}
{
set checked
"checked"
}
incr num_stakeholders
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment