Esempio n. 1
0
 static function save_user_info_jomsocial($user_info, $use_utf8_decode = true)
 {
     $db = JFactory::getDBO();
     $username = $user_info['username'];
     $id = JUserHelper::getUserId($username);
     $user = JFactory::getUser($id);
     $mappings = JoomdleHelperMappings::get_app_mappings('jomsocial');
     foreach ($mappings as $mapping) {
         $additional_info[$mapping->joomla_field] = $user_info[$mapping->moodle_field];
         // Custom moodle fields
         if (strncmp($mapping->moodle_field, 'cf_', 3) == 0) {
             $data = JoomdleHelperMappings::get_moodle_custom_field_value($user_info, $mapping->moodle_field);
             JoomdleHelperMappings::set_field_value_jomsocial($mapping->joomla_field, $data, $id);
         } else {
             if ($use_utf8_decode) {
                 JoomdleHelperMappings::set_field_value_jomsocial($mapping->joomla_field, utf8_decode($user_info[$mapping->moodle_field]), $id);
             } else {
                 JoomdleHelperMappings::set_field_value_jomsocial($mapping->joomla_field, $user_info[$mapping->moodle_field], $id);
             }
         }
     }
     if ($user_info['picture'] && $user_info['pic_url']) {
         JoomdleHelperMappings::save_avatar_jomsocial($id, $user_info['pic_url']);
     } else {
         JoomdleHelperMappings::delete_avatar_jomsocial($id);
     }
     return $additional_info;
 }