X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Faxletter%2Faxletter.inc.php;h=af34cac284c753948daa3a23c93686389f036594;hb=5d45be961ee2170ae9aa8bb15aaf2bdaaa45450a;hp=0f16c36a1e1146d5e727d714261e303c5a5d3bb0;hpb=4e25428d4d53f5e53332a5969ad002b4ebd397ad;p=platal.git diff --git a/modules/axletter/axletter.inc.php b/modules/axletter/axletter.inc.php index 0f16c36..af34cac 100644 --- a/modules/axletter/axletter.inc.php +++ b/modules/axletter/axletter.inc.php @@ -33,7 +33,7 @@ class AXLetter extends MassMailer function __construct($id) { - parent::__construct('axletter/letter.tpl', 'ax.css', 'ax/show'); + parent::__construct('axletter/letter.tpl', 'ax.css', 'ax/show', 'axletter', 'axletter_ins'); $this->_head = ' ,'; if (!is_array($id)) { @@ -56,6 +56,9 @@ class AXLetter extends MassMailer list($this->_id, $this->_shortname, $this->_title_mail, $this->_title, $this->_body, $this->_signature, $this->_promo_min, $this->_promo_max, $this->_echeance, $this->_date, $this->_bits) = $id; + if ($this->_date == '0000-00-00') { + $this->_date = 0; + } } protected function assignData(&$smarty) @@ -157,9 +160,28 @@ class AXLetter extends MassMailer return $res->fetchOneCell(); } - protected function subscriptionTable() + static public function grantPerms($uid) { - return 'axletter_ins'; + if (!is_numeric($uid)) { + $res = XDB::query("SELECT id FROM aliases WHERE alias = {?}", $uid); + $uid = $res->fetchOneCell(); + } + if (!$uid) { + return false; + } + return XDB::execute("INSERT IGNORE INTO axletter_rights SET user_id = {?}", $uid); + } + + static public function revokePerms($uid) + { + if (!is_numeric($uid)) { + $res = XDB::query("SELECT id FROM aliases WHERE alias = {?}", $uid); + $uid = $res->fetchOneCell(); + } + if (!$uid) { + return false; + } + return XDB::execute("DELETE FROM axletter_rights WHERE user_id = {?}", $uid); } protected function subscriptionWhere() @@ -217,5 +239,5 @@ class AXLetter extends MassMailer } } -// vim:set et sw=4 sts=4 sws=4: +// vim:set et sw=4 sts=4 sws=4 enc=utf-8: ?>