Index: openacs-4/packages/logger/logger.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/logger.info,v diff -u -r1.1 -r1.2 --- openacs-4/packages/logger/logger.info 8 Apr 2003 12:11:56 -0000 1.1 +++ openacs-4/packages/logger/logger.info 22 Apr 2003 09:23:48 -0000 1.2 @@ -6,20 +6,20 @@ Loggers f f - - - - oracle - postgresql - + + Peter Marklund Lars Pind Supports time and expenses reporting. Full specification is here: http://www.collaboraid.biz/developer/logger-spec - 2003-04-02 + 2003-04-16 Collaboraid - + + + + + Index: openacs-4/packages/logger/sql/oracle/logger-tables-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/sql/oracle/logger-tables-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/logger/sql/oracle/logger-tables-create.sql 6 Apr 2003 08:02:45 -0000 1.3 +++ openacs-4/packages/logger/sql/oracle/logger-tables-create.sql 22 Apr 2003 09:24:47 -0000 1.4 @@ -82,7 +82,10 @@ constraint logger_variables_type_nn not null constraint logger_variables_type_ck - check (type in ('additive', 'non-additive')) + check (type in ('additive', 'non-additive')), + package_id integer + constraint logger_project_var_map_pi_fk + references apm_packages(package_id) ); comment on column logger_variables.type is ' @@ -91,6 +94,10 @@ a project. A non-additive variable would be the amount of money in a bank account. '; +comment on column logger_variables.package_id is ' + The id of the package that the variable was created in. +'; + create sequence logger_variables_seq; create table logger_project_var_map ( Index: openacs-4/packages/logger/tcl/measurement-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/Attic/measurement-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/logger/tcl/measurement-procs.tcl 6 Apr 2003 09:26:47 -0000 1.1 +++ openacs-4/packages/logger/tcl/measurement-procs.tcl 22 Apr 2003 09:25:40 -0000 1.2 @@ -46,6 +46,26 @@ return $measurement_id } +ad_proc -public logger::measurement::edit { + {-measurement_id:required} + {-value:required} + {-time_stamp:required} + {-description ""} +} { + Edit a measurement. + + @param measurement_id The id of the measurement to edit + @param value The new value of the measurement + @param time_stamp The new time stamp of the measurement + @param description The new description of the measurement + + @return The return value from db_dml + + @author Peter Marklund +} { + db_dml update_measurement {} +} + ad_proc -public logger::measurement::delete { {-measurement_id:required} } { Index: openacs-4/packages/logger/tcl/measurement-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/Attic/measurement-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/logger/tcl/measurement-procs.xql 6 Apr 2003 09:26:47 -0000 1.1 +++ openacs-4/packages/logger/tcl/measurement-procs.xql 22 Apr 2003 09:25:40 -0000 1.2 @@ -15,4 +15,14 @@ + + + update logger_measurements + set value = :value, + time_stamp = :time_stamp, + description = :description + where measurement_id = :measurement_id + + + Index: openacs-4/packages/logger/tcl/package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/package-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/logger/tcl/package-procs.tcl 5 Apr 2003 10:16:42 -0000 1.1 +++ openacs-4/packages/logger/tcl/package-procs.tcl 22 Apr 2003 09:25:40 -0000 1.2 @@ -49,3 +49,30 @@ } { return [db_list select_projects {}] } + +ad_proc -public logger::package::variables_multirow { + {not_in_project_id ""} +} { + Executes a db_multirow that returns all variables created + in the current package and all variables mapped to projects + in the current package. + + @param not_in_project_id Exclude variables already mapped to the given project_id. + + @author Peter Marklund +} { + set package_id [ad_conn package_id] + + if { ![empty_string_p $not_in_project_id] } { + set extra_where_clause \ + "and not exists (select 1 + from logger_project_var_map + where project_id = $not_in_project_id + and variable_id = lv.variable_id + )" + } else { + set extra_where_clause "" + } + + db_multirow variables select_variables {} +} Index: openacs-4/packages/logger/tcl/package-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/package-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/logger/tcl/package-procs.xql 5 Apr 2003 10:16:42 -0000 1.1 +++ openacs-4/packages/logger/tcl/package-procs.xql 22 Apr 2003 09:25:40 -0000 1.2 @@ -25,4 +25,24 @@ + + + select lv.variable_id, + lv.name, + lv.unit, + lv.type + 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) + $extra_where_clause + + + Index: openacs-4/packages/logger/tcl/project-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/project-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/tcl/project-procs-postgresql.xql 22 Apr 2003 09:25:40 -0000 1.1 @@ -0,0 +1,30 @@ + + + + postgresql7.1 + + + + begin + select logger_project__new ( + :project_id, + :name, + :description, + :project_lead, + :creation_user, + :creation_ip, + :package_id + ); + end; + + + + + + begin + select logger_project__delete(:project_id); + end; + + + + Index: openacs-4/packages/logger/tcl/project-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/project-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/logger/tcl/project-procs.tcl 6 Apr 2003 09:26:47 -0000 1.2 +++ openacs-4/packages/logger/tcl/project-procs.tcl 22 Apr 2003 09:25:40 -0000 1.3 @@ -11,87 +11,77 @@ ad_proc -public logger::project::new { {-name:required} - {-project_id ""} - {-package_id ""} {-description ""} {-project_lead ""} - {-creation_user ""} - {-creation_ip ""} + {-project_id ""} } {

