+ // Returns the list of allowed storages for the @p user.
+ static public function get_allowed_storages($uid)
+ {
+ global $globals;
+ $storages = array();
+
+ // Google Apps storage is available for users with valid Google Apps account.
+ require_once 'googleapps.inc.php';
+ if ($globals->mailstorage->googleapps_domain &&
+ GoogleAppsAccount::account_status($uid) == '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::has_perms()) {
+ $storages[] = 'imap';
+ }
+
+ return $storages;
+ }
+
+
+ public function __construct($uid, $name)
+ {
+ $this->uid = $uid;
+ $this->email = $name;
+ $this->display_email = (isset($this->display_names[$name]) ? $this->display_names[$name] : $name);
+
+ $storages = $this->get_storages();
+ $this->sufficient = ($name == 'googleapps');
+ $this->active = $storages->hasFlag($name);
+ $this->broken = false;
+ $this->disabled = false;
+ $this->rewrite = '';
+ $this->panne = $this->last = $this->panne_level = 0;
+ }
+
+ public function activate()
+ {
+ if (!$this->active) {
+ $storages = $this->get_storages();
+ $storages->addFlag($this->email);
+ $this->set_storages($storages);
+ $this->active = true;
+ }
+ }
+
+ public function deactivate()
+ {
+ if ($this->active) {
+ $storages = $this->get_storages();
+ $storages->rmFlag($this->email);
+ $this->set_storages($storages);
+ $this->active = false;
+ }
+
+ }
+
+ // Source rewrite can't be enabled for email storage addresses.
+ public function set_rewrite($rewrite) {}
+
+ // Email storage are not supposed to be broken, hence not supposed to be
+ // cleaned-up.
+ public function clean_errors() {}
+
+ // Capabilities.
+ public function has_rewrite() { return false; }
+ public function is_removable() { return false; }
+ public function has_disable() { return false; }
+}
+
+// class Redirect {{{1
+// Redirect is a placeholder class for an user's active redirections (third-party
+// redirection email, or Polytechnique.org mail storages).