Changeset View
Changeset View
Standalone View
Standalone View
branches/5.3.x/core/units/users/users_event_handler.php
Show First 20 Lines • Show All 1029 Lines • ▼ Show 20 Line(s) | |||||
$skip_clause = $event->getEventParam('skip_clause'); | $skip_clause = $event->getEventParam('skip_clause'); | ||||
if ($skip_clause) { | if ($skip_clause) { | ||||
$sql .= ' AND !('.implode(') AND !(', $skip_clause).')'; | $sql .= ' AND !('.implode(') AND !(', $skip_clause).')'; | ||||
} | } | ||||
$records = $this->Conn->Query($sql); | $records = $this->Conn->Query($sql); | ||||
if ($records) { | if ($records) { | ||||
$conditions = Array(); | $conditions = Array(); | ||||
$send_params = Array ('PrefixSpecial' => 'u'); | |||||
/** @var UsersItem $user */ | |||||
$user = $this->Application->recallObject('u', null, array('skip_autoload' => true)); | |||||
foreach ($records as $record) { | foreach ($records as $record) { | ||||
$send_params['item_id'] = $record['PortalUserId']; | $user->Load($record['PortalUserId']); | ||||
$this->Application->emailUser('USER.MEMBERSHIP.EXPIRATION.NOTICE', $record['PortalUserId'], $send_params); | |||||
$this->Application->emailAdmin('USER.MEMBERSHIP.EXPIRATION.NOTICE', null, $send_params); | $this->Application->emailUser( | ||||
'USER.MEMBERSHIP.EXPIRATION.NOTICE', | |||||
$record['PortalUserId'], | |||||
$user->getEmailParams() | |||||
); | |||||
$this->Application->emailAdmin('USER.MEMBERSHIP.EXPIRATION.NOTICE', null, $user->getEmailParams()); | |||||
$conditions[] = '(PortalUserId = '.$record['PortalUserId'].' AND GroupId = '.$record['GroupId'].')'; | $conditions[] = '(PortalUserId = '.$record['PortalUserId'].' AND GroupId = '.$record['GroupId'].')'; | ||||
} | } | ||||
$sql = 'UPDATE '.TABLE_PREFIX.'UserGroupRelations | $sql = 'UPDATE '.TABLE_PREFIX.'UserGroupRelations | ||||
SET ExpirationReminderSent = 1 | SET ExpirationReminderSent = 1 | ||||
WHERE '.implode(' OR ', $conditions); | WHERE '.implode(' OR ', $conditions); | ||||
$this->Conn->Query($sql); | $this->Conn->Query($sql); | ||||
} | } | ||||
// send pre-expiration reminders: end | // send pre-expiration reminders: end | ||||
// remove users from groups with expired membership: begin | // remove users from groups with expired membership: begin | ||||
$sql = 'SELECT PortalUserId | $sql = 'SELECT PortalUserId | ||||
FROM '.TABLE_PREFIX.'UserGroupRelations | FROM '.TABLE_PREFIX.'UserGroupRelations | ||||
WHERE (MembershipExpires IS NOT NULL) AND (MembershipExpires < '.time().')'; | WHERE (MembershipExpires IS NOT NULL) AND (MembershipExpires < '.time().')'; | ||||
$user_ids = $this->Conn->GetCol($sql); | $user_ids = $this->Conn->GetCol($sql); | ||||
if ($user_ids) { | if ($user_ids) { | ||||
$send_params = Array ('PrefixSpecial' => 'u'); | /** @var UsersItem $user */ | ||||
$user = $this->Application->recallObject('u', null, array('skip_autoload' => true)); | |||||
foreach ($user_ids as $id) { | foreach ($user_ids as $id) { | ||||
$send_params['item_id'] = $id; | $user->Load($id); | ||||
$this->Application->emailUser('USER.MEMBERSHIP.EXPIRED', $id, $send_params); | |||||
$this->Application->emailAdmin('USER.MEMBERSHIP.EXPIRED', null, $send_params); | $this->Application->emailUser('USER.MEMBERSHIP.EXPIRED', $id, $user->getEmailParams()); | ||||
$this->Application->emailAdmin('USER.MEMBERSHIP.EXPIRED', null, $user->getEmailParams()); | |||||
} | } | ||||
} | } | ||||
$sql = 'DELETE FROM '.TABLE_PREFIX.'UserGroupRelations | $sql = 'DELETE FROM '.TABLE_PREFIX.'UserGroupRelations | ||||
WHERE (MembershipExpires IS NOT NULL) AND (MembershipExpires < '.time().')'; | WHERE (MembershipExpires IS NOT NULL) AND (MembershipExpires < '.time().')'; | ||||
$this->Conn->Query($sql); | $this->Conn->Query($sql); | ||||
// remove users from groups with expired membership: end | // remove users from groups with expired membership: end | ||||
} | } | ||||
▲ Show 20 Lines • Show All 885 Lines • Show Last 20 Lines |