示例#1
0
function post_queue_u_update($job)
{
    global $globals;
    // If the u_update job was an unsuspend request, re-adds the redirection
    // to the Google Apps delivery address, provided the account is active (it might
    // have been deleted between the unsuspension and the post-queue processing).
    $parameters = json_decode($job['j_parameters'], true);
    $username = isset($parameters['username']) ? $parameters['username'] : null;
    if (!($user = User::getSilent($username))) {
        return;
    }
    if (isset($parameters['suspended']) && $parameters['suspended'] == false) {
        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) {
                Email::activate_storage($user, 'googleapps');
            }
            // Sends an email to the account owner.
            $mailer = new PlMailer('googleapps/unsuspend.mail.tpl');
            $mailer->assign('account', $account);
            $mailer->assign('email', $user->bestEmail());
            $mailer->assign('prenom', $user->displayName());
            $mailer->assign('sexe', $user->isFemale());
            $mailer->send();
        }
    }
}
示例#2
0
 public static function IsCandidate(User $user, $candidate)
 {
     if (!$user->checkPerms(User::PERM_MAIL)) {
         return false;
     }
     require_once 'googleapps.inc.php';
     $isSubscribed = GoogleAppsAccount::account_status($user->id());
     if ($isSubscribed == 'disabled') {
         $isSubscribed = false;
     }
     if ($isSubscribed) {
         Reminder::MarkCandidateAsAccepted($user->id(), $candidate);
     }
     return !$isSubscribed;
 }
