Page 1 of 1

Date and Group Quesstion.

Posted: Fri Feb 11, 2011 3:33 am
by EFiNSTORM
Hey guys i am having trouble getting the last time visited date right.

Code: Select all

'LAST_SEEN'			=> $user->format_date($row['user_lastvisit']),
Which displays "Thu Feb 4, 2011 2:53 am" and when i check the member list it shows "Thu Feb 10, 2011 10:26 pm"

can you guys point out how to fix this issues.

ok next thing.
I am trying to accomplish is i have default group where all my buddies are and i am wondering if there is a way to show what other groups the are in.

Ex:
Username, Groups, Last Seen
Joe , memeber, admin Today
Mike, members Today
Smith, leader, graphics, admin Yesterday


Hope you guys know what i mean .

thanks.

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 5:16 am
by EFiNSTORM
Any one?

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 6:08 am
by CMCDragonkai
For your first issue, the problem may be caused by the location of where you are viewing:

Code: Select all

$user->format_date($row['user_lastvisit'])
You need to provide more detailed information.

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 8:18 am
by EFiNSTORM
The issue i am having that the last visit that is stored in the users table is not accurate. With the code i posted above.

My script says my last visit was. Thu Feb 10, 2011 2:53 am

And then memeberlist.php says Wed Feb 16, 2011 3:17 am

I know it has to do with session table since the sessions that are stored don't update the users table right away.

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 8:22 am
by CMCDragonkai
Do you know which one is correct?

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 6:12 pm
by EFiNSTORM
CMCDragonkai wrote:Do you know which one is correct?
Yes the one in the member list is correct.

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 6:48 pm
by Brf
The memberlist uses the session_time, if there is one.

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 7:13 pm
by EFiNSTORM
Brf wrote:The memberlist uses the session_time, if there is one.
Yes i looked into the memberlist.php and i seen the query where it take the session info from. I just have no idea how to link it to my current query.

Btw Brf would you know how i could build a query to show members from a default group and then show which other groups they are part off ?

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 7:17 pm
by Brf

Code: Select all

$member_array = group_memberships($group_number);
$group_array = group_memberships(false,$member_array);
If you need to see what individual groups each user is a member of, then put the second statement in a loop for each user in the array.

Wait.... that is not right.

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 7:21 pm
by EFiNSTORM
Brf wrote:

Code: Select all

$member_array = group_memberships($group_number);
$group_array = group_memberships(false,$member_array);
If you need to see what individual groups each user is a member of, then put the second statement in a loop for each user in the array.
So basically all i do is a sql query to get members from a "default group" and then use the foreach loop to get what other groups they are part of?

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 7:24 pm
by Brf

Code: Select all

$member_array = group_memberships($group_number);

$members = array();
foreach ($member_array as $ky => $member_row)
{
    $members[] = $member_row['user_id'];
}
$group_array = group_memberships(false,$members);
Then $group_array will have the list of 'user_id' and 'group_id'

Re: Date and Group Quesstion.

Posted: Wed Feb 16, 2011 7:34 pm
by EFiNSTORM
Brf wrote:

Code: Select all

$member_array = group_memberships($group_number);

$members = array();
foreach ($member_array as $ky => $member_row)
{
    $members[] = $member_row['user_id'];
}
$group_array = group_memberships(false,$members);
Then $group_array will have the list of 'user_id' and 'group_id'
I am totally brain dead. This my current query i been using which displays the group names and members that are in each group how would i mod it to work with what you provided me.

Code: Select all

$groups=array(9, 60, 47, 56); //multiple group id's
 
foreach ($groups as $groupid)
{

   $sql = "SELECT * FROM ".GROUPS_TABLE." WHERE group_id=$groupid ";

   $result = $db->sql_query($sql);
   while ($row = $db->sql_fetchrow($result))
   {
         $template->assign_block_vars('roster_group', array(
                    'GROUP'      => $row['group_name'],
                    ));		
   }

         $sql = "SELECT u.*, g.*, r.*, ug.* FROM ".USERS_TABLE." u, ".RANKS_TABLE." r, ".GROUPS_TABLE." g, ".USER_GROUP_TABLE." ug
               WHERE g.group_id = $groupid
               AND ug.group_id = $groupid
               AND u.user_id = ug.user_id
               AND r.rank_id = u.user_rank
			   ORDER BY ug.group_leader DESC";
           
      $result = $db->sql_query($sql);
   
      while ($row = $db->sql_fetchrow($result))
      {  	  
	  //DUMP INFO INTO STYLE
	  	  
      $template->assign_block_vars('roster_group.roster', array(
				
                    ));
      }
}