R0.25 No Longer Supported

[IMP] Creates a new Joomdle user Custom

  • raimonesteve
  • Topic Author
  • Offline
  • New Member
  • New Member
More
15 years 7 months ago #1 by raimonesteve
[IMP] Creates a new Joomdle user Custom was created by raimonesteve
New features auth moodle:

auth/joomdle/auth.php

This function add new user and user fields get array (not joomla user).

Avaible 3rd Party Components, for example, Moodle Coupon Component.

/**
* Creates a new Joomdle user Custom
* XXX Also used to update user profile if the user already exists. Created by Zikzakmedia for Moodle Coupon component.
*
* @param string $user custom array
*/
function create_joomdle_user_custom ($user_data)
{
global $CFG;

$username = $user_data;

$username = addslashes ($username);
/* Creamos el nuevo usuario de Moodle si no está creado */
$user = get_record('user','username',$username);
if (!$user)
$user = create_user_record($username, "", "manual");

/* Información del usuario */
$password = md5($user_data);
$email = $user_data;
$firstname = $user_data;
$lastname = $user_data;
$city = $user_data;
$country = $user_data;
$lang = $user_data;
$timezone = $user_data;
$phone1 = $user_data;
$phone2 = $user_data;
$address = $user_data;
$description = $user_data;
$institution = $user_data;
$url = $user_data;

//XXX Maybe this can be optimized for a single DB call...$bool = update_record('user', addslashes_recursive($localuser)); en ment/aut.php
if (!xmlrpc_is_fault($response)) {

/* Actualizamos la informacion del usuario recien creado con los datos */
set_field('user', 'password', $password, 'id', $user->id);
set_field('user', 'firstname', utf8_encode($firstname), 'id', $user->id);
set_field('user', 'lastname', utf8_encode($lastname), 'id', $user->id);
set_field('user', 'email', $email, 'id', $user->id);

/* Set first access as now */
set_field('user', 'firstaccess', time (), 'id', $user->id);
/* Optional data in Joomla, only fill if has a value */
if ($city)
set_field('user', 'city', utf8_encode($city), 'id', $user->id);
if ($country)
set_field('user', 'country', $country, 'id', $user->id);
if ($lang)
set_field('user', 'lang', $lang, 'id', $user->id);
if ($timezone)
set_field('user', 'timezone', $timezone, 'id', $user->id);
if ($phone1)
set_field('user', 'phone1', utf8_encode($phone1), 'id', $user->id);
if ($phone2)
set_field('user', 'phone2', utf8_encode($phone2), 'id', $user->id);
if ($address)
set_field('user', 'address', utf8_encode($address), 'id', $user->id);
if ($description)
set_field('user', 'description', utf8_encode($description), 'id', $user->id);
if ($institution)
set_field('user', 'institution', utf8_encode($institution), 'id', $user->id);
if ($url)
set_field('user', 'url', $url, 'id', $user->id);
}

return $user;
}

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #2 by Chris
Again, thanks for the combined suggestion and solution :)

Moved again

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #3 by Antonio Durán
Replied by Antonio Durán on topic Re: [IMP] Creates a new Joomdle user Custom
Hi.

I was looking at this one and I am not sure what it is for.

Is this to be used as a web service from Joomla? I see it creates users with auth set to "manual", so I don't know if this has anything to do with Joomdle...

Can you explain a little more please?

Please Log in or Create an account to join the conversation.