function _confirmArchive() { if (isset($_REQUEST['PHAT_ArchiveConfirm'])) { include PHPWS_SOURCE_DIR . 'mod/phatform/inc/Archive.php'; $error = NULL; $error = archive($this->getId()); if (PHPWS_Error::isError($error)) { PHPWS_Error::log($error); javascript('alert', array('content' => dgettext('phatform', 'Failed to archive.'))); unset($_REQUEST['PHAT_ArchiveConfirm']); unset($error); $_REQUEST['PHAT_FORM_OP'] = 'ArchiveConfirm'; $this->action(); return; } $this->_saved = 0; $this->_position = 0; $sql = 'UPDATE mod_phatform_forms SET saved=\'' . $this->_saved . "' WHERE id='" . $this->getId() . "'"; PHPWS_DB::query($sql); $sql = 'DROP TABLE mod_phatform_form_' . $this->getId(); PHPWS_DB::query($sql); $table = 'mod_phatform_form_' . $this->getId() . '_seq'; if (PHPWS_DB::isTable($table)) { $sql = 'DROP TABLE ' . $table; PHPWS_DB::query($sql); } $_REQUEST['PHAT_FORM_OP'] = 'EditAction'; $_REQUEST['PHAT_Submit'] = 1; $this->action(); } else { if (isset($_REQUEST['PHAT_ArchiveCancel'])) { $_REQUEST['PHAT_MAN_OP'] = 'List'; $_SESSION['PHAT_FormManager']->action(); } else { $hiddens['module'] = 'phatform'; $hiddens['PHAT_FORM_OP'] = 'ArchiveConfirm'; foreach ($hiddens as $key => $value) { $eles[] = PHPWS_Form::formHidden($key, $value); } $elements[0] = implode("\n", $eles); $confirmTags['WARNING_TAG'] = dgettext('phatform', 'WARNING!'); $confirmTags['MESSAGE'] = dgettext('phatform', 'You have chosen to edit a saved form! All current data will be archived and cleared if you chose to continue! Make sure you export your data from your form before you continue!'); $confirmTags['CANCEL_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Cancel'), 'PHAT_ArchiveCancel'); $confirmTags['CONFIRM_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Confirm'), 'PHAT_ArchiveConfirm'); $elements[0] .= PHPWS_Template::processTemplate($confirmTags, 'phatform', 'form/archiveConfirm.tpl'); $content = PHPWS_Form::makeForm('PHAT_FormArchiveConfirm', 'index.php', $elements); $GLOBALS['CNT_phatform']['title'] = dgettext('phatform', 'Form') . ': ' . $this->getLabel(); $GLOBALS['CNT_phatform']['content'] .= $content; } } }
function testEditors($text) { if ($_SESSION["OBJ_user"]->allow_access("xwysiwyg", "settings")) { $this->content .= "<a href=\"" . $this->linkRef . "&action=admin" . "\">" . $_SESSION['translate']->it("Back to administration") . "</a>"; $tags = array(); $tags["TESTAREA"] = PHPWS_WizardBag::js_insert("wysiwyg", "xw_test_form", "xw_testarea") . PHPWS_Form::formTextArea("xw_testarea", $text, 10, 70); $tags["SUBMIT_BUTTON"] = PHPWS_Form::formSubmit($_SESSION["translate"]->it("Save")); $elements[0] = PHPWS_Form::formHidden("module", "xwysiwyg"); $elements[0] .= PHPWS_Form::formHidden("action", "testEditor"); $elements[0] .= PHPWS_Template::processTemplate($tags, "xwysiwyg", "test_editor.tpl"); $this->content .= PHPWS_Form::makeForm("xw_test_form", "index.php", $elements, "post", FALSE, TRUE); $this->content .= "<hr /><br />" . PHPWS_Text::parseOutput($text); } else { $this->content .= $_SESSION['translate']->it("Access was denied due to lack of proper permissions."); } // End of ADMINISTRATOR condition }
/** * Edit this PHAT_Radiobutton * * This function provides the HTML form to edit or create a new PHAT_Radiobutton * * @return string The HTML form for editing * @access public */ function edit() { $numOptions = sizeof($this->getOptionText()); if (!$numOptions) { $numOptions = ''; } $elements[0] = PHPWS_Form::formHidden('module', 'phatform') . PHPWS_Form::formHidden('PHAT_EL_OP', 'SaveElement'); if (!$this->getLabel()) { $num = $_SESSION['PHAT_FormManager']->form->numElements(); $this->setLabel('Element' . ($num + 1)); } if (PHAT_SHOW_INSTRUCTIONS) { $GLOBALS['CNT_phatform']['title'] = dgettext('phatform', 'Radiobutton Element Instructions'); } $editTags['BLURB_LABEL'] = dgettext('phatform', 'Associated Text'); $editTags['BLURB_INPUT'] = PHPWS_Form::formTextArea('PHAT_ElementBlurb', $this->getBlurb(), PHAT_DEFAULT_ROWS, PHAT_DEFAULT_COLS); $editTags['NAME_LABEL'] = dgettext('phatform', 'Name'); $editTags['NAME_INPUT'] = PHPWS_Form::formTextField('PHAT_ElementName', $this->getLabel(), PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE); $editTags['OPTIONS_LABEL'] = dgettext('phatform', 'Number of Options'); $editTags['OPTIONS_INPUT'] = PHPWS_Form::formTextField('PHAT_ElementNumOptions', $numOptions, 5, 3); $options = $this->getOptionSets(); if (is_array($options)) { $editTags['OPTION_SET_LABEL'] = dgettext('phatform', 'Predefined Option Set'); $editTags['OPTION_SET_INPUT'] = PHPWS_Form::formSelect('PHAT_OptionSet', $options, $this->getOptionSet(), FALSE, TRUE); } $editTags['REQUIRE_LABEL'] = dgettext('phatform', 'Required'); $editTags['REQUIRE_INPUT'] = PHPWS_Form::formCheckBox('PHAT_ElementRequired', 1, $this->isRequired()); $editTags['BACK_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Back'), 'PHAT_ElementBack'); $editTags['NEXT_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Next')); $elements[0] .= PHPWS_Template::processTemplate($editTags, 'phatform', 'radiobutton/edit.tpl'); return PHPWS_Form::makeForm('PHAT_RadiobuttonEdit', 'index.php', $elements, 'post', NULL, NULL); }
/** * Edit this PHAT_Textarea * * @return string The HTML form needed to edit this PHAT_Textarea * @access public */ function edit() { $elements[0] = PHPWS_Form::formHidden('module', 'phatform') . PHPWS_Form::formHidden('PHAT_EL_OP', 'SaveElement'); if (!$this->getLabel()) { $num = $_SESSION['PHAT_FormManager']->form->numElements(); $this->setLabel('Element' . ($num + 1)); } if (PHAT_SHOW_INSTRUCTIONS) { $GLOBALS['CNT_phatform']['title'] = dgettext('phatform', 'Textarea Element Instructions'); } $editTags['BLURB_LABEL'] = dgettext('phatform', 'Associated Text'); $editTags['BLURB_INPUT'] = PHPWS_Form::formTextArea('PHAT_ElementBlurb', $this->getBlurb(), PHAT_DEFAULT_ROWS, PHAT_DEFAULT_COLS); $editTags['NAME_LABEL'] = dgettext('phatform', 'Name'); $editTags['NAME_INPUT'] = PHPWS_Form::formTextField('PHAT_ElementName', $this->getLabel(), PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE); $editTags['ROWS_LABEL'] = dgettext('phatform', 'Rows'); $editTags['ROWS_INPUT'] = PHPWS_Form::formTextField('PHAT_ElementRows', $this->_rows, 5, 3); $editTags['COLS_LABEL'] = dgettext('phatform', 'Columns'); $editTags['COLS_INPUT'] = PHPWS_Form::formTextField('PHAT_ElementCols', $this->_cols, 5, 3); $editTags['VALUE_LABEL'] = dgettext('phatform', 'Value'); $editTags['VALUE_INPUT'] = PHPWS_Form::formTextArea('PHAT_ElementValue', $this->getValue(), PHAT_DEFAULT_ROWS, PHAT_DEFAULT_COLS); $editTags['REQUIRE_LABEL'] = dgettext('phatform', 'Require'); $editTags['REQUIRE_INPUT'] = PHPWS_Form::formCheckBox('PHAT_ElementRequired', 1, $this->isRequired()); $editTags['BACK_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Back'), 'PHAT_ElementBack'); $editTags['SAVE_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Save Textarea')); $elements[0] .= PHPWS_Template::processTemplate($editTags, 'phatform', 'textarea/edit.tpl'); return PHPWS_Form::makeForm('PHAT_TextareaEdit', 'index.php', $elements, 'post', NULL, NULL); }
/** * * * * */ function confirmDelete() { $hiddens['module'] = 'phatform'; $hiddens['PHAT_REPORT_OP'] = 'delete'; $hiddens['PHAT_ENTRY_ID'] = $_REQUEST['PHAT_ENTRY_ID']; foreach ($hiddens as $key => $value) { $eles[] = PHPWS_Form::formHidden($key, $value); } $elements[0] = implode("\n", $eles); $confirmTags['MESSAGE'] = dgettext('phatform', 'Are you sure you want to delete this entry?'); $confirmTags['NO_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'No'), 'PHAT_DeleteNo'); $confirmTags['YES_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Yes'), 'PHAT_DeleteYes'); $elements[0] .= PHPWS_Template::processTemplate($confirmTags, 'phatform', 'report/deleteConfirm.tpl'); $content = PHPWS_Form::makeForm('PHAT_EntryDeleteConfirm', 'index.php', $elements); $content .= '<br /><hr /><br />'; $content .= $this->view(FALSE); return $content; }
/** * Remove this PHAT_Element * * @accesss public */ function remove() { if (isset($_REQUEST['PHAT_Yes'])) { $result = $this->kill(); if (PHPWS_Error::isError($result)) { return PHPWS_Error::get(PHATFORM_CANNOT_DELETE_ELEMENT, 'phatform', 'PHAT_Element::remove()'); } else { $result = $_SESSION['PHAT_FormManager']->form->popElement(); if (PHPWS_Error::isError($result)) { return $result; } else { return dgettext('phatform', 'The element was successfully removed.'); } } } else { if (isset($_REQUEST['PHAT_No'])) { return dgettext('phatform', 'No element was removed.'); } else { $className = get_class($this); $properName = ucfirst(str_ireplace('phat_', '', $className)); $tags['MESSAGE'] = sprintf(dgettext('phatform', 'Are you sure you want to remove this %s element?'), '<b><i>' . $properName . '</i></b>'); $tags['YES_BUTTON'] = PHPWS_Form::formSubmit('Yes', 'PHAT_Yes'); $tags['NO_BUTTON'] = PHPWS_Form::formSubmit('No', 'PHAT_No'); $tags['ELEMENT_PREVIEW'] = $this->view(); $elements[0] = PHPWS_Form::formHidden('module', 'phatform'); $elements[0] .= PHPWS_Form::formHidden('PHAT_EL_OP', 'RemoveElement'); $elements[0] .= PHPWS_Template::processTemplate($tags, 'phatform', 'form/deleteConfirm.tpl'); $content = PHPWS_Form::makeForm('PHAT_Confirm', 'index.php', $elements); } } return $content; }
function deleteArchive() { if (isset($_POST['yes'])) { if (!isset($_REQUEST['ARCHIVE_filename'])) { $content = dgettext('phatform', 'There was a problem deleting the archive.') . '<br /><br />'; $content .= $this->viewArchives(); return $content; } $this->cleanUpArchive(); $filename = PHPWS_HOME_DIR . 'files/phatform/archive/' . $_REQUEST['ARCHIVE_filename']; if (is_file($filename) && unlink($filename)) { $content = dgettext('phatform', 'The phatform archive was successfully <b>deleted</b>.') . '<br /><br />'; } else { $content = dgettext('phatform', 'There was a problem deleting the archive.') . '<br /><br />'; } $content .= $_SESSION['PHAT_advViews']->viewArchives(); } elseif (isset($_POST['no'])) { $content = sprintf(dgettext('phatform', 'You have chosen <b>not</b> to delete the archive with the filename "%s".'), $_REQUEST['ARCHIVE_filename']) . '<br /><br />'; $content .= $_SESSION['PHAT_advViews']->viewArchives(); } else { $elements[0] = PHPWS_Form::formHidden('module', 'phatform'); $elements[0] .= PHPWS_Form::formHidden('ARCHIVE_OP', 'deleteArchive'); $elements[0] .= PHPWS_Form::formHidden('ARCHIVE_filename', $_REQUEST['ARCHIVE_filename']); $elements[0] .= PHPWS_Form::formSubmit(dgettext('phatform', 'Yes'), 'yes'); $elements[0] .= PHPWS_Form::formSubmit(dgettext('phatform', 'No'), 'no'); $content = sprintf(dgettext('phatform', 'Are you sure you wish to delete the archive with filename "<b>%s</b>"?'), $_REQUEST['ARCHIVE_filename']) . '<br /><br />'; $content .= PHPWS_Form::makeForm('archive_delete', 'index.php', $elements); } return $content; }
function _editOptions() { if (Current_User::allow('phatform', 'edit_options')) { if (isset($_REQUEST['PHAT_OptionSetId']) && !is_numeric($_REQUEST['PHAT_OptionSetId']) || isset($_REQUEST['PHAT_OptionBack'])) { $_REQUEST['PHAT_MAN_OP'] = 'Options'; $this->action(); return; } else { $optionSetId = $_REQUEST['PHAT_OptionSetId']; } if (isset($_REQUEST['PHAT_SaveOptionSet'])) { if (is_array($_REQUEST['PHAT_ElementOptions']) && is_array($_REQUEST['PHAT_ElementValues'])) { for ($i = 0; $i < sizeof($_REQUEST['PHAT_ElementOptions']); $i++) { $_REQUEST['PHAT_ElementOptions'][$i] = PHPWS_Text::parseInput($_REQUEST['PHAT_ElementOptions'][$i]); $_REQUEST['PHAT_ElementValues'][$i] = PHPWS_Text::parseInput($_REQUEST['PHAT_ElementValues'][$i]); } $options = addslashes(serialize($_REQUEST['PHAT_ElementOptions'])); $values = addslashes(serialize($_REQUEST['PHAT_ElementValues'])); $saveArray = array('optionSet' => $options, 'valueSet' => $values); $db = new PHPWS_DB('mod_phatform_options'); $db->addWhere('id', $optionSetId); $db->addValue($saveArray); $db->update(); } } else { if (isset($_REQUEST['PHAT_delete'])) { $db = new PHPWS_DB('mod_phatform_options'); $db->addWhere('id', $optionSetId); $db->delete(); $_REQUEST['PHAT_MAN_OP'] = 'Options'; $this->action(); return; } } $GLOBALS['CNT_phatform']['title'] = PHAT_TITLE; $sql = "SELECT * FROM mod_phatform_options WHERE id='{$optionSetId}'"; $result = PHPWS_DB::getRow($sql); if ($result) { $elements = array(); $elements[] = PHPWS_Form::formHidden('module', $this->_module); $elements[] = PHPWS_Form::formHidden('PHAT_MAN_OP', 'editOptions'); $elements[] = PHPWS_Form::formHidden('PHAT_OptionSetId', $optionSetId); $options = unserialize(stripslashes($result['optionSet'])); $values = unserialize(stripslashes($result['valueSet'])); $editTags = array(); $editTags['TITLE'] = dgettext('phatform', 'Edit option set') . " {$result['label']}"; $editTags['NUMBER_LABEL'] = dgettext('phatform', 'Option'); $editTags['INPUT_LABEL'] = dgettext('phatform', 'Text'); $editTags['VALUE_LABEL'] = dgettext('phatform', 'Value'); $editTags['OPTIONS'] = ''; $rowClass = NULL; for ($i = 0; $i < sizeof($options); $i++) { $optionRow['OPTION_NUMBER'] = $i + 1; $optionRow['OPTION_INPUT'] = PHPWS_Form::formTextField("PHAT_ElementOptions[{$i}]", $options[$i], PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE); $optionRow['VALUE_INPUT'] = PHPWS_Form::formTextField("PHAT_ElementValues[{$i}]", $values[$i], PHAT_DEFAULT_SIZE, PHAT_DEFAULT_MAXSIZE); $optionRow['ROW_CLASS'] = $rowClass; if ($i % 2) { $rowClass = ' class="bgcolor1"'; } else { $rowClass = null; } $editTags['OPTIONS'] .= PHPWS_Template::processTemplate($optionRow, 'phatform', 'options/option.tpl'); } } $editTags['BACK_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Back'), 'PHAT_OptionBack'); $editTags['SAVE_BUTTON'] = PHPWS_Form::formSubmit(dgettext('phatform', 'Save'), 'PHAT_SaveOptionSet'); $elements[] = PHPWS_Template::processTemplate($editTags, 'phatform', 'options/optionList.tpl'); return PHPWS_Form::makeForm('PHAT_Options_edit', 'index.php', $elements); } else { $this->_list(); } }