getInfo() public method

Fetch the field values of the submitted form.
public getInfo ( Variables $vars, array &$info )
$vars Variables A Variables instance, optional since Horde 3.2.
$info array Array to be filled with the submitted field values.
Esempio n. 1
0
 /**
  * Trick getInfo to catch pager parameters
  */
 function getInfo($vars, &$info)
 {
     parent::getInfo($vars, $info);
     if (!$this->isSubmitted()) {
         foreach ($info as $key => $val) {
             $info[$key] = $vars->get($key);
         }
     }
 }
Esempio n. 2
0
 /**
  * Fetch the field values of the submitted form.
  *
  * @param Variables $vars  A Variables instance (Needed?).
  * @param array $info      Array to be filled with the submitted field
  *                         values.
  */
 public function getInfo($vars, &$info)
 {
     parent::getInfo($vars, $info);
     if (!isset($info['user_name']) && isset($info['extra']['user_name'])) {
         $info['user_name'] = $info['extra']['user_name'];
     }
     if (!isset($info['password']) && isset($info['extra']['password'])) {
         $info['password'] = $info['extra']['password'];
     }
 }
Esempio n. 3
0
File: Ui.php Progetto: horde/horde
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * 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();
 }
Esempio n. 5
0
 /**
  * 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());
 }
Esempio n. 6
0
 /**
  */
 function getInfo(&$vars, &$info)
 {
     parent::getInfo($vars, $info);
     /* Build release date. */
     if (!empty($info['publish_now'])) {
         $info['published'] = time();
     } elseif (!empty($info['publish_date'])) {
         $info['published'] = mktime((int) $info['publish_time']['hour'], (int) $info['publish_time']['minute'], 0, date('n', $info['publish_date']), date('j', $info['publish_date']), date('Y', $info['publish_date']));
     } else {
         $info['published'] = null;
     }
     unset($info['publish_now']);
     unset($info['publish_date']);
     unset($info['publish_time']);
 }
Esempio n. 7
0
 /**
  * Fetch the field values of the submitted form.
  *
  * @param Horde_Variables $vars  A Horde_Variables instance, optional since Horde 3.2.
  * @param array           $info  Array to be filled with the submitted field
  *                               values.
  */
 public function getInfo($vars, &$info)
 {
     parent::getInfo($vars, $info);
     if (empty($info['queue'])) {
         $info['queue'] = array_keys(Whups::permissionsFilter($GLOBALS['whups_driver']->getQueues(), 'queue', Horde_Perms::READ, $GLOBALS['registry']->getAuth(), $GLOBALS['registry']->getAuth()));
     } else {
         $info['queue'] = array($info['queue']);
     }
     if (empty($info['states'])) {
         unset($info['states']);
     }
     // ... if we were given a set of states
     if (isset($info['states'])) {
         // collect them into a list of state_id
         $info['state_id'] = array();
         foreach ($info['states'] as $states) {
             if (isset($states)) {
                 // because null === array_merge(array, null)
                 $info['state_id'] = array_merge($info['state_id'], $states);
             }
         }
         unset($info['states']);
     }
     // Remove any queues that don't have a state selected.
     $types = array();
     foreach ($info['queue'] as $queue) {
         foreach ($GLOBALS['whups_driver']->getTypeIds($queue) as $type) {
             $types[$type][$queue] = true;
         }
     }
     $queues = array();
     foreach ($info['state_id'] as $stateId) {
         $state = $GLOBALS['whups_driver']->getState($stateId);
         if (isset($types[$state['type']])) {
             $queues = array_merge($queues, array_keys($types[$state['type']]));
         }
     }
     $info['queue'] = array_intersect($info['queue'], $queues);
 }
Esempio n. 8
0
 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();
 }
Esempio n. 9
0
 * Copyright 2007 Obala d.o.o. (http://www.obala.si/)
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 *
 * @author Duck <*****@*****.**>
 */
require_once __DIR__ . '/tabs.php';
$vars = Horde_Variables::getDefaultVariables();
$title = _("Forgot your username?");
$form = new Horde_Form($vars, $title);
$form->setButtons(_("Send me my username"));
$form->addVariable(_("Your email"), 'email', 'email', true);
/* Validate the form. */
if ($form->validate()) {
    $form->getInfo(null, $info);
    $users = $folks_driver->getUsers(array('email' => $info['email']));
    if ($users instanceof PEAR_Error) {
        $notification->push($users);
    } elseif (empty($users) || count($users) != 1) {
        $notification->push(_("Could not find any username with this email."), 'horde.warning');
    } else {
        $users = current($users);
        $body = sprintf(_("Your username on %s %s is: %s. \n\n It was requested by %s on %s"), $registry->get('name', 'horde'), Horde::url($registry->get('webroot', 'horde'), true), $users['user_uid'], $_SERVER['REMOTE_ADDR'], date('Ymd H:i:s'));
        Folks::sendMail($info['email'], _("Your username was requested"), $body);
        $notification->push(sprintf(_("Your username was sent, check your email (%s)."), $users['user_email']), 'horde.success');
        throw new Horde_Exception_AuthenticationFailure();
    }
}
$page_output->header(array('title' => $title));
require FOLKS_TEMPLATES . '/menu.inc';
Esempio n. 10
0
            $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'])) {
                    foreach ($info['extra'] as $field => $value) {
                        $credentials[$field] = $value;
Esempio n. 11
0
        $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 {
            $mail->send($injector->getInstance('Horde_Mail'));
Esempio n. 12
0
$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. */
        $notification->push(_("No available fields."), 'horde.warning');
    }
Esempio n. 13
0
$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. */
$renderer = new Horde_Form_Renderer();
Horde::startBuffer();
Esempio n. 14
0
 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();
 }