private function onEdit() { $u = $this->user; $form = $this->getForm(); if (false !== ($error = $form->validate($this->module))) { return $error; } if ($form->getVar('email') !== $u->getVar('user_email')) { GWF_Hook::call(GWF_Hook::CHANGE_MAIL, $u, array($u->getVar('user_email'), $form->getVar('email'))); } if (false === $u->saveVars(array('user_countryid' => $form->getVar('country'), 'user_langid' => $form->getVar('lang1'), 'user_langid2' => $form->getVar('lang2'), 'user_gender' => $form->getVar('gender'), 'user_email' => $form->getVar('email'), 'user_level' => $form->getVar('level')))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $msgs = array_merge($this->onEditFlags('bot', $u->isBot(), GWF_User::BOT), $this->onEditFlags('showemail', $u->isOptionEnabled(GWF_User::SHOW_EMAIL), GWF_User::SHOW_EMAIL), $this->onEditFlags('adult', $u->isOptionEnabled(GWF_User::WANTS_ADULT), GWF_User::WANTS_ADULT), $this->onEditFlags('online', $u->isOptionEnabled(GWF_User::HIDE_ONLINE), GWF_User::HIDE_ONLINE), $this->onEditFlags('approved', $u->hasValidMail(), GWF_User::MAIL_APPROVED), $this->onEditDeleteFlag($u->isDeleted(), Common::getPost('deleted') !== false), $this->onEditUsername($u->getVar('user_name'), $form->getVar('username')), $this->onEditPassword($form->getVar('password'))); $msgs[] = $this->module->lang('msg_user_edited'); return GWF_HTML::messageA('Account', $msgs); }
private function onUpdate() { $form = $this->getForm(); if (false !== ($error = $form->validate($this->module))) { return $error; } $moduleid = $this->mod->getID(); $errors = $messages = array(); $vars = GWF_ModuleLoader::getModuleVars($moduleid); foreach ($vars as $row) { $key = $row['mv_key']; $mvkey = 'mv_' . $key; if ($row['mv_type'] === 'bool') { $newval = isset($_POST[$mvkey]) ? '1' : '0'; } elseif (isset($_POST[$mvkey])) { $newval = $_POST[$mvkey]; } else { $errors[] = GWF_HTML::err('ERR_MISSING_VAR', array(htmlspecialchars($mvkey))); continue; } if (false !== ($error = $this->updateVar($key, $newval, $vars, $row))) { if ($error !== '') { $errors[] = $error; } } else { $transkey = $this->mod->lang('cfg_' . $key); $messages[] = $this->module->lang('msg_update_var', array($transkey, GWF_HTML::display($newval))); } } $back = ''; $modname = $this->mod->display('module_name'); if (!empty($errors)) { $back .= GWF_HTML::error($modname, $errors); } if (!empty($messages)) { $back .= GWF_HTML::messageA($modname, $messages); } return $back; }