HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


change memberslist to show last online instead of join date

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#77554 (In Topic #15958)
Avatar

Community saint

Just something I wanted to do, as join date doesn't show me much of anything I want to know.

I modified the members.php in /site/pages/modules_custom and attached it to this message.  Pretty much the only change was changing m_join_time to m_last_visit_time in the routine to show the members list, and changing the reference from 'JOIN_DATE' to 'LAST_DATE'  for the language file.

If you are using english, then go into /lang/EN/ofc.ini   search for 'JOIN_DATE' and below it add:

LAST_DATE=Last Online

Save that file to /lang_custom/EN/ofc.ini

Now everything is in 'custom' folders as it should be so updates do not alter your changes.  And when you list members now it shows last time online instead of joined date.

Attachment
» Download: members.php (38 Kb, 201 downloads so far)

Paul
Back to the top
 
Posted
Rating:
#77562
Avatar

thanks for sharing :)


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Item has a rating of 5 (Liked by JeanLiked by TisnartLiked by sholzyLiked by BobS)  
Rating:
#90908
Avatar

Community saint

I have decided to work to put this one back in my V9.  Sticking with some of the other modifications I have recently done, I am going to add a configuration option that allows you to use join_date as it defaults to, or use last_online instead.  I prefer last_online as it let's me see how slow and inactive my site is. ;)

I started by adding a field into ocp_config.   I called this option use_joindate … add it follows the same pattern in my other modifications.  However this time for the_page I used 'FEATURE' as this selection should be under features in the config screens, and for section i used "MEMBERS".  Since OCP is well written and picks this stuff up, it adds this automatically to the features config screen, AND adds a 'Members' section with this option in it automatically.


Paul
Back to the top
 
Posted
Rating:
#90909
Avatar

Community saint

In lang/EN/config.ini I added the following to give the language for the new config option:

Code

USE_JOINDATE=Join Date in Members List
CONFIG_OPTION_use_joindate=If selected, members Join Date is seen in the members list, if not selected members last time active is used.

Paul
Back to the top
 
Posted
Rating:
#90910
Avatar

Well-settled

Thanx Arbo,
You should have your own thread called "Arbo's Mods"  :lol:
Much appreciated.  :thumbs:

Making games is fun…having people play them is the reward!
Back to the top
 
Posted
Rating:
#90911
Avatar

Community saint

Thanks.

So next up was going into site/pages/modules and modifying members.php.

If you load up this file and search for m_join_time you will see there are 7 instances in there.    So I did some changes that checked the 'use_joindate' config option, so now it selects and displays the proper date.  Some use of the xxxx ?   yyyy: zzzz ,  some if statements.    

Paul
Back to the top
 
Posted
Rating:
#90912
Avatar

Community saint

Rather than go through every bit of it, here are the two function's inside that file that get modified, the first is get_sitemap_pagelinks:

Code (php)

        function get_sitemap_pagelinks($callback,$member_id,$depth,$pagelink_stub)
        {
                if (get_forum_type()!='ocf') return;

                // Entries
                if ($depth>=DEPTH__ENTRIES)
                {
                        $start=0;
                        do
                        {      // memeberslist date choice modification
                                $groups=$GLOBALS['FORUM_DB']->query_select('f_members',array('id','m_username AS title',get_option('use_joindate')?'m_join_time':'m_last_visit_time'),NULL,'',500,$start);

                                foreach ($groups as $row)
                                {
                                        if ($row['id']!=db_get_first_id())
                                        {
                                                $pagelink=$pagelink_stub.'view:'.strval($row['id']);
                                                call_user_func_array($callback,array($pagelink,$pagelink_stub.'misc',get_option('use_joindate')?$row['m_join_time']:$row['m_last_visit_time'],NULL,0.2,$row['title'])); // Callback
                                        }
                                }

                                $start+=500;
                        }
                        while (array_key_exists(0,$groups));
                }
        }

The next is the directory() function:

