Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Fixes #104

Merged
merged 1 commit into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions install-sd.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
sd_upgrade_recreate_search();
sd_upgrade_fix_last_updated();
sd_upgrade_convert_serialize();
sd_reconfigure_integrate();

// Are we done?
if (SMF == 'SSI')
Expand Down Expand Up @@ -898,4 +899,17 @@ function sd_upgrade_convert_serialize()
$smcFunc['db_free_result']($request);

}
}

// Reconfigure stuff that we disable during uninstall.
function sd_reconfigure_integrate()
{
global $modSettings;

// Add the integrate actions, if its still there.
if (!empty($modSettings['shd_helpdesk_only']))
{
add_integration_function('integrate_default_action', 'shd_main', true, '$sourcedir/sd_source/SimpleDesk.php');
add_integration_function('integrate_fallback_action', 'shd_main', true, '$sourcedir/sd_source/SimpleDesk.php');
}
}
8 changes: 3 additions & 5 deletions sd_source/SimpleDesk-Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,9 @@ function switchitems()
if (isset($_GET['save']))
{
// SMF 2.1 has a hook for the default action. Lets trigger it.
if (isset($_POST['shd_helpdesk_only']))
{
add_integration_function('integrate_default_action', 'shd_main', true, '$sourcedir/sd_source/SimpleDesk.php');
add_integration_function('integrate_fallback_action', 'shd_main', true, '$sourcedir/sd_source/SimpleDesk.php');
}
$integrate_function = !empty($_POST['shd_helpdesk_only']) ? 'add_integration_function' : 'remove_integration_function';
$integrate_function('integrate_default_action', 'shd_main', true, '$sourcedir/sd_source/SimpleDesk.php');
$integrate_function('integrate_fallback_action', 'shd_main', true, '$sourcedir/sd_source/SimpleDesk.php');
}

return $config_vars;
Expand Down
23 changes: 2 additions & 21 deletions sd_source/SimpleDesk-Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,27 +214,8 @@ function shd_profile_frontpage($memID)
$ban_query_vars = array('time' => time());
$ban_query[] = 'id_member = ' . $context['member']['id'];

// Valid IP?
if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $memberContext[$memID]['ip'], $ip_parts) == 1)
{
$ban_query[] = '((' . $ip_parts[1] . ' BETWEEN bi.ip_low1 AND bi.ip_high1)
AND (' . $ip_parts[2] . ' BETWEEN bi.ip_low2 AND bi.ip_high2)
AND (' . $ip_parts[3] . ' BETWEEN bi.ip_low3 AND bi.ip_high3)
AND (' . $ip_parts[4] . ' BETWEEN bi.ip_low4 AND bi.ip_high4))';

// Do we have a hostname already?
if (!empty($context['member']['hostname']))
{
$ban_query[] = '({string:hostname} LIKE hostname)';
$ban_query_vars['hostname'] = $context['member']['hostname'];
}
}
// Use '255.255.255.255' for 'unknown' - it's not valid anyway.
elseif ($memberContext[$memID]['ip'] == 'unknown')
$ban_query[] = '(bi.ip_low1 = 255 AND bi.ip_high1 = 255
AND bi.ip_low2 = 255 AND bi.ip_high2 = 255
AND bi.ip_low3 = 255 AND bi.ip_high3 = 255
AND bi.ip_low4 = 255 AND bi.ip_high4 = 255)';
$ban_query[] = ' {inet:ip} BETWEEN bi.ip_low and bi.ip_high';
$ban_query_vars['ip'] = $memberContext[$memID]['ip'];

