Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Module only for owner and friends
Page:
1
Module only for owner and friends
Administrator has disabled public posting
Re: Module only for owner and friends
Hi sniper_rio,
I'm just installing com_comprofiler to check how easy this will be. Can you please confirm exactly which page(s) you want this to appear on? This is important because the recipe will need to find out who is the owner of that page.
Administrator has disabled public posting
Re: Module only for owner and friends
Ok, try this one. I hope it's what you are after.
It's slightly complicated by 2 things:
1 - there are 2 separate URLs to get to your own profile page.
2 - "friends" can be in either direction: you "friend" me, or I "friend" you. In this recipe I check to see if at least 1 direction is valid, it doesn't matter which one.
Code:
$module_to_show = XXX; // replace with the module id to show
// always show the module on a person's individual profile page
if ( $option == 'com_comprofiler' and JRequest::getVar('task') == '' and $user->id > 0) {
return $module_to_show;
}
if ( $option == 'com_comprofiler' and JRequest::getVar('task') == 'userProfile' and $user->id > 0) {
$userid = JRequest::getInt('user', 0);
// show it if the userid on the page is the same as the logged-in user
if ($userid == $user->id) {
return $module_to_show;
}
// now check for forward or backward connections between the logged-in user and the page owner
$sql = "select memberid from #__comprofiler_members where accepted = 1 " .
" and ((referenceid = " . $userid . " and memberid = " . (int)$user->id . ") " .
" or (memberid = " . $userid . " and referenceid = " . (int)$user->id . ")) ";
$db->setQuery( $sql );
$res = $db->loadResultArray();
if ($res) return $module_to_show;
}
Administrator has disabled public posting
Page:
1
- Index
- » MetaMod
- » MetaMod General Support
- » Module only for owner and friends
Board Info
- Board Stats:
- Total Topics:
- 1698
- Total Polls:
- 6
- Total Posts:
- 5944
- Posts this week:
- 3
- User Info:
- Total Users:
- 5550
- Newest User:
- anjanarajput
- Members Online:
- 0
- Guests Online:
- 114
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked