本文整理汇总了PHP中S::hasAuthToken方法的典型用法代码示例。如果您正苦于以下问题:PHP S::hasAuthToken方法的具体用法?PHP S::hasAuthToken怎么用?PHP S::hasAuthToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S
的用法示例。
在下文中一共展示了S::hasAuthToken方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _add_rss_link
function _add_rss_link($page)
{
if (!S::hasAuthToken()) {
return;
}
$page->setRssLink('Polytechnique.org :: Carnet', '/carnet/rss/' . S::v('hruid') . '/' . S::user()->token . '/rss.xml');
}
示例2: __construct
public function __construct(User $user, $params = null)
{
$this->user =& $user;
global $globals;
Banana::$msgedit_canattach = false;
Banana::$spool_root = $globals->spoolroot . '/spool/banana/';
array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail');
Banana::$nntp_host = self::buildURL($user->login());
if (S::admin()) {
Banana::$msgshow_mimeparts[] = 'source';
}
Banana::$debug_nntp = $globals->debug & DEBUG_BT;
Banana::$debug_smarty = $globals->debug & DEBUG_SMARTY;
Banana::$feed_active = S::hasAuthToken();
parent::__construct($params, 'NNTP', 'PlatalBananaPage');
if (@$params['action'] == 'profile') {
Banana::$action = 'profile';
}
}
示例3: __construct
function __construct(User $user, $params = null)
{
global $globals;
$this->user =& $user;
Banana::$spool_root = $globals->spoolroot . '/spool/banana/';
Banana::$spool_boxlist = false;
Banana::$msgedit_canattach = true;
Banana::$debug_mbox = $globals->debug & DEBUG_BT;
Banana::$debug_smarty = $globals->debug & DEBUG_SMARTY;
Banana::$mbox_helper = $globals->spoolroot . '/banana/mbox-helper/mbox-helper';
Banana::$feed_updateOnDemand = true;
if (S::admin()) {
Banana::$msgshow_mimeparts[] = 'source';
}
array_push(Banana::$msgparse_headers, 'x-org-id', 'x-org-mail');
Banana::$feed_active = S::hasAuthToken();
MLBanana::$listname = $params['listname'];
MLBanana::$domain = $params['domain'];
$params['group'] = $params['listname'] . '@' . $params['domain'];
parent::__construct($params, 'MLArchive', 'PlatalBananaMLPage');
}
示例4: handler_wiki
function handler_wiki($page, $action = 'list', $wikipage = null, $wikipage2 = null)
{
if (S::hasAuthToken()) {
$page->setRssLink('Changement Récents', '/Site/AllRecentChanges?action=rss&user=' . S::v('hruid') . '&hash=' . S::user()->token);
}
// update wiki perms
if ($action == 'update') {
S::assert_xsrf_token();
$perms_read = Post::v('read');
$perms_edit = Post::v('edit');
if ($perms_read || $perms_edit) {
foreach ($_POST as $wiki_page => $val) {
if ($val == 'on') {
$wp = new PlWikiPage(str_replace(array('_', '/'), '.', $wiki_page));
if ($wp->setPerms($perms_read ? $perms_read : $wp->readPerms(), $perms_edit ? $perms_edit : $wp->writePerms())) {
$page->trigSuccess("Permission de la page {$wiki_page} mises à jour");
} else {
$page->trigError("Impossible de mettre les permissions de la page {$wiki_page} à jour");
}
}
}
}
} else {
if ($action != 'list' && !empty($wikipage)) {
$wp = new PlWikiPage($wikipage);
S::assert_xsrf_token();
if ($action == 'delete') {
if ($wp->delete()) {
$page->trigSuccess("La page " . $wikipage . " a été supprimée.");
} else {
$page->trigError("Impossible de supprimer la page " . $wikipage . ".");
}
} else {
if ($action == 'rename' && !empty($wikipage2) && $wikipage != $wikipage2) {
if ($changedLinks = $wp->rename($wikipage2)) {
$s = 'La page <em>' . $wikipage . '</em> a été déplacée en <em>' . $wikipage2 . '</em>.';
if (is_numeric($changedLinks)) {
$s .= $changedLinks . ' lien' . ($changedLinks > 1 ? 's ont été modifiés.' : ' a été modifié.');
}
$page->trigSuccess($s);
} else {
$page->trigError("Impossible de déplacer la page " . $wikipage);
}
}
}
}
}
$perms = PlWikiPage::permOptions();
// list wiki pages and their perms
$wiki_pages = PlWikiPage::listPages();
ksort($wiki_pages);
$wiki_tree = array();
foreach ($wiki_pages as $file => $desc) {
list($cat, $name) = explode('.', $file);
if (!isset($wiki_tree[$cat])) {
$wiki_tree[$cat] = array();
}
$wiki_tree[$cat][$name] = $desc;
}
$page->changeTpl('admin/wiki.tpl');
$page->assign('wiki_pages', $wiki_tree);
$page->assign('perms_opts', $perms);
}
示例5: 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);
}
示例6: handler_index
function handler_index($page, $arg = null)
{
global $globals, $platal;
if (!is_null($arg)) {
return PL_NOT_FOUND;
}
$page->changeTpl('xnetgrp/asso.tpl');
if (S::logged()) {
if (Env::has('read')) {
XDB::query('DELETE r.*
FROM group_announces_read AS r
INNER JOIN group_announces AS a ON (a.id = r.announce_id)
WHERE expiration < CURRENT_DATE()');
XDB::query('INSERT INTO group_announces_read
VALUES ({?}, {?})', Env::i('read'), S::i('uid'));
pl_redirect("");
}
if (Env::has('unread')) {
XDB::query('DELETE FROM group_announces_read
WHERE announce_id = {?} AND uid = {?}', Env::i('unread'), S::i('uid'));
pl_redirect("#art" . Env::i('unread'));
}
/* TODO: refines this filter on promotions by using userfilter. */
$user = S::user();
if ($user->hasProfile()) {
$promo = XDB::format('{?}', $user->profile()->entry_year);
$minCondition = ' OR promo_min <= ' . $promo;
$maxCondition = ' OR promo_max >= ' . $promo;
} else {
$minCondition = '';
$maxCondition = '';
}
$arts = XDB::iterator('SELECT a.*, FIND_IN_SET(\'photo\', a.flags) AS photo
FROM group_announces AS a
LEFT JOIN group_announces_read AS r ON (r.uid = {?} AND r.announce_id = a.id)
WHERE asso_id = {?} AND expiration >= CURRENT_DATE()
AND (promo_min = 0' . $minCondition . ')
AND (promo_max = 0' . $maxCondition . ')
AND r.announce_id IS NULL
ORDER BY a.expiration', S::i('uid'), $globals->asso('id'));
$index = XDB::iterator('SELECT a.id, a.titre, r.uid IS NULL AS nonlu
FROM group_announces AS a
LEFT JOIN group_announces_read AS r ON (a.id = r.announce_id AND r.uid = {?})
WHERE asso_id = {?} AND expiration >= CURRENT_DATE()
AND (promo_min = 0' . $minCondition . ')
AND (promo_max = 0' . $maxCondition . ')
ORDER BY a.expiration', S::i('uid'), $globals->asso('id'));
$page->assign('article_index', $index);
} else {
$arts = XDB::iterator("SELECT *, FIND_IN_SET('photo', flags) AS photo\n FROM group_announces\n WHERE asso_id = {?} AND expiration >= CURRENT_DATE()\n AND FIND_IN_SET('public', flags)", $globals->asso('id'));
$payments = XDB::fetchAllAssoc("SELECT id, text\n FROM payments\n WHERE asso_id = {?} AND NOT FIND_IN_SET('old', flags) AND FIND_IN_SET('public', flags)\n ORDER BY id DESC", $globals->asso('id'));
$page->assign('payments', $payments);
}
if (may_update()) {
$subs_valid = XDB::query("SELECT uid\n FROM group_member_sub_requests\n WHERE asso_id = {?}", $globals->asso('id'));
$page->assign('requests', $subs_valid->numRows());
}
if (!S::hasAuthToken()) {
$page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News publiques", $platal->ns . "rss/rss.xml");
} else {
$page->setRssLink("Polytechnique.net :: {$globals->asso("nom")} :: News", $platal->ns . 'rss/' . S::v('hruid') . '/' . S::user()->token . '/rss.xml');
}
$page->assign('articles', $arts);
}