예제 #1
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));
                     }
                 }
             }
         }
     }
 }
예제 #2
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;
 }
예제 #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();
     }
 }
예제 #4
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;
 }
 /**
  * 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;
 }
 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);
     }
 }
예제 #7
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;
 }
예제 #8
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;
 }
 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', '');
 }
예제 #10
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);
     }
 }
예제 #11
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'));
 }
예제 #12
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;
     }
 }
예제 #13
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;
 }
예제 #14
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());
 }
예제 #15
0
 protected function _check()
 {
     if ($this->configMethodCheck) {
         $method = $this->configMethodCheck;
         if (!$this->config->{$method}()) {
             return $this->notavailable();
         }
     }
     if (\jAuth::isConnected()) {
         return $this->noaccess();
     }
     return null;
 }
예제 #16
0
 /**
  *
  */
 function index()
 {
     $rep = $this->getResponse('html');
     $tpl = new jTpl();
     if (jAuth::isConnected()) {
         $tpl->assign('user', jAuth::getUserSession());
     }
     $config = new \Jelix\JCommunity\Config();
     $tpl->assign('canRegister', $config->isRegistrationEnabled());
     $tpl->assign('canResetPassword', $config->isResetPasswordEnabled());
     $rep->body->assign('MAIN', $tpl->fetch('startpage'));
     return $rep;
 }
예제 #17
0
/**
 * 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;
}
예제 #18
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 boolean true if the right is ok
  */
 public function getRight($subject, $resource = null)
 {
     if (!jAuth::isConnected()) {
         return self::getAnonymousRight($subject, $resource);
     }
     $groups = null;
     if (self::$acl === null) {
         $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;
     }
     if ($resource === null) {
         return self::$acl[$subject];
     }
     if (isset(self::$aclres[$subject][$resource])) {
         return self::$aclres[$subject][$resource];
     }
     self::$aclres[$subject][$resource] = self::$acl[$subject];
     // if the general right is not set, 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;
     }
 }
예제 #19
0
 /**
  * retrieve the list of group the current user is member of
  * @return array list of group id
  */
 public static function getGroups()
 {
     static $groups = null;
     if (!jAuth::isConnected()) {
         return array();
     }
     // chargement des groupes
     if ($groups === null) {
         $gp = jDao::get('jelix~jacl2usergroup', jAcl2Db::getProfile())->getGroupsUser(jAuth::getUserSession()->login);
         $groups = array();
         foreach ($gp as $g) {
             $groups[] = intval($g->id_aclgrp);
         }
     }
     return $groups;
 }
 /**
  * Retrieve the list of group the current user is member of
  * @return array list of group id
  * @since 1.0b3
  */
 public static function getGroups()
 {
     static $groups = null;
     if (!jAuth::isConnected()) {
         return array();
     }
     // load the groups
     if ($groups === null) {
         $dao = jDao::get('jacldb~jaclusergroup', 'jacl_profile');
         $gp = $dao->getGroupsUser(jAuth::getUserSession()->login);
         $groups = array();
         foreach ($gp as $g) {
             $groups[] = intval($g->id_aclgrp);
         }
     }
     return $groups;
 }
예제 #21
0
function template_4870c643ce0f402d15b20aff5d50fb00($t)
{
    if (jAuth::isConnected()) {
        ?>
<div class="option">
<ul>
<li><a href="<?php 
        jtpl_function_html_jurl($t, 'editPage', array('page' => $t->_vars['page']));
        ?>
"><?php 
        echo jLocale::get('jelix~crud.link.edit.record');
        ?>
</a></li>
</ul>
</div>
<?php 
    }
}
예제 #22
0
 /**
  * save the Rate to a given source and ID
  * @param integer $id_source the id to link to the source
  * @param string $source the linked source
  * @param integer $rate the rate
  * @return boolean
  */
 function saveRatesBySource($id_source, $source, $rate)
 {
     $dao = jDao::get('hfnurates~rates');
     $id_user = jAuth::isConnected() ? 0 : jAuth::getUserSession()->id;
     $rec = $dao->getByIdSourceSourceRate($id_user, $id_source, $source);
     if ($rec == false) {
         $record = jDao::createRecord('hfnurates~rates');
         $record->id_source = $id_source;
         $record->id_user = $id_user;
         $record->source = $source;
         $record->level = $rate;
         $record->ip = $_SERVER['REMOTE_ADDR'];
         $dao->insert($record);
     } else {
         $rec->level = $rate;
         $dao->update($rec);
     }
     jZone::clear("hfnurates~rates");
     return true;
 }
 function index()
 {
     if (!jAuth::isConnected()) {
         jMessage::add('Geobookmarks - User is not connected', 'error');
         return $this->error();
     }
     if ($this->param('q') == 'add') {
         return $this->add();
     } else {
         if ($this->param('q') == 'del') {
             return $this->delete();
         } else {
             if ($this->param('q') == 'get') {
                 return $this->getBookmarkParams();
             }
         }
     }
     jMessage::add('Geobookmarks - Wrong parameters given', 'error');
     return $this->error();
 }
