Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Module only for owner and friends

Module only for owner and friends

Hello Stephen

I was out, but never forget this wonderful module.

I need help.
To visualize a com_comprofiler page, I want the module to appear only for the owner of the page and their friends.

Is it possible?

sniper_rio
Beginner Modder
ranks
useravatar
Offline
15 Posts
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.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
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;
}

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1680
Total Polls:
6
Total Posts:
5914
Total Posts Today:
1
User Info:
 
Total Users:
10831
Newest User:
bluesky1
Members Online:
0
Guests Online:
132

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