/** * */ public function saveedit() { $rep = $this->getResponse('redirect'); $rep->action = 'jpref_admin~prefs:index'; $id = $this->param('id', 0); $field = $this->param('field'); $form = jForms::fill('jpref_admin~pref', $id); if (!$form || !$id || !$field) { return $rep; } if (!$form->check()) { $form->setErrorOn($field, 'jpref_admin~admin.field.error'); $rep->action = 'jpref_admin~prefs:edit'; $rep->params = array('id' => $id); return $rep; } $data = $form->getData($field); if ($field == 'boolean') { if ($data == 'false') { $data = false; } else { $data = true; } } elseif ($field == 'integer') { $data = (int) $data; } elseif ($field == 'decimal') { $data = (double) $data; } jPref::set($id, $data); jMessage::add(jLocale::get('jpref_admin~admin.message.pref.updated'), 'notice'); return $rep; }
function destroy() { jForms::destroy('sample'); $rep = $this->getResponse("redirect"); $rep->action = "sampleform:status"; return $rep; }
/** * */ function in() { $rep = $this->getResponse('redirectUrl'); $conf = jApp::coord()->getPlugin('auth')->config; $url_return = '/'; if ($conf['after_login'] == '') { throw new jException('jcommunity~login.error.no.auth_login'); } if ($conf['after_logout'] == '') { throw new jException('jcommunity~login.error.no.auth_logout'); } $form = jForms::fill('jcommunity~login'); if (!$form) { $rep->url = jUrl::get($conf['after_logout']); return $rep; } if (!jAuth::login($form->getData('auth_login'), $form->getData('auth_password'), $form->getData('auth_remember_me'))) { sleep(intval($conf['on_error_sleep'])); $form->setErrorOn('auth_login', jLocale::get('jcommunity~login.error')); //jMessage::add(jLocale::get('jcommunity~login.error'), 'error'); if ($auth_url_return = $this->param('auth_url_return')) { $url_return = jUrl::get('login:index', array('auth_url_return' => $auth_url_return)); } else { $url_return = jUrl::get('login:index'); } } else { jForms::destroy('jcommunity~login'); if (!($conf['enable_after_login_override'] && ($url_return = $this->param('auth_url_return')))) { $url_return = jUrl::get($conf['after_login']); } } $rep->url = $url_return; return $rep; }
function savecreate() { $form = $this->_getForm(); $form->initFromRequest(); $rep = $this->getResponse('redirect'); if ($form == null) { $rep->action = $this->_getAction('index'); return $rep; } if ($form->check() && $this->_checkData($form, false)) { extract($form->prepareDaoFromControls($this->dao, null, $this->dbProfile), EXTR_PREFIX_ALL, "form"); $dao = jDao::get('emails'); if ($dao->get($form->getData('email')) == null) { $form_dao->insert($form_daorec); $id = $form_daorec->getPk(); $form->saveAllFiles($this->uploadsDirectory); $rep->action = 'NewsLetter~emails:confirm'; $this->_afterCreate($form, $id, $rep); jForms::destroy($this->form); $rep->params['id'] = $id; return $rep; } else { $rep->action = 'NewsLetter~emails:alreadyIn'; return $rep; } } else { $rep->action = 'NewsLetter~emails:create'; return $rep; } }
public function getListData() { $rep = $this->getResponse('json', true); try { $form = jForms::get($this->param('__form'), $this->param('__formid')); if (!$form) { throw new Exception('dummy'); } } catch (Exception $e) { throw new Exception('invalid form selector'); } if ($form->securityLevel == jFormsBase::SECURITY_CSRF) { if ($form->getContainer()->token !== $this->param('__JFORMS_TOKEN__')) { throw new jException("jelix~formserr.invalid.token"); } } $control = $form->getControl($this->param('__ref')); if (!$control || !$control instanceof jFormsControlDatasource) { throw new Exception('bad control'); } if (!$control->datasource instanceof jFormsDaoDatasource) { throw new Exception('not supported datasource type'); } $dependentControls = $control->datasource->getDependentControls(); if (!$dependentControls) { throw new Exception('no dependent controls'); } foreach ($dependentControls as $ctname) { $form->setData($ctname, $this->param($ctname)); } $rep->data = array('data' => $control->datasource->getData($form)); return $rep; }
function images() { $vidsService = new OnDiskVideosService(); $albumId = $this->param('albumId'); $rep = $this->getResponse('html'); $tpl = new Jtpl(); $picasaService = new jPicasa(); $thumbnailSize = 400; foreach ($picasaService->images($albumId, $thumbnailSize) as $image) { $paint = new Painting($image); $paintings[] = $paint; //break; } $tpl->assign('albumId', $albumId); $tpl->assign('images', $paintings); if ($this->param('commented')) { $tpl->assign('commented', true); } else { $tpl->assign('commented', false); } $form = jForms::create('coment'); $form->setData('albumId', $albumId); $tpl->assign('form', $form); $vidFile = $vidsService->getVideo($picasaService->getAlbumById($albumId)->name); $tpl->assign('video', $vidFile); $rep->body->assign('MAIN', $tpl->fetch('images_html')); return $rep; }
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)); } } } } } }
/** * Main page */ public function index() { $submit = $this->param('validate'); if ($submit == jLocale::get('hfnucontact~contact.form.saveBt')) { $form = jForms::fill('hfnucontact~admincontact'); $rep = $this->getResponse('redirect'); if (!$form->check()) { $rep->action = 'hfnucontact~admin:index'; return $rep; } $HfnucontactConfig = new jIniFileModifier(jApp::configPath('defaultconfig.ini.php')); $HfnucontactConfig->setValue('email_contact', $this->param('contact'), 'hfnucontact'); $HfnucontactConfig->save(); jMessage::add(jLocale::get('hfnucontact~contact.admin.form.email.saved'), 'ok'); jForms::destroy('hfnucontact~admincontact'); $rep->action = 'hfnucontact~admin:index'; return $rep; } else { $form = jForms::create('hfnucontact~admincontact'); } $form->setData('contact', jApp::config()->hfnucontact['email_contact']); $rep = $this->getResponse('html'); $tpl = new jTpl(); $tpl->assign('form', $form); $rep->body->assign('MAIN', $tpl->fetch('hfnucontact~admincontact')); $rep->body->assign('selectedMenuItem', 'contact'); return $rep; }
protected function _prepareTpl() { $form = jForms::get('password'); if ($form == null) { $form = jForms::create('password'); } $this->_tpl->assign('form', $form); }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { $id_forum = $this->param('id_forum'); if (!$id_forum) { return; } $form = jForms::create('havefnubb~jumpto', $id_forum); $this->_tpl->assign('form', $form); }
/** * form to ask to reindex */ function index() { $rep = $this->getResponse('html'); $form = jForms::create('hfnusearch~indexing'); $tpl = new jTpl(); $tpl->assign('form', $form); $rep->body->assign('MAIN', $tpl->fetch('hfnusearch~admin.index')); $rep->body->assign('selectedMenuItem', 'searchengine'); return $rep; }
protected function _prepareTpl() { $form = jForms::get('registration'); if ($form == null) { $form = jForms::create('registration'); } jForms::destroy('confirmation'); jEvent::notify('jcommunity_registration_init_form', array('form' => $form, 'tpl' => $this->_tpl)); $this->_tpl->assign('form', $form); }
protected function _prepareTpl() { $id = $this->param('id'); $form = jForms::create('events'); $form->initFromDao('events', $id); $this->_tpl->assign('id', $id); $this->_tpl->assign('form', $form); $this->_tpl->assign('record', jDao::get('events')->get($id)); $this->_tpl->assign('editAction', 'events~events:preupdate'); $this->_tpl->assign('deleteAction', 'events~events:delete'); $this->_tpl->assign('listAction', 'events~events:index'); }
function savePage() { $form = jForms::fill("index"); $srv = new PagesService(); $page = $srv->getPageOBJ($this->param('name')); $page->text = $this->param('text'); $dao = jDao::get('pages'); $dao->update($page); $rep = $this->getResponse('redirect'); $rep->action = 'default:viewPage'; $rep->params['page'] = $this->param('name'); return $rep; }
function save() { $f = jForms::fill('base~formauth'); if (!$f->check) { $vue = $this->getResponse('redirect'); $vue->action = 'base~identity:index'; return $vue; } $vue = $this->common(); $c = jClasses::getService('UserManager'); $c->save($f); return $vue; }
function savecreate() { $form = jForms::get('files'); $form->initFromRequest(); $rep = $this->getResponse('redirect'); $form->saveAllFiles("files/"); $dao = jDao::get('files'); $record = jDao::createRecord('files'); $record->name = $form->getData('name'); $record->url = "http://www.helenekling.com/" . $this->testDir . $this->uploadsDirectory . "/" . $form->getData('file'); $dao->insert($record); $rep->action = 'files:index'; jForms::destroy($this->form); return $rep; }
/** * web service for XHR request when a control should be filled with a list * of values, depending of the value of an other control. */ public function getListData() { $rep = $this->getResponse('json', true); try { $form = jForms::get($this->param('__form'), $this->param('__formid')); if (!$form) { throw new Exception('dummy'); } } catch (Exception $e) { throw new Exception('invalid form selector'); } // check CSRF if ($form->securityLevel == jFormsBase::SECURITY_CSRF) { if ($form->getContainer()->token !== $this->param('__JFORMS_TOKEN__')) { throw new jException("jelix~formserr.invalid.token"); } } // retrieve the control to fill $control = $form->getControl($this->param('__ref')); if (!$control || !$control instanceof jFormsControlDatasource) { throw new Exception('bad control'); } if (!$control->datasource instanceof jIFormsDynamicDatasource) { throw new Exception('not supported datasource type'); } $dependentControls = $control->datasource->getCriteriaControls(); if (!$dependentControls) { throw new Exception('no dependent controls'); } foreach ($dependentControls as $ctname) { $form->setData($ctname, $this->param($ctname)); } $rep->data = array(); if ($control->datasource->hasGroupedData()) { foreach ($control->datasource->getData($form) as $k => $items) { $data = array(); foreach ($items as $k2 => $v) { $data[] = array('value' => $k2, 'label' => $v); } $rep->data[] = array('items' => $data, 'label' => $k); } } else { foreach ($control->datasource->getData($form) as $k => $v) { $rep->data[] = array('value' => $k, 'label' => $v); } } return $rep; }
function index() { $rep = $this->getResponse('html'); $tpl = new jTpl(); $form = jForms::create('search'); $tpl->assign('formulaire', $form); $vidsServ = new OnDiskVideosService(); $tpl->assign('video', $vidsServ->randomVideo()); $picasaSrv = new jPicasa(); $paintings = array(); foreach ($picasaSrv->lastImages() as $img) { $paintings[$img->name] = new Painting($img); } $tpl->assign('images', $paintings); $rep->body->assign('MAIN', $tpl->fetch('photogallery_index')); return $rep; }
function save() { $rep = $this->getResponse('redirect'); $rep->action = 'default:index'; $form = jForms::fill('config'); if (!$form) { return $rep; } if (!$form->check()) { return $rep; } $activeusers = jClasses::create('activeusers~connectedusers'); try { $activeusers->saveVisitTimeout($form->getData('timeout_visit')); jMessage::add(jLocale::get('main.config.save.ok')); } catch (Exception $e) { jMessage::add('Error: ' . $e->getMessage(), 'error'); } return $rep; }
function answer() { $resp = $this->precreate(); $this->_markAsRead(); if ($id = $this->param("id")) { // verify i'm the dest of the message i will answer $mail = jDao::get($this->dao)->get($id); if ($mail->id_for != jAuth::getUserSession()->id) { return $resp; } $form = jForms::get($this->form); if ($form == null) { $form = jForms::create($this->form); } $form->deactivate("id_for", true); $form->setData("answer_to", $mail->id_from); $resp->params['id'] = $id; $form->setData("title", "Re : " . jDao::get($this->dao)->get($id)->title); } return $resp; }
/** * 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); }
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', ''); } } }
/** * Save the data for one section. * @return Redirect to the index. */ function validateSection() { $repository = $this->param('repository'); $new = $this->intParam('new'); // Destroy the form if ($form = jForms::get('admin~config_section')) { jForms::destroy('admin~config_section'); } else { // undefined form : redirect $rep = $this->getResponse("redirect"); $rep->action = "admin~config:index"; return $rep; } // Redirect to the index $rep = $this->getResponse("redirect"); if ($new) { jMessage::add(jLocale::get("admin~admin.form.admin_section.message.configure.rights")); $rep->action = "admin~config:modifySection"; $rep->params['repository'] = $repository; } else { $rep->action = "admin~config:index"; } return $rep; }
/** * save data of a form in a new record */ function saveupdate() { $rep = $this->getResponse('redirect'); $id = $this->param('id'); $page = $this->param($this->offsetParameterName); $form = $this->_getForm($id); if ($form === null || $id === null) { $rep->action = $this->_getAction('index'); return $rep; } $form->initFromRequest(); $rep->params[$this->offsetParameterName] = $page; if ($form->check() && $this->_checkData($form, true)) { $results = $form->prepareDaoFromControls($this->dao, $id, $this->dbProfile); extract($results, EXTR_PREFIX_ALL, "form"); //use a temp variable to avoid notices $this->_beforeSaveUpdate($form, $form_daorec, $id); $form_dao->update($form_daorec); $rep->action = $this->_getAction('view'); $rep->params['id'] = $id; $this->_afterUpdate($form, $id, $rep); if ($this->uploadsDirectory !== false) { $form->saveAllFiles($this->uploadsDirectory); } jForms::destroy($this->form, $id); } else { $rep->action = $this->_getAction('editupdate'); $rep->params['id'] = $id; } return $rep; }
public function getDefaultBottomDockable() { jClasses::inc('view~lizmapMapDockItem'); $dockable = array(); $configOptions = $this->getOptions(); $bp = jApp::config()->urlengine['basePath']; if ($this->hasAttributeLayers()) { $form = jForms::create('view~attribute_layers_option'); $assign = array('form' => $form); $tpl = new jTpl(); $dockable[] = new lizmapMapDockItem('attributeLayers', jLocale::get('view~map.attributeLayers.navbar.title'), array('view~map_attributeLayers', $assign), 1, '', $bp . 'js/attributeTable.js'); } return $dockable; }
/** * activate a new password. the key should be given as a parameter */ function confirm() { $repError = $this->_check(); if ($repError) { return $repError; } $rep = $this->getResponse("redirect"); $rep->action = "password:confirmform"; if ($_SERVER['REQUEST_METHOD'] != 'POST') { return $rep; } $form = jForms::fill('confirmation'); if ($form == null) { return $rep; } if (!$form->check()) { return $rep; } $login = $form->getData('conf_login'); $user = jAuth::getUser($login); if (!$user) { $form->setErrorOn('conf_login', jLocale::get('password.form.confirm.login.doesnt.exist')); return $rep; } if ($user->status != JCOMMUNITY_STATUS_PWD_CHANGED) { jForms::destroy('confirmation'); $rep = $this->getResponse('html'); $tpl = new jTpl(); $tpl->assign('status', JCOMMUNITY_STATUS_VALID); $rep->body->assign('MAIN', $tpl->fetch('password_ok')); return $rep; } if (strcmp($user->request_date, date('Y-m-d H:i:s', time() - 48 * 60 * 60)) < 0) { jForms::destroy('confirmation'); $rep = $this->getResponse('html'); $tpl = new jTpl(); $tpl->assign('status', JCOMMUNITY_STATUS_MAIL_CHANGED); $rep->body->assign('MAIN', $tpl->fetch('password_ok')); return $rep; } if ($form->getData('conf_key') != $user->keyactivate) { $form->setErrorOn('conf_key', jLocale::get('password.form.confirm.bad.key')); return $rep; } $passwd = $form->getData('conf_password'); $user->status = JCOMMUNITY_STATUS_VALID; jAuth::updateUser($user); jAuth::changePassword($login, $passwd); jAuth::login($login, $passwd); jForms::destroy('confirmation'); $rep->action = "password:confirmok"; return $rep; }
/** * save data of a form in a new record */ function saveupdate() { $rep = $this->getResponse('redirect'); $id = $this->param('id'); $form = jForms::get($this->form, $id); $form->initFromRequest(); if ($form === null || $id === null) { $rep->action = 'master_admin~default:index'; return $rep; } $evresp = array(); if ($form->check() && !jEvent::notify('jauthdbAdminCheckUpdateForm', array('form' => $form))->inResponse('check', false, $evresp)) { extract($form->prepareDaoFromControls($this->dao, $id, $this->dbProfile), EXTR_PREFIX_ALL, "form"); // we call jAuth instead of using jDao, to allow jAuth to do // all process, events... jAuth::updateUser($form_daorec); $form->saveAllFiles($this->uploadsDirectory); $rep->action = 'user:index'; jMessage::add(jLocale::get('crud.message.update.ok', $id), 'notice'); jForms::destroy($this->form, $id); } else { $rep->action = 'user:editupdate'; } $rep->params['id'] = $id; return $rep; }
/** * Send a message to a friend */ public function send_a_message_to_friend() { $form = jForms::fill('hfnucontact~send_to_friend'); $rep = $this->getResponse('redirect'); if (!$form) { $rep = $this->getResponse('redirect'); $rep->action = 'jelix~error:403'; return $rep; } if (!$form->check()) { $rep = $this->getResponse('redirect'); $rep->action = 'jelix~error:404'; return $rep; } // the sender is not connected and use contact form to send a message // to the contact defined in hfnucontact.ini.php if (!jAuth::isConnected()) { $gJConfig = jApp::config(); $email = $gJConfig->mailer['webmasterEmail']; $login = $gJConfig->mailer['webmasterName']; } else { $email = jAuth::getUserSession()->email; $login = jAuth::getUserSession()->login; } $mail = new jMailer(); $mail->From = $email; $mail->FromName = $login; $mail->Sender = $email; $mail->Subject = $form->getData('subject'); $mail->ContentType = 'text/html'; $tpl = new jTpl(); $tpl->assign('login', $login); $tpl->assign('message', $form->getData('message')); $mail->Body = $tpl->fetch('hfnucontact~send_an_email', 'text'); $mail->AddAddress($form->getData('email_to')); $mail->Send(); jForms::destroy('hfnucontact~send_to_friend'); $rep->action = 'hfnucontact~default:contacted'; return $rep; }
/** * displays a record */ function view() { $spk = $this->param($this->spkName); $dpk = $this->param($this->dpkName); $page = $this->param($this->offsetParameterName); if ($dpk === null) { $rep = $this->getResponse('redirect'); $rep->action = $this->_getAction('index'); $rep->params[$this->spkName] = $spk; return $rep; } $rep = $this->_getResponse(); $id = $this->_getPk($spk, $dpk); // we're using a form to display a record, to have the portunity to have // labels with each values. We need also him to load easily values of some // of controls with initControlFromDao (to use in _view method). $form = jForms::create($this->form, $id); $form->initFromDao($this->dao, $id, $this->dbProfile); $tpl = new jTpl(); $tpl->assign('dpk', $dpk); $tpl->assign('dpkName', $this->dpkName); $tpl->assign('spkName', $this->spkName); $tpl->assign('spk', $spk); $tpl->assign('form', $form); $tpl->assign('page', $page); $tpl->assign('offsetParameterName', $this->offsetParameterName); $tpl->assign('editAction', $this->_getAction('preupdate')); $tpl->assign('deleteAction', $this->_getAction('delete')); $tpl->assign('listAction', $this->_getAction('index')); $this->_view($form, $rep, $tpl); $rep->body->assign($this->templateAssign, $tpl->fetch($this->viewTemplate)); return $rep; }
/** * activate an account. the key should be given as a parameter */ function confirm() { if (jAuth::isConnected()) { return $this->noaccess(); } $rep = $this->getResponse("redirect"); $rep->action = "registration:confirmform"; if ($_SERVER['REQUEST_METHOD'] != 'POST') { return $rep; } $form = jForms::fill('confirmation'); if ($form == null) { return $rep; } if (!$form->check()) { return $rep; } $login = $form->getData('conf_login'); $user = jAuth::getUser($login); if (!$user) { $form->setErrorOn('conf_login', jLocale::get('register.form.confirm.login.doesnt.exist')); return $rep; } if ($user->status != JCOMMUNITY_STATUS_NEW) { jForms::destroy('confirmation'); $rep = $this->getResponse('html'); $tpl = new jTpl(); $tpl->assign('already', true); $rep->body->assign('MAIN', $tpl->fetch('registration_ok')); return $rep; } if ($form->getData('conf_key') != $user->keyactivate) { $form->setErrorOn('conf_key', jLocale::get('register.form.confirm.bad.key')); return $rep; } $user->status = JCOMMUNITY_STATUS_VALID; jEvent::notify('jcommunity_registration_confirm', array('user' => $user)); jAuth::updateUser($user); jAuth::changePassword($login, $form->getData('conf_password')); jAuth::login($login, $form->getData('conf_password')); jForms::destroy('confirmation'); $rep->action = "registration:confirmok"; return $rep; }