/**
  * 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;
 }
Exemplo n.º 2
0
 function install()
 {
     if (self::$key === null) {
         self::$key = jAuth::getRandomPassword(30, true);
     }
     $authconfig = $this->config->getValue('auth', 'coordplugins');
     $authconfigMaster = $this->config->getValue('auth', 'coordplugins', null, true);
     $forWS = in_array($this->entryPoint->type, array('json', 'jsonrpc', 'soap', 'xmlrpc'));
     if (!$authconfig || $forWS && $authconfig == $authconfigMaster) {
         if ($forWS) {
             $pluginIni = 'authsw.coord.ini.php';
         } else {
             $pluginIni = 'auth.coord.ini.php';
         }
         $authconfig = dirname($this->entryPoint->configFile) . '/' . $pluginIni;
         if ($this->firstExec('auth:' . $authconfig)) {
             // no configuration, let's install the plugin for the entry point
             $this->config->setValue('auth', $authconfig, 'coordplugins');
             if (!file_exists(jApp::configPath($authconfig))) {
                 $this->copyFile('var/config/' . $pluginIni, jApp::configPath($authconfig));
             }
         }
     }
     $localConfigIni = $this->entryPoint->localConfigIni;
     $key = $localConfigIni->getValue('persistant_crypt_key', 'coordplugin_auth');
     if ($key === 'exampleOfCryptKey' || $key == '') {
         $localConfigIni->getMaster()->setValue('persistant_crypt_key', self::$key, 'coordplugin_auth');
     }
 }
Exemplo n.º 3
0
 /**
  * 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();
     }
 }
Exemplo n.º 4
0
 /**
  *
  */
 function create()
 {
     $rep = $this->getResponse('json');
     $category_id = $this->intParam('category_id', null, true);
     $title = $this->param('title', '', true);
     $url = $this->param('url', '', true);
     //$description=$this->param('description', '', true);
     //insert
     if (!empty($url) && !empty($title) && !empty($category_id)) {
         $this->msg = 'link non  ajouté';
         // instanciation de la factory
         $tb = jDao::get("link");
         // creation d'un record correspondant au dao foo
         $record = jDao::createRecord("link");
         // on remplit le record
         $record->title = $title;
         $record->url = $url;
         $record->category_id = $category_id;
         $record->user_id = jAuth::getUserSession()->id;
         // on le sauvegarde dans la base
         try {
             $tb->insert($record);
             $this->success = true;
             $this->msg = "Lien ajouté ";
         } catch (Exception $e) {
             $this->success = false;
             $this->msg = "lien non ajouté ";
         }
     }
     $rep->data = array('success' => $this->success, 'msg' => $this->msg);
     return $rep;
 }
Exemplo n.º 5
0
 /**
  * 
  */
 function update()
 {
     $id = $this->param('j_user_login');
     $pwd = $this->param('pwd');
     $pwdconf = $this->param('pwd_confirm');
     $rep = $this->getResponse('redirect');
     if ($this->personalView && $id != jAuth::getUserSession()->login) {
         jMessage::add(jLocale::get('jelix~errors.acl.action.right.needed'), 'error');
         $rep->action = 'master_admin~default:index';
         return $rep;
     }
     if (trim($pwd) == '' || $pwd != $pwdconf) {
         jMessage::add(jLocale::get('crud.message.bad.password'), 'error');
         $rep->action = 'password:index';
         $rep->params['j_user_login'] = $id;
         return $rep;
     }
     if (jAuth::changePassword($id, $pwd)) {
         jMessage::add(jLocale::get('crud.message.change.password.ok', $id), 'notice');
         if ($this->personalView) {
             $rep->action = 'user:index';
         } else {
             $rep->action = 'default:view';
         }
         $rep->params['j_user_login'] = $id;
         return $rep;
     } else {
         jMessage::add(jLocale::get('crud.message.change.password.notok'), 'error');
         $rep->action = 'password:index';
         $rep->params['j_user_login'] = $id;
     }
     return $rep;
 }
