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; } }
function destroy() { jForms::destroy('sample'); $rep = $this->getResponse("redirect"); $rep->action = "sampleform:status"; return $rep; }
/** * 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; }
/** * */ 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; }
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); }
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; }
function testEnd() { global $gJCoord; $gJCoord->request->params = $this->savedParams; jForms::destroy('product'); }
/** * 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; }
/** * 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; }
function destroy() { jForms::destroy('sample2', $this->param('id')); $rep = $this->getResponse("redirect"); $rep->action = "forms:listform"; 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 testEnd() { global $gJCoord; $gJCoord->request->params = $this->savedParams; jForms::destroy('product'); jForms::destroy('label', array(1, 'fr')); jForms::destroy('label', array(1, 'en')); }
function save() { $user = $this->param('user'); $rep = $this->getResponse('redirect'); $rep->action = 'jcommunity~account:show'; $rep->params = array('user' => $user); if ($user == '' || !jAuth::isConnected() || jAuth::getUserSession()->login != $user) { return $rep; } $form = jForms::get('account', $user); if (!$form) { return $rep; } jEvent::notify('jcommunity_init_edit_form_account', array('login' => $user, 'form' => $form)); $form->initFromRequest(); $form->check(); $accountFact = jDao::get($this->getDaoName()); if ($accountFact->verifyNickname($user, $form->getData('nickname'))) { $form->setErrorOn('nickname', jLocale::get('account.error.dup.nickname')); } jEvent::notify('jcommunity_check_before_save_account', array('login' => $user, 'form' => $form)); if (count($form->getErrors())) { $rep->action = 'jcommunity~account:edit'; } else { extract($form->prepareDaoFromControls($this->getDaoName()), EXTR_PREFIX_ALL, "form"); jEvent::notify('jcommunity_save_account', array('login' => $user, 'form' => $form, 'factory' => $form_dao, 'record' => $form_daorec, 'to_insert' => $form_toInsert)); if ($form_toInsert) { $form_dao->insert($form_daorec); } else { $form_dao->update($form_daorec); } jForms::destroy('account', $user); } return $rep; }
function saveedit() { $id_rank = $this->param('id_rank'); $rank_name = $this->param('rank_name'); $rank_limit = $this->param('rank_limit'); $hfnutoken = (string) $this->param('hfnutoken'); //let's check if we have a valid token in our form $token = jClasses::getService("havefnubb~hfnutoken"); if ($this->param('saveBt') == jLocale::get('hfnuadmin~rank.saveBt')) { if (count($id_rank) == 0) { jMessage::add(jLocale::get('hfnuadmin~rank.unknown.rank'), 'error'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ranks:index'; return $rep; } $dao = jDao::get('havefnubb~ranks'); foreach ($id_rank as $thisId) { $record = $dao->get((int) $id_rank[$thisId]); $record->rank_name = (string) $rank_name[$id_rank[$thisId]]; $record->rank_limit = (int) $rank_limit[$id_rank[$thisId]]; if ($record->rank_name == '') { jMessage::add(jLocale::get('hfnuadmin~rank.rank.name.invalid'), 'error'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ranks:index'; return $rep; } $dao->update($record); } jForms::destroy('hfnuadmin~ranks'); jMessage::add(jLocale::get('hfnuadmin~rank.rank.modified'), 'ok'); } else { jForms::destroy('hfnuadmin~ranks'); jMessage::add(jLocale::get('hfnuadmin~rank.invalid.datas'), 'error'); } $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~ranks:index'; 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 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; }
/** * Confirm form submission and destroy form. * @return Redirect to the index. */ function validateAccount() { // Destroy the form if ($form = jForms::get('view~lizmap_user')) { jForms::destroy('view~lizmap_user'); } // Redirect to the index $rep = $this->getResponse("redirect"); $rep->action = "view~default:index"; 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 testPrepareObjectFromControls() { $f = jForms::create('product'); $ctrl = new jFormsControlcheckbox('instock'); $ctrl->label = 'En stock?'; $f->addControl($ctrl); $verif = ' <array> <array key="jelix_tests~product"> <object key="' . jForms::DEFAULT_ID . '" class="jFormsDataContainer"> <integer property="formId" value="' . jForms::DEFAULT_ID . '" /> <string property="formSelector" value="jelix_tests~product" /> <array property="data"> <string key="name" value="" /> <string key="price" value="" /> <string key="instock" value="0" /> </array> <array property="errors">array()</array> </object> </array> </array>'; $this->assertComplexIdenticalStr($_SESSION['JFORMS'], $verif); $f->setData('name', 'car'); $f->setData('price', 56598); $f->setData('instock', true); $verif = ' <array> <array key="jelix_tests~product"> <object key="' . jForms::DEFAULT_ID . '" class="jFormsDataContainer"> <integer property="formId" value="' . jForms::DEFAULT_ID . '" /> <string property="formSelector" value="jelix_tests~product" /> <array property="data"> <string key="name" value="car" /> <integer key="price" value="56598" /> <string key="instock" value="1" /> </array> <array property="errors">array()</array> </object> </array> </array>'; $this->assertComplexIdenticalStr($_SESSION['JFORMS'], $verif); $o = new UTjformsDummyObject(); $f->prepareObjectFromControls($o); $verif = '<object class="UTjformsDummyObject"> <string property="name" value="car" /> <integer property="price" value="56598" /> <boolean property="instock" value="true" /> </object>'; $this->assertComplexIdenticalStr($o, $verif); jForms::destroy('product'); }
/** * 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 = $this->_getForm($id); $form->initFromRequest(); if ($form === null || $id === null) { $rep->action = $this->_getAction('index'); return $rep; } if ($form->check() && $this->_checkData($form, true)) { extract($form->prepareDaoFromControls($this->dao, $id, $this->dbProfile), EXTR_PREFIX_ALL, "form"); $this->_beforeSaveUpdate($form, $form_daorec, $id); $form_dao->update($form_daorec); $form->saveAllFiles($this->uploadsDirectory); $rep->action = $this->_getAction('view'); $this->_afterUpdate($form, $id, $rep); jForms::destroy($this->form, $id); } else { $rep->action = $this->_getAction('editupdate'); } $rep->params['id'] = $id; return $rep; }
/** * 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; }
/** * Form validation : destroy it and display a message * * @param string $repository Lizmap Repository * @param string $project Name of the project * @param string $layerId Qgis id of the layer * @param integer $featureId Id of the feature. * @return Confirmation message that the form has been saved. */ public function validateFeature() { // Get repository, project data and do some right checking if (!$this->getEditionParameters()) { return $this->serviceAnswer(); } // Destroy the form if ($form = jForms::get('view~edition', $this->featureId)) { jForms::destroy('view~edition', $this->featureId); } else { // undefined form : redirect to error jMessage::add('An error has been raised when getting the form', 'error'); return $this->serviceAnswer(); } // Return html fragment response jMessage::add(jLocale::get('view~edition.form.data.saved'), 'success'); return $this->serviceAnswer(); }
/** * 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 saveedit() { $id_cat = $this->param('id_cat'); $cat_name = $this->param('cat_name'); $cat_order = $this->param('cat_order'); $hfnutoken = (string) $this->param('hfnutoken'); //let's check if we have a valid token in our form $token = jClasses::getService("havefnubb~hfnutoken"); $token->checkHfnuToken($hfnutoken); if ($this->param('saveBt') == jLocale::get('hfnuadmin~category.saveBt')) { if (count($id_cat) == 0) { jMessage::add(jLocale::get('hfnuadmin~category.unknown.category'), 'error'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~category:index'; return $rep; } $dao = jDao::get('havefnubb~category'); foreach ($id_cat as $thisId) { $record = $dao->get((int) $id_cat[$thisId]); $record->cat_name = (string) $cat_name[$id_cat[$thisId]]; $record->cat_order = (int) $cat_order[$id_cat[$thisId]]; if ($record->cat_name == '' or $record->cat_order == 0) { jMessage::add(jLocale::get('hfnuadmin~category.category.name.or.order.invalid'), 'error'); $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~category:index'; return $rep; } $dao->update($record); } jForms::destroy('hfnuadmin~category'); jMessage::add(jLocale::get('hfnuadmin~category.category.modified'), 'ok'); } else { jForms::destroy('hfnuadmin~category'); jMessage::add(jLocale::get('hfnuadmin~category.invalid.datas'), 'error'); } $rep = $this->getResponse('redirect'); $rep->action = 'hfnuadmin~category:index'; return $rep; }