// Check their email as well...
if (strlen($context['member']['email']) != 0)
Expand Down
3 changes: 2 additions & 1 deletion sd_source/SimpleDesk.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ function shd_main_dept()
// Get the departments and order them in the same order they would be on the board index.
$context['dept_list'] = array();
$query = $smcFunc['db_query']('', '
SELECT hdd.id_dept, hdd.dept_name
SELECT hdd.id_dept, hdd.dept_name, hdd.description
FROM {db_prefix}helpdesk_depts AS hdd
WHERE hdd.id_dept IN ({array_int:depts})
ORDER BY hdd.dept_order',
Expand All @@ -506,6 +506,7 @@ function shd_main_dept()
$context['dept_list'][$row['id_dept']] = array(
'id_dept' => $row['id_dept'],
'dept_name' => $row['dept_name'],
'description' => !empty($row['description']) ? parse_bbc($row['description']) : '',
'tickets' => array(
'open' => 0,
'closed' => 0,
Expand Down
2 changes: 1 addition & 1 deletion sd_source/Subs-SimpleDeskAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ function shd_admin_log_configvar($save_vars)
'action' => 'update',
'setting' => $var[1],
'type' => $var[0],
'from' => $modSettings[$var[1]],
'from' => isset($modSettings[$var[1]]) ? $modSettings[$var[1]] : null,
'to' => $newValue,
));
}
Expand Down
34 changes: 24 additions & 10 deletions sd_template/SimpleDesk.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ function template_main()
// Start the ticket listing
foreach ($context['ticket_block_order'] as $block)
{
// Nothing for this block.
if (empty($context['ticket_blocks'][$block]))
continue;

$context['current_block'] = $block;
if (!empty($context['ticket_blocks'][$block]['count']) && $context['ticket_blocks'][$block]['count'] > 10)
$context['block_link'] = $context['shd_current_subaction'] == 'viewblock' ? $scripturl . '?' . $context['shd_home'] . $context['shd_dept_link'] : $scripturl . '?action=helpdesk;sa=viewblock;block=' . $block . $context['shd_dept_link'] . '#shd_block_' . $block;
Expand Down Expand Up @@ -121,8 +125,8 @@ function template_shd_depts()
', $txt['shd_departments'], '
</h3>
</div>
<table class="table_grid">
<tbody class="content">';

<div id="category_helpdesk" class="boardindex_table">';

foreach ($context['dept_list'] as $dept)
{
Expand All @@ -133,17 +137,27 @@ function template_shd_depts()
$icon = $settings['default_theme_url'] . '/images/simpledesk/helpdesk_' . $state . '.png';

echo '
<tr class="windowbg2">
<td class="icon windowbg"><img src="', $icon, '" alt="*"></td>
<td class="info"><a href="', $scripturl, '?', $context['shd_home'], ';dept=', $dept['id_dept'], '">', $dept['dept_name'], '</a></td>
<td class="stats windowbg">', $dept['tickets']['open'], ' open<br>', $dept['tickets']['closed'], ' closed</td>
<td class="lastpost"></td>
</tr>';
<div id="board_shd', $dept['id_dept'], '" class="up_contain">
<div class="board_icon">
<img src="', $icon, '"/>
</div>
<div class="info">
<a class="subject mobile_subject" href="', $scripturl, '?', $context['shd_home'], ';dept=', $dept['id_dept'], '">', $dept['dept_name'], '</a>
<div class="board_description">', $dept['description'], '</div>
</div>
<div class="board_stats">
<p>
', $dept['tickets']['open'], ' ', $txt['shd_tickets_open'], '<br>
', $dept['tickets']['closed'], ' ', $txt['shd_tickets_closed'], '
</p>
</div>
<div class="lastpost hidden">
</div>
</div>';
}

echo '
</tbody>
</table>
</div>
</div>';
}

Expand Down
4 changes: 4 additions & 0 deletions uninstall-sd-required.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@
'hooks' => $shd_hooks,
)
);

// Remove the integrate actions.
remove_integration_function('integrate_default_action', 'shd_main', true, '$sourcedir/sd_source/SimpleDesk.php');
remove_integration_function('integrate_fallback_action', 'shd_main', true, '$sourcedir/sd_source/SimpleDesk.php');