Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - venguard223

#1
The profile area showing the entire editing history of someone can be pretty cool. Not so cool if you get a white screen of death because too much memory got eaten in PHP.

So, let's fix that with some pagination. Bit more complex a fix this, two files needed.

Firstly, SimpleDesk-Profile.php

Code (find) Select
function shd_profile_actionlog($memID)
{
global $context, $txt, $scripturl, $sourcedir, $user_info, $settings;

loadTemplate('sd_template/SimpleDesk-Profile');
shd_load_language('sd_language/SimpleDeskProfile');

require_once($sourcedir . '/sd_source/Subs-SimpleDeskAdmin.php');
$context['action_log'] = shd_load_action_log_entries(0, 10, '', '', 'la.id_member = ' . $memID);
$context['action_log_count'] = shd_count_action_log_entries('la.id_member = ' . $memID);
$context['action_full_log'] = allowedTo('admin_forum') || shd_allowed_to('admin_helpdesk', 0);

$context['page_title'] = $txt['shd_profile_area'] . ' - ' . $txt['shd_profile_actionlog'];
$context['sub_template'] = 'shd_profile_actionlog';

}


(your copy may or may not have that odd empty line... just replace the entire function definition)

Code (replace) Select
function shd_profile_actionlog($memID)
{
global $context, $txt, $scripturl, $sourcedir, $user_info, $settings;

loadTemplate('sd_template/SimpleDesk-Profile');
shd_load_language('sd_language/SimpleDeskProfile');

require_once($sourcedir . '/sd_source/Subs-SimpleDeskAdmin.php');
$context['action_log_count'] = shd_count_action_log_entries('la.id_member = ' . $memID);
$context['displaypage'] = 30;
$context['start'] = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
if ($context['start'] < 0 || $context['start'] >= $context['action_log_count'])
$context['start'] = 0;
$context['action_log'] = shd_load_action_log_entries($context['start'], $context['displaypage'], '', '', 'la.id_member = ' . $memID);
$context['action_full_log'] = allowedTo('admin_forum') || shd_allowed_to('admin_helpdesk', 0);
$context['page_index'] = shd_no_expand_pageindex($scripturl . '?action=profile;area=hd_actionlog;u=' . $memID, $context['start'], $context['action_log_count'], $context['displaypage']);
$context['page_title'] = $txt['shd_profile_area'] . ' - ' . $txt['shd_profile_actionlog'];
$context['sub_template'] = 'shd_profile_actionlog';
}


This does the actual pagination under the hood. Now we have to display it.

SimpleDesk-Profile.template.php

function template_shd_profile_actionlog()
{
global $context, $settings, $txt, $scripturl;

echo '
<div class="tborder">
<div class="cat_bar grid_header">
<h3 class="catbg" id="ticket_log_header">
<img src="', $settings['default_images_url'], '/simpledesk/log.png" class="icon" alt="*" />
', sprintf($txt['shd_profile_log'], $context['member']['name']), '
<span class="smalltext">(', $context['action_log_count'] == 1 ? $txt['shd_profile_log_count_one'] : sprintf($txt['shd_profile_log_count_more'], $context['action_log_count']) , ')</span>
</h3>
</div>


Code (replace) Select
function template_shd_profile_actionlog()
{
global $context, $settings, $txt, $scripturl;

echo '
<div class="title_bar">
<h3 class="titlebg">
<span class="smalltext">', $txt['pages'], ': ', $context['page_index'], '</span>
</h3>
</div>
<div class="tborder">
<div class="cat_bar grid_header">
<h3 class="catbg" id="ticket_log_header">
<img src="', $settings['default_images_url'], '/simpledesk/log.png" class="icon" alt="*" />
', sprintf($txt['shd_profile_log'], $context['member']['name']), '
<span class="smalltext">(', $context['action_log_count'] == 1 ? $txt['shd_profile_log_count_one'] : sprintf($txt['shd_profile_log_count_more'], $context['action_log_count']) , ')</span>
</h3>
</div>


It's not pretty but it should give you pagination on the profile area log.
#2
tfs asked me to look at this, where large text custom fields were re-encoding br tags unnecessarily.

I'd submit a pull request to Github about this but I'm wary of doing it because I see other changes that I don't like the look of. But first, the SMF 2.0 / SD 2.0 changes. These should be good for any current version out there.

Very simple, one change to Subs-SimpleDeskPost.php, line 846 onwards.

Code (find) Select
if (isset($field_values[$row['id_field']]))
{
if ($context['ticket_form']['custom_fields'][$loc][$row['id_field']]['type'] == CFIELD_TYPE_MULTI)
$field_values[$row['id_field']] = explode(',', $field_values[$row['id_field']]);
$context['ticket_form']['custom_fields'][$loc][$row['id_field']]['value'] = $field_values[$row['id_field']];
}


Code (replace) Select
if (isset($field_values[$row['id_field']]))
{
if ($context['ticket_form']['custom_fields'][$loc][$row['id_field']]['type'] == CFIELD_TYPE_MULTI)
$field_values[$row['id_field']] = explode(',', $field_values[$row['id_field']]);
if ($context['ticket_form']['custom_fields'][$loc][$row['id_field']]['type'] == CFIELD_TYPE_LARGETEXT)
$field_values[$row['id_field']] = un_preparsecode($field_values[$row['id_field']]);
$context['ticket_form']['custom_fields'][$loc][$row['id_field']]['value'] = $field_values[$row['id_field']];
}


Just add those two lines before the final line of that block.


Now for what's in Github. Github looks like it's been modified for SMF 2.1 - I don't know if it's properly compatible, but I imagine it probably is since the work's been by emanuele.

The relevant block in Github is:
if (isset($field_values[$row['id_field']]))
{
if ($context['ticket_form']['custom_fields'][$loc][$row['id_field']]['type'] == CFIELD_TYPE_MULTI)
$field_values[$row['id_field']] = explode(',', $field_values[$row['id_field']]);

// Large text boxes may need fixing.
if ($context['ticket_form']['custom_fields'][$loc][$row['id_field']]['type'] == CFIELD_TYPE_LARGETEXT)
{
require_once($sourcedir . '/Subs-Editor.php');

$field_values[$row['id_field']] = html_to_bbc($field_values[$row['id_field']]);
}

$context['ticket_form']['custom_fields'][$loc][$row['id_field']]['value'] = $field_values[$row['id_field']];
}


I can only imagine that the html_to_bbc call is for the benefit of this fix, and that it should be what I've suggested above, however I don't know if other changes to the custom fields were made that meant it does have HTML parsing (I never gave it HTML parsing, only BBC parsing) so I don't want to submit a pull request in case it's irrelevant, but this is certainly something to think about.

I've tested this change locally and it works for me (and I can't seem to break it) but I can't believe I didn't spot it before somehow, there aren't any comments from me in the source reflecting it, put it that way.
#3
I find it interesting that just about every support request is how to configure the permissions.

I shouldn't have done what I did with them, but I dunno, I couldn't think of anything that actually worked better... and in the two years since I wrote it, I still can't think of anything better to do the job that did.

But I feel bad for all the support issues because people don't understand it :(