예제 #24
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 boolean true if the right is ok
  */
 public function getRight($subject, $resource = null)
 {
     if (!jAuth::isConnected()) {
         return self::getAnonymousRight($subject, $resource);
     }
     $groups = null;
     if (self::$acl === null) {
         $groups = jAcl2DbUserGroup::getGroups();
         self::$acl = array();
         if (count($groups)) {
             $dao = jDao::get('jelix~jacl2rights', jAcl2Db::getProfile());
             foreach ($dao->getRightsByGroups($groups) as $rec) {
                 self::$acl[$rec->id_aclsbj] = true;
             }
         }
     }
     if (!isset(self::$acl[$subject])) {
         self::$acl[$subject] = false;
     }
     if ($resource === null) {
         return self::$acl[$subject];
     }
     if (isset(self::$aclres[$subject][$resource])) {
         return self::$aclres[$subject][$resource];
     }
     self::$aclres[$subject][$resource] = self::$acl[$subject];
     if (!self::$acl[$subject]) {
         if ($groups === null) {
             $groups = jAcl2DbUserGroup::getGroups();
         }
         if (count($groups)) {
             $dao = jDao::get('jelix~jacl2rights', jAcl2Db::getProfile());
             $right = $dao->getRightWithRes($subject, $groups, $resource);
             self::$aclres[$subject][$resource] = $right != false;
         }
         return self::$aclres[$subject][$resource];
     } else {
         return true;
     }
 }
예제 #25
0
 /**
  * let's change the user password
  */
 function savenewpwd()
 {
     $login = $this->param('user');
     $rep = $this->getResponse('redirect');
     $rep->action = 'jcommunity~account:show';
     $rep->params = array('user' => $login);
     if ($login == '' || !jAuth::isConnected() || jAuth::getUserSession()->login != $login) {
         return $rep;
     }
     $form = jForms::fill('havefnubb~pwd', $login);
     if (!$form) {
         return $rep;
     }
     // check the form !
     $form->check();
     //if error go back to the form to retry to change the password
     if (count($form->getErrors())) {
         $rep->action = 'havefnubb~members:changepwd';
         // check if the new password is different from the actual one
     } else {
         if ($form->getData('conf_password') == $form->getData('old_password')) {
             jMessage::add(jLocale::get('havefnubb~members.pwd.passwd.are.the.same.unchanged'), 'warning');
             $rep->action = 'havefnubb~members:changepwd';
             return $rep;
         }
         //update the password
         $passwd = $form->getData('conf_password');
         $user = jAuth::getUser($login);
         // update the user info
         jAuth::updateUser($user);
         // change the pass
         jAuth::changePassword($login, $passwd);
         // login back with new pass
         jAuth::login($login, $passwd);
         jForms::destroy('havefnubb~pwd');
     }
     jMessage::add(jLocale::get('havefnubb~member.pwd.passwd.successfully.changed'), 'ok');
     return $rep;
 }
예제 #26
0
 /**
  * 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);
 }
예제 #27
0
 /**
  * Shows the login form
  */
 function form()
 {
     $conf = $GLOBALS['gJCoord']->getPlugin('auth')->config;
     if (jAuth::isConnected()) {
         if ($conf['after_login'] != '') {
             if (!($conf['enable_after_login_override'] && ($url_return = $this->param('auth_url_return')))) {
                 $url_return = jUrl::get($conf['after_login']);
             }
             $rep = $this->getResponse('redirectUrl');
             $rep->url = $url_return;
             return $rep;
         }
     }
     $rep = $this->getResponse('htmlauth');
     $rep->title = jLocale::get('auth.titlePage.login');
     $rep->bodyTpl = 'jauth~index';
     $zp = array('login' => $this->param('login'), 'failed' => $this->param('failed'), 'showRememberMe' => jAuth::isPersistant());
     if ($conf['enable_after_login_override']) {
         $zp['auth_url_return'] = $this->param('auth_url_return');
     }
     $rep->body->assignZone('MAIN', 'jauth~loginform', $zp);
     return $rep;
 }
