The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
BB Code - Need help restricting to specific usergroups
I am trying to resolve the following problem, but my coding skills are obviously not sufficient to get this working. What I am trying to do is have a BB code that displays a video to users in the premium usergroup and shows all others an image and a comment that they have to buy a subscription to view this video.
I have got a working BB code to display the video, my problem is restricting this to members of the specified usergroup. Here is the code I put together (i shortened the video part as that is not the issue): Code:
if(is_member_of($user,30)==TRUE) { // Premium member, can watch video // <a href="premium/{param}" style="display:block;width:720px;height:405px;" id="player"></a> <script language="JavaScript"> flowplayer("player", "flash/flowplayer-3.2.5.swf", { [ **** VIDEO CODE REMOVED FROM THIS EXAMPLE ****] }); </script> } else { // Not Premium Member <img src="premium/thumbs/{option}" border="0" alt="" /> Note: Premium membership required to watch this video. } // ############################################################################# /** * Works out if a user is a member of the specified usergroup(s) * * This function can be overloaded to test multiple usergroups: is_member_of($user, 1, 3, 4, 6...) * * @param array User info array - must contain userid, usergroupid and membergroupids fields * @param integer Usergroup ID to test * @param boolean Pull result from cache * * @return boolean */ function is_member_of($userinfo, $usergroupid, $cache = true) { static $user_memberships; switch (func_num_args()) { // 1 can't happen case 2: // note: func_num_args doesn't count args with default values unless they're overridden $groups = is_array($usergroupid) ? $usergroupid : array($usergroupid); break; case 3: if (is_array($usergroupid)) { $groups = $usergroupid; $cache = (bool)$cache; } else if (is_bool($cache)) { // passed in 1 group and a cache state $groups = array($usergroupid); } else { // passed in 2 groups $groups = array($usergroupid, $cache); $cache = true; } break; default: // passed in 4+ args, which means it has to be in the 1,2,3 method $groups = func_get_args(); unset($groups[0]); $cache = true; } if (!is_array($user_memberships["$userinfo[userid]"]) OR !$cache) { // fetch membergroup ids for this user $user_memberships["$userinfo[userid]"] = fetch_membergroupids_array($userinfo); } foreach ($groups AS $usergroupid) { // is current group user's primary usergroup, or one of their membergroups? if ($userinfo['usergroupid'] == $usergroupid OR in_array($usergroupid, $user_memberships["$userinfo[userid]"])) { // yes - return true return true; } } // if we get here then the user doesn't belong to any of the groups. return false; } Can someone here help me to get this working, please? |
#2
|
|||
|
|||
No, no , no, your your code will never work. You're putting php code in a bb code tag and it simply won't work.
It's possible to do this but the question is how important is this feature? You're posting in the vB3 forum, what version are you using? You'll probably have to upgrade sooner or later to vB4. vB3 won't be supported forever and older versions require PHP 4, which is obsolete. My hosting service made PHP 4 available for a while after upgrading to PHP 5 but eventually quit. The reason I ask about this is vB4 has a built in video bb code and it wouldn't be very difficult to modify it and then add some JavaScript to the showthread page to switch from a default image to the video for premium members. But this would affect all videos, there wouldn't be a distinction between some videos for everyone and special videos only for premium members. Trying to do this for vB3 would also be possible but when you eventually upgrade to vB4 I'm not sure how to fix all your old threads. But I can't test anything in vB3 now that my hosting service no longer uses PHP4. Now, on the technical side, the reason this is so messy is that whenever you post a new reply, the bb codes are parsed (i.e., translated) into html and the parsed version is stored in the database and that's what is used whenever the thread is displayed. Once it's parsed it's too late to check what usergroup the viewer belongs to, everyone sees the same thing. So to make this work you would have to have both the image and the video in place but the video is inside a <div style="display:none;">. Once the page is loaded JavaScript can run through all the posts, find the undisplayed videos and switch them to display block for premium members and then hide the images. |
Благодарность от: | ||
TheLastSuperman |
#3
|
|||
|
|||
Hi nerbert,
I am open for ways of making this work. This feature is important for me as I release a lot of videos on my forum that only paying "premium" members should be able to see. I solved this in the past by using realplayer .ram files in attachments, which contain a link to the actual video. This required the user to have real player installed - I want to use flash player or html5 video to do this now as I need to support subtitles. As this is what finances my forum costs, and I have 9 new videos waiting to be released, it is essential that I solve this somehow. If we can somehow process the contents of an attachment, if access is denied then the user is not a premium member - that would work. I am currently using vBulletin 3.8.7 Patch Level 3 (PHP5 is no problem with this version) and due to a lot of mods I am using, I have not upgraded so far, particularly as everything is working smoothly. I am considering upgrading directly to vBulletin 5 once that is stable enough and I can find replacements for the mods I need. I run my own root server, so it is in my hands what software runs on it. I could just place these videos in a forum that only premium members can access, but I want normal members to be able to see that a video is available and read the description, just not be able to play the video (this encourages more subscriptions). I have all the other items in place, I just need to be able to restrict the showing of the video to premium members and preferably show everyone else an image instead. If you need to test anything, I can setup a vbtest forum on my server for example. Again, my forum is using php5 without problems. I see what you are saying about the parsing. maybe an option is needed to simply open up a new window and that is then capable of determining if premium or not? I am open to any suggestions on how to resolve this. My members are eagerly waiting for the new videos... |
#4
|
||||
|
||||
There is a modification for VB 3.x- Automatic Media Embedder (AME) 2.5.
This mod automatically turns youtube (and other video sites) links into embedded videos. It also uses a template to embed the code in the page. This means you could EDIT the video template created by the AME mod and use template conditionals to display the video to premium usergroups and your message to those who aren't supposed to see video. It does rely on a 3rd party mod, and it will be difficult to upgrade in the future and keep the functionality, but it should work. You need to use template conditionals (not PHP) in templates, there is an Article in the VB3 Articles section here on how template conditionals work. |
#5
|
|||
|
|||
I have other things to attend to at the moment but I'll get back on this later today. I'm pretty sure I can make this work. One question I need to have answered :
What do vb3.8.7 look like, this -- <if condition=".....">, or this -- <vb:if condtion="....."> |
#6
|
|||
|
|||
From what I can see, <if condition="....."> is used.
|
#7
|
||||
|
||||
Yes, vb 3.x is <if condition=""></if>
VB 4.x and 5.x is <vb:if condition=""></vb:if> |
#8
|
|||
|
|||
@ BOP5: That looks like too nice a product to chop up. Can you add extra tags so you could have premium tags available only for admins and still have video tags for members?
@ Peter Walker: If you want to go with AME and it can be suitably modified maybe BOP5 can give some guidance. An alternative I have in mind would be a direct edit of the file includes/class_bbcode.php to insert some code from vB4. No point using plugins here, the next upgrade will be to at least vB4 and it won't require a plugin (and besides, I'm not sure I can write the plugin code). A problem I foresee is regular members will see the [premium] tags when they quote your post and try using them just to see what happens. I don't know how to make them usable only for admins. I haven't found all the little pieces that go into parsing a video tags so I would have to write some of it myself. If you plan on using only youtube that wouldn't be much trouble. Do you need this for other types of videos? |
#9
|
||||
|
||||
It doesn't use tags at all... yes you can add more sites, hundreds of video sites even, but not by usergroup. Like I said the way to limit it by usergroup would be to use template conditionals. That would be far simpler then manually editing code.
|
#10
|
|||
|
|||
I already use flowplayer video code to show this. The reason being I need to be able to support subtitles and splash pages and most other video programs do not support this. I also host the video files on my own server, to give me better control.
The problem with YouTube is that once people see the youtube link, they can potentially just give the address to others for free and that is against the whole point of restricting access to non-paying members. Otherwise, Youtube would be suitable as that does support subtitles, etc. The interim solution I am working on is to put the videos into a subforum that only premium members can see. The links to this forum being in the normal premium directory which others can at least view. It is clumsy, so I hope you guys can come up with a better solution. I had a brief look at the AME system, but from what I saw the video component would not support subtitles. Thanks to all those trying to help. Regards Peter |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|