Class ::xo::db::CrFolder (public)
::xo::db::CrClass ::xo::db::CrFolder
Defined in
- Testcases:
-
No testcase defined.
Source code:
namespace eval ::xo::db {}
::nsf::object::alloc ::xo::db::CrClass ::xo::db::CrFolder {set :__default_metaclass ::xotcl::Class
set :__default_superclass ::xotcl::Object
set :abstract_p f
set :auto_save false
array set :db_constraints {folder_id {{references {cr_items on delete cascade}} {references {cr_items on delete cascade}}}}
array set :db_slot {label ::xo::db::CrFolder::slot::label creation_date ::xo::db::Object::slot::creation_date creation_user ::xo::db::Object::slot::creation_user object_id ::xo::db::Object::slot::object_id description ::xo::db::CrFolder::slot::description creation_ip ::xo::db::Object::slot::creation_ip text ::xo::db::CrItem::slot::text folder_id ::xo::db::CrFolder::slot::folder_id nls_language ::xo::db::CrItem::slot::nls_language object_title ::xo::db::Object::slot::object_title package_id ::xo::db::Object::slot::package_id security_inherit_p ::xo::db::Object::slot::security_inherit_p context_id ::xo::db::Object::slot::context_id mime_type ::xo::db::CrItem::slot::mime_type name ::xo::db::CrItem::slot::name title ::xo::db::CrItem::slot::title item_id ::xo::db::CrItem::slot::item_id revision_id ::xo::db::CrItem::slot::revision_id modifying_user ::xo::db::Object::slot::modifying_user publish_date ::xo::db::CrItem::slot::publish_date last_modified ::xo::db::Object::slot::last_modified modifying_ip ::xo::db::Object::slot::modifying_ip}
set :edit_form CrFolderForm
set :folder_id -100
set :form CrFolderForm
set :id_column folder_id
set :mime_type text/plain
set :name_method {}
set :non_cached_instance_var_patterns __*
set :object_type content_folder
set :object_type_key 000000000000110100000000
set :pretty_name Folder
set :pretty_plural Folders
set :security_inherit_p t
set :sql_package_name ::xo::db::CrFolder
set :storage_type text
set :supertype content_revision
set :table_name cr_folders
set :with_table true}
::xo::db::CrFolder proc get_instance_from_db {{-item_id 0} {-revision_id 0} {-initialize:boolean true}} {
set object ::$item_id
if {![nsf::is object $object]} {
:fetch_object -object $object -item_id $item_id -initialize $initialize
$object destroy_on_cleanup
}
return $object
}
::xo::db::CrFolder proc fetch_object {-item_id:required {-revision_id 0} -object:required {-initialize:boolean true}} {
if {![nsf::is object $object]} {
:create $object
}
$object set item_id $item_id
$object db_1row [:qn fetch_folder] {
SELECT * FROM cr_folders
JOIN cr_items on cr_folders.folder_id = cr_items.item_id
JOIN acs_objects on cr_folders.folder_id = acs_objects.object_id
WHERE folder_id = :item_id
}
if {$initialize} {
$object initialize_loaded_object
}
return $object
}
::xo::db::CrFolder proc instance_select_query {{-select_attributes ""} {-orderby ""} {-where_clause ""} {-from_clause ""} {-with_subtypes:boolean true} {-with_children:boolean true} -publish_status {-count:boolean false} -folder_id -parent_id {-page_size 20} {-page_number ""} {-base_table "cr_folders"}} {
if {![info exists folder_id]} {set folder_id ${:folder_id}}
if {![info exists parent_id]} {set parent_id $folder_id}
if {$base_table eq "cr_folders"} {
set attributes [list ci.item_id ci.name ci.publish_status acs_objects.object_type]
} else {
set attributes [list bt.item_id ci.name ci.publish_status bt.object_type]
}
foreach a $select_attributes {
lappend attributes $a
}
set type_selection_clause [:type_selection_clause -base_table cr_revisions -with_subtypes false]
if {$count} {
set attribute_selection "count(*)"
set orderby "" ;
set page_number "" ;
} else {
set attribute_selection [join $attributes ,]
}
set cond [list]
if {$type_selection_clause ne ""} {lappend cond $type_selection_clause}
if {$where_clause ne ""} {lappend cond $where_clause}
if {[info exists publish_status]} {lappend cond "ci.publish_status = :publish_status"}
if {$base_table eq "cr_folders"} {
lappend cond "acs_objects.object_id = cf.folder_id and ci.item_id = cf.folder_id"
set acs_objects_table "acs_objects, cr_items ci, "
} else {
lappend cond "ci.item_id = bt.item_id"
set acs_objects_table ""
}
if {$parent_id ne ""} {
set parent_clause "ci.parent_id = :parent_id"
if {$with_children} {
lappend cond "ci.item_id in (
select children.item_id from cr_items parent, cr_items children
where children.tree_sortkey between parent.tree_sortkey and tree_right(parent.tree_sortkey)
and parent.item_id = $parent_id and parent.tree_sortkey <> children.tree_sortkey)"
} else {
lappend cond $parent_clause
}
}
if {$page_number ne ""} {
set limit $page_size
set offset [expr {$page_size*($page_number-1)}]
} else {
set limit ""
set offset ""
}
set sql [::xo::dc select -vars $attribute_selection -from "$acs_objects_table cr_folders cf $from_clause" -where [join $cond " and "] -orderby $orderby -limit $limit -offset $offset]
return $sql
}
::xo::db::CrFolder proc register_content_types {-folder_id:required {-content_types ""}} {
foreach content_type $content_types {
set with_subtypes [expr {[regexp {^(.*)[*]$} $content_type _ content_type] ? "t" : "f"}]
::acs::dc call content_folder register_content_type -folder_id $folder_id -content_type $content_type -include_subtypes $with_subtypes
}
}
::xo::db::CrFolder proc delete -item_id {
::acs::dc call content_folder del -folder_id $item_id -cascade_p t
}
::xo::db::CrFolder instproc save_new -creation_user {
set package_id ${:package_id}
[:info class] get_context package_id creation_user creation_ip
set :folder_id [::acs::dc call content_folder new -name ${:name} -label [:label] -description [:description] -parent_id ${:parent_id} -package_id $package_id -creation_user $creation_user -creation_ip $creation_ip]
if { [nsf::is object ::${:parent_id}] } {
::${:parent_id} set has_child_folders t
}
if {[[self class] exists allowed_content_types]} {
::xo::db::CrFolder register_content_types -folder_id ${:folder_id} -content_types [[self class] set allowed_content_types]
}
::xo::xotcl_object_cache flush ${:parent_id}
return ${:folder_id}
}
::xo::db::CrFolder instproc update {} {
::xo::dc transaction {
next
:instvar object_id label description
::xo::dc dml update_cr_folders {update cr_folders
set label = :label,description = :description where folder_id = :object_id
}
}
}
::xo::db::CrFolder instproc save args {
set folder_id ${:folder_id}
content::folder::update -folder_id $folder_id -attributes [list [list name ${:name}] [list label ${:label}] [list description ${:description}] ]
[:info class] get_context package_id user_id ip
::xo::dc 1row _ "select acs_object__update_last_modified(:folder_id, :user_id, :ip)"
}
::xo::db::CrFolder instproc delete {} {
if {[:is_package_root_folder]} {
ad_return_error "Removal denied" "Don't delete the package root folder, delete the package"
return
}
[:info class] delete -item_id ${:folder_id}
}
::xo::db::CrFolder instparametercmd description
::xo::db::CrFolder instparametercmd label
::xo::db::CrFolder instparametercmd folder_id
::xo::db::CrFolder instparametercmd mime_type
::nsf::relation::set ::xo::db::CrFolder superclass ::xo::db::CrItem
::nx::slotObj -container slot ::xo::db::CrFolder
::nsf::object::alloc ::xo::db::CrAttribute ::xo::db::CrFolder::slot::folder_id {set :accessor public
set :column_name folder_id
set :configurable true
set :convert false
set :create_acs_attribute true
set :create_table_attribute true
set :datatype integer
set :defaultmethods {}
set :disposition alias
set :domain ::xo::db::CrFolder
set :incremental false
set :manager ::xo::db::CrFolder::slot::folder_id
set :max_n_values 1
set :methodname folder_id
set :min_n_values 1
set :multiplicity 1..1
set :name folder_id
set :per-object false
set :position 0
set :pretty_name {Folder ID}
set :pretty_plural {}
set :references {cr_items on delete cascade}
set :required false
set :sqltype integer
set :trace none
: init}
::nsf::object::alloc ::xo::db::CrAttribute ::xo::db::CrFolder::slot::label {set :accessor public
set :column_name label
set :configurable true
set :convert false
set :create_acs_attribute true
set :create_table_attribute true
set :datatype text
set :defaultmethods {}
set :disposition alias
set :domain ::xo::db::CrFolder
set :incremental false
set :manager ::xo::db::CrFolder::slot::label
set :max_n_values 1
set :methodname label
set :min_n_values 1
set :multiplicity 1..1
set :name label
set :per-object false
set :position 0
set :pretty_name Label
set :pretty_plural {}
set :references {}
set :required false
set :sqltype text
set :trace none
: init}
::nsf::object::alloc ::xo::db::CrAttribute ::xo::db::CrFolder::slot::description {set :accessor public
set :column_name description
set :configurable true
set :convert false
set :create_acs_attribute true
set :create_table_attribute true
set :datatype text
set :defaultmethods {}
set :disposition alias
set :domain ::xo::db::CrFolder
set :incremental false
set :manager ::xo::db::CrFolder::slot::description
set :max_n_values 1
set :methodname description
set :min_n_values 1
set :multiplicity 1..1
set :name description
set :per-object false
set :position 0
set :pretty_name Description
set :pretty_plural {}
set :references {}
set :required false
set :spec textarea,cols=80,rows=2
set :sqltype text
set :trace none
: init}
::nsf::object::alloc ::xotcl::Attribute ::xo::db::CrFolder::slot::mime_type {set :accessor public
set :configurable true
set :convert false
set :default text/plain
set :defaultmethods {}
set :disposition alias
set :domain ::xo::db::CrFolder
set :incremental false
set :manager ::xo::db::CrFolder::slot::mime_type
set :methodname mime_type
set :multiplicity 1..1
set :name mime_type
set :per-object false
set :position 0
set :required false
set :substdefault 0b111
set :trace none
: init}
XQL Not present:Generic, PostgreSQL, Oracle
[
hide source ]
| [
make this the default ]