projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Save answers.
[platal.git]
/
include
/
googleapps.inc.php
diff --git
a/include/googleapps.inc.php
b/include/googleapps.inc.php
index
accc779
..
f4cc69c
100644
(file)
--- a/
include/googleapps.inc.php
+++ b/
include/googleapps.inc.php
@@
-1,6
+1,6
@@
<?php
/***************************************************************************
<?php
/***************************************************************************
- * Copyright (C) 2003-20
09
Polytechnique.org *
+ * Copyright (C) 2003-20
11
Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-23,7
+23,7
@@
function post_queue_u_create($job) {
global $globals;
function post_queue_u_create($job) {
global $globals;
- // Retrieves the user parameters (GoogleApps username and u
ser_
id).
+ // Retrieves the user parameters (GoogleApps username and uid).
$parameters = json_decode($job['j_parameters'], true);
$username = isset($parameters['username']) ? $parameters['username'] : null;
if (!($user = User::getSilent($username))) {
$parameters = json_decode($job['j_parameters'], true);
$username = isset($parameters['username']) ? $parameters['username'] : null;
if (!($user = User::getSilent($username))) {
@@
-40,18
+40,12
@@
function post_queue_u_create($job) {
}
// Sends the 'account created' email to the user, with basic documentation.
}
// Sends the 'account created' email to the user, with basic documentation.
- $res = XDB::query(
- "SELECT FIND_IN_SET('femme', u.flags), prenom
- FROM auth_user_md5 AS u
- WHERE u.user_id = {?}", $user->id());
- list($sexe, $prenom) = $res->fetchOneRow();
-
$mailer = new PlMailer('googleapps/create.mail.tpl');
$mailer->assign('account', $account);
$mailer->assign('email', $user->bestEmail());
$mailer->assign('googleapps_domain', $globals->mailstorage->googleapps_domain);
$mailer = new PlMailer('googleapps/create.mail.tpl');
$mailer->assign('account', $account);
$mailer->assign('email', $user->bestEmail());
$mailer->assign('googleapps_domain', $globals->mailstorage->googleapps_domain);
- $mailer->assign('prenom', $
prenom
);
- $mailer->assign('sexe', $
sexe
);
+ $mailer->assign('prenom', $
user->displayName()
);
+ $mailer->assign('sexe', $
user->isFemale()
);
$mailer->send();
}
$mailer->send();
}
@@
-79,17
+73,11
@@
function post_queue_u_update($job) {
}
// Sends an email to the account owner.
}
// Sends an email to the account owner.
- $res = XDB::query(
- "SELECT FIND_IN_SET('femme', u.flags), prenom
- FROM auth_user_md5 AS u
- WHERE u.user_id = {?}", $user->id());
- list($sexe, $prenom) = $res->fetchOneRow();
-
$mailer = new PlMailer('googleapps/unsuspend.mail.tpl');
$mailer->assign('account', $account);
$mailer->assign('email', $user->bestEmail());
$mailer = new PlMailer('googleapps/unsuspend.mail.tpl');
$mailer->assign('account', $account);
$mailer->assign('email', $user->bestEmail());
- $mailer->assign('prenom', $
prenom
);
- $mailer->assign('sexe', $
sexe
);
+ $mailer->assign('prenom', $
user->displayName()
);
+ $mailer->assign('sexe', $
user->isFemale()
);
$mailer->send();
}
}
$mailer->send();
}
}
@@
-205,7
+193,6
@@
class GoogleAppsAccount
// validation queue.
private function load_pending_validations()
{
// validation queue.
private function load_pending_validations()
{
- require_once('validations.inc.php');
$this->pending_validation_unsuspend =
Validate::get_typed_requests_count($this->user->id(), 'gapps-unsuspend');
}
$this->pending_validation_unsuspend =
Validate::get_typed_requests_count($this->user->id(), 'gapps-unsuspend');
}
@@
-353,7
+340,6
@@
class GoogleAppsAccount
}
if (!$this->pending_update_suspension && !$this->pending_validation_unsuspend) {
}
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;
$unsuspend = new GoogleAppsUnsuspendReq($this->user);
$unsuspend->submit();
$this->pending_validation_unsuspend = true;
@@
-369,17
+355,7
@@
class GoogleAppsAccount
if (!$this->pending_update_suspension) {
if ($this->sync_password) {
if (!$this->pending_update_suspension) {
if ($this->sync_password) {
- $res = XDB::query(
- "SELECT password
- FROM auth_user_md5
- WHERE user_id = {?}", $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));
}
} else {
$this->create_queue_job('u_update', array('suspended' => false));
}
@@
-390,18
+366,21
@@
class GoogleAppsAccount
}
// Creates a new Google Apps account with the @p local parameters.
}
// 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.
if ($this->g_status != NULL) {
return;
}
if (!$this->pending_create) {
// Retrieves information on the new account.
- $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(
// Adds an 'unprovisioned' entry in the gapps_accounts table.
XDB::execute(
@@
-417,8
+396,7
@@
class GoogleAppsAccount
$password_sync,
$redirect_mails,
$this->g_account_name,
$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(
// Adds the creation job in the GApps queue.
$this->create_queue_job(
@@
-426,7
+404,7
@@
class GoogleAppsAccount
array(
'username' => $this->g_account_name,
'first_name' => $prenom,
array(
'username' => $this->g_account_name,
'first_name' => $prenom,
- 'last_name' =>
($nom_usage ? $nom_usage : $nom)
,
+ 'last_name' =>
$nom
,
'password' => $password,
));
'password' => $password,
));