A link is considered selected if the current page url starts with the url of the link
- and each HTML parameter in the param_list has the specified value.
+ and each HTML parameter in the param_list has the specified value. If the param_list
+ is empty then the query string of the request must be empty for the link to be
+ considered selected.
+ @param navbar_url The url relative page root of the link
+ @param param_list A list of URL parameters and their values on the format
+ [list [list param_name1 param_value1] [list param_name2 param_value2]]
+
+ @return 1 if the navbar link should be selected and 0 otherwise
+
@author Peter Marklund
} {
# Let's remove any trailing slash and make it optional in our pattern
Index: openacs-4/packages/logger/tcl/variable-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/variable-procs.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/logger/tcl/variable-procs.tcl 1 May 2003 10:00:24 -0000 1.5
+++ openacs-4/packages/logger/tcl/variable-procs.tcl 1 May 2003 14:14:33 -0000 1.6
@@ -18,7 +18,7 @@
} {
Create a new variable to use for logger entries. The
variable can be tied to logger projects through the
- logger::project::add_variable proc.
+ logger::project::map_variable proc.
@param variable_id Any pre-generated id of the variable. Optional.
@param name The name of the new variable. Required.
@@ -44,6 +44,14 @@
set variable_id [db_exec_plsql insert_variable {}]
+ if { $pre_installed_p } {
+ # Registered users should have read privilege on pre-installed variables
+ permission::grant \
+ -party_id [acs_magic_object registered_users] \
+ -object_id $variable_id \
+ -privilege read
+ }
+
return $variable_id
}
Index: openacs-4/packages/logger/tcl/test/logger-test-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/test/logger-test-init.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/logger/tcl/test/logger-test-init.tcl 1 May 2003 10:00:47 -0000 1.6
+++ openacs-4/packages/logger/tcl/test/logger-test-init.tcl 1 May 2003 14:15:28 -0000 1.7
@@ -78,22 +78,22 @@
set hours_var_id [logger::variable::new -name $hours_var(name) \
-unit $hours_var(unit) \
-type $hours_var(type)]
- logger::project::add_variable -project_id $project_id \
+ logger::project::map_variable -project_id $project_id \
-variable_id $hours_var_id
# Create and map the minutes variable
# (variate by pre-generating the variable id this time)
set minutes_var_id [logger::variable::new -name $minutes_var(name) \
-unit $minutes_var(unit) \
-type $minutes_var(type)]
- logger::project::add_variable -project_id $project_id \
+ logger::project::map_variable -project_id $project_id \
-variable_id $minutes_var_id
# Create and map the expense variable (euros)
set expense_var_id [logger::variable::new -name $expense_var(name) \
-unit $expense_var(unit) \
-type $expense_var(type)]
- logger::project::add_variable -project_id $project_id \
+ logger::project::map_variable -project_id $project_id \
-variable_id $expense_var_id
# Assert that variables are retrievable
Index: openacs-4/packages/logger/www/admin/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/index.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/logger/www/admin/index.adp 1 May 2003 07:20:58 -0000 1.2
+++ openacs-4/packages/logger/www/admin/index.adp 1 May 2003 14:16:18 -0000 1.3
@@ -21,7 +21,8 @@
[ delete ]
+ onclick="return confirm('Are you sure you want to delete project @projects.name@?');">delete |
+ permissions ]
|
@projects.name@
@@ -49,13 +50,20 @@
+
+ [ delete |
+ permissions ]
+
+ |
@variables.name@ |
@variables.unit@ |
yesno |
@@ -72,4 +80,9 @@
Add new variable
-
\ No newline at end of file
+
+Package
+
+ Set permissions of this package
+
+
Index: openacs-4/packages/logger/www/admin/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/index.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/logger/www/admin/index.tcl 1 May 2003 07:20:58 -0000 1.2
+++ openacs-4/packages/logger/www/admin/index.tcl 1 May 2003 14:16:18 -0000 1.3
@@ -12,10 +12,34 @@
set home_url [ad_parameter -package_id [ad_acs_kernel_id] HomeURL]
-db_multirow projects select_projects {} {
+set application_url [ad_conn url]
+set permissions_uri "/permissions/one"
+
+db_multirow -extend { permissions_url } projects select_projects {} {
set description [string_truncate -len 50 $description]
+ set permissions_url "${permissions_uri}?[export_vars {{object_id $project_id} application_url}]"
}
-logger::package::variables_multirow
+db_multirow -extend { permissions_url } variables select_variables {
+ select lv.variable_id,
+ lv.name,
+ lv.unit,
+ lv.type,
+ acs_permission.permission_p(lv.variable_id, :user_id, 'admin') as admin_p
+ from logger_variables lv
+ where (exists (select 1
+ from logger_project_var_map lpvm,
+ logger_project_pkg_map lppm
+ where lv.variable_id = lpvm.variable_id
+ and lpvm.project_id = lppm.project_id
+ and lppm.package_id = :package_id
+ )
+ or lv.package_id = :package_id
+ or lv.package_id is null)
+} {
+ set permissions_url "${permissions_uri}?[export_vars {{object_id $variable_id} application_url}]"
+}
+set package_permissions_url "${permissions_uri}?[export_vars {{object_id $package_id} application_url}]"
+
ad_return_template
Index: openacs-4/packages/logger/www/admin/map-variable-to-project-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/map-variable-to-project-2.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/logger/www/admin/map-variable-to-project-2.tcl 22 Apr 2003 09:27:03 -0000 1.1
+++ openacs-4/packages/logger/www/admin/map-variable-to-project-2.tcl 1 May 2003 14:16:18 -0000 1.2
@@ -9,6 +9,6 @@
variable_id:integer
}
-logger::project::add_variable -project_id $project_id -variable_id $variable_id
+logger::project::map_variable -project_id $project_id -variable_id $variable_id
ad_returnredirect "project?project_id=$project_id"
Index: openacs-4/packages/logger/www/admin/map-variable-to-project.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/map-variable-to-project.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/logger/www/admin/map-variable-to-project.adp 22 Apr 2003 09:27:03 -0000 1.1
+++ openacs-4/packages/logger/www/admin/map-variable-to-project.adp 1 May 2003 14:16:18 -0000 1.2
@@ -11,5 +11,7 @@
- There are no variables in this package that are not already added to the project
+
+ You do not have access to any variables that are not already added to the project
+
Index: openacs-4/packages/logger/www/admin/map-variable-to-project.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/map-variable-to-project.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/logger/www/admin/map-variable-to-project.tcl 22 Apr 2003 09:27:03 -0000 1.1
+++ openacs-4/packages/logger/www/admin/map-variable-to-project.tcl 1 May 2003 14:16:18 -0000 1.2
@@ -14,17 +14,4 @@
set context [list $page_title]
# List all variables not already mapped to the project
-logger::package::variables_multirow $project_id
-
-db_multirow variables variables_to_map {
- select variable_id,
- name,
- unit,
- type
- from logger_variables lv
- where not exists (select 1
- from logger_project_var_map
- where project_id = :project_id
- and variable_id = lv.variable_id
- )
-}
+logger::package::variables_multirow -not_in_project_id $project_id
Index: openacs-4/packages/logger/www/admin/project.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/project.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/logger/www/admin/project.tcl 30 Apr 2003 12:21:16 -0000 1.3
+++ openacs-4/packages/logger/www/admin/project.tcl 1 May 2003 14:16:18 -0000 1.4
@@ -9,26 +9,33 @@
}
set package_id [ad_conn package_id]
+set user_id [ad_conn user_id]
-if { ![empty_string_p [ns_set iget [rp_getform] formbutton:done_button]] } {
+if { [string equal [form get_action project_form] "done"] } {
# User is done editing - redirect back to index page
- ad_returnredirect index
+ ad_returnredirect .
ad_script_abort
}
if { [exists_and_not_null project_id] } {
# Initial request in display or edit mode or a submit of the form
set page_title "One Project"
set ad_form_mode display
+ set project_exists_p [db_string project_exists_p {
+ select count(*)
+ from logger_projects
+ where project_id = :project_id
+ }]
} else {
# Initial request in add mode
set page_title "Add a Project"
set ad_form_mode edit
+ set project_exists_p 0
}
set context [list $page_title]
-set actions_list [list [list Edit "formbuilder::edit"] [list Done done_button]]
+set actions_list [list [list Edit "formbuilder::edit"] [list Done done]]
ad_form -name project_form \
-cancel_url index \
-mode $ad_form_mode \
@@ -46,30 +53,60 @@
}
}
-if { [exists_and_not_null project_id] } {
+if { $project_exists_p } {
# We are in edit or display mode
# Display the variables linked to this project
set variables_list [list]
set variables_text ""
db_foreach variables_in_project {
select lv.variable_id,
- lv.name
+ lv.name,
+ lpvm.primary_p
from logger_project_var_map lpvm,
logger_variables lv
where lpvm.variable_id = lv.variable_id
and lpvm.project_id = :project_id
} {
- lappend variables_list "$name"
+ set variable_link "$name"
+ if { [string equal $primary_p "f"] } {
+ append variable_link " \[ unmap | make primary \]"
+ } else {
+ append variable_link " (primary)"
+ }
+
+ lappend variables_list $variable_link
}
if { [llength $variables_list] != 0 } {
- set variables_text [join $variables_list ", "]
+ set variables_text "[join $variables_list " "] "
} else {
set variables_text "no variables"
}
- append variables_text " \[add variable\]"
+ set n_can_be_mapped [db_string n_can_be_mapped {
+ select count(*)
+ from logger_variables lv
+ where (exists (select 1
+ from logger_project_var_map lpvm,
+ logger_project_pkg_map lppm
+ where lv.variable_id = lpvm.variable_id
+ and lpvm.project_id = lppm.project_id
+ and lppm.package_id = :package_id
+ )
+ or lv.package_id = :package_id
+ or lv.package_id is null)
+ and not exists (select 1
+ from logger_project_var_map lpvm
+ where lpvm.project_id = :project_id
+ and lpvm.variable_id = lv.variable_id
+ )
+ and acs_permission.permission_p(lv.variable_id, :user_id, 'read') = 't'
+ }]
+ if { $n_can_be_mapped > 0 } {
+ append variables_text " \[add variable\] "
+ }
+
ad_form -extend -name project_form -form {
{variables:text(inform)
{label Variables}
Index: openacs-4/packages/logger/www/admin/variable.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/variable.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/logger/www/admin/variable.tcl 30 Apr 2003 12:21:16 -0000 1.2
+++ openacs-4/packages/logger/www/admin/variable.tcl 1 May 2003 14:16:18 -0000 1.3
@@ -10,6 +10,12 @@
set package_id [ad_conn package_id]
+if { [string equal [form get_action variable_form] "done"] } {
+ # User is done editing - redirect back to index page
+ ad_returnredirect .
+ ad_script_abort
+}
+
if { [exists_and_not_null variable_id] } {
# Initial request in display or edit mode or a submit of the form
set page_title "One variable"
@@ -22,7 +28,8 @@
set context [list $page_title]
-ad_form -name variable_form -cancel_url index -mode $ad_form_mode -form {
+set actions_list [list [list Edit "formbuilder::edit"] [list Done done]]
+ad_form -name variable_form -cancel_url index -mode $ad_form_mode -actions $actions_list -form {
variable_id:key(acs_object_id_seq)
{name:text
|