/** * 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; }
/** * */ 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 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 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() { // récuper le formulaire // et le rempli avec les données reçues de la requête $rep = $this->getResponse("redirect"); $form = jForms::fill('sample'); if ($form->check()) { $rep->action = "sampleform:ok"; } else { $rep->action = "sampleform:show"; } 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 prepareToSave() { $tpl = new jTpl(); $rep = $this->getResponse('html'); if ($this->param('id') === null) { $form = jForms::fill('NewsLetter~news'); $dao = jDao::get('NewsLetter~newsLetter'); $r = jDao::createRecord('NewsLetter~newsLetter'); $r->date_create = date("Y-m-d"); $r->text = $form->getData('text'); $dao->insert($r); } else { $id = $this->param('id'); $dao = jDao::get('NewsLetter~newsLetter'); $r = $dao->get($this->param('id')); } $actions = array(); $emails_dao = jDao::get('emails'); $conds = jDao::createConditions(); $count = $emails_dao->countBy($conds); $email_rate = 2000; for ($i = 0; $i <= $count; $i += $email_rate) { $action = array(); $action['inf'] = $i; $action['sup'] = $i + $email_rate; $action['url'] = 'send'; $action['id'] = $r->id; $actions[] = $action; } $tpl->assign('actions', $actions); $tpl->assign('id', $r->id); $emailSrv = new EmailService(); if ($emailSrv->nbEmailsToSend($r->id) == 0) { $emailSrv->resetLogs($r->id); } $tpl->assign('n_emails', $emailSrv->nbEmailsToSend($r->id)); $tpl->assign('n_emails_sent', $emailSrv->nbEmailsSent($r->id)); $tpl->assign('servers', $emailSrv->getServers()); $tpl->assign('maxMailPerMin', $emailSrv->maxMailPerMin()); $tpl->assign('maxMailPerDay', $emailSrv->maxMailPerDay()); $rep->body->assign('MAIN', $tpl->fetch('prepare_sending')); 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 testUpdateDao() { global $gJCoord; $form = jForms::create('product', $this->id); // "fill" need an existing form $gJCoord->request->params['name'] = 'other phone'; $gJCoord->request->params['price'] = '68'; $gJCoord->request->params['tag'] = array('high tech', 'best seller'); $form = jForms::fill('product', $this->id); $id = $form->saveToDao('products'); $this->assertEqual($id, $this->id); $form->saveToDao('products'); // try to update an unchanged record $records = array(array('id' => $this->id, 'name' => 'other phone', 'price' => 68), array('id' => $this->id2, 'name' => 'computer', 'price' => 590)); $this->assertTableContainsRecords('product_test', $records); // save data of the tags control which is a container $form->saveControlToDao('tag', 'product_tags', $this->id); $records = array(array('product_id' => $this->id2, 'tag' => 'professionnal'), array('product_id' => $this->id2, 'tag' => 'promotion'), array('product_id' => $this->id, 'tag' => 'high tech'), array('product_id' => $this->id, 'tag' => 'best seller')); $this->assertTableContainsRecords('product_tags_test', $records); }
function savecreate() { $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ranks:index'; if ($this->param('validate') == jLocale::get('hfnuadmin~rank.saveBt')) { $dao = jDao::get('havefnubb~ranks'); $form = jForms::fill('hfnuadmin~ranks'); if (!$form) { jMessage::add(jLocale::get('hfnuadmin~rank.invalid.datas'), 'error'); return $rep; } if (!$form->check()) { jMessage::add(jLocale::get('hfnuadmin~rank.invalid.datas'), 'error'); return $rep; } $record = jDao::createRecord('havefnubb~ranks'); $record->rank_name = $form->getData('rank_name'); $record->rank_limit = $form->getData('rank_limit'); $dao->insert($record); jForms::destroy('hfnuadmin~ranks'); jMessage::add(jLocale::get('hfnuadmin~rank.rank.added'), 'ok'); } 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; }
/** * 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; }
/** * save the datas posted from the reply form */ function savereply() { $id_forum = (int) $this->param('id_forum'); if (jAuth::isConnected()) { if (!jAcl2::check('hfnu.posts.quote', 'forum' . $id_forum) and !jAcl2::check('hfnu.posts.reply', 'forum' . $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; } } else { if (!jAcl2::check('hfnu.posts.quote', 'forum' . $id_forum) and !jAcl2::check('hfnu.posts.quote') and !jAcl2::check('hfnu.posts.reply', 'forum' . $id_forum) and !jAcl2::check('hfnu.posts.reply')) { 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; } } $id_user = jAuth::isConnected() ? jAuth::getUserSession()->id : 0; $id_post = (int) $this->param('id_post'); $thread_id = (int) $this->param('thread_id'); $submit = $this->param('validate'); // preview ? if ($submit == jLocale::get('havefnubb~post.form.previewBt')) { if (jAuth::isConnected()) { $daoUser = jDao::get('havefnubb~member'); $user = $daoUser->getByLogin(jAuth::getUserSession()->login); } else { $user = new StdClass(); $user->member_comment = ''; } //crumbs infos $forum = jClasses::getService('havefnubb~hfnuforum')->getForum($id_forum); if (jAuth::isConnected()) { $form = jForms::fill('havefnubb~posts', $thread_id); $id_user = jAuth::getUserSession()->id; } else { $form = jForms::fill('havefnubb~posts_anonym', $thread_id); $id_user = 0; } $rep = $this->getResponse('redirect'); if (!$form or !$form->check()) { jMessage::add(jLocale::get('havefnubb~main.invalid.datas'), 'error'); $rep->action = 'default:index'; return $rep; } $form->setData('id_forum', $id_forum); $form->setData('id_user', $id_user); $form->setData('id_post', $id_post); $form->setData('thread_id', $thread_id); $form->setData('subject', $form->getData('subject')); $form->setData('message', $form->getData('message')); //set the needed parameters to the template $tpl = new jTpl(); $tpl->assign('id_post', 0); $tpl->assign('thread_id', $thread_id); $tpl->assign('id_forum', $id_forum); $tpl->assign('previewsubject', $form->getData('subject')); $tpl->assign('previewtext', $form->getData('message')); $tpl->assign('form', $form); $tpl->assign('forum', $forum); $tpl->assign('signature', $user->member_comment); $rep = $this->getResponse('html'); $rep->title = jLocale::get('havefnubb~post.form.reply.message') . ' ' . $form->getData('subject'); $tpl->assign('heading', jLocale::get('havefnubb~post.form.reply.message') . ' ' . $form->getData('subject')); $tpl->assign('reply', 1); $tpl->assign('submitAction', 'havefnubb~posts:savereply'); $rep->body->assign('MAIN', $tpl->fetch('havefnubb~posts.edit')); return $rep; } elseif ($submit == jLocale::get('havefnubb~post.form.saveBt')) { $rep = $this->getResponse('redirect'); if ($id_forum == 0) { jMessage::add(jLocale::get('havefnubb~main.invalid.datas'), 'error'); $rep->action = 'havefnubb~default:index'; return $rep; } //let's save the reply $hfnuposts = jClasses::getService('havefnubb~hfnuposts'); $record = $hfnuposts->savereply($thread_id, $id_post); if ($record === false) { jMessage::add(jLocale::get('havefnubb~main.invalid.datas'), 'error'); $record = $hfnuposts->getPost($thread_id); $forum = jDao::get('havefnubb~forum')->get($id_forum); $rep->action = 'havefnubb~posts:view'; $rep->anchor = 'p' . $record->id_post; $rep->params = array('id_forum' => $id_forum, 'ftitle' => $forum->forum_name, 'id_post' => $record->id_post, 'ptitle' => $record->subject, 'thread_id' => $record->thread_id); } else { jMessage::add(jLocale::get('havefnubb~main.common.reply.added'), 'ok'); $forum = jDao::get('havefnubb~forum')->get($id_forum); $rep->action = 'havefnubb~posts:viewtogo'; $rep->anchor = 'p' . $record->id_post; $rep->params = array('id_forum' => $id_forum, 'ftitle' => $forum->forum_name, 'id_post' => $record->id_first_msg, 'ptitle' => $hfnuposts->getPost(jDao::get('havefnubb~threads_alone')->get($record->thread_id)->id_first_msg)->subject, 'thread_id' => $record->thread_id, 'go' => $record->id_post); } return $rep; } else { jLog::log(__METHOD__ . ' line : ' . __LINE__ . ' [this button that submit the form is not the expected one] the submit button is not save nor preview', 'DEBUG'); $rep = $this->getResponse('html'); $tpl = new jTpl(); $rep->body->assign('MAIN', $tpl->fetch('havefnubb~404.html')); $rep->setHttpStatus('404', 'Not found'); return $rep; } }
function testFill() { global $gJCoord; $savedParams = $gJCoord->request->params; $form = jForms::fill('product'); $this->assertComplexIdenticalStr($form, $this->form1Descriptor); $gJCoord->request->params['name'] = 'phone'; $gJCoord->request->params['price'] = '45'; $form = jForms::fill('product'); $verif = ' <object class="cForm_jelix_tests_Jx_product"> <object method="getContainer()" class="jFormsDataContainer"> <integer property="formId" value="' . jForms::DEFAULT_ID . '" /> <string property="formSelector" value="jelix_tests~product" /> <array property="data"> <string key="name" value="phone" /> <string key="price" value="45" /> </array> <array property="errors">array()</array> </object> <array method="getAllData()"> <string key="name" value="phone" /> <string key="price" value="45" /> </array> <integer method="id()" value="' . jForms::DEFAULT_ID . '" /> <array method="getControls()"> <object key="name" class="jFormsControlInput"> <string property="ref" value="name"/> <boolean property="required" value="true"/> <boolean method="isReadOnly()" value="false"/> <string property="label" value="product name"/> <string property="defaultValue" value=""/> </object> <object key="price" class="jFormsControlInput"> <string property="ref" value="price"/> <boolean property="required" value="false"/> <boolean method="isReadOnly()" value="false"/> <string property="label" value="The price"/> <string property="defaultValue" value=""/> </object> </array> </object>'; $this->assertComplexIdenticalStr($form, $verif); // verify that the other form hasn't changed $form = jForms::get('product', 'akey'); $this->assertComplexIdenticalStr($form, $this->form2Descriptor); $form = jForms::fill('product', 'akey'); $verif = ' <object class="cForm_jelix_tests_Jx_product"> <object method="getContainer()" class="jFormsDataContainer"> <integer property="formId" value="akey" /> <string property="formSelector" value="jelix_tests~product" /> <array property="data"> <string key="name" value="phone" /> <string key="price" value="45" /> </array> <array property="errors">array()</array> </object> <array method="getAllData()"> <string key="name" value="phone" /> <string key="price" value="45" /> </array> <integer method="id()" value="akey" /> <array method="getControls()"> <object key="name" class="jFormsControlInput"> <string property="ref" value="name"/> <boolean property="required" value="true"/> <boolean method="isReadOnly()" value="false"/> <string property="label" value="product name"/> <string property="defaultValue" value=""/> </object> <object key="price" class="jFormsControlInput"> <string property="ref" value="price"/> <boolean property="required" value="false"/> <boolean method="isReadOnly()" value="false"/> <string property="label" value="The price"/> <string property="defaultValue" value=""/> </object> </array> </object>'; $gJCoord->request->params = $savedParams; }
function save() { $id = $this->param('id'); $newid = $this->param('newid'); // récupe le formulaire et le rempli avec les données reçues de la requête $form = jForms::fill('sample2', $id); if ($id != $newid) { $form2 = jForms::create('sample2', $newid); $form2->getContainer()->data = $form->getContainer()->data; } if ($id == '0') { jForms::destroy('sample2', $id); } // on pourrait ici enregistrer les données aprés un $form->check() // non implementé pour le moment... $rep = $this->getResponse("redirect"); $rep->action = "forms:listform"; return $rep; }
/** * save a notification posted by a user * @param integer $id_post id post of the current post if editing of 0 if adding * @return boolean status of success of this submit */ public function savenotify($id_post, $thread_id) { $form = jForms::fill('havefnubb~notify', $id_post); if (!$form) { return false; } //.. if the data are not ok, return to the form and display errors messages form if (!$form->check()) { return false; } jEvent::notify('HfnuPostBeforeSaveNotify', array('id' => $id_post)); $dao = jDao::get('havefnubb~notify')->getNotifByUserId($id_post, $form->getData('id_user')); if ($dao > 0) { jMessage::add(jLocale::get('havefnubb~post.notification.already.done'), 'error'); return false; } $result = $form->prepareDaoFromControls('havefnubb~notify'); $result['daorec']->thread_id = $thread_id; $result['daorec']->subject = $this->getPost(jDao::get('havefnubb~threads_alone')->get($thread_id)->id_last_msg)->subject; $result['daorec']->message = '[' . $form->getData('reason') . '] ' . $form->getData('message'); $result['daorec']->date_created = time(); $result['daorec']->date_modified = time(); $result['dao']->insert($result['daorec']); jEvent::notify('HfnuPostAfterSaveNotify', array('id' => $id_post)); jEvent::notify('HfnuSearchEngineAddContent', array('id' => $id_post, 'datasource' => 'havefnubb~posts')); jForms::destroy('havefnubb~notify', $id_post); return true; }
function saveedit() { $id_forum = (int) $this->param('id_forum'); $submit = $this->param('validate'); if ($submit == jLocale::get('hfnuadmin~forum.saveBt')) { $form = jForms::fill('hfnuadmin~forum_edit', $id_forum); if (!$form->check()) { jMessage::add(jLocale::get('hfnuadmin~forum.unknown.forum'), 'error'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~forum:edit'; $rep->params = array('id_forum' => $id_forum); return $rep; } $form->saveToDao('havefnubb~forum'); } $submitRight = $this->param('validateright'); if ($submitRight == jLocale::get('hfnuadmin~forum.saveBt')) { $hfnuadminrights = jClasses::getService("hfnuadmin~hfnuadminrights"); $rights = $this->param('rights', array()); foreach (jAcl2DbUserGroup::getGroupList() as $grp) { $id = $grp->id_aclgrp; $hfnuadminrights->setRightsOnForum($id, isset($rights[$id]) ? $rights[$id] : array(), 'forum' . $id_forum); } $hfnuadminrights->setRightsOnForum('__anonymous', isset($rights['__anonymous']) ? $rights['__anonymous'] : array(), 'forum' . $id_forum); } $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~forum:index'; return $rep; }
/** * 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; }
function saveconfig() { $resp = $this->getResponse('redirect'); $resp->action = 'hfnuadmin~default:config'; $form = jForms::fill('hfnuadmin~config'); if (!$form->check()) { return $resp; } $defaultConfig = new jIniFileModifier(jApp::configPath('defaultconfig.ini.php')); $p = jAcl2Db::getProfile(); //if we want to allow the anonymous users on the forum : if ($form->getData('anonymous_post_authorized')) { $rights = array('hfnu.forum.list' => 'on', 'hfnu.forum.view' => 'on', 'hfnu.posts.list' => 'on', 'hfnu.posts.view' => 'on', 'hfnu.posts.rss' => 'on', 'hfnu.posts.reply' => 'on', 'hfnu.posts.create' => 'on', 'hfnu.search' => 'on'); jAcl2DbManager::setRightsOnGroup('__anonymous', $rights); } else { jAcl2DbManager::setRightsOnGroup('__anonymous', array()); } $defaultConfig->setValue('title', htmlentities($this->param('title')), 'havefnubb'); $defaultConfig->setValue('description', htmlentities($form->getData('description')), 'havefnubb'); $defaultConfig->setValue('webmasterEmail', $this->param('webmaster_email'), 'mailer'); $defaultConfig->setValue('rules', str_replace('"', '', $form->getData('rules')), 'havefnubb'); $defaultConfig->setValue('admin_email', $form->getData('admin_email'), 'havefnubb'); $defaultConfig->setValue('posts_per_page', $form->getData('posts_per_page'), 'havefnubb'); $defaultConfig->setValue('replies_per_page', $form->getData('replies_per_page'), 'havefnubb'); $defaultConfig->setValue('members_per_page', $form->getData('members_per_page'), 'havefnubb'); $defaultConfig->setValue('stats_nb_of_lastpost', $form->getData('stats_nb_of_lastpost'), 'havefnubb'); $defaultConfig->setValue('post_max_size', $form->getData('post_max_size'), 'havefnubb'); $defaultConfig->setValue('avatar_max_width', $form->getData('avatar_max_width'), 'havefnubb'); $defaultConfig->setValue('avatar_max_height', $form->getData('avatar_max_height'), 'havefnubb'); $defaultConfig->setValue('important_nb_replies', $form->getData('important_nb_replies'), 'havefnubb'); $defaultConfig->setValue('important_nb_views', $form->getData('important_nb_views'), 'havefnubb'); $defaultConfig->setValue('anonymous_post_authorized', $form->getData('anonymous_post_authorized'), 'havefnubb'); $defaultConfig->setValue('twitter', $form->getData('social_network_twitter'), 'social_networks'); $defaultConfig->setValue('digg', $form->getData('social_network_digg'), 'social_networks'); $defaultConfig->setValue('delicious', $form->getData('social_network_delicious'), 'social_networks'); $defaultConfig->setValue('facebook', $form->getData('social_network_facebook'), 'social_networks'); $defaultConfig->setValue('reddit', $form->getData('social_network_reddit'), 'social_networks'); $defaultConfig->setValue('netvibes', $form->getData('social_network_netvibes'), 'social_networks'); $tz = DateTimeZone::listIdentifiers(); $defaultConfig->setValue('timeZone', $tz[$form->getData('timezone')]); $defaultConfig->save(); $floodConfig = new jIniFileModifier(jApp::configPath('havefnubb/flood.coord.ini.php')); $floodConfig->setValue('only_same_ip', $form->getData('only_same_ip')); $floodConfig->setValue('elapsed_time_between_two_post', $form->getData('elapsed_time_between_two_post')); $floodConfig->save(); jForms::destroy('hfnuadmin~config'); jMessage::add(jLocale::get('hfnuadmin~config.config.modified'), 'ok'); return $resp; }
/** * 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 the censored message */ public function savecensor() { if (!jAcl2::check('hfnu.admin.post')) { 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; } $rep = $this->getResponse('redirect'); $id_post = (int) $this->param('id_post'); $thread_id = (int) $this->param('thread_id'); if ($id_post < 1 or $thread_id < 0) { jMessage::add(jLocale::get('havefnubb~main.invalid.datas'), 'error'); $rep->action = 'havefnubb~default:index'; return $rep; } $form = jForms::fill('havefnubb~censor', $id_post); if (!$form) { jMessage::add(jLocale::get('havefnubb~main.invalid.datas'), 'error'); $rep->action = 'havefnubb~postsmgr:censor'; $rep->params = array('id_post' => $id_post, 'thread_id' => $thread_id); return $rep; } if (!$form->check()) { jMessage::add(jLocale::get('havefnubb~main.invalid.datas'), 'error'); $rep->action = 'havefnubb~postsmgr:censor'; $rep->params = array('id_post' => $id_post, 'thread_id' => $thread_id); return $rep; } //censoring an entire thread $result = jClasses::getService('havefnubb~hfnuposts')->censor($thread_id, $id_post, $form->getData('censored_msg')); if ($result === false) { jMessage::add(jLocale::get('havefnubb~main.invalid.datas'), 'error'); $rep->action = 'havefnubb~default:index'; return $rep; } else { $post = $result; jMessage::add(jLocale::get('havefnubb~post.status.censored'), 'ok'); $rep->action = 'havefnubb~posts:viewtogo'; $rep->params = array('id_post' => $post->id_post, 'thread_id' => $thread_id, 'id_forum' => $post->id_forum, 'ftitle' => $post->forum_name, 'ptitle' => $post->subject, 'go' => $post->id_post); return $rep; } }
/** * save data of a form in a new record */ function saveupdate() { $spk = $this->param($this->spkName); $dpk = $this->param($this->dpkName); $page = $this->param($this->offsetParameterName); $rep = $this->getResponse('redirect'); $rep->params[$this->spkName] = $spk; $id = $this->_getPk($spk, $dpk); $form = jForms::fill($this->form, $id); if ($form === null || $dpk === null) { $rep->action = $this->_getAction('index'); return $rep; } $rep->params[$this->dpkName] = $dpk; $rep->params[$this->offsetParameterName] = $page; if ($form->check() && $this->_checkData($spk, $form, true)) { $results = $form->prepareDaoFromControls($this->dao, $id, $this->dbProfile); extract($results, EXTR_PREFIX_ALL, "form"); $this->_beforeSaveUpdate($form, $form_daorec, $id); $form_dao->update($form_daorec); $rep->action = $this->_getAction('view'); $this->_afterUpdate($form, $id, $rep); if ($this->uploadsDirectory !== false) { $form->saveAllFiles($this->uploadsDirectory); } jForms::destroy($this->form, $id); } else { $rep->action = $this->_getAction('editupdate'); } return $rep; }
function saveban() { $username = $this->param('ban_username'); $ip = $this->param('ban_ip'); $mail = $this->param('ban_email'); $expire = $this->param('ban_expire'); $message = $this->param('ban_message'); if ($username == '' and $ip == '' and $mail == '' and $expire['day'] == '' and $expire['month'] == '' and $expire['year'] == '' and $message == '') { jMessage::add(jLocale::get('hfnuadmin~ban.you.have.to.fill.one.field.at.least'), 'error'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ban:index'; return $rep; } $submit = $this->param('validate'); if ($submit == jLocale::get('hfnuadmin~ban.saveBt')) { if ($ip != '' and jClasses::getService('havefnubb~bans')->checkIp($ip) === false) { $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ban:index'; return $rep; } if ($mail != '') { $validMail = false; // ban one given domain if (preg_match('/^[a-z0-9]+\\.[a-z]{2,4}$/', $mail)) { $validMail = true; } else { // ban one member email $validMail = jFilter::isEmail($mail); } if ($validMail === false) { jMessage::add(jLocale::get('hfnuadmin~ban.mail.invalid') . ' ' . $mail, 'warning'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ban:index'; return $rep; } } if (!empty($expire)) { $expire['hour'] = 0; $expire['minute'] = 0; $expire['second'] = 0; $expire['day'] = (int) $expire['day']; $expire['month'] = (int) $expire['month']; $expire['year'] = (int) $expire['year']; $now = 0; // we made a permanent ban ! if ($expire['day'] == 0 and $expire['month'] == 0 and $expire['year'] == 0) { $expiry = 0; } else { $now = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $expiry = mktime($expire['hour'], $expire['minute'], $expire['second'], $expire['month'], $expire['day'], $expire['year']); } if ($expiry <= $now and $expiry > 0) { jMessage::add(jLocale::get('hfnuadmin~ban.expiry.invalid'), 'warning'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ban:index'; return $rep; } } $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ban:index'; $dao = jDao::get('havefnubb~bans'); $form = jForms::fill('hfnuadmin~bans'); if (!$form) { jMessage::add(jLocale::get('hfnuadmin~ban.invalid.datas'), 'error'); return $rep; } if (!$form->check()) { jMessage::add(jLocale::get('hfnuadmin~ban.invalid.datas'), 'error'); return $rep; } $form->setData('ban_expire', $expiry); $form->saveToDao('havefnubb~bans'); jMessage::add(jLocale::get('hfnuadmin~ban.added'), 'ok'); return $rep; } }