コード例 #1
0
 /**
  *
  */
 function onmasteradminGetMenuContent($event)
 {
     $plugin = $GLOBALS['gJCoord']->getPlugin('auth', false);
     if ($plugin && $plugin->config['driver'] == 'Db' && jAcl2::check('auth.users.list')) {
         $event->add(new masterAdminMenuItem('users', jLocale::get('jauthdb_admin~auth.adminmenu.item.list'), jUrl::get('jauthdb_admin~default:index'), 10, 'system'));
     }
 }
コード例 #2
0
 public function setFromIniNode($node_key, $node)
 {
     $this->id = substr($node_key, 5);
     if (!empty($node['type'])) {
         if (in_array($node['type'], self::$allowed_types)) {
             $this->type = $node['type'];
         } else {
             throw new jException('jPref~admin.type.not.allowed', array($node['type'], implode(',', self::$allowed_types)));
         }
     }
     if (!empty($node['locale'])) {
         $this->locale = $node['locale'];
     }
     if (!empty($node['group'])) {
         $this->group = $node['group'];
     }
     $this->_readable = empty($node['read_acl_subject']) || jAcl2::check($node['read_acl_subject']);
     $this->_writable = empty($node['write_acl_subject']) || jAcl2::check($node['write_acl_subject']);
     if (!empty($node['default_value'])) {
         $this->default_value = $node['default_value'];
     }
     if ($this->type == 'boolean') {
         if ($this->default_value == 'true' || $this->default_value == '1') {
             $this->default_value = true;
         } else {
             if ($this->default_value == 'false' || isset($node['default_value']) && $node['default_value'] == '') {
                 $this->default_value = false;
             }
         }
     }
 }
コード例 #3
0
 /**
  * Displays a list of project for a given repository.
  *
  * @param string $repository. Name of the repository.
  * @return Html page with a list of projects.
  */
 function index()
 {
     if ($this->param('theme')) {
         jApp::config()->theme = $this->param('theme');
     }
     $rep = $this->getResponse('html');
     // Get lizmap services
     $services = lizmap::getServices();
     // only maps
     if ($services->onlyMaps) {
         $repository = lizmap::getRepository($services->defaultRepository);
         if ($repository && jAcl2::check('lizmap.repositories.view', $repository->getKey())) {
             $project = lizmap::getProject($repository->getKey() . '~' . $services->defaultProject);
             if ($project) {
                 // test redirection to an other controller
                 $items = jEvent::notify('mainviewGetMaps')->getResponse();
                 foreach ($items as $item) {
                     if ($item->parentId == $repository->getKey() && $item->id == $services->defaultProject) {
                         $rep = $this->getResponse('redirectUrl');
                         $rep->url = $item->url;
                         return $rep;
                     }
                 }
                 // redirection to default controller
                 $rep = $this->getResponse('redirect');
                 $rep->action = 'view~map:index';
                 return $rep;
             }
         }
     }
     // Get repository data
     $repository = $this->param('repository');
     $repositoryList = array();
     if ($repository) {
         if (!jAcl2::check('lizmap.repositories.view', $repository)) {
             $rep = $this->getResponse('redirect');
             $rep->action = 'view~default:index';
             jMessage::add(jLocale::get('view~default.repository.access.denied'), 'error');
             return $rep;
         }
     }
     $title = jLocale::get("view~default.repository.list.title");
     $rep->body->assign('repositoryLabel', $title);
     $rep->body->assign('isConnected', jAuth::isConnected());
     $rep->body->assign('user', jAuth::getUserSession());
     if ($services->allowUserAccountRequests) {
         $rep->body->assign('allowUserAccountRequests', True);
     }
     if ($repository) {
         $lrep = lizmap::getRepository($repository);
         $title .= ' - ' . $lrep->getData('label');
     }
     $rep->title = $title;
     $rep->body->assignZone('MAIN', 'main_view', array('repository' => $repository));
     $rep->addJSCode("\n      \$(window).load(function() {\n        \$('.liz-project-img').parent().mouseenter(function(){\n          var self = \$(this);\n          self.find('.liz-project-desc').slideDown();\n          self.css('cursor','pointer');\n        }).mouseleave(function(){\n          var self = \$(this);\n          self.find('.liz-project-desc').hide();\n        }).click(function(){\n          var self = \$(this);\n          window.location = self.parent().find('a.liz-project-view').attr('href');\n          return false;\n        });\n      });\n      ");
     // Js hack to normalize the height of the project thumbnails to avoid line breaks with long project titles
     $bp = jApp::config()->urlengine['basePath'];
     $rep->addJSLink($bp . 'js/view.js');
     return $rep;
 }
