/** * @abstract Displays and processes the edit news form * @param integer $id * @access public */ public function edit($id = false) { if (!files()->setUploadDirectory()) { sml()->say("The file upload directory does not appear to be writable. Please create the folder and set proper permissions."); } $form = new Form('news', $id); if (!$id) { $form->setCurrentValue('timestamp', date("Y-m-d H:i:s")); } // if form has been submitted if ($form->isSubmitted()) { $file = files()->upload('pdf_filename'); if (is_array($file) && !empty($file[0])) { $form->setCurrentValue('pdf_filename', $file[0]['file_name']); } if ($form->save($id)) { sml()->say('News entry has successfully been updated.'); router()->redirect('view'); } } // make sure the template has access to all current values $data['form'] = $form; template()->addCss('admin/datepicker.css'); template()->addJs('admin/datepicker.js'); template()->addJs('edit.js'); template()->display($data); }
public function index() { $user = System::getUser(); $form = new Form('form-profile'); $form->setAttribute('data-noajax', 'true'); $form->binding = $user; $fieldset = new Fieldset(System::getLanguage()->_('General')); $firstname = new Text('firstname', System::getLanguage()->_('Firstname')); $firstname->binding = new Databinding('firstname'); $lastname = new Text('lastname', System::getLanguage()->_('Lastname')); $lastname->binding = new Databinding('lastname'); $email = new Text('email', System::getLanguage()->_('EMail'), true); $email->binding = new Databinding('email'); $email->blacklist = $this->getListOfMailAdresses($user); $email->error_msg[4] = System::getLanguage()->_('ErrorMailAdressAlreadyExists'); $language = new Radiobox('lang', System::getLanguage()->_('Language'), L10N::getLanguages()); $language->binding = new Databinding('lang'); $fieldset->addElements($firstname, $lastname, $email, $language); $form->addElements($fieldset); $fieldset = new Fieldset(System::getLanguage()->_('Password')); $password = new Password('password', System::getLanguage()->_('Password')); $password->minlength = PASSWORD_MIN_LENGTH; $password->binding = new Databinding('password'); $password2 = new Password('password2', System::getLanguage()->_('ReenterPassword')); $fieldset->addElements($password, $password2); $form->addElements($fieldset); $fieldset = new Fieldset(System::getLanguage()->_('Settings')); $quota = new Text('quota', System::getLanguage()->_('Quota')); if ($user->quota > 0) { $quota->value = System::getLanguage()->_('QuotaAvailabe', Utils::formatBytes($user->getFreeSpace()), Utils::formatBytes($user->quota)); } else { $quota->value = System::getLanguage()->_('Unlimited'); } $quota->readonly = true; $fieldset->addElements($quota); $form->addElements($fieldset); if (Utils::getPOST('submit', false) !== false) { if (!empty($password->value) && $password->value != $password2->value) { $password2->error = System::getLanguage()->_('ErrorInvalidPasswords'); } else { if ($form->validate()) { $form->save(); System::getUser()->save(); System::getSession()->setData('successMsg', System::getLanguage()->_('ProfileUpdated')); System::forwardToRoute(Router::getInstance()->build('ProfileController', 'index')); exit; } } } else { $form->fill(); } $form->setSubmit(new Button(System::getLanguage()->_('Save'), 'floppy-disk')); $smarty = new Template(); $smarty->assign('title', System::getLanguage()->_('MyProfile')); $smarty->assign('heading', System::getLanguage()->_('MyProfile')); $smarty->assign('form', $form->__toString()); $smarty->display('form.tpl'); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Form(); if (isset($_POST['Form'])) { $model->attributes = $_POST['Form']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Создает новую модель Тарифа. * Если создание прошло успешно - перенаправляет на просмотр. * * @return void */ public function actionCreate() { $model = new Form(); if (Yii::app()->getRequest()->getPost('Form') !== null) { $model->setAttributes(Yii::app()->getRequest()->getPost('Form')); if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('ListnerModule.listner', 'Запись добавлена!')); $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id])); } } $this->render('create', ['model' => $model]); }
/** * Displays and processes the add/edit user form * @access public * @param integer $id */ public function edit($id = false) { $result = false; $form = new Form('users', $id, array('groups')); $form->addField('password_confirm'); // process the form if submitted if ($form->isSubmitted()) { $result = $form->save($id); } template()->set(array('form' => $form)); return $result; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Form(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Form'])) { $model->attributes = $_POST['Form']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id_form)); } } $this->render('create', array('model' => $model)); }
/** * @abstract Displays and processes the edit news form * @param integer $id * @access public */ public function edit($id = false) { $form = new Form('forms', $id); if ($form->isSubmitted()) { if ($form->save($id)) { sml()->say('Form has been updated successfully.'); router()->redirect('view'); } } $data['form'] = $form; template()->addJs('edit.js'); template()->display($data); }
public function postEdit($p) { if ($_POST['submitAction'] == 'Save') { Form::save(); // $request = isset($p[1]) && $p[1] ? new Request($p[1]) : new Request(); // $request->setFields(array_merge($_POST['_record'], array('owner_id' => $this->loggedInUser->id))); // $request->save(); } else { if ($_POST['submitAction'] == 'Delete') { assert(isset($p[1]) && $p[1]); $request = new Request($p[1]); $request->destroy(); } } $this->redirect('list'); }
public function postResetPassword($p, $z) { Form::set('Person', function ($person) { $person->password = Person::hashPassword($person->password); }); $objects = Form::save(); $person = current($objects); assert($person instanceof Person); $person->login(); $message = new GuiMessage(); $message->setFrom('*****@*****.**', 'The System'); $message->addTo($person->username); $message->setSubject("{$person->firstname}, your password has been reset"); $message->assign('person', $person); $message->send('messages/confirmPasswordReset.tpl'); BaseRedirect('install/list'); }
/** * Создает новую модель Формы обучения. * Если создание прошло успешно - перенаправляет на просмотр. * * @return void */ public function actionCreate() { $roles = ['1', '5', '3']; $role = \Yii::app()->user->role; if (array_intersect($role, $roles)) { $model = new Form(); if (Yii::app()->getRequest()->getPost('Form') !== null) { $model->setAttributes(Yii::app()->getRequest()->getPost('Form')); if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('ListnerModule.listner', 'Запись добавлена!')); $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id])); } } $this->render('create', ['model' => $model]); } else { throw new CHttpException(403, 'Ошибка прав доступа.'); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionNew() { $model = new Form(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Form'])) { $model->attributes = $_POST['Form']; $model->TABLE_NAME = str_replace(' ', '_', $model->FORM_NAME); $model->TABLE_NAME = strtoupper($model->TABLE_NAME); if (!Yii::app()->db->schema->getTable($model->TABLE_NAME)) { if ($model->save()) { Yii::app()->db->createCommand()->createTable($model->TABLE_NAME, array('ID' => 'pk', 'FORM_ID' => 'INT(10)', 'CREATED_BY' => 'VARCHAR(255)', 'LAST_MODIFIED_BY' => 'VARCHAR(255)', 'CREATED_DATE' => 'TIMESTAMP NOT NULL DEFAULT "0000-00-00 00:00:00"', 'LAST_MODIFIED_DATE' => 'TIMESTAMP NOT NULL DEFAULT "0000-00-00 00:00:00" ON UPDATE CURRENT_TIMESTAMP')); $this->redirect(array('fields/index', 'form' => $model->FORM_ID)); } } else { $model->addError('TABLE_NAME', 'Table "' . $model->TABLE_NAME . '" already used. Pick a new table name.'); } } $this->render('new', array('model' => $model)); }
/** * @abstract Add a new page * @access public */ public function add() { $form = new Form('pages'); // process the form if submitted if ($form->isSubmitted()) { $form->setCurrentValue('page_sort_order', $model->quickValue('SELECT MAX(page_sort_order) FROM pages', 'MAX(page_sort_order)') + 1); // form field validation if (!$form->isFilled('page_title')) { $form->addError('page_title', 'You must enter a page title.'); } // if we have no errors, save the record if (!$form->error()) { // set the link text field to the page title if blank if (!$form->isFilled('page_link_text')) { $form->setCurrentValue('page_link_text', $form->cv('page_title')); } return $form->save(); } } return false; }
/** * @abstract Edits an event recprd * @param integer $id * @access public */ public function edit($id = false) { $form = new Form('courses', $id); // grab existing groups settings $model = model()->open('course_groups_link'); $model->where('course_id', $id); $group_records = $model->results(); $groups = array(); if ($group_records) { foreach ($group_records as $course_record) { $groups[] = $course_record['group_id']; } } $form->addField('groups', $groups, $groups); // proces the form if submitted if ($form->isSubmitted()) { // validation if (!$form->isFilled('title')) { $form->addError('title', 'You must enter a course title.'); } // if we have no errors, process sql if (!$form->error()) { if ($res_id = $form->save($id)) { $id = $id ? $id : $res_id; // update course groups $model->delete('course_groups_link', $id, 'course_id'); $groups = $form->cv('groups'); foreach ($groups as $group) { $sql = sprintf('INSERT INTO course_groups_link (course_id, group_id) VALUES ("%s", "%s")', $id, $group); $model->query($sql); } // if successful insert, redirect to the list sml()->say('The course has successfully been saved.'); router()->redirect('view'); } } } $data['form'] = $form; template()->addView(template()->getTemplateDir() . DS . 'header.tpl.php'); template()->addView(template()->getModuleTemplateDir() . DS . 'edit.tpl.php'); template()->addView(template()->getTemplateDir() . DS . 'footer.tpl.php'); template()->display($data); }
/** * @abstract Edits an event recprd * @param integer $id * @access public */ public function edit($id = false) { template()->addJs('edit.js'); $form = new Form('contacts', $id, array('contact_languages', 'contact_groups', 'contact_specialties')); // proces the form if submitted if ($form->isSubmitted()) { if ($res_id = $form->save($id)) { $id = $id ? $id : $res_id; // upload file app()->setConfig('upload_server_path', APPLICATION_PATH . DS . 'files' . DS . 'contacts' . DS . $id); app()->setConfig('enable_uploads', true); // enable uploads $uploads = files()->upload('file_path'); // small thumb $thm_width = app()->config('contact_image_thm_maxwidth'); $thm_height = app()->config('contact_image_thm_maxheight'); // resized original $orig_width = app()->config('contact_image_maxwidth'); $orig_height = app()->config('contact_image_maxheight'); if (is_array($uploads) && !empty($uploads[0])) { foreach ($uploads as $file) { // delete previous images $model = model()->open('contact_images'); $model->where('contact_id', $id); $images = $model->results(); if (is_array($images)) { foreach ($images as $image) { $base = APPLICATION_PATH . DS . 'files' . DS . 'contacts' . DS . $image['contact_id']; files()->delete($base . DS . $image['filename_orig']); files()->delete($base . DS . $image['filename_thumb']); $model->delete('contact_images', $image['id']); } } // get new thumb file name, new path $thm_name = str_replace($file['file_extension'], '_thm' . $file['file_extension'], $file['file_name']); $thm_path = str_replace($file['file_name'], $thm_name, $file['server_file_path']); // get new file name, new path $orig_name = str_replace($file['file_extension'], '_orig' . $file['file_extension'], $file['file_name']); $orig_path = str_replace($file['file_name'], $orig_name, $file['server_file_path']); // load original in thumbnail $thm_create = new Thumbnail($file['server_file_path']); $thm_create->adaptiveResize($thm_width, $thm_height); $thm_create->save($thm_path); $orig_create = new Thumbnail($file['server_file_path']); $orig_create->adaptiveResize($orig_width, $orig_height); $orig_create->save($orig_path); // store image and thumb info to database model()->open('contact_images')->insert(array('contact_id' => $id, 'filename_orig' => $orig_name, 'filename_thumb' => $thm_name, 'width_orig' => $orig_width, 'height_orig' => $orig_height, 'width_thumb' => $thm_width, 'height_thumb' => $thm_height)); } } sml()->say('Contact changes have been saved successfully.'); router()->redirect('view'); } } $data['form'] = $form; // get images if ($id) { $model = model()->open('contact_images'); $model->where('contact_id', $id); $data['images'] = $model->results(); } else { $data['images'] = false; } template()->display($data); }
function parseForms($intElmntId, $strCommand) { global $_PATHS, $objLang, $_CONF, $_CLEAN_POST, $objLiveUser; $objTpl = new HTML_Template_IT($_PATHS['templates']); switch ($strCommand) { case CMD_LIST: $objTpl->loadTemplatefile("multiview.tpl.htm"); $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsForms", "menu")); $objForm = Form::selectByPK($intElmntId); if (empty($intElmntId)) { $strFormName = "Website"; } else { if (is_object($objForm)) { $strFormName = $objForm->getName(); } else { $strFormName = ""; } } if (is_object($objForm)) { $objFields = $objForm->getFields(); if (is_object($objFields)) { //*** Initiate field loop. $listCount = 0; $intPosition = request("pos"); $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0; $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"]; $objFields->seek($intPosition); //*** Loop through the fields. foreach ($objFields as $objField) { $objFieldType = TemplateFieldType::selectByPK($objField->getTypeId()); $strMeta = "Aangepast door " . $objField->getUsername() . ", " . Date::fromMysql($objLang->get("datefmt"), $objField->getModified()); $objTpl->setCurrentBlock("multiview-item"); $objTpl->setVariable("BUTTON_DUPLICATE", $objLang->get("duplicate", "button")); $objTpl->setVariable("BUTTON_DUPLICATE_HREF", "javascript:PTemplateField.duplicate({$objField->getId()});"); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("delete", "button")); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:PTemplateField.remove({$objField->getId()});"); $objTpl->setVariable("MULTIITEM_VALUE", $objField->getId()); $objTpl->setVariable("MULTIITEM_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$objField->getId()}&cmd=" . CMD_EDIT_FIELD); $strValue = htmlspecialchars($objField->getName()); $strShortValue = getShortValue($strValue, 50); $intSize = strlen($strValue); $objTpl->setVariable("MULTIITEM_NAME", $intSize > 50 ? $strShortValue : $strValue); $objTpl->setVariable("MULTIITEM_TITLE", $intSize > 50 ? $strValue : ""); $objTpl->setVariable("MULTIITEM_TYPE", ", " . $objFieldType->getName()); $objTpl->setVariable("MULTIITEM_TYPE_CLASS", "field"); $objTpl->setVariable("MULTIITEM_META", $strMeta); $objTpl->parseCurrentBlock(); $listCount++; if ($listCount >= $_SESSION["listCount"]) { break; } } //*** Render page navigation. $pageCount = ceil($objFields->count() / $_SESSION["listCount"]); if ($pageCount > 0) { $currentPage = ceil(($intPosition + 1) / $_SESSION["listCount"]); $previousPos = $intPosition - $_SESSION["listCount"] > 0 ? $intPosition - $_SESSION["listCount"] : 0; $nextPos = $intPosition + $_SESSION["listCount"] < $objFields->count() ? $intPosition + $_SESSION["listCount"] : $intPosition; $objTpl->setVariable("PAGENAV_PAGE", sprintf($objLang->get("pageNavigation", "label"), $currentPage, $pageCount)); $objTpl->setVariable("PAGENAV_PREVIOUS", $objLang->get("previous", "button")); $objTpl->setVariable("PAGENAV_PREVIOUS_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&pos={$previousPos}"); $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button")); $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&pos={$nextPos}"); //*** Top page navigation. for ($intCount = 0; $intCount < $pageCount; $intCount++) { $objTpl->setCurrentBlock("multiview-pagenavitem-top"); $position = $intCount * $_SESSION["listCount"]; if ($intCount != $intPosition / $_SESSION["listCount"]) { $objTpl->setVariable("PAGENAV_HREF", "href=\"?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } //*** Top page navigation. for ($intCount = 0; $intCount < $pageCount; $intCount++) { $objTpl->setCurrentBlock("multiview-pagenavitem-bottom"); $position = $intCount * $_SESSION["listCount"]; if ($intCount != $intPosition / $_SESSION["listCount"]) { $objTpl->setVariable("PAGENAV_HREF", "href=\"?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&pos={$position}\""); } $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1); $objTpl->parseCurrentBlock(); } } } } //*** Render list action pulldown. $arrActions[$objLang->get("choose", "button")] = 0; $arrActions[$objLang->get("delete", "button")] = "delete"; $arrActions[$objLang->get("duplicate", "button")] = "duplicate"; foreach ($arrActions as $key => $value) { $objTpl->setCurrentBlock("multiview-listactionitem"); $objTpl->setVariable("LIST_ACTION_TEXT", $key); $objTpl->setVariable("LIST_ACTION_VALUE", $value); $objTpl->parseCurrentBlock(); } //*** Render the rest of the page. $objTpl->setCurrentBlock("multiview"); $objTpl->setVariable("ACTIONS_OPEN", $objLang->get("pcmsOpenActionsMenu", "menu")); $objTpl->setVariable("ACTIONS_CLOSE", $objLang->get("pcmsCloseActionsMenu", "menu")); $objTpl->setVariable("LIST_LENGTH_HREF_10", "href=\"?list=10&cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_25", "href=\"?list=25&cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}\""); $objTpl->setVariable("LIST_LENGTH_HREF_100", "href=\"?list=100&cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}\""); switch ($_SESSION["listCount"]) { case 10: $objTpl->setVariable("LIST_LENGTH_HREF_10", ""); break; case 25: $objTpl->setVariable("LIST_LENGTH_HREF_25", ""); break; case 100: $objTpl->setVariable("LIST_LENGTH_HREF_100", ""); break; } $objTpl->setVariable("LIST_LENGTH_HREF", "&cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}"); $objTpl->setVariable("LIST_WITH_SELECTED", $objLang->get("withSelected", "label")); $objTpl->setVariable("LIST_ACTION_ONCHANGE", "PTemplateField.multiDo(this, this[this.selectedIndex].value)"); $objTpl->setVariable("LIST_ITEMS_PER_PAGE", $objLang->get("itemsPerPage", "label")); $objTpl->setVariable("BUTTON_LIST_SELECT", $objLang->get("selectAll", "button")); $objTpl->setVariable("BUTTON_LIST_SELECT_HREF", "javascript:PTemplateField.multiSelect()"); if (is_object($objForm)) { $objTpl->setVariable("BUTTON_EDIT", $objLang->get("edit", "button")); $objTpl->setVariable("BUTTON_EDIT_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_EDIT); $objTpl->setVariable("BUTTON_NEWFIELD", $objLang->get("newField", "button")); $objTpl->setVariable("BUTTON_NEWFIELD_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_ADD_FIELD); $objTpl->setVariable("BUTTON_REMOVE", $objLang->get("removeForm", "button")); $objTpl->setVariable("BUTTON_REMOVE_HREF", "javascript:Form.remove({$intElmntId});"); } else { $objTpl->setVariable("BUTTON_NEWSUBJECT", $objLang->get("newForm", "button")); $objTpl->setVariable("BUTTON_NEWSUBJECT_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_ADD); } $objTpl->setVariable("LABEL_SUBJECT", $objLang->get("fieldsFor", "label") . " "); $objTpl->setVariable("SUBJECT_NAME", $strFormName); $objTpl->parseCurrentBlock(); break; case CMD_REMOVE: $objForm = Form::selectByPK($intElmntId); $intParent = $objForm->getParentId(); $objForm->delete(); header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; break; case CMD_REMOVE_FIELD: if (strpos($intElmntId, ',') !== false) { //*** Multiple elements submitted. $arrFields = explode(',', $intElmntId); $objFields = TemplateField::selectByPK($arrFields); $intParent = $objFields->current()->getFormId(); foreach ($objFields as $objField) { $objField->delete(); } } else { //*** Single element submitted. $objField = TemplateField::selectByPK($intElmntId); $intParent = $objField->getFormId(); $objField->delete(); } header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; break; case CMD_DUPLICATE_FIELD: if (strpos($intElmntId, ',') !== false) { //*** Multiple elements submitted. $arrFields = explode(',', $intElmntId); $objFields = TemplateField::selectByPK($arrFields); $intParent = $objFields->current()->getFormId(); foreach ($objFields as $objField) { $objField->setUsername($objLiveUser->getProperty("name")); $objField->duplicate($objLang->get("copyOf", "label")); } } else { //*** Single element submitted. $objField = TemplateField::selectByPK($intElmntId); $intParent = $objField->getFormId(); $objField->setUsername($objLiveUser->getProperty("name")); $objField->duplicate($objLang->get("copyOf", "label")); } header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent); exit; break; case CMD_ADD: case CMD_EDIT: $objTpl->loadTemplatefile("forms.tpl.htm"); $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsForms", "menu")); //*** Post the template form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "addForm") { //*** The template form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_name"])) { $objTpl->setVariable("ERROR_NAME_ON", " error"); $objTpl->setVariable("ERROR_NAME", $objLang->get("formName", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_apiname"])) { $objTpl->setVariable("ERROR_APINAME_ON", " error"); $objTpl->setVariable("ERROR_APINAME", $objLang->get("commonTypeWord", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_description"])) { $objTpl->setVariable("ERROR_NOTES_ON", " error"); $objTpl->setVariable("ERROR_NOTES", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_NAME", "formForm"); $objTpl->setVariable("FORM_ISPAGE_VALUE", isset($_POST["frm_ispage"]) && $_POST["frm_ispage"] == "on" ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_APINAME_VALUE", $_POST["frm_apiname"]); $objTpl->setVariable("FORM_NOTES_VALUE", $_POST["frm_description"]); $objTpl->setVariable("ERROR_MAIN", $objLang->get("main", "formerror")); } else { //*** Input is valid. Save the form. if ($strCommand == CMD_EDIT) { $objForm = Form::selectByPK($intElmntId); } else { $objForm = new Form(); $objForm->setAccountId($_CONF['app']['account']->getId()); } $objForm->setName($_CLEAN_POST["frm_name"]); $objForm->setApiName($_CLEAN_POST["frm_apiname"]); $objForm->setDescription($_CLEAN_POST["frm_description"]); $objForm->save(); header("Location: " . Request::getURI() . "/?cid=" . $_POST["cid"] . "&cmd=" . CMD_LIST . "&eid=" . $objForm->getId()); exit; } } else { $objTpl->setVariable("FORM_NAME", "formForm"); } //*** Parse the form. $objForm = Form::selectByPK($intElmntId); $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("formDetails", "label")); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("formadd"); //*** Insert values if action is edit. if ($strCommand == CMD_EDIT) { $objTpl->setVariable("FORM_ISPAGE_VALUE", $objForm->getIsPage() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_ISCONTAINER_VALUE", $objForm->getIsContainer() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $objForm->getName()); $objTpl->setVariable("FORM_APINAME_VALUE", $objForm->getApiname()); $objTpl->setVariable("FORM_NOTES_VALUE", $objForm->getDescription()); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$objForm->getParentId()}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$objForm->getParentId()}&cmd=" . CMD_LIST); } else { $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_LIST); } $objTpl->setVariable("LABEL_REQUIRED", $objLang->get("requiredFields", "form")); $objTpl->setVariable("LABEL_PAGECONTAINER", $objLang->get("pageContainer", "form")); $objTpl->setVariable("LABEL_CONTAINER", $objLang->get("container", "form")); $objTpl->setVariable("LABEL_FORMNAME", $objLang->get("formName", "form")); $objTpl->setVariable("LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("APINAME_NOTE", $objLang->get("apiNameNote", "tip")); $objTpl->setVariable("LABEL_NOTES", $objLang->get("notes", "form")); $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("singleview"); $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button")); $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button")); $objTpl->setVariable("CID", NAV_PCMS_FORMS); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); break; case CMD_ADD_FIELD: case CMD_EDIT_FIELD: $objTpl->loadTemplatefile("templatefield.tpl.htm"); $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsForms", "menu")); //*** Post the templateField form if submitted. if (count($_CLEAN_POST) > 0 && !empty($_CLEAN_POST['dispatch']) && $_CLEAN_POST['dispatch'] == "addTemplateField") { //*** The template form has been posted. $blnError = false; //*** Check sanitized input. if (is_null($_CLEAN_POST["frm_required"])) { $objTpl->setVariable("ERROR_REQUIRED_ON", " error"); $objTpl->setVariable("ERROR_REQUIRED", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_name"])) { $objTpl->setVariable("ERROR_NAME_ON", " error"); $objTpl->setVariable("ERROR_NAME", $objLang->get("fieldName", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_apiname"])) { $objTpl->setVariable("ERROR_APINAME_ON", " error"); $objTpl->setVariable("ERROR_APINAME", $objLang->get("commonTypeWord", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_description"])) { $objTpl->setVariable("ERROR_NOTES_ON", " error"); $objTpl->setVariable("ERROR_NOTES", $objLang->get("commonTypeText", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["frm_field_type"])) { $objTpl->setVariable("ERROR_FIELDTYPE_ON", " error"); $objTpl->setVariable("ERROR_FIELDTYPE", $objLang->get("fieldType", "formerror")); $blnError = true; } if (is_null($_CLEAN_POST["dispatch"])) { $blnError = true; } if ($blnError === true) { //*** Display global error. $objTpl->setVariable("FORM_NAME", "templateFieldForm"); $objTpl->setVariable("FORM_REQUIRED_VALUE", isset($_POST["frm_required"]) && $_POST["frm_required"] == "on" ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $_POST["frm_name"]); $objTpl->setVariable("FORM_APINAME_VALUE", $_POST["frm_apiname"]); $objTpl->setVariable("FORM_NOTES_VALUE", $_POST["frm_description"]); $objTpl->setVariable("ERROR_MAIN", $objLang->get("main", "formerror")); } else { //*** Input is valid. Save the template. if ($strCommand == CMD_EDIT_FIELD) { $objField = TemplateField::selectByPK($intElmntId); } else { $objField = new TemplateField(); $objField->setFormId($_POST["eid"]); } $objField->setRequired(empty($_CLEAN_POST["frm_required"]) ? 0 : 1); $objField->setName($_CLEAN_POST["frm_name"]); $objField->setApiName($_CLEAN_POST["frm_apiname"]); $objField->setDescription($_CLEAN_POST["frm_description"]); $objField->setTypeId($_CLEAN_POST["frm_field_type"]); $objField->setUsername($objLiveUser->getProperty("name")); $objField->save(); $objField->clearValues(); //*** Add type values to the field. foreach ($_REQUEST as $key => $value) { if ($value != "" && substr($key, 0, 4) == "tfv_") { $objValue = new TemplateFieldValue(); $objValue->setName($key); $objValue->setValue($value); $objValue->setFieldId($objField->getId()); $objValue->save(); } } header("Location: " . Request::getURI() . "/?cid=" . $_POST["cid"] . "&cmd=" . CMD_LIST . "&eid=" . $objField->getFormId()); exit; } } else { $objTpl->setVariable("FORM_NAME", "templateFieldForm"); } $objTpl->setCurrentBlock("headertitel_simple"); $objTpl->setVariable("HEADER_TITLE", $objLang->get("templateFieldDetails", "label")); $objTpl->parseCurrentBlock(); $typeValue = 0; if ($strCommand == CMD_EDIT_FIELD) { $objField = TemplateField::selectByPK($intElmntId); $typeValue = $objField->getTypeId(); } $objTypes = TemplateFieldTypes::getTypes(); if (is_object($objTypes)) { foreach ($objTypes as $objType) { $objTpl->setCurrentBlock("list_fieldtype"); if ($typeValue == $objType->getId()) { $objTpl->setVariable("FIELDTYPE_SELECTED", "selected=\"selected\""); } $objTpl->setVariable("FIELDTYPE_VALUE", $objType->getId()); $objTpl->setVariable("FIELDTYPE_TEXT", $objType->getName()); $objTpl->parseCurrentBlock(); } } $objTpl->setCurrentBlock("templatefieldadd"); $objTpl->setVariable("LABEL_REQUIRED", $objLang->get("requiredFields", "form")); $objTpl->setVariable("LABEL_REQUIREDFIELD", $objLang->get("requiredField", "form")); $objTpl->setVariable("LABEL_FIELDNAME", $objLang->get("fieldName", "form")); $objTpl->setVariable("LABEL_NAME", $objLang->get("name", "form")); $objTpl->setVariable("APINAME_NOTE", $objLang->get("apiNameNote", "tip")); $objTpl->setVariable("LABEL_NOTES", $objLang->get("notes", "form")); $objTpl->setVariable("LABEL_FIELDTYPE", $objLang->get("fieldType", "form")); $objTpl->setVariable("LABEL_FIELDTYPE_OPTIONS", $objLang->get("typeOptions", "label")); $objTpl->setVariable("TFV_LIST_NOTES", $objLang->get("templateListType", "tip")); $objTpl->setVariable("TFV_FORMAT_NOTES", $objLang->get("templateDateType", "tip")); $objTpl->setVariable("TFV_QUALITY_NOTES", $objLang->get("templateImageType", "tip")); $objTpl->setVariable("TFV_EXTENSION_NOTES", $objLang->get("templateFileType", "tip")); //*** Render image scale pulldown. $arrValues = array(1, 2, 3, 4, 5); $arrLabels = array("Resize exact, crop", "Resize exact, distort", "Resize with boundary, crop", "Resize with boundary, distort", "Resize with boundary, exact"); $strValue = ""; foreach ($arrValues as $key => $value) { $strValue .= "<option value=\"{$arrValues[$key]}\">{$arrLabels[$key]}</option>\n"; } $objTpl->setVariable("TFV_IMAGE_SCALE", $strValue); //*** Insert values if action is edit. if ($strCommand == CMD_EDIT_FIELD) { $objTpl->setVariable("FORM_REQUIRED_VALUE", $objField->getRequired() ? "checked=\"checked\"" : ""); $objTpl->setVariable("FORM_NAME_VALUE", $objField->getName()); $objTpl->setVariable("FORM_APINAME_VALUE", $objField->getApiname()); $objTpl->setVariable("FORM_NOTES_VALUE", $objField->getDescription()); //*** Insert values for the field type. $objFieldValues = $objField->getValues(); if (is_object($objFieldValues)) { foreach ($objFieldValues as $objFieldValue) { if (strtoupper($objFieldValue->getName()) == "TFV_IMAGE_SCALE") { if ($objField->getTypeId() == FIELD_TYPE_IMAGE) { $strValue = ""; foreach ($arrValues as $key => $value) { $selected = $value == $objFieldValue->getValue() ? " selected=\"selected\"" : ""; $strValue .= "<option value=\"{$arrValues[$key]}\"{$selected}>{$arrLabels[$key]}</option>\n"; } $objTpl->setVariable(strtoupper($objFieldValue->getName()), $strValue); } } else { $strValue = $objFieldValue->getValue(); $objTpl->setVariable(strtoupper($objFieldValue->getName()), $strValue); } } } } $objTpl->parseCurrentBlock(); $objTpl->setCurrentBlock("singleview"); if ($strCommand == CMD_EDIT_FIELD) { $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$objField->getFormId()}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$objField->getFormId()}&cmd=" . CMD_LIST); } else { $objTpl->setVariable("BUTTON_FORMCANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_LIST); $objTpl->setVariable("BUTTON_CANCEL_HREF", "?cid=" . NAV_PCMS_FORMS . "&eid={$intElmntId}&cmd=" . CMD_LIST); } $objTpl->setVariable("BUTTON_CANCEL", $objLang->get("back", "button")); $objTpl->setVariable("BUTTON_FORMCANCEL", $objLang->get("cancel", "button")); $objTpl->setVariable("CID", NAV_PCMS_FORMS); $objTpl->setVariable("CMD", $strCommand); $objTpl->setVariable("EID", $intElmntId); $objTpl->parseCurrentBlock(); break; } return $objTpl->get(); }
public function edit() { $user = User::find('_id', $this->getParam('uid', 0)); if ($user == NULL) { System::displayError(System::getLanguage()->_('ErrorUserNotFound'), '404 Not Found'); } $form = new Form('form-user', Router::getInstance()->build('UsersController', 'edit', $user)); $form->binding = $user; $fieldset = new Fieldset(System::getLanguage()->_('General')); $username = new Text('username', System::getLanguage()->_('Username'), true); $username->binding = new Databinding('username'); $username->blacklist = $this->getListOfUsernames($user); $username->error_msg[4] = System::getLanguage()->_('ErrorUsernameAlreayExists'); $firstname = new Text('firstname', System::getLanguage()->_('Firstname')); $firstname->binding = new Databinding('firstname'); $lastname = new Text('lastname', System::getLanguage()->_('Lastname')); $lastname->binding = new Databinding('lastname'); $email = new Text('email', System::getLanguage()->_('EMail'), true); $email->binding = new Databinding('email'); $email->blacklist = $this->getListOfMailAdresses($user); $email->error_msg[4] = System::getLanguage()->_('ErrorMailAdressAlreadyExists'); $language = new Radiobox('lang', System::getLanguage()->_('Language'), L10N::getLanguages(), LANGUAGE); $language->binding = new Databinding('lang'); $fieldset->addElements($username, $firstname, $lastname, $email, $language); $form->addElements($fieldset); $fieldset = new Fieldset(System::getLanguage()->_('Password')); $password = new Password('password', System::getLanguage()->_('Password')); $password->binding = new Databinding('password'); $password2 = new Password('password2', System::getLanguage()->_('ReenterPassword')); $fieldset->addElements($password, $password2); $form->addElements($fieldset); if ($user->uid != System::getUser()->uid) { $fieldset = new Fieldset(System::getLanguage()->_('Settings')); $quota = new Text('quota', System::getLanguage()->_('Quota') . ' (MB)', true, 'numeric'); $quota->binding = new Databinding('quota'); $p = new Paragraph(System::getLanguage()->_('QuotaInfo')); $admin = new Radiobox('admin', System::getLanguage()->_('Admin'), array('1' => System::getLanguage()->_('YesStr'), '0' => System::getLanguage()->_('NoStr'))); $admin->binding = new Databinding('isAdmin'); $fieldset->addElements($quota, $p, $admin); $form->addElements($fieldset); } $form->setSubmit(new Button(System::getLanguage()->_('Save'), 'floppy-disk')); if ($user->uid != System::getUser()->uid) { $form->addButton(new Button(System::getLanguage()->_('DeleteUser'), 'trash', Router::getInstance()->build('UsersController', 'delete', $user))); } $form->addButton(new Button(System::getLanguage()->_('Cancel'), 'remove', Router::getInstance()->build('UsersController', 'index'))); if (Utils::getPOST('submit', false) !== false) { if ($form->validate()) { if ($quota->value < 0) { $quota->error = 'Quota must be > 0'; } else { $form->save(); $user->quota *= 1048576; // Quota is MB $user->save(); System::forwardToRoute(Router::getInstance()->build('UsersController', 'index')); exit; } } } else { $user->quota /= 1048576; // Quota is MB $form->fill(); } $smarty = new Template(); $smarty->assign('title', System::getLanguage()->_('EditUser')); $smarty->assign('heading', System::getLanguage()->_('EditUser')); $smarty->assign('form', $form); $smarty->display('form.tpl'); }
function saveMenuItem(&$menuComponents, &$saveObj, $arrDBNames, $dbID, $itemType, $saveAdditionalArgs = array(), $saveType = "add") { if ($_POST['itemtype'] != $itemType) { return false; } global $formObj, $menuItemObj; foreach ($arrDBNames as $componentName => $dbName) { $menuComponents[$componentName]['db_name'] = $dbName; } $saveAdditional = array("menuitem_id" => $menuItemObj->get_info("menuitem_id")); $setupFormArgs = array("name" => "console-" . $cID . "-" . $itemType, "components" => $menuComponents, "saveObject" => $saveObj, "saveType" => $saveType, "saveAdditional" => array_merge($saveAdditional, $saveAdditionalArgs)); $localFormObj = new Form($setupFormArgs); $localFormObj->save(); $menuItemObj->update(array("itemtype_id"), array($saveObj->get_info($dbID))); }
<?php include "forms_process.class.php"; $_POST["fn"] = "jonathan"; $_POST["ln"] = "de montalembert"; $_POST["mphone"] = "+8618600014793"; $_POST["mail"] = "*****@*****.**"; $_POST["country"] = "france"; $_POST["city"] = "paris"; $_POST['lang'] = 'en'; $_POST['fullname'] = $_POST["fn"] . ' ' . $_POST["ln"]; $form = new Form($_POST); // if($form->setConnection('localhost', 'root', '', 'fuel_dev')) // echo 'connected'; // else // echo 'not connected'; // $form->received(); // $form->getStructure("callback"); // $form->setConnection('localhost', 'root', '', 'fuel_dev'); $form->setValues("city fn mphone mail country lang")->setColumns("city name phone email country language")->setTable("form"); date_default_timezone_set('Asia/Shanghai'); $form->add(array("fromURL" => "google", "website" => "cn")); $form->addIP("user_ip"); $form->check("mail")->exist()->isEmail(); $form->check("mphone")->isPhone(); if ($form->save()) { echo 'success'; } else { echo 'not saved'; }
function display($use_fckeditor = false, $require_email = false, $ask_website = false, $editor_height = false) { global $CFG; if ($CFG->backstage_mode && !($this->record_id > 0) && !$this->show_all) { return false; } $use_fckeditor = $this->use_fckeditor ? $this->use_fckeditor : $use_fckeditor; $require_email = $this->require_email ? $this->require_email : $require_email; $ask_website = $this->ask_website ? $this->ask_website : $ask_website; $editor_height = $this->editor_height ? $this->editor_height : $editor_height; if ($_REQUEST['comments_' . $this->i] && !$this->comments_closed) { if (!empty($_REQUEST['comments_' . $this->i]['comments1'])) { $_REQUEST['comments_' . $this->i]['comments'] = $_REQUEST['comments_' . $this->i]['comments1']; unset($_REQUEST['comments_' . $this->i]['comments1']); } $CFG->save_called = false; $form = new Form('comments_' . $this->i, false, false, $this->class . '_form', 'comments'); $form->verify(); if (!$form->errors) { $form->save(); Messages::add($CFG->comments_sent_message); Messages::display(); } else { $form->show_errors(); } } $comments = Comments::get(); $c = count(Comments::get(false, true)); $show = $this->autoshow ? '' : 'style="display:none;"'; if ($this->label) { if ($CFG->pm_editor) { $method_name = Form::peLabel($this->label['method_id'], 'label'); } echo '<div class="grid_label"><div class="label">' . $this->label['text'] . ' ' . $method_name . '</div><div class="clear"></div></div>'; } if (!$this->short_version) { if ($comments) { echo '<div class="expand">' . str_ireplace('[field]', $c, $CFG->comments_there_are) . ' ' . (!$_REQUEST['comments_' . $this->i] ? '<a href="#" onclick="showComments(' . $this->i . ',this);return false;">' . $CFG->comments_expand . '</a>' : '') . '<a style="display:none;" href="#" onclick="hideComments(' . $this->i . ',this);return false;">' . $CFG->comments_hide . '</a></div>'; } else { echo '<div class="expand">' . $CFG->comments_none . ' <a href="#" onclick="showComments(' . $this->i . ',this);return false;">' . $CFG->comments_be_first . '</a><a style="display:none;" href="#" onclick="hideComments(' . $this->i . ',this);return false;">' . $CFG->comments_hide . '</a></div>'; } } echo ' <div id="comments_' . $this->i . '" class="' . $this->class . '" ' . (!$_REQUEST['comments_' . $this->i] ? $show : '') . '>'; if ($comments) { Comments::show($comments); } echo ' <div id="movable_form" style="display:none;">'; if (!$this->comments_closed) { Comments::showForm($use_fckeditor, $require_email, $ask_website, 1, $editor_height); } echo ' </div>'; if (!$this->comments_closed) { Comments::showForm($use_fckeditor, $require_email, $ask_website, 0, $editor_height); } echo ' <div style="clear:both;height:0;"></div> </div>'; }
$cID = $consoleObj->findConsoleIDByName("Plugin Manager"); $consoleObj->select($cID); $consoleInfo = $consoleObj->get_info_filtered(); $consoleTitle = $consoleInfo['pagetitle']; $member = new Member($mysqli); $member->select($_SESSION['btUsername']); $PAGE_NAME = $pluginInfo['name'] . " Plugin Settings - " . $consoleTitle . " - "; $EXTERNAL_JAVASCRIPT .= "\n<script type='text/javascript' src='" . $MAIN_ROOT . "members/js/console.js'></script>\n<script type='text/javascript' src='" . $MAIN_ROOT . "members/js/main.js'></script>\n"; $formObj = new Form(); require BASE_DIRECTORY . "plugins/" . $pluginInfo['filepath'] . "/settings_form.php"; $hooksObj->run("pluginsettings-" . $pluginInfo['filepath']); include BASE_DIRECTORY . "themes/" . $THEME . "/_header.php"; $breadcrumbObj->setTitle($pluginInfo['name'] . " Plugin Settings"); $breadcrumbObj->addCrumb("Home", $MAIN_ROOT); $breadcrumbObj->addCrumb("My Account", $MAIN_ROOT . "members"); $breadcrumbObj->addCrumb($consoleTitle, $MAIN_ROOT . "members/console.php?cID=" . $cID); $breadcrumbObj->addCrumb($pluginInfo['name'] . " Plugin Settings"); include BASE_DIRECTORY . "include/breadcrumb.php"; // Check Login $LOGIN_FAIL = true; if ($member->authorizeLogin($_SESSION['btPassword']) && $member->hasAccess($consoleObj)) { $formObj->buildForm($setupFormArgs); if ($_POST['submit'] && $formObj->save()) { $formObj->saveMessageTitle = $pluginInfo['name'] . " Plugin Settings"; $formObj->showSuccessDialog(); } $formObj->show(); } else { die("<script type='text/javascript'>window.location = '" . $MAIN_ROOT . "login.php';</script>"); } include BASE_DIRECTORY . "themes/" . $THEME . "/_footer.php";
$disable->verify(); $disable->show_errors(); $disable->HTML('<img class="qrcode" src="includes/qrcode.php?sec=1&code=otpauth://totp/Backstage2?secret=' . $key . '" />'); $disable->textInput('token', 'Enter token', true); $disable->submitButton('submit', 'Disable 2FA'); $disable->display(); } } } if ($show_form) { Messages::display(); $CFG->form_legend = 'My User Info.'; $edit = new Form('users_form', false, false, false, 'admin_users', true); $edit->verify(); $edit->show_errors(); $edit->save(); $edit->get(User::$info['id']); $edit->textInput('user', $CFG->user_username, true, false, false, false, false, false, false, false, 1, $CFG->user_unique_error); $edit->passwordInput('pass', $CFG->user_password, true); $edit->passwordInput('pass1', $CFG->user_password, true, false, false, false, false, false, 'pass'); $edit->textInput('first_name', $CFG->user_first_name, true); $edit->textInput('last_name', $CFG->user_last_name, true); $edit->textInput('phone', $CFG->user_phone); $edit->textInput('email', $CFG->user_email); $edit->submitButton('submit', $CFG->save_caption); $edit->cancelButton($CFG->cancel_button); if ($edit->info['verified_authy'] == 'Y') { $edit->button('my-account', 'Disable Google 2FA', array('action' => 'disable')); } else { $edit->button('my-account', 'Enable Google 2FA', array('action' => 'enable')); }
if ($CFG->url == 'edit_tabs') { include_once 'includes/edit_tabs.php'; } elseif ($CFG->url == 'edit_page') { include_once 'includes/edit_page.php'; } elseif ($CFG->url == 'users') { include_once 'includes/users.php'; } elseif ($CFG->url == 'settings') { include_once 'includes/settings.php'; } elseif ($CFG->url == 'my-account') { include_once 'includes/account.php'; } else { $form_name = ereg_replace("[^a-zA-Z_\\-]", "", $_REQUEST['form_name']); if (!empty($form_name) && $form_name != 'form_filters' && $form_name != 'loginform' && !$_REQUEST['return_to_self']) { $form = new Form($form_name); $form->verify(); $form->save(); $form->show_errors(); $form->show_messages(); } $control = new Control($CFG->url, $CFG->action, $CFG->is_tab); } if ($CFG->print) { echo '</div>'; } echo ' <div class="clear"> </div> <input type="hidden" id="page_url" value="' . $CFG->editor_page_id . '" /> <input type="hidden" id="page_is_tab" value="' . $CFG->editor_is_tab . '" /> <input type="hidden" id="page_action" value="' . $CFG->action . '" /> <script type="text/javascript">footerToBottom(\'credits\');scaleBackstage();</script>'; if (!$CFG->bypass || $CFG->url != 'edit_page') {
$form->info['order'] = $form->info['order'] > 0 ? $form->info['order'] : '0'; $sql = "UPDATE {$f_table} SET {$f_table}.order = ({$f_table}.order + 1) WHERE {$f_table}.order >= {$form->info['order']} AND {$l_field} = {$l_id}"; db_query($sql); } else { unset($form->info['order']); } $form->verify(); $form->save(); $form->show_errors(); $form->show_messages(); if ($f_table == 'admin_controls' && !$form->errors) { $CFG->save_called = false; if ($form->info['class'] == 'Excel') { $form1 = new Form($f_name, false, false, false, $f_table); $form1->info['action'] = 'form'; $form1->save(); $form1->show_errors(); $form1->show_messages(); } elseif ($form->info['class'] == 'Form') { } } if ($f_table = 'admin_controls_methods' && ($form->info['method'] == 'emailNotify' || $form->info['method'] == 'createRecord' || $form->info['method'] == 'editRecord')) { if ($form->info['argument_day'] || $form->info['argument_month'] || $form->info['argument_year'] || $form->info['argument_run_in_cron']) { $sql = "SELECT id FROM admin_cron WHERE control_id = " . $form->info['control_id'] . " AND method_id = " . $form->record_id; $result = db_query_array($sql); if (!$result) { DB::insert('admin_cron', array('control_id' => $form->info['control_id'], 'method_id' => $form->record_id, 'day' => $form->info['argument_day'], 'month' => $form->info['argument_month'], 'year' => $form->info['argument_year'], 'send_condition' => $form->info['argument_send_condition'])); } else { DB::update('admin_cron', array('day' => $form->info['argument_day'], 'month' => $form->info['argument_month'], 'year' => $form->info['argument_year'], 'send_condition' => $form->info['argument_send_condition']), $result[0]['id']); } }
public function postEdit($p, $z) { Form::save(); $this->redirect(''); }
public function display() { $template = new Template(); $template->load("formeditor"); $form = new Form($_GET['form']); if (isset($_POST['datatype']) && !isset($_POST['save'])) { $form->dataTypeID = $_POST['datatype']; $form->clearFieldsFromDB(); } foreach ($_POST as $key => $value) { $id = explode('_', $key); $id = $id[0]; if (is_numeric($id)) { $key = substr($key, strlen($id) + 1); $fields[$id][$key] = $value; } } if (isset($fields)) { foreach ($fields as $field) { $formField = new FormField(); $formField->sortIndex = $field['sortIndex']; $formField->dataName = $field['dataname']; $formField->label = $field['label']; if ($field['insert']) { $formField->insert = true; } else { $formField->insert = false; } if (isset($field['mandatory']) && $field['mandatory']) { $formField->mandatory = true; } else { $formField->mandatory = false; } if ($field['show']) { $formField->show = true; } else { $formField->show = false; } $formField->edit = $field['edit']; $formField->preAllocate = $field['value']; $form->addField($formField); } } if (isset($_POST['save'])) { $form->buttonText = $_POST['buttontext']; $form->succeedMessage = $_POST['succeedmessage']; $form->dataTypeID = $_POST['datatype']; if (isset($_POST['captcha']) && $_POST['captcha']) { $form->captcha = true; } else { $form->captcha = false; } if (isset($_POST['showAfterInsert']) && $_POST['showAfterInsert']) { $form->showAfterInsert = true; } else { $form->showAfterInsert = false; } $form->save(); } $combobox = new combobox(); $combobox->fillSelect = "SELECT 0 as value, '' as label UNION SELECT id as value, displayName as label FROM {'dbprefix'}datatypes ORDER BY label"; $combobox->value = $form->dataTypeID; $combobox->name = 'datatype'; $combobox->onChange = "document.form.submit();"; $template->assign_var("DATATYPE", $combobox->getCode()); $buttonText = new textbox(); $buttonText->name = "buttontext"; $buttonText->value = $form->buttonText; $template->assign_var("BUTTONTEXT", $buttonText->getCode()); $succeedMessage = new textbox(); $succeedMessage->name = "succeedmessage"; $succeedMessage->value = $form->succeedMessage; $template->assign_var("SUCCEEDMESSAGE", $succeedMessage->getCode()); $captcha = new checkbox(); $captcha->name = "captcha"; $captcha->value = $form->captcha; $template->assign_var("CAPTCHA", $captcha->getCode()); $showAfterInsert = new checkbox(); $showAfterInsert->name = "showAfterInsert"; $showAfterInsert->value = $form->showAfterInsert; $template->assign_var("SHOWAFTERINSERT", $showAfterInsert->getCode()); $list = new CustomList(); if ($form->isEmpty()) { $list->fillSelect = "SELECT *, @rownum:=@rownum+1 AS sortindex, 'checked' as show_check, '' as mandatory_check, 'checked' as insert_check, '\\'\\'' as preallocate FROM (SELECT @rownum:=0) r, {'dbprefix'}datafields WHERE dataType = '" . $form->dataTypeID . "' ORDER BY displayName"; } else { $list->fillSelect = "SELECT *, label as displayname, @rownum:=@rownum+1 as id, IF( `show` = '1', 'checked', '' ) as show_check, IF( `insert` = '1', 'checked', '' ) as insert_check, IF( `mandatory` = '1', 'checked', '' ) as mandatory_check FROM (SELECT @rownum:=0) r, {'dbprefix'}form_fields WHERE form = '" . $form->id . "' ORDER by sortIndex"; } $list->template = "formfield_editor"; $list->paddingLeft = 0; $list->showButtons = false; $template->assign_var("FIELDS", $list->getCode()); $template->output(); }
/** * @abstract Processes the registration * @access public */ public function process_registration() { $form = new Form('users', false, array('groups')); $form->addField('password_confirm'); if ($form->isSubmitted()) { if ($form->save()) { $this->mail->AddAddress($form->cv('username')); $this->mail->From = $this->config('email_sender'); $this->mail->FromName = $this->config('email_sender_name'); $this->mail->Mailer = "mail"; $this->mail->ContentType = 'text/html'; $this->mail->Subject = $this->website_title() . " Registration Confirmation"; $body = $this->config('registration_email_body'); $body = str_replace('{website}', $this->website_title(), $body); $body = str_replace('{user}', $form->cv('username'), $body); $body = str_replace('{pass}', post()->getRaw('password'), $body); $this->mail->Body = $body; $this->mail->Send(); $this->mail->ClearAddresses(); // send to thanks page $thanks = $this->cms_lib->url($this->config('registration_thanks_page_id')); header("Location: " . (empty($thanks) ? 'index.php' : $thanks)); exit; } } return $form; }
/** * @abstract Edits a page and all content sections * @param integer $id */ public function edit($id) { template()->addCss('style.css'); template()->addJs('admin/datepicker.js'); template()->addJs('edit.js'); template()->addJsVar('last_id', app()->Pages_Admin->section_count); $data['templates'] = $this->scanTemplateList(); $data['available_sections'] = director()->getPageSections(); $form = new Form('pages', $id); // load sections $data['sections'] = array(); // pull all references to sections for this page $model = model()->open('section_list'); $model->where('page_id', $id); $sections = $model->results(); if ($sections) { foreach ($sections as $section) { $section_results = model()->open('section_' . strtolower($section['section_type']), $section['section_id']); $data['sections'][$section['id']]['meta'] = $section; $data['sections'][$section['id']]['content'] = $section_results; } $this->section_count = count($data['sections']) - 1; } // add in section field names so our form handler can see them foreach (director()->getPageSections() as $section_field) { $form->addField($section_field['option_value']); } // process the form if submitted if ($form->isSubmitted()) { // set checkboxes to false if they're not sent from browser // @todo is this really needed? if (!post()->keyExists('show_in_menu')) { $form->setCurrentValue('show_in_menu', false); } if (!post()->keyExists('page_is_live')) { $form->setCurrentValue('page_is_live', false); } if (!post()->keyExists('is_parent_default')) { $form->setCurrentValue('is_parent_default', false); } if (!post()->keyExists('login_required')) { $form->setCurrentValue('login_required', false); } // update page information if ($form->save($id)) { $model = model()->open('section_list'); // remove all current sections references $model->delete($id, 'page_id'); $sections = director()->savePageSections($id); // store references to the specifc sections foreach ($sections as $key => $section) { $model->insert(array('page_id' => $id, 'section_type' => $section['type'], 'section_id' => $section['id'], 'sort_order' => $key, 'called_in_template' => $section['called_in_template'], 'placement_group' => $section['placement_group'])); } sml()->say('Page changes have been saved successfully. ' . template()->link('Edit Again', 'edit', array($id))); router()->redirect('view'); } else { sml()->say('An error occurred. Please try again.'); } } $data['form'] = $form; template()->display($data); }