示例#3
0
文件: platal.php 项目: Ekleog/platal
 function handler_tmpPWD($page, $certif = null)
 {
     global $globals;
     XDB::execute('DELETE FROM  account_lost_passwords
                         WHERE  DATE_SUB(NOW(), INTERVAL 380 MINUTE) > created');
     if (Post::has('pwhash') && Post::t('pwhash')) {
         $uid = XDB::fetchOneCell('SELECT  uid
                                     FROM  accounts
                                    WHERE  hruid = {?}', Post::t('username'));
         $password = Post::t('pwhash');
         XDB::query('UPDATE  accounts
                        SET  password = {?}
                      WHERE  uid = {?} AND state = \'active\'', $password, $uid);
         XDB::query('DELETE FROM  account_lost_passwords
                           WHERE  certificat = {?}', $certif);
         // If GoogleApps is enabled, and the user did choose to use synchronized passwords,
         // updates the Google Apps password as well.
         if ($globals->mailstorage->googleapps_domain) {
             require_once 'googleapps.inc.php';
             $account = new GoogleAppsAccount(User::getSilent($uid));
             if ($account->active() && $account->sync_password) {
                 $account->set_password($password);
             }
         }
         S::logger($uid)->log("passwd", "");
         // Try to start a session (so the user don't have to log in); we will use
         // the password available in Post:: to authenticate the user.
         Platal::session()->start(AUTH_PASSWD);
         $page->changeTpl('platal/tmpPWD.success.tpl');
     } else {
         $res = XDB::query('SELECT  uid
                              FROM  account_lost_passwords
                             WHERE  certificat = {?}', $certif);
         $ligne = $res->fetchOneAssoc();
         if (!$ligne) {
             $page->changeTpl('platal/index.tpl');
             $page->kill("Cette adresse n'existe pas ou n'existe plus sur le serveur.");
         }
         $hruid = XDB::fetchOneCell('SELECT  hruid
                                       FROM  accounts
                                      WHERE  uid = {?}', $ligne['uid']);
         $page->changeTpl('platal/password.tpl');
         $page->assign('hruid', $hruid);
         $page->assign('do_auth', 1);
     }
 }
示例#4
0
 /**
  * Clears a user.
  *  *always deletes in: account_lost_passwords, register_marketing,
  *      register_pending, register_subs, watch_nonins, watch, watch_promo, watch_group,
  *  *always keeps in: account_types, accounts, email_virtual, carvas,
  *      group_members, homonyms_list, newsletter_ins, register_mstats, email_source_account
  *  *deletes if $clearAll: account_auth_openid, announce_read, contacts,
  *      email_redirect_account, email_redirect_account, email_send_save, forum_innd, forum_profiles,
  *      forum_subs, gapps_accounts, gapps_nicknames, group_announces_read,
  *      group_member_sub_requests, reminder, requests, requests_hidden,
  *      email_virtual, ML
  *  *modifies if $clearAll: accounts
  *
  * Use cases:
  *  *$clearAll == false: when a user dies, her family still needs to keep in
  *      touch with the community.
  *  *$clearAll == true: in every other case we want the account to be fully
  *      deleted so that it can not be used anymore.
  */
 public function clear($clearAll = true)
 {
     $tables = array('account_lost_passwords', 'register_marketing', 'register_pending', 'register_subs', 'watch_nonins', 'watch', 'watch_promo', 'watch_group');
     foreach ($tables as $t) {
         XDB::execute('DELETE FROM  ' . $t . '
                             WHERE  uid = {?}', $this->id());
     }
     if ($clearAll) {
         global $globals;
         $groupIds = XDB::iterator('SELECT  asso_id
                                      FROM  group_members
                                     WHERE  uid = {?}', $this->id());
         while ($groupId = $groupIds->next()) {
             $group = Group::get($groupId);
             if (!empty($group) && $group->notif_unsub) {
                 $mailer = new PlMailer('xnetgrp/unsubscription-notif.mail.tpl');
                 $admins = $group->iterAdmins();
                 while ($admin = $admins->next()) {
                     $mailer->addTo($admin);
                 }
                 $mailer->assign('group', $group->shortname);
                 $mailer->assign('user', $this);
                 $mailer->assign('selfdone', false);
                 $mailer->send();
             }
         }
         $tables = array('account_auth_openid', 'announce_read', 'contacts', 'email_send_save', 'forum_innd', 'forum_profiles', 'forum_subs', 'group_announces_read', 'group_members', 'group_member_sub_requests', 'reminder', 'requests', 'requests_hidden');
         foreach ($tables as $t) {
             XDB::execute('DELETE FROM  ' . $t . '
                                 WHERE  uid = {?}', $this->id());
         }
         XDB::execute('DELETE FROM  email_redirect_account
                             WHERE  uid = {?} AND type != \'homonym\'', $this->id());
         XDB::execute('DELETE FROM  email_virtual
                             WHERE  redirect = {?}', $this->forlifeEmail());
         foreach (array('gapps_accounts', 'gapps_nicknames') as $t) {
             XDB::execute('DELETE FROM  ' . $t . '
                                 WHERE  l_userid = {?}', $this->id());
         }
         XDB::execute("UPDATE  accounts\n                             SET  registration_date = 0, state = 'pending', password = NULL,\n                                  weak_password = NULL, token = NULL, is_admin = 0\n                           WHERE  uid = {?}", $this->id());
         if ($globals->mailstorage->googleapps_domain) {
             require_once 'googleapps.inc.php';
             if (GoogleAppsAccount::account_status($this->id())) {
                 $account = new GoogleAppsAccount($this);
                 $account->suspend();
             }
         }
     }
     $mmlist = new MMList(S::user());
     $mmlist->kill($this->forlife, $this->promo(), $clearAll);
 }
示例#5
0
 function handler_admin_user($page, $user = null)
 {
     require_once 'emails.inc.php';
     require_once 'googleapps.inc.php';
     $page->changeTpl('googleapps/admin.user.tpl');
     $page->setTitle('Administration Google Apps');
     $page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
     if (!$user && Post::has('login')) {
         $user = Post::v('login');
     }
     $user = User::get($user);
     if ($user) {
         $account = new GoogleAppsAccount($user);
         // Apply requested actions.
         if (Post::has('suspend') && $account->active() && !$account->pending_update_suspension) {
             S::assert_xsrf_token();
             $account->suspend();
             $page->trigSuccess('Le compte est en cours de suspension.');
         } else {
             if (Post::has('unsuspend') && $account->suspended() && !$account->pending_update_suspension) {
                 S::assert_xsrf_token();
                 $account->do_unsuspend();
                 $page->trigSuccess('Le compte est en cours de réactivation.');
             } else {
                 if (Post::has('forcesync') && $account->active() && $account->sync_password) {
                     $account->set_password($user->password());
                     $page->trigSuccess('Le mot de passe est en cours de synchronisation.');
                 } else {
                     if (Post::has('sync') && $account->active()) {
                         $account->set_password($user->password());
                         $account->set_password_sync(true);
                     } else {
                         if (Post::has('nosync') && $account->active()) {
                             $account->set_password_sync(false);
                         }
                     }
                 }
             }
         }
         // Displays basic account information.
         $page->assign('account', $account);
         $page->assign('admin_account', GoogleAppsAccount::is_administrator($user->id()));
         $page->assign('googleapps_storage', Email::is_active_storage($user, 'googleapps'));
         $page->assign('user', $user->id());
         // Retrieves user's pending requests.
         $res = XDB::iterator("SELECT  q_id, q_recipient_id, p_status, j_type, UNIX_TIMESTAMP(p_entry_date) AS p_entry_date\n                   FROM  gapps_queue\n                  WHERE  q_recipient_id = {?}\n               ORDER BY  p_entry_date DESC", $user->id());
         $page->assign('requests', $res);
     }
 }
示例#6
0
文件: admin.php 项目: Ekleog/platal
 function handler_user($page, $login = false)
 {
     global $globals;
     $page->changeTpl('admin/user.tpl');
     $page->setTitle('Administration - Compte');
     if (S::suid()) {
         $page->kill("Déjà en SUID !!!");
     }
     // Loads the user identity using the environment.
     if ($login) {
         $user = User::get($login);
     }
     if (empty($user)) {
         pl_redirect('admin/accounts');
     }
     $listClient = new MMList(S::user());
     $login = $user->login();
     $registered = $user->state != 'pending';
     // Form processing
     if (!empty($_POST)) {
         S::assert_xsrf_token();
         if (Post::has('uid') && Post::i('uid') != $user->id()) {
             $page->kill('Une erreur s\'est produite');
         }
     }
     // Handles specific requests (AX sync, su, ...).
     if (Post::has('log_account')) {
         pl_redirect("admin/logger?loguser={$login}&year=" . date('Y') . "&month=" . date('m'));
     }
     if (Post::has('su_account') && $registered) {
         if (!Platal::session()->startSUID($user)) {
             $page->trigError('Impossible d\'effectuer un SUID sur ' . $user->login());
         } else {
             pl_redirect("");
         }
     }
     // Handles account deletion.
     if (Post::has('account_deletion_confirmation')) {
         $uid = $user->id();
         $name = $user->fullName();
         $profile = $user->profile();
         if ($profile && Post::b('clear_profile')) {
             $user->profile()->clear();
         }
         $user->clear(true);
         $page->trigSuccess("L'utilisateur {$name} ({$uid}) a bien été désinscrit.");
         if (Post::b('erase_account')) {
             XDB::execute('DELETE FROM  accounts
                                 WHERE  uid = {?}', $uid);
             $page->trigSuccess("L'utilisateur {$name} ({$uid}) a été supprimé de la base de données");
         }
     }
     // Account Form {{{
     require_once 'emails.inc.php';
     $to_update = array();
     if (Post::has('disable_weak_access')) {
         $to_update['weak_password'] = null;
     } else {
         if (Post::has('update_account')) {
             if (!$user->hasProfile()) {
                 require_once 'name.func.inc.php';
                 $name_update = false;
                 $lastname = capitalize_name(Post::t('lastname'));
                 $firstname = capitalize_name(Post::t('firstname'));
                 if ($lastname != $user->lastname) {
                     $to_update['lastname'] = $lastname;
                     $name_update = true;
                 }
                 if (Post::s('type') != 'virtual' && $firstname != $user->firstname) {
                     $to_update['firstname'] = $firstname;
                     $name_update = true;
                 }
                 if ($name_update) {
                     if (Post::s('type') == 'virtual') {
                         $firstname = '';
                     }
                     $to_update['full_name'] = build_full_name($firstname, $lastname);
                     $to_update['directory_name'] = build_directory_name($firstname, $lastname);
                     $to_update['sort_name'] = build_sort_name($firstname, $lastname);
                 }
                 if (Post::s('display_name') != $user->displayName()) {
                     $to_update['display_name'] = Post::s('display_name');
                 }
             }
             if (Post::s('sex') != ($user->isFemale() ? 'female' : 'male')) {
                 $to_update['sex'] = Post::s('sex');
                 if ($user->hasProfile()) {
                     XDB::execute('UPDATE  profiles
                                  SET  sex = {?}
                                WHERE  pid = {?}', Post::s('sex'), $user->profile()->id());
                 }
             }
             if (!Post::blank('pwhash')) {
                 $to_update['password'] = Post::s('pwhash');
                 require_once 'googleapps.inc.php';
                 $account = new GoogleAppsAccount($user);
                 if ($account->active() && $account->sync_password) {
                     $account->set_password(Post::s('pwhash'));
                 }
             }
             if (!Post::blank('weak_password')) {
                 $to_update['weak_password'] = Post::s('weak_password');
             }
             if (Post::i('token_access', 0) != ($user->token_access ? 1 : 0)) {
                 $to_update['token'] = Post::i('token_access') ? rand_url_id(16) : null;
             }
             if (Post::i('skin') != $user->skin) {
                 $to_update['skin'] = Post::i('skin');
                 if ($to_update['skin'] == 0) {
                     $to_update['skin'] = null;
                 }
             }
             if (Post::s('state') != $user->state) {
                 $to_update['state'] = Post::s('state');
             }
             if (Post::i('is_admin', 0) != ($user->is_admin ? 1 : 0)) {
                 $to_update['is_admin'] = Post::b('is_admin');
             }
             if (Post::s('type') != $user->type) {
                 $to_update['type'] = Post::s('type');
             }
             if (Post::i('watch', 0) != ($user->watch ? 1 : 0)) {
                 $to_update['flags'] = new PlFlagset();
                 $to_update['flags']->addFlag('watch', Post::i('watch'));
             }
             if (Post::t('comment') != $user->comment) {
                 $to_update['comment'] = Post::blank('comment') ? null : Post::t('comment');
             }
             $new_email = strtolower(Post::t('email'));
             if (require_email_update($user, $new_email)) {
                 $to_update['email'] = $new_email;
                 $listClient->change_user_email($user->forlifeEmail(), $new_email);
                 update_alias_user($user->forlifeEmail(), $new_email);
             }
         }
     }
     if (!empty($to_update)) {
         $res = XDB::query('SELECT  *
                              FROM  accounts
                             WHERE  uid = {?}', $user->id());
         $oldValues = $res->fetchAllAssoc();
         $oldValues = $oldValues[0];
         $set = array();
         $diff = array();
         foreach ($to_update as $k => $value) {
             $value = XDB::format('{?}', $value);
             $set[] = $k . ' = ' . $value;
             $diff[$k] = array($oldValues[$k], trim($value, "'"));
             unset($oldValues[$k]);
         }
         XDB::rawExecute('UPDATE  accounts
                             SET  ' . implode(', ', $set) . '
                           WHERE  uid = ' . XDB::format('{?}', $user->id()));
         $page->trigSuccess('Données du compte mise à jour avec succès');
         $user = User::getWithUID($user->id());
         /* Formats the $diff and send it to the site administrators. The rules are the folowing:
          *  -formats: password, token, weak_password
          */
         foreach (array('password', 'token', 'weak_password') as $key) {
             if (isset($diff[$key])) {
                 $diff[$key] = array('old value', 'new value');
             } else {
                 $oldValues[$key] = 'old value';
             }
         }
         $mail = new PlMailer('admin/useredit.mail.tpl');
         $mail->assign('admin', S::user()->hruid);
         $mail->assign('hruid', $user->hruid);
         $mail->assign('diff', $diff);
         $mail->assign('oldValues', $oldValues);
         $mail->send();
     }
     // }}}
     // Profile form {{{
     if (Post::has('add_profile') || Post::has('del_profile') || Post::has('owner')) {
         if (Post::i('del_profile', 0) != 0) {
             XDB::execute('DELETE FROM  account_profiles
                                 WHERE  uid = {?} AND pid = {?}', $user->id(), Post::i('del_profile'));
             XDB::execute('DELETE FROM  profiles
                                 WHERE  pid = {?}', Post::i('del_profile'));
         } else {
             if (!Post::blank('new_profile')) {
                 $profile = Profile::get(Post::t('new_profile'));
                 if (!$profile) {
                     $page->trigError('Le profil ' . Post::t('new_profile') . ' n\'existe pas');
                 } else {
                     XDB::execute('INSERT IGNORE INTO  account_profiles (uid, pid)
                                           VALUES  ({?}, {?})', $user->id(), $profile->id());
                 }
             }
         }
         XDB::execute('UPDATE  account_profiles
                          SET  perms = IF(pid = {?}, CONCAT(perms, \',owner\'), REPLACE(perms, \'owner\', \'\'))
                        WHERE  uid = {?}', Post::i('owner'), $user->id());
     }
     // }}}
     // Email forwards form {{{
     $redirect = $registered ? new Redirect($user) : null;
     if (Post::has('add_fwd')) {
         $email = Post::t('email');
         if (!isvalid_email_redirection($email, $user)) {
             $page->trigError("Email non valide: {$email}");
         } else {
             $redirect->add_email($email);
             $page->trigSuccess("Ajout de {$email} effectué");
         }
     } else {
         if (!Post::blank('del_fwd')) {
             $redirect->delete_email(Post::t('del_fwd'));
         } else {
             if (!Post::blank('activate_fwd')) {
                 $redirect->modify_one_email(Post::t('activate_fwd'), true);
             } else {
                 if (!Post::blank('deactivate_fwd')) {
                     $redirect->modify_one_email(Post::t('deactivate_fwd'), false);
                 } else {
                     if (Post::has('disable_fwd')) {
                         $redirect->disable();
                     } else {
                         if (Post::has('enable_fwd')) {
                             $redirect->enable();
                         } else {
                             if (!Post::blank('clean_fwd')) {
                                 $redirect->clean_errors(Post::t('clean_fwd'));
                             }
                         }
                     }
                 }
             }
         }
     }
     // }}}
     // Email alias form {{{
     if (Post::has('add_alias')) {
         // Splits new alias in user and fqdn.
         $alias = Env::t('email');
         if (strpos($alias, '@') !== false) {
             list($alias, $domain) = explode('@', $alias);
         } else {
             $domain = $user->mainEmailDomain();
         }
         // Checks for alias' user validity.
         if (!preg_match('/[-a-z0-9\\.]+/s', $alias)) {
             $page->trigError("'{$alias}' n'est pas un alias valide");
         }
         // Eventually adds the alias to the right domain.
         if ($domain == $globals->mail->alias_dom || $domain == $globals->mail->alias_dom2) {
             $req = new AliasReq($user, $alias, 'Admin request', false);
             if ($req->commit()) {
                 $page->trigSuccess("Nouvel alias '{$alias}@{$domain}' attribué.");
             } else {
                 $page->trigError("Impossible d'ajouter l'alias '{$alias}@{$domain}', il est probablement déjà attribué.");
             }
         } elseif ($domain == $user->mainEmailDomain()) {
             XDB::execute('INSERT INTO  email_source_account (email, uid, domain, type, flags)
                                SELECT  {?}, {?}, id, \'alias\', \'\'
                                  FROM  email_virtual_domains
                                 WHERE  name = {?}', $alias, $user->id(), $domain);
             $page->trigSuccess("Nouvel alias '{$alias}' ajouté");
         } else {
             $page->trigError("Le domaine '{$domain}' n'est pas valide pour cet utilisateur.");
         }
     } else {
         if (!Post::blank('del_alias')) {
             $delete_alias = Post::t('del_alias');
             list($email, $domain) = explode('@', $delete_alias);
             XDB::execute('DELETE  s
                         FROM  email_source_account  AS s
                   INNER JOIN  email_virtual_domains AS m ON (s.domain = m.id)
                   INNER JOIN  email_virtual_domains AS d ON (d.aliasing = m.id)
                        WHERE  s.email = {?} AND s.uid = {?} AND d.name = {?} AND type != \'forlife\'', $email, $user->id(), $domain);
             XDB::execute('UPDATE  email_redirect_account AS r
                   INNER JOIN  email_virtual_domains  AS m ON (m.name = {?})
                   INNER JOIN  email_virtual_domains  AS d ON (d.aliasing = m.id)
                          SET  r.rewrite = \'\'
                        WHERE  r.uid = {?} AND r.rewrite = CONCAT({?}, \'@\', d.name)', $domain, $user->id(), $email);
             fix_bestalias($user);
             $page->trigSuccess("L'alias '{$delete_alias}' a été supprimé");
         } else {
             if (!Post::blank('best')) {
                 $best_alias = Post::t('best');
                 // First delete the bestalias flag from all this user's emails.
                 XDB::execute("UPDATE  email_source_account\n                             SET  flags = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', flags, ','), ',bestalias,', ','))\n                           WHERE  uid = {?}", $user->id());
                 // Then gives the bestalias flag to the given email.
                 list($email, $domain) = explode('@', $best_alias);
                 XDB::execute("UPDATE  email_source_account\n                             SET  flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'bestalias')\n                           WHERE  uid = {?} AND email = {?}", $user->id(), $email);
                 // As having a non-null bestalias value is critical in
                 // plat/al's code, we do an a posteriori check on the
                 // validity of the bestalias.
                 fix_bestalias($user);
             }
         }
     }
     // }}}
     // OpenId form {{{
     if (Post::has('del_openid')) {
         XDB::execute('DELETE FROM  account_auth_openid
                             WHERE  id = {?}', Post::i('del_openid'));
     }
     // }}}
     // Forum form {{{
     if (Post::has('b_edit')) {
         XDB::execute("DELETE FROM  forum_innd\n                                WHERE  uid = {?}", $user->id());
         if (Env::v('write_perm') != "" || Env::v('read_perm') != "" || Env::v('commentaire') != "") {
             XDB::execute("INSERT INTO  forum_innd\n                                      SET  ipmin = '0', ipmax = '4294967295',\n                                           write_perm = {?}, read_perm = {?},\n                                           comment = {?}, priority = '200', uid = {?}", Env::v('write_perm'), Env::v('read_perm'), Env::v('comment'), $user->id());
         }
     }
     // }}}
     $page->addJsLink('jquery.ui.xorg.js');
     // Displays last login and last host information.
     $res = XDB::query("SELECT  start, host\n                             FROM  log_sessions\n                            WHERE  uid = {?} AND suid IS NULL\n                         ORDER BY  start DESC\n                            LIMIT  1", $user->id());
     list($lastlogin, $host) = $res->fetchOneRow();
     $page->assign('lastlogin', $lastlogin);
     $page->assign('host', $host);
     // Display mailing lists
     $page->assign('mlists', $listClient->get_all_user_lists($user->forlifeEmail()));
     // Display active aliases.
     $page->assign('virtuals', $user->emailGroupAliases());
     $aliases = XDB::iterator("SELECT  CONCAT(s.email, '@', d.name) AS email, (s.type = 'forlife') AS forlife,\n                                          (s.email REGEXP '\\\\.[0-9]{2}\$') AS hundred_year,\n                                          FIND_IN_SET('bestalias', s.flags) AS bestalias, s.expire,\n                                          (s.type = 'alias_aux') AS alias\n                                    FROM  email_source_account  AS s\n                              INNER JOIN  email_virtual_domains AS d ON (s.domain = d.id)\n                                   WHERE  s.uid = {?}\n                                ORDER BY  !alias, s.email", $user->id());
     $page->assign('aliases', $aliases);
     $page->assign('account_types', XDB::iterator('SELECT * FROM account_types ORDER BY type'));
     $page->assign('skins', XDB::iterator('SELECT id, name FROM skins ORDER BY name'));
     $page->assign('profiles', XDB::iterator('SELECT  p.pid, p.hrpid, FIND_IN_SET(\'owner\', ap.perms) AS owner, p.ax_id
                                                FROM  account_profiles AS ap
                                          INNER JOIN  profiles AS p ON (ap.pid = p.pid)
                                               WHERE  ap.uid = {?}', $user->id()));
     $page->assign('openid', XDB::iterator('SELECT  id, url
                                              FROM  account_auth_openid
                                             WHERE  uid = {?}', $user->id()));
     // Displays email redirection and the general profile.
     if ($registered && $redirect) {
         $page->assign('emails', $redirect->emails);
     }
     $page->assign('user', $user);
     $page->assign('hasProfile', $user->hasProfile());
     // Displays forum bans.
     $res = XDB::query("SELECT  write_perm, read_perm, comment\n                             FROM  forum_innd\n                            WHERE  uid = {?}", $user->id());
     $bans = $res->fetchOneAssoc();
     $page->assign('bans', $bans);
 }
示例#7
0
 protected function _mail_body($isok)
 {
     if ($isok) {
         $res = "  Le changement de nom que tu as demandé vient d'être effectué.";
         if (!is_null($this->profileOwner)) {
             if ($this->old_alias != $this->new_alias) {
                 if ($this->old_alias) {
                     $res .= "\n\n  L'alias {$this->old_alias}@{$this->mail_domain} a été supprimé.";
                 }
                 if ($this->new_alias) {
                     $res .= "\n\n  L'alias {$this->new_alias}@{$this->mail_domain} est maintenant à ta disposition !";
                 }
             }
             if ($globals->mailstorage->googleapps_domain) {
                 require_once 'googleapps.inc.php';
                 $account = new GoogleAppsAccount($this->profileOwner);
                 if ($account->active()) {
                     $res .= "\n\n  Si tu utilises Google Apps, tu peux changer ton nom d'usage sur https://mail.google.com/a/polytechnique.org/#settings/accounts.";
                 }
             }
         }
         return $res;
     } else {
         return "  La demande de changement de nom que tu avais faite a été refusée.";
     }
 }
示例#8
0
文件: email.php 项目: Ekleog/platal
 function handler_redirect($page, $action = null, $email = null, $rewrite = null)
 {
     global $globals;
     require_once 'emails.inc.php';
     $page->changeTpl('emails/redirect.tpl');
     $user = S::user();
     $page->assign_by_ref('user', $user);
     $page->assign('eleve', $user->promo() >= date("Y") - 5);
     $redirect = new Redirect($user);
     // FS#703 : $_GET is urldecoded twice, hence
     // + (the data) => %2B (in the url) => + (first decoding) => ' ' (second decoding)
     // Since there can be no spaces in emails, we can fix this with :
     $email = str_replace(' ', '+', $email);
     // Apply email redirection change requests.
     $result = SUCCESS;
     if ($action == 'remove' && $email) {
         $result = $redirect->delete_email($email);
     }
     if ($action == 'active' && $email) {
         $redirect->modify_one_email($email, true);
     }
     if ($action == 'inactive' && $email) {
         $redirect->modify_one_email($email, false);
     }
     if ($action == 'rewrite' && $email) {
         $redirect->modify_one_email_redirect($email, $rewrite);
     }
     if (Env::has('emailop')) {
         S::assert_xsrf_token();
         $actifs = Env::v('emails_actifs', array());
         if (Env::v('emailop') == "ajouter" && Env::has('email')) {
             $error_email = false;
             $new_email = Env::v('email');
             if ($new_email == "*****@*****.**") {
                 $new_email = Env::v('email_new');
             }
             $result = $redirect->add_email($new_email);
             if ($result == ERROR_INVALID_EMAIL) {
                 $error_email = true;
                 $page->assign('email', $new_email);
             }
             $page->assign('retour', $result);
             $page->assign('error_email', $error_email);
         } elseif (empty($actifs)) {
             $result = ERROR_INACTIVE_REDIRECTION;
         } elseif (is_array($actifs)) {
             $result = $redirect->modify_email($actifs, Env::v('emails_rewrite', array()));
         }
     }
     switch ($result) {
         case ERROR_INACTIVE_REDIRECTION:
             $page->trigError('Tu ne peux pas avoir aucune adresse de redirection active, sinon ton adresse ' . $user->forlifeEmail() . ' ne fonctionnerait plus.');
             break;
         case ERROR_INVALID_EMAIL:
             $page->trigError('Erreur : l\'email n\'est pas valide.');
             break;
         case ERROR_LOOP_EMAIL:
             $page->trigError('Erreur : ' . $user->forlifeEmail() . ' ne doit pas être renvoyé vers lui-même, ni vers son équivalent en ' . $globals->mail->domain2 . ' ni vers polytechnique.edu.');
             break;
     }
     // Fetch existing email aliases.
     $alias = XDB::query('SELECT  CONCAT(s.email, \'@\', d.name) AS email, s.expire
                            FROM  email_source_account  AS s
                      INNER JOIN  email_virtual_domains AS m ON (s.domain = m.id)
                      INNER JOIN  email_virtual_domains AS d ON (m.id = d.aliasing)
                           WHERE  s.uid = {?}
                        ORDER BY  NOT(s.type = \'alias_aux\'), s.email, d.name', $user->id());
     $page->assign('alias', $alias->fetchAllAssoc());
     $page->assign('best_email', $user->bestEmail());
     $page->assign('emails', $redirect->emails);
     // Display GoogleApps acount information.
     require_once 'googleapps.inc.php';
     $page->assign('googleapps', GoogleAppsAccount::account_status($user->id()));
     require_once 'emails.combobox.inc.php';
     fill_email_combobox($page, array('job', 'stripped_directory'));
 }
示例#9
0
 public static function get_allowed_storages(User $user)
 {
     global $globals;
     $storages = array();
     // Google Apps storage is available for users with valid Google Apps account.
     require_once 'googleapps.inc.php';
     if ($user->checkPerms('gapps') && $globals->mailstorage->googleapps_domain && GoogleAppsAccount::account_status($user->id()) == 'active') {
         $storages[] = 'googleapps';
     }
     // IMAP storage is always visible to administrators, and is allowed for
     // everyone when the service is marked as 'active'.
     if ($globals->mailstorage->imap_active || S::admin()) {
         $storages[] = 'imap';
     }
     return $storages;
 }
示例#10
0
 public function commit()
 {
     require_once dirname(__FILE__) . '/../googleapps.inc.php';
     $account = new GoogleAppsAccount($this->user);
     return $account->do_unsuspend();
 }