| |
104 |
104 |
|
| |
105 |
105 |
set keyword_id [classified-ads::ads::get_category_id -ad_id $ad_id] |
| |
106 |
106 |
|
| |
107 |
107 |
# |
| |
108 |
108 |
# object_id, object_type, context_id, security_inherit_p, creation_user, |
| |
109 |
109 |
# creation_date, creation_ip, last_modified, modifying_user, modifying_ip, |
| |
110 |
110 |
# tree_sortkey, revision_id, title, item_id, description, publish_date, |
| |
111 |
111 |
# mime_type, nls_language, name, parent_id, ad_id |
| |
112 |
112 |
# |
| |
113 |
113 |
db_1row select_data {} -column_array row |
| |
114 |
114 |
|
| |
115 |
115 |
set row(pretty_publish_date) [util_AnsiDatetoPrettyDate $row(publish_date)] |
| |
116 |
116 |
set row(data) [classified-ads::get_content -revision_id $revision_id] |
| |
117 |
117 |
set row(keyword_id) $keyword_id |
| |
118 |
118 |
|
| |
119 |
119 |
return 0 |
| |
120 |
120 |
} |
| |
121 |
121 |
|
| |
122 |
122 |
|
| |
123 |
123 |
ad_proc -public classified-ads::ads::get_assigned_ads_by_category { |
| |
124 |
|
{-category_id_list ""} |
| |
|
124 |
{-category_id ""} |
| |
125 |
125 |
} { |
| |
126 |
|
Gets all the ads assigned to categories |
| |
|
126 |
Gets all the ads assigned to a category (or all categories in a package.) |
| |
127 |
127 |
|
| |
128 |
|
@param category_id_list A list of category ids. |
| |
129 |
|
The system returns all ads mapped to these categories, or |
| |
|
128 |
@param category_id The system returns all ads mapped to these categories, or |
| |
130 |
129 |
all ads if no category is passed. |
| |
|
130 |
|
| |
|
131 |
@author Roberto Mello |
| |
131 |
132 |
} { |
| |
132 |
|
# DEDS: FIXME - this uses a subselect. this will get inefficient |
| |
133 |
|
# when faced with a large db. optimize this. |
| |
|
133 |
set parent_id [classified-ads::get_folder_id -package_id [ad_conn package_id]] |
| |
|
134 |
|
| |
134 |
135 |
# |
| |
135 |
|
# RBM: I think Deds was referring to the IN clause. It will get |
| |
136 |
|
# slow if there are lots of items in the list, but that |
| |
137 |
|
# doesn't seem to be the case. I made a small optimization |
| |
138 |
|
# to use 'and keyword_id = x' when opnly one category is |
| |
139 |
|
# passed. |
| |
|
136 |
# If no category passed, use the package category |
| |
|
137 |
# |
| |
140 |
138 |
|
| |
141 |
|
set condition_stub "" |
| |
142 |
|
set n_categories [llength $category_id_list] |
| |
|
139 |
if {[empty_string_p $category_id]} { |
| |
|
140 |
set category_id [classified-ads::categories::package_category_exists_p] |
| |
|
141 |
} |
| |
143 |
142 |
|
| |
144 |
|
if { $n_categories == 1 } { |
| |
145 |
|
set condition_stub "and keyword_id = [lindex $category_id_list 0]" |
| |
146 |
|
} elseif { $n_categories > 1 } { |
| |
147 |
|
set condition_stub "and keyword_id in ([join $category_id_list ", "])" |
| |
|
143 |
# |
| |
|
144 |
# Get custom fields for this category. |
| |
|
145 |
# |
| |
|
146 |
|
| |
|
147 |
set custom_fields_list [util_memoize "classified-ads::categories::get_custom_fields -keyword_id $category_id"] |
| |
|
148 |
set custom_fields "" |
| |
|
149 |
|
| |
|
150 |
if {[llength $custom_fields_list] > 0} { |
| |
|
151 |
foreach field $custom_fields_list { |
| |
|
152 |
append custom_fields ", ads.$field" |
| |
148 |
153 |
} |
| |
|
154 |
} |
| |
149 |
155 |
|
| |
150 |
|
set parent_id [classified-ads::get_folder_id -package_id [ad_conn package_id]] |
| |
151 |
156 |
return [db_list_of_ns_sets select_ads {}] |
| |
152 |
157 |
} |
| |
153 |
158 |
|
| |
154 |
159 |
|
| |
155 |
160 |
ad_proc -public classified-ads::ads::get_unassigned_ads_by_category { |
| |
156 |
161 |
{-category_id_list ""} |
| |
157 |
162 |
} { |
| |
158 |
163 |
Gets all the ads NOT assigned to the categories passed. |
| |
159 |
164 |
|
| |
160 |
165 |
@param container_id_list A list of category ids. The system returns all ads not mapped to these categories. |
| |
161 |
166 |
|
| |
162 |
167 |
} { |
| |
163 |
168 |
# DEDS: FIXME - this uses a subselect. this will get inefficient |
| |
164 |
169 |
# when faced with a large db. optimize this. |
| |
165 |
170 |
set condition_stub "" |
| |
166 |
171 |
|
| |
167 |
172 |
if {[llength $category_id_list]} { |
| |
168 |
173 |
set condition_stub "where keyword_id in ([join $category_id_list ", "])" |
| |
169 |
174 |
} |
| |
170 |
175 |
|