restriction of access for tabs

17 years 1 month ago #30266 by nzimas
Replied by nzimas on topic Re:restriction of access for tabs
I have set a new user group in JACL with gid 31.
Following your instructions, i have *tried* to create a working function that looks like
[code:1]function _loadTabsList($user, $position=null) {
global $database;
if( ($my->gid!=31) || ($user->gid!=31) ) {
$temp=" AND t.title<>'Catalog' ";
}
if ($this->tabsToDisplay === null) {
$qry .="SELECT * FROM #__comprofiler_tabs t WHERE t.enabled=1 ".($position==null ? "" : "\n AND t.position='".$position);
$qry .= $temp;
$qry .= " ORDER BY t.position, t.ordering";

$database->setQuery($qry);
$this->tabsToDisplay = $database->loadObjectList();
}
}[/code:1]
Tht tab titled Catalog is not displaying to anyone, though it should be displaying for all users in gid 31.

I bet there is something wrong in my implementation of your patch :)

Help and guidance are more than welcome.

Nuno.

Professional Website: www.bittingbits.com

Please Log in to join the conversation.

17 years 1 month ago #30273 by king.lui
Replied by king.lui on topic Re:restriction of access for tabs
Yes, with [code:1]if( ($my->gid!=31) || ($user->gid!=31) ) {
$temp=" AND t.title<>'Catalog' ";
}[/code:1] you're saying, that tab Catalog will display for gid=31. What do you want to make? If all user will be able to see the tab and gid=31 not, then you must change the code like this: [code:1]if( ($my->gid==31) || ($user->gid==31) ) {
$temp=" AND t.title<>'Catalog' ";
}[/code:1]

I know, my english seems a little .. unusual .. but really, it's not bad, it's only a bavarian version :whistle:

Please Log in to join the conversation.

17 years 1 month ago #30279 by nzimas
Replied by nzimas on topic Re:restriction of access for tabs
king.lui wrote:

Yes, with [code:1]if( ($my->gid!=31) || ($user->gid!=31) ) {
$temp=" AND t.title<>'Catalog' ";
}[/code:1] you're saying, that tab Catalog will display for gid=31. What do you want to make?


That is exactly what i want to achieve. I want only the users with gid 31 to see the tab Catalog. It happens that when i insert your code, the tab does not display to anyone. This is what i find strange.
I have posted the full function to check if it has any syntax error.

Nuno.

Professional Website: www.bittingbits.com

Please Log in to join the conversation.

17 years 1 month ago #30280 by king.lui
Replied by king.lui on topic Re:restriction of access for tabs
try this [code:1]if($my->gid!=31) {
$temp=" AND t.title<>'Catalog' ";
}[/code:1] so only gid31 will see the tab. i hope so :blush:

I know, my english seems a little .. unusual .. but really, it's not bad, it's only a bavarian version :whistle:

Please Log in to join the conversation.

17 years 1 month ago #30313 by nzimas
Replied by nzimas on topic Re:restriction of access for tabs
Thanks for your kind help, but it is still not working.
Here's how the function looks like now

function _loadTabsList($user, $position=null) {
global $database;
if($my->gid!=31) {
$temp=" AND t.title<>'Catalog' ";
}
if ($this->tabsToDisplay === null) {
$qry .="SELECT * FROM #__comprofiler_tabs t WHERE t.enabled=1 ".($position==null ? "" : "\n AND t.position='".$position);
$qry .= $temp;
$qry .= " ORDER BY t.position, t.ordering";

$database->setQuery($qry);
$this->tabsToDisplay = $database->loadObjectList();
}
}

Users belonging to gid=41 still cannot see the tab with the title Catalog.

Pity :S

Nuno.

Professional Website: www.bittingbits.com

Please Log in to join the conversation.

17 years 1 month ago #30333 by king.lui
Replied by king.lui on topic Re:restriction of access for tabs
gid=41? i think, you meen gid=31. the problem is, that $my isn't available in that function. so this code must be run: [code:1]function _loadTabsList($user, $position=null) {
global $database, $my;
$temp="";
if($my->gid!=31) {
$temp=" AND t.title<>'Catalog' ";
}
if ($this->tabsToDisplay === null) {
$qry .="SELECT * FROM #__comprofiler_tabs t WHERE t.enabled=1 ".($position==null ? "" : "n AND t.position='".$position);
$qry .= $temp;
$qry .= " ORDER BY t.position, t.ordering";

$database->setQuery($qry);
$this->tabsToDisplay = $database->loadObjectList();
}
}[/code:1]

Here are some examples to do related things.

1. tabs only for me:
[code:1]if( $user->id!=$my->id ) $temp .= " AND t.title<>'Clicked me' ";[/code:1]

2. tabs only for connected people: [code:1]
$qry_myCont ="SELECT cms.id
FROM #__users as cms, #__comprofiler_members AS m
LEFT JOIN #__comprofiler AS cb ON m.memberid=cb.id
WHERE m.referenceid = $user->user_id
AND block='0'
AND cb.user_id=cms.id
AND cb.approved=1
AND cb.confirmed=1";

$database->setQuery( $qry_myCont );
$arr_onlyContIds = $database->loadResultArray();
array_push($arr_onlyContIds,'62');

if(count($arr_onlyContIds) && !in_array($my->id,$arr_onlyContIds) && $my->id!=$user->id) $temp .= " AND t.title<>'Fotos'";[/code:1]

Post edited by: king.lui, at: 2007/02/01 10:17

I know, my english seems a little .. unusual .. but really, it's not bad, it's only a bavarian version :whistle:

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.212 seconds

Facebook Twitter LinkedIn