Code (php)

        function directory()
        {
                require_javascript('javascript_ajax');
                require_javascript('javascript_ajax_people_lists');

                $title=get_screen_title('MEMBERS');

                require_code('templates_internalise_screen');
                $test_tpl=internalise_own_screen($title);
                if (is_object($test_tpl)) return $test_tpl;

                if (running_script('iframe'))
                {
                        $get_url=find_script('iframe');
                } else
                {
                        $get_url=find_script('index');
                }
                $hidden=build_keep_form_fields('_SELF',true,array('filter'));

                $start=get_param_integer('md_start',0);
                $max=get_param_integer('md_max',50);
                if (get_option('use_joindate')) {
                  $sortables=array('m_username'=>do_lang_tempcode('USERNAME'),'m_primary_group'=>do_lang_tempcode('PRIMARY_GROUP'),'m_cache_num_posts'=>do_lang_tempcode('COUNT_POSTS'),'m_join_time'=>do_lang_tempcode('JOIN_DATE'));
                } else {
                  $sortables=array('m_username'=>do_lang_tempcode('USERNAME'),'m_primary_group'=>do_lang_tempcode('PRIMARY_GROUP'),'m_cache_num_posts'=>do_lang_tempcode('COUNT_POSTS'),'m_last_visit_time'=>do_lang_tempcode('LAST_ACTIVE'));
               
                }
                $default_sort_order=get_value('md_default_sort_order');
                if (is_null($default_sort_order))
                        $default_sort_order=get_option('use_joindate')?'m_join_time DESC':'m_last_visit_time DESC';
                $test=explode(' ',get_param('md_sort',$default_sort_order),2);
                if (count($test)==1) $test[]='ASC';
                list($sortable,$sort_order)=$test;
                if (((strtoupper($sort_order)!='ASC') && (strtoupper($sort_order)!='DESC')) || (!array_key_exists($sortable,$sortables)))
                        log_hack_attack_and_exit('ORDERBY_HACK');
                global $NON_CANONICAL_PARAMS;
                $NON_CANONICAL_PARAMS[]='md_sort';

                $group_filter=get_param('group_filter','');

                $_usergroups=$GLOBALS['FORUM_DRIVER']->get_usergroup_list(true,false,false,($group_filter=='')?NULL:array(intval($group_filter)));
                $usergroups=array();
                require_code('ocf_groups2');
                foreach ($_usergroups as $group_id=>$group)
                {
                        $num=ocf_get_group_members_raw_count($group_id,true);
                        $usergroups[$group_id]=array('USERGROUP'=>$group,'NUM'=>strval($num));
                }

                // ocSelect
                $ocselect=either_param('active_filter','');
                if ($ocselect!='')
                {
                        require_code('ocselect');
                        $content_type='member';
                        list($ocselect_extra_select,$ocselect_extra_join,$ocselect_extra_where)=ocselect_to_sql($GLOBALS['SITE_DB'],parse_ocselect($ocselect),$content_type,'');
                        $extra_select_sql=implode('',$ocselect_extra_select);
                        $extra_join_sql=implode('',$ocselect_extra_join);
                } else
                {
                        $extra_select_sql='';
                        $extra_join_sql='';
                        $ocselect_extra_where='';
                }

                $where_clause='id<>'.strval(db_get_first_id()).$ocselect_extra_where;
                if (!has_specific_permission(get_member(),'see_unvalidated')) $where_clause.=' AND m_validated=1';

                if ($group_filter!='')
                {
                        if (is_numeric($group_filter))
                                $title=get_screen_title('USERGROUP',true,array($usergroups[intval($group_filter)]['USERGROUP']));

                        require_code('ocfiltering');
                        $filter=ocfilter_to_sqlfragment($group_filter,'m_primary_group','f_groups',NULL,'m_primary_group','id');
                        $where_clause.=' AND '.$filter;
                }
                $search=get_param('filter','');
                if ($search!='')
                {
                        $where_clause.=' AND (m_username LIKE \''.db_encode_like(str_replace('*','%',$search)).'\'';
                        if (has_specific_permission(get_member(),'member_maintenance'))
                                $where_clause.=' OR m_email_address LIKE \''.db_encode_like(str_replace('*','%',$search)).'\'';
                        $where_clause.=')';
                }
                $query='FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_members r'.$extra_join_sql.' WHERE '.$where_clause;

                $max_rows=$GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(DISTINCT r.id) '.$query);

                if (can_arbitrary_groupby()) $query.=' GROUP BY r.id';
                if ($sortable=='m_join_time' || $sortable=='m_last_visit_time')
                {
                        if (get_option('use_joindate')) {
                          $query.=' ORDER BY m_join_time '.$sort_order.','.'id '.$sort_order;
                    } else {
                      $query.=' ORDER by m_last_visit_time '.$sort_order.','.'id '.$sort_order;
                    }
                       
                } else
                {
                        $query.=' ORDER BY '.$sortable.' '.$sort_order;
                }
                $rows=$GLOBALS['FORUM_DB']->query('SELECT r.*'.$extra_select_sql.' '.$query,$max,$start);
                $rows=remove_duplicate_rows($rows,'id');

                $members=new ocp_tempcode();
                $member_boxes=array();
                require_code('templates_results_table');
                $fields_title=results_field_title(array(do_lang_tempcode('USERNAME'),do_lang_tempcode('PRIMARY_GROUP'),do_lang_tempcode('COUNT_POSTS'),do_lang_tempcode('JOIN_DATE')),$sortables,'md_sort',$sortable.' '.$sort_order);
                require_code('ocf_members2');
                foreach ($rows as $row)
                {
                        $link=$GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['id'],true,$row['m_username']);
                        $url=$GLOBALS['FORUM_DRIVER']->member_profile_url($row['id'],true);
                        if ($row['m_validated']==0) $link->attach(do_lang_tempcode('MEMBER_IS_UNVALIDATED'));
                        if ($row['m_validated_email_confirm_code']!='') $link->attach(do_lang_tempcode('MEMBER_IS_UNCONFIRMED'));
                        $member_primary_group=ocf_get_member_primary_group($row['id']);
                        $primary_group=ocf_get_group_link($member_primary_group);

                        $members->attach(results_entry(array($link,$primary_group,integer_format($row['m_cache_num_posts']),escape_html(get_timezoned_date(get_option('use_joindate')?$row['m_join_time']:$row['m_last_visit_time'])))));

                        $box=render_member_box($row['id'],true);
                        $member_boxes[]=$box;
                }
                $results_table=(count($rows)==0)?new ocp_tempcode():results_table(do_lang_tempcode('MEMBERS'),$start,'md_start',$max,'md_max',$max_rows,$fields_title,$members,$sortables,$sortable,$sort_order,'md_sort');

                $other_ids=array();
                $_max_rows_to_preload=get_value('max_rows_to_preload');
                $max_rows_to_preload=is_null($_max_rows_to_preload)?500:intval($_max_rows_to_preload);
                if (($max_rows<$max_rows_to_preload) && ($max_rows>count($rows)))
                {
                        $query='FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_members r'.$extra_join_sql.' WHERE '.$where_clause;
                        $or_list='';
                        foreach ($rows as $row)
                        {
                                $or_list=' AND r.id<>'.strval($row['id']);
                        }
                        $rows=$GLOBALS['FORUM_DB']->query('SELECT r.id'.$extra_select_sql.' '.$query.$or_list);
                        foreach ($rows as $row)
                        {
                                $other_ids[]=strval($row['id']);
                        }
                }

                require_code('templates_pagination');
                $pagination=pagination(do_lang_tempcode('MEMBERS'),NULL,$start,'md_start',$max,'md_max',$max_rows,NULL,NULL,true,true);

                $symbols=NULL;
                if (get_option('allow_alpha_search')=='1')
                {
                        $alpha_query=$GLOBALS['FORUM_DB']->query('SELECT m_username FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_members WHERE id<>'.strval(db_get_first_id()).' ORDER BY m_username ASC');
                        $symbols=array(array('START'=>'0','SYMBOL'=>do_lang('ALL')),array('START'=>'0','SYMBOL'=>'#'));
                        foreach (array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') as $s)
                        {
                                foreach ($alpha_query as $i=>$q)
                                {
                                        if (strtolower(substr($q['m_username'],0,1))==$s)
                                        {
                                                break;
                                        }
                                }
                                if (substr(strtolower($q['m_username']),0,1)!=$s) $i=intval($symbols[count($symbols)-1]['START']);
                                $symbols[]=array('START'=>strval(intval($max*floor(floatval($i)/floatval($max)))),'SYMBOL'=>$s);
                        }
                }

                return do_template('OCF_MEMBER_DIRECTORY_SCREEN',array('_GUID'=>'096767e9aaabce9cb3e6591b7bcf95b8','MAX'=>strval($max),'PAGINATION'=>$pagination,'MEMBER_BOXES'=>$member_boxes,'OTHER_IDS'=>$other_ids,'USERGROUPS'=>$usergroups,'HIDDEN'=>$hidden,'SYMBOLS'=>$symbols,'SEARCH'=>$search,'GET_URL'=>$get_url,'TITLE'=>$title,'RESULTS_TABLE'=>$results_table));
        }
 

