291791
GIJOE
Re: Adding the group permission feature to your module
  • 2003/9/19 6:51

  • GIJOE

  • Quite a regular

  • Posts: 265

  • Since: 2003/8/13


This feature is very useful for module developpers.
Thanks!



291792
onokazu
Adding the group permission feature to your module
  • 2003/9/19 5:18

  • onokazu

  • XOOPS Founder

  • Posts: 617

  • Since: 2001/12/13


Adding the group permission feature to your module

Requirements

XOOPS 2.0.4

or

XOOPS 2.0.x plus the following files:
/class/xoopsform/grouppermform.php
/modules/system/admin/groupperm.php
/include/functions.php included in 2.0.4


Admin side

Adding Permissions

Some initial settings
include '../../../include/cp_header.php';
include_once 
XOOPS_ROOT_PATH.'/class/xoopsform/grouppermform.php';
$module_id $xoopsModule->getVar('mid');


A list of items that we will be setting permissions to.
In most cases, this should be retrieved from DB. We use a static array here just for exemplification.
$item_list = array('1' => 'Category 1''2' => 'Category 2''3' => 'Category 3');


The title of the group permission form
$title_of_form 'Permission form for my module';


The name of permission which should be unique within the module
$perm_name 'Category Permission';


A short description of this permission
$perm_desc 'Select categories that each group is allowed to view';


Create and display the form
$form = new XoopsGroupPermForm($title_of_form$module_id$perm_name$perm_desc);
foreach (
$item_list as $item_id => $item_name) {
    
$form->addItem($item_id$item_name);
}
echo 
$form->render();


This will then display a form like below:

Resized Image

Permission settings submitted via the form will be stored in DB automatically by /modules/system/admin/groupperm.php.


Deleting Permissions

One final thing you need to do: whenever you delete an item from your module (e.g. delete a category, delete a topic), you need to delete all group permissions for this item.

You can do so with this function call:

xoops_groupperm_deletebymoditem ($module_id, $perm_name, $item_id);

$module_id -- Module ID (required)
$perm_name -- Name of permission (optional)
$item_id -- ID of a deleted item (optional)



User Side

Suppose that a user requests the contents of a category via the HTTP GET method. The variable $_GET['category_id'] will be used to identify the requested category.

Specify the permission we are going to check for. This must be one of the permission names created on the admin side.
$perm_name 'Category Permission';


The unique id of an item to check permissions for.
$perm_itemid intval($_GET['category_id']);


Get group ids that the current user belongs to.
if ($xoopsUser) {
    
$groups $xoopsUser->getGroups();
} else {
    
$groups XOOPS_GROUP_ANONYMOUS;
}


Get the current module ID.
$module_id $xoopsModule->getVar('mid');


Get the group permission handler.
$gperm_handler =& xoops_gethandler('groupperm');


Now check if the current user has access to the category by calling the checkRight() method of the handler class.
if ($gperm_handler->checkRight($perm_name$perm_itemid$groups$module_id)) {

    
// allowed, so display contents within the category

} else {

    
// not allowed, display an error message or redirect to another page

}




Advanced Topic

If the items that need to check permissions for have a parent-child tree structure, a parent ID for each of the items must be supplied as the 3rd parameter of the XoopsGroupForm::addItem() method.
By doing so the XoopsGroupForm class will generate a form with each items displayed in a tree view. It also ensures that a permission to an item is not added without giving the same permission to all of the parent items for that item.

Suppose that our categories have the following tree structure:

Category 1 (ID: 1)
--- Category 2 (ID: 2)
------ Category 3 (ID: 3)
------ Category 4 (ID: 4)
--------- Category 6 (ID: 6)
--- Category 5 (ID: 5)
------ Category 8 (ID: 8)
Category 7 (ID: 7)
--- Category 9 (ID: 9)
------ Category 14 (ID: 14)
Category 10 (ID: 10)
--- Category 11 (ID: 11)
--- Category 13 (ID: 13)
Category 12 (ID: 12)

The category structure above can be represented with an array as below:
$categories[1] = array('name' => 'Category 1''parent' => 0);
$categories[2] = array('name' => 'Category 2''parent' => 1);
$categories[3] = array('name' => 'Category 3''parent' => 2);
$categories[4] = array('name' => 'Category 4''parent' => 2);
$categories[5] = array('name' => 'Category 5''parent' => 1);
$categories[6] = array('name' => 'Category 6''parent' => 4);
$categories[7] = array('name' => 'Category 7''parent' => 0);
$categories[8] = array('name' => 'Category 8''parent' => 5);
$categories[9] = array('name' => 'Category 9''parent' => 7);
$categories[10] = array('name' => 'Category 10''parent' => 0);
$categories[11] = array('name' => 'Category 11''parent' => 10);
$categories[12] = array('name' => 'Category 12''parent' => 0);
$categories[13] = array('name' => 'Category 13''parent' => 10);
$categories[14] = array('name' => 'Category 14''parent' => 9);


When we add an item entry to the group permission form, we must supply its parent ID as the 3rd parameter
foreach ($categories as $cat_id => $cat_data)
{
    
$form->addItem($cat_id$cat_data['name'], $cat_data['parent']);
}


This will then generate a form like below:

Resized Image

When the form is submitted, the submitted data will be validated so that a permission to an item is not granted without giving the same permission to all the parent items of that item. The validation is done in both the client side (javascript) and the server side (php). Therefore on the user side of the module, there is no need to check permission for all the parent items of a requested item, but only for that requested item.




291793
costi
Re: "sorry, you don't have permissions..." msg when trying to display detailed user info.
  • 2003/9/18 23:37

  • costi

  • Just popping in

  • Posts: 15

  • Since: 2003/9/12


With me, it's the reverse. I'm trying to hide that information and I can't.

I disabled access for anon users to xoopsmembers module, but they can access userinfo.php file with no problems with links like:

http://trubadur.usr.ro/userinfo.php?uid=1
http://trubadur.usr.ro/userinfo.php?uid=2

And so forth.
They click on the links from "Who's online" and "New members" block, and maybe others.

I'm very interested how you made a "no permision" for that file.



291794
hamilton
Re: PM notification hack. . .
  • 2003/9/18 23:27

  • hamilton

  • Just popping in

  • Posts: 1

  • Since: 2003/8/28


This is nice and easy. Thanks for the tip. I've already put it in place. Thanks again!



291795
Kolibri
Re: Streaming Audio Mod
  • 2003/9/18 23:14

  • Kolibri

  • Just popping in

  • Posts: 17

  • Since: 2003/9/5 1


JackJ, a big thank you for you!

This code meets the requirements for this moment. Right now I'm fitting it to my needs.

Couldn't mention it enough:

There are two brilliant streaming modules out there for PHPNuke »»» Internet Radio and Internet TV, as well as total admin control, popups, blocks and module...

They can be seen/found onhttp://www.just4me.nl/

So if anyone has some knowledge and time left to port it...
(Please check the module development team first, they might have accepted this port as a project!, otherwise it's a waste of your precious time!)



291796
MattG
Re: Which forum module do you reckon?
  • 2003/9/18 22:25

  • MattG

  • Just popping in

  • Posts: 2

  • Since: 2003/9/18


nm, I found it. :)



291797
MattG
Re: Which forum module do you reckon?
  • 2003/9/18 22:20

  • MattG

  • Just popping in

  • Posts: 2

  • Since: 2003/9/18


I'm fairly new to Xoops, but we are looking at moving from a phpbb2 board to Xoops. I looked around but have been unable to find a phpbb2 module for Xoops, though it sounds like one exists. Can someone show me the light?

Thanks,
-Matt G



291798
JackJ
Re: Streaming Audio Mod
  • 2003/9/18 21:29

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


More for previous

I did not install this as a module, here is my customisation, I am no coder, but it works for me

Edited this, I posted wrong code a min ago

I called this popup.php

<?php
/****************************************************************
* Block XP-Radio Adapté à XOOPS par LLaumgui pour XPerience-Fr *
*http://www.xperience-fr.net *
* *
* Module sous licence gpl *
****************************************************************/
?>
<script language="JavaScript" type="text/JavaScript">
function MM_jumpMenu(targ,selObj,restore){
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;}</script>
<?php
if ($station == capitalfm){$staradio = "www.radio-now.co.uk/l/capitalfmlo.asx";}
elseif ($station == classicgold) {$staradio = "62.25.96.7/classicgold";}
elseif ($station == powerfm) {$staradio = "streaming.capitalinteractive.co.uk/power_low";}
elseif ($station == smoothjazz) {$staradio = "smoothjazz.com/smooth.asx";}
elseif ($station == radiostorm) {$staradio = "64.236.34.141:80/stream/1023";}
elseif ($station == talksport) {$staradio = "194.162.227.149/audio/talksport.asx";}
elseif ($station == studentbroadcast) {$staradio = "www.sbn.co.uk/SBNLive.asx";}
elseif ($station == premierchristian) {$staradio = "www.premier.org.uk/streaming/premier.asx";}
elseif ($station == radioscotland) {$staradio = "62.25.96.7/rrs/";}
elseif ($station == talkgospel) {$staradio = "www.premier.org.uk/streaming/premierg.asx";}
elseif ($station == rtl2) {$staradio = "cache.yacast.fr/V4/rtl2/rtl2.asx";}
elseif ($station == crfm) {$staradio = "audio.musicradio.com/2CR.asx";}
elseif ($station == ucbeurope) {$staradio = "62.25.96.7/ucbinspiration";}
elseif ($station == ucbbible) {$staradio = "62.25.96.7/ucbbible";}
echo "
<title>$station</title><body bgcolor=\"#000033\"><body oncontextmenu=\"return false\" ondragstart=\"return false\" onselectstart=\"return false\">
<center><img src=\"radio.gif\"><p><p>
<object id=\"NSPlay\" width=\"180\" height=\"50\"
classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\"
codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\"
standby=\"Chargement...\"
type=\"application/x-oleobject\" align=\"middle\">
<param name=\"AudioStream\" value=\"-1\">
<param name=\"AutoSize\" value=\"0\">
<param name=\"AutoStart\" value=\"-1\">
<param name=\"AnimationAtStart\" value=\"-1\">
<param name=\"AllowScan\" value=\"-1\">
<param name=\"AllowChangeDisplaySize\" value=\"-1\">
<param name=\"AutoRewind\" value=\"0\">
<param name=\"Balance\" value=\"0\">
<param name=\"BufferingTime\" value=\"5\">
<param name=\"ClickToPlay\" value=\"-1\">
<param name=\"CursorType\" value=\"0\">
<param name=\"CurrentPosition\" value=\"-1\">
<param name=\"CurrentMarker\" value=\"0\">
<param name=\"DisplayBackColor\" value=\"0\">
<param name=\"DisplayForeColor\" value=\"16777215\">
<param name=\"DisplayMode\" value=\"0\">
<param name=\"DisplaySize\" value=\"4\">
<param name=\"Enabled\" value=\"-1\">
<param name=\"EnableContextMenu\" value=\"-1\">
<param name=\"EnablePositionControls\" value=\"-1\">
<param name=\"EnableFullScreenControls\" value=\"0\">
<param name=\"EnableTracker\" value=\"-1\">
<param name=\"Filename\" value=http://".$staradio.">
<param name=\"InvokeURLs\" value=\"-1\">
<param name=\"Language\" value=\"-1\">
<param name=\"Mute\" value=\"0\">
<param name=\"PlayCount\" value=\"1\">
<param name=\"PreviewMode\" value=\"0\">
<param name=\"Rate\" value=\"1\">
<param name=\"SelectionStart\" value=\"-1\">
<param name=\"SelectionEnd\" value=\"-1\">
<param name=\"SendOpenStateChangeEvents\" value=\"-1\">
<param name=\"SendWarningEvents\" value=\"-1\">
<param name=\"SendErrorEvents\" value=\"-1\">
<param name=\"SendKeyboardEvents\" value=\"0\">
<param name=\"SendMouseClickEvents\" value=\"0\">
<param name=\"SendMouseMoveEvents\" value=\"0\">
<param name=\"SendPlayStateChangeEvents\" value=\"-1\">
<param name=\"ShowCaptioning\" value=\"-1\">
<param name=\"ShowControls\" value=\"-1\">
<param name=\"ShowAudioControls\" value=\"-1\">
<param name=\"ShowDisplay\" value=\"0\">
<param name=\"ShowGotoBar\" value=\"0\">
<param name=\"ShowPositionControls\" value=\"0\">
<param name=\"ShowStatusBar\" value=\"-1\">
<param name=\"ShowTracker\" value=\"0\">
<param name=\"TransparentAtStart\" value=\"0\">
<param name=\"VideoBorderWidth\" value=\"0\">
<param name=\"VideoBorderColor\" value=\"0\">
<param name=\"VideoBorder3D\" value=\"0\">
<param name=\"Volume\" value=\"-650\">
<param name=\"WindowlessVideo\" value=\"0\">
<embed type=\"application/x-mplayer2\"pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/\"filename=http://62.25.96.7/classicgold src= showcontrols=\"1\" showdisplay=\"0\" showstatusbar=\"1\" width=\"100\" height=\"50\" align=\"middle\">
</embed>
</object><br>
<form name=\"form1\">
<select name=\"Radios\" onChange=\"MM_jumpMenu('parent',this,0)\">
<option selected>Stations</option>
<option value=\"popup.php?station=crfm\">2CRFM</option>
<option value=\"popup.php?station=premierchristian\">Premier Christian</option>
<option value=\"popup.php?station=capitalfm\">Capital FM</option>
<option value=\"popup.php?station=radioscotland\">Radio Scotland</option>
<option value=\"popup.php?station=powerfm\">Power FM</option>
<option value=\"popup.php?station=radiostorm\">Radio Storm 80's</option>
<option value=\"popup.php?station=talkgospel\">Talk Gospel</option>
<option value=\"popup.php?station=smoothjazz\">smooth jazz</option>
<option value=\"popup.php?station=studentbroadcast\">Student Broadcast</option>
<option value=\"popup.php?station=classicgold\">ClassicGold</option>
<option value=\"popup.php?station=talksport\">Talk Sport</option>
<option value=\"popup.php?station=ucbeurope\">UCB Europe</option>
<option value=\"popup.php?station=ucbbible\">UCB Bible</option>

</select>
</form>

<FORM>
<INPUT type=\"button\" value=\"Radio 4 Player\" onClick=\"window.open('http://www.bbc.co.uk/radio/aod/radio4.shtml?fm')\">
</FORM>
<FORM>
<INPUT type=\"button\" value=\"Close Window\" onClick=\"window.close()\">
</FORM><br>


";


?>

//End of popup.php



My Custom Block:-- Hashed code, I am sure you can improve



<center><img border="0" src="radio.gif" width="108" height="96"></p>
<br<br>

<FORM>
<INPUT type="button" value="Popup Select" onClick="window.open('http://www.macambridge.com/popup.php','mywindow','width=220,height=330',scrollbars=0)">
</FORM><br>
<FORM>
<INPUT type="button" value="Radio4 Player" onClick="window.open('http://www.bbc.co.uk/radio/aod/radio4.shtml?fm')">
</FORM>
<br>
<hr>
</center>

//end of hashed code

//copy radio.gif from my site if you wish

A lot of the stuff in the code is not needed, I just pasted it all from the module with my changes. Some of the french stations listed don't have matching "option value=", so they won't appear as a selection. Perhaps a coder could improve this and include real player etc. Internet_Radio for Postnuke is very good if someone could port it

A couple of the radio links are not functional because the stations are off, but you get the idea, nice one to play with?




291799
JackJ
Re: Streaming Audio Mod
  • 2003/9/18 21:09

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


Quote:

Kolibri wrote:
A few questions about Kitsou's streaming audio block.

1) How can I get a pulldown menu under the player in which some channels are predefined?

2)How to add an option to load the player into a new frame which will continue the channel/music while browsing the site.

3)Howto make the media player not start automatically.

4)Can I change the skin of the player?

Thanks in advance.

I already posted a module request at the Module Development Team based on a existing PHPNuke Module...


I have a radio mod called xp-radio on my site which I downloaded from some XOOPS Site, german or french I think, which you can customise.. Search on google for xp-radio

It has pop up selection etc, add as many stations as you like, although I customised my block not to play on the main page, no point in that, when users browse to other pages the radio goes off..popups are far better..if this is of any use to you let me know if I can help

You can make the block look like you wish with html

macambridge.com




291800
Kolibri
Re: Streaming Audio Mod
  • 2003/9/18 20:38

  • Kolibri

  • Just popping in

  • Posts: 17

  • Since: 2003/9/5 1


A few questions about Kitsou's streaming audio block.

1) How can I get a pulldown menu under the player in which some channels are predefined?

2)How to add an option to load the player into a new frame which will continue the channel/music while browsing the site.

3)Howto make the media player not start automatically.

4)Can I change the skin of the player?

Thanks in advance.

I already posted a module request at the Module Development Team based on a existing PHPNuke Module...







Login

Who's Online

206 user(s) are online (144 user(s) are browsing Support Forums)


Members: 0


Guests: 206


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits