From: Florent Bruneau Date: Sun, 28 Feb 2010 17:12:14 +0000 (+0100) Subject: Port email/send X-Git-Tag: xorg/1.0.0~332^2~145 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=48e683dd9a1ec2eaa096d21ca3fd27f3010349e3;p=platal.git Port email/send Signed-off-by: Florent Bruneau --- diff --git a/classes/user.php b/classes/user.php index 532b39e..7db7df4 100644 --- a/classes/user.php +++ b/classes/user.php @@ -278,14 +278,6 @@ class User extends PlUser return $this->profile()->promo(); } - public function yearpromo() - { - if (!$this->hasProfile()) { - return 0; - } - return $this->profile()->yearpromo(); - } - public function firstName() { if (!$this->hasProfile()) { @@ -480,7 +472,7 @@ class User extends PlUser // Contacts private $contacts = null; - public function isContact(PlUser &$user) + private function fetchContacts() { if (is_null($this->contacts)) { $this->contacts = XDB::fetchAllAssoc('contact', 'SELECT * @@ -488,6 +480,23 @@ class User extends PlUser WHERE uid = {?}', $this->id()); } + } + + public function iterContacts() + { + $this->fetchContacts(); + return self::iterOverUIDs(array_keys($this->contacts)); + } + + public function getContacts() + { + $this->fetchContacts(); + return self::getBulkUsersWithUIDs(array_keys($this->contacts)); + } + + public function isContact(PlUser &$user) + { + $this->fetchContacts(); return isset($this->contacts[$user->id()]); } diff --git a/modules/email.php b/modules/email.php index 057de8d..9a77979 100644 --- a/modules/email.php +++ b/modules/email.php @@ -381,7 +381,8 @@ class EmailModule extends PLModule $_POST['cc_contacts'] = explode(';', @$_POST['cc_contacts']); $data = serialize($_POST); XDB::execute("REPLACE INTO email_send_save - VALUES ({?}, {?})", S::i('uid'), $data); + VALUES ({?}, {?})", + S::user()->id('uid'), $data); } exit; } else if (Env::v('submit') == 'Envoyer') { @@ -411,7 +412,8 @@ class EmailModule extends PLModule if (!$error) { XDB::execute("DELETE FROM email_send_save - WHERE uid = {?}", S::i('uid')); + WHERE uid = {?}", + S::user()->id()); $to2 = getEmails(Env::v('to_contacts')); $cc2 = getEmails(Env::v('cc_contacts')); @@ -478,14 +480,8 @@ class EmailModule extends PLModule } } - $res = XDB::query( - "SELECT ac.full_name, a.alias as forlife - FROM accounts AS ac - INNER JOIN contacts AS c ON (ac.uid = c.contact) - INNER JOIN aliases AS a ON (ac.uid = a.uid AND FIND_IN_SET('bestalias', a.flags)) - WHERE c.uid = {?} - ORDER BY ac.full_name", S::i('uid')); - $page->assign('contacts', $res->fetchAllAssoc()); + $contacts = S::user()->getContacts(); + $page->assign('contacts', $contacts); $page->assign('maxsize', ini_get('upload_max_filesize') . 'o'); $page->assign('user', S::user()); } diff --git a/templates/emails/send.tpl b/templates/emails/send.tpl index 3c5b88c..4e9b0d3 100644 --- a/templates/emails/send.tpl +++ b/templates/emails/send.tpl @@ -211,18 +211,18 @@

{foreach item=contact from=$contacts} - {if !in_array($contact.forlife, $smarty.request.to_contacts) && !in_array($contact.forlife, $smarty.request.cc_contacts)} - {/if} {/foreach}
{foreach item=contact from=$contacts} - + {/foreach} @@ -283,7 +283,7 @@ {$smarty.request.contenu} {if !$smarty.request.contenu} -- -{$smarty.session.prenom} {$smarty.session.nom} +{$smarty.session.user->full_name} {/if}