projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Drops update time from profile_addresses.
[platal.git]
/
include
/
massmailer.inc.php
diff --git
a/include/massmailer.inc.php
b/include/massmailer.inc.php
index
db1441e
..
c866f90
100644
(file)
--- a/
include/massmailer.inc.php
+++ b/
include/massmailer.inc.php
@@
-1,6
+1,6
@@
<?php
/***************************************************************************
<?php
/***************************************************************************
- * Copyright (C) 2003-20
08
Polytechnique.org *
+ * Copyright (C) 2003-20
10
Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-19,6
+19,13
@@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
+// {{{ class MailNotFound
+
+class MailNotFound extends Exception {
+}
+
+// }}}
+
// {{{ class MassMailer
abstract class MassMailer
// {{{ class MassMailer
abstract class MassMailer
@@
-158,7
+165,7
@@
abstract class MassMailer
if (is_null($hash)) {
$hash = XDB::fetchOneCell("SELECT hash
FROM {$this->_subscriptionTable}
if (is_null($hash)) {
$hash = XDB::fetchOneCell("SELECT hash
FROM {$this->_subscriptionTable}
- WHERE u
ser_
id = {?}", $user->id());
+ WHERE uid = {?}", $user->id());
}
if (is_null($hash)) {
$hash = $this->createHash(array($user->displayName(), $user->fullName(),
}
if (is_null($hash)) {
$hash = $this->createHash(array($user->displayName(), $user->fullName(),
@@
-166,7
+173,7
@@
abstract class MassMailer
rand(), "X.org rulez"));
XDB::execute("UPDATE {$this->_subscriptionTable} as ni
SET ni.hash = {?}
rand(), "X.org rulez"));
XDB::execute("UPDATE {$this->_subscriptionTable} as ni
SET ni.hash = {?}
- WHERE ni.u
ser_id !
= {?}",
+ WHERE ni.u
id
= {?}",
$hash, $user->id());
}
$hash, $user->id());
}
@@
-183,12
+190,13
@@
abstract class MassMailer
protected function getAllRecipients()
{
global $globals;
protected function getAllRecipients()
{
global $globals;
- return "SELECT a.uid, a.hruid, a.display_name, a.full_name, a.email_format,
- ni.hash AS hash
+ return "SELECT a.uid
FROM {$this->_subscriptionTable} AS ni
FROM {$this->_subscriptionTable} AS ni
- INNER JOIN accounts AS a ON (ni.u
ser_
id = a.uid)
+ INNER JOIN accounts AS a ON (ni.uid = a.uid)
LEFT JOIN email_options AS eo ON (eo.uid = a.uid)
LEFT JOIN emails AS e ON (e.uid = a.uid AND e.flags='active')
LEFT JOIN email_options AS eo ON (eo.uid = a.uid)
LEFT JOIN emails AS e ON (e.uid = a.uid AND e.flags='active')
+ LEFT JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms))
+ LEFT JOIN profile_display AS pd ON (ap.pid = pd.pid)
WHERE ni.last < {?} AND ({$this->subscriptionWhere()}) AND
(e.email IS NOT NULL OR FIND_IN_SET('googleapps', eo.storage))
GROUP BY a.uid";
WHERE ni.last < {?} AND ({$this->subscriptionWhere()}) AND
(e.email IS NOT NULL OR FIND_IN_SET('googleapps', eo.storage))
GROUP BY a.uid";
@@
-197,16
+205,18
@@
abstract class MassMailer
public function sendToAll()
{
$this->setSent();
public function sendToAll()
{
$this->setSent();
- $query = XDB::format($this->getAllRecipients(), $this->id()) . ' LIMIT 60';
+ $query = XDB::format($this->getAllRecipients(), $this->_id) . ' LIMIT 60';
+ $emailsCount = 0;
+
while (true) {
while (true) {
- $
res = XDB::iterRow($query
);
- if (
!$res->total()
) {
- return;
+ $
users = User::getBulkUsersWithUIDs(XDB::fetchColumn($query)
);
+ if (
count($users) == 0
) {
+ return
$emailsCount
;
}
}
- while ($infos = $res->next()) {
- $user = User::getSilentWithValues(null, $infos);
- $sent[] = XDB::format('user_id = {?}', $user->id());
+ foreach ($users as $user) {
+ $sent[] = XDB::format('uid = {?}', $user->id());
$this->sendTo($user, $hash);
$this->sendTo($user, $hash);
+ ++$emailsCount;
}
XDB::execute("UPDATE {$this->_subscriptionTable}
SET last = {?}
}
XDB::execute("UPDATE {$this->_subscriptionTable}
SET last = {?}
@@
-214,6
+224,7
@@
abstract class MassMailer
sleep(60);
}
sleep(60);
}
+ return $emailsCount;
}
abstract protected function assignData(&$smarty);
}
abstract protected function assignData(&$smarty);