FreiChat related discussions
showing only users in groups

first off, thanks for this great tool, it has fit in well with my company's new content management system.

I was wondering if there is a way to alter the below code to only show other users that happen to be in the same group, and users can be in multiple groups. the database is called group_users and the fields are group_id and user_id. there is 1 user_id per person, but they can have several group_id values.



found this code @ http://elgghacks.com/customizing-frei-chat/ but cant figure out how to begin editing it to do what i want, thanks for looking

the following gets edited into \freichat\server\drivers\custom.php just after $result = $this->getList();



$query = "SELECT guid_two FROM " . DBprefix . "entity_relationships WHERE guid_one = " . $_SESSION[$this->uid . 'usr_ses_id'] . " AND relationship = 'friend'";
$friendsarray = $this->db->query($query)->fetchAll();

$friends = array();
foreach($friendsarray as $array){
$friends[] = $array[0];
}

if(count($friends) == 0){
$result = array();
}
else{
for($i=0; $i<count if unset array_values></count>

first off, thanks for this great tool, it has fit in well with my company&#039;s new content management system. I was wondering if there is a way to alter the below code to only show other users that happen to be in the same group, and users can be in multiple groups. the database is called group_users and the fields are group_id and user_id. there is 1 user_id per person, but they can have several group_id values. found this code @ http://elgghacks.com/customizing-frei-chat/ but cant figure out how to begin editing it to do what i want, thanks for looking the following gets edited into \freichat\server\drivers\custom.php just after $result = $this-&amp;gt;getList(); $query = &quot;SELECT guid_two FROM &quot; . DBprefix . &quot;entity_relationships WHERE guid_one = &quot; . $_SESSION[$this-&amp;gt;uid . &#039;usr_ses_id&#039;] . &quot; AND relationship = &#039;friend&#039;&quot;; $friendsarray = $this-&amp;gt;db-&amp;gt;query($query)-&amp;gt;fetchAll(); $friends = array(); foreach($friendsarray as $array){ $friends[] = $array[0]; } if(count($friends) == 0){ $result = array(); } else{ for($i=0; $i&amp;lt;count($result); $i++){ if(!in_array($result[$i][&#039;session_id&#039;], $friends)){ unset($result[$i]); } } } $result = array_values($result);

Read the last section of adding buddy support in below page
http://evnix.com/drupal2/node/328

Similarly you will have add your query to show users in groups

Read the last section of adding buddy support in below page http://evnix.com/drupal2/node/328 Similarly you will have add your query to show users in groups
Necessity is the mother of all inventions!

i read through the last section of the custom install, and you basically say that it has to be custom code depending on database layout, and you dont give any examples on how to go about it.

I have also searched through this forum and many posts on other forums for this answer and have yet to figure out the correct structure.

could you please point me in the right direction, i think im close, but am getting "No one is Online" in the user window in the bottom right, and the following is in my freixlog.log

"USER parameters for show_name are wrong"

this is i think the closest variant of my code:



<?php $user_id_num = $_SESSION['userid'];

$query = "SELECT user_id
FROM `database`.`group_users`
WHERE user_id = (
SELECT group_id
FROM `database`.`group_users`
WHERE user_id = '$user_id_num'
)
AND user_id != '$user_id_num'";

$friendsarray = $this->db->query($query)->fetchAll();

$friends = array();
foreach($friendsarray as $array){
$friends[] = $array[0];
}

if(count($friends) == 0){
$result = array();
}
else{
for($i=0; $i<count if unset array_values></count>
i read through the last section of the custom install, and you basically say that it has to be custom code depending on database layout, and you dont give any examples on how to go about it. I have also searched through this forum and many posts on other forums for this answer and have yet to figure out the correct structure. could you please point me in the right direction, i think im close, but am getting &quot;No one is Online&quot; in the user window in the bottom right, and the following is in my freixlog.log &quot;USER parameters for show_name are wrong&quot; this is i think the closest variant of my code: &amp;lt;blockquote&amp;gt; &amp;lt;?php $user_id_num = $_SESSION[&#039;userid&#039;]; $query = &quot;SELECT user_id FROM `database`.`group_users` WHERE user_id = ( SELECT group_id FROM `database`.`group_users` WHERE user_id = &#039;$user_id_num&#039; ) AND user_id != &#039;$user_id_num&#039;&quot;; $friendsarray = $this-&amp;gt;db-&amp;gt;query($query)-&amp;gt;fetchAll(); $friends = array(); foreach($friendsarray as $array){ $friends[] = $array[0]; } if(count($friends) == 0){ $result = array(); } else{ for($i=0; $i&amp;lt;count($result); $i++){ if(!in_array($result[$i][&#039;session_id&#039;], $friends)){ unset($result[$i]); } } } $result = array_values($result); ?&amp;gt; &amp;lt;/blockquote&amp;gt;
44
2
0
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft