UBB.Dev
Posted By: flint display banner depending on groups - 01/07/2005 1:45 AM
so this is standard invocation code for phpadsnew to display ads from a certain zone, which I have running in UBBT´s header.php:

Code
     if (@include(getenv('DOCUMENT_ROOT').'/php/phpadsnew/phpadsnew.inc.php')) { <br />        if (!isset($phpAds_context)) $phpAds_context = array(); <br />        $phpAds_raw = view_raw ('zone:3', 0, '_blank', '', '0', $phpAds_context); <br />        echo $phpAds_raw['html']; <br />    } 


can anyone please give me a hint on how to abort this, if the viewer belongs to a certain group?

I have already found this useful piece of code,
Code
 if (preg_match("/-6-/",$postergroup))  { <br />   	 echo "wiu wiu wiu"; <br />    } 


but I really don´t know how to combine these too.
I´m busy RTFM, but I still can´t figure out how to do this, I´m more of a photoshop person
Posted By: ksanuk Re: display banner depending on groups - 01/07/2005 3:57 AM
Hi,

Not tested, but my guess would be something like this:

Code
<br />if (preg_match("/-6-/",$postergroup))  {<br />     if (@include(getenv('DOCUMENT_ROOT').'/php/phpadsnew/phpadsnew.inc.php')) {<br />        if (!isset($phpAds_context)) $phpAds_context = array();<br />        $phpAds_raw = view_raw ('zone:3', 0, '_blank', '', '0', $phpAds_context);<br />        echo $phpAds_raw['html'];<br />    } <br />} <br />


On a related note, how would I allow this usergroup to set whether or not they want to see the ads?

Sanuk!
Posted By: flint Re: display banner depending on groups - 01/07/2005 4:51 AM
[]ksanuk said:
Hi,

Not tested, but my guess would be something like this:

Code
<br />if (preg_match("/-6-/",$postergroup))  {<br />     if (@include(getenv('DOCUMENT_ROOT').'/php/phpadsnew/phpadsnew.inc.php')) {<br />        if (!isset($phpAds_context)) $phpAds_context = array();<br />        $phpAds_raw = view_raw ('zone:3', 0, '_blank', '', '0', $phpAds_context);<br />        echo $phpAds_raw['html'];<br />    } <br />} <br />

[/]

just tested it, unfortunately it won´t execute anymore at all, regardless of the group you´re in. Strange ...

[] On a related note, how would I allow this usergroup to set whether or not they want to see the ads? [/]
I have one usergroup called supporters, which are added automatically through mypaymentpal.
Surprisingly, many still want to see ads, because most of our ads are very content related, and not randomly picked.

So I decided to create another group called "noads", and i would allow supporters to choose themselve if they wanted to be part of that group.

For now I´d do it manually, cause we have very few supporters. I could imagine making a switch one day, and only allowing "supporters" to use that switch.
Posted By: JoshPet Re: display banner depending on groups - 01/07/2005 5:19 AM
The header might not know what group you're in, in ubbt.inc.php - find the authenticate function, and add U_Groups to the end of the $Query listed in that function.
Posted By: ksanuk Re: display banner depending on groups - 01/07/2005 7:03 AM
Hi,

"I have one usergroup called supporters, which are added automatically through mypaymentpal.
Surprisingly, many still want to see ads, because most of our ads are very content related, and not randomly picked."

Yes, I am in a similar situation, just trying to come up with as much benefits for paying members as possible.

Sanuk!
Posted By: Twisty Re: display banner depending on groups - 01/07/2005 10:45 AM
The following assumes that your donators are in usergroup 6, and that the ads are also supposed to be seen no matter what by everyone else not in the donator group.

Ok...

You'll have to create a new field in the users table. Run this query...

ALTER TABLE w3t_users ADD U_Ads tinyint(1) NOT NULL default '0'


...and then add a config option in their display preferences section.

editdisplay.php...

Code
$adsyes = ""; <br />$adsno = ""; <br /> <br />if ($ads == 1) { <br />   $adsyes = "selected=\"selected\""; <br />else { <br />   $adsno = "selected=\"selected\""; <br />} 



...which will only appear if they belong to that group and default that selection to 0 (No). You can add the PHP in the template for that.

editdisplay.tmpl...


Code
UBBTPRINT; <br />if ((preg_match("/-6-/",$postergroup)) { <br />echo "Do you wish to see ads?<br /> <br /><select name = \"Adselect\" class=\"formboxes\"> <br /><option value = \"1\"  $adsyes>Yes</option> <br /><option value = \"0\" $adsno>No</option> <br /></select> <br /><br /><br />"; <br />} <br />echo <<<UBBTPRINT 



In changedisplay.php add in the necessary stuff...

Code
// ------------- <br />// Get the input <br />	$Adselect = get_input("Adselect","post"); <br />             if ((empty($Adselect)) || (!Adselect)) { <br />               $Adselect = 0; <br />             } <br /> <br />// ----------------------- <br />// Format the query words <br />   $Adselect_q   = addslashes($Adselect); <br /> <br />// -------------------------- <br />// Update the User's profile <br />   $query = " <br />    UPDATE {$config['tbprefix']}Users <br />    SET U_Ads       = '$Adselect_q', <br />



You'd also have to make sure to authenticate U_Ads in ubbt.inc.php and assign it a variable ($ads).

Then in the header.php ad code, you'd modify it to say something like...

Code
if ( ((preg_match("/-6-/",$postergroup)) && ($ads == 1)) || (!preg_match("/-6-/",$postergroup)) ) { <br />     if (@include(getenv('DOCUMENT_ROOT').'/php/phpadsnew/phpadsnew.inc.php')) { <br />         if (!isset($phpAds_context)) $phpAds_context = array(); <br />         $phpAds_raw = view_raw ('zone:3', 0, '_blank', '', '0', $phpAds_context); <br />         echo $phpAds_raw['html']; <br />    } <br />}   
Posted By: ksanuk Re: display banner depending on groups - 01/07/2005 12:26 PM
Hi,

Thanks. Might give this a go over the weekend.

Sanuk!
Posted By: Twisty Re: display banner depending on groups - 01/07/2005 2:02 PM
Ok, btw I just changed a couple things in the code that weren't quite right.
Posted By: flint Re: display banner depending on groups - 01/08/2005 5:32 PM
Twisty, thanks a million for the code, but can you think of a method that´s based on groups?
I´m a little bit afraid of making changes to the w3t_ fields, bacause one lucky or unlucky day there´ll be an import script, which moves this to a totally different format, I fear.
Posted By: Twisty Re: display banner depending on groups - 01/08/2005 5:54 PM
[]flint said:
Twisty, thanks a million for the code, but can you think of a method that´s based on groups?
[/]

You'd still add the option in their prefs (but forget about creating the new field and authenticating it in ubbt.inc.php as that would no longer be necessary).

What you would then have to do is create a new donars group (-7- in this example), and then in changedisplay.php, do a query and move them from group 6 to group 7 if they selected 'Yes' for wanting ads.

Then in the header code you would limit the ads to be displayed for everyone in group 7, and every not in group 6.
© UBB.Developers