本文整理汇总了PHP中XDB::changeFlag方法的典型用法代码示例。如果您正苦于以下问题:PHP XDB::changeFlag方法的具体用法?PHP XDB::changeFlag怎么用?PHP XDB::changeFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDB
的用法示例。
在下文中一共展示了XDB::changeFlag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handler_notifs
public function handler_notifs($page, $action = null, $arg = null)
{
$page->changeTpl('carnet/notifs.tpl');
if ($action) {
S::assert_xsrf_token();
switch ($action) {
case 'add_promo':
$this->addPromo($page, $arg);
break;
case 'del_promo':
$this->delPromo($page, $arg);
break;
case 'add_group':
$this->addGroup($page, $arg);
break;
case 'del_group':
$this->delGroup($page, $arg);
break;
case 'del_nonins':
$user = User::get($arg);
if ($user) {
$this->delNonRegistered($page, $user);
}
break;
case 'add_nonins':
$user = User::get($arg);
if ($user) {
$this->addNonRegistered($page, $user);
}
break;
}
}
if (Env::has('subs')) {
S::assert_xsrf_token();
$flags = new PlFlagSet();
foreach (Env::v('sub') as $key => $value) {
$flags->addFlag($key, $value);
}
XDB::execute('UPDATE watch
SET actions = {?}
WHERE uid = {?}', $flags, S::i('uid'));
S::user()->invalidWatchCache();
Platal::session()->updateNbNotifs();
}
if (Env::has('flags_contacts')) {
S::assert_xsrf_token();
XDB::execute('UPDATE watch
SET ' . XDB::changeFlag('flags', 'contacts', Env::b('contacts')) . '
WHERE uid = {?}', S::i('uid'));
S::user()->invalidWatchCache();
Platal::session()->updateNbNotifs();
}
if (Env::has('flags_mail')) {
S::assert_xsrf_token();
XDB::execute('UPDATE watch
SET ' . XDB::changeFlag('flags', 'mail', Env::b('mail')) . '
WHERE uid = {?}', S::i('uid'));
S::user()->invalidWatchCache();
Platal::session()->updateNbNotifs();
}
$user = S::user();
$nonins = new UserFilter(new UFC_WatchRegistration($user));
$promo = XDB::fetchColumn('SELECT promo
FROM watch_promo
WHERE uid = {?}
ORDER BY promo', S::i('uid'));
$page->assign('promo_count', count($promo));
$ranges = array();
$range_start = null;
$range_end = null;
foreach ($promo as $p) {
if (is_null($range_start)) {
$range_start = $range_end = $p;
} else {
if ($p != $range_end + 1) {
$ranges[] = array($range_start, $range_end);
$range_start = $range_end = $p;
} else {
$range_end = $p;
}
}
}
$ranges[] = array($range_start, $range_end);
$page->assign('promo_ranges', $ranges);
$page->assign('nonins', $nonins->getUsers());
$groups = XDB::fetchColumn('SELECT g.nom
FROM watch_group AS w
INNER JOIN groups AS g ON (g.id = w.groupid)
WHERE w.uid = {?}
ORDER BY g.nom', S::i('uid'));
$page->assign('groups', $groups);
$page->assign('groups_count', count($groups));
list($flags, $actions) = XDB::fetchOneRow('SELECT flags, actions
FROM watch
WHERE uid = {?}', S::i('uid'));
$flags = new PlFlagSet($flags);
$actions = new PlFlagSet($actions);
$page->assign('flags', $flags);
$page->assign('actions', $actions);
}