Validates the form, checking if it really has been submitted by calling
isSubmitted() and if true does any onSubmit() calls for variable types
in the form. The _submitted variable is then rechecked.
public function validate(&$vars) { if (!Whups::hasPermission($this->_queue, 'queue', Horde_Perms::DELETE)) { $this->setError('yesno', _("Permission Denied.")); } return parent::validate($vars); }
public function validate(&$vars) { if (Whups::hasPermission($this->_queue, 'queue', Horde_Perms::DELETE)) { $this->_warn->setDefault('<span class="horde-form-error">' . _("Permission Denied.") . '</span>'); } return parent::validate($vars); }
public function validate(&$vars, $canAutoFill = false) { global $conf; if (!parent::validate($vars, $canAutoFill)) { if (!$GLOBALS['registry']->getAuth() && !empty($conf['guests']['captcha'])) { $vars->remove('captcha'); $this->removeVariable($varname = 'captcha'); $this->insertVariableBefore('newcomment', _("Spam protection"), 'captcha', 'figlet', true, null, null, array(Whups::getCAPTCHA(true), $conf['guests']['figlet_font'])); } return false; } return true; }
/** * Function to validate any delete form input. * * @param TODO $info TODO * * @return mixed If the delete button confirmation has been pressed return * true, if any other submit button has been pressed return * false. If form did not validate return null. */ public function validateDeleteForm(&$info) { $form_submit = $this->_vars->get('submitbutton'); if ($form_submit == Horde_Core_Translation::t("Delete")) { if ($this->_form->validate($this->_vars)) { $this->_form->getInfo($this->_vars, $info); return true; } } elseif (!empty($form_submit)) { return false; } return null; }
/** * Expects: * $vars * $registry * $notification */ public function run() { extract($this->_params, EXTR_REFS); /* Set up the form variables and the form. */ $form_submit = $vars->get('submitbutton'); $channel_id = $vars->get('channel_id'); try { $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($channel_id); } catch (Exception $e) { Horde::log($e, 'ERR'); $notification->push(_("Invalid channel specified for deletion."), 'horde.message'); Horde::url('channels')->redirect(); exit; } /* If not yet submitted set up the form vars from the fetched channel. */ if (empty($form_submit)) { $vars = new Horde_Variables($channel); } /* Check permissions and deny if not allowed. */ if (!Jonah::checkPermissions(Jonah::typeToPermName($channel['channel_type']), Horde_Perms::DELETE, $channel_id)) { $notification->push(_("You are not authorised for this action."), 'horde.warning'); throw new Horde_Exception_AuthenticationFailure(); } $title = sprintf(_("Delete News Channel \"%s\"?"), $vars->get('channel_name')); $form = new Horde_Form($vars, $title); $form->setButtons(array(_("Delete"), _("Do not delete"))); $form->addHidden('', 'channel_id', 'int', true, true); $msg = _("Really delete this News Channel? All stories created in this channel will be lost!"); $form->addVariable($msg, 'confirm', 'description', false); if ($form_submit == _("Delete")) { if ($form->validate($vars)) { $form->getInfo($vars, $info); try { $delete = $GLOBALS['injector']->getInstance('Jonah_Driver')->deleteChannel($info); $notification->push(_("The channel has been deleted."), 'horde.success'); Horde::url('channels')->redirect(); exit; } catch (Exception $e) { $notification->push(sprintf(_("There was an error deleting the channel: %s"), $e->getMessage()), 'horde.error'); } } } elseif (!empty($form_submit)) { $notification->push(_("Channel has not been deleted."), 'horde.message'); Horde::url('channels')->redirect(); exit; } $GLOBALS['page_output']->header(array('title' => $title)); $notification->notify(array('listeners' => 'status')); $form->renderActive(null, $vars, Horde::selfUrl(), 'post'); $GLOBALS['page_output']->footer(); }
/** * Display form * * @param integer $form_id Form id dispaly * @param string $target_url Target url to link form to */ public function display($form_id, $target_url = null) { /* Get the stored form information from the backend. */ try { $form_info = $GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getForm($form_id, Horde_Perms::READ); } catch (Horde_Exception $e) { throw new Ulaform_Exception($e->getMessage()); } if (!empty($form_info['form_params']['language'])) { Horde_Nls::setLanguageEnvironment($form_info['form_params']['language']); } $vars = Horde_Variables::getDefaultVariables(); $vars->set('form_id', $form_id); $form = new Horde_Form($vars); $form->addHidden('', 'form_id', 'int', false); $form->addHidden('', 'user_uid', 'text', false); $form->addHidden('', 'email', 'email', false); $vars->set('user_uid', $GLOBALS['registry']->getAuth()); $vars->set('email', $GLOBALS['prefs']->getValue('from_addr')); try { $fields = $GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getFields($form_id); } catch (Ulaform_Exception $e) { throw new Ulaform_Exception($e->getMessage()); } foreach ($fields as $field) { /* In case of these types get array from stringlist. */ if ($field['field_type'] == 'link' || $field['field_type'] == 'enum' || $field['field_type'] == 'multienum' || $field['field_type'] == 'mlenum' || $field['field_type'] == 'radio' || $field['field_type'] == 'set' || $field['field_type'] == 'sorter') { $field['field_params']['values'] = Ulaform::getStringlistArray($field['field_params']['values']); } /* Setup the field with all the parameters. */ $form->addVariable($field['field_label'], $field['field_name'], $field['field_type'], $field['field_required'], $field['field_readonly'], $field['field_desc'], $field['field_params']); } /* Check if submitted and validate. */ $result = array('title' => $form_info['form_name']); if ($form->validate()) { $form->getInfo(null, $info); try { $GLOBALS['ulaform_driver']->submitForm($info); return true; } catch (Horde_Exception $e) { throw new Ulaform_Exception(sprintf(_("Error submitting form. %s."), $e->getMessage())); } } if (is_null($target_url)) { $target_url = Horde::selfUrl(true); } Horde::startBuffer(); $form->renderActive(null, null, $target_url, 'post', 'multipart/form-data'); return array('title' => $form_info['form_name'], 'form' => Horde::endBuffer()); }
protected function _content() { $vars = Horde_Variables::getDefaultVariables(); $formname = $vars->get('formname'); $done = false; $form = new Horde_Form($vars); $fields = $GLOBALS['injector']->getInstance('Ulaform_Factory_Driver')->create()->getFields($this->_params['form_id']); foreach ($fields as $field) { /* In case of these types get array from stringlist. */ if ($field['field_type'] == 'link' || $field['field_type'] == 'enum' || $field['field_type'] == 'multienum' || $field['field_type'] == 'radio' || $field['field_type'] == 'set' || $field['field_type'] == 'sorter') { $field['field_params']['values'] = Ulaform::getStringlistArray($field['field_params']['values']); } /* Setup the field with all the parameters. */ $form->addVariable($field['field_label'], $field['field_name'], $field['field_type'], $field['field_required'], $field['field_readonly'], $field['field_desc'], $field['field_params']); } if ($formname) { $form->validate($vars); if ($form->isValid() && $formname) { $form->getInfo($vars, $info); $info['form_id'] = $this->_params['form_id']; try { $submit = $GLOBALS['ulaform_driver']->submitForm($info); $GLOBALS['notification']->push(_("Form submitted successfully."), 'horde.success'); $done = true; } catch (Horde_Exception $e) { $GLOBALS['notification']->push(sprintf(_("Error submitting form. %s."), $e->getMessage()), 'horde.error'); } } } /* Render active or inactive, depending if submitted or * not. */ $render_type = $done ? 'renderInactive' : 'renderActive'; /* Render the form. */ $renderer = new Horde_Form_Renderer(); $renderer->showHeader(false); Horde::startBuffer(); $form->{$render_type}($renderer, $vars, Horde::selfUrl(true), 'post'); return Horde::endBuffer(); }
foreach ($extra as $field_name => $field) { $readonly = isset($field['readonly']) ? $field['readonly'] : null; $desc = isset($field['desc']) ? $field['desc'] : null; $field_params = isset($field['params']) ? $field['params'] : array(); $addForm->addVariable($field['label'], 'extra[' . $field_name . ']', $field['type'], $field['required'], $readonly, $desc, $field_params); } } } catch (Horde_Exception_HookNotSet $e) { } if (empty($extra)) { $addForm->addVariable(_("Username"), 'user_name', 'text', true); $addForm->addVariable(_("Password"), 'password', 'passwordconfirm', false, false, _("type the password twice to confirm")); } switch ($vars->form) { case 'add': $addForm->validate($vars); if ($addForm->isValid() && $vars->get('formname') == 'adduser') { $addForm->getInfo($vars, $info); if (empty($info['user_name']) && isset($info['extra']['user_name'])) { $info['user_name'] = $info['extra']['user_name']; } if (empty($info['password']) && isset($info['extra']['password'])) { $info['password'] = $info['extra']['password']; } if (empty($info['user_name'])) { $notification->push(_("You must specify the username to add."), 'horde.error'); } elseif ($auth->exists($info['user_name'])) { $notification->push(sprintf(_("The user \"%s\" already exists."), $info['user_name']), 'horde.error'); } else { $credentials = array('password' => $info['password']); if (isset($info['extra'])) {
if ($vars->get('email') == $email) { $can_validate = true; $form->setButtons(_("Reset Password")); $question = $prefs->getValue('security_question'); $form->addVariable($question, 'question', 'description', false); $form->addVariable(_("Answer"), 'answer', 'text', true); if (!$question) { $notification->push(_("No security question has been set. Please contact your administrator."), 'horde.error'); $registry->getServiceLink('login')->add('url', $vars->url)->redirect(); } } else { $notification->push(_("Incorrect username or alternate address. Try again or contact your administrator if you need further help."), 'horde.error'); } } /* Validate the form. */ if ($can_validate && $form->validate($vars)) { $form->getInfo($vars, $info); /* Fetch values from prefs for selected user. */ $answer = $prefs->getValue('security_answer'); /* Check the given values witht the prefs stored ones. */ if ($email == $info['email'] && strtolower($answer) == strtolower($info['answer'])) { /* Info matches, so reset the password. */ try { $password = $auth->resetPassword($info['username']); $success = true; } catch (Horde_Exception $e) { $notification->push($e); $success = false; } $mail = new Horde_Mime_Mail(array('body' => sprintf(_("Your new password for %s is: %s"), $registry->get('name', 'horde'), $password), 'charset' => 'UTF-8', 'From' => empty($conf['auth']['resetpassword_from']) ? $email : $conf['auth']['resetpassword_from'], 'To' => $email, 'Subject' => _("Your password has been reset"))); try {
/* Check if the submitted field type has extra parameters and set them up. */ $field_type = $vars->get('field_type'); $available_params = Ulaform::getFieldParams($field_type); if (!is_null($vars->get('formname')) && $vars->get($v->getVarName()) != $vars->get('__old_' . $v->getVarName()) && !empty($available_params)) { $notification->push(_("This field type has extra parameters."), 'horde.message'); } foreach ($available_params as $name => $param) { $field_id = 'field_params[' . $name . ']'; $param['required'] = isset($param['required']) ? $param['required'] : null; $param['readonly'] = isset($param['readonly']) ? $param['readonly'] : null; $param['desc'] = isset($param['desc']) ? $param['desc'] : null; $fieldform->addVariable($param['label'], $field_id, $param['type'], $param['required'], $param['readonly'], $param['desc']); } /* Set the current field type to the old field type var. */ $vars->set('old_field_type', $field_type); if ($fieldform->validate($vars)) { /* Save field if valid and the current and old field type match. */ $fieldform->getInfo($vars, $info); try { $save_field = $injector->getInstance('Ulaform_Factory_Driver')->create()->saveField($info); $notification->push(_("Field saved."), 'horde.success'); Horde::url('fields.php', true)->add('form_id', $info['form_id'])->redirect(); } catch (Horde_Exception $e) { $notification->push(sprintf(_("Error saving field. %s."), $e->getMessage()), 'horde.error'); } } /* Get a field list. */ try { $fields_list = $ulaform_driver->getFieldsList($form_id); if (empty($fields_list)) { /* Show a warning if no fields present. */
$param['readonly'] = isset($param['readonly']) ? $param['readonly'] : false; $param['desc'] = isset($param['desc']) ? $param['desc'] : null; $param['params'] = isset($param['params']) ? $param['params'] : null; $form->addVariable($param['label'], 'form_params[' . $id . ']', $param['type'], $param['required'], $param['readonly'], $param['desc'], $param['params']); } } /* Set default language for the form. */ $v = $form->addVariable(_("Default language"), 'form_params[language]', 'enum', false, false, null, array($registry->nlsconfig->languages, _("-- default configured --"))); $v->setOption('htmlchars', true); /* TODO: set up Ulaform to insert any javascript saved here into the form. */ $v = $form->addVariable(_("Javascript to execute on form \"submit\":"), 'form_onsubmit', 'longtext', false, false, null, array(3, 40)); $v->setHelp('on-submit'); /* Set up the action choice fields. */ $vars->set('old_form_action', $form_action); if ($formname && !$changed_action) { $form->validate($vars); if ($form->isValid()) { $form->getInfo($vars, $info); try { $form_id = $ulaform_driver->saveForm($info); $notification->push(_("Form details saved."), 'horde.success'); Horde::url('forms.php', true)->redirect(); } catch (Ulaform_Exception $e) { $notification->push(sprintf(_("Error saving form. %s."), $e->getMessage()), 'horde.error'); } } } /* Render the form. */ $view = new Horde_View(array('templatePath' => ULAFORM_TEMPLATES)); Horde::startBuffer(); $form->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('edit.php'), 'post');
require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('ulaform', array('admin' => true)); $delvars = Horde_Variables::getDefaultVariables(); $form_id = $delvars->get('form_id'); $form_submit = $delvars->get('submitbutton'); /* Set up the forms. */ $ulaform_driver = $injector->getInstance('Ulaform_Factory_Driver')->create(); $viewvars = new Horde_Variables($ulaform_driver->getForm($form_id)); $viewform = new Horde_Form($viewvars, _("Form Details")); $delform = new Horde_Form($delvars, _("Delete this form?")); $viewform->addVariable(_("Name"), 'form_name', 'text', false); $viewform->addVariable(_("Action"), 'form_action', 'email', false); $delform->setButtons(array(_("Delete"), _("Do not delete"))); $delform->addHidden('', 'form_id', 'int', true); if ($form_submit == _("Delete")) { $delform->validate($delvars); if ($delform->isValid()) { $delform->getInfo($delvars, $info); try { $deleteform = $ulaform_driver->deleteForm($info['form_id']); $notification->push(_("Form deleted."), 'horde.success'); Horde::url('forms.php', true)->redirect(); } catch (Ulaform_Exception $e) { $notification->push(sprintf(_("Error deleting form. %s."), $e->getMessage()), 'horde.error'); } } } elseif (!empty($form_submit)) { $notification->push(_("Form has not been deleted."), 'horde.message'); Horde::url('forms.php', true)->redirect(); } /* Render the form. */
public function run() { extract($this->_params, EXTR_REFS); $form_submit = $vars->get('submitbutton'); $channel_id = $vars->get('channel_id'); $story_id = $vars->get('id'); /* Driver */ $driver = $GLOBALS['injector']->getInstance('Jonah_Driver'); /* Fetch the channel details, needed for later and to check if valid * channel has been requested. */ try { $channel = $driver->getChannel($channel_id); } catch (Exception $e) { $notification->push(sprintf(_("Story editing failed: %s"), $e->getMessage()), 'horde.error'); Horde::url('channels/index.php', true)->redirect(); exit; } /* Check permissions. */ if (!Jonah::checkPermissions(Jonah::typeToPermName($channel['channel_type']), Horde_Perms::DELETE, $channel_id)) { $notification->push(_("You are not authorised for this action."), 'horde.warning'); throw new Horde_Exception_AuthenticationFailure(); } try { $story = $driver->getStory($channel_id, $story_id); } catch (Exception $e) { $notification->push(_("No valid story requested for deletion."), 'horde.message'); Horde::url('channels/index.php', true)->redirect(); exit; } /* If not yet submitted set up the form vars from the fetched story. */ if (empty($form_submit)) { $vars = new Horde_Variables($story); } $title = sprintf(_("Delete News Story \"%s\"?"), $vars->get('title')); $form = new Horde_Form($vars, $title); $form->setButtons(array(_("Delete"), _("Do not delete"))); $form->addHidden('', 'channel_id', 'int', true, true); $form->addHidden('', 'id', 'int', true, true); $form->addVariable(_("Really delete this News Story?"), 'confirm', 'description', false); if ($form_submit == _("Delete")) { if ($form->validate($vars)) { $form->getInfo($vars, $info); try { $delete = $driver->deleteStory($info['channel_id'], $info['id']); $notification->push(_("The story has been deleted."), 'horde.success'); Horde::url('stories/index.php', true)->add('channel_id', $channel_id)->setRaw(true)->redirect(); exit; } catch (Exception $e) { $notification->push(sprintf(_("There was an error deleting the story: %s"), $e->getMessage()), 'horde.error'); } } } elseif (!empty($form_submit)) { $notification->push(_("Story has not been deleted."), 'horde.message'); $url = Horde::url('stories/index.php', true)->add('channel_id', $channel_id)->setRaw(true); Horde::url('stories/index.php', true)->add('channel_id', $channel_id)->setRaw(true)->redirect(); exit; } $GLOBALS['page_output']->header(array('title' => $title)); $notification->notify(array('listeners' => 'status')); $form->renderActive(null, $vars, Horde::url('stories/delete.php'), 'post'); $GLOBALS['page_output']->footer(); }
/** * Allows other Horde apps to remove messages. * * The forum name is constructed by just the $forum_name variable * under the data root 'agora.forums.<app>'. It is up to the apps * themselves to make sure that the forum name is unique. * * @access private * * @param string $scope The application which is posting this message. * @param string $forum_name The unique name for the forum. * @param string $callback A callback method of the specified application * that gets called to make sure that posting to * this forum is allowed. * @param array $params Any parameters for the forum message posting. * <pre> * message_id - An existing message to delete * </pre> * @param array $variables A hash with all variables of a submitted form * generated by this method. * * @return mixed Returns either the rendered Horde_Form for posting a message * or PEAR_Error object on error, or true in case of a * successful post. */ public function removeMessage($scope, $forum_name, $callback, $params = array(), $variables = null) { global $registry; /* Check if posting messages is allowed. */ $check = $registry->callByPackage($scope, $callback, array($forum_name)); if ($check instanceof PEAR_Error || !$check) { return ''; } /* Create a separate notification queue. */ $queue = Horde_Notification::singleton('agoraRemoveMessage'); $queue->attach('status'); /* Set up the forums object. */ $forums = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope); $params['forum_id'] = $forums->getForumId($forum_name); if (empty($params['forum_id'])) { return PEAR::raiseError(sprintf(_("Forum %s does not exist."), $forum_name)); } /* Set up the messages control object. */ $messages = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope, $params['forum_id']); if ($messages instanceof PEAR_Error) { PEAR::raiseError(sprintf(_("Could not delete the message. %s"), $messages->getMessage())); } /* Check delete permissions. */ if (!$messages->hasPermission(Horde_Perms::DELETE)) { return PEAR::raiseError(sprintf(_("You don't have permission to delete messages in forum %s."), $params['forum_id'])); } /* Get the message to be deleted. */ $message = $messages->getMessage($params['message_id']); if ($message instanceof PEAR_Error) { return PEAR::raiseError(sprintf(_("Could not delete the message. %s"), $message->getMessage())); } /* Set up the form. */ $vars = new Horde_Variables($variables); $form = new Horde_Form($vars, sprintf(_("Delete \"%s\" and all replies?"), $message['message_subject']), 'delete_agora_message'); $form->setButtons(array(_("Delete"), _("Cancel"))); $form->addHidden('', 'forum_id', 'int', true); $form->addHidden('', 'message_id', 'int', true); if ($form->validate()) { if ($vars->get('submitbutton') == _("Delete")) { $result = $messages->deleteMessage($params['message_id']); if ($result instanceof PEAR_Error) { $queue->push(sprintf(_("Could not delete the message. %s"), $result->getMessage()), 'horde.error'); } else { $queue->push(_("Message deleted."), 'horde.success'); $count = $messages->countMessages(); $registry->callByPackage($scope, $callback, array($forum_name, 'messages', $count)); } } else { $queue->push(_("Message not deleted."), 'horde.message'); } Horde::startBuffer(); $queue->notify(array('listeners' => 'status')); return Horde::endBuffer(); } Horde::startBuffer(); $form->renderActive(null, null, null, 'post', null, false); return Horde::endBuffer(); }
public function validate(&$vars) { if (!$GLOBALS['registry']->getAuth()) { $this->setError('_auth', _("Permission Denied.")); } return parent::validate($vars); }
$desc = sprintf($desc, $type, $user_name); if ($aliasesCount) { $desc .= ' ' . sprintf(ngettext("Account has %d alias.", "Account has %d aliases.", $aliasesCount), $aliasesCount); } if ($forwardsCount) { $desc .= ' ' . sprintf(ngettext("Account is the target of %d forward.", "Account is the target of %d forwards.", $forwardsCount), $forwardsCount); } if ($groupsCount) { $desc .= ' ' . sprintf(ngettext("Account belongs to %d group.", "Account belongs to %d groups.", $groupsCount), $groupsCount); } $form->addVariable($desc, 'description', 'description', false); if ($vars->get('submitbutton') == _("Do not delete")) { $notification->push(_("User not deleted."), 'horde.message'); Horde::url('users/index.php', true)->add('domain_id', $domain['id'])->redirect(); } if ($vars->get('submitbutton') == _("Delete") && $form->validate($vars)) { $form->getInfo($vars, $info); switch ($type) { case 'alias': $deleteInfo = array('address' => $address['destination'], 'alias' => $user_id); try { $vilma->driver->deleteAlias($deleteInfo); $notification->push(_("Alias deleted."), 'horde.success'); } catch (Exception $e) { $notification->push(sprintf(_("Error deleting alias. %s."), $e->getMessage()), 'horde.error'); } Horde::url('users/index.php', true)->add('domain_id', $domain['id'])->redirect(); case 'forward': $deleteInfo = array('address' => $address['destination'], 'forward' => $user_id); try { $vilma->driver->deleteForward($deleteInfo);
$vars = Horde_Variables::getDefaultVariables(); $virtual_id = $vars->virtual_id; $formname = $vars->formname; $virtual = $vilma->driver->getVirtual($virtual_id); $domain = Vilma::stripDomain($virtual['virtual_email']); $domain = $vilma->driver->getDomainByName($domain); if ($vars->submitbutton == _("Do not delete")) { $notification->push(_("Virtual email not deleted."), 'horde.message'); Horde::url('virtuals/index.php')->add('domain_id', $domain['domain_id'])->redirect(); } $form = new Horde_Form($vars, _("Delete Virtual Email Address")); /* Set up the form. */ $form->setButtons(array(_("Delete"), _("Do not delete"))); $form->addHidden('', 'virtual_id', 'text', false); $form->addVariable(sprintf(_("Delete the virtual email address \"%s\" => \"%s\"?"), $virtual['virtual_email'], $virtual['virtual_destination']), 'description', 'description', false); if ($vars->submitbutton == _("Delete") && $form->validate($vars)) { $form->getInfo($vars, $info); try { $delete = $vilma->driver->deleteVirtual($info['virtual_id']); $notification->push(_("Virtual email deleted."), 'horde.success'); Horde::url('virtuals/index.php', true)->add('domain_id', $domain['domain_id'])->redirect(); } catch (Exception $e) { Horde::log($e); $notification->push(sprintf(_("Error deleting virtual email. %s."), $e->getMessage()), 'horde.error'); } } /* Render the form. */ $renderer = new Horde_Form_Renderer(); $page_output->header(); $notification->notify(array('listeners' => 'status')); $form->renderActive($renderer, $vars, Horde::url('virtuals/delete.php'), 'post');
<?php /** * Copyright 2005-2015 Horde LLC (http://www.horde.org/) * * See the enclosed file LICENSE for license information (BSD). If you * did not receive this file, see http://www.horde.org/licenses/bsdl.php. * * @author Chuck Hagenbuch <*****@*****.**> * @author Jan Schneider <*****@*****.**> */ require_once __DIR__ . '/lib/Application.php'; $hermes = Horde_Registry::appInit('hermes'); $vars = Horde_Variables::getDefaultVariables(); $form = new Horde_Form($vars, _("Stop Watch")); $form->addVariable(_("Stop watch description"), 'description', 'text', true); if ($form->validate($vars)) { Hermes::newTimer($vars->get('description')); echo Horde::wrapInlineScript(array('var t = ' . Horde_Serialize::serialize(sprintf(_("The stop watch \"%s\" has been started and will appear in the menu at the next refresh."), $vars->get('description')), Horde_Serialize::JSON) . ';', 'alert(t);', 'window.close();')); exit; } $page_output->topbar = $page_output->sidebar = false; $page_output->header(array('title' => _("Stop Watch"))); $form->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('start.php'), 'post'); $page_output->footer();
} $vars = Horde_Variables::getDefaultVariables(); $form = new Horde_Form($vars, $title); $form->setButtons(array(array('class' => 'horde-default', 'value' => _("Report")), array('class' => 'horde-cancel', 'value' => _("Cancel")))); $enum = array('advertisement' => _("Advertisement content"), 'terms' => _("Terms and conditions infringement"), 'offensive' => _("Offensive content"), 'copyright' => _("Copyright infringement")); $form->addVariable($gallery->get('name'), 'name', 'description', false); $form->addVariable($gallery->get('desc'), 'desc', 'description', false); $form->addHidden('', 'gallery', 'text', true, true); $vars->set('gallery', $gallery_id); $form->addVariable(_("Report type"), 'type', 'radio', true, false, null, array($enum)); $form->addVariable(_("Report reason"), 'reason', 'longtext', true); $gallery_id = Horde_Util::getFormData('id'); if ($vars->get('submitbutton') == _("Cancel")) { Horde::url('', true)->redirect(); } if ($form->validate()) { if (Horde_Util::getFormData('submitbutton') == _("Report")) { $report = Ansel_Report::factory(); $body = _("Gallery Name") . ': ' . $gallery->get('name') . "\n" . _("Gallery Description") . ': ' . $gallery->get('desc') . "\n" . _("Gallery Id") . ': ' . $gallery->id . "\n" . _("Report type") . ': ' . $enum[$vars->get('type')] . "\n" . _("Report reason") . ': ' . $vars->get('reason') . "\n" . $return_url; try { $result = $report->report($body); $notification->push(_("Gallery was reported."), 'horde.success'); } catch (Horde_Exception $e) { $notification->push(_("Gallery was not reported.") . ' ' . $result->getMessage(), 'horde.error'); } } else { $notification->push(_("Gallery was not reported."), 'horde.warning'); } $return_url->redirect(); exit; }
*/ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('ulaform', array('admin' => true)); /* Get some variables. */ $vars = Horde_Variables::getDefaultVariables(); $form_id = $vars->get('form_id'); $formname = $vars->get('formname'); $fields = $ulaform_driver->getFieldsArray($form_id); /* Set up the form object. */ $sortform = new Horde_Form($vars, _("Sort Fields")); /* Set up the form. */ $sortform->setButtons(_("Save")); $sortform->addVariable(_("Select the sort order of the fields"), 'field_order', 'sorter', false, false, null, array($fields, 12)); $sortform->addHidden('', 'form_id', 'int', true); if ($formname) { $sortform->validate($vars); if ($sortform->isValid()) { $sortform->getInfo($vars, $info); try { $sort = $injector->getInstance('Ulaform_Factory_Driver')->create()->sortFields($info); $notification->push(_("Field sort order saved."), 'horde.success'); Horde::url('fields.php', true)->add('form_id', $form_id)->redirect(); } catch (Horde_Exception $e) { $notification->push(sprintf(_("Error saving fields. %s."), $e->getMessage()), 'horde.error'); } } } /* Render the form. */ $view = new Horde_View(array('templatePath' => ULAFORM_TEMPLATES)); Horde::startBuffer(); $sortform->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('sortfields.php'), 'post');
$auth = $injector->getInstance('Horde_Core_Factory_Auth')->create(); if (!$auth->hasCapability('resetpassword')) { $notification->push(_("Cannot update password, contact your administrator."), 'horde.error'); throw new Horde_Exception_AuthenticationFailure(); } */ $title = _("Change Your Password"); $vars = Horde_Variables::getDefaultVariables(); $form = new Horde_Form($vars, $title, 'password'); $form->setButtons(_("Continue")); $form->addVariable(_("Current password"), 'old', 'password', true); $form->addVariable(_("Choose a password"), 'new', 'passwordconfirm', true, false, _("type the password twice to confirm")); // Use a do-while to allow easy breaking if an error is found. do { // Validate the form if (!$form->validate()) { break; } $form->getInfo(null, $info); // Check old and new passwords if ($info['old'] == $info['new']) { $notification->push(_("Your new password must be different from your current password"), 'horde.warning'); break; } // Check old password if ($info['old'] == $info['new']) { $notification->push(_("Your old password didn't match"), 'horde.warning'); break; } // Check some password policy $password_policy = Horde::loadConfiguration('password_policy.php', 'password_policy', 'folks');
/** * Validates the form, checking if it really has been submitted by calling * isSubmitted() and if true does any onSubmit() calls for variable types * in the form. The _submitted variable is then rechecked. * * @param Variables $vars A Variables instance, optional since Horde * 3.2. * @param boolean $canAutofill Can the form be valid without being * submitted? * * @return boolean True if the form is valid. */ public function validate($vars, $canAutoFill = false) { $this->_addParameters($vars); return parent::validate($vars, $canAutoFill); }