daveb
committed
on 21 Dec 04
Add CR Tcl API from HEAD.
openacs-4/packages/news/www/item.tcl (+14 -2)
8 8     @cvs-id $Id$
9 9    
10 10 } {
11 11
12 12     item_id:integer,notnull
13 13
14 14 } -properties {
15 15     title:onevalue
16 16     context:onevalue
17 17     item_exist_p:onevalue
18 18     publish_title:onevalue
19 19     publish_date:onevalue
20 20     publish_body:onevalue
21 21     html_p:onevalue
22 22     creator_link:onevalue
23 23     comments:onevalue
24 24     comment_link:onevalue
25 25 }
26 26
27 27
28   ad_require_permission [ad_conn package_id] news_read
  28 set user_id [ad_conn untrusted_user_id]
29 29
  30 permission::require_permission \
  31     -object_id $item_id \
  32     -party_id  $user_id \
  33     -privilege read
30 34
  35
31 36 # live view of a news item in its active revision
32 37 set item_exist_p [db_0or1row one_item "
33 38 select item_id,
34 39        live_revision,
35 40        publish_title,
36 41        html_p,
37 42        publish_date,
38 43        '<a href=/shared/community-member?user_id=' || creation_user || '>' || item_creator ||  '</a>' as creator_link
39 44 from   news_items_live_or_submitted
40 45 where  item_id = :item_id"]
41 46
42 47
43 48 if { $item_exist_p } {
44 49
45 50     # workaround to get blobs with >4000 chars into a var, content.blob_to_string fails!
46 51     # when this'll work, you get publish_body by selecting 'publish_body' directly from above view
47 52     #
48 53     # RAL: publish_body is already snagged in the 1st query above for postgres.
49 54     #
50 55     set get_content [db_map get_content]
51 56     if {![string match "" $get_content]} {
52 57         set publish_body [db_string get_content "select  content
53 58         from    cr_revisions
54 59         where   revision_id = :live_revision"]
55 60     }
56 61
57 62     # text-only body
58 63     if {[info exists html_p] && [string equal $html_p "f"]} {
59 64         set publish_body [ad_text_to_html -- $publish_body]
60 65     }
61 66    
62 67     if { [ad_parameter SolicitCommentsP "news" 0] &&
63 68          [ad_permission_p $item_id general_comments_create] } {
64 69         set comment_link [general_comments_create_link $item_id "[ad_conn package_url]item?item_id=$item_id"]
65 70         set comments [general_comments_get_comments -print_content_p 1 -print_attachments_p 1 \
66 71                 $item_id "[ad_conn package_url]item?item_id=$item_id"]
67 72     } else {
68 73         set comment_link ""
69 74         set comments ""
70 75     }
71 76
  77     if {[permission::permission_p -object_id $item_id -privilege write] } {
  78         set edit_link "<a href=\"admin/revision-add?item_id=$item_id\">Revise</a>"
  79     } else {
  80         set edit_link ""
  81     }
  82
  83
72 84     set title $publish_title
73 85     set context [list $title]
74 86     set publish_title {}
75 87
76 88 } else {
77 89     set context {}
78 90     set title "[_ news.Error]"
79 91 }
80 92
81 93
82 94
83 95
84 96
85 97
86 98
87 99
88 100
89 101
90 102
91 103