Disabling expand/collapse per user?
 
 
Post new topic   Reply to topic   printer-friendly view    phpMiX.org Forum Index -> phpBB MODs -> Select Expand BBCodes
View previous topic :: View next topic  
Author Message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Thu Mar 23, 2006 6:10 am    Post subject: Disabling expand/collapse per user? Reply with quote

I had to restore the database and this topic from Smudge was lost. Embarassed Let's see if I can rebuild the question...

So a new tinyint(1) field has been created in the user table to provide users with the ability to disable the expand/collapse feature of SXBB (from their profile, I guess). Sorry, Smudge, I do not recall the name of the field. Let's say it is user_sxbb_enabled and it contains 1 when the feature is enabled, otherwise it is 0.

I think the easiest way to tell SXBB to disable this feature is by forcing the function SXBB_IsOverflowAble (from select_expand_bbcodes.js) to return false when a user has the feature disabled, so SXBB reacts as if the browser was not supporting that feature. ie. the code/quote boxes will remain expaned. You could see this effect disabling javascript in your browser.

My first proposed solution didn't work. Maybe the following works?

OPEN: viewtopic.php

FIND:
Code:
$template->set_filenames(array(
   'body' => 'viewtopic_body.tpl')
);

BEFORE, ADD:
Code:
if ($userdata['user_sxbb_enabled'] == 0)
{
   $template->assign_block_vars('sxbb_expand_disabled', array());
}


OPEN: viewtopic_body.tpl

On top of the file, ADD:
Code:
<!-- BEGIN sxbb_expand_disabled -->
<script type="text/javascript">
var SXBB_expand_disabled = true;
</script>
<!-- END sxbb_expand_disabled -->


OPEN: select_expand_bbcodes.js

FIND:
Code:
function SXBB_IsOverflowAble()
{

AFTER, ADD:
Code:
   if (typeof(SXBB_expand_disabled) != 'undefined')
   {
      return false;
   }

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Smudge
Apprentice
Apprentice


Joined: 23 Mar 2006
Posts: 5

PostPosted: Thu Mar 23, 2006 6:20 am    Post subject: Reply with quote

Yes, it works. If the variable is set to 0, the code/quote boxes are expanded out and don't have the Contract option. The Select option is still available.

Hopefully this will make my forum users happy.

Thanks markus.
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Thu Mar 23, 2006 6:22 am    Post subject: Reply with quote

Sweet! Ok Left
 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Smudge
Apprentice
Apprentice


Joined: 23 Mar 2006
Posts: 5

PostPosted: Thu Mar 23, 2006 6:43 am    Post subject: Reply with quote

I have taken this one step further. Based on my original idea of disabling the str_replace in bbcode.php (I know you said it would disable SXBB which is what I originally wanted. I didn't think about just disabling the Expand option like you have), I now have 3 options by changing the variable.
0 = disabled completely. Normal quote/code boxes
1 = expanded boxes, select still available
2 = normal select/expand options and views

Let me know if you see anything wrong with this idea. I've been testing it for a few minutes and it all seems to be working.

do the changes above then

OPEN: includes\bbcode.php

FIND:
Code:
   //+MOD: Select Expand BBcodes MOD
      global $phpbb_root_path;


REPLACE WITH:
Code:
   //+MOD: Select Expand BBcodes MOD
      global $userdata,$phpbb_root_path;
      if ($userdata['user_quote_format'] > 0) {


FIND:
Code:
   //-MOD: Select Expand BBcodes MOD


REPLACE WITH:
Code:
      }
   //-MOD: Select Expand BBcodes MOD
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Thu Mar 23, 2006 6:54 am    Post subject: Reply with quote

Nope. That won't work. The code added by this MOD in bbcode.php is used to replace text in the code that comes from bbcode.tpl, where the HTML used to render BBCodes is located. Ignoring that code would render a broken SXBB.

If you're committed to providing a different version of the HTML used to render BBCodes, you would have to create a separate bbcode.tpl file, say bbcode2.tpl and load that one depending on user settings or whatever.

Check out function load_bbcode_template() in bbcode.php to see where bbcode.tpl is loaded.

See what I mean?

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Thu Mar 23, 2006 6:58 am    Post subject: Reply with quote

hmm... it would be much easier to provide these options by using a different style. You could install the .tpl changes of this MOD on one style and not on a another style. So your users can choose the style that better suit their needs.

I think. And no, the php side will not get broken if a style doesn't have SXBB in it.

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Smudge
Apprentice
Apprentice


Joined: 23 Mar 2006
Posts: 5

PostPosted: Thu Mar 23, 2006 7:06 am    Post subject: Reply with quote

the different style is a good idea but you say my mod won't work but yet it does. I've tried it with Avant Browser (IE engine) and Netscape 8.1 (both IE and FF engines). 
Back to top
View user's profile Send private message
Smudge
Apprentice
Apprentice


Joined: 23 Mar 2006
Posts: 5

PostPosted: Thu Mar 23, 2006 7:11 am    Post subject: Reply with quote

oh, and I just noticed that you used 'user_sxbb_enabled' and I used 'user_quote_format' in my mod instructions but I can't edit my posts. 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Thu Mar 23, 2006 7:12 am    Post subject: Reply with quote

It works in that it doesn't show the select/expand labels, but it probably generates javascript errors. Look at the source of the page, SXBB is broken. Wink
 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Smudge
Apprentice
Apprentice


Joined: 23 Mar 2006
Posts: 5

PostPosted: Thu Mar 23, 2006 7:29 am    Post subject: Reply with quote

Turned on "Display a notification of every script error" but didn't receive any errors. 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Thu Mar 23, 2006 8:50 am    Post subject: Reply with quote

Then great. I was mostly guessing, but if it works, it works.

Glad you got it.

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    phpMiX.org Forum Index -> phpBB MODs -> Select Expand BBCodes All times are GMT + 1 Hour
 
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum