X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fgoogleapps.inc.php;h=d107e5ecb4fa7b896c51a5037a747a23406aa8c3;hb=ee682285d39f3358b1c50e672f7cbd001d6a9ac9;hp=43025931549a30992ccf32990822f8ffc19a3fdc;hpb=32742f846e13a7806dde6b7b912c423a46f933d8;p=platal.git diff --git a/include/googleapps.inc.php b/include/googleapps.inc.php index 4302593..d107e5e 100644 --- a/include/googleapps.inc.php +++ b/include/googleapps.inc.php @@ -360,7 +360,8 @@ class GoogleAppsAccount } // Creates a new Google Apps account with the @p local parameters. - public function create($password_sync, $password, $redirect_mails) { + public function create($password_sync, $password, $redirect_mails) + { if ($this->g_status != NULL) { return; } @@ -368,11 +369,13 @@ class GoogleAppsAccount if (!$this->pending_create) { // Retrieves information on the new account. // TODO: retreive first_name and last_name from the profile. - $res = XDB::query( - "SELECT nom, nom_usage, prenom - FROM auth_user_md5 - WHERE user_id = {?}", $this->user->id()); - list($nom, $nom_usage, $prenom) = $res->fetchOneRow(); + if (!$user->hasProfile()) { + $prenom = $user->displayName(); + $nom = $user->fullName(); + } else { + $prenom = $user->profile()->firstName(); + $nom = $user->profile()->lastName(); + } // Adds an 'unprovisioned' entry in the gapps_accounts table. XDB::execute( @@ -388,8 +391,7 @@ class GoogleAppsAccount $password_sync, $redirect_mails, $this->g_account_name, - $prenom, - ($nom_usage ? $nom_usage : $nom)); + $prenom, $nom); // Adds the creation job in the GApps queue. $this->create_queue_job( @@ -397,7 +399,7 @@ class GoogleAppsAccount array( 'username' => $this->g_account_name, 'first_name' => $prenom, - 'last_name' => ($nom_usage ? $nom_usage : $nom), + 'last_name' => $nom, 'password' => $password, ));