コード例 #4
0
ファイル: menu.zone.php プロジェクト: havefnubb/havefnubb
 /**
  * function to manage data before assigning to the template of its zone
  */
 protected function _prepareTpl()
 {
     jClasses::inc('havefnubb~hfnuMenuItem');
     $admin = jAcl2::check('hfnu.admin.index');
     $menu = array();
     $items = jEvent::notify('hfnuGetMenuContent', array('admin' => $admin))->getResponse();
     foreach ($items as $item) {
         if ($item->parentId) {
             if (!isset($menu[$item->parentId])) {
                 $menu[$item->parentId] = new hfnuMenuItem($item->parentId, '', '');
             }
             $menu[$item->parentId]->childItems[] = $item;
         } else {
             if (isset($menu[$item->id])) {
                 $menu[$item->id]->copyFrom($item);
             } else {
                 $menu[$item->id] = $item;
             }
         }
     }
     usort($menu, "hfnuItemSort");
     foreach ($menu as $topitem) {
         usort($topitem->childItems, "hfnuItemSort");
     }
     $this->_tpl->assign('menuitems', $menu);
     $this->_tpl->assign('selectedMenuItem', $this->param('selectedMenuItem', ''));
 }
コード例 #5
0
ファイル: forum.classic.php プロジェクト: havefnubb/havefnubb
 /**
  * display the RSS of the forum
  */
 public function read_rss()
 {
     $ftitle = jUrl::escape($this->param('ftitle'), true);
     $id_forum = (int) $this->param('id_forum');
     if (!jAcl2::check('hfnu.posts.list', 'forum' . $id_forum)) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'default:index';
         return $rep;
     }
     if ($id_forum == 0) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'default:index';
         return $rep;
     }
     $forum = jClasses::getService('havefnubb~hfnuforum')->getForum($id_forum);
     if (jUrl::escape($forum->forum_name, true) != $ftitle) {
         $rep = $this->getResponse('redirect');
         $rep->action = jApp::config()->urlengine['notfoundAct'];
         return $rep;
     }
     jApp::coord()->getPlugin('history')->change('label', htmlentities($forum->forum_name, ENT_COMPAT, 'UTF-8'));
     $feed_reader = new jFeedReader();
     $feed_reader->setCacheDir(jApp::varPath('feeds'));
     $feed_reader->setTimeout(2);
     $feed_reader->setUserAgent('HaveFnuBB - http://www.havefnubb.org/');
     $feed = $feed_reader->parse($forum->forum_url);
     $rep = $this->getResponse('html');
     $tpl = new jTpl();
     $tpl->assign('feed', $feed);
     $tpl->assign('forum', $forum);
     $rep->title = $forum->forum_name;
     $rep->body->assign('MAIN', $tpl->fetch('havefnubb~forum_rss.view'));
     return $rep;
 }
コード例 #6
0
 /**
  *
  */
 function index()
 {
     $rep = $this->getResponse('html');
     $tpl = new jTpl();
     $gid = array(0);
     $o = new StdClass();
     $o->id_aclgrp = '0';
     $o->name = jLocale::get('jacl2_admin~acl2.anonymous.group.name');
     $o->grouptype = 0;
     $groups = array($o);
     $grouprights = array(0 => false);
     foreach (jAcl2DbUserGroup::getGroupList() as $grp) {
         $gid[] = $grp->id_aclgrp;
         $groups[] = $grp;
         $grouprights[$grp->id_aclgrp] = false;
     }
     $rights = array();
     $p = jAcl2Db::getProfil();
     $rs = jDao::get('jelix~jacl2subject', $p)->findAllSubject();
     foreach ($rs as $rec) {
         $rights[$rec->id_aclsbj] = $grouprights;
     }
     $rs = jDao::get('jelix~jacl2rights', $p)->getRightsByGroups($gid);
     foreach ($rs as $rec) {
         $rights[$rec->id_aclsbj][$rec->id_aclgrp] = true;
     }
     $tpl->assign(compact('groups', 'rights'));
     if (jAcl2::check('acl.group.modify')) {
         $rep->body->assign('MAIN', $tpl->fetch('groups_right'));
     } else {
         $rep->body->assign('MAIN', $tpl->fetch('groups_right_view'));
     }
     return $rep;
 }
コード例 #7
0
ファイル: jacl2.coord.php プロジェクト: alienpham/helenekling
 /**
  * @param  array  $params   plugin parameters for the current action
  * @return null or jSelectorAct  if action should change
  */
 public function beforeAction($params)
 {
     $selector = null;
     $aclok = true;
     if (isset($params['jacl2.right'])) {
         $aclok = jAcl2::check($params['jacl2.right']);
     } elseif (isset($params['jacl2.rights.and'])) {
         $aclok = true;
         foreach ($params['jacl2.rights.and'] as $right) {
             if (!jAcl2::check($right)) {
                 $aclok = false;
                 break;
             }
         }
     } elseif (isset($params['jacl2.rights.or'])) {
         $aclok = false;
         foreach ($params['jacl2.rights.or'] as $right) {
             if (jAcl2::check($right)) {
                 $aclok = true;
                 break;
             }
         }
     }
     if (!$aclok) {
         if ($this->config['on_error'] == 1 || !$GLOBALS['gJCoord']->request->isAllowedResponse('jResponseRedirect')) {
             throw new jException($this->config['error_message']);
         } else {
             $selector = new jSelectorAct($this->config['on_error_action']);
         }
     }
     return $selector;
 }
コード例 #8
0
 function onmasteradminGetMenuContent($event)
 {
     if (jAcl2::check('activeusers.configuration')) {
         $item = new masterAdminMenuItem('activeusers', jLocale::get('activeusers_admin~main.masteradmin.menu.item'), jUrl::get('activeusers_admin~default:index'), 120, 'system');
         $event->add($item);
     }
 }
コード例 #9
0
 /**
  * 
  */
 function index()
 {
     $id = $this->param('id');
     if ($id === null) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'master_admin~default:index';
         return $rep;
     }
     $rep = $this->getResponse('html');
     // we're using a form to display a record, to have the portunity to have
     // labels with each values.
     $form = jForms::create($this->form, $id);
     $form->initFromDao($this->dao, $id, $this->dbProfile);
     $tpl = new jTpl();
     $tpl->assign('id', $id);
     $tpl->assign('form', $form);
     $tpl->assign('personalview', true);
     $tpl->assign('otherInfo', jEvent::notify('jauthdbAdminGetViewInfo', array('form' => $form, 'tpl' => $tpl))->getResponse());
     $form->deactivate('password');
     $form->deactivate('password_confirm');
     $tpl->assign('canUpdate', jAcl2::check('auth.user.modify'));
     $tpl->assign('canChangePass', jAcl2::check('auth.user.change.password'));
     $rep->body->assign('MAIN', $tpl->fetch('user_view'));
     return $rep;
 }
コード例 #10
0
 /**
  *
  */
 function onmasteradminGetMenuContent($event)
 {
     if (jAcl2::check('auth.users.list')) {
         $item = new masterAdminMenuItem('pref', jLocale::get('jpref_admin~admin.item.title'), jUrl::get('jpref_admin~prefs:index'), 50, 'system');
         $item->icon = jApp::config()->urlengine['jelixWWWPath'] . 'design/images/cog.png';
         $event->add($item);
     }
 }
コード例 #11
0
 /**
  *
  */
 function onmasteradminGetMenuContent($event)
 {
     if (jAcl2::check('acl.user.view')) {
         $event->add(new masterAdminMenuItem('usersrights', jLocale::get('jacl2db_admin~acl2.menu.item.rights'), jUrl::get('jacl2db_admin~users:index'), 30, 'system'));
     }
     if (jAcl2::check('acl.group.view')) {
         $event->add(new masterAdminMenuItem('usersgroups', jLocale::get('jacl2db_admin~acl2.menu.item.groups'), jUrl::get('jacl2db_admin~groups:index'), 20, 'system'));
     }
 }
コード例 #12
0
 function onmasteradminGetMenuContent($event)
 {
     $chemin = jApp::config()->urlengine['basePath'] . 'hfnu/admin/';
     if (jAcl2::check('modulesinfo.access')) {
         $item = new masterAdminMenuItem('modulesinfo', jLocale::get('modulesinfo~modulesinfo.masteradmin.menu.item'), jUrl::get('modulesinfo~default:index'), 202, 'system');
         $item->icon = $chemin . 'images/modules_list.png';
         $event->add($item);
     }
 }
コード例 #13
0
 /**
  *
  */
 function onmasteradminGetMenuContent($event)
 {
     $plugin = $GLOBALS['gJCoord']->getPlugin('auth', false);
     if ($plugin && $plugin->config['driver'] == 'Db' && jAcl2::check('auth.users.list')) {
         $item = new masterAdminMenuItem('users', jLocale::get('jauthdb_admin~auth.adminmenu.item.list'), jUrl::get('jauthdb_admin~default:index'), 10, 'system');
         $item->icon = $GLOBALS['gJConfig']->urlengine['jelixWWWPath'] . 'design/images/user.png';
         $event->add($item);
     }
 }
コード例 #14
0
 function onmasteradminGetMenuContent($event)
 {
     $chemin = jApp::config()->urlengine['basePath'] . 'hfnu/admin/';
     if (jAcl2::check('jelixcache.access')) {
         $item = new masterAdminMenuItem('jelixcache', jLocale::get('jelixcache~jelixcache.masteradmin.menu.item'), jUrl::get('jelixcache~default:index'), 100, 'system');
         $item->icon = $chemin . 'images/clear_cache.png';
         $event->add($item);
     }
 }
コード例 #15
0
 /**
  * the menu item
  * @param object $event
  * @return void
  */
 function onmasteradminGetMenuContent($event)
 {
     $chemin = jApp::config()->urlengine['basePath'] . 'hfnu/admin/';
     if (jAcl2::check('hfnu.admin.contact')) {
         $event->add(new masterAdminMenuItem('hfnucontact', 'Contact', '', 40));
         $item = new masterAdminMenuItem('contact', jLocale::get('hfnucontact~contact.contact'), jUrl::get('hfnucontact~admin:index'), 100, 'hfnucontact');
         $item->icon = $chemin . 'images/contact.png';
         $event->add($item);
     }
 }
コード例 #16
0
 /**
  * the menu item
  * @param object $event
  * @return void
  */
 function onmasteradminGetMenuContent($event)
 {
     $chemin = jApp::config()->urlengine['basePath'] . 'hfnu/admin/';
     if (jAcl2::check('hfnu.admin.index')) {
         $event->add(new masterAdminMenuItem('hfnuthemes', jLocale::get('hfnuthemes~theme.themes'), '', 30));
         $item = new masterAdminMenuItem('theme', jLocale::get('hfnuthemes~theme.themes'), jUrl::get('hfnuthemes~default:index'), 10, 'hfnuthemes');
         $item->icon = $chemin . 'images/theme.png';
         $event->add($item);
     }
 }
コード例 #17
0
 /**
  * the menu item
  * @param object $event
  * @return void
  */
 function onmasteradminGetMenuContent($event)
 {
     $chemin = jApp::config()->urlengine['basePath'] . 'hfnu/admin/';
     $event->add(new masterAdminMenuItem('hfnusearch', jLocale::get('hfnusearch~search.admin.search.engine'), '', 50));
     if (jAcl2::check('hfnu.admin.search')) {
         $item = new masterAdminMenuItem('hfnusearch', jLocale::get('hfnusearch~search.admin.search.engine'), jUrl::get('hfnusearch~admin:index'), 100, 'hfnusearch');
         $item->icon = $chemin . 'images/search_engine.png';
         $event->add($item);
     }
 }
コード例 #18
0
 /**
  * is this record allowed to be see ?
  */
 function allowed()
 {
     if ($this->forbidden === null) {
         $this->forbidden = !jAcl2::check('hfnu.forum.list', 'forum' . $this->record->id_forum);
         if ($this->forbidden) {
             $this->disallow();
         }
     }
     return !$this->forbidden;
 }
コード例 #19
0
 /**
  *
  */
 function onmasteradminGetMenuContent($event)
 {
     $plugin = jApp::coord()->getPlugin('auth', false);
     $driver = $plugin->config['driver'];
     $hasDao = isset($plugin->config[$driver]['dao']) && isset($plugin->config[$driver]['compatiblewithdb']) && $plugin->config[$driver]['compatiblewithdb'];
     if ($plugin && ($driver == 'Db' || $hasDao) && jAcl2::check('auth.users.list')) {
         $item = new masterAdminMenuItem('users', jLocale::get('jauthdb_admin~auth.adminmenu.item.list'), jUrl::get('jauthdb_admin~default:index'), 10, 'system');
         $item->icon = jApp::config()->urlengine['jelixWWWPath'] . 'design/images/user.png';
         $event->add($item);
     }
 }
コード例 #20
0
 /**
  *
  */
 function onmasteradminGetMenuContent($event)
 {
     if (jAcl2::check('acl.user.view')) {
         $item = new masterAdminMenuItem('usersrights', jLocale::get('jacl2db_admin~acl2.menu.item.rights'), jUrl::get('jacl2db_admin~users:index'), 30, 'system');
         $item->icon = jApp::config()->urlengine['jelixWWWPath'] . 'design/images/rights.png';
         $event->add($item);
     }
     if (jAcl2::check('acl.group.view')) {
         $item = new masterAdminMenuItem('usersgroups', jLocale::get('jacl2db_admin~acl2.menu.item.groups'), jUrl::get('jacl2db_admin~groups:index'), 20, 'system');
         $item->icon = jApp::config()->urlengine['jelixWWWPath'] . 'design/images/group.png';
         $event->add($item);
     }
 }
コード例 #21
0
 /**
  * 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()));
             }
         }
     }
 }
コード例 #22
0
 function __construct($id)
 {
     // " jump to " will display all the forum except :
     // 1) the current one
     // 2) the ones the access are not granted
     $data = array();
     $dao = jDao::get('havefnubb~forum');
     $recs = $dao->findAll();
     foreach ($recs as $rec) {
         if ($rec->id_forum != $id and jAcl2::check('hfnu.forum.view', 'forum' . $rec->id_forum)) {
             $data[$rec->id_forum] = $rec->forum_name;
         }
     }
     $this->formId = $id;
     $this->data = $data;
 }
コード例 #23
0
 /**
  * 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;
 }
コード例 #24
0
ファイル: postlc.zone.php プロジェクト: havefnubb/havefnubb
 /**
  * function to manage data before assigning to the template of its zone
  */
 protected function _prepareTpl()
 {
     $thread_id = (int) $this->param('thread_id');
     $id_forum = (int) $this->param('id_forum');
     if (!$thread_id and !$id_forum) {
         return;
     }
     $user = '';
     $noMsg = '';
     $dao = jDao::get('havefnubb~threads');
     $admin = jAcl2::check('hfnu.admin.post');
     if ($thread_id) {
         if ($admin) {
             $userPost = $dao->getUserLastCommentOnPosts($thread_id);
         } else {
             $userPost = $dao->getUserLastVisibleCommentOnPosts($thread_id);
         }
         $user = jDao::get('havefnubb~member')->getById($userPost->id_user);
     } else {
         if ($id_forum) {
             if ($admin) {
                 $userPost = $dao->getUserLastCommentOnForums($id_forum);
             } else {
                 $userPost = $dao->getUserLastVisibleCommentOnForums($id_forum);
             }
             if ($userPost !== false) {
                 $user = jDao::get('havefnubb~member')->getById($userPost->id_user);
             } else {
                 $noMsg = jLocale::get('havefnubb~forum.postlc.no.msg');
             }
         }
     }
     $this->_tpl->assign('user', $user);
     $this->_tpl->assign('post', $userPost);
     $this->_tpl->assign('msg', $noMsg);
 }
