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)); } } } } } }
/** * */ 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; }
/** * 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; }
/** * 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(); } }
/** * */ 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; }
/** * 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; }
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); } }
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()); }
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')); }
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')); }
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')); }
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); } }
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', ''); }
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); } }
/** * 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; }
/** * 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()); }
/** * */ 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); }
function current() { $rep = $this->getResponse('json'); $u = jAuth::getUserSession(); if ($u->birthdate) { $dt = new DateTime($u->birthdate); $rep->data = array('firstname' => $u->firstname, 'lastname' => $u->lastname, 'email' => $u->email, 'birthdate' => $u->birthdate, 'day' => $dt->format('d'), 'month' => $dt->format('m'), 'year' => $dt->format('Y')); } else { $rep->data = array('firstname' => $u->firstname, 'lastname' => $u->lastname, 'email' => $u->email, 'birthdate' => '', 'day' => '', 'month' => '', 'year' => ''); } return $rep; }
/** * 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()); }
/** * */ 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; }
/** * */ 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; }
/** * notify something from a given post (from the thread_id) to the admin */ function notify() { $id_post = (int) $this->param('id_post'); if ($id_post == 0) { jLog::log(__METHOD__ . ' line : ' . __LINE__ . ' [this should not be 0] $id_post', 'DEBUG'); $rep = $this->getResponse('html'); $tpl = new jTpl(); $rep->body->assign('MAIN', $tpl->fetch('havefnubb~404.html')); $rep->setHttpStatus('404', 'Not found'); return $rep; } $hfnuposts = jClasses::getService('havefnubb~hfnuposts'); $post = $hfnuposts->getPost($id_post); if (!jAcl2::check('hfnu.posts.notify', 'forum' . $post->id_forum)) { jMessage::add(jLocale::get('havefnubb~main.permissions.denied'), 'error'); $rep = $this->getResponse('html'); $tpl = new jTpl(); $rep->body->assign('MAIN', $tpl->fetch('havefnubb~403.html')); $rep->setHttpStatus('403', 'Permission denied'); return $rep; } // crumbs infos $forum = jClasses::getService('havefnubb~hfnuforum')->getForum($post->id_forum); if (!$forum) { jLog::log(__METHOD__ . ' line : ' . __LINE__ . ' [this should not be false] $forum', 'DEBUG'); $rep = $this->getResponse('html'); $tpl = new jTpl(); $rep->body->assign('MAIN', $tpl->fetch('havefnubb~404.html')); $rep->setHttpStatus('404', 'Not found'); return $rep; } $form = jForms::create('havefnubb~notify', $id_post); $form->setData('id_user', jAuth::getUserSession()->id); $form->setData('id_post', $id_post); $form->setData('id_forum', $post->id_forum); $form->setData('thread_id', $post->thread_id); //set the needed parameters to the template $tpl = new jTpl(); $tpl->assign('forum', $forum); $tpl->assign('id_post', $id_post); $tpl->assign('form', $form); $tpl->assign('forum', $forum); $tpl->assign('subject', $post->subject); $tpl->assign('heading', jLocale::get("havefnubb~post.form.notify.message") . ' - ' . $post->subject); $tpl->assign('submitAction', 'havefnubb~postsmgr:savenotify'); $rep = $this->getResponse('html'); $rep->title = jLocale::get("havefnubb~post.form.notify.message") . ' - ' . $post->subject; $rep->body->assign('MAIN', $tpl->fetch('havefnubb~posts.notify')); return $rep; }
/** * 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; }
/** * */ function index() { $rootUrl = jApp::config()->urlengine["basePath"]; $rep = $this->getResponse('html'); $rep->title = 'Tableau de bord ' . $rep->appName; $tb = jDao::get('chat~message'); $jsfiles = $this->extensionsFiles(); $messages = $tb->findLatest(jAuth::getUserSession()->id)->fetchAll(); $rep->body->assign('user', jAuth::getUserSession()); $rep->body->assign('messages', $messages); $rep->body->assign('menus', $this->extensionsMenu()); $rep->body->assign('js_bottom_files', $jsfiles['bottom']); $rep->body->assign('js_head_files', $jsfiles['head']); $rep->body->assign('rootUrl', $rootUrl); return $rep; }
/** * 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; }
public function saveData($champs, $rows) { $s = false; $ir = array_search('ID Patient', $rows[0]); $reception_id = $rows[1][$ir]; // foreach ($champs as $c) { $valeur = ''; $index = array_search($c->importation, $rows[0]); if ($index) { $valeur = $rows[1][$index]; if (strpos($c->importation, "10^(-1)")) { $valeur = (double) $valeur; $valeur = $valeur * 0.1; } } else { $valeur = 0; } // instanciation de la factory $tb = jDao::get("radiologie~resexamen"); // creation d'un record correspondant au dao $record = jDao::createRecord("radiologie~resexamen"); // on remplit le record $user = jAuth::getUserSession(); $record->user_id = $user->id; $record->champ_id = $c->champ_id; $record->examen_id = $reception_id; $record->acte_id = $c->acte_id; $record->valeur = $valeur; $record->datecreation = date('Y-d-m H:i:s'); $record->datemodification = date('Y-d-m H:i:s'); // on le sauvegarde dans la base try { //jLog::dump($record); $tb->insert($record); $s = true; } catch (Exception $e) { //jLog::dump($e->getTraceAsString()); $s = false; } } return $s; }
public static function check($alias) { $cnx = jDb::getConnection(); $user = jAuth::getUserSession(); try { //informations de connection profile DB $sql = "SELECT COUNT(F.id) AS total FROM " . $cnx->prefixTable('user') . " U\n RIGHT JOIN " . $cnx->prefixTable('user_group') . " UG ON U.id = UG.user_id\n RIGHT JOIN " . $cnx->prefixTable('group_feature') . " GF ON UG.group_id = GF.group_id\n RIGHT JOIN " . $cnx->prefixTable('feature') . " F ON GF.feature_id = F.id\n WHERE UG.user_id = '" . $user->id . "' AND (F.title = '" . $alias . "' OR F.title = '*') "; $rs = $cnx->query($sql); $record = $rs->fetch(); if ($record->total >= 1) { $result = true; } else { $result = false; } return $result; } catch (Exception $e) { throw new Exception($e); } }
/** * 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; }
/** * Display the form to resquest an account. * * @return Redirect to the form display action. */ function editAccount() { // Get lizmap services $services = lizmap::getServices(); $rep = $this->getResponse('redirect'); $rep->action = 'view~default:index'; // Redirect if not active if (!$services->allowUserAccountRequests) { return $rep; } // Redirect if already a logged user if (jAuth::isConnected()) { jMessage::add(jLocale::get("view~user.already.logged")); return $rep; } // Prepare html response $rep = $this->getResponse('html'); $rep->title = 'Lizmap'; if ($this->param('theme')) { jApp::config()->theme = $this->param('theme'); } // Get the form $form = jForms::get('view~lizmap_user'); if ($form) { // Display form $tpl = new jTpl(); $tpl->assign('form', $form); $rep->body->assign('MAIN', $tpl->fetch('view~lizmap_user_form')); } else { // redirect to default page $rep = $this->getResponse('redirect'); $rep->action = 'view~user:createAccount'; return $rep; } $rep->body->assign('isConnected', jAuth::isConnected()); $rep->body->assign('user', jAuth::getUserSession()); $rep->body->assign('repositoryLabel', "LizMap"); return $rep; }