function loadByParams($params = array(), $limit = FALSE, $offset = FALSE) { global $database; $extra_clause = ""; if ($limit !== FALSE and !empty($limit)) { $extra_clause .= " LIMIT {$limit}"; } if ($offset !== FALSE and !empty($offset)) { $extra_clause .= " OFFSET {$offset}"; } $query = "SELECT " . $this->_tbl . ".id FROM " . $this->_tbl . " " . buildWhere($params) . " {$extra_clause};"; $database->setQuery($query); $database->query(); if ($database->getNumRows() > 1) { $jObjs = array(); $row = (array) $database->loadResultArray(); foreach ($row as $id) { $jObj = new jRemind($database); $jObj->load($id); array_push($jObjs, $jObj); } return $jObjs; } else { if ($database->getNumRows() == 1) { $this->load($database->loadResult()); return $this; } else { return FALSE; } } }
$jTipsUser = new jTipsUser($database); $jTipsUser->load($user['id']); //jTipsLogger::_log($jTipsUser); if ($jTipsUser->getPreference('email_reminder')) { $recipient = $user['email']; $user['round'] = $round[0]['round']; $user['competition'] = $round[0]['season']; $user['season'] = $round[0]['season']; $body = parseTemplate($body, $variables, $user); $record = array('round_id' => $round[0]['id'], 'user_id' => $user['id'], 'notified' => 0); $attempted++; if (jTipsMail($from, $fromname, $recipient, $subject, $body)) { $record['notified'] = 1; jTipsLogger::_log('sent reminder email to ' . $recipient . ' subject: ' . $subject . ' from: ' . $fromname . ' <' . $from . '>', 'info'); $sent++; } else { jTipsLogger::_log('failed to send reminder email to ' . $recipient, 'error'); } $jRemind = new jRemind($database); $jRemindParams = array('round_id' => $record['round_id'], 'user_id' => $record['user_id']); $jRemind->loadByParams($jRemindParams); $jRemind->attempts++; $jRemind->bind($record); $jRemind->save(); } } } $result = 'Sent ' . $sent . ' out of ' . $attempted . ' jTips reminder emails for ' . count($season_ids) . ' seasons'; jTipsLogger::_log($result, 'INFO'); echo $result; exit;