torbenb
committed
on 25 Aug 08
spam-3.tcl
/admin/portal-element-add.tcl (+3 -3)
5 5   @creation-date Oct 23, 2005
6 6   @cvs-id $Id$
7 7
8 8   @param object_type show objects of this class and its subclasses
9 9 } -parameter {
10 10   {-portal_id}
11 11   {-page_name}
12 12   {-referer .}
13 13 }
14 14
15 15
16 16 set page_id [$package_id resolve_request -path $page_name method]
17 17 set page_id [::Generic::CrItem lookup -name $page_name -parent_id [$package_id folder_id]]
18 18 set page_title [$page_id title]
19 19
20 20 # for the time being, we add the portlet on the first page (page 0)
21 21 set portal_page_id [portal::get_page_id -portal_id $portal_id -sort_key 0]
22 22
23 23 if {[db_string check_unique_name_on_page {
24 24   select 1 from portal_element_map
25     where portal_id   = :portal_page_id
  25   where page_id     = :portal_page_id
26 26   and   pretty_name = :page_title
27   }] eq "1"} {
  27 } -default 0] == 1} {
28 28   ad_return_error [_ xowiki.portlet_title_exists_error_short] [_ xowiki.portlet_title_exists_error_long]
29 29 } else {
30 30   db_transaction {
31 31     set element_id [portal::add_element \
32 32                         -portal_id $portal_id \
33 33                         -portlet_name [xowiki_portlet::get_my_name] \
34 34                         -pretty_name $page_title \
35 35                         -force_region [parameter::get_from_package_key \
36 36                                            -parameter "xowiki_portal_content_force_region" \
37 37                                            -package_key "xowiki-portlet"]
38 38                    ]
39 39     portal::set_element_param $element_id package_id $package_id
40 40     portal::set_element_param $element_id page_name [$page_id name]
41 41   }
42 42   ad_returnredirect $referer
43 43 }
44 44 ad_script_abort
45 45