function smarty_modifier_rel($path) { if (substr($path, -3) == 'css') { return FrankizPage::getCssPath($path); } else { return FrankizPage::getTplPath($path); } }
function handler_ajax_admin($page) { $json = json_decode(Env::v('json')); $id = $json->id; if (isset($json->admin)) { $a = new ActivityInstance($id); $a->select(ActivityInstanceSelect::base()); if (!S::user()->hasRights($a->target()->group(), Rights::admin())) { throw new Exception("Invalid credentials"); } $page->assign('activity', $a); if ($a->regular()) { $result = $page->fetch(FrankizPage::getTplPath('activity/modify_instance_regular.tpl')); } else { $result = $page->fetch(FrankizPage::getTplPath('activity/modify_punctual.tpl')); } $page->jsonAssign('success', true); $page->jsonAssign('activity', $result); } elseif (isset($json->regular)) { $a = new Activity($id); $a->select(ActivitySelect::base()); if (!S::user()->hasRights($a->target()->group(), Rights::admin())) { throw new Exception("Invalid credentials"); } $page->assign('activity', $a); $result = $page->fetch(FrankizPage::getTplPath('activity/modify_regular_activity.tpl')); $page->jsonAssign('success', true); $page->jsonAssign('activity', $result); } return PL_JSON; }
public function __construct() { global $globals; parent::__construct('Frankiz : Annonces', $globals->baseurl, 'Frankiz : le serveur des élèves de l\'École polytechnique', $globals->baseurl . '/css/' . FrankizPage::getCssPath('images/home_logo.png'), FrankizPage::getTplPath('news/rss.tpl')); }
public function sendLater($html = true) { global $globals; $this->page->assign('isHTML', $html); $tpl = FrankizPage::getTplPath($this->tpl); $content = $this->page->fetch($tpl); XDB::execute('INSERT INTO mails SET target = {?}, writer = {?}, writername = {?}, title = {?}, body = {?}, ishtml = {?}', json_encode($this->To->export()), $this->From, $this->FromName, $this->Subject, trim($content), $html); }
function handler_ajax_ranking($page) { $json = json_decode(Env::v('json')); $period = $json->period; $int = QDJ::interval(); $date_min = mktime(1, 0, 0, floor(($int['date_min']->format('n') - 1) / 2) * 2 + 1, 1, $int['date_min']->format('Y')); $date_max = mktime(1, 0, 0, floor(($int['date_max']->format('n') + 1) / 2) * 2 + 1, 1, $int['date_max']->format('Y')); $date = $date_min; $begin_dates = array(); $end_dates = array(); while ($date < $date_max) { $begin_dates[] = $date; $date = strtotime('+2 months', $date); $end_dates[] = strtotime('-1 day', $date); } $page->assign('results', $this->fetch_scores($begin_dates, $end_dates, $period)); $result = $page->fetch(FrankizPage::getTplPath('qdj/ranking.tpl')); $page->jsonAssign('success', true); $page->jsonAssign('result', $result); return PL_JSON; }
function handler_tol_ajax_sheet($page, $uid) { $f = new UserFilter(new UFC_Uid($uid)); $u = $f->get(true); if ($u) { $u->select(UserSelect::tol()); } $page->assign('user', S::user()); $page->assign('result', $u); try { $sheet = $page->filteredFetch(FrankizPage::getTplPath('tol/sheet.tpl')); } catch (Exception $e) { $sheet = "La fiche de l'utilisateur comporte des erreurs"; XDB::execute('INSERT INTO tol_errors SET error = {?}', $u->id()); } $page->jsonAssign('sheet', $sheet); $page->jsonAssign('success', true); return PL_JSON; }
function handler_group_ajax_admin_users($page) { $group = Group::fromId(Json::i('gid')); $limit = 10; $total = 0; $users = false; if ($group) { $users = array(); $order = new UFO_Name(UFO_Name::LASTNAME); $filters = array(); $rights = Rights::everybody(); if (Json::s('rights', '') != '') { $rights = new Rights(Json::s('rights')); } $filters[] = new UFC_Group($group, $rights); if (Json::t('promo', '') != '') { $filters[] = new UFC_Group(explode(';', Json::v('promo'))); } if (Json::t('name', '') != '') { $filters[] = new UFC_Name(Json::t('name'), UFC_Name::LASTNAME | UFC_Name::FIRSTNAME | UFC_Name::NICKNAME, UFC_Name::CONTAINS); } $uf = new UserFilter(new PFC_And($filters), $order); $users = $uf->get(new PlLimit($limit, (Json::i('page', 1) - 1) * $limit)); $total = $uf->getTotalCount(); $export = array(); if ($users->count() > 0) { $users->select(UserSelect::base()); /* * Fetching rights */ $users_rights = $group->selectRights($users); /* * Fetching comments */ $users_comments = array(); $iter = XDB::iterRow('SELECT uid, comment FROM users_comments WHERE gid = {?} AND uid IN {?}', $group->id(), $users->ids()); while (list($uid, $comment) = $iter->next()) { $users_comments[$uid] = $comment; } /* * Exporting */ $page->assign('defaultrights', array(Rights::admin(), Rights::member(), Rights::friend())); foreach ($users as $uid => $u) { $page->assign('user', $u); $page->assign('rights', empty($users_rights[$uid]) ? array() : $users_rights[$uid]); $page->assign('comment', empty($users_comments[$uid]) ? "" : $users_comments[$uid]); $export[$uid] = $page->filteredFetch(FrankizPage::getTplPath('groups/admin_user.tpl')); } } } $page->jsonAssign('limit', $limit); $page->jsonAssign('total', $total); $page->jsonAssign('users', $export); return PL_JSON; }
function handler_ajax_minimodules_add($page) { $json = json_decode(Env::v('json')); $m = FrankizMiniModule::get($json->name); $row = S::user()->addMinimodule($m); if ($row === false) { $page->jsonAssign('error', "Impossible d'activer le minimodule"); } else { $page->jsonAssign('name', $m->name()); $page->jsonAssign('css', FrankizPage::getCssPath($m->css())); $page->assign('minimodule', $m); $page->jsonAssign('html', $page->fetch(FrankizPage::getTplPath('minimodule.tpl'))); } return PL_JSON; }