本文整理汇总了PHP中Reminder::GetCandidateReminder方法的典型用法代码示例。如果您正苦于以下问题:PHP Reminder::GetCandidateReminder方法的具体用法?PHP Reminder::GetCandidateReminder怎么用?PHP Reminder::GetCandidateReminder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reminder
的用法示例。
在下文中一共展示了Reminder::GetCandidateReminder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handler_reminder
function handler_reminder($page, $reminder_name = null, $action = null)
{
require_once 'reminder.inc.php';
$user = S::user();
// If no reminder name was passed, or if we don't know that reminder name,
// just drop the request.
if (!$reminder_name || !($reminder = Reminder::GetByName($user, $reminder_name))) {
return PL_NOT_FOUND;
}
// Otherwise, the request is dispatched, and a new reminder, if any, is
// displayed.
$reminder->HandleAction($action);
$previous_reminder = $reminder->title();
if ($new_reminder = Reminder::GetCandidateReminder($user)) {
$new_reminder->DisplayStandalone($page, $previous_reminder);
} else {
$reminder->NotifiesAction($page);
}
}
示例2: handler_ev
function handler_ev($page, $action = 'list', $eid = null, $pound = null)
{
$page->changeTpl('events/index.tpl');
$user = S::user();
/** XXX: Tips and reminder only for user with 'email' permission.
* We can do better in the future by storing a userfilter
* with the tip/reminder.
*/
if ($user->checkPerms(User::PERM_MAIL)) {
$page->assign('tips', $this->get_tips());
}
// Adds a reminder onebox to the page.
require_once 'reminder.inc.php';
if ($reminder = Reminder::GetCandidateReminder($user)) {
$reminder->Prepare($page);
}
// Wishes "Happy birthday" when required
$profile = $user->profile();
if (!is_null($profile)) {
if ($profile->next_birthday == date('Y-m-d')) {
$birthyear = (int) date('Y', strtotime($profile->birthdate));
$curyear = (int) date('Y');
$page->assign('birthday', $curyear - $birthyear);
}
}
// Direct link to the RSS feed, when available.
if (S::hasAuthToken()) {
$page->setRssLink('Polytechnique.org :: News', '/rss/' . S::v('hruid') . '/' . S::user()->token . '/rss.xml');
}
// Hide the read event, and reload the page to get to the next event.
if ($action == 'read' && $eid) {
XDB::execute('DELETE ev.*
FROM announce_read AS ev
INNER JOIN announces AS e ON e.id = ev.evt_id
WHERE expiration < NOW()');
XDB::execute('INSERT IGNORE INTO announce_read (evt_id, uid)
VALUES ({?}, {?})', $eid, S::v('uid'));
pl_redirect('events#' . $pound);
}
// Unhide the requested event, and reload the page to display it.
if ($action == 'unread' && $eid) {
XDB::execute('DELETE FROM announce_read
WHERE evt_id = {?} AND uid = {?}', $eid, S::v('uid'));
pl_redirect('events#newsid' . $eid);
}
// Fetch the events to display, along with their metadata.
$array = array();
$it = XDB::iterator("SELECT e.id, e.titre, e.texte, e.post_id, e.uid,\n p.x, p.y, p.attach IS NOT NULL AS img, FIND_IN_SET('wiki', e.flags) AS wiki,\n FIND_IN_SET('important', e.flags) AS important,\n e.creation_date > DATE_SUB(CURDATE(), INTERVAL 2 DAY) AS news,\n e.expiration < DATE_ADD(CURDATE(), INTERVAL 2 DAY) AS end,\n ev.uid IS NULL AS nonlu, e.promo_min, e.promo_max\n FROM announces AS e\n LEFT JOIN announce_photos AS p ON (e.id = p.eid)\n LEFT JOIN announce_read AS ev ON (e.id = ev.evt_id AND ev.uid = {?})\n WHERE FIND_IN_SET('valide', e.flags) AND expiration >= NOW()\n ORDER BY important DESC, news DESC, end DESC, e.expiration, e.creation_date DESC", S::i('uid'));
$cats = array('important', 'news', 'end', 'body');
$this->load('feed.inc.php');
$user = S::user();
$body = EventFeed::nextEvent($it, $user);
foreach ($cats as $cat) {
$data = array();
if (!$body) {
continue;
}
do {
if ($cat == 'body' || $body[$cat]) {
$data[] = $body;
} else {
break;
}
$body = EventFeed::nextEvent($it, $user);
} while ($body);
if (!empty($data)) {
$array[$cat] = $data;
}
}
$page->assign_by_ref('events', $array);
}