projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
On redirection addition, the antispam level is either set to the user's redirection...
[platal.git]
/
include
/
googleapps.inc.php
diff --git
a/include/googleapps.inc.php
b/include/googleapps.inc.php
index
accc779
..
68bf04d
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))) {
@@
-34,24
+34,17
@@
function post_queue_u_create($job) {
// the user at creation time.
$account = new GoogleAppsAccount($user);
if ($account->activate_mail_redirection) {
// the user at creation time.
$account = new GoogleAppsAccount($user);
if ($account->activate_mail_redirection) {
- require_once('emails.inc.php');
- $storage = new EmailStorage($user, 'googleapps');
- $storage->activate();
+ require_once 'emails.inc.php';
+ Email::activate_storage($user, 'googleapps');
}
// 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();
}
@@
-69,27
+62,20
@@
function post_queue_u_update($job) {
}
if (isset($parameters['suspended']) && $parameters['suspended'] == false) {
}
if (isset($parameters['suspended']) && $parameters['suspended'] == false) {
- require_once
('emails.inc.php')
;
+ require_once
'emails.inc.php'
;
$account = new GoogleAppsAccount($user);
if ($account->active()) {
// Re-adds the email redirection (if the user did request it).
if ($account->activate_mail_redirection) {
$account = new GoogleAppsAccount($user);
if ($account->active()) {
// Re-adds the email redirection (if the user did request it).
if ($account->activate_mail_redirection) {
- $storage = new EmailStorage($user, 'googleapps');
- $storage->activate();
+ Email::activate_storage($user, 'googleapps');
}
// 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();
}
}
@@
-136,7
+122,7
@@
class GoogleAppsAccount
// Constructs the account object, by retrieving all informations from the
// GApps account table, from GApps job queue, and from plat/al validation queue.
// Constructs the account object, by retrieving all informations from the
// GApps account table, from GApps job queue, and from plat/al validation queue.
- public function __construct(User
&
$user)
+ public function __construct(User $user)
{
$this->user = &$user;
if (!$this->user || !$this->user->login()) {
{
$this->user = &$user;
if (!$this->user || !$this->user->login()) {
@@
-205,7
+191,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
+338,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
+353,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
+364,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
+394,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
+402,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,
));