Index: openacs-4/packages/connections/tcl/connections-apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/tcl/connections-apm-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/tcl/connections-apm-callback-procs.tcl 7 Apr 2006 08:11:45 -0000 1.1 @@ -0,0 +1,29 @@ +ad_library { + + APM callbacks for connections package + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-12 +} + +namespace eval connections::install { + + ad_proc -public after_mount { + -package_id + -node_id + } { + + Create a connection category tree and put the tree_id in the connections parameter for the connections site + + @return + + @error + } { + + # create category tree for connections + set tree_id [category_tree::add -name "Connections" -description "Connection keywords"] + parameter::set_value -package_id $package_id -parameter "Connections_TreeId" -value $tree_id + + } + +} Index: openacs-4/packages/connections/tcl/connections-forms-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/tcl/connections-forms-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/tcl/connections-forms-procs.tcl 7 Apr 2006 08:11:45 -0000 1.1 @@ -0,0 +1,66 @@ +ad_library { + Library to generate and process form elements for Connections + + @author Hamilton Chua (ham@soluiongrove.com) + @creation-date 2006-01-11 +} + +namespace eval connections::form { } + +ad_proc -public connections::form::generate { + -form_id:required + -object_id:required + {-num_of_con "20"} +} { + Generate an extended ad_form with textboxes for users to enter connection keywords + associated with the given object_id. If the given object_id has any existing keywords associated with it, + alter the num_of_connections to the number of existing keywords. + + @author Hamilton Chua + @param form_id The form id or name of an existing form. + @param object_id The object_id that you want to map keywords to. + @param num_of_con The number of textboxes to generate. +} { + set existing_con_list [connections::getlist -object_id $object_id -with_url "0"] + set existing_num_of_con [llength $existing_con_list] + + if { $existing_num_of_con > $num_of_con } { + set num_of_con $existing_num_of_con + } + + # create elements + for { set x 0 } { $x < $num_of_con } { incr x } { + template::element::create $form_id conkeyword${x} -datatype "text" -optional -label "" -section "Tags" + } + + # set elements + if { [exists_and_not_null object_id] } { + for { set x 0 } { $x < $num_of_con } { incr x } { + if { [lindex $existing_con_list $x] != "" } { + template::element::set_value $form_id conkeyword${x} [lindex $existing_con_list $x] + } + } + } +} + +ad_proc -public connections::form::process { + -form_id:required + -object_id:required + {-num_of_con "20"} +} { + Retrieves field values generated by connections::form::generate and saves the connection keywords. + + @author Hamilton Chua + @param form_id The form id or name of an existing form. + @param object_id The object_id that you want to map keywords to. + @param num_of_con The number of text fields from which you will get connection keywords.. + +} { + connections::remove_all -object_id $object_id + + for { set x 0 } { $x < $num_of_con } { incr x } { + if { [template::element::get_value $form_id conkeyword${x}] != "" } { + connections::create -object_id $object_id -keyword [template::element::get_value $form_id conkeyword${x}] + } + } +} \ No newline at end of file Index: openacs-4/packages/connections/tcl/connections-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/tcl/connections-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/tcl/connections-procs.tcl 7 Apr 2006 08:11:45 -0000 1.1 @@ -0,0 +1,147 @@ +ad_library { + Library for Connections + + @author Hamilton Chua (ham@soluiongrove.com) + @creation-date 2006-01-11 +} + +namespace eval connections { } + +ad_proc -private connections::get_package_id { + +} { + Return the package_id of the connections mounted connections instance + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2003-01-11 + @return + + @error + +} { + return [apm_package_id_from_key "connections"] +} + +ad_proc -private connections::get_url { + +} { + Return the URL to the connections instance + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2003-01-11 + @return + + @error + +} { + return [apm_package_url_from_id [connections::get_package_id]] +} + +ad_proc -public connections::category_tree_id { + +} { + Return tree id used for Connections + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2003-01-11 + @return + + @error + +} { + return [parameter::get -package_id [connections::get_package_id] -parameter "Connections_TreeId" -default 0] +} + +ad_proc -public connections::getlist { + -object_id:required + -with_url:required +} { + Returns a list of connections and a link. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2003-01-11 + @return + + @error +} { + # get list of categories associated to the object_id + set tree_id [connections::category_tree_id] + set category_ids [category::get_mapped_categories -tree_id $tree_id $object_id] + + # generate the list of connection keywords with the appropriate links for display + set connections [list] + set preurl [connections::get_url] + + foreach id $category_ids { + if { $with_url == 1 } { + lappend connections "[category::get_name $id]" + } else { + lappend connections [category::get_name $id] + } + } + return $connections +} + +ad_proc -public connections::create { + -object_id:required + -keyword:required +} { + Creates a connection. + If keyword is not found in categories, this proc will create it and map object_id to it. + If keyword already exits in categories, just get category id and map it to the object_id. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2005-10-26 + @return + + @error +} { + set category_id [category::get_id [string tolower [string trim $keyword]]] + if { $category_id == "" } { + + # add category and map to object_id + set tree_id [connections::category_tree_id] + + # remove spaces and any html from keywords + regsub -all {<.+?>} $keyword "" keyword + set keyword [string tolower [string trim $keyword]] + set category_id [category::add -tree_id $tree_id -name $keyword -parent_id ""] + category::map_object -object_id $object_id $category_id + + } else { + + # map object_id to category + category::map_object -object_id $object_id $category_id + + } +} + +ad_proc -public connections::remove { + -object_id:required + -category_id:required +} { + Remove a connection. Unmaps a object_id from a category. + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2005-10-26 + @return + + @error +} { + db_dml "delmap" "delete from category_object_map where object_id = :object_id and category_id =:category_id" +} + +ad_proc -public connections::remove_all { + -object_id:required +} { + Remove all connections. + Unmaps all category from object_id + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2005-10-26 + @return + + @error +} { + db_dml "delmap" "delete from category_object_map where object_id = :object_id" +} Index: openacs-4/packages/connections/www/add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/add.tcl 7 Apr 2006 08:11:45 -0000 1.1 @@ -0,0 +1,14 @@ +ad_page_contract { + Add a connection keyword + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2005-10-29 +} { + object_id:integer,notnull + keyword:notnull + return_url +} + +connections::create -object_id $object_id -keyword $keyword + +ad_returnredirect -message "Connection added successfully." $return_url \ No newline at end of file Index: openacs-4/packages/connections/www/delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/delete.tcl 7 Apr 2006 08:11:45 -0000 1.1 @@ -0,0 +1,14 @@ +ad_page_contract { + Add a connection keyword + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2005-10-29 +} { + object_id:integer,notnull + category_id:integer,notnull + return_url +} + +connections::remove_connection -object_id $object_id -category_id $category_id + +ad_returnredirect -message "Connection removed successfully." $return_url \ No newline at end of file Index: openacs-4/packages/connections/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/index.adp 7 Apr 2006 08:11:45 -0000 1.1 @@ -0,0 +1,8 @@ + +Connections + + @ah_sources;noquote@ + + + + \ No newline at end of file Index: openacs-4/packages/connections/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/index.tcl 7 Apr 2006 08:11:45 -0000 1.1 @@ -0,0 +1,13 @@ +ad_page_contract { + Provides a search form. Returns the most recent connection keywords. + + @author Roel Canicula (Roel Canicula), Hamilton Chua (ham@solutiongrove.com) + @creation-date 2005-10-29 +} { + {search:trim ""} +} + +# HAM : AjaxHelper +set ah_sources [ah::js_sources -default] +append ah_sources [ah::js_sources -source "overlibmws"] +append ah_sources [ah::js_sources -source "rounder"] Index: openacs-4/packages/connections/www/oneconnection.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/oneconnection.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/oneconnection.adp 7 Apr 2006 08:11:45 -0000 1.1 @@ -0,0 +1,19 @@ + +Connections + + + + +

The Connection Keyword "@category_name;noquote@" returned @num_of_connections@ results.

+ + +
+ +
+
+ + No connections found for the given search string. + \ No newline at end of file Index: openacs-4/packages/connections/www/oneconnection.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/oneconnection.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/oneconnection.tcl 7 Apr 2006 08:11:45 -0000 1.1 @@ -0,0 +1,24 @@ +ad_page_contract { + Return list of objects mapped to a given category_id +} { + category_id:integer,notnull + {detailed:integer "0"} +} -validate { + detailed_one_or_zero_only -requires { detailed:integer } { + if { $detailed > 1 || $detailed < 0 } { + ad_complain "Detailed must be either 1 or 0" + } + } +} -errors { + category_id:integer,notnull { Category Id is required. } +} + +# get category name, use it as title +set category_name [category::get_name $category_id] + +db_multirow -extend {url} objectlist "getobjects" "select a.object_id, b.title, a.category_id, b.object_type, c.pretty_name from category_object_map a, acs_objects b, acs_object_types c where a.object_id=b.object_id and b.object_type=c.object_type and a.category_id=:category_id" { + set url "/o/${object_id}" +} + +set num_of_connections [template::multirow size "objectlist"] + \ No newline at end of file Index: openacs-4/packages/connections/www/resources/connections.css =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/resources/connections.css,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/resources/connections.css 7 Apr 2006 08:11:45 -0000 1.1 @@ -0,0 +1,38 @@ +#connections { + opacity:0; + line-height: 25px; + padding: 5px; + margin: 0; + min-height:100px; + width:95%; + vertical-align: middle; +} + +.oneobject { + clear: both; + border-top: 1px solid #ccc; + min-height: 3.3em; /*for the hover*/ +} + +.oneobject:hover { + background: #E8ECF4; +} + +.objtitle, .objdetails { + float:left; + display:block; + text-decoration: none; +} + +.objfulldetails { + opacity:0; + clear:both; + width:100%; + padding-left:5px; + padding-top:10px; + padding-bottom: 5px; +} + +#objectslist a, .oneobject a , .oneobject span { + padding: 15px 4px 4px 4px; +} \ No newline at end of file Index: openacs-4/packages/connections/www/xmlhttp/getconnections.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/xmlhttp/getconnections.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/xmlhttp/getconnections.adp 7 Apr 2006 08:11:46 -0000 1.1 @@ -0,0 +1,6 @@ + + No connection keywords matched your search. + + + + Index: openacs-4/packages/connections/www/xmlhttp/getconnections.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/xmlhttp/getconnections.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/xmlhttp/getconnections.tcl 7 Apr 2006 08:11:46 -0000 1.1 @@ -0,0 +1,53 @@ +ad_page_contract { + If a search term is provided, this include will return the most recent connection keywords. + If an object_id is provided, this include will return all the connection keywords for the give object_id. + + @author Roel Canicula (Roel Canicula), Hamilton Chua (ham@solutiongrove.com) + @creation-date 2005-10-29 +} { + {search:trim ""} + {object_id:integer ""} + {limit_n 250} + {effects "0"} +} + +set tree_id [connections::category_tree_id] +set locale [ad_conn locale] +set connections_url [connections::get_url] + +if { $search eq "" } { + set search_clause "" +} else { + set search_clause { and lower(t.name) like '%'||:search||'%' } +} + +if { [exists_and_not_null object_id] } { + + db_multirow -extend { url } connections connections { + select c.category_id, c.object_id, t.name, count(*) as count from category_object_map c, category_translations t where c.category_id=t.category_id and t.locale=:locale and c.object_id=:object_id group by c.category_id,c.object_id,t.name; + } { + set url [export_vars -base $connections_url\oneconnection { category_id }] + } + +} else { + + db_multirow -extend { url } connections connections [subst { + select c.category_id, t.name, count(*) as count, o.creation_user + from categories c, category_translations t, category_object_map m, acs_objects o + where c.category_id = t.category_id + and c.tree_id = :tree_id + and t.locale = :locale + and c.category_id = m.category_id + and c.category_id = o.object_id + $search_clause + + group by t.name, o.creation_date, o.creation_user, c.category_id + + order by o.creation_date desc + + limit $limit_n + }] { + set url [export_vars -base $connections_url\oneconnection { category_id }] + } + +} \ No newline at end of file Index: openacs-4/packages/connections/www/xmlhttp/getlatestobj.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/xmlhttp/getlatestobj.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/xmlhttp/getlatestobj.adp 7 Apr 2006 08:11:46 -0000 1.1 @@ -0,0 +1,5 @@ +The Latest on @category_name@ +
+@pretty_objlist;noquote@ +
+Click for more .... \ No newline at end of file Index: openacs-4/packages/connections/www/xmlhttp/getlatestobj.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/xmlhttp/getlatestobj.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/xmlhttp/getlatestobj.tcl 7 Apr 2006 08:11:46 -0000 1.1 @@ -0,0 +1,21 @@ +ad_page_contract { + Returns the names of the most recent objects associated with the given category_id + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-17 +} { + {category_id:integer ""} + {limit_n 10} +} + +set category_name [category::get_name $category_id] + +db_multirow objectlist "getobjects" "select a.object_id, b.title, a.category_id, b.object_type, c.pretty_name from category_object_map a, acs_objects b, acs_object_types c where a.object_id=b.object_id and b.object_type=c.object_type and a.category_id=:category_id" { } + +set objlist [list] + +template::multirow foreach objectlist { + lappend objlist "$title ($pretty_name)" +} + +set pretty_objlist [join $objlist ", "] \ No newline at end of file Index: openacs-4/packages/connections/www/xmlhttp/getoneobj.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/xmlhttp/getoneobj.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/xmlhttp/getoneobj.adp 7 Apr 2006 08:11:46 -0000 1.1 @@ -0,0 +1,6 @@ + + + + + Sorry, we could not find the details of this object + \ No newline at end of file Index: openacs-4/packages/connections/www/xmlhttp/getoneobj.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/connections/www/xmlhttp/getoneobj.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/connections/www/xmlhttp/getoneobj.tcl 7 Apr 2006 08:11:46 -0000 1.1 @@ -0,0 +1,14 @@ +ad_page_contract { + Returns the details of the object with the given object_id + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-01-17 +} { + {object_id:integer ""} +} + +if { [db_0or1row "objquery" "select object_type from acs_objects where object_id=:object_id"] } { + switch $object_type { + "user" { set liburl "/packages/connections/lib/ot-user" } + } +} \ No newline at end of file