well guys I'm using SSI.php to make a bride with my website and my SMF forum i using RC 2.0 and i don't have troubles with the log in, and using $context['user']['is_admin'] and $context['user']['is_guest'].
But now i want to add something like: $context['user']['is_organizer'] or thinks like this to give different kind of permissions to some users.
So i started to follow the $context['user] and i found $user_info[] and $user_settings in load.php.
But i don't know where can i add an is_XXX to the arrays or in which db table i need to add information.
any kind of help?
special thanks for your support
nax
There is a context already made, if ($context['user']['is_logged'] && ['user']['group_id'] == 2){ echo 'content';}
But, it only works for Global Mods as far as I know, so you'd have to set up your own context for anything further than that.
Labradoodle-360
I am pretty sure you'd want to use (allowedTo ('permission') )
Quote from: Labradoodle-360 on December 09, 2009, 04:52:02 PM
There is a context already made, if ($context['user']['is_logged'] && ['user']['group_id'] == 2){ echo 'content';}
But, it only works for Global Mods as far as I know, so you'd have to set up your own context for anything further than that.
Labradoodle-360
['user']['group_id'] is not in array $context
id => 3
is_logged => 1
is_guest =>
is_admin =>
is_mod =>
can_mod =>
username => naxx
language => english
email => [email protected]
ignoreusers => Array
name => naxx
smiley_set => default
messages => 0
unread_messages => 0
popup_messages =>
avatar => Array
total_time_logged_in => Array
by the way i want to give 3 or 5 different kind of permissions..
for example one user have the right to add news in a webpage.
other user can moderate the comments from one city
and other user moderate the comments from other city,...
so i need a different group and then maybe make some subgroups.
Quote from: Labradoodle-360 on December 09, 2009, 04:53:23 PM
I am pretty sure you'd want to use (allowedTo ('permission') )
can you explain me that? i think i can use it.
nax
First of all, I am fairly sure ['group_id'] is a working context, I have used it, or something similar. (May be 1.1.)
Please refer to SMF's explanation for allowedTo by clicking here (http://support.simplemachines.org/function_db/index.php?action=view_function;id=408)
Labradoodle-360
Quote from: Labradoodle-360 on December 09, 2009, 05:11:33 PM
First of all, I am fairly sure ['group_id'] is a working context, I have used it, or something similar. (May be 1.1.)
i'm using this script to test all these things
<?php
require_once("../smf/SSI.php");
function logued() {
global $context;
$_SESSION['login_url'] = 'http://localhost' . $_SERVER['PHP_SELF'];
$_SESSION['logout_url'] = 'http://localhost' . $_SERVER['PHP_SELF'];
if ($context['user']['is_guest'])
{
ssi_login();
}else if ($context['user']['is_logged'] && $context['user']['group_id'] == 4)
{
echo 'eres del grupo ORG';
}else
{
foreach ($context['user'] as $user => $data)
{
echo $user.' => '.$data.'<br />';
}
ssi_logout();
}
}
logued();
?>
and it don't show group_id.
i'm going to see allowedTo, thanks
As I stated in my post the contextif ($context['user']['is_logged'] && ['user']['group_id'] == 2) { echo ' content'; }
will ONLY work for the first to usergroups, Admin and Global Mod, I'm sure you could add more though.
(So that's why it didn't work, you put == 4))
Also, remember user and member are whole different contexts, user is the person viewing the page, member is used for posts, profiles and other information about a member.
Labradoodle-360
4 is the id of a test group called ORG.
all i want is add some groups like is_admin is_logged, in other words is_custom.
So with it i can give acces to a "custom admin" site por his is_custom rank.
well finally i can make something but it is not really i want at all...
}else if ($context['user']['is_logged'] && in_array(4, $user_info['groups']))
using user_info maybe i can do something.
really thanks
info (http://www.simplemachines.org/community/index.php?topic=286840.0)
if i have more troubles i post it.
nax
OK, let's take a step back.
What is is_foo? What determines it? Should it be a permission? Should it be multiple permissions?
well i'm really bad at english but i try to explain it.
I have 2 pages.
the first is a news page. Only some people and admins can put news and update it.
then i have other page with:
state 1 (4 example)
city 1
city 2
state 2
city 3
city 4
only one user from state 1 can admin the state 1 "site" (and admins of course), he can add more people from the city 1 or city 2 can allow users from city 1 to admin city 1 or acces it, and the same to state 2.
And a user of city one can give acces to common users from city 1 to these area the same with other city's
i thing is_foo is the best way to do it, or groups.
How do you determine that a user is in state 1 or state 2?
when he registered whe ask him from he is (in this web all people knows us so we went to trust they)
and i thinking to make a second table in DB to put this kind of information about the user.
so i think i need to add lines in the load.php to make a query and know where is he from and what is allowed to do (the last, i think i can made with smf_groupsmembers) but the state and city i think i need other table)
You could use custom profile fields for storing that, though, which changes the game again.
ok i take a look to these mod.
at the moment i have all doubts solved.
thanks sir
nax
Custom Profile Fields isn't a mod in 2.0; it's built in.