X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fgoogleapps.inc.php;h=f4cc69c5e4262dcee7c309ffa0b8e00b566afec6;hb=2f854773c646a58688a06c24c6dcf19479c91837;hp=43025931549a30992ccf32990822f8ffc19a3fdc;hpb=be638e733bce413df4324d985297d9a4d94dcbca;p=platal.git diff --git a/include/googleapps.inc.php b/include/googleapps.inc.php index 4302593..f4cc69c 100644 --- a/include/googleapps.inc.php +++ b/include/googleapps.inc.php @@ -1,6 +1,6 @@ pending_validation_unsuspend = Validate::get_typed_requests_count($this->user->id(), 'gapps-unsuspend'); } @@ -260,6 +262,21 @@ class GoogleAppsAccount return $this->g_status == 'disabled'; } + // Loads and returns the list of nicknames for the user. + public function nicknames() + { + if ($this->nicknames == null) { + $res = XDB::query( + "SELECT g_nickname + FROM gapps_nicknames + WHERE g_account_name = {?} + ORDER BY g_nickname", + $this->g_account_name); + $this->nicknames = $res->fetchColumn(); + } + return $this->nicknames; + } + // Changes the GoogleApps password. public function set_password($password) { @@ -323,7 +340,6 @@ class GoogleAppsAccount } if (!$this->pending_update_suspension && !$this->pending_validation_unsuspend) { - require_once('validations.inc.php'); $unsuspend = new GoogleAppsUnsuspendReq($this->user); $unsuspend->submit(); $this->pending_validation_unsuspend = true; @@ -339,17 +355,7 @@ class GoogleAppsAccount if (!$this->pending_update_suspension) { if ($this->sync_password) { - $res = XDB::query( - "SELECT password - FROM accounts - WHERE uid = {?}", $this->user->id()); - $password = ($res->numRows() > 0 ? $res->fetchOneCell() : false); - } else { - $password = false; - } - - if ($password) { - $this->create_queue_job('u_update', array('suspended' => false, 'password' => $password)); + $this->create_queue_job('u_update', array('suspended' => false, 'password' => $this->user->password())); } else { $this->create_queue_job('u_update', array('suspended' => false)); } @@ -360,19 +366,21 @@ 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; } 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 (!$this->user->hasProfile()) { + $prenom = $this->user->displayName(); + $nom = $this->user->fullName(); + } else { + $prenom = $this->user->profile()->firstName(); + $nom = $this->user->profile()->lastName(); + } // Adds an 'unprovisioned' entry in the gapps_accounts table. XDB::execute( @@ -388,8 +396,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 +404,7 @@ class GoogleAppsAccount array( 'username' => $this->g_account_name, 'first_name' => $prenom, - 'last_name' => ($nom_usage ? $nom_usage : $nom), + 'last_name' => $nom, 'password' => $password, ));