Index: openacs-4/packages/project-manager/tcl/project-procs-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/project-manager/tcl/project-procs-oracle.xql,v
diff -u -N -r1.3 -r1.4
--- openacs-4/packages/project-manager/tcl/project-procs-oracle.xql 3 Jun 2005 22:13:44 -0000 1.3
+++ openacs-4/packages/project-manager/tcl/project-procs-oracle.xql 28 Nov 2005 16:59:29 -0000 1.4
@@ -195,4 +195,30 @@
+
+
+ select
+ distinct
+ p.item_id
+ from
+ pm_projectsx p,
+ pm_projectsx p2
+ where
+ p.parent_id = p2.item_id
+ and p.parent_id = :parent
+
+
+
+
+
+ select
+ distinct
+ status_id
+ from
+ pm_projectsx
+ where
+ item_id in ($projects)
+
+
+
Index: openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql,v
diff -u -N -r1.8 -r1.9
--- openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql 28 Aug 2005 14:54:36 -0000 1.8
+++ openacs-4/packages/project-manager/tcl/project-procs-postgresql.xql 28 Nov 2005 16:59:29 -0000 1.9
@@ -388,4 +388,30 @@
+
+
+ select
+ distinct
+ p.item_id
+ from
+ pm_projectsx p,
+ pm_projectsx p2
+ where
+ p.parent_id = p2.item_id
+ and p.parent_id = :parent
+
+
+
+
+
+ select
+ distinct
+ status_id
+ from
+ pm_projectsx
+ where
+ item_id in ($projects)
+
+
+
Index: openacs-4/packages/project-manager/tcl/project-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/project-manager/tcl/project-procs.tcl,v
diff -u -N -r1.24 -r1.25
--- openacs-4/packages/project-manager/tcl/project-procs.tcl 7 Oct 2005 09:53:36 -0000 1.24
+++ openacs-4/packages/project-manager/tcl/project-procs.tcl 28 Nov 2005 16:59:29 -0000 1.25
@@ -12,7 +12,6 @@
namespace eval pm::project {}
-
ad_proc -public pm::project::get_project_id {
-project_item_id:required
} {
@@ -3242,3 +3241,74 @@
append html ""
return $html
}
+
+ad_proc -public pm::project::get_all_subprojects {
+ -project_item_id:required
+} {
+ @author Miguel Marin (miguelmarin@viaro.net)
+ @author Viaro Networks www.viaro.net
+ @creation-date 2005-11-28
+
+ Returns a list of all subprojects (including subprojects of the subprojects and
+ so on...) for the specific project_item_id
+
+ @param project_item_id The project_item_id to get all the subprojects
+ @returns list of all the subprojects
+} {
+
+ # First we are going to get all subprojects
+ set parent $project_item_id
+ set subprojects [db_list get_subprojects { }]
+
+ set i 0
+ set continue_p 0
+
+ while { [string equal $continue_p 0] } {
+ set parent [lindex $subprojects $i]
+
+ # Now we get the sub_projects of the sub_projects if there is any
+ set sub_projects [db_list get_subprojects { }]
+ foreach sp $sub_projects {
+ lappend subprojects $sp
+ }
+ # We reach the end of the list so we just end the while
+ if { [empty_string_p [lindex $subprojects [expr $i + 1]]] } {
+ set continue_p 1
+ }
+ # We increment the variable i so we can get
+ # the subprojects of the next project in the list
+ incr i
+ }
+
+ return $subprojects
+}
+
+ad_proc -public pm::project::check_projects_status {
+ -projects:required
+ -status_id:required
+} {
+ @author Miguel Marin (miguelmarin@viaro.net)
+ @author Viaro Networks www.viaro.net
+ @creation-date 2005-11-28
+
+ Returns 1 if all the projects provided in the @projects@
+ have status @status_id@, 0 otherwise
+
+ @param projects The list of projects to get check the status
+ @param status_id The status_id that all project must have
+ @returns 1 or 0
+} {
+
+ set projects [template::util::tcl_to_sql_list $projects]
+ set projects_status [db_list get_projects_status " "]
+
+ if { [llength $projects_status] > 1 } {
+ return 0
+ } else {
+ if { [lindex $projects_status 0] == $status_id } {
+ return 1
+ } else {
+ return 0
+ }
+ }
+}