/** * Send an email to the members that have subsribe to this post * @param integer $id of the subscribed post * @return void */ public static function sendMail($id) { if (!jAuth::isConnected()) { return; } $dao = jDao::get(self::$daoSub); $memberDao = jDao::get('havefnubb~member'); //get all the members that subscribe to this thread except "ME" !!! $records = $dao->findSubscribedPost($id, jAuth::getUserSession()->id); $gJConfig = jApp::config(); // then send them a mail foreach ($records as $record) { //get all the member that subscribe to the thread id $id (called by hfnupost -> savereply ) $thread = jClasses::getService('havefnubb~hfnuposts')->getThread($id); $post = jClasses::getService('havefnubb~hfnuposts')->getPost($thread->id_last_msg); //get the email of the member that subscribes this thread $member = $memberDao->getById($record->id_user); $subject = jLocale::get('havefnubb~post.new.comment.received') . " : " . $post->subject; $mail = new jMailer(); $mail->From = $gJConfig->mailer['webmasterEmail']; $mail->FromName = $gJConfig->mailer['webmasterName']; $mail->Sender = $gJConfig->mailer['webmasterEmail']; $mail->Subject = $subject; $tpl = new jTpl(); $tpl->assign('server', $_SERVER['SERVER_NAME']); $tpl->assign('post', $post); $tpl->assign('login', $member->login); $mail->Body = $tpl->fetch('havefnubb~new_comment_received', 'text'); $mail->AddAddress($member->email); $mail->Send(); } }
/** * Main page */ function index() { $title = stripslashes(jApp::config()->havefnubb['title']); $rep = $this->getResponse('html'); $historyPlugin = jApp::coord()->getPlugin('history'); $historyPlugin->change('label', ucfirst(htmlentities($title, ENT_COMPAT, 'UTF-8'))); $historyPlugin->change('title', jLocale::get('havefnubb~main.goto_homepage')); $forums = jClasses::getService('hfnuforum'); $forumsList = $forums->getFullList(); // generate rss links list foreach ($forumsList->getLinearIterator() as $f) { // get the list of forum to build the RSS link $url = jUrl::get('havefnubb~posts:rss', array('ftitle' => $f->record->forum_name, 'id_forum' => $f->record->id_forum)); $rep->addHeadContent('<link rel="alternate" type="application/rss+xml" title="' . $f->record->forum_name . ' - RSS" href="' . htmlentities($url) . '" />'); $url = jUrl::get('havefnubb~posts:atom', array('ftitle' => $f->record->forum_name, 'id_forum' => $f->record->id_forum)); $rep->addHeadContent('<link rel="alternate" type="application/atom+xml" title="' . $f->record->forum_name . ' - ATOM " href="' . htmlentities($url) . '" />'); } $tpl = new jTpl(); $tpl->assign('selectedMenuItem', 'community'); $tpl->assign('currentIdForum', 0); $tpl->assign('action', 'index'); $tpl->assign('forumsList', $forumsList); $rep->body->assign('MAIN', $tpl->fetch('havefnubb~index')); return $rep; }
/** * Main Menu of the navbar * @pararm event $event Object of a listener */ function onhfnuGetMenuContent($event) { $gJConfig = jApp::config(); $event->add(new hfnuMenuItem('home', jLocale::get('havefnubb~main.home'), jUrl::get('havefnubb~default:index'), 1, 'main')); $event->add(new hfnuMenuItem('members', jLocale::get('havefnubb~main.member.list'), jUrl::get('havefnubb~members:index'), 2, 'main')); $event->add(new hfnuMenuItem('search', jLocale::get('havefnubb~main.search'), jUrl::get('hfnusearch~default:index'), 3, 'main')); if ($gJConfig->havefnubb['rules'] != '') { $event->add(new hfnuMenuItem('rules', jLocale::get('havefnubb~main.rules'), jUrl::get('havefnubb~default:rules'), 4, 'main')); } // dynamic menu $menus = jClasses::getService('havefnubb~hfnumenusbar')->getMenus(); if (!empty($menus)) { foreach ($menus as $indx => $menu) { $event->add(new hfnuMenuItem($menu['itemName'], $menu['name'], $menu['url'], 50 + $menu['order'], 'main')); } } if ($event->getParam('admin') === true) { $url = ''; try { // let's try to retrieve the url of the admin, if the admin is in // the same app $url = jUrl::get('hfnuadmin~default:index'); } catch (Exception $e) { if (isset($gJConfig->havefnubb["admin_url"])) { $url = $gJConfig->havefnubb["admin_url"]; } } if ($url) { $event->add(new hfnuMenuItem('admin', jLocale::get('havefnubb~main.admin.panel'), $url, 100, 'main')); } } }
public function unread() { $rep = $this->getResponse('html'); $tpl = new jTpl(); $tpl->assign('posts', jClasses::getService('havefnubb~hfnuposts')->findUnreadThreadByMod()); $rep->body->assign('MAIN', $tpl->fetch('posts.list')); return $rep; }
protected function _prepareTpl() { $id = $this->getParam('id', false); $scope = $this->getParam('scope', false); if (!$id || !$scope) { throw new Exception(jLocale::get("jtags~tags.error.parametermissing")); } $tags = jClasses::getService("jtags~tags")->getTagsBySubject($scope, $id); $this->_tpl->assign(compact('tags')); }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { $subs = array(); // get the threads the user subscribed $threads = jDao::get('havefnubb~sub')->findSubscribedPostByUser(jAuth::getUserSession()->id); foreach ($threads as $t) { // get the thread details $thread = jClasses::getService('havefnubb~hfnuposts')->getThread($t->id_post); $subs[] = array('id_post' => $thread->id_last_msg, 'ptitle' => jClasses::getService('havefnubb~hfnuposts')->getPost($thread->id_last_msg)->subject, 'thread_id' => $thread->id_thread, 'id_forum' => $thread->id_forum_thread, 'ftitle' => jClasses::getService('havefnubb~hfnuforum')->getForum($thread->id_forum_thread)->forum_name); } $this->_tpl->assign('subs', $subs); }
function onHfnuSearchEngineRun($event) { $HfnuSearchConfig = parse_ini_file(jApp::configPath() . 'havefnu.search.ini.php', true); $cleaner = jClasses::getService('hfnusearch~cleaner'); $words = $cleaner->stemPhrase($event->getParam('string')); $nb_words = count($words); // no words ; go back with nothing :P if (!$words) { return array('count' => 0, 'result' => array()); } $service = jClasses::getService($HfnuSearchConfig['classToPerformSearchEngine']); $result = $service->searchEngineRun($event); }
function save() { $f = jForms::fill('base~formauth'); if (!$f->check) { $vue = $this->getResponse('redirect'); $vue->action = 'base~identity:index'; return $vue; } $vue = $this->common(); $c = jClasses::getService('UserManager'); $c->save($f); return $vue; }
/** * Index that will display all the available theme to be used */ function index() { $tpl = new jTpl(); $themes = jClasses::getService('themes'); $lists = $themes->lists(); $tpl->assign('themes', $lists); $tpl->assign('lang', jApp::config()->locale); $tpl->assign('current_theme', strtolower(jApp::config()->theme)); $rep = $this->getResponse('html'); $rep->body->assign('MAIN', $tpl->fetch('theme')); $rep->body->assign('selectedMenuItem', 'theme'); return $rep; }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { $srvinfos = jClasses::getService("servinfo~serverinfos"); list($records, $size) = $srvinfos->dbSize(); $this->_tpl->assign('LOADS_AVG', $srvinfos->loadsAvg()); $this->_tpl->assign('CACHE_ENGINE', $srvinfos->cacheEngine()); $this->_tpl->assign('PHP_VERSION', phpversion()); $this->_tpl->assign('PHP_OS', PHP_OS); $this->_tpl->assign('DB_VERSION', $srvinfos->dbVersion()); $this->_tpl->assign('DB_SIZE', $size); $this->_tpl->assign('DB_RECORDS', $records); $this->_tpl->assign('otherInfos', jEvent::notify('servinfoGetInfo')->getResponse()); }
/** * function that display the status of one post or post in a given forum */ function jtpl_function_html_post_status($tpl, $source, $data, $lastMarkThreadAsRead = 0, $forum = null) { $statusAvailable = array('pined', 'pinedclosed', 'opened', 'closed', 'censored', 'uncensored', 'hidden'); if ($source == 'forum') { $id_forum = $data; // does the user still read everything in the forum ? if (!jClasses::getService('havefnubb~hfnuposts')->getCountUnreadThreadbyForumId($id_forum)) { //yes $status = 'forumicone'; } else { $status = 'forumiconenew'; } } elseif ($source == 'post') { $post = $data; $status = $statusAvailable[$post->status_thread - 1]; if (jAuth::isConnected()) { //opened thread ? if ($post->status_thread == 3) { //do the member already read that post ? // yes so status is opened if ($post->date_last_post < $lastMarkThreadAsRead || $post->date_read_post >= $post->date_last_post) { $status = 'opened'; } else { // no so post is new $status = 'post-new'; } } } // does this forum manage auto-expiration ? $dayInSecondes = 24 * 60 * 60; $dateDiff = $post->date_modified == 0 ? floor((time() - $post->date_created) / $dayInSecondes) : floor((time() - $post->date_modified) / $dayInSecondes); //if forum has expired ... if ($forum->post_expire > 0 and $dateDiff >= $forum->post_expire) { //close the thread $status = 'closed'; } $gJConfig = jApp::config(); $important = false; if ($post->status_thread != 5 and $post->status_thread != 7) { if ($post->nb_replies >= $gJConfig->havefnubb['important_nb_replies']) { $important = true; } if ($post->nb_viewed >= $gJConfig->havefnubb['important_nb_views']) { $important = true; } } $status = $important === true ? $status . '_important' : $status; } echo $status; }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { $tag = $this->param('tag'); $srvTags = jClasses::getService("jtags~tags"); $tags = $srvTags->getSubjectsByTags($tag, "forumscope"); $posts = array(); // We check the rights access to the posts in the template foreach ($tags as $tag) { if (jClasses::getService('havefnubb~hfnuposts')->getPost($tag) !== false) { $posts[] = jClasses::getService('havefnubb~hfnuposts')->getPost($tag); } } $this->_tpl->assign('posts', $posts); }
/** * Reindexing the search engine */ function reindexing() { $confirm = $this->param('confirm'); if ($confirm == 'Y') { $idx = jClasses::getService('hfnusearch~search_index'); $nbWords = $idx->searchEngineReindexing(); jMessage::add(jLocale::get('hfnusearch~search.admin.reindexing.done', $nbWords)); } else { jMessage::add(jLocale::get('hfnusearch~search.admin.reindexing.canceled')); } $rep = $this->getResponse('redirect'); $rep->action = 'hfnusearch~admin:index'; return $rep; }
/** * default searchEngineRun methode which make a search from the engine by querying the table define in the dao of the hfnusearch.ini.php file * @param object $event */ function searchEngineRun($event) { $cleaner = jClasses::getService('hfnusearch~cleaner'); $words = $cleaner->stemPhrase($event->getParam('string')); $page = (int) $event->getParam('page'); $limit = (int) $event->getParam('limit'); $id_forum = (int) $event->getParam('id_forum'); // no words ; go back with nothing :P if (!$words) { return array('count' => 0, 'result' => array()); } //1) open the config file $HfnuSearchConfig = parse_ini_file(jApp::configPath() . 'havefnu.search.ini.php', true); //2) get the dao we want to read $dataSource = $HfnuSearchConfig['dao']; //3) build an array with each one $dataSources = preg_split('/,/', $dataSource); foreach ($dataSources as $ds) { //4) get a factory of the current DAO $dao = jDao::get($ds); //getting the column name on which we need to make the query $indexSubject = $HfnuSearchConfig[$ds]['index_subject']; $indexMessage = $HfnuSearchConfig[$ds]['index_message']; //5) get all the record $conditions = jDao::createConditions(); $conditions->startGroup('OR'); if ($id_forum > 0) { $conditions->addCondition('id_forum', '=', $id_forum); } foreach ($words as $word) { $conditions->addCondition($indexSubject, 'LIKE', '%' . $word . '%'); $conditions->addCondition($indexMessage, 'LIKE', '%' . $word . '%'); } $conditions->endGroup(); $allRecord = $dao->findBy($conditions); if ($page > 0 and $limit > 0) { $record = $dao->findBy($conditions, $page, $limit); } else { $record = $allRecord; } foreach ($record as $rec) { if (jAcl2::check('hfnu.admin.post')) { $event->Add(array('SearchEngineResult' => $rec, 'SearchEngineResultTotal' => $allRecord->rowCount())); } elseif (jAcl2::check('hfnu.forum.view', 'forum' . $rec->id_forum) and $rec->status < 7) { $event->Add(array('SearchEngineResult' => $rec, 'SearchEngineResultTotal' => $allRecord->rowCount())); } } } }
/** *Put a rate (in ajax) */ function rate_ajax_it() { //info about the "source" from where the datas come from $id_source = $this->intParam('id_source'); $source = $this->param('source'); //check if the cancel button was selected if ($id_source == 0 or $source == '') { return $this->getResponse('htmlfragment'); } $rate = $this->floatParam('star1'); jClasses::getService('hfnurates~rates')->saveRatesBySource($id_source, $source, $rate); $result = jClasses::getService('hfnurates~rates')->getTotalRatesBySource($id_source, $source); $rep = $this->getResponse('htmlfragment'); $rep->addContent(jLocale::get('hfnurates~main.total.of.rates') . ':' . $result->total_rates . ' ' . jLocale::get('hfnurates~main.rate') . ':' . $result->avg_level); return $rep; }
/** * Use DynamicLayers python plugin to get a child project * And redirect to Lizmap view map controller with changed project parameter */ function index() { // Set up redirect response $rep = $this->getResponse('redirect'); $rep->action = 'view~map:index'; $params = jApp::coord()->request->params; $rep->params = $params; // Redirect to normal map if no suitable parameters if (!$params['dlsourcelayer'] or !$params['dlexpression']) { jLog::log('Dynamic layers - no parameters DLSOURCELAYER or DLEXPRESSION'); return $rep; } // Get project path $project = $params['project']; $repository = $params['repository']; $lrep = lizmap::getRepository($repository); $projectTemplatePath = realpath($lrep->getPath()) . '/' . $project . ".qgs"; // Use QGIS python plugins dynamicLayers to get child project $lizmapServices = lizmap::getServices(); $url = $lizmapServices->wmsServerURL . '?'; $qparams = array(); $qparams['service'] = 'dynamicLayers'; $qparams['map'] = $projectTemplatePath; $qparams['dlsourcelayer'] = $params['dlsourcelayer']; $qparams['dlexpression'] = $params['dlexpression']; $rparams = http_build_query($qparams); $querystring = $url . $rparams; // Get remote data $lizmapCache = jClasses::getService('lizmap~lizmapCache'); $getRemoteData = $lizmapCache->getRemoteData($querystring, $this->services->proxyMethod, $this->services->debugMode); $data = $getRemoteData[0]; $mime = $getRemoteData[1]; // Get returned response and redirect to appropriate project page $json = json_decode($data); if ($json->status == 0) { jLog::log('DynamicLayers error : ' . $json->message); } else { $params['project'] = preg_replace('#\\.qgs$#', '', $json->childProject); unset($params['dlsourcelayer']); unset($params['dlexpression']); $rep->params = $params; jLog::log('DynamicLayers message : ' . $json->message . ' - ' . $json->childProject); } return $rep; }
/** * */ function view() { $lang = jLocale::getCurrentLang(); $name = $this->param('name'); jLog::log("lang: {$lang} / name: {$name}"); $rep = $this->getResponse('html'); jLog::log("Name of fame: " . $this->param('name')); $articles = jClasses::getService('amigatlk~articles'); jLog::log(" " . get_class($articles)); $article = $articles->getArticle($this->param('name')); if (empty($article)) { $rep->body->assignZone('MAIN', 'amigatlk~notFound404'); $rep->setHttpStatus('404', 'Not Found'); return $rep; } $rep->title = $article->title; $rep->body->assignZone('MAIN', 'amigatlk~viewArticle', array('article' => $article)); return $rep; }
/** * View a given Category of forum then the list of forums */ function view() { $ctitle = $this->param('ctitle'); $id_cat = (int) $this->param('id_cat'); if ($id_cat == 0) { $rep = $this->getResponse('redirect'); $rep->action = 'havefnubb~default:index'; return $rep; } // add the category name in the page title // so // 1) get the category record $category = jClasses::getService('havefnubb~hfnucat')->getCat($id_cat); // check that the title of the category exist // if not => error404 if (jUrl::escape($ctitle, true) != jUrl::escape($category->cat_name, true)) { $rep = $this->getResponse('redirect'); $rep->action = jApp::config()->urlengine['notfoundAct']; return $rep; } $rep = $this->getResponse('html'); // 2) assign the title page $rep->title = $category->cat_name; $historyPlugin = jApp::coord()->getPlugin('history'); $histname = ucfirst(htmlentities($category->cat_name, ENT_COMPAT, 'UTF-8')); $historyPlugin->change('label', $histname); $historyPlugin->change('title', $histname); $categories = jDao::get('havefnubb~forum')->findParentByCatId($id_cat); foreach ($categories as $cat) { if (jAcl2::check('hfnu.forum.list', 'forum' . $cat->id_forum)) { // get the list of forum to build the RSS link $url = jUrl::get('havefnubb~posts:rss', array('ftitle' => $cat->forum_name, 'id_forum' => $cat->id_forum)); $rep->addHeadContent('<link rel="alternate" type="application/rss+xml" title="' . $cat->forum_name . '" href="' . htmlentities($url) . '" />'); } } $tpl = new jTpl(); $tpl->assign('action', 'view'); $tpl->assign('cat_name', $category->cat_name); $tpl->assign('categories', $categories); $tpl->assign('currentIdForum', 0); $rep->body->assign('MAIN', $tpl->fetch('index')); return $rep; }
/** * */ public static function stemPhrase($phrase) { // split into words $words = str_word_count(strtolower($phrase), 1); // ignore stop words $words = self::removeStopwords($words); // stem words $stemmedWords = array(); foreach ($words as $word) { // ignore 1 and 2 letter words if (strlen($word) <= 2) { continue; } //$stem = jClasses::getService('hfnusearch~PorterStemmer'); $stem = jClasses::getService('hfnusearch~hfnuStemmer'); $stemmedWords[] = $stem->Stem($word, true); } return $stemmedWords; }
function onHfnuTaskTodo($event) { $dao = jDao::get('havefnubb~notify'); $notify = $dao->findAll(); $nbRec = $notify->rowCount(); if ($nbRec > 0) { $link = '<a href=' . jUrl::get('hfnuadmin~notify:index') . '>'; $link .= jLocale::get('hfnuadmin~task.notification', $nbRec); $link .= '</a>'; $event->add($link); } $data = jClasses::getService('havefnubb~hfnuposts')->findUnreadThreadByMod(); $nbRec = $data->rowCount(); if ($nbRec > 0) { $link = '<a href=' . jUrl::get('hfnuadmin~posts:unread') . '>'; $link .= jLocale::get('hfnuadmin~task.unreadpostbymod', $nbRec); $link .= '</a>'; $event->add($link); } }
/** * */ function index() { $lang = jLocale::getCurrentLang(); if ($lang != 'fr') { $rep = $this->getResponse('redirect'); $rep->action = "amigatlk~default:index"; $rep->params = array('lang' => 'fr'); return $rep; } $rep = $this->getResponse('html'); $articles = jClasses::getService('amigatlk~articles'); $article = $articles->getArticle('homepage'); if (empty($article)) { $rep->body->assignZone('MAIN', 'amigatlk~notFound404'); $rep->setHttpStatus('404', 'Not Found'); return $rep; } $rep->body->assignZone('MAIN', 'amigatlk~viewArticle', array('article' => $article)); return $rep; }
function saveedit() { $id_cat = $this->param('id_cat'); $cat_name = $this->param('cat_name'); $cat_order = $this->param('cat_order'); $hfnutoken = (string) $this->param('hfnutoken'); //let's check if we have a valid token in our form $token = jClasses::getService("havefnubb~hfnutoken"); $token->checkHfnuToken($hfnutoken); if ($this->param('saveBt') == jLocale::get('hfnuadmin~category.saveBt')) { if (count($id_cat) == 0) { jMessage::add(jLocale::get('hfnuadmin~category.unknown.category'), 'error'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~category:index'; return $rep; } $dao = jDao::get('havefnubb~category'); foreach ($id_cat as $thisId) { $record = $dao->get((int) $id_cat[$thisId]); $record->cat_name = (string) $cat_name[$id_cat[$thisId]]; $record->cat_order = (int) $cat_order[$id_cat[$thisId]]; if ($record->cat_name == '' or $record->cat_order == 0) { jMessage::add(jLocale::get('hfnuadmin~category.category.name.or.order.invalid'), 'error'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~category:index'; return $rep; } $dao->update($record); } jForms::destroy('hfnuadmin~category'); jMessage::add(jLocale::get('hfnuadmin~category.category.modified'), 'ok'); } else { jForms::destroy('hfnuadmin~category'); jMessage::add(jLocale::get('hfnuadmin~category.invalid.datas'), 'error'); } $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~category:index'; return $rep; }
/** * */ function view() { //$lang = jApp::config()->locale; //$lang = jLocale::getCurrentLang(); $name = $this->param('name'); jLog::log("lang: {$lang} / name: {$name}"); $rep = $this->getResponse('html'); jLog::log("Name of fame: " . $this->param('name')); $games = jClasses::getService('amigatlk~games'); $game = $games->getProduct($this->param('name')); if (empty($game)) { $rep->body->assignZone('MAIN', 'amigatlk~notFound404'); $rep->setHttpStatus('404', 'Not Found'); return $rep; } $rep->title = $game->title; $rep->body->assignZone('MAIN', 'amigatlk~viewGame', array('game' => $game)); // this is a call for the 'welcome' zone after creating a new application // remove this line ! //$rep->body->assignZone('MAIN', 'jelix~check_install'); return $rep; }
/** * Page info display to sitemap */ function index() { $rep = $this->getResponse('sitemap'); //index $rep->addUrl(jUrl::get('havefnubb~default:index'), null, 'daily', 1); //categories $cats = jDao::get('havefnubb~category')->findAll(); foreach ($cats as $cat) { $rep->addUrl(jUrl::get('havefnubb~category:view', array('id_cat' => $cat->id_cat, 'ctitle' => $cat->cat_name)), null, 'daily', 1); } // posts list : // 1=) get the list of forum $forums = jDao::get('havefnubb~forum')->findAll(); foreach ($forums as $forum) { // 2=) for each forum, get the list of posts list($page, $posts) = jClasses::getService('havefnubb~hfnuposts')->getThreadsList($forum->id_forum, 0, 25); foreach ($posts as $post) { $rep->addUrl(jUrl::get('havefnubb~posts:view', array('id_post' => $post->id_post, 'thread_id' => $post->thread_id, 'id_forum' => $post->id_forum, 'ftitle' => $post->forum_name, 'ptitle' => $post->subject)), null, 'hourly', 1); } } return $rep; }
function saveedit() { $id_rank = $this->param('id_rank'); $rank_name = $this->param('rank_name'); $rank_limit = $this->param('rank_limit'); $hfnutoken = (string) $this->param('hfnutoken'); //let's check if we have a valid token in our form $token = jClasses::getService("havefnubb~hfnutoken"); if ($this->param('saveBt') == jLocale::get('hfnuadmin~rank.saveBt')) { if (count($id_rank) == 0) { jMessage::add(jLocale::get('hfnuadmin~rank.unknown.rank'), 'error'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ranks:index'; return $rep; } $dao = jDao::get('havefnubb~ranks'); foreach ($id_rank as $thisId) { $record = $dao->get((int) $id_rank[$thisId]); $record->rank_name = (string) $rank_name[$id_rank[$thisId]]; $record->rank_limit = (int) $rank_limit[$id_rank[$thisId]]; if ($record->rank_name == '') { jMessage::add(jLocale::get('hfnuadmin~rank.rank.name.invalid'), 'error'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ranks:index'; return $rep; } $dao->update($record); } jForms::destroy('hfnuadmin~ranks'); jMessage::add(jLocale::get('hfnuadmin~rank.rank.modified'), 'ok'); } else { jForms::destroy('hfnuadmin~ranks'); jMessage::add(jLocale::get('hfnuadmin~rank.invalid.datas'), 'error'); } $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ranks:index'; return $rep; }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { $thread_id = (int) $this->param('thread_id'); $id_post = (int) $this->param('id_post'); $id_forum = (int) $this->param('id_forum'); $isConnected = (bool) $this->param('connected'); if ($id_post < 1) { return; } if ($id_forum < 1) { return; } $daoUser = jDao::get('havefnubb~member'); if (jAuth::isConnected()) { $user = $daoUser->getByLogin(jAuth::getUserSession()->login); } else { $user = new StdClass(); $user->id = 0; } $post = jClasses::getService('havefnubb~hfnuposts')->getPost($id_post); $subject = ''; if ($post->subject != '') { $subject = $post->subject; } if (jAuth::isConnected()) { $form = jForms::create('havefnubb~posts', $thread_id); } else { $form = jForms::create('havefnubb~posts_anonym', $thread_id); } $form->setData('id_forum', $id_forum); $form->setData('id_user', $user->id); $form->setData('id_post', $id_post); $form->setData('thread_id', $thread_id); $form->setData('subject', $subject); $this->_tpl->assign('form', $form); $this->_tpl->assign('id_post', $id_post); $this->_tpl->assign('thread_id', $thread_id); }
public function beforeAction($params) { jClasses::getService('activeusers~connectedusers')->check(); return null; }
function onAuthRemoveUser($event) { $login = $event->getParam('login'); jClasses::getService('activeusers~connectedusers')->disconnectUser($login); }
/** * GetFeatureInfoHtml : return HTML for the getFeatureInfo. * @param array $params Array of parameters * @param string $xmldata XML data from getFeatureInfo * @return Feature Info in HTML format. */ function getFeatureInfoHtml($params, $xmldata) { // Get data from XML $use_errors = libxml_use_internal_errors(true); $go = true; $errorlist = array(); // Create a DOM instance $xml = simplexml_load_string($xmldata); if (!$xml) { foreach (libxml_get_errors() as $error) { $errorlist[] = $error; } $go = false; } // Get json configuration for the project $configLayers = $this->project->getLayers(); // Get optionnal parameter fid $filterFid = null; $fid = $this->param('fid'); if ($fid) { $expFid = explode('.', $fid); if (count($expFid) == 2) { $filterFid = array(); $filterFid[$expFid[0]] = $expFid[1]; } } // Loop through the layers $content = array(); $ptemplate = 'view~popup'; $lizmapCache = $this->lizmapCache; $popupClass = jClasses::getService('view~popup'); foreach ($xml->Layer as $layer) { $layername = $layer['name']; $configLayer = $this->project->findLayerByName($layername); // since 2.6 layer's name can be layer's title if ($configLayer == null) { $configLayer = $this->project->findLayerByTitle($layername); } if ($configLayer == null) { continue; } // Avoid layer if no popup asked by the user for it // or if no popup property // or if no edition $returnPopup = False; if (property_exists($configLayer, 'popup') && $configLayer->popup == 'True') { $returnPopup = True; } if (!$returnPopup) { $editionLayer = $this->project->findEditionLayerByLayerId($configLayer->id); if ($editionLayer != null && ($editionLayer->capabilities->modifyGeometry == 'True' || $editionLayer->capabilities->modifyAttribute == 'True' || $editionLayer->capabilities->deleteFeature == 'True')) { $returnPopup = True; } } if (!$returnPopup) { continue; } // Get layer title $layerTitle = $configLayer->title; $layerId = $configLayer->id; // Get the template for the popup content $templateConfigured = False; if (property_exists($configLayer, 'popupTemplate')) { // Get template content $popupTemplate = (string) trim($configLayer->popupTemplate); // Use it if not empty if (!empty($popupTemplate)) { $templateConfigured = True; // first replace all "media/bla/bla/llkjk.ext" by full url $popupTemplate = preg_replace_callback('#(["\']){1}(media/.+\\.\\w{3,10})(["\']){1}#', array($this, 'replaceMediaPathByMediaUrl'), $popupTemplate); // Replace : html encoded chars to let further regexp_replace find attributes $popupTemplate = str_replace(array('%24', '%7B', '%7D'), array('$', '{', '}'), $popupTemplate); } } // Loop through the features foreach ($layer->Feature as $feature) { $id = $feature['id']; // Optionnally filter by feature id if ($filterFid and $filterFid[$configLayer->name] and $filterFid[$configLayer->name] != $id) { continue; } // Hidden input containing layer id and feature id $hiddenFeatureId = '<input type="hidden" value="' . $layerId . '.' . $id . '" class="lizmap-popup-layer-feature-id"/> '; // Specific template for the layer has been configured if ($templateConfigured) { $popupFeatureContent = $popupTemplate; // then replace all column data by appropriate content foreach ($feature->Attribute as $attribute) { // Replace #col and $col by colomn name and value $popupFeatureContent = $popupClass->getHtmlFeatureAttribute($attribute['name'], $attribute['value'], $this->repository->getKey(), $this->project->getKey(), $popupFeatureContent); } } else { $isMaptip = false; $maptipValue = ''; foreach ($feature->Attribute as $attribute) { if ($attribute['name'] == 'maptip') { $isMaptip = true; $maptipValue = $attribute['value']; } } // If there is a maptip attribute we display its value if ($isMaptip) { // first replace all "media/bla/bla/llkjk.ext" by full url $maptipValue = preg_replace_callback('#(["\']){1}(media/.+\\.\\w{3,10})(["\']){1}#', array($this, 'replaceMediaPathByMediaUrl'), $maptipValue); // Replace : html encoded chars to let further regexp_replace find attributes $maptipValue = str_replace(array('%24', '%7B', '%7D'), array('$', '{', '}'), $maptipValue); $popupFeatureContent = $maptipValue; } else { $tpl = new jTpl(); $tpl->assign('attributes', $feature->Attribute); $tpl->assign('repository', $this->repository->getKey()); $tpl->assign('project', $this->project->getKey()); $popupFeatureContent = $tpl->fetch('view~popupDefaultContent'); } } $tpl = new jTpl(); $tpl->assign('layerTitle', $layerTitle); $tpl->assign('popupContent', $hiddenFeatureId . $popupFeatureContent); $content[] = $tpl->fetch('view~popup'); } // loop features } // loop layers $content = array_reverse($content); return implode("\n", $content); }
/** * Get WFS data from a "Value Relation" layer and fill the form control for a specific field. * @param string $fieldName Name of QGIS field * * @return Modified form control */ private function fillControlFromValueRelationLayer($fieldName) { // Build WFS request parameters // Get layername via id $relationLayerId = $this->formControls[$fieldName]->valueRelationData['layer']; $_relationayerXml = $this->project->getXmlLayer($relationLayerId); $relationayerXml = $_relationayerXml[0]; $_layerName = $relationayerXml->xpath('layername'); $layerName = (string) $_layerName[0]; $valueColumn = $this->formControls[$fieldName]->valueRelationData['value']; $keyColumn = $this->formControls[$fieldName]->valueRelationData['key']; $filterExpression = $this->formControls[$fieldName]->valueRelationData['filterExpression']; $params = array('SERVICE' => 'WFS', 'VERSION' => '1.0.0', 'REQUEST' => 'GetFeature', 'TYPENAME' => $layerName, 'PROPERTYNAME' => $valueColumn . ',' . $keyColumn, 'OUTPUTFORMAT' => 'GeoJSON', 'GEOMETRYNAME' => 'none', 'map' => $this->repository->getPath() . $this->project->getKey() . ".qgs"); // add EXP_FILTER. Only for QGIS >=2.0 $expFilter = Null; if ($filterExpression) { $expFilter = $filterExpression; } // Filter by login if (!$this->loginFilteredOveride) { $this->filterDataByLogin($layerName); if (is_array($this->loginFilteredLayers)) { if ($expFilter) { $expFilter = " ( " . $expFilter . " ) AND ( " . $this->loginFilteredLayers['where'] . " ) "; } else { $expFilter = $this->loginFilteredLayers['where']; } } } if ($expFilter) { $params['EXP_FILTER'] = $expFilter; // disable PROPERTYNAME in this case : if the exp_filter uses other fields, no data would be returned otherwise unset($params['PROPERTYNAME']); } // Build query $lizmapServices = lizmap::getServices(); $url = $lizmapServices->wmsServerURL . '?'; $bparams = http_build_query($params); $querystring = $url . $bparams; // Get remote data $lizmapCache = jClasses::getService('lizmap~lizmapCache'); $getRemoteData = $lizmapCache->getRemoteData($querystring, $lizmapServices->proxyMethod, $lizmapServices->debugMode); $wfsData = $getRemoteData[0]; $mime = $getRemoteData[1]; if ($wfsData and !in_array(strtolower($mime), array('text/html', 'text/xml'))) { $wfsData = json_decode($wfsData); // Get data from layer $features = $wfsData->features; $data = array(); foreach ($features as $feat) { if (property_exists($feat, 'properties')) { if (property_exists($feat->properties, $keyColumn) && property_exists($feat->properties, $valueColumn)) { $data[(string) $feat->properties->{$keyColumn}] = $feat->properties->{$valueColumn}; } } } $dataSource = new jFormsStaticDatasource(); // orderByValue if (strtolower($this->formControls[$fieldName]->valueRelationData['orderByValue']) == 'true' or strtolower($this->formControls[$fieldName]->valueRelationData['orderByValue']) == '1') { asort($data); } $dataSource->data = $data; $this->formControls[$fieldName]->ctrl->datasource = $dataSource; // required if (strtolower($this->formControls[$fieldName]->valueRelationData['allowNull']) == 'false' or strtolower($this->formControls[$fieldName]->valueRelationData['allowNull']) == '0') { $this->formControls[$fieldName]->ctrl->required = True; } } else { if (!preg_match('#No feature found error messages#', $wfsData)) { $this->formControls[$fieldName]->ctrl->hint = 'Problem : cannot get data to fill this control !'; $this->formControls[$fieldName]->ctrl->help = 'Problem : cannot get data to fill this control !'; } else { $this->formControls[$fieldName]->ctrl->hint = 'No data to fill this control !'; $this->formControls[$fieldName]->ctrl->help = 'No data to fill this control !'; } } }