|
1193 | 1193 | $links = array(); |
1194 | 1194 | $link_owner_class = get_class( $LinkOwner->link_Object ); |
1195 | 1195 |
|
| 1196 | + load_class( '_core/model/dataobjects/_dataobjectlist2.class.php', 'DataObjectList2' ); |
| 1197 | + $LinkCache = & get_LinkCache(); |
| 1198 | + $ea_Linklist = new DataObjectList2( $LinkCache ); |
| 1199 | + |
1196 | 1200 | switch( $link_owner_class ) |
1197 | 1201 | { |
1198 | 1202 | case 'Item': |
|
1214 | 1218 | $comments_SQL->WHERE( 'comment_item_ID = '.$DB->quote( $item_ID ) ); |
1215 | 1219 | $comment_IDs = $DB->get_col( $comments_SQL ); |
1216 | 1220 |
|
1217 | | - load_class( '_core/model/dataobjects/_dataobjectlist2.class.php', 'DataObjectList2' ); |
1218 | | - $LinkCache = & get_LinkCache(); |
1219 | | - $ea_Linklist = new DataObjectList2( $LinkCache ); |
1220 | | - |
1221 | 1221 | $links_SQL = new SQL( 'Get all the links belonging to comments of an Item' ); |
1222 | | - $links_SQL->SELECT( 'l.*' ); |
| 1222 | + $links_SQL->SELECT( '*' ); |
1223 | 1223 | $links_SQL->FROM( 'T_links AS l' ); |
1224 | | - $links_SQL->FROM_add( 'LEFT JOIN T_comments AS c ON c.comment_ID = l.link_cmt_ID' ); |
1225 | 1224 | if( $comment_IDs ) |
1226 | 1225 | { |
1227 | 1226 | $links_SQL->WHERE( 'link_cmt_ID IN ('.$DB->quote( $comment_IDs ).')' ); |
1228 | 1227 | } |
1229 | 1228 | $links_SQL->WHERE_or( 'link_itm_ID = '.$DB->quote( $item_ID ) ); |
1230 | | - $links_SQL->ORDER_BY( 'c.comment_date DESC' ); |
| 1229 | + $links_SQL->ORDER_BY( 'link_datemodified DESC, link_datecreated DESC' ); |
1231 | 1230 |
|
1232 | 1231 | $ea_Linklist->sql = $links_SQL->get(); |
1233 | 1232 | $ea_Linklist->run_query( false, false, false, 'get_attachment_LinkList' ); |
|
1257 | 1256 | $selected_Filelist = new Filelist( $fm_FileRoot, false ); // Arbitrary list of attached files |
1258 | 1257 | break; |
1259 | 1258 |
|
| 1259 | + case 'EmailCampaign': |
| 1260 | + if( $edited_Newsletter = & $LinkOwner->link_Object->get_Newsletter() ) |
| 1261 | + { |
| 1262 | + // Get list of email campaign IDs under the same Newsletter: |
| 1263 | + $email_campaigns_SQL = new SQL( 'Get all the email campaigns of a List' ); |
| 1264 | + $email_campaigns_SQL->SELECT( 'ecmp_ID' ); |
| 1265 | + $email_campaigns_SQL->FROM( 'T_email__campaign' ); |
| 1266 | + $email_campaigns_SQL->WHERE( 'ecmp_enlt_ID = '.$DB->quote( $edited_Newsletter->ID ) ); |
| 1267 | + $email_campaign_IDs = $DB->get_col( $email_campaigns_SQL ); |
| 1268 | + |
| 1269 | + if( $email_campaign_IDs ) |
| 1270 | + { |
| 1271 | + $links_SQL = new SQL( 'Get all the links belonging to email campaigns of a List' ); |
| 1272 | + $links_SQL->SELECT( '*' ); |
| 1273 | + $links_SQL->FROM( 'T_links AS l' ); |
| 1274 | + $links_SQL->WHERE( 'link_ecmp_ID IN ('.$DB->quote( $email_campaign_IDs ).')' ); |
| 1275 | + $links_SQL->ORDER_BY( 'link_datemodified DESC, link_datecreated DESC' ); |
| 1276 | + |
| 1277 | + $ea_Linklist->sql = $links_SQL->get(); |
| 1278 | + $ea_Linklist->run_query( false, false, false, 'get_attachment_LinkList' ); |
| 1279 | + } |
| 1280 | + } |
| 1281 | + |
| 1282 | + // Get FileRoot and dummy FileList: |
| 1283 | + if( $ea_Linklist->get_total_rows() ) |
| 1284 | + { // Use first attachment to get the FileRoot: |
| 1285 | + $Link = & $ea_Linklist->get_by_idx( 0 ); |
| 1286 | + $File = & $Link->get_File(); |
| 1287 | + $fm_FileRoot = & $File->get_FileRoot(); |
| 1288 | + } |
| 1289 | + else |
| 1290 | + { |
| 1291 | + $fm_FileRoot = & $FileRootCache->get_by_type_and_ID( 'emailcampaign', $LinkOwner->link_Object->ID ); |
| 1292 | + } |
| 1293 | + load_class( 'files/model/_filelist.class.php', 'FileList' ); |
| 1294 | + $fm_Filelist = new Filelist( $fm_FileRoot, false ); // Arbitrary list of attached files |
| 1295 | + $selected_Filelist = new Filelist( $fm_FileRoot, false ); // Arbitrary list of attached files |
| 1296 | + break; |
| 1297 | + |
1260 | 1298 | default: |
1261 | 1299 | debug_die( 'Existing attachments list not available to '.$link_owner_class ); |
1262 | 1300 | } |
|
1268 | 1306 |
|
1269 | 1307 | $AdminUI = new AdminUI(); |
1270 | 1308 | $Widget = new Widget( 'file_browser' ); |
1271 | | - $Widget->title = T_('Existing attachments').get_manual_link('existing-attachments'); |
1272 | 1309 | $Widget->disp_template_replaced( 'block_start' ); |
1273 | 1310 |
|
1274 | 1311 | require $inc_path.'links/views/_link_file_list.inc.php'; |
|
0 commit comments