Create a logger project.

- I've tried to design this proc so that it can be used also - if there is no HTTP (ad_conn) connection, for example during a data import. + This proc requires the ad_conn proc to be initialized (uses user_id, peeraddr, and package_id). + The ad_conn proc is initialized + by the request processor during an HTTP request to an OpenACS server.

@param name The name of the project. - @param project_id Any pre-generated id of the new package. Optional. - @param package_id The id of the Logger package in which the project is created. Defaults - to ad_conn package_id. Also used as context_id. @param description The description for the proct. Optional. @param project_lead The user id of the project leader of the project. Defaults to the currently logged in user. - @param creation_user The user creating the project. Defaults to ad_conn user_id. - @param creation_ip The ip of the user creating the project. Defaults to ad_conn peeraddr - + @param project_id Any pre-generated id of the new package. Optional. + @return The project_id of the created project. @author Peter Marklund } { - # Use ad_conn to setup default values and check that required values are provided - # if there is no ad_conn - # The lists are on the array format + # Use ad_conn to initialize variables + # The lists are on the following array format # var_name1 ad_conn_arg_name1 var_name2 ad_conn_arg_name2 ... - set required_ad_conn_vars [list package_id package_id creation_user user_id] - set optional_ad_conn_vars [list creation_ip peeraddr] + set ad_conn_vars [list package_id package_id creation_user user_id creation_ip peeraddr] if { [ad_conn isconnected] } { - # HTTP connection available - - # ad_conn provides default values for us - foreach {var_name ad_conn_name} [concat $required_ad_conn_vars $optional_ad_conn_vars] { - if { [empty_string_p [set $var_name]] } { + foreach {var_name ad_conn_name} $ad_conn_vars { set $var_name [ad_conn $ad_conn_name] - - # If we are using ad_conn package_id - # we might as well use ad_conn to check that its a logger package - if { [string equal $var_name package_id] } { - if { ![string equal [ad_conn package_key] logger] } { - error "logger::project::new Defaulting package_id to the current package with key [ad_conn package_key] but package must be a logger package" - } - } - } } - - } else { - # No HTTP connection - - # Default optional ad_conn vars to the empty string - foreach {var_name ad_conn_name} $optional_ad_conn_vars { - set $var_name "" - } - - # Assert that required ad_conn variables are provided - foreach var_name $required_ad_conn_vars { - if { [empty_string_p [set $var_name]] } { - error "logger::project::new - the $var_name argument was not provided and there is no ad_conn (HTTP) connection so a default value cannot be set" - } - } + error "logger::project::new - this proc requires an ad_conn connection" } # Project lead defaults to creation user if { [empty_string_p $project_lead] } { set project_lead $creation_user } + # Insert the project set project_id [db_exec_plsql insert_project {}] return $project_id } +ad_proc -public logger::project::edit { + {-project_id:required} + {-name:required} + {-description:required} + {-project_lead:required} + {-active_p:required} +} { + Edit a Logger project. + + @param project_id The id of the project to edit + @param name The new name + @param description The new description + @param project_lead The new id of the project lead + @param active_p The new value for active_p, must be t (true) or f (false) + + @return The return value from db_dml + + @author Peter Marklund +} { + ad_assert_arg_value_in_list active_p {t f} + + db_dml update_project {} +} + ad_proc -public logger::project::delete { {-project_id:required} } { @@ -190,3 +180,18 @@ } { return [db_list select_variables {}] } + +ad_proc -public logger::project::get_primary_variable { + {-project_id:required} +} { + Return the id of the variable primarily logged in for a certain project. + + @param project_id The id of the project to return the primary variable for. + + @return The id of the primary variable. Returns the empty string if the + project has no primary variable. + + @author Peter Marklund +} { + return [db_string select_primary_variable {} -default ""] +} \ No newline at end of file Index: openacs-4/packages/logger/tcl/project-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/project-procs.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/logger/tcl/project-procs.xql 6 Apr 2003 09:26:47 -0000 1.3 +++ openacs-4/packages/logger/tcl/project-procs.xql 22 Apr 2003 09:25:40 -0000 1.4 @@ -30,6 +30,15 @@ + + + select variable_id + from logger_project_var_map + where project_id = :project_id + and primary_p = 't' + + + select variable_id @@ -38,4 +47,15 @@ + + + update logger_projects + set name = :name, + description = :description, + project_lead = :project_lead, + active_p = :active_p + where project_id = :project_id + + + Index: openacs-4/packages/logger/tcl/ui-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/ui-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/tcl/ui-procs.tcl 22 Apr 2003 09:25:40 -0000 1.1 @@ -0,0 +1,39 @@ +ad_library { + Procedures in the logger::ui namespace. Those + procedures are used to support the building of the logger + UI. + + @creation-date 21 April 2003 + @author Peter Marklund (peter@collaboraid.biz) + @cvs-id $Id: ui-procs.tcl,v 1.1 2003/04/22 09:25:40 peterm Exp $ +} + +namespace eval logger::ui {} + +ad_proc -public logger::ui::navbar_link_selected_p { + navbar_url +} { +

+ Return 1 if the navbar link with given URL (relative server URL) should be marked + selected in the UI for the current request and 0 otherwise. +

+ +

+ A link is considered selected if the current page url starts with the url of the link + followed by the optional slash, question mark and query string +

+ + @author Peter Marklund +} { + # Let's remove any trailing slash and make it optional in our pattern + regsub {(.*)/$} $navbar_url {\1} url_no_slash + + # For readability I define the pattern in curly braces which avoids a lot of backslashes + set selected_pattern {^/?(\?[^/]*$|$)} + regsub {} $selected_pattern $url_no_slash selected_pattern + + set page_url [ad_conn url] + set selected_p [regexp $selected_pattern $page_url match] + + return $selected_p +} 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.2 -r1.3 --- openacs-4/packages/logger/tcl/variable-procs.tcl 5 Apr 2003 13:10:42 -0000 1.2 +++ openacs-4/packages/logger/tcl/variable-procs.tcl 22 Apr 2003 09:25:40 -0000 1.3 @@ -36,11 +36,37 @@ set variable_id [db_nextval logger_variables_seq] } + set package_id [ad_conn package_id] + db_dml insert_variable {} return $variable_id } +ad_proc -public logger::variable::edit { + {-variable_id:required} + {-name:required} + {-unit:required} + {-type:required} +} { + Edit a logger variable. + + @param variable_id The id of the project to edit + @param name The new name of the variable + @param unit The new unit of the variable + @param type The new type of the variable (additive or non-additive) + + @return The return value from db_dml + + @author Peter Marklund +} { + ad_assert_arg_value_in_list type {additive non-additive} + + set package_id [ad_conn package_id] + + db_dml update_variable {} +} + ad_proc -public logger::variable::delete { {-variable_id:required} } { Index: openacs-4/packages/logger/tcl/variable-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/tcl/variable-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/logger/tcl/variable-procs.xql 5 Apr 2003 10:16:42 -0000 1.1 +++ openacs-4/packages/logger/tcl/variable-procs.xql 22 Apr 2003 09:25:40 -0000 1.2 @@ -4,11 +4,21 @@ - insert into logger_variables (variable_id, name, unit, type) - values (:variable_id, :name, :unit, :type) + insert into logger_variables (variable_id, name, unit, type, package_id) + values (:variable_id, :name, :unit, :type, :package_id) + + + update logger_variables + set name = :name, + unit = :unit, + type = :type + where variable_id = :variable_id + + + delete from logger_variables Index: openacs-4/packages/logger/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/index.adp 22 Apr 2003 09:26:17 -0000 1.1 @@ -0,0 +1,87 @@ + +Logger Application + + + + + + + + + + + +
+ +

+ Filter +

+ + + + + + + + + + + + +
+

+ Projects +

+
+ @projects.name@ log +
+
+ + + + There are no matching log entries + + + + + + + + + + + + + + + + + + + +
TimeValueVariableDescription 
@measurements.time_stamp@@measurements.value@@measurements.variable_name@ (@measurements.unit@)@measurements.description@[ Edit ]
+
+ +
+ +
+ + + + +

+ Before anyone can start working with the Logger application an administrator needs to setup a project. +

+ + +

+ Since you are an administrator you may visit the admin pages to do so now. +

+
+ +

+ Please contact an administrator about this. Thank you. +

+
+ +
Index: openacs-4/packages/logger/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/index.tcl 22 Apr 2003 09:26:17 -0000 1.1 @@ -0,0 +1,49 @@ +ad_page_contract { + User index page for the Logger application. + + @author Peter marklund (peter@collaboraid.biz) + @creation-date 2003-04-08 + @cvs-id $Id: index.tcl,v 1.1 2003/04/22 09:26:17 peterm Exp $ +} { + project_id:optional,integer +} + +set package_id [ad_conn package_id] +set admin_p [permission::permission_p -object_id $package_id -privilege admin] + +set where_clauses [list] +if { [exists_and_not_null project_id] } { + lappend where_clauses "lp.project_id = :project_id" +} + +db_multirow measurements select_measurements " + select lm.measurement_id as id, + lm.time_stamp, + lv.name as variable_name, + lm.value, + lv.unit, + lm.description + from logger_measurements lm, + logger_variables lv, + logger_projects lp + where lm.variable_id = lv.variable_id + and lm.project_id = lp.project_id + and exists (select 1 + from logger_project_pkg_map + where project_id = lp.project_id + and package_id = :package_id) + [ad_decode $where_clauses "" "" "and [join $where_clauses "\n and"]"] + order by lm.time_stamp desc +" + +db_multirow -extend url projects select_projects { + select lp.project_id, + lp.name + from logger_projects lp, + logger_project_pkg_map lppm + where lp.project_id = lppm.project_id + and lppm.package_id = :package_id + order by lp.name +} { + set url "index?[export_vars project_id]" +} Index: openacs-4/packages/logger/www/log.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/log.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/log.adp 22 Apr 2003 09:26:17 -0000 1.1 @@ -0,0 +1,7 @@ + +@page_title@ +@context@ + +
+ +
Index: openacs-4/packages/logger/www/log.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/log.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/log.tcl 22 Apr 2003 09:26:17 -0000 1.1 @@ -0,0 +1,137 @@ +ad_page_contract { + Add/edit/display a log entry. + + @author Peter marklund (peter@collaboraid.biz) + @creation-date 2003-04-16 + @cvs-id $Id: log.tcl,v 1.1 2003/04/22 09:26:17 peterm Exp $ +} { + measurement_id:integer,optional + project_id:integer,optional + variable_id:integer,optional +} -validate { + project_id_required_in_add_mode { + # For the sake of simplicity of the form + # we are requiring a project_id to be provided in add mode + if { ![exists_and_not_null measurement_id] && ![exists_and_not_null project_id] } { + ad_complain "When adding a log entry a project_id must be provided (either measurement_id or project_id must be present)." + } + } +} + +set package_id [ad_conn package_id] + +if { ![empty_string_p [ns_set iget [rp_getform] formbutton:done_button]] } { + # User is done editing - redirect back to index page + ad_returnredirect index + ad_script_abort +} + +# Different page title and form mode when adding a log entry +# versus displaying/editing one +if { [exists_and_not_null measurement_id] } { + # Initial request in display or edit mode or a submit of the form + set page_title "One Log Entry" + set ad_form_mode display +} else { + # Initial request in add mode + set page_title "Add a Log Entry" + set ad_form_mode edit +} + +set context [list $page_title] + +# Build the log entry form elements +ad_form -name log_entry_form -cancel_url index -mode $ad_form_mode -actions [list [list Edit "formbuilder::edit"] [list Done done_button]] -form { + measurement_id:key(acs_object_id_seq) +} + +# On various occasions we need to know if we are dealing with a submit with the +# form or an initial request (could also be with error message after unaccepted submit) +set submit_p [form is_valid log_entry_form] + +# Initial request of form or input error +if { ! $submit_p } { + + # Add project and variable elements to the form + # Get project_id if it's not provided + if { ![exists_and_not_null project_id] } { + logger::measurement::get -measurement_id $measurement_id -array measurement + set project_id $measurement(project_id) + } + # For simplicity - use the primary variable of the + # project + set variable_id [logger::project::get_primary_variable -project_id $project_id] + # We need project and variable names + logger::project::get -project_id $project_id -array project + logger::variable::get -variable_id $variable_id -array variable + ad_form -extend -name log_entry_form -form { + {project:text(inform) + {label Project} + {value $project(name)} + } + + {variable:text(inform) + {label Variable} + {value "$variable(name) ($variable(unit))"} + } + + {project_id:integer(hidden) + {value $project_id} + } + + {variable_id:integer(hidden) + {value $variable_id} + } + } +} + +# Add form elements common to all modes +# The form builder date datatype doesn't understand standard ANSI format date strings +regsub -all -- {-} [dt_systime] { } default_date +ad_form -extend -name log_entry_form -form { + {value:integer + {label Value} + } + + {time_stamp:date + {label Date} + {value $default_date} + } + + description:text,optional +} + +# Execute the form +ad_form -extend -name log_entry_form -select_query { + select project_id, + variable_id, + value, + to_char(time_stamp, 'YYYY MM DD') as time_stamp, + description + from logger_measurements + where measurement_id = :measurement_id +} -new_data { + set time_stamp_ansi "[lindex $time_stamp 0]-[lindex $time_stamp 1]-[lindex $time_stamp 2]" + logger::measurement::new -measurement_id $measurement_id \ + -project_id $project_id \ + -variable_id $variable_id \ + -value $value \ + -time_stamp $time_stamp_ansi \ + -description $description +} -edit_data { + set time_stamp_ansi "[lindex $time_stamp 0]-[lindex $time_stamp 1]-[lindex $time_stamp 2]" + logger::measurement::edit -measurement_id $measurement_id \ + -value $value \ + -time_stamp $time_stamp_ansi \ + -description $description +} -on_submit { + + ns_log Notice "pm debug on_submit" + +} -after_submit { + + ns_log Notice "pm debug after_submit" + + ad_returnredirect "[ad_conn url]?measurement_id=$measurement_id" + ad_script_abort +} Index: openacs-4/packages/logger/www/master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/Attic/master.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/master.adp 22 Apr 2003 09:26:17 -0000 1.1 @@ -0,0 +1,2 @@ + +@title@ Index: openacs-4/packages/logger/www/style.css =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/Attic/style.css,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/style.css 22 Apr 2003 09:26:17 -0000 1.1 @@ -0,0 +1,26 @@ + +.no_items_text { + font-style: italic; + font-weight: bold; +} + +table.logger_navbar { + background-color: #41329c; +} +a.logger_navbar { + color: white; +} +a.logger_navbar:hover { + color: white; + text-decoration: underline; +} +.logger_navbar_selected_link { + font-weight: bold; +} +.logger_filter_bar_header { + font-weight: bold; + text-align: center; +} +.logger_filter_bar_section_header { + font-weight: bold; +} Index: openacs-4/packages/logger/www/test-page.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/test-page.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/test-page.adp 22 Apr 2003 09:26:17 -0000 1.1 @@ -0,0 +1 @@ + Index: openacs-4/packages/logger/www/admin/index-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/index-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/index-oracle.xql 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,25 @@ + + + + oracle8.1.6 + + + + select lp.project_id, + lp.name, + lp.description, + lp.active_p, + lp.project_lead as project_lead_id, + cc_users.first_names || ' ' || cc_users.last_name as project_lead_name, + acs_permission.permission_p(lp.project_id, :user_id, 'admin') as admin_p + from logger_project_pkg_map lppm, + logger_projects lp, + cc_users + where lppm.project_id = lp.project_id + and lppm.package_id = :package_id + and cc_users.user_id = lp.project_lead + order by name + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/index.adp 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,72 @@ + +@page_title@ + +
+

Projects

+ + + <% # Project table header %> + + + + + + + + + + <% # Project table rows %> + + + + + + + + + + <% # Close project table %> +
Project NameProject DescriptionActiveProject Lead
@projects.name@ + [ Delete ] + + @projects.description@yesno @projects.project_lead_name@
+
+ + + There are no projects + + +

+ Add new project +

+ +

Variables

+ + + + + + + + + + + + + + + + + +
NameUnitAdditive
@variables.name@@variables.unit@yesno
+
+ + + There are no variables + + +

+ Add new variable +

+
\ No newline at end of file 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/index.tcl 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,19 @@ +ad_page_contract { + Administration index page for the Logger application. + + @author Peter marklund (peter@collaboraid.biz) + @creation-date 2003-04-08 + @cvs-id $Id: index.tcl,v 1.1 2003/04/22 09:27:03 peterm Exp $ +} + +set package_id [ad_conn package_id] +set user_id [ad_conn user_id] +set page_title "Logger Administration" + +set home_url [ad_parameter -package_id [ad_acs_kernel_id] HomeURL] + +db_multirow projects select_projects {} + +logger::package::variables_multirow + +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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/map-variable-to-project-2.tcl 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,14 @@ +ad_page_contract { + Add a variable to a logger project. + + @author Peter marklund (peter@collaboraid.biz) + @creation-date 2003-04-16 + @cvs-id $Id: map-variable-to-project-2.tcl,v 1.1 2003/04/22 09:27:03 peterm Exp $ +} { + project_id:integer + variable_id:integer +} + +logger::project::add_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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/map-variable-to-project.adp 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,15 @@ + +@page_title@ +@context@ + + + + + + There are no variables in this package 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/map-variable-to-project.tcl 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,30 @@ +ad_page_contract { + List variables variables for inclusion in a project. + + @author Peter marklund (peter@collaboraid.biz) + @creation-date 2003-04-15 + @cvs-id $Id: map-variable-to-project.tcl,v 1.1 2003/04/22 09:27:03 peterm Exp $ +} { + project_id:integer +} + +logger::project::get -project_id $project_id -array project + +set page_title "Add a variable to project \"$project(name)\"" +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 + ) +} Index: openacs-4/packages/logger/www/admin/project-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/project-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/project-delete.tcl 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,18 @@ +ad_page_contract { + Delete a logger project + + @author Peter Marklund + @creation-date 2003-04-15 + @cvs-id $Id: project-delete.tcl,v 1.1 2003/04/22 09:27:03 peterm Exp $ + +} { + project_id:integer +} + +set user_id [ad_conn user_id] + +permission::require_permission -object_id $project_id -party_id $user_id -privilege admin + +logger::project::delete -project_id $project_id + +ad_returnredirect index Index: openacs-4/packages/logger/www/admin/project.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/project.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/project.adp 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,7 @@ + +@page_title@ +@context@ + +
+ +
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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/project.tcl 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,101 @@ +ad_page_contract { + Add/edit/display a project for this Logger application instance. + + @author Peter marklund (peter@collaboraid.biz) + @creation-date 2003-04-08 + @cvs-id $Id: project.tcl,v 1.1 2003/04/22 09:27:03 peterm Exp $ +} { + project_id:integer,optional +} + +set package_id [ad_conn package_id] + +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 +} else { + # Initial request in add mode + set page_title "Add a Project" + set ad_form_mode edit +} + +set context [list $page_title] + +ad_form -name project_form -cancel_url index -mode $ad_form_mode -form { + project_id:key(acs_object_id_seq) + + name:text + + description:text(textarea),optional +} + +if { [exists_and_not_null project_id] } { + # 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 + 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" + } + + if { [llength $variables_list] != 0 } { + set variables_text [join $variables_list ", "] + } else { + set variables_text "no variables" + } + append variables_text "  \[add variable\]" + + + ad_form -extend -name project_form -form { + {variables:text(inform) + {label Variables} + {value $variables_text} + } + } + +} else { + # We are in add mode +} + +# Finalize the form with the execution blocks +ad_form -extend -name project_form -select_query { + select name, + description + from logger_projects + where project_id = :project_id +} -validate { + { + name + { ![empty_string_p [string trim $name]] } + { A name with only spaces is not allowed } + } + +} -new_data { + + logger::project::new -project_id $project_id \ + -name $name \ + -description $description \ +} -edit_data { + + # The edit proc requires all attributes to be provided + # so use the old values for project_lead and active_p + logger::project::get -project_id $project_id -array old_project + logger::project::edit -project_id $project_id \ + -name $name \ + -description $description \ + -project_lead $old_project(project_lead) \ + -active_p $old_project(active_p) +} -after_submit { + + ad_returnredirect "[ad_conn url]?project_id=$project_id" + + ad_script_abort +} Index: openacs-4/packages/logger/www/admin/variable.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/admin/variable.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/variable.adp 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,7 @@ + +@page_title@ +@context@ + +
+ +
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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/admin/variable.tcl 22 Apr 2003 09:27:03 -0000 1.1 @@ -0,0 +1,64 @@ +ad_page_contract { + Add/edit/display a variable for this Logger application instance. + + @author Peter marklund (peter@collaboraid.biz) + @creation-date 2003-04-15 + @cvs-id $Id: variable.tcl,v 1.1 2003/04/22 09:27:03 peterm Exp $ +} { + variable_id:optional +} + +set package_id [ad_conn package_id] + +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" + set ad_form_mode display +} else { + # Initial request in add mode + set page_title "Add a variable" + set ad_form_mode edit +} + +set context [list $page_title] + +ad_form -name variable_form -cancel_url index -mode $ad_form_mode -form { + variable_id:key(logger_variables_seq) + + name:text + + unit:text + + {type:text(radio) + {options {{Additive additive} {Non-Additive non-additive}}} + } + +} -select_query { + select name, + unit, + type + from logger_variables + where variable_id = :variable_id + +} -validate { + { + name + { ![empty_string_p [string trim $name]] } + { A name with only spaces is not allowed } + } + +} -new_data { + logger::variable::new -variable_id $variable_id \ + -name $name \ + -unit $unit \ + -type $type +} -edit_data { + logger::variable::edit -variable_id $variable_id \ + -name $name \ + -unit $unit \ + -type $type +} -after_submit { + + ad_returnredirect "[ad_conn url]?variable_id=$variable_id" + ad_script_abort +} Index: openacs-4/packages/logger/www/lib/master.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/lib/Attic/master.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/lib/master.adp 22 Apr 2003 09:28:13 -0000 1.1 @@ -0,0 +1,29 @@ + +@title@ +@context@ + + + + + + + + + + + + + + + + + + +
+ Valid XHTML 1.0! +
Index: openacs-4/packages/logger/www/lib/master.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/lib/Attic/master.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/lib/master.tcl 22 Apr 2003 09:28:13 -0000 1.1 @@ -0,0 +1,3 @@ +if [template::util::is_nil context] { set context {}} + +set package_url [ad_conn package_url] \ No newline at end of file Index: openacs-4/packages/logger/www/lib/nav-bar.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/lib/Attic/nav-bar.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/lib/nav-bar.adp 22 Apr 2003 09:28:13 -0000 1.1 @@ -0,0 +1,22 @@ + + + + + +
+ + + + +
+ + + @links.name@ + + + @links.name@ + +  |  + +
+
Index: openacs-4/packages/logger/www/lib/nav-bar.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/logger/www/lib/Attic/nav-bar.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/logger/www/lib/nav-bar.tcl 22 Apr 2003 09:28:13 -0000 1.1 @@ -0,0 +1,39 @@ +# Set up links in the navbar that the user has access to + +set package_id [ad_conn package_id] +set package_url [ad_conn package_url] +set page_url [ad_conn url] + +set admin_p [permission::permission_p -object_id $package_id -privilege admin] + +# The links used in the navbar on format url1 label1 url2 label2 ... +set link_list {} + +if { [ad_conn user_id] != 0 } { + lappend link_list "${package_url}" + lappend link_list "My log entries" +} + +if { $admin_p } { + lappend link_list "${package_url}admin/" + lappend link_list "Admin" +} + +# Convert the list to a multirow and add the selected_p attribute +multirow create links name url selected_p +foreach {url label} $link_list { + if { [regexp {/$} $url match] } { + # Index page - special case as we additionally need to check for a URL with + # the index word in it + set selected_p [expr [logger::ui::navbar_link_selected_p $url] || \ + [logger::ui::navbar_link_selected_p ${url}index]] + } else { + # Not an index page + set selected_p [logger::ui::navbar_link_selected_p $url] + } + + ns_log Notice "pm debug appending navbar link $label $url $selected_p" + multirow append links $label $url $selected_p +} + +ad_return_template