FileFront Forums

FileFront Forums (http://forums.filefront.com/)
-   General Yib-Yab (Off Topic) (http://forums.filefront.com/general-discussion-184/)
-   -   My work is being featured in IPB SDK (http://forums.filefront.com/general-discussion/266689-my-work-being-featured-ipb-sdk.html)

Tango Protocol July 22nd, 2006 11:52 AM

My work is being featured in IPB SDK
 
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 Code:

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; }


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 July 22nd, 2006 12:02 PM

Re: My work is being featured in IPB SDK
 
I don't think I understood much of that....but well done Knipps :nodding:

Biggus Dickus July 22nd, 2006 12:06 PM

Re: My work is being featured in IPB SDK
 
Hmm...Just for information, would it be possible to do this:
Code:

function is_ingroup($groups,$member='') {
        global
$SDK;
        return
($SDK->is_ingroup($groups, $member) or is_in2group($groups, $member)) ? true : false;
}

instead of this:
Code:

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 July 22nd, 2006 12:07 PM

Re: My work is being featured in IPB SDK
 
Basically something I did for myself to add functionality to software is being "officially" added as functionality.

Tango Protocol July 22nd, 2006 12:13 PM

Re: My work is being featured in IPB SDK
 
Quote:

Originally Posted by Biggus Dickus
Hmm...Just for information, would it be possible to do this:
Code:

function is_ingroup($groups,$member='') {
        global
$SDK;
        return
($SDK->is_ingroup($groups, $member) or is_in2group($groups, $member)) ? true : false;
}

instead of this:
Code:

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 July 22nd, 2006 12:32 PM

Re: My work is being featured in IPB SDK
 
Quote:

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 July 22nd, 2006 12:35 PM

Re: My work is being featured in IPB SDK
 
I don't know what all that code means, but congrats on your work being used!

Tango Protocol July 22nd, 2006 12:36 PM

Re: My work is being featured in IPB SDK
 
Thanks!

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

DavetheFo July 22nd, 2006 12:52 PM

Re: My work is being featured in IPB SDK
 
Well Done Mr Knipp!

Thats some very nippy work there.








I'll go get my coat.

mentalmagic July 22nd, 2006 12:53 PM

Re: My work is being featured in IPB SDK
 
No idea what it means, but congrats all the same...

Biggus Dickus July 22nd, 2006 12:55 PM

Re: My work is being featured in IPB SDK
 
Quote:

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

I asked it because this language looks a bit like java or c++. But I can be wrong.

Sheepeep July 22nd, 2006 12:57 PM

Re: My work is being featured in IPB SDK
 
Hrm, I never thought of contributing to someone else's project with my own PHP knowledge...

Ah well, good job. :p

Tango Protocol July 22nd, 2006 12:58 PM

Re: My work is being featured in IPB SDK
 
Quote:

Originally Posted by Sheepeep
Hrm, I never thought of contributing to someone else's project with my own PHP knowledge...

Ah well, good job. :p

You should, it gives you a warm fuzzy feeling inside

Sheepeep July 22nd, 2006 01:01 PM

Re: My work is being featured in IPB SDK
 
Quote:

Originally Posted by Knippschild
You should, it gives you a warm fuzzy feeling inside

Well, yeah, I should...But I write all my own PHP software and thus have little experience with other peoples'. And since more and more people are starting to charge for their PHP-based products, it gets harder still to contribute to them. Shame, I guess.

Tango Protocol July 22nd, 2006 01:08 PM

Re: My work is being featured in IPB SDK
 
Well if you contribute code that they later charge for (which is totally bogus; it's opensource software) you can demand royalties :)

Sheepeep July 22nd, 2006 01:10 PM

Re: My work is being featured in IPB SDK
 
Quote:

Originally Posted by Knippschild
Well if you contribute code that they later charge for (which is totally bogus; it's opensource software) you can demand royalties :)

I think you just gave me something to do for after I finish my own personal project. Contribute to a million other projects and wait a few years...Then have my three lines removed and replaced by something else. :p

Tango Protocol July 22nd, 2006 04:26 PM

Re: My work is being featured in IPB SDK
 
Quote:

Originally Posted by Sheepeep
I think you just gave me something to do for after I finish my own personal project. Contribute to a million other projects and wait a few years...Then have my three lines removed and replaced by something else. :p

Hey, sometimes that happens...

Revenge July 22nd, 2006 04:40 PM

Re: My work is being featured in IPB SDK
 
Quote:

Originally Posted by Biggus Dickus
Hmm...Just for information, would it be possible to do this:
Code:

function is_ingroup($groups,$member='') {
        global
$SDK;
        return
($SDK->is_ingroup($groups, $member) or is_in2group($groups, $member)) ? true : false;
}

instead of this:
Code:

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.

Yep, that would work. It's used for the vBulletin plugin system alot, and it prevents an extra function call. If you know the ELSE function will just return FALSE, then there is no need to have an overhead of calling the else function. Therefore there is a method, like in C (since PHP is based on C) for returning FALSE automatically if the IF condition is false without calling ELSE.

Even though the ELSE function (if you can call it that) is obviously embedded so that it is hideously fast when used, it's still more than the parser needs to know.

Knippy, does $SDK->get_advinfo($member) generate a query? If so, it's probably a better idea for the Invision guys to incorporate all usergroups into their is_ingroup() function rather than just the first, and query it all at once (I've not used Invision for around a year - presuming the primary and secondary usergroups are stored in the same table). Well done nevertheless.

Tango Protocol July 22nd, 2006 04:54 PM

Re: My work is being featured in IPB SDK
 
Quote:

Originally Posted by Reven
Knippy, does $SDK->get_advinfo($member) generate a query? If so, it's probably a better idea for the Invision guys to incorporate all usergroups into their is_ingroup() function rather than just the first, and query it all at once (I've not used Invision for around a year - presuming the primary and secondary usergroups are stored in the same table). Well done nevertheless.

$SDK->get_advinfo is an object calling which pulls all of $member's attributes in the database. if the param is blank, it returns the info of the currently logged in user.

the SDK is developed by a different group than IPB is.

so basically get_advinfo returns stuff like

username
displayname
warn
posts
mgroup
mgroup_others [secondary groups are stored here]

Revenge July 22nd, 2006 04:57 PM

Re: My work is being featured in IPB SDK
 
Ah, so it's kind of like PEAR then?

I prefer to make a list of usergroups a member is part of (primary usergroup being the first in the list) and put it into CSV format in the database, so it uses one cell. Then call it and explode() it.

Tango Protocol July 22nd, 2006 05:03 PM

Re: My work is being featured in IPB SDK
 
well it stores mgroup as one interger

then mgroup_others is a CSV of all other groups the user is a secondary of.

Dr.Fritz July 22nd, 2006 08:55 PM

Re: My work is being featured in IPB SDK
 
I have no idea what that means, but good job finding it Knipps. :)

Panzer~Aufklärungs July 24th, 2006 02:03 AM

Re: My work is being featured in IPB SDK
 
I have NO idea what this is all about, but well done all the same :)

