Skip to content

Commit

Permalink
Fixes #346 - Fixes #347
Browse files Browse the repository at this point in the history
Show Sidebox UCP Setting Rework
  • Loading branch information
Mark Vincent committed Oct 13, 2018
1 parent 211c105 commit 41da1d3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
35 changes: 9 additions & 26 deletions Upload/inc/plugins/asb/forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,41 +386,24 @@ function asb_initialize()
*/
function asbUserCpOptionsEnd()
{
global $db, $mybb, $templates, $user, $lang;
global $db, $mybb, $templates, $user, $lang, $asbShowSideboxes;

if (!$lang->asb) {
$lang->load('asb');
}

// if the form is being submitted save the users choice.
// if the form is being submitted save the users choice.
if ($mybb->request_method == 'post') {
$db->update_query('users', array('show_sidebox' => (int) $mybb->input['showsidebox']), "uid='{$user['uid']}'");
return;
}

// don't be silly and waste a query :p (thanks Destroy666)
if (!$lang->asb) {
$lang->load('asb');
}

// don't be silly and waste a query :p (thanks Destroy666)
if ($mybb->user['show_sidebox'] > 0) {
// checked
$checked = 'checked="checked" ';
}

$userCpOption = <<<EOF
<td valign="top" width="1">
<input type="checkbox" class="checkbox" name="showsidebox" id="showsidebox" value="1" {$checked}/>
</td>
<td>
<span class="smalltext"><label for="showsidebox">{$lang->asb_show_sidebox}</label></span>
</td>
</tr>
<tr>
<td valign="top" width="1">
<input type="checkbox" class="checkbox" name="showredirect"
EOF;

// update the template cache
$find = <<<EOF
<td valign="top" width="1"><input type="checkbox" class="checkbox" name="showredirect"
EOF;
$templates->cache['usercp_options'] = str_replace($find, $userCpOption, $templates->cache['usercp_options']);
eval("\$asbShowSideboxes = \"{$templates->get('asb_ucp_show_sidebox_option')}\";");
}

/**
Expand Down
6 changes: 6 additions & 0 deletions Upload/inc/plugins/asb/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ function asb_activate()

// change the permissions to on by default
change_admin_permission('config', 'asb');

require_once MYBB_ROOT . '/inc/adminfunctions_templates.php';
find_replace_templatesets('usercp_options', "#" . preg_quote('{$board_style}') . "#i", '{$asbShowSideboxes}{$board_style}');
}

/**
Expand All @@ -179,6 +182,9 @@ function asb_deactivate()
{
// remove the permissions
change_admin_permission('config', 'asb', -1);

require_once MYBB_ROOT . '/inc/adminfunctions_templates.php';
find_replace_templatesets('usercp_options', "#" . preg_quote('{$asbShowSideboxes}') . "#i", '');
}

/**
Expand Down
12 changes: 12 additions & 0 deletions Upload/inc/plugins/asb/install_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,18 @@
<div class="expcolimage">
<img src="{\$theme['imgdir']}/{\$expcolimage}" id="{\$sidebox['expcolimage_id']}" class="expander" alt="{\$expaltext}" title="{\$expaltext}"/>
</div>
EOF
,
'asb_ucp_show_sidebox_option' => <<<EOF
<tr>
<td valign="top" width="1">
<input type="checkbox" class="checkbox" name="showsidebox" id="showsidebox" value="1" {\$checked}/>
</td>
<td>
<span class="smalltext"><label for="showsidebox">{\$lang->asb_show_sidebox}</label></span>
</td>
</tr>
EOF
),
),
Expand Down

0 comments on commit 41da1d3

Please sign in to comment.