Exemplo n.º 6
0
 /**
  *
  */
 function out()
 {
     jAuth::logout();
     $rep = $this->getResponse('text');
     $rep->content = 'LOGOUT';
     return $rep;
 }
Exemplo n.º 7
0
 protected function _prepareTpl()
 {
     $config = new \Jelix\JCommunity\Config();
     $this->_tpl->assign('canRegister', $config->isRegistrationEnabled());
     $this->_tpl->assign('canResetPassword', $config->isResetPasswordEnabled());
     if (jAuth::isConnected()) {
         $this->_tpl->assign('login', jAuth::getUserSession()->login);
     } else {
         $conf = jAuth::loadConfig();
         $this->_tpl->assign('persistance_ok', jAuth::isPersistant());
         $form = jForms::get("jcommunity~login");
         if (!$form) {
             $form = jForms::create("jcommunity~login");
         }
         $this->_tpl->assign('form', $form);
         $this->_tpl->assign('url_return', '');
         if ($conf['enable_after_login_override']) {
             $req = jApp::coord()->request;
             if ($req->getParam('auth_url_return')) {
                 $this->_tpl->assign('url_return', $req->getParam('auth_url_return'));
             } else {
                 if ($this->param('as_main_content')) {
                     if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] && $_SERVER['HTTP_REFERER'] != jUrl::getCurrentUrl(false, true)) {
                         $this->_tpl->assign('url_return', $_SERVER['HTTP_REFERER']);
                     }
                 } else {
                     if ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') {
                         $this->_tpl->assign('url_return', jUrl::getCurrentUrl(false, true));
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
 /**
  *
  */
 function out()
 {
     $rep = $this->getResponse('redirectUrl');
     jAuth::logout();
     $conf = jApp::coord()->getPlugin('auth')->config;
     if ($conf['after_logout'] == '') {
         throw new jException('jcommunity~login.error.no.auth_logout');
     }
     if (jApp::coord()->execOriginalAction()) {
         if ($conf['enable_after_logout_override']) {
             $url_return = $this->param('auth_url_return');
             if ($url_return) {
                 $rep->url = $url_return;
             } else {
                 $rep->url = jUrl::get($conf['after_logout']);
             }
         }
     } else {
         // we are here because of an internal redirection (authentication missing)
         // if we can indicate the url to go after the login, let's pass this url
         // to the next action (which is in most of case a login form)
         if ($conf['enable_after_login_override']) {
             $rep->url = jUrl::get($conf['after_logout'], array('auth_url_return' => jUrl::getCurrentUrl()));
         } else {
             $rep->url = jUrl::get($conf['after_logout']);
         }
     }
     return $rep;
 }
Exemplo n.º 9
0
 /**
  * check if there is a flood
  * @param integer $timeInterval time between two actions
  * @param integer $onlySameIp  true: the flood is checked only between same ip
  * @return boolean  true if flood is detected
  */
 public static function check($timeInterval, $onlySameIp)
 {
     // since we don't store data of anonymous user, and anonymous user
     // are not allowed to post, we don't check
     if (!jAuth::isConnected()) {
         return false;
     }
     // check if the user is member of Admins (groupid 0) / Moderators (groupid 3)
     // if so, no need to stop the action of this group of users
     // FIXME we should check, not the group, but the rights !
     foreach (jAcl2DbUserGroup::getGroupList() as $grp) {
         if ($grp->id_aclgrp == 'admins' or $grp->id_aclgrp == 'moderators') {
             return false;
         }
     }
     $dao = jDao::get('havefnubb~posts');
     $rec = $dao->getMyLastEditedPost(jAuth::getUserSession()->id);
     if ($rec->member_last_post + $timeInterval > time()) {
         return false;
     }
     if ($onlySameIp && isset($_SERVER['REMOTE_ADDR']) && $rec->poster_ip != $_SERVER['REMOTE_ADDR']) {
         return false;
     }
     return true;
 }
Exemplo n.º 10
0
 public function testAll()
 {
     if ($this->config === null) {
         $this->sendMessage('Ldap plugin for jauth is not tested because there isn\'t configuration.' . ' To test it, you should create and configure an auth_ldap.coord.ini.php file.');
         return;
     }
     for ($i = 1; $i <= NB_USERS_LDAP; $i++) {
         $myUser = jAuth::createUserObject("testldap usr {$i}", "pass{$i}");
         $this->assertTrue($myUser instanceof jAuthUserLDAP);
         jAuth::saveNewUser($myUser);
         $myUserLDAP = jAuth::getUser("testldap usr {$i}");
         $user = "******"jAuthUserLDAP\">\n                <string property=\"login\" value=\"testldap usr {$i}\" />\n                <string property=\"email\" value=\"\" />\n                <array property=\"cn\">array('testldap usr {$i}')</array>\n                <array property=\"distinguishedName\">array('CN=testldap usr {$i},{$this->config['ldap']['searchBaseDN']}')</array>\n                <array property=\"name\">array('testldap usr {$i}')</array>\n                <string property=\"password\" value=\"\" />\n            </object>\n            ";
         $this->assertComplexIdenticalStr($myUserLDAP, $user);
         $myUser->email = "usr{$i}.testldap@domain.com";
         jAuth::updateUser($myUser);
         $myUserLDAP = jAuth::getUser("testldap usr {$i}");
         $user = "******"login\" value=\"testldap usr {$i}\" />\n                <array property=\"email\">array('usr{$i}.testldap@domain.com')</array>\n                <array property=\"cn\">array('testldap usr {$i}')</array>\n                <array property=\"distinguishedName\">array('CN=testldap usr {$i},{$this->config['ldap']['searchBaseDN']}')</array>\n                <array property=\"name\">array('testldap usr {$i}')</array>\n                <string property=\"password\" value=\"\" />\n            </object>\n            ";
         $this->assertComplexIdenticalStr($myUserLDAP, $user);
         $this->assertTrue(jAuth::verifyPassword("testldap usr {$i}", "pass{$i}"));
         $this->assertTrue(jAuth::changePassword("testldap usr {$i}", "newpass{$i}"));
     }
     $myUsersLDAP = jAuth::getUserList('testldap usr*');
     $users = "<array>";
     for ($i = 1; $i <= NB_USERS_LDAP; $i++) {
         $users .= "\n            <object>\n                <array property=\"login\">array('testldap usr {$i}')</array>\n                <array property=\"email\">array('usr{$i}.testldap@domain.com')</array>\n                <array property=\"cn\">array('testldap usr {$i}')</array>\n                <array property=\"distinguishedName\">array('CN=testldap usr {$i},{$this->config['ldap']['searchBaseDN']}')</array>\n                <array property=\"name\">array('testldap usr {$i}')</array>\n                <string property=\"password\" value=\"\" />\n            </object>\n            ";
     }
     $users .= "</array>";
     $this->assertComplexIdenticalStr($myUsersLDAP, $users);
     for ($i = 1; $i <= NB_USERS_LDAP; $i++) {
         $this->assertTrue(jAuth::removeUser("testldap usr {$i}"));
     }
     $myUsersLDAP = jAuth::getUserList('testldap usr*');
     $this->assertFalse(count($myUsersLDAP) > 0);
 }
Exemplo n.º 11
0
 /**
  * 
  */
 function update()
 {
     $id = $this->param('id');
     $pwd = $this->param('pwd');
     $pwdconf = $this->param('pwd_confirm');
     $rep = $this->getResponse('redirect');
     if (trim($pwd) == '' || $pwd != $pwdconf) {
         jMessage::add(jLocale::get('crud.message.bad.password'), 'error');
         $rep->action = 'password:index';
         $rep->params['id'] = $id;
         return $rep;
     }
     if (jAuth::changePassword($id, $pwd)) {
         jMessage::add(jLocale::get('crud.message.change.password.ok', $id), 'notice');
         if ($this->personalView) {
             $rep->action = 'user:index';
         } else {
             $rep->action = 'default:view';
         }
         $rep->params['id'] = $id;
         return $rep;
     } else {
         jMessage::add(jLocale::get('crud.message.change.password.notok'), 'error');
         $rep->action = 'password:index';
         $rep->params['id'] = $id;
     }
     return $rep;
 }
Exemplo n.º 12
0
 /**
  * return the value of the right on the given subject (and on the optional resource)
  * @param string $subject the key of the subject
  * @param string $resource the id of a resource
  * @return array list of values corresponding to the right
  */
 public function getRight($subject, $resource = null)
 {
     if ($resource === null && isset(self::$acl[$subject])) {
         return self::$acl[$subject];
     } elseif (isset(self::$aclres[$subject][$resource])) {
         return self::$aclres[$subject][$resource];
     }
     if (!jAuth::isConnected()) {
         // not authificated = no rights
         return array();
     }
     $groups = jAclDbUserGroup::getGroups();
     if (count($groups) == 0) {
         self::$acl[$subject] = array();
         self::$aclres[$subject][$resource] = array();
         return array();
     }
     // recupère toutes les valeurs correspondant aux groupes auquel appartient le user,
     //   avec le sujet et ressource indiqué
     $values = array();
     $dao = jDao::get('jelix~jaclrights', jAclDb::getProfile());
     $list = $dao->getAllGroupRights($subject, $groups);
     foreach ($list as $right) {
         $values[] = $right->value;
     }
     self::$acl[$subject] = $values;
     if ($resource !== null) {
         $list = $dao->getAllGroupRightsWithRes($subject, $groups, $resource);
         foreach ($list as $right) {
             $values[] = $right->value;
         }
         self::$aclres[$subject][$resource] = $values = array_unique($values);
     }
     return $values;
 }
 protected function _prepareTpl()
 {
     // Get the project and repository params
     $project = $this->param('project');
     $repository = $this->param('repository');
     $auth_url_return = $this->param('auth_url_return');
     if (!$auth_url_return) {
         $auth_url_return = jUrl::get('view~map:index', array("repository" => $repository, "project" => $project));
     }
     // Get lizmapProject class
     $assign = array('isConnected' => jAuth::isConnected(), 'user' => jAuth::getUserSession(), 'auth_url_return' => $auth_url_return, "externalSearch" => "", "edition" => false, "measure" => false, "locate" => false, "geolocation" => false, "timemanager" => false, "print" => false, "attributeLayers" => false);
     try {
         $lproj = lizmap::getProject($repository . '~' . $project);
         $configOptions = $lproj->getOptions();
         if (property_exists($configOptions, 'externalSearch')) {
             $assign['externalSearch'] = $configOptions->externalSearch;
         }
     } catch (UnknownLizmapProjectException $e) {
         jLog::logEx($e, 'error');
     }
     $this->_tpl->assign($assign);
     // Get lizmap services
     $services = lizmap::getServices();
     if ($services->allowUserAccountRequests) {
         $this->_tpl->assign('allowUserAccountRequests', True);
     }
 }
Exemplo n.º 14
0
 /**
  * return the value of the right on the given subject (and on the optional resource)
  * @param string $subject the key of the subject
  * @param string $resource the id of a resource
  * @return array list of values corresponding to the right
  */
 public function getRight($subject, $resource = null)
 {
     if ($resource === null && isset(self::$acl[$subject])) {
         return self::$acl[$subject];
     } elseif (isset(self::$aclres[$subject][$resource])) {
         return self::$aclres[$subject][$resource];
     }
     if (!jAuth::isConnected()) {
         // not authificated = no rights
         return array();
     }
     $groups = jAclDbUserGroup::getGroups();
     if (count($groups) == 0) {
         self::$acl[$subject] = array();
         self::$aclres[$subject][$resource] = array();
         return array();
     }
     // get all the values corresponding to the groups which the user has access to,
     //  with the subject and resource indicated
     $values = array();
     $dao = jDao::get('jacldb~jaclrights', 'jacl_profile');
     $list = $dao->getAllGroupRights($subject, $groups);
     foreach ($list as $right) {
         $values[] = $right->value;
     }
     self::$acl[$subject] = $values;
     if ($resource !== null) {
         $list = $dao->getAllGroupRightsWithRes($subject, $groups, $resource);
         foreach ($list as $right) {
             $values[] = $right->value;
         }
         self::$aclres[$subject][$resource] = $values = array_unique($values);
     }
     return $values;
 }
Exemplo n.º 15
0
 /**
  * @param    array  $params   plugin parameters for the current action
  * @return null or jSelectorAct  if action should change
  */
 public function beforeAction($params)
 {
     $notLogged = false;
     $badip = false;
     $selector = null;
     // Check if auth cookie exist and user isn't logged on
     jAuth::checkCookieToken();
     //Do we check the ip ?
     if ($this->config['secure_with_ip']) {
         if (!isset($_SESSION['JELIX_AUTH_SECURE_WITH_IP'])) {
             $_SESSION['JELIX_AUTH_SECURE_WITH_IP'] = $this->_getIpForSecure();
         } else {
             if ($_SESSION['JELIX_AUTH_SECURE_WITH_IP'] != $this->_getIpForSecure()) {
                 session_destroy();
                 $selector = new jSelectorAct($this->config['bad_ip_action']);
                 $notLogged = true;
                 $badip = true;
             }
         }
     }
     //Creating the user's object if needed
     if (!isset($_SESSION[$this->config['session_name']])) {
         $notLogged = true;
         $_SESSION[$this->config['session_name']] = new jAuthDummyUser();
     } else {
         $notLogged = !jAuth::isConnected();
     }
     if (!$notLogged && $this->config['timeout']) {
         if (isset($_SESSION['JELIX_AUTH_LASTTIME'])) {
             if (time() - $_SESSION['JELIX_AUTH_LASTTIME'] > $this->config['timeout'] * 60) {
                 $notLogged = true;
                 jAuth::logout();
                 unset($_SESSION['JELIX_AUTH_LASTTIME']);
             } else {
                 $_SESSION['JELIX_AUTH_LASTTIME'] = time();
             }
         } else {
             $_SESSION['JELIX_AUTH_LASTTIME'] = time();
         }
     }
     $needAuth = isset($params['auth.required']) ? $params['auth.required'] == true : $this->config['auth_required'];
     $authok = false;
     if ($needAuth) {
         if ($notLogged) {
             if (jApp::coord()->request->isAjax() || $this->config['on_error'] == 1 || !jApp::coord()->request->isAllowedResponse('jResponseRedirect')) {
                 throw new jException($this->config['error_message']);
             } else {
                 if (!$badip) {
                     $selector = new jSelectorAct($this->config['on_error_action']);
                 }
             }
         } else {
             $authok = true;
         }
     } else {
         $authok = true;
     }
     return $selector;
 }
Exemplo n.º 16
0
 public function testGetRightDisconnect()
 {
     jAuth::logout();
     jAcl::clearCache();
     $this->assertEqual(jAcl::getRight('super.cms'), array());
     $this->assertEqual(jAcl::getRight('admin.access'), array());
     jAcl::clearCache();
 }
 protected function _prepareTpl()
 {
     jClasses::inc('masterAdminMenuItem');
     $items = jEvent::notify('masteradminGetInfoBoxContent')->getResponse();
     usort($items, "masterAdminItemSort");
     $this->_tpl->assign('infoboxitems', $items);
     $this->_tpl->assign('user', jAuth::getUserSession());
 }
Exemplo n.º 18
0
 protected function _prepareTpl()
 {
     $id = jAuth::getUserSession()->id;
     $title = jLocale::get("jmessenger~message.msg.inbox");
     $dao = jDao::get($this->dao);
     $msg = $dao->getRecus($id);
     $this->_tpl->assign(compact('msg', 'id', 'title'));
 }
Exemplo n.º 19
0
 protected function _prepareTpl()
 {
     $config = new \Jelix\JCommunity\Config();
     $this->_tpl->assign('canRegister', $config->isRegistrationEnabled());
     $this->_tpl->assign('canResetPassword', $config->isResetPasswordEnabled());
     if (jAuth::isConnected()) {
         $this->_tpl->assign('login', jAuth::getUserSession()->login);
     }
 }
Exemplo n.º 20
0
 protected function _prepareTpl()
 {
     $id = $this->getParam("id", jAuth::getUserSession()->id);
     $title = jLocale::get("jmessenger~message.msg.archived");
     $dao = jDao::get($this->dao);
     $msg = $dao->getArchive($id);
     $send = true;
     $this->_tpl->assign(compact('msg', 'id', 'title', 'send'));
 }
Exemplo n.º 21
0
 protected function _prepareTpl()
 {
     $this->_tpl->assign('login', $this->param('login'));
     $this->_tpl->assign('failed', $this->param('failed'));
     $this->_tpl->assign('auth_url_return', $this->param('auth_url_return', ''));
     $this->_tpl->assign('user', jAuth::getUserSession());
     $this->_tpl->assign('isLogged', jAuth::isConnected());
     $this->_tpl->assign('showRememberMe', $this->param('showRememberMe'));
 }
Exemplo n.º 22
0
 protected function _markAsRead()
 {
     $dao = jDao::get($this->dao);
     $m = $dao->get($this->param("id", 0));
     if ($m && $m->id_for == jAuth::getUserSession()->id) {
         $m->isSeen = 1;
         $dao->update($m);
     }
 }
 protected function doAfterActions()
 {
     $this->body->assignIfNone('MAIN', '<p>no content</p>');
     $this->body->assignIfNone('repositoryLabel', 'Lizmap');
     $this->body->assignIfNone('isConnected', jAuth::isConnected());
     $this->body->assignIfNone('user', jAuth::getUserSession());
     $this->body->assignIfNone('auth_url_return', '');
     $this->body->assignIfNone('googleAnalyticsID', '');
 }
Exemplo n.º 24
0
 /**
  * return the value of the right on the given subject (and on the optional resource).
  *
  * The resource "-" (meaning 'all resources') has the priority over specific resources.
  * It means that if you give a specific resource, it will be ignored if there is a positive right
  * with "-". The right on the given resource will be checked if there is no rights for "-".
  * 
  * @param string $subject the key of the subject
  * @param string $resource the id of a resource
  * @return boolean true if the user has the right on the given subject
  */
 public function getRight($subject, $resource = '-')
 {
     if (empty($resource)) {
         $resource = '-';
     }
     if (!jAuth::isConnected()) {
         return self::getAnonymousRight($subject, $resource);
     }
     $groups = null;
     if (self::$acl === null) {
         // let's load all rights for the groups on which the current user is attached
         $groups = jAcl2DbUserGroup::getGroups();
         self::$acl = array();
         if (count($groups)) {
             $dao = jDao::get('jacl2db~jacl2rights', 'jacl2_profile');
             foreach ($dao->getRightsByGroups($groups) as $rec) {
                 // if there is already a right on a same subject on an other group
                 // we should take care when this rights says "cancel"
                 if (isset(self::$acl[$rec->id_aclsbj])) {
                     if ($rec->canceled) {
                         self::$acl[$rec->id_aclsbj] = false;
                     }
                 } else {
                     self::$acl[$rec->id_aclsbj] = $rec->canceled ? false : true;
                 }
             }
         }
     }
     if (!isset(self::$acl[$subject])) {
         self::$acl[$subject] = false;
     }
     // no resource given, just return the global right for the given subject
     if ($resource == '-') {
         return self::$acl[$subject];
     }
     // if we already have loaded the corresponding right, returns it
     if (isset(self::$aclres[$subject][$resource])) {
         return self::$aclres[$subject][$resource];
     }
     // default right for the resource is the global right
     self::$aclres[$subject][$resource] = self::$acl[$subject];
     // if the general right is not given, check the specific right for the resource
     if (!self::$acl[$subject]) {
         if ($groups === null) {
             $groups = jAcl2DbUserGroup::getGroups();
         }
         if (count($groups)) {
             $dao = jDao::get('jacl2db~jacl2rights', 'jacl2_profile');
             $right = $dao->getRightWithRes($subject, $groups, $resource);
             self::$aclres[$subject][$resource] = $right != false ? $right->canceled ? false : true : false;
         }
         return self::$aclres[$subject][$resource];
     } else {
         return true;
     }
 }
Exemplo n.º 25
0
 /**
  * get the private group for the current user or for the given login
  * @param string $login The user's login
  * @return string the id of the private group
  * @since 1.2
  */
 public static function getPrivateGroup($login = null)
 {
     if (!$login) {
         if (!jAuth::isConnected()) {
             return null;
         }
         $login = jAuth::getUserSession()->login;
     }
     return jDao::get('jacl2db~jacl2group', 'jacl2_profile')->getPrivateGroup($login)->id_aclgrp;
 }
Exemplo n.º 26
0
 /**
  * Function that updates member's datas
  */
 private function updateMember()
 {
     $daoUser = jDao::get('havefnubb~member');
     if (jAuth::isConnected()) {
         $id_user = jAuth::getUserSession()->id;
         $daoUser->updateNbMsg($id_user);
     } else {
         $id_user = 0;
     }
     $daoUser->updateLastPostedMsg($id_user, time());
 }
Exemplo n.º 27
0
 /**
  *
  */
 function index()
 {
     $resp = $this->getResponse('html');
     $resp->title = jLocale::get('gui.dashboard.title');
     $resp->body->assignZone('MAIN', 'dashboard');
     if (jAuth::getUserSession()->login == 'admin' && jAuth::getUserSession()->password == md5('admin')) {
         jMessage::add(jLocale::get('gui.message.admin.password'), 'error');
     }
     $resp->body->assign('selectedMenuItem', 'dashboard');
     return $resp;
 }
 /**
  * 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);
 }
Exemplo n.º 29
0
 /**
  * method which manages 'globales' behavior/var
  */
 protected function doAfterActions()
 {
     // Include all process in common for all actions, like the settings of the
     // main template, the settings of the response etc..
     $this->title .= ($this->title != '' ? ' - ' : '') . ' Administration';
     $this->body->assignIfNone('selectedMenuItem', '');
     $this->body->assignZone('MENU', 'master_admin~admin_menu', array('selectedMenuItem' => $this->body->get('selectedMenuItem')));
     $this->body->assignZone('INFOBOX', 'master_admin~admin_infobox');
     $this->body->assignIfNone('MAIN', '');
     $this->body->assignIfNone('adminTitle', '');
     $this->body->assign('user', jAuth::getUserSession());
 }
Exemplo n.º 30
0
 /**
  *
  */
 function index()
 {
     $resp = $this->getResponse('html');
     $resp->title = jLocale::get('gui.dashboard.title');
     $resp->body->assignZone('MAIN', 'dashboard');
     $user = jAuth::getUserSession();
     $driver = jAuth::getDriver();
     if (method_exists($driver, 'checkPassword') && $user->login == 'admin' && $driver->checkPassword('admin', $user->password)) {
         jMessage::add(jLocale::get('gui.message.admin.password'), 'error');
     }
     $resp->body->assign('selectedMenuItem', 'dashboard');
     return $resp;
 }