예제 #28
0
 protected function _prepareTpl()
 {
     if (jAuth::isConnected()) {
         $this->_tpl->assign('login', jAuth::getUserSession()->login);
     } else {
         $conf = jApp::coord()->getPlugin('auth')->config;
         $this->_tpl->assign('persistance_ok', $conf['persistant_enable']);
         $form = jForms::get("jcommunity~login");
         if (!$form) {
             $form = jForms::create("jcommunity~login");
         }
         $this->_tpl->assign('form', $form);
         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 ($_SERVER['HTTP_REFERER']) {
                         $this->_tpl->assign('url_return', $_SERVER['HTTP_REFERER']);
                     } else {
                         $this->_tpl->assign('url_return', '');
                     }
                 } else {
                     //(empty($_SERVER['HTTPS'])?'http':'https').'://'.$_SERVER["HTTP_HOST"].
                     $url = $req->urlScript . $req->urlPathInfo;
                     if (!empty($_SERVER['QUERY_STRING'])) {
                         $url .= '?' . $_SERVER['QUERY_STRING'];
                     }
                     $this->_tpl->assign('url_return', $url);
                 }
             }
         } else {
             $this->_tpl->assign('url_return', '');
         }
     }
 }
예제 #29
0
function template_c6c3209f21a9d1f4126c529d5d56c118($t)
{
    if (jAuth::isConnected()) {
        ?>
<div class="option">
<ul>
<li>
<a href="<?php 
        jtpl_function_html_jurl($t, $t->_vars['createAction']);
        ?>
" class="crud-link"><?php 
        echo jLocale::get('jelix~crud.link.create.record');
        ?>
</a>
</li>
</ul>
</div>
<?php 
    }
    foreach ($t->_vars['list'] as $t->_vars['record']) {
        ?>
	<?php 
        echo jZone::get('viewevent', array('id' => $t->_vars['record']->id));
    }
    if ($t->_vars['recordCount'] > $t->_vars['listPageSize']) {
        ?>
<p class="record-pages-list">Pages : <?php 
        jtpl_function_html_pagelinks($t, $t->_vars['listAction'], array(), $t->_vars['recordCount'], $t->_vars['page'], $t->_vars['listPageSize'], $t->_vars['offsetParameterName']);
        ?>
</p>
<?php 
    }
    ?>

<?php 
}
 public function getDefaultMiniDockable()
 {
     jClasses::inc('view~lizmapMapDockItem');
     $dockable = array();
     $configOptions = $this->getOptions();
     $bp = jApp::config()->urlengine['basePath'];
     if ($this->hasLocateByLayer()) {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('locate', jLocale::get('view~map.locatemenu.title'), $tpl->fetch('view~map_locate'), 1);
     }
     if (property_exists($configOptions, 'geolocation') && $configOptions->geolocation == 'True') {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('geolocation', jLocale::get('view~map.geolocate.navbar.title'), $tpl->fetch('view~map_geolocation'), 2);
     }
     if (property_exists($configOptions, 'print') && $configOptions->print == 'True') {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('print', jLocale::get('view~map.print.navbar.title'), $tpl->fetch('view~map_print'), 3);
     }
     if (property_exists($configOptions, 'measure') && $configOptions->measure == 'True') {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('measure', jLocale::get('view~map.measure.navbar.title'), $tpl->fetch('view~map_measure'), 4);
     }
     if ($this->hasTooltipLayers()) {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('tooltip-layer', jLocale::get('view~map.tooltip.navbar.title'), $tpl->fetch('view~map_tooltip'), 5, '', '');
     }
     if ($this->hasTimemanagerLayers()) {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('timemanager', jLocale::get('view~map.timemanager.navbar.title'), $tpl->fetch('view~map_timemanager'), 6, '', $bp . 'js/timemanager.js');
     }
     // Permalink
     if (true) {
         // Get geobookmark if user is connected
         $gbCount = False;
         $gbList = Null;
         if (jAuth::isConnected()) {
             $juser = jAuth::getUserSession();
             $usr_login = $juser->login;
             $daogb = jDao::get('lizmap~geobookmark');
             $conditions = jDao::createConditions();
             $conditions->addCondition('login', '=', $usr_login);
             $conditions->addCondition('map', '=', $this->repository->getKey() . ':' . $this->getKey());
             $gbList = $daogb->findBy($conditions);
             $gbCount = $daogb->countBy($conditions);
         }
         $tpl = new jTpl();
         $tpl->assign('gbCount', $gbCount);
         $tpl->assign('gbList', $gbList);
         $gbContent = Null;
         if ($gbList) {
             $gbContent = $tpl->fetch('view~map_geobookmark');
         }
         $tpl = new jTpl();
         $tpl->assign('gbContent', $gbContent);
         $dockable[] = new lizmapMapDockItem('permaLink', jLocale::get('view~map.permalink.navbar.title'), $tpl->fetch('view~map_permalink'), 6);
     }
     return $dockable;
 }