Пример #1
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;
 }
Пример #2
0
 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'));
 }
Пример #3
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);
 }
Пример #4
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;
 }