category::add (public)
category::add [ -category_id category_id ] -tree_id tree_id \ -parent_id parent_id -name name [ -locale locale ] \ [ -description description ] [ -deprecated_p deprecated_p ] \ [ -user_id user_id ] [ -creation_ip creation_ip ] [ -noflush ]
Defined in packages/categories/tcl/categories-procs.tcl
Insert a new category. The same translation will be added in the default language if it's in a different language.
- Switches:
- Options:
- -category_id (optional)
- -tree_id (required)
- -parent_id (required)
- -name (required)
- -locale (optional)
- -description (optional)
- -deprecated_p (optional, defaults to
"f"
)- -user_id (optional)
- -creation_ip (optional)
- -noflush (optional, boolean)
- -category_id
- category_id of the category to be inserted.
- -locale
- locale of the language. [ad_conn locale] used by default.
- -name
- category name.
- -description
- description of the category.
- -deprecated_p
- is category deprecated?
- -tree_id
- tree_id of the category the category should be added.
- -parent_id
- id of the parent category. "" if top level category.
- -user_id
- user that adds the category. [ad_conn user_id] used by default.
- -creation_ip
- ip-address of the user that adds the category. [ad_conn peeraddr] used by default.
- -noflush
- defer calling category_tree::flush_cache (which if adding multiple categories to a large tree can be very expensive). note that if you set this flag you must call category_tree::flush_cache once the adds are complete.
- Returns:
- category_id
- Author:
- Timo Hentschel <timo@timohentschel.de>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- category_synonyms, category_link, category_crud, category_get_procs, category_tree_procs
Source code: if {$user_id eq ""} { set user_id [ad_conn user_id] } if {$creation_ip eq ""} { set creation_ip [ad_conn peeraddr] } if {$locale eq ""} { set locale [ad_conn locale] } db_transaction { set category_id [db_exec_plsql insert_category ""] set translations [list $locale $name] set default_locale [parameter::get -parameter DefaultLocale -default en_US] if {$locale != $default_locale} { lappend translations $default_locale $name db_exec_plsql insert_default_category "" } if {!$noflush_p} { category_tree::flush_cache $tree_id } # JCD: avoid doing a query and set the translation cache directly # flush_translation_cache $category_id nsv_set categories $category_id [list $tree_id $translations] } return $category_idXQL Not present: Generic PostgreSQL XQL file: <fullquery name="category::add.insert_category"> <querytext> select category__new ( :category_id, :tree_id, :locale, :name, :description, :parent_id, :deprecated_p, current_timestamp, :user_id, :creation_ip ) </querytext> </fullquery> <fullquery name="category::add.insert_default_category"> <querytext> select category__new_translation ( :category_id, :default_locale, :name, :description, current_timestamp, :user_id, :creation_ip ) </querytext> </fullquery>packages/categories/tcl/categories-procs-postgresql.xql
Oracle XQL file: <fullquery name="category::add.insert_category"> <querytext> begin :1 := category.new ( category_id => :category_id, locale => :locale, name => :name, description => :description, tree_id => :tree_id, parent_id => :parent_id, creation_user => :user_id, creation_ip => :creation_ip ); end; </querytext> </fullquery> <fullquery name="category::add.insert_default_category"> <querytext> begin category.new_translation ( category_id => :category_id, locale => :default_locale, name => :name, description => :description, modifying_user => :user_id, modifying_ip => :creation_ip ); end; </querytext> </fullquery>packages/categories/tcl/categories-procs-oracle.xql