Paul
Back to the top
 
Posted
Rating:
#90913
Avatar

Community saint

I'll attach the whole file here, if it let's me.

Attachment
modified file for modification discussed in thread
» Download: members.php (12 Kb, 207 downloads so far)


Now I need to add the text for the header on the table for 'last active', since that previously didn't exist.

Paul
Back to the top
 
Posted
Rating:
#90916
Avatar

Community saint

Adding the text goes back to the first post in this thread from long ago:


If you are using english, then go into /lang/EN/ofc.ini   search for 'JOIN_DATE' and below it add:

LAST_ACTIVE=Last Online

Paul
Back to the top
 
Posted
Rating:
#90919
Avatar

Community saint

Ok, missed one in the members.php… around line 238 (of the modified file), a line needs to be modified as such:

Code (php)

                $fields_title=results_field_title(array(do_lang_tempcode('USERNAME'),do_lang_tempcode('PRIMARY_GROUP'),do_lang_tempcode('COUNT_POSTS'),$get_option('use_joindate')?do_lang_tempcode('JOIN_DATE'):do_lang_tempcode('LAST_ACTIVE')),$sortables,'md_sort',$sortable.' '.$sort_order);
 

Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by Tisnart)  
Rating:
#91029
Avatar

Well-settled

Arbo,

