Skip to content

Commit 41da1d3

Browse files
author
Mark Vincent
committed
Fixes #346 - Fixes #347
Show Sidebox UCP Setting Rework
1 parent 211c105 commit 41da1d3

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

Upload/inc/plugins/asb/forum.php

+9-26
Original file line numberDiff line numberDiff line change
@@ -386,41 +386,24 @@ function asb_initialize()
386386
*/
387387
function asbUserCpOptionsEnd()
388388
{
389-
global $db, $mybb, $templates, $user, $lang;
389+
global $db, $mybb, $templates, $user, $lang, $asbShowSideboxes;
390390

391-
if (!$lang->asb) {
392-
$lang->load('asb');
393-
}
394-
395-
// if the form is being submitted save the users choice.
391+
// if the form is being submitted save the users choice.
396392
if ($mybb->request_method == 'post') {
397393
$db->update_query('users', array('show_sidebox' => (int) $mybb->input['showsidebox']), "uid='{$user['uid']}'");
394+
return;
398395
}
399396

400-
// don't be silly and waste a query :p (thanks Destroy666)
397+
if (!$lang->asb) {
398+
$lang->load('asb');
399+
}
400+
401+
// don't be silly and waste a query :p (thanks Destroy666)
401402
if ($mybb->user['show_sidebox'] > 0) {
402-
// checked
403403
$checked = 'checked="checked" ';
404404
}
405405

406-
$userCpOption = <<<EOF
407-
<td valign="top" width="1">
408-
<input type="checkbox" class="checkbox" name="showsidebox" id="showsidebox" value="1" {$checked}/>
409-
</td>
410-
<td>
411-
<span class="smalltext"><label for="showsidebox">{$lang->asb_show_sidebox}</label></span>
412-
</td>
413-
</tr>
414-
<tr>
415-
<td valign="top" width="1">
416-
<input type="checkbox" class="checkbox" name="showredirect"
417-
EOF;
418-
419-
// update the template cache
420-
$find = <<<EOF
421-
<td valign="top" width="1"><input type="checkbox" class="checkbox" name="showredirect"
422-
EOF;
423-
$templates->cache['usercp_options'] = str_replace($find, $userCpOption, $templates->cache['usercp_options']);
406+
eval("\$asbShowSideboxes = \"{$templates->get('asb_ucp_show_sidebox_option')}\";");
424407
}
425408

426409
/**

Upload/inc/plugins/asb/install.php

+6
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ function asb_activate()
168168

169169
// change the permissions to on by default
170170
change_admin_permission('config', 'asb');
171+
172+
require_once MYBB_ROOT . '/inc/adminfunctions_templates.php';
173+
find_replace_templatesets('usercp_options', "#" . preg_quote('{$board_style}') . "#i", '{$asbShowSideboxes}{$board_style}');
171174
}
172175

173176
/**
@@ -179,6 +182,9 @@ function asb_deactivate()
179182
{
180183
// remove the permissions
181184
change_admin_permission('config', 'asb', -1);
185+
186+
require_once MYBB_ROOT . '/inc/adminfunctions_templates.php';
187+
find_replace_templatesets('usercp_options', "#" . preg_quote('{$asbShowSideboxes}') . "#i", '');
182188
}
183189

184190
/**

Upload/inc/plugins/asb/install_data.php

+12
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,18 @@
243243
<div class="expcolimage">
244244
<img src="{\$theme['imgdir']}/{\$expcolimage}" id="{\$sidebox['expcolimage_id']}" class="expander" alt="{\$expaltext}" title="{\$expaltext}"/>
245245
</div>
246+
EOF
247+
,
248+
'asb_ucp_show_sidebox_option' => <<<EOF
249+
250+
<tr>
251+
<td valign="top" width="1">
252+
<input type="checkbox" class="checkbox" name="showsidebox" id="showsidebox" value="1" {\$checked}/>
253+
</td>
254+
<td>
255+
<span class="smalltext"><label for="showsidebox">{\$lang->asb_show_sidebox}</label></span>
256+
</td>
257+
</tr>
246258
EOF
247259
),
248260
),

0 commit comments

Comments
 (0)