SleePy Public Git Projects
Repositories
Main Site
GitHub Profile
SD-SimpleDesk
Code
Commits
Branches
Tags
Search
Tree:
87b5488
Branches
Tags
master
smf21
1.0.1
2.0.0
v.21/2.1.1
v2.1/2.1-RC1
v2.1/2.1-RC2
v2.1/2.1.0
v2.1/2.1.1
v2.1/2.1.2
v2.1/2.1.3
SD-SimpleDesk
install-xml
install-attachments.xml
! I broke everything when moving stuff to /trunk/, but it works now :P
nas
commited
87b5488
at 2010-11-29 05:20:37
install-attachments.xml
Blame
History
Raw
<?xml version="1.0"?> <!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification"> <modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/"> <id>SimpleDeskTeam:SimpleDesk</id> <version>1.1 rev753</version> <file name="$sourcedir/Display.php"> <operation><!-- add the option to the download system to ensure it handles SD attachments --> <search position="after"><![CDATA[ // This is just a regular attachment... else]]></search> <add><![CDATA[ elseif (!empty($_REQUEST['ticket'])) { // Make sure the attachment is on this ticket, note right now we're forcing it to be "approved" $request = shd_db_query('', ' SELECT a.id_folder, a.filename, a.file_hash, a.fileext, a.id_attach, a.attachment_type, a.mime_type, 1 AS approved FROM {db_prefix}attachments AS a INNER JOIN {db_prefix}helpdesk_attachments AS hda ON (a.id_attach = hda.id_attach) INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr ON (hda.id_msg = hdtr.id_msg) INNER JOIN {db_prefix}helpdesk_tickets AS hdt ON (hdtr.id_ticket = hdt.id_ticket) WHERE {query_see_ticket} AND a.id_attach = {int:attach} AND hdt.id_ticket = {int:ticket} LIMIT 1', array( 'attach' => $_REQUEST['attach'], 'ticket' => (int) $_REQUEST['ticket'], ) ); }]]></add> </operation> </file> <file name="$sourcedir/ManageAttachments.php"> <operation><!-- extend removeAttachments to cover SD's table items since it's doing the rest of the work anyway --> <search position="after"><![CDATA[ if ($return_affected_messages)]]></search> <add><![CDATA[ // And now lastly to remove SimpleDesk attachments if (!empty($attach)) $smcFunc['db_query']('', ' DELETE FROM {db_prefix}helpdesk_attachments WHERE id_attach IN ({array_int:attachment_list})', array( 'attachment_list' => $attach, ) ); ]]></add> </operation> <operation><!-- prevent attachment maintenance killing our attachments! unconventionally, this is an atomic query for good reason, it MUST be put in place fully --> <search position="replace"><![CDATA[SELECT a.id_attach, a.id_folder, a.filename, a.file_hash FROM {db_prefix}attachments AS a LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) WHERE a.id_attach BETWEEN {int:substep} AND {int:substep} + 499 AND a.id_member = {int:no_member} AND a.id_msg != {int:no_msg} AND m.id_msg IS NULL]]></search> <add><![CDATA[SELECT a.id_attach, a.id_folder, a.filename, a.file_hash FROM {db_prefix}attachments AS a LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) LEFT JOIN {db_prefix}helpdesk_attachments AS hda ON (hda.id_attach = a.id_attach) LEFT JOIN {db_prefix}helpdesk_ticket_replies AS hdtr ON (hdtr.id_msg = hda.id_msg) WHERE a.id_attach BETWEEN {int:substep} AND {int:substep} + 499 AND a.id_member = {int:no_member} AND a.id_msg != {int:no_msg} AND m.id_msg IS NULL AND hdtr.id_msg IS NULL]]></add> </operation> <operation><!-- override the master attachments code if it's HD only stuff requested --> <search position="before"><![CDATA[$context['browse_type'] = isset($_REQUEST['avatars']) ? 'avatars' : (isset($_REQUEST['thumbs']) ? 'thumbs' : 'attachments');]]></search> <add><![CDATA[ if (!empty($modSettings['helpdesk_active']) && (isset($_REQUEST['shd_attach']) || isset($_REQUEST['shd_thumb']))) { // We're actually wanting helpdesk only stuff, so do it and bail return shd_admin_browse_attachments(); } ]]></add> </operation> <operation><!-- add the code to deal with deleting our attachments from ACP --> <search position="after"><![CDATA[if ($_REQUEST['type'] == 'avatars' && !empty($attachments))]]></search> <add><![CDATA[if (in_array($_REQUEST['type'], array('shd_attach', 'shd_thumb')) && !empty($attachments)) $messages = removeAttachments(array('id_attach' => $attachments), '', true); else]]></add> </operation> <operation><!-- add our handling for attachments --> <search position="end" /> <add><![CDATA[ function shd_admin_browse_attachments() { global $context, $txt, $scripturl, $options, $modSettings; global $smcFunc, $sourcedir; $context['browse_type'] = isset($_REQUEST['shd_attach']) ? 'shd_attach' : 'shd_thumb'; // Set the options for the list component. $listOptions = array( 'id' => 'file_list', 'title' => $txt['attachment_manager_' . $context['browse_type']], 'items_per_page' => $modSettings['defaultMaxMessages'], 'base_href' => $scripturl . '?action=admin;area=manageattachments;sa=browse;' . $context['browse_type'], 'default_sort_col' => 'name', 'no_items_label' => $txt['attachment_manager_' . $context['browse_type'] . '_no_entries'], 'get_items' => array( 'function' => 'shd_list_get_files', 'params' => array( $context['browse_type'], ), ), 'get_count' => array( 'function' => 'shd_list_get_num_files', 'params' => array( $context['browse_type'], ), ), 'columns' => array( 'name' => array( 'header' => array( 'value' => $txt['attachment_name'], ), 'data' => array( 'function' => create_function('$rowData', ' global $modSettings, $context, $scripturl; $link = \'<a href="\'; $link .= sprintf(\'%1$s?action=dlattach;ticket=%2$d.0;id=%3$d\', $scripturl, $rowData[\'id_ticket\'], $rowData[\'id_attach\']); $link .= \'"\'; // Show a popup on click if it\'s a picture and we know its dimensions. if (!empty($rowData[\'width\']) && !empty($rowData[\'height\'])) $link .= sprintf(\' onclick="return reqWin(this.href + \\\';image\\\', %1$d, %2$d, true);"\', $rowData[\'width\'] + 20, $rowData[\'height\'] + 20); $link .= sprintf(\'>%1$s</a>\', preg_replace(\'~&#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~\', \'&#\\\\1;\', htmlspecialchars($rowData[\'filename\']))); // Show the dimensions. if (!empty($rowData[\'width\']) && !empty($rowData[\'height\'])) $link .= sprintf(\' <span class="smalltext">%1$dx%2$d</span>\', $rowData[\'width\'], $rowData[\'height\']); return $link; '), ), 'sort' => array( 'default' => 'a.filename', 'reverse' => 'a.filename DESC', ), ), 'filesize' => array( 'header' => array( 'value' => $txt['attachment_file_size'], ), 'data' => array( 'function' => create_function('$rowData',' global $txt; return sprintf(\'%1$s%2$s\', round($rowData[\'size\'] / 1024, 2), $txt[\'kilobyte\']); '), 'class' => 'windowbg', ), 'sort' => array( 'default' => 'a.size', 'reverse' => 'a.size DESC', ), ), 'member' => array( 'header' => array( 'value' => $txt['posted_by'], ), 'data' => array( 'function' => create_function('$rowData', ' global $scripturl; return htmlspecialchars($rowData[\'poster_name\']); '), ), 'sort' => array( 'default' => 'mem.real_name', 'reverse' => 'mem.real_name DESC', ), ), 'date' => array( 'header' => array( 'value' => $txt['date'], ), 'data' => array( 'function' => create_function('$rowData', ' global $txt, $context, $scripturl; return empty($rowData[\'poster_time\']) ? $txt[\'never\'] : timeformat($rowData[\'poster_time\']); '), 'class' => 'windowbg', ), 'sort' => array( 'default' => 'hdtr.id_msg', 'reverse' => 'hdtr.id_msg DESC', ), ), 'downloads' => array( 'header' => array( 'value' => $txt['downloads'], ), 'data' => array( 'function' => create_function('$rowData',' global $txt; return comma_format($rowData[\'downloads\']); '), 'class' => 'windowbg', ), 'sort' => array( 'default' => 'a.downloads', 'reverse' => 'a.downloads DESC', ), ), 'check' => array( 'header' => array( 'value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />', ), 'data' => array( 'sprintf' => array( 'format' => '<input type="checkbox" name="remove[%1$d]" class="input_check" />', 'params' => array( 'id_attach' => false, ), ), 'style' => 'text-align: center', ), ), ), 'form' => array( 'href' => $scripturl . '?action=admin;area=manageattachments;sa=remove;' . $context['browse_type'], 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array( 'type' => $context['browse_type'], ), ), 'additional_rows' => array( array( 'position' => 'below_table_data', 'value' => '<input type="submit" name="remove_submit" class="button_submit" value="' . $txt['quickmod_delete_selected'] . '" onclick="return confirm(\'' . $txt['confirm_delete_attachments'] . '\');" />', 'class' => 'titlebg', 'style' => 'text-align: right;', ), ), ); // Create the list. require_once($sourcedir . '/Subs-List.php'); createList($listOptions); } function shd_list_get_files($start, $items_per_page, $sort, $browse_type) { global $smcFunc, $txt; $request = $smcFunc['db_query']('', ' SELECT hdtr.id_msg, IFNULL(mem.real_name, hdtr.poster_name) AS poster_name, hdtr.poster_time, hdt.id_ticket, hdtr.id_member, a.id_attach, a.filename, a.file_hash, a.attachment_type, a.size, a.width, a.height, a.downloads, hdt.subject FROM {db_prefix}attachments AS a INNER JOIN {db_prefix}helpdesk_attachments AS hda ON (a.id_attach = hda.id_attach) INNER JOIN {db_prefix}helpdesk_tickets AS hdt ON (hda.id_ticket = hdt.id_ticket) INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr ON (hda.id_msg = hdtr.id_msg) LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = hdtr.id_member) WHERE a.attachment_type = {int:attachment_type} ORDER BY {raw:sort} LIMIT {int:start}, {int:per_page}', array( 'attachment_type' => $browse_type === 'shd_thumb' ? '3' : '0', 'sort' => $sort, 'start' => $start, 'per_page' => $items_per_page, ) ); $files = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) $files[] = $row; $smcFunc['db_free_result']($request); return $files; } function shd_list_get_num_files($browse_type) { global $smcFunc; $request = $smcFunc['db_query']('', ' SELECT COUNT(*) AS num_attach FROM {db_prefix}attachments AS a INNER JOIN {db_prefix}helpdesk_attachments AS hda ON (a.id_attach = hda.id_attach) INNER JOIN {db_prefix}helpdesk_tickets AS hdt ON (hda.id_ticket = hdt.id_ticket) INNER JOIN {db_prefix}helpdesk_ticket_replies AS hdtr ON (hda.id_msg = hdtr.id_msg) WHERE a.attachment_type = {int:attachment_type} AND a.id_member = {int:guest_id_member}', array( 'attachment_type' => $browse_type === 'shd_thumb' ? '3' : '0', 'guest_id_member' => 0, ) ); list ($num_files) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); return $num_files; } ]]></add> </operation> </file> <file name="$themedir/ManageAttachments.template.php"> <operation> <search position="before"><![CDATA[$txt['attachment_manager_thumbs'], ']]></search> <add><![CDATA[', (empty($GLOBALS['modSettings']['helpdesk_active']) ? '' : '</a> | <a href="' . $scripturl . '?action=admin;area=manageattachments;sa=browse;shd_attach">' . ($context['browse_type'] == 'shd_attach' ? '<img src="' . $settings['images_url'] . '/selected.gif" alt=">" border="0" /> ' : '') . $txt['attachment_manager_shd_attach'] . '</a> | <a href="' . $scripturl . '?action=admin;area=manageattachments;sa=browse;shd_thumb">' . ($context['browse_type'] == 'shd_thumb' ? '<img src="' . $settings['images_url'] . '/selected.gif" alt=">" border="0" /> ' : '') . $txt['attachment_manager_shd_thumb']), ']]></add> </operation> </file> </modification>