Viewing Paste 408
Formated Paste
// Send me an array of customization ids and I'll return an array of context. { //$id_cust = is_array($id_cust) ? $id_cust : array($id_cust); if (($context['customization'] = cache_get_data('custs_' . serialize($id_cust), $cust_settings['cache_time'])) == null) { // The reason why I'm not joining the members table again for c.id_owner is because the owner is also an author. // So, we can just grab that information from the authors table. $request = $smcFunc['db_query']('cust_context', ' SELECT c.id_cust, c.id_site, c.id_owner, c.id_topic, c.id_topic_discuss, c.id_topic_dev, c.submit_time, c.modified_time, c.latest_version, c.name, c.id_file, c.cust_type as type, c.id_cat, c.approved, c.downloads, c.package_id, c.short_desc, c.enabled_features, c.description, t.id_tag, t.name AS tag_name, a.id_member AS id_author, IFNULL(feat.id_cust, 0) as featured, IFNULL(f.id_file, 0) as id_file, at.id_attach, at.id_thumb, at.id_folder, at.attachment_type, at.filename, at.file_hash, at.fileext, at.size, at.downloads AS file_downloads, at.width, at.height, at.mime_type FROM {raw:database}customizations as c LEFT JOIN {raw:database}tagged as td ON (td.id_cust = c.id_cust) LEFT JOIN {raw:database}tags as t ON (t.id_tag = td.id_tag) LEFT JOIN {raw:database}authors as a ON (a.id_cust = c.id_cust) LEFT JOIN {raw:database}members as m ON (mem.id_member = a.id_member) LEFT JOIN {raw:database}featured as feat ON (feat.id_cust = c.id_cust) LEFT JOIN {raw:database}files as f ON (f.id_cust = c.id_cust) LEFT JOIN {raw:database}attachments as at ON (at.id_attach = f.id_attach) WHERE c.id_cust IN({raw:id_cust}) {raw:order_by} {raw:order} LIMIT {int:limit}', 'database' => $cust_settings['db_prefix'], ) ); if ($smcFunc['db_num_rows']($request) == 0) return null; // Setup those empty arrays. while ($row = $smcFunc['db_fetch_assoc']($request)) { { 'name' => $row['name'], 'id' => $row['id_cust'], 'id' => $row['id_owner'], 'name' => $row['poster_name'], ), 'id' => $row['id_site'], 'name' => , ), 'downloads' => comma_format($row['downloads']), 'description' => parse_bbc($row['description']), 'short_desc' => parse_bbc($row['short_desc']), 'submit_time' => timeformat($row['submit_time']), 'modified_time' => timeformat($row['modified_time']), 'package_id' => $row['package_id'], 'featured' => (bool) $row['featured'], ); } // Tags. 'id' => $row['id_tag'], 'name' => $row['tag_name'], ); $context['customization'][$row['id_cust']]['tags'][] = $row['id_tag']; // Authors. 'id' => $row['id_author'], 'name' => $row['author_name'], ); $context['customization'][$row['id_cust']]['authors'][] = $row['id_author']; if ($row['id_author'] == $row['id_owner']) $context['customization'][$row['id_cust']]['owner']['name'] = $row['author_name']; // Files. if (!isset($context['customization'][$row['id_cust']]['files'][$row['id_file']] && $row['id_file'] != 0) 'id' => $row['id_file'], 'name' => $row['filename'], 'location' => $modSettings['attachmentUploadDir'][$row['id_folder']] . '/' . $row['filename'], //'url' => $row[''], 'id_attach' => $row['id_attach'], 'id_folder' => $row['id_folder'], 'type' => $row['attachment_type'], 'hash' => $row['file_hash'], 'ext' => $row['fileext'], 'size' => $row['size'], 'downloads' => $row['file_downloads'], 'width' => $row['width'], 'height' => $row['height'], 'mime_type' => $row['mime_type'], ); } cache_put_data('custs_' . serialize($id_cust), $context['cust_tags'], $cust_settings['extended_cache_time']); } }
