class MailStorage {
protected $uid;
protected $name;
+ protected $storage;
public function __construct($_uid, $_name)
{
$this->uid = $_uid;
$this->name = $_name;
- }
- public function disable()
- {
$res = XDB::query("SELECT mail_storage
FROM auth_user_md5
WHERE user_id = {?}", $this->uid);
- $storages = explode(',', $res->fetchOneCell());
+ $this->storages = new FlagSet($res->fetchOneCell());
+ }
- if (in_array($this->name, $storages)) {
- array_splice($storages, array_search($this->name, $storages), 1);
- XDB::execute("UPDATE auth_user_md5
- SET mail_storage = {?}
- WHERE user_id = {?}", implode(',', $storages), $this->uid);
- }
+ public function disable()
+ {
+ $this->storages->rmFlag($this->name);
+ XDB::execute("UPDATE auth_user_md5
+ SET mail_storage = {?}
+ WHERE user_id = {?}", $this->storages->flags(), $this->uid);
}
public function enable()
{
+ $this->storages->addFlag($this->name);
XDB::execute("UPDATE auth_user_md5
- SET mail_storage = CONCAT_WS(',', IF(mail_storage = '', NULL, mail_storage), {?})
- WHERE user_id = {?} AND
- FIND_IN_SET({?}, mail_storage) = 0", $this->name, $this->uid, $this->name);
+ SET mail_storage = {?}
+ WHERE user_id = {?}", $this->storages->flags(), $this->uid);
}
}
{if count($storage) neq 0}
Ton courrier est également stocké sur {if count($storage) eq 1}le compte suivant{else} les comptes suivants{/if} :
<ul>
- {foreach from=$storage item=s}
{if in_array('googleapps', $storage)}
<li><a href="https://www.polytechnique.org/Xorg/GoogleApps">
<strong>Compte Google Apps / GMail de Polytechnique.org</strong>
</a></li>
- {elseif in_array('imap', $storage)}
+ {/if}
+ {if in_array('imap', $storage)}
<li><a href="https://www.polytechnique.org/Xorg/IMAP">
<strong>Accès de secours aux emails (IMAP)</strong>
</a></li>
{/if}
- {/foreach}
</ul>
{/if}
{test_email}