function handler_coml_remaining($page) { pl_content_headers('text/html'); $page->changeTpl('newsletter/remaining.tpl', NO_SKIN); $article = new ComLArticle('', Post::t('body'), ''); $rest = $article->remain(); $page->assign('too_long', $rest['remaining_lines'] < 0); $page->assign('last_line', $rest['remaining_lines'] == 0); $page->assign('remaining', $rest['remaining_lines'] == 0 ? $rest['remaining_characters_for_last_line'] : $rest['remaining_lines']); }
function handler_map_url($page) { pl_content_headers('text/plain'); if (Post::has('text')) { $address = new Address(array('text' => Post::t('text'))); $gmapsGeocoder = new GMapsGeocoder(); $gmapsGeocoder->getGeocodedAddress($address); echo GMapsGeocoder::buildStaticMapURL($address->latitude, $address->longitude, Post::t('color')); } exit; }
public function DisplayStandalone($page, $previous_reminder = null) { pl_content_headers("text/html"); $page->changeTpl('reminder/base.tpl', NO_SKIN); $this->Prepare($page); if ($previous_reminder) { $page->assign('previous_reminder', $previous_reminder); } }
function handler_ajax($page, $list = null) { pl_content_headers("text/html"); $page->changeTpl('lists/liste.inc.tpl', NO_SKIN); S::assert_xsrf_token(); $mlist = $this->prepare_list($list); if (Get::has('unsubscribe')) { $mlist->unsubscribe(); } if (Get::has('subscribe')) { $mlist->subscribe(); } if (Get::has('sadd')) { $mlist->handleRequest(MailingList::REQ_SUBSCRIBE, Get::v('sadd')); } if (Get::has('mid')) { $this->moderate_mail($mlist, Get::i('mid')); } list($liste, $members, $owners) = $mlist->getMembers(); if ($liste['own']) { list($subs, $mails) = $this->get_pending_ops($mlist); $liste['subscriptions'] = $subs; $liste['mails'] = $mails; } $page->register_modifier('hdc', 'list_header_decode'); $page->assign_by_ref('liste', $liste); }
function handler_ajax($page, $type) { $this->load('survey.inc.php'); pl_content_headers("text/html"); if (Survey::isType($type)) { // when type has been chosen, the form is updated to fit exactly the type of question chosen $page->changeTpl('survey/edit_new.tpl', NO_SKIN); $page->assign('survey_types', Survey::getTypes()); $page->assign('survey_type', $type); } }
public function RenderUserXrdsPage($page, User $user) { pl_content_headers("application/xrds+xml"); $page->changeTpl('openid/user_xrds.tpl', NO_SKIN); $page->assign('type2', Auth_OpenID_TYPE_2_0); $page->assign('type1', Auth_OpenID_TYPE_1_1); $page->assign('sreg', Auth_OpenID_SREG_URI); $page->assign('provider', $this->base_url); $page->assign('local_id', $user->login()); }
/** * Display a JSon page containing the sub-branches of a branch in the job terms tree. * @param $page the Platal page * @param $filter filter helps to display only jobterms that are contained in jobs or in mentors * * @param Env::i('jtid') job term id of the parent branch, if none trunk will be used * @param Env::v('attrfunc') the name of a javascript function that will be called when a branch * is chosen * @param Env::v('treeid') tree id that will be given as first argument of attrfunc function * the second argument will be the chosen job term id and the third one the chosen job's full name. * @param Env::v('text_filter') a string (usually ending by %) that will be used to filter * subbranches, keeping only the one containing this text in its title or in the title of one of * its subbranches. */ public static function ajaxGetBranch($page, $filter = self::ALL) { pl_content_headers('application/json'); $page->changeTpl('include/jobterms.branch.tpl', NO_SKIN); $subTerms = self::getSubTerms(Env::v('jtid'), $filter, Env::v('text_filter')); $page->assign('subTerms', $subTerms); switch ($filter) { case self::ONLY_JOBS: $page->assign('filter', 'camarade'); break; case self::ONLY_MENTORS: $page->assign('filter', 'mentor'); break; } $page->assign('jtid', Env::v('jtid')); $page->assign('text_filter', Env::v('text_filter')); $page->assign('attrfunc', Env::v('attrfunc')); $page->assign('treeid', Env::v('treeid')); }
function handler_icalendar($page, $type = 'friends', $user = null, $hash = null) { $user = User::from($user); if (!$user) { return PL_FORBIDDEN; } $user->select(UserSelect::base()); if ($user->hash_rss() != $hash) { return PL_FORBIDDEN; } if ($type == 'participate') { $activities = new ActivityInstanceFilter(new PFC_AND(new AIFC_Participants(S::user()), new AIFC_END(new FrankizDateTime(), AIFC_End::AFTER))); } else { $activities = new ActivityInstanceFilter(new PFC_Or(new PFC_And(new AIFC_END(new FrankizDateTime(), AIFC_End::AFTER), new AIFC_User($user, 'restricted')), new PFC_And(new AIFC_END(new FrankizDateTime(), AIFC_End::AFTER), new AIFC_User($user, 'everybody')))); } $c = $activities->get(); $c->select(ActivityInstanceSelect::all()); $page->assign('view', $type); $page->assign('activities', $c); $page->changeTpl('activity/icalendar.tpl', NO_SKIN); pl_content_headers("text/calendar"); }
function handler_tips($page, $tips = null) { pl_content_headers("text/html"); $page->changeTpl('include/tips.tpl', NO_SKIN); $page->assign('tips', $this->get_tips($tips)); }
function handler_admin_member_new_ajax($page) { pl_content_headers("text/html"); $page->changeTpl('xnetgrp/membres-new-search.tpl', NO_SKIN); $users = array(); $same_email = false; if (Env::has('login')) { $user = User::getSilent(Env::t('login')); if ($user && $user->state != 'pending') { $users = array($user->id() => $user); $same_email = true; } } if (empty($users)) { list($lastname, $firstname) = str_replace(array('-', ' ', "'"), '%', array(Env::t('nom'), Env::t('prenom'))); $cond = new PFC_And(); if (!empty($lastname)) { $cond->addChild(new UFC_NameTokens($lastname, array(), false, false, Profile::LASTNAME)); } if (!empty($firstname)) { $cond->addChild(new UFC_NameTokens($firstname, array(), false, false, Profile::FIRSTNAME)); } if (Env::t('promo')) { $cond->addChild(new UFC_Promo('=', UserFilter::DISPLAY, Env::t('promo'))); } $uf = new UserFilter($cond); $users = $uf->getUsers(new PlLimit(30)); if ($uf->getTotalCount() > 30) { $page->assign('too_many', true); $users = array(); } } $page->assign('users', $users); $page->assign('same_email', $same_email); }
/** * @param $page The page * @param $login The hruid of the user * @param $token The hash_rss for identification */ public function run(FrankizPage $page, $login, $token) { $uf = new UserFilter(new UFC_Hruid($login)); $user = $uf->get(true); if (!$user) { return PL_FORBIDDEN; } $user->select(UserSelect::feed()); if ($user->hash_rss() != $token) { return PL_FORBIDDEN; } $page->assign('rss_hash', $token); pl_content_headers("application/rss+xml"); $this->iterator = $this->fetch($user); $page->coreTpl('feed.rss2.tpl', NO_SKIN); $page->assign_by_ref('feed', $this); $page->run(); }
function handler_ical($page, $eid = null) { global $globals; $this->load('xnetevents.inc.php'); $evt = get_event_detail($eid); if (!$evt) { return PL_FORBIDDEN; } $evt['debut'] = preg_replace('/(\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)/', "\\1\\2\\3T\\4\\5\\6", $evt['debut']); $evt['fin'] = preg_replace('/(\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)/', "\\1\\2\\3T\\4\\5\\6", $evt['fin']); foreach ($evt['moments'] as $m) { $evt['descriptif'] .= "\n\n** " . $m['titre'] . " **\n" . $m['details']; } $page->changeTpl('xnetevents/calendar.tpl', NO_SKIN); require_once 'ical.inc.php'; $page->assign('asso', $globals->asso()); $page->assign('timestamp', time()); $page->assign('admin', may_update()); if (may_update()) { $page->assign('participants', get_event_participants($evt, null, UserFilter::sortByPromo())); } $page->register_function('display_ical', 'display_ical'); $page->assign_by_ref('e', $evt); pl_content_headers("text/calendar"); }
function handler_autologin($page) { $allkeys = func_get_args(); unset($allkeys[0]); $url = join('/', $allkeys); pl_content_headers("text/javascript"); echo '$.ajax({ url: "' . $url . '?forceXml=1", dataType: "xml", success: function(xml) { $("body",xml).insertBefore("body"); $("body:eq(1)").remove(); }});'; exit; }
public static function output_profiles($profiles, $lang) { pl_content_headers("text/plain", "iso8859-15"); $fields =& Outlook::$contact_fields[$lang]; foreach ($fields as $i => $k) { if ($i != 0) { echo ','; } echo Outlook::protect($k); } echo "\r\n"; foreach ($profiles as &$p) { $values = Outlook::profile_to_contact($p); foreach ($fields as $i => $k) { if ($i != 0) { echo ','; echo Outlook::protect($values[$k]); } else { // HACK to fix fullname $fullname = $p->firstName() . " " . $p->lastName(); echo Outlook::protect($fullname); } } echo "\r\n"; } }
/** * Page for url "profile/jobterms" (function also used for "referent/autocomplete" @see * handler_ref_autocomplete). Displays an "autocomplete" page (plain text with values * separated by "|" chars) for jobterms to add in profile. * @param $page the Platal page * @param $type set to 'mentor' to display the number of mentors for each term and order * by descending number of mentors. * * @param Env::v('q') the text that has been typed and to complete automatically */ function handler_jobterms($page, $type = 'nomentor') { pl_content_headers("text/plain"); $q = Env::v('term') . '%'; $tokens = JobTerms::tokenize($q); if (count($tokens) == 0) { exit; } sort($tokens); $q_normalized = implode(' ', $tokens); // Try to look in cached results. $cached = false; $cache = XDB::query('SELECT result FROM search_autocomplete WHERE name = {?} AND query = {?} AND generated > NOW() - INTERVAL 1 DAY', $type, $q_normalized); if ($cache->numRows() > 0) { $cached = true; $data = explode("\n", $cache->fetchOneCell()); $list = array(); foreach ($data as $line) { if ($line != '') { $aux = explode("\t", $line); if ($type == 'mentor') { $item = array('field' => $aux[0], 'nb' => $aux[1], 'id' => $aux[2]); $item['value'] = SearchModule::format_autocomplete($item); } else { $item = array('value' => $aux[0], 'id' => $aux[1]); } array_push($list, $item); } } } else { $joins = JobTerms::token_join_query($tokens, 'e'); if ($type == 'mentor') { $count = ', COUNT(DISTINCT pid) AS nb'; $countjoin = ' INNER JOIN profile_job_term_relation AS r ON(r.jtid_1 = e.jtid) INNER JOIN profile_mentor_term AS m ON(r.jtid_2 = m.jtid)'; $countorder = 'nb DESC, '; } else { $count = $countjoin = $countorder = ''; } $list = XDB::fetchAllAssoc('SELECT e.jtid AS id, e.full_name AS field' . $count . ' FROM profile_job_term_enum AS e ' . $joins . $countjoin . ' GROUP BY e.jtid ORDER BY ' . $countorder . 'field LIMIT ' . DirEnumeration::AUTOCOMPLETE_LIMIT); $to_cache = ''; if ($type == 'mentor') { foreach ($list as &$item) { $to_cache .= $item['field'] . "\t" . $item['nb'] . "\t" . $item['id'] . "\n"; $item['value'] = SearchModule::format_autocomplete($item); } } else { foreach ($list as &$item) { $to_cache .= $item['field'] . "\t" . $item['id'] . "\n"; $item['value'] = $item['field']; } } } if (count($list) == DirEnumeration::AUTOCOMPLETE_LIMIT && $type == 'nomentor') { $list[] = array('value' => '… parcourir les résultats dans un arbre …', 'field' => '', 'id' => -1); } if (!$cached) { XDB::query('INSERT INTO search_autocomplete (name, query, result, generated) VALUES ({?}, {?}, {?}, NOW()) ON DUPLICATE KEY UPDATE result = VALUES(result), generated = VALUES(generated)', $type, $q_normalized, $to_cache); } echo json_encode($list); exit; }
/** * Builds a select field to choose among countries that referents * know about. Only referents linked to term (jtid) are displayed. * @param $jtid id of job term to restrict referents */ function handler_referent_countries($page, $jtid = null) { pl_content_headers("text/xml"); $page->changeTpl('include/field.select.tpl', NO_SKIN); $page->assign('name', 'country'); $it = XDB::iterator("SELECT gc.iso_3166_1_a2 AS id, gc.country AS field\n FROM geoloc_countries AS gc\n INNER JOIN profile_mentor_country AS mp ON (mp.country = gc.iso_3166_1_a2)\n INNER JOIN profile_mentor_term AS mt ON (mt.pid = mp.pid)\n INNER JOIN profile_job_term_relation AS jtr ON (jtr.jtid_2 = mt.jtid)\n WHERE jtr.jtid_1 = {?}\n GROUP BY gc.iso_3166_1_a2\n ORDER BY gc.country", $jtid); $page->assign('list', $it); }