*Soviet.Power July 24th, 2006 10:06 AM

Re: My work is being featured in IPB SDK
 
Quote:

Originally Posted by DavetheFo
Well Done Mr Knipp!
Thats some very nippy work there.

:vikki:

I didn't understand a word of what you are on about Knipps, but well done nonetheless. :p

Tango Protocol July 24th, 2006 10:13 AM

Re: My work is being featured in IPB SDK
 
Nobody understands me :(

(dude that so sounded emo)

Mastershroom July 24th, 2006 01:22 PM

Re: My work is being featured in IPB SDK
 
Lol, emo. </3

Seriously, I don't have the slighest clue about code and stuff like that, but good job and congratulations on having it used! Drinks are on me!

screamingbye July 24th, 2006 03:11 PM

Re: My work is being featured in IPB SDK
 
congrats dude, now your an established developer.

Tango Protocol July 25th, 2006 08:39 PM

Re: My work is being featured in IPB SDK
 
Quote:

Originally Posted by screamingbye
congrats dude, now your an established developer.

Thankies.

I've been an "established developer" for awhile.. Have you not seen team357.org? It's for my robotics team :p

Also.. I might be getting a job for like... $17 an hour in a few days working for a Chamber of Commerce.. I honestly don't even know what a Chamber of Commerce is.. will someone enlighten me?


All times are GMT -7.

Powered by vBulletin®
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.