MyBB Hacks

Full Version: XThreads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can you explain your setup a little more?  Your first post seems to say that you have a listbox, but you don't want group B seeing some of the items in it.  Your second post seems to say that you have two separate fields instead, and you don't want group B to see the second field?

Hiding the (not set) value basically does the same thing as requiring entry.  If you're using templates to hide the input field entirely from some users (assuming not group because you could just change the Editable value), put in a hidden input field set to any valid value that you wish it to be.
Ok, sorry to be unclear. The problem is with listboxes AND radio buttons showing the NOT SET when it is not using the "everyone required" setting.

I have this wedding I have to make a signup forum for and there is
Ceremony (Attending) - (Custom thread field1 yes/no - radio button) & (# of guests) - (Custom thread field2 1 or 2 or 3 or 4 - listbox)
Private lunch (Attending) -  (Custom thread field3 yes/no - radio button) & (# of guests) - (Custom thread field4 1 or 2 or 3 or 4 - listbox)
Evening party  (Attending) - (Custom thread field5 yes/no - radio button) & (# of guests) - (Custom thread field6 1 or 2 or 3 or 4 - listbox)

The grouping is by user group - there are about 200 guests, so I don't think I can do it by user.

The private lunch (fields 3 and 4) is the only one that is not required by everyone - just for one usergroup - thats one radio button, one listbox. It just looks odd on the inputs when some of the fields have the (not set).

The marrieds to be are hoping I can give them reports on how many guests etc per part of the day - so for querying the database later I thought this would be the best set up.
I did try setting the default value to NO and default guests to 0 for these lunch fields, and then making them a hidden field.  But when I tested the error came up that I had not filled in a required field. Eg.I set group A as not able to edit the field - But for group B it is a required field - so it fails for group A or Group B see the not set with the risk that they may not fill the field in.

Link to site in progress if you are interested...  ttp://brownpaperbag.eu/index.php
Oh, okay, I see what you mean now - thanks for the explanation.
Unfortunately the 'required' thing was meant to be more of a data constraint so making it required would mean that everyone needs to be able to set a value to it.  If it was only editable to a certain group and yet required, then the group which can't edit it would never be able to set a value, thus they'll never be able to fill the required constraint and never be able to create a thread.

Your issue can be solved if I implement permissions for individual values as I said earlier.  Basically it means that group B won't be allowed to leave the field as blank.
I see, I kind of thought that was so, but I thought it was worth a try to ask (if you don't ask, you won't find out....).

Well, I think IF this could be added it would be a major bonus - in the meantime I will explain to my rapidly less best best friend that she will just have to live with the brackets and the not set Smile
Sorry to post here, but I don't have permissions to post in the Template Conditionals forum (maybe that's a hint) but I am plodding on with this wedding forum thing. (see above posts)

My "client" does not wish the wedding guests to realise that not all guests are equal and that some have been invited to a slap up lunch whilst the rest can go buy a sandwich.... Therefore I cannot use coloured usergroups or things like that - there are two usergroups  - with the same title - (which the users do not know about) so I can filter out who is who a bit.

I have an overview of what guests have replied re this lunch (yes or no, number of people) and I have a default value of "not filled in" for these two fields. Unfortunately, as this cannot be a required field, then its possible for an invited lunchee to forget to fill out the field. Then it will get the default value of "not filled in".

I was trying to make an if statement in the forumdisplay_thread template  that basically says

<if thread starter is from usergroup 3 then> N/A<else>custom threadfield value</if> so that it will fill in the N/A instead of the real default value.

I am a bit stuck. Can anyone help?
(02-08-2011 05:09 PM)leefish Wrote: [ -> ]Sorry to post here, but I don't have permissions to post in the Template Conditionals forum
Fixed, thanks.

(02-08-2011 05:09 PM)leefish Wrote: [ -> ]I have an overview of what guests have replied re this lunch (yes or no, number of people) and I have a default value of "not filled in" for these two fields. Unfortunately, as this cannot be a required field, then its possible for an invited lunchee to forget to fill out the field. Then it will get the default value of "not filled in".

I was trying to make an if statement in the forumdisplay_thread template  that basically says

<if thread starter is from usergroup 3 then> N/A<else>custom threadfield value</if> so that it will fill in the N/A instead of the real default value.

I am a bit stuck. Can anyone help?
I don't think there's a particularly neat way to do that from templates.
BTW, it's probably nicer to put it in the Display Format rather than templates.
Since I suspect that performance isn't really an issue, you can probably get around with something like this:

Code:
<setvar user>get_user($thread['uid'])</setvar>
<if $tplvars['user']['usergroup'] == 3 then>a<else>b</if>


I've also pushed usergroup permissions based on values into GitHub if you want to experiment with that to see if it suits your needs.  Basically, you'd make your field editable by only the groups you want to set them, then in the permissions, leave the value as blank (which means Not Set) and only allow Admins to set it to that value.

Thank you very much - that <set var> is what I was looking for - and yes, I think you are right regarding using display format rather than templates.

Re performance - yes, its  a one off site with a sole purpose and a fixed membership - once the wedding has happened site closes.

I will also go take a look at the github code - I think that this will be a popular change Smile
EDIT: I do "proper upgrades" on 'top-level' forums, and cruel hacking and experiments on other test sites.

After the last upgrade I was getting this error on index.php
  • Disclaimer: Normal usage will *not* produce this error!

Code:
The following warnings occurred:
Warning [2] Invalid argument supplied for foreach() - Line: 378 - File: inc/plugins/xthreads.php PHP 5.3.5 (Linux)
File 	Line 	Function
/inc/plugins/xthreads.php 	378 	errorHandler->error
/inc/xthreads/xt_forumdhooks.php 	637 	xthreads_get_tplprefixes
/inc/plugins/xthreads.php 	327 	xthreads_global_forumbits_tpl
[PHP] 	  	xthreads_global
/inc/class_plugins.php 	101 	call_user_func_array
/global.php 	96 	pluginSystem->run_hooks
/index.php 	18 	require_once


The solution is in my next post...

FYI: To Anyone
XThreads includes hooks like these (for example)
...

Code:
$plugins->add_hook('admin_forum_management_edit', 'xthreads_admin_forumedit', 9);
$plugins->add_hook('admin_forum_management_add', 'xthreads_admin_forumedit', 9);
$plugins->add_hook('admin_forum_management_add_commit', 'xthreads_admin_forumcommit');
$plugins->add_hook('admin_forum_management_add_insert_query', 'xthreads_admin_forumcommit_myplazaturbo_fix');
$plugins->add_hook('admin_forum_management_edit_commit', 'xthreads_admin_forumcommit');

...to keep your current forums in sync with XThreads datacache.

If you add or edit forums from an 'external' script, (and also update your forum cache at the same time), then you might need this simple little piece of code:

PHP Code:
<?php
// sync_yzb.php
define('IN_MYBB', 1);
require_once './global.php';
require_once "inc/xthreads/xt_admin.php";
xthreads_buildcache_forums();
echo "Yes!";
?>

  Smile

Thanks for that.  It's a bit crap that I can't hook into the $cache->update_forums() function.  Perhaps this is a reason for not using an external forum cache... Erf
Reference URL's