I don't suppose you have a version that shows both Joined Date and Last On, do you?

 ;)
Back to the top
 
Posted
Rating:
#91030
Avatar

Community saint

No, I didn't see how I could fit both in that listing without dropping something else.   But I use a fixed width theme like here, and have left hand columns, so my screen real estate is limited.

Would it fit on the screen for your site?   If so I could modify it and have two config options, one for join one for last on, if both are checked have it show both.   I don't think that would be difficult.  Let me know.

Paul
Back to the top
 
Posted
Rating:
#91071
Avatar

Well-settled

I have lots of real estate on my site.  I don't use fixed width and I don't have a left-side menu, so even if I showed both columns there should be room to spare.

If you could make that mod it would be much appreciated.  Thanks!
Back to the top
 
Posted
Rating:
#91114
Avatar

Think this should be on tracker.

Chris


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#91115
Avatar

Community saint

I didn't put it there?

Once I made the mod's that D-Train requested I'll try to remember to do that.

Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by BobS)  
Rating:
#91116
Avatar

It is possible I missed, I didn't see when I spent 10 seconds checking ;). I'm excited by the coding activity by people recently and wanted to ensure everything was staying organised and people felt enfranchised :).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#91117
Avatar

Community saint

Ok, for the D-Train addition to this mod, to start, you need two fields in the config table in the database, so use this sql:

Code

INSERT INTO `ocp_config` (`the_name`, `human_name`, `c_set`, `config_value`, `the_type`, `eval`, `the_page`, `section`, `explanation`, `shared_hosting_restricted`, `c_data`) VALUES
('use_joindate', 'USE_JOINDATE', 1, '0', 'tick', 'return ''1'';', 'FEATURE', 'MEMBERS', 'CONFIG_OPTION_use_joindate', 0, ''),
('use_lastondate', 'USE_LASTONDATE', 1, '0', 'tick', 'return ''1'';', 'FEATURE', 'MEMBERS', 'CONFIG_OPTION_use_lastondate', 0, '');

Paul
Back to the top
 
Posted
Rating:
#91118
Avatar

Community saint

Next, from lang/EN/config.ini, add the following lines at the bottom:

Code

USE_JOINDATE=Join Date in Members List
CONFIG_OPTION_use_joindate=If selected, members Join Date is seen in the members list.
USE_LASTONDATE=Last Online Date in Members List
CONFIG_OPTION_use_lastondate=If selected members Last Online date is seen in the members list.

And of course resave that file in lang_custom/EN .. ;)

Paul
Back to the top
 
Posted
Rating:
#91119
Avatar

Community saint

If you are using english, then go into /lang/EN/ofc.ini   search for 'JOIN_DATE' and below it add:

LAST_ACTIVE=Last Online

and save it into lang_custom/EN folder.

Paul
Back to the top
 
Posted
Rating:
#91125
Avatar

Community saint

Getting there, having a bit of a problem figuring out a few things, but will get there… Here is what I see now, obviously I'm passing something where I shouldn't.   And need to figure it out.   




Paul
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Expand