Commit b1436c72 authored by Frank Bergmann's avatar Frank Bergmann

- joined v3.1.4 with head

parent 51260adc
......@@ -2,19 +2,22 @@
<!-- Generated by the OpenACS Package Manager -->
<package key="intranet-simple-survey" url="http://openacs.org/repository/apm/packages/intranet-simple-survey" type="apm_application">
<package-name>]oroject-open[ Simple Survey</package-name>
<pretty-plural>]oroject-open[ Simple Surveys</pretty-plural>
<package-name>]project-open[ Simple Survey</package-name>
<pretty-plural>]project-open[ Simple Surveys</pretty-plural>
<initial-install-p>f</initial-install-p>
<singleton-p>t</singleton-p>
<auto-mount>intranet-simple-survey</auto-mount>
<version name="3.1.0.0.0" url="http://openacs.org/repository/download/apm/intranet-simple-survey-3.1.0.0.0.apm">
<version name="3.1.4.0.0" url="http://projop.dnsalias.com/download/apm/intranet-simple-survey-3.1.4.0.0.apm">
<owner url="mailto:frank.bergmann@project-open.com">Frank Bergmann</owner>
<summary>Allows to associated &quot;Simple Surveys&quot; with business objects such as users, projects and companies.</summary>
<vendor url="http://www.project-open.com/">]project-open[</vendor>
<description format="text/plain">&quot;Simple Surveys&quot; are able to capture semi-structured information such as project reports, provider evaluations, ... This module allows to associate recurring surveys for objects and to track their completion</description>
<!-- No dependency information -->
<provides url="intranet-simple-survey" version="3.0.0"/>
<requires url="intranet-core" version="3.0.0"/>
<requires url="simple-survey" version="0.2"/>
<callbacks>
</callbacks>
......
-- /packages/intranet-simple-survey/sql/postgres/intranet-simple-survey-create.sql
--
-- Copyright (c) 2003-2004 Project/Open
--
-- All rights reserved. Please check
-- http://www.project-open.com/license/ for details.
--
-- @author frank.bergmann@project-open.com
-----------------------------------------------------------
-- Simple Surveys - Object Linking Map
--
-- This map links "Business Object Types" (users, projects and
-- companies) and it's Type (provider, customer, internal, ...)
-- to Simple Surveys.
-- In the future we will also include there information about:
-- - Who whould fill out the survey
-- - When a person should fill out a survey
--
-- The problem with survey is not that much "restriction"
-- (make sure only the right persons fill out a survey)
-- but "enforcemente" (make sure the survey is filled out
-- when necessary, such as a PM report).
--
-- Permissions are being set at the survey level, not at
-- this mapping level.
create table im_survsimp_object_map (
acs_object_type varchar(1000)
constraint im_survsimp_omap_object_type_nn
not null
constraint im_survsimp_omap_object_type_fk
references acs_object_types,
biz_object_type_id integer
constraint im_survsimp_omap_biz_object_type_id_fk
references im_categories,
survey_id integer
constraint im_survsimp_omap_survey_id_nn
not null
constraint im_survsimp_omap_survey_id_fk
references survsimp_surveys,
name varchar(1000),
obligatory_p char(1) default 'f'
constraint im_survsimp_omap_obligatory_p_ck
check(obligatory_p in ('t','f')),
recurrence_tcl varchar(4000),
interviewee_profile_id integer
constraint im_survsimp_omap_interv_id_fk
references groups,
note varchar(4000)
);
create index im_survsimp_object_map_acs_object_type_idx on im_survsimp_object_map (acs_object_type);
create index im_survsimp_object_map_biz_object_type_idx on im_survsimp_object_map (biz_object_type_id);
create index im_survsimp_object_map_survey_idx on im_survsimp_object_map (survey_id);
insert into im_survsimp_object_map (
acs_object_type,
biz_object_type_id,
survey_id,
name,
obligatory_p,
recurrence_tcl,
interviewee_profile_id,
note
) values (
'im_project',
null, -- all project subtypes
(select survey_id from survsimp_surveys where short_name = 'pm_weekly'),
'Weekly Project Report',
't',
'', -- Recurrence
467, -- Project Managers
'Please deliver weekly until Friday 11am'
);
---------------------------------------------------------
-- Change the "survsimp_take_survey" from being
-- a child of the "read privilege" to a "write".
-- This is necessary, because the read privilege
-- is required for a user in order to be able to
-- access any page of the simple-survey package.
--
-- However, we want to set permissions on a
-- survey-by-survey level. The "write" privilege
-- is managable by the standard ]po[ security
-- maintenance screens.
select acs_privilege__remove_child('read','survsimp_take_survey');
select acs_privilege__add_child('write','survsimp_take_survey');
---------------------------------------------------------
-- delete potentially existing menus and plugins if this
-- file is sourced multiple times during development...
select im_component_plugin__del_module('intranet-simple-survey');
select im_menu__del_module('intranet-simple-survey');
---------------------------------------------------------
-- Register components:
-- - at project pages
-- - An admin menu at the ]po[ admin page ('/intranet/admin/index')
--
create or replace function inline_0 ()
returns integer as '
declare
v_plugin integer;
begin
v_plugin := im_component_plugin__new (
null, -- plugin_id
''acs_object'', -- object_type
now(), -- creation_date
null, -- creation_user
null, -- creation_ip
null, -- context_id
''Project Survey Component'', -- plugin_name
''intranet-simple-survey'', -- package_name
''right'', -- location
''/intranet/projects/view'', -- page_url
null, -- view_name
50, -- sort_order
''im_survsimp_component $project_id'' -- component_tcl
);
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
create or replace function inline_0 ()
returns integer as '
declare
v_plugin integer;
begin
v_plugin := im_component_plugin__new (
null, -- plugin_id
''acs_object'', -- object_type
now(), -- creation_date
null, -- creation_user
null, -- creation_ip
null, -- context_id
''Company Survey Component'', -- plugin_name
''intranet-simple-survey'', -- package_name
''right'', -- location
''/intranet/companies/view'', -- page_url
null, -- view_name
20, -- sort_order
''im_survsimp_component $company_id'' -- component_tcl
);
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
-------------------------------------------------------------
-- Menus
--
-- prompt *** intranet-costs: Create Finance Menu
-- Setup the "Finance" main menu entry
--
create or replace function inline_0 ()
returns integer as '
declare
-- Menu IDs
v_menu integer;
v_admin_menu integer;
-- Groups
v_employees integer;
v_accounting integer;
v_senman integer;
v_customers integer;
v_freelancers integer;
v_proman integer;
v_admins integer;
begin
select group_id into v_admins from groups where group_name = ''P/O Admins'';
select group_id into v_senman from groups where group_name = ''Senior Managers'';
select group_id into v_accounting from groups where group_name = ''Accounting'';
select group_id into v_customers from groups where group_name = ''Customers'';
select group_id into v_freelancers from groups where group_name = ''Freelancers'';
select menu_id
into v_admin_menu
from im_menus
where label=''admin'';
v_menu := im_menu__new (
null, -- menu_id
''acs_object'', -- object_type
now(), -- creation_date
null, -- creation_user
null, -- creation_ip
null, -- context_id
''intranet-simple-survey'', -- package_name
''admin_survsimp'', -- label
''Simple Surveys'', -- name
''/intranet-simple-survey/admin/index'', -- url
83, -- sort_order
v_admin_menu, -- parent_menu_id
null -- visible_tcl
);
PERFORM acs_permission__grant_permission(v_menu, v_admins, ''read'');
PERFORM acs_permission__grant_permission(v_menu, v_senman, ''read'');
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
-- /packages/intranet-simple-survey/sql/postgres/intranet-simple-survey-drop.sql
--
-- Copyright (c) 2003-2004 Project/Open
--
-- All rights reserved. Please check
-- http://www.project-open.com/license/ for details.
--
-- @author frank.bergmann@project-open.com
-- Sets up an interface to show Security Server messages
---------------------------------------------------------
-- delete menus and plugins
select im_component_plugin__del_module('intranet-simple-survey');
select im_menu__del_module('intranet-simple-survey');
# /tcl/intranet-simple-survey-procs.tcl
#
# Copyright (C) 2003-2006 Project/Open
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_library {
Associate Simple Surveys with ]po[ business objects
and allow to manage their relationship and recurrence.
@author frank.bergmann@project-open.com
@creation-date January 3rd, 2006
}
# -----------------------------------------------------------
# Standard procedures
# -----------------------------------------------------------
ad_proc -public im_package_survsimp_id { } {
} {
return [util_memoize "im_package_survsimp_id_helper"]
}
ad_proc -private im_package_survsimp_id_helper {} {
return [db_string im_package_core_id {
select package_id from apm_packages
where package_key = 'intranet-simple-survey'
} -default 0]
}
# -----------------------------------------------------------
# Standard procedures
# -----------------------------------------------------------
ad_proc im_survsimp_component { object_id } {
Shows al associated simple surveys for a given project or company
} {
set bgcolor(0) "class=roweven"
set bgcolor(1) "class=rowodd"
set survey_url "/simple-survey/one"
set current_user_id [ad_get_user_id]
# Get information about object type
db_1row object_type_info "
select aot.*,
aot.pretty_name as aot_pretty_name,
im_biz_object__type(:object_id) as object_type_id
from acs_object_types aot
where object_type = (
select object_type
from acs_objects
where object_id = :object_id
)
"
set survsimp_sql "
select
som.*,
som.name as som_name,
som.note as som_note,
ss.*
from
im_survsimp_object_map som,
survsimp_surveys ss
where
som.survey_id = ss.survey_id
and som.acs_object_type = :object_type
and (
som.biz_object_type_id is null
OR som.biz_object_type_id = :object_type_id
)
and im_object_permission_p(ss.survey_id, :current_user_id, 'survsimp_take_survey') = 't'
"
set simple_surveys_l10n [lang::message::lookup "" intranet-simple-survey.${aot_pretty_name}_Surveys "$aot_pretty_name Surveys"]
set survsimp_html ""
set ctr 0
db_foreach survsimp_map $survsimp_sql {
set som_gif ""
if {"" != $som_note} {set som_gif [im_gif help $som_note]}
append survsimp_html "
<tr $bgcolor([expr $ctr % 2])>
<td><a href=\"$survey_url?survey_id=$survey_id\">$short_name</a></td>
<td>$som_name $som_gif</td>
</tr>
"
incr ctr
}
if {0 == $ctr} {
set survsimp_html "
<tr $bgcolor([expr $ctr % 2])>
<td colspan=2>[lang::message::lookup "" intranet-simple-survey.There_are_no_surveys_for_this_object "There are no surveys available for this object"]</td>
</tr>
"
}
set survsimp_html "
<table>
<tr class=rowtitle>
<td>Survey</td>
<td>Comment</td>
</tr>
$survsimp_html
</table>
"
return [im_table_with_title $simple_surveys_l10n $survsimp_html]
}
<master>
<property name="context">@context_bar@</property>
<property name="title">@page_title@</property>
<property name="admin_navbar_label">admin_dynfield</property>
<h3>Global Survey Permissions</h3>
<ul>
<li><a href="/intranet/admin/permissions/one?object_id=@survsimp_package_id@">Modify global survey permissions</a>
</ul>
<h3>Detailed Survey Permissions</h3>
@table;noquote@
# /packages/intranet-simple-survey/www/admin/index.tcl
#
#
# Copyright (C) 2003-2006 Project/Open
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
ad_page_contract {
Show the permissions for all menus in the system
@author frank.bergmann@project-open.com
} {
{ return_url "" }
}
# ------------------------------------------------------
# Defaults & Security
# ------------------------------------------------------
set user_id [ad_maybe_redirect_for_registration]
set user_is_admin_p [im_is_user_site_wide_or_intranet_admin $user_id]
if {!$user_is_admin_p} {
ad_return_complaint 1 "You have insufficient privileges to use this page"
return
}
if {"" == $return_url} { set return_url [ad_conn url] }
set page_title "Simple Survey Permissions"
set context_bar [im_context_bar [list /intranet-simple-survey/ "Simple Surveys"] $page_title]
set survsimp_url "/intranet-simple-survey/admin/new"
set toggle_url "/intranet/admin/toggle"
set group_url "/admin/groups/one"
set bgcolor(0) " class=rowodd"
set bgcolor(1) " class=roweven"
set survsimp_package_id [db_string sursimp_package "
select package_id
from apm_packages
where package_key = 'simple-survey'
"]
# ------------------------------------------------------
# Get the list of all dynfields
# and generate the dynamic part of the SQL
# ------------------------------------------------------
set table_header "
<tr>
<td class=rowtitle>Object Type</td>
<td class=rowtitle>Survey</td>
\n"
set group_list_sql {
select DISTINCT
g.group_name,
g.group_id,
p.profile_gif
from
acs_objects o,
groups g,
im_profiles p
where
g.group_id = o.object_id
and g.group_id = p.profile_id
and o.object_type = 'im_profile'
}
set main_sql_select ""
set num_groups 0
set group_ids [list]
set group_names [list]
db_foreach group_list $group_list_sql {
lappend group_ids $group_id
lappend group_names $group_name
append main_sql_select "\tim_object_permission_p(ss.survey_id, $group_id, 'read') as p${group_id}_read_p,\n"
append table_header "
<td class=rowtitle><A href=$group_url?group_id=$group_id>
[im_gif $profile_gif $group_name]
</A></td>\n"
incr num_groups
}
append table_header "
<td class=rowtitle>[im_gif del "Delete Simple Survey"]</td>
</tr>
"
# ------------------------------------------------------
# Main SQL: Extract permissions
# ------------------------------------------------------
set table "
<form action=dynfield-action method=post>
[export_form_vars return_url]
<table>
$table_header\n"
set survsimp_sql "
select
${main_sql_select}
som.*,
som.name as som_name,
som.note as som_note,
ss.*,
aot.*,
aot.pretty_name as object_type_pretty_name
from
im_survsimp_object_map som,
survsimp_surveys ss,
acs_object_types aot
where
som.survey_id = ss.survey_id
and som.acs_object_type = aot.object_type
"
set ctr 0
set old_package_name ""
db_foreach survsimp_query $survsimp_sql {
incr ctr
append table "\n<tr$bgcolor([expr $ctr % 2])>\n"
append table "
<td>
$object_type_pretty_name
</td>
<td>
<A href=$survsimp_url?acs_object_type=$acs_object_type&biz_object_type_id=$biz_object_type_id&survey_id=$survey_id&return_url=$return_url>
$som_name
</A>
</td>
"
foreach horiz_group_id $group_ids {
set object_id $survey_id
set read_p [expr "\$p${horiz_group_id}_read_p"]
set action "add_readable"
set letter "r"
if {$read_p == "t"} {
set read "<A href=$toggle_url?object_id=$survey_id&action=remove_readable&[export_url_vars horiz_group_id return_url]><b>R</b></A>\n"
set action "remove_readable"
set letter "<b>R</b>"
}
set read "<A href=$toggle_url?[export_url_vars horiz_group_id object_id action return_url]>$letter</A>\n"
append table "
<td align=center>
$read
</td>
"
}
append table "
<td>
<input type=checkbox name=survey_id.$survey_id>
</td>
</tr>
"
}
append table "
</table>
</form>
"
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