My work is being featured in IPB SDK 27 replies

Please wait...

Tango Protocol

Master of my own domain

50 XP

18th July 2003

0 Uploads

8,283 Posts

0 Threads

#1 12 years ago

There is software called IPB SDK that allows webmasters to integrate their websites into their forums (to share information and to make it interact with the forums and all that jazz).. well, when I was coding something for Universium yesterday, I needed a function that did not yet exist in the IPB SDK. This function would return positive feedback if the user belongs to one of of the specified SECONDARY groups on the forums. Because IPB uses primary groups and secondary group (primary the one being showed in profiles, the secondary is "hidden")

the SDK had a function to do what I needed, but it would only look in the user's primary group, instead of both.

So I wrote a function that would scan secondary groups as well... and the author of the SDK said that my code will be incorporated into the next version release.

Link: Official IPB SDK Forum

Final code: [php] function is_ingroup($groups,$member='') { global $SDK; if ($SDK->is_ingroup($groups, $member) or is_in2group($groups, $member)) { return true; } else { return false; } } function is_in2group($groups, $member='') { global $SDK; $sdk_userinfo = $SDK->get_advinfo($member); $sdk_userinfo_altgroups = $sdk_userinfo['mgroup_others']; $sdk_array = explode(",", $sdk_userinfo_altgroups);

if (is_array($groups)) {

foreach ($groups as $g) { if (in_array($g, $sdk_array)) { if (!$x) { $x = true; } } } } else { if (in_array($groups, $sdk_array)) { $x = true; } } if ($x) { return true; } else { return false; } } [/php] Documentation: standalone function is_ingroup ( groupID [array OR int], memberid [int] )

Well return true if user memberid is in any of the groups specified in groupID. Will also return true if groupID matches any of the user memberid secondary groups

--

standalone function is_in2group ( groupID [array OR int], memberid [int] )

Will return true if user memberid has secondary usergroup that matches an entry in groupID

I just thought I'd share that. I thought it was pretty cool that a lot of the IPB community may be using my code in a few weeks




PC Chipmunk VIP Member

Please don't kick.

50 XP

9th July 2005

0 Uploads

7,866 Posts

0 Threads

#2 12 years ago

I don't think I understood much of that....but well done Knipps :nodding:




Biggus Dickus VIP Member

I would die without my life.

195,640 XP

19th January 2004

0 Uploads

18,764 Posts

0 Threads

#3 12 years ago

Hmm...Just for information, would it be possible to do this: function is_ingroup($groups,$member='') { global $SDK; return ($SDK->is_ingroup($groups, $member) or is_in2group($groups, $member)) ? true : false; } instead of this: function is_ingroup($groups,$member='') { global $SDK; if ($SDK->is_ingroup($groups, $member) or is_in2group($groups, $member)) { return true; } else { return false; } } It's exactly the same thing with less lines. I don't know if it's allowed in this language.




Tango Protocol

Master of my own domain

50 XP

18th July 2003

0 Uploads

8,283 Posts

0 Threads

#4 12 years ago

Basically something I did for myself to add functionality to software is being "officially" added as functionality.




Tango Protocol

Master of my own domain

50 XP

18th July 2003

0 Uploads

8,283 Posts

0 Threads

#5 12 years ago
Biggus DickusHmm...Just for information, would it be possible to do this: function is_ingroup($groups,$member='') { global $SDK; return ($SDK->is_ingroup($groups, $member) or is_in2group($groups, $member)) ? true : false; } instead of this: function is_ingroup($groups,$member='') { global $SDK; if ($SDK->is_ingroup($groups, $member) or is_in2group($groups, $member)) { return true; } else { return false; } } It's exactly the same thing with less lines. I don't know if it's allowed in this language.

I've never seen that in PHP, it'd probably give you a parse error




nowhereman

For KAVATCH!!!

50 XP

20th April 2005

0 Uploads

1,906 Posts

0 Threads

#6 12 years ago
It's exactly the same thing with less lines. I don't know if it's allowed in this language.

I dont think that that is allowed. Some languages don't like you putting alot of stuff on one line. But it might work i'm not too familiar with PHP.

Also nice work Knippschild.




*The.Doctor

Trust me, I'm a Doctor

102,440 XP

25th November 2003

0 Uploads

9,964 Posts

0 Threads

#7 12 years ago

I don't know what all that code means, but congrats on your work being used!




Tango Protocol

Master of my own domain

50 XP

18th July 2003

0 Uploads

8,283 Posts

0 Threads

#8 12 years ago

Thanks!

I'm just gonna get my name above the code in PHP comments, but.. good enough for me.




DavetheFo

RogueDevil / Rogue Angel

50 XP

29th May 2003

0 Uploads

8,689 Posts

0 Threads

#9 12 years ago

Well Done Mr Knipp!

Thats some very nippy work there.

I'll go get my coat.




mentalmagic

Just Do It.

50 XP

12th January 2006

0 Uploads

3,458 Posts

0 Threads

#10 12 years ago

No idea what it means, but congrats all the same...