コード例 #25
0
 /**
  * Get parameters and set classes for the project and repository given.
  *
  * @param boolean $save If true, we have to save the form. So take liz_repository and others instead of repository from request parameters.
  * @return array List of needed variables : $params, $lizmapRepository, lizmapProject, etc.
  */
 private function getEditionParameters($save = Null)
 {
     // Get the project
     $project = $this->param('project');
     $repository = $this->param('repository');
     $layerId = $this->param('layerId');
     $featureIdParam = $this->param('featureId');
     if ($save) {
         $project = $this->param('liz_project');
         $repository = $this->param('liz_repository');
         $layerId = $this->param('liz_layerId');
         $featureIdParam = $this->param('liz_featureId');
     }
     if (!$project) {
         jMessage::add('The parameter project is mandatory !', 'ProjectNotDefind');
         return false;
     }
     // Get repository data
     $lrep = lizmap::getRepository($repository);
     $lproj = lizmap::getProject($repository . '~' . $project);
     // Redirect if no rights to access this repository
     if (!jAcl2::check('lizmap.repositories.view', $lrep->getKey())) {
         jMessage::add(jLocale::get('view~default.repository.access.denied'), 'AuthorizationRequired');
         return false;
     }
     // Redirect if no rights to use the edition tool
     if (!jAcl2::check('lizmap.tools.edition.use', $lrep->getKey())) {
         jMessage::add(jLocale::get('view~edition.access.denied'), 'AuthorizationRequired');
         return false;
     }
     $layerXml = $lproj->getXmlLayer($layerId);
     $layerXmlZero = $layerXml[0];
     $_layerName = $layerXmlZero->xpath('layername');
     $layerName = (string) $_layerName[0];
     // Verifying if the layer is edtable
     $eLayers = $lproj->getEditionLayers();
     if (!property_exists($eLayers, $layerName)) {
         jMessage::add('The layer is not editable!', 'LayerNotEditable');
         return false;
     }
     $eLayer = $eLayers->{$layerName};
     if ($eLayer->capabilities->modifyGeometry != "True" && $eLayer->capabilities->modifyAttribute != "True" && $eLayer->capabilities->deleteFeature != "True" && $eLayer->capabilities->createFeature != "True") {
         jMessage::add('The layer is not editable!', 'LayerNotEditable');
         return false;
     }
     // feature Id (optionnal, only for edition and save)
     if (preg_match('#,#', $featureIdParam)) {
         $featureId = preg_split('#,#', $featureIdParam);
     } else {
         $featureId = $featureIdParam;
     }
     // Define class private properties
     $this->project = $lproj;
     $this->repository = $lrep;
     $this->layerId = $layerId;
     $this->featureId = $featureId;
     $this->featureIdParam = $featureIdParam;
     $this->layerXml = $layerXml;
     $this->layerName = $layerName;
     // Optionnaly filter data by login
     if (!jAcl2::check('lizmap.tools.loginFilteredLayers.override', $lrep->getKey())) {
         $this->loginFilteredLayers = True;
     }
     $this->loginFilteredOveride = jacl2::check('lizmap.tools.loginFilteredLayers.override', $lrep->getKey());
     return true;
 }
コード例 #26
0
 public function getDefaultDockable()
 {
     jClasses::inc('view~lizmapMapDockItem');
     $dockable = array();
     $bp = jApp::config()->urlengine['basePath'];
     // Get lizmap services
     $services = lizmap::getServices();
     // only maps
     if ($services->onlyMaps) {
         $projectsTpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('home', jLocale::get('view~default.repository.list.title'), $projectsTpl->fetch('view~map_projects'), 0);
     }
     $switcherTpl = new jTpl();
     $switcherTpl->assign(array('layerExport' => jAcl2::check('lizmap.tools.layer.export', $this->repository->getKey())));
     $dockable[] = new lizmapMapDockItem('switcher', jLocale::get('view~map.switchermenu.title'), $switcherTpl->fetch('view~map_switcher'), 1);
     //$legendTpl = new jTpl();
     //$dockable[] = new lizmapMapDockItem('legend', 'Légende', $switcherTpl->fetch('map_legend'), 2);
     $metadataTpl = new jTpl();
     // Get the WMS information
     $wmsInfo = $this->getWMSInformation();
     // WMS GetCapabilities Url
     $wmsGetCapabilitiesUrl = jAcl2::check('lizmap.tools.displayGetCapabilitiesLinks', $this->repository->getKey());
     if ($wmsGetCapabilitiesUrl) {
         $wmsGetCapabilitiesUrl = $this->getData('wmsGetCapabilitiesUrl');
     }
     $metadataTpl->assign(array_merge(array('repositoryLabel' => $this->getData('label'), 'repository' => $this->repository->getKey(), 'project' => $this->getKey(), 'wmsGetCapabilitiesUrl' => $wmsGetCapabilitiesUrl), $wmsInfo));
     $dockable[] = new lizmapMapDockItem('metadata', jLocale::get('view~map.metadata.link.label'), $metadataTpl->fetch('view~map_metadata'), 2);
     if ($this->hasEditionLayers()) {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('edition', jLocale::get('view~edition.navbar.title'), $tpl->fetch('view~map_edition'), 3, '', $bp . 'js/edition.js');
     }
     return $dockable;
 }
コード例 #27
0
 /**
  * Get a CSS file stored in the repository in a "media/themes" folder.
  * Url to images are replaced by getMedia URL
  *
  * @param string $repository Repository of the project.
  * @param string $project Project key.
  * @param string $path Path to the CSS file relative to the project file.
  * @return binary object The transformed CSS file.
  */
 function getCssFile()
 {
     // Get repository data
     $repository = $this->param('repository');
     $lrep = lizmap::getRepository($repository);
     if (!jAcl2::check('lizmap.repositories.view', $lrep->getKey())) {
         $rep = $this->getResponse('redirect');
         $rep->action = 'view~default:error';
         jMessage::add(jLocale::get('view~default.repository.access.denied'), 'error');
         return $rep;
     }
     // Get the project
     $project = $this->param('project');
     // Get the file
     $path = $this->param('path');
     $repositoryPath = realpath($lrep->getPath());
     $abspath = realpath($repositoryPath . '/' . $path);
     $n_repositoryPath = str_replace('\\', '/', $repositoryPath);
     $n_abspath = str_replace('\\', '/', $abspath);
     $ok = True;
     // Only allow files within the repository for safety reasons
     // and in the media/themes/ folder
     if (!preg_match("#^" . $n_repositoryPath . "(/)?media/themes/#", $n_abspath)) {
         $ok = False;
     }
     // Check if file exists
     if ($ok and !file_exists($abspath)) {
         $ok = False;
     }
     // Check if file is CSS
     $path_parts = pathinfo($abspath);
     if (strtolower($path_parts['extension']) != 'css') {
         $ok = False;
     }
     // Redirect if errors
     if (!$ok) {
         $content = "No CSS file in the specified path";
         $rep = $this->getResponse('text');
         $rep->content = $content;
         return $rep;
     }
     // Prepare the file to return
     $rep = $this->getResponse('binary');
     $rep->doDownload = false;
     $rep->fileName = $abspath;
     // Get the name of the file
     $name = $path_parts['basename'] . '.' . $path_parts['extension'];
     $rep->outputFileName = $name;
     // Mime type
     $rep->mimeType = 'text/css';
     // Read content from file
     $content = jFile::read($abspath);
     // Replace relative images URL with getMedia URL
     $newPath = preg_replace("#" . $path_parts['basename'] . "\$#", '', $path);
     $baseUrl = jUrl::get('view~media:getMedia', array('repository' => $lrep->getKey(), 'project' => $project, 'path' => $newPath));
     $pattern = 'url\\((.+)\\)';
     $replacement = 'url(' . $baseUrl . '/\\1)';
     $content = preg_replace("#{$pattern}#", $replacement, $content);
     $content = str_replace('"', '', $content);
     $rep->content = $content;
     $rep->setExpires('+60 seconds');
     return $rep;
 }
コード例 #28
0
 /**
  * Get parameters and set classes for the project and repository given.
  *
  * @return array List of needed variables : $params, $lizmapProject, $lizmapRepository, $lizmapCache.
  */
 protected function getServiceParameters()
 {
     // Get the project
     $project = $this->iParam('project');
     if (!$project) {
         jMessage::add('The parameter project is mandatory !', 'ProjectNotDefind');
         return false;
     }
     // Get repository data
     $repository = $this->iParam('repository');
     // Get the corresponding repository
     $lrep = lizmap::getRepository($repository);
     // Redirect if no rights to access this repository
     if (!jAcl2::check('lizmap.repositories.view', $lrep->getKey())) {
         jMessage::add(jLocale::get('view~default.repository.access.denied'), 'AuthorizationRequired');
         return false;
     }
     // Get and normalize the passed parameters
     $pParams = jApp::coord()->request->params;
     $pParams['map'] = realpath($lrep->getPath()) . '/' . $project . ".qgs";
     $lizmapCache = jClasses::getService('lizmap~lizmapCache');
     $params = $lizmapCache->normalizeParams($pParams);
     // Define class private properties
     $this->project = lizmap::getProject($repository . '~' . $project);
     $this->repository = $lrep;
     $this->services = lizmap::getServices();
     $this->params = $params;
     $this->lizmapCache = $lizmapCache;
     // Optionnaly filter data by login
     if (isset($params['request'])) {
         $request = strtolower($params['request']);
         if (in_array($request, array('getmap', 'getfeatureinfo', 'getfeature', 'getprint')) and !jAcl2::check('lizmap.tools.loginFilteredLayers.override', $lrep->getKey())) {
             $this->filterDataByLogin();
         }
     }
     return true;
 }
コード例 #29
0
 function rightres()
 {
     $rep = $this->getResponse('html');
     $groupid = $this->param('group', null);
     if ($groupid === null || $groupid == '') {
         $rep->body->assign('MAIN', '<p>invalid group.</p>');
         return $rep;
     }
     $daogroup = jDao::get('jacl2db~jacl2group', 'jacl2_profile');
     if ($groupid != '__anonymous') {
         $group = $daogroup->get($groupid);
         if (!$group) {
             $rep->body->assign('MAIN', '<p>invalid group.</p>');
             return $rep;
         }
         $groupname = $group->name;
     } else {
         $groupname = jLocale::get('jacl2db_admin~acl2.anonymous.group.name');
     }
     $rightsWithResources = array();
     $daorights = jDao::get('jacl2db~jacl2rights', 'jacl2_profile');
     $rs = $daorights->getRightsHavingRes($groupid);
     $hasRightsOnResources = false;
     foreach ($rs as $rec) {
         if (!isset($rightsWithResources[$rec->id_aclsbj])) {
             $rightsWithResources[$rec->id_aclsbj] = array();
         }
         $rightsWithResources[$rec->id_aclsbj][] = $rec;
         $hasRightsOnResources = true;
     }
     $subjects_localized = array();
     if (!empty($rightsWithResources)) {
         $conditions = jDao::createConditions();
         $conditions->addCondition('id_aclsbj', 'in', array_keys($rightsWithResources));
         foreach (jDao::get('jacl2db~jacl2subject', 'jacl2_profile')->findBy($conditions) as $rec) {
             $subjects_localized[$rec->id_aclsbj] = jLocale::get($rec->label_key);
         }
     }
     $tpl = new jTpl();
     $tpl->assign(compact('groupid', 'groupname', 'subjects_localized', 'rightsWithResources', 'hasRightsOnResources'));
     if (jAcl2::check('acl.group.modify')) {
         $rep->body->assign('MAIN', $tpl->fetch('group_rights_res'));
     } else {
         $rep->body->assign('MAIN', $tpl->fetch('group_rights_res_view'));
     }
     $rep->body->assign('selectedMenuItem', 'usersgroups');
     return $rep;
 }
コード例 #30
0
ファイル: users.classic.php プロジェクト: rodacom/jelix
 function rightres()
 {
     $rep = $this->getResponse('html');
     $user = $this->param('user');
     if (!$user) {
         $rep->body->assign('MAIN', '<p>invalid user</p>');
         return $rep;
     }
     $daogroup = jDao::get('jacl2db~jacl2group', 'jacl2_profile');
     $group = $daogroup->getPrivateGroup($user);
     $rightsWithResources = array();
     $daorights = jDao::get('jacl2db~jacl2rights', 'jacl2_profile');
     $rs = $daorights->getRightsHavingRes($group->id_aclgrp);
     $hasRightsOnResources = false;
     foreach ($rs as $rec) {
         if (!isset($rightsWithResources[$rec->id_aclsbj])) {
             $rightsWithResources[$rec->id_aclsbj] = array();
         }
         $rightsWithResources[$rec->id_aclsbj][] = $rec;
         $hasRightsOnResources = true;
     }
     $subjects_localized = array();
     if (!empty($rightsWithResources)) {
         $conditions = jDao::createConditions();
         $conditions->addCondition('id_aclsbj', 'in', array_keys($rightsWithResources));
         foreach (jDao::get('jacl2db~jacl2subject', 'jacl2_profile')->findBy($conditions) as $rec) {
             $subjects_localized[$rec->id_aclsbj] = jLocale::get($rec->label_key);
         }
     }
     $tpl = new jTpl();
     $tpl->assign(compact('user', 'subjects_localized', 'rightsWithResources', 'hasRightsOnResources'));
     if (jAcl2::check('acl.user.modify')) {
         $rep->body->assign('MAIN', $tpl->fetch('user_rights_res'));
     } else {
         $rep->body->assign('MAIN', $tpl->fetch('user_rights_res_view'));
     }
     $rep->body->assign('selectedMenuItem', 'usersrights');
     return $rep;
 }