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.


Another example of overriding

Another example of overriding The other day I showed how some cool stuff could be achieved with a little bit of an ocPortal code override. Today I needed again to make a minor ocPortal.com change and there wasn't a feature for it: I wanted members to have a default avatar. We don't really have plans to make this a feature, because if we did we'd be opening up the floodgates to thousands of similar things, and ocPortal would get too complex to use. This is how I implemented it on ocPortal.com…

I made a new file, sources_custom/ocf_members_action.php:

PHP code

function ocf_make_member($username,$password,$email_address,$groups,$dob_day,$dob_month,$dob_year,$custom_fields,$timezone_offset=0,$primary_group=NULL,$validated=1,$join_time=NULL,$last_visit_time=NULL,$theme='',$avatar_url='',$signature='',$is_perm_banned=0,$preview_posts=1,$reveal_age=1,$title='',$photo_url='',$photo_thumb_url='',$views_signatures=1,$track_all_forums=0,$track_contributed_topics=1,$language=NULL,$allow_emails=1,$personal_notes='',$ip_address=NULL,$validated_email_confirm_code='',$check_correctness=true,$password_compatibility_scheme='',$salt='',$zone_wide=1,$last_submit_time=NULL,$id=NULL)
{
   if (
$avatar_url==''$avatar_url='themes/default/images/ocf_default_avatars/default_set/cool_flare.png';
   return 
non_overrided__ocf_make_member($username,$password,$email_address,$groups,$dob_day,$dob_month,$dob_year,$custom_fields,$timezone_offset,$primary_group,$validated,$join_time,$last_visit_time,$theme,$avatar_url,$signature,$is_perm_banned,$preview_posts,$reveal_age,$title,$photo_url,$photo_thumb_url,$views_signatures,$track_all_forums,$track_contributed_topics,$language,$allow_emails,$personal_notes,$ip_address,$validated_email_confirm_code,$check_correctness,$password_compatibility_scheme,$salt,$zone_wide,$last_submit_time,$id);
}

This gives new members the avatar. This function is trivially simple. It just wraps around the original function, relaying all parameters, and does one extra small thing - if the avatar for a new member is unspecified, it specifies it.

To update for existing members I ran a simple SQL query:

Code

UPDATE `ocp2_f_members` SET m_avatar_url = 'themes/default/images/ocf_default_avatars/default_set/cool_flare.png' WHERE m_avatar_url = ''

View all

Trackbacks

There have been no trackbacks yet