1
flameshockey
Xoops Variables question

I'm relatively new to XOOPS and PHP/SQL programming, and I don't know what the global XOOPS variables are defined as. I want to do something like this:

xoops user logs in

xoops user is in predefined group which is hopefully a variable?

clicks on .php custom link in MyModule


(inside the php file)

SQL connect to database
SELECT table WHERE (column.table = $XoopsGroupName (what is this variable?? )
ORDER BY whatevercolumn.table;

So, my question is, what are the names for variables for XOOPS groups or is there a link to some sort of easily readable documentation? Thanks!!

2
leostotch
Re: Xoops Variables question
  • 2006/7/10 19:45

  • leostotch

  • Just popping in

  • Posts: 76

  • Since: 2006/4/1 1


Info about the current user is in a global variable called xoopsUser. The groups this user belongs to can be retrieved using a method of this object called getGroups().
So you could do something like this:
function stuff() {
    global 
$xoopsDB$xoopsUser;

    
$groups $xoopsUser->getGroups();
    
$table $xoopsDB->prefix'mytable' );
    
$rs $xoopsDB->query"SELECT * FROM $table WHERE yourcol IN( " implode','$groups ) . ")" );


}

3
flameshockey
Re: Xoops Variables question

I tried that, but I am not sure how the function is actually used in the .php file. Here is what I Have:

filename:index.php

// other stuff before here

function viewsched()
{
global $xoopsDB, $xoopsUser;
$groups = $xoopsUser->getGroups();
$table = $xoopsDB->prefix( 'game_schedule' );
$query = $xoopsDB->query( "SELECT * FROM $table WHERE home IN( " . implode( ',', $groups ) . ") ORDER BY date ASC" );
}
-------------------------
This is the old code where each team had their own .php file to view and add games, now I want only one file to do this
// Define query and make sure the right team name is selected!!
//$query = 'SELECT * FROM game_schedule WHERE (home = "Depaul") ORDER BY date ASC';
--------------------------

if ($result = mysql_query($query))
{
while ($row = mysql_fetch_array($result))
{
echo the selected MySQL data in html table
}// end while

}// end if

4
Cuidiu
Re: Xoops Variables question
  • 2006/7/10 20:44

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


Quote:
what are the names for variables for XOOPS groups


I have wondered this myself. I did discover groups have id numbers assigned to them but could not figure out how to use groupid for separating groups. Then again, I'm not a coder, so that doesn't surprise me.
groupid | name
1 | Webmasters
2 | Registered Users
3 | Anonymous Users
4 | 4th User Group
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

5
flameshockey
Re: Xoops Variables question

I decided to echo those variables and found out the numbers as well, i think i'm going to try and find out what group corrseponds to each number and do:

global $xoopsUser;
if $xoopsUser=#10,
depaul=#10
if $xoopsUser = depaul, SELECT schedule WHERE table=depaul

i think i may try this

6
Bender
Re: Xoops Variables question
  • 2006/7/10 21:44

  • Bender

  • Home away from home

  • Posts: 1899

  • Since: 2003/3/10


There was a topic covering usergroups within the last 2 weeks. For the moment i don´t remember who asked/answered but using the search might be adviseable.

The topic was especially about the handling of custom XOOPS groups iirc.
Sorry, this signature is experiencing technical difficulties. We will return you to the sheduled signature as soon as possible ...

7
Cuidiu
Re: Xoops Variables question
  • 2006/7/10 22:12

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


[/quote]This thread perhaps.

[quote]Bender wrote:
There was a topic covering usergroups within the last 2 weeks. For the moment i don´t remember who asked/answered but using the search might be adviseable.
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

Login

Who's Online

218 user(s) are online (124 user(s) are browsing Support Forums)


Members: 0


Guests: 218


more...

Donat-O-Meter

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

Latest GitHub Commits