function handler_members($page, $liste = null) { if (is_null($liste)) { return PL_NOT_FOUND; } $mlist = $this->prepare_list($liste); $this->is_group_admin($page); $page->changeTpl('lists/members.tpl'); if (Get::has('del')) { S::assert_xsrf_token(); $mlist->unsubscribe(); pl_redirect('lists/members/' . $liste); } if (Get::has('add')) { S::assert_xsrf_token(); $mlist->subscribe(); pl_redirect('lists/members/' . $liste); } $members = $mlist->getMembers(); $tri_promo = !Env::b('alpha'); if (list($det, $mem, $own) = $members) { $membres = list_sort_members($mem, $tri_promo); $moderos = list_sort_owners($own, $tri_promo); $page->assign_by_ref('details', $det); $page->assign_by_ref('members', $membres); $page->assign_by_ref('owners', $moderos); $page->assign('nb_m', count($mem)); } else { $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails."); } }
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); }
public function b($key, $def = false) { if ($this->fake_env) { return $this->fake_env->b($key, $def); } else { return Env::b($this->envprefix . $key, $def); } }