renderActive() public méthode

Renders the form for editing.
public renderActive ( Horde_Form_Renderer $renderer = null, Variables $vars = null, string $action = '', string $method = 'get', string $enctype = null, boolean $focus = true )
$renderer Horde_Form_Renderer A renderer instance, optional since Horde 3.2.
$vars Variables A Variables instance, optional since Horde 3.2.
$action string The form action (url).
$method string The form method, usually either 'get' or 'post'.
$enctype string The form encoding type. Determined automatically if null.
$focus boolean Focus the first form field?
Exemple #1
0
 /**
  * Renders the form for editing.
  *
  * @param Horde_Form_Renderer $renderer  A renderer instance, optional
  *                                       since Horde 3.2.
  * @param Variables $vars                A Variables instance, optional
  *                                       since Horde 3.2.
  * @param string $action                 The form action (url).
  * @param string $method                 The form method, usually either
  *                                       'get' or 'post'.
  * @param string $enctype                The form encoding type. Determined
  *                                       automatically if null.
  * @param boolean $focus                 Focus the first form field?
  */
 public function renderActive($renderer, $vars, $action, $method = 'get', $enctype = null, $focus = true)
 {
     if ($vars->get('old_datatype') === null) {
         $this->_addParameters($vars);
     }
     parent::renderActive($renderer, $vars, $action, $method, $enctype, $focus);
 }
Exemple #2
0
 public function renderActive()
 {
     $url = Horde::url('list.php');
     if ($this->_vars->get('smart_id')) {
         // Editing an existing smartlist.
         $url->add(array('actionID' => 'smart', 'list' => $this->_vars->get('smart_id'), 'tab_name' => $this->_vars->get('smart_id')));
     }
     return parent::renderActive($this->getRenderer(array('varrenderer_driver' => array('nag', 'nag'))), $this->_vars, $url->setRaw(true), 'post');
 }
Exemple #3
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();
 }
Exemple #4
0
    $notification->push(_("Password changed."), 'horde.success');
    // reset credentials so user is not forced to relogin
    if ($registry->getAuthCredential('password') == $info['old']) {
        $registry->setAuthCredential('password', $info['new']);
    }
} while (false);
// update password reminder prefs
if (Horde_Util::getPost('formname') == 'security') {
    if ($prefs->getValue('security_question') != Horde_Util::getPost('security_question')) {
        $prefs->setValue('security_question', Horde_Util::getPost('security_question'));
    }
    if ($prefs->getValue('security_answer') != Horde_Util::getPost('security_answer')) {
        $prefs->setValue('security_answer', Horde_Util::getPost('security_answer'));
    }
    $notification->push(_("Your securiy questions was updated."), 'horde.success');
}
$form_security = new Horde_Form($vars, _("Security question used when reseting password"), 'security');
$form_security->setButtons(_("Continue"), _("Reset"));
if (!$prefs->isLocked('security_question')) {
    $v = $form_security->addVariable(_("Security question"), 'security_question', 'text', true);
    $v->setDefault($prefs->getValue('security_question'));
}
$v = $form_security->addVariable(_("Security answer"), 'security_answer', 'text', true);
$v->setDefault($prefs->getValue('security_answer'));
$page_output->header(array('title' => $title));
require FOLKS_TEMPLATES . '/menu.inc';
echo $tabs->render('password');
$form->renderActive(null, null, null, 'post');
echo '<br />';
$form_security->renderActive(null, null, null, 'post');
$page_output->footer();
Exemple #5
0
$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();
$delform->renderActive($renderer, $delvars, Horde::url('delete.php'), 'post');
$viewform->renderInactive($renderer, $viewvars);
$main = Horde::endBuffer();
$view = new Horde_View(array('templatePath' => ULAFORM_TEMPLATES));
$view->main = $main;
$page_output->header();
$notification->notify(array('listeners' => 'status'));
echo $view->render('main');
$page_output->footer();
Exemple #6
0
 public function renderActive()
 {
     global $conf;
     return parent::renderActive($this->getRenderer(array('varrenderer_driver' => array('nag', 'nag'))), $this->_vars, Horde::url($conf['urls']['pretty'] == 'rewrite' ? 't/save' : 'task/save.php'), 'post');
 }
Exemple #7
0
    $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($channel_id);
    if (empty($channel['channel_story_url'])) {
        $story_url = Horde::url('stories/view.php', true)->add(array('channel_id' => '%c', 'id' => '%s'));
    } else {
        $story_url = $channel['channel_story_url'];
    }
    $story_url = str_replace(array('%25c', '%25s'), array('%c', '%s'), $story_url);
    $story_url = str_replace(array('%c', '%s', '&amp;'), array($channel_id, $story['id'], '&'), $story_url);
    if ($info['include'] == 0) {
        require_once 'Horde/MIME/Part.php';
        /* TODO: Create a "URL link" MIME part instead. */
        $message_part = new MIME_Part('text/plain');
        $message_part->setContents($message_part->replaceEOL($story_url));
        $message_part->setDescription(_("Story Link"));
    } else {
        $message_part = Jonah::getStoryAsMessage($story);
    }
    $result = _mail($message_part, $info['from'], $info['recipients'], $info['subject'], $info['message']);
    if (is_a($result, 'PEAR_Error')) {
        $notification->push(sprintf(_("Unable to send story: %s"), $result->getMessage()), 'horde.error');
    } else {
        $notification->push(_("The story was sent successfully."), 'horde.success');
        header('Location: ' . $story_url);
        exit;
    }
}
$page_output->topbar = $page_output->sidebar = false;
$page_output->header(array('title' => $title));
$notification->notify(array('listeners' => 'status'));
$form->renderActive(null, $vars, Horde::url('stories/share.php'), 'post');
$page_output->footer();
Exemple #8
0
 public function renderActive()
 {
     return parent::renderActive($this->getRenderer(array('varrenderer_driver' => array('kronolith', 'kronolith'))), $this->_vars);
 }
Exemple #9
0
<?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();
Exemple #10
0
$form->setButtons(array(_("Move"), _("Cancel")));
$form->addHidden('', 'agora', 'text', false);
$form->addHidden('', 'scope', 'text', false);
$forums_list = Agora::formatCategoryTree($messages->getForums(0, false));
$v =& $form->addVariable(_("Forum"), 'new_forum_id', 'enum', true, false, null, array($forums_list));
$v->setDefault($forum_id);
/* Validate the form. */
if ($form->validate()) {
    $form->getInfo($vars, $info);
    if ($vars->get('submitbutton') == _("Move")) {
        $move = $messages->moveThread($message_id, $info['new_forum_id']);
        if ($move instanceof PEAR_Error) {
            $notification->push($move->getMessage(), 'horde.error');
        } else {
            $notification->push(sprintf(_("Thread %s moved to from forum %s to %s."), $message_id, $forum_id, $info['new_forum_id']), 'horde.success');
            header('Location: ' . Agora::setAgoraId($info['new_forum_id'], $message_id, Horde::url('messages/index.php', true), $scope));
            exit;
        }
    }
}
/* Template object. */
$view = new Agora_View();
Horde::startBuffer();
$form->renderActive(null, $vars, Horde::url('messages/move.php'), 'post');
$view->formbox = Horde::endBuffer();
$view->message_subject = $message['message_subject'];
$view->message_author = $message['message_author'];
$view->message_body = Agora_Driver::formatBody($message['body']);
$page_output->header();
echo $view->render('messages/edit');
$page_output->footer();
Exemple #11
0
                 $parent .= '|' . $name;
             }
         }
         break;
     case 'search':
         /* Create Form */
         $searchForm = new Horde_Form($vars, null, 'search');
         $searchForm->setButtons(_("Search"));
         $searchForm->addHidden('sidebar', 'show', 'text', false);
         $searchForm->addHidden('', 'module', 'text', false);
         $searchForm->addHidden('', 'side_show', 'text', false);
         $searchForm->addVariable(_("Keyword"), 'keyword', 'text', false, false, null, array(null, 20));
         $renderer = new Horde_Form_Renderer();
         $renderer->setAttrColumnWidth('50%');
         Horde::startBuffer();
         $searchForm->renderActive($renderer, $vars, $sidebar_url->copy()->setRaw(true), 'post');
         $contents = Horde::endBuffer() . '<br />';
         $keywords = $vars->get('keyword');
         if (!empty($keywords)) {
             $results = $help->search($keywords);
             foreach ($results as $id => $title) {
                 if (empty($title)) {
                     continue;
                 }
                 $contents .= Horde::link($base_url->copy()->add(array('show' => 'entry', 'topic' => $id)), null, null, 'help_main') . htmlspecialchars($title) . "</a><br />\n";
             }
         }
         break;
 }
 require HORDE_TEMPLATES . '/help/sidebar.inc';
 break;
Exemple #12
0
    }
    $url = Agora::setAgoraId($forum_id, null, Horde::url('ban.php', true), $scope);
    header('Location: ' . $url);
    exit;
}
/* Get the list of banned users. */
$delete = Horde::url('ban.php')->add(array('action' => 'delete', 'scope' => $scope, 'forum_id' => $forum_id));
$banned = $forums->getBanned();
foreach ($banned as $user => $level) {
    $banned[$user] = Horde::link($delete->add('user', $user), _("Delete")) . $user . '</a>';
}
$title = _("Ban");
$vars = Horde_Variables::getDefaultVariables();
$form = new Horde_Form($vars, $title);
$form->addHidden('', 'scope', 'text', false);
$form->addHidden('', 'agora', 'text', false);
$form->addHidden('', 'action', 'text', false);
$vars->set('action', 'add');
$form->addVariable(_("User"), 'user', 'text', true);
$view = new Agora_View();
Horde::startBuffer();
$form->renderActive(null, null, Horde::url('ban.php'), 'post');
$view->formbox = Horde::endBuffer();
Horde::startBuffer();
$notification->notify(array('listeners' => 'status'));
$view->notify = Horde::endBuffer();
$view->banned = $banned;
$view->forum = $forums->getForum();
$page_output->header(array('title' => $title));
echo $view->render('ban');
$page_output->footer();
Exemple #13
0
$form->addHidden('', 'virtual_id', 'int', false);
$form->addHidden('', 'domain', 'text', false);
$form->addVariable(_("Virtual Email"), 'stripped_email', 'text', true, false, sprintf(_("Enter a virtual email address @%s and then indicate below where mail sent to that address is to be delivered. The address must begin with an alphanumerical character, it must contain only alphanumerical and '._-' characters, and must end with an alphanumerical character."), $domain), array('~^[a-zA-Z0-9]{1,1}[a-zA-Z0-9._-]*[a-zA-Z0-9]$~'));
$var =& $form->addVariable(_("Destination type"), 'destination_type', 'enum', true, false, null, array(array('local' => _("Local user"), 'remote' => _("Remote address"))));
$var->setAction(Horde_Form_Action::factory('reload'));
if ($vars->destination_type == 'remote') {
    $form->addVariable(_("Remote e-mail address"), 'virtual_destination', 'email', true, false);
} else {
    $form->addVariable(_("Destination"), 'virtual_destination', 'enum', true, false, null, array($user_list, true));
}
if ($form->validate($vars)) {
    $form->getInfo($vars, $info);
    $info['stripped_email'] = Horde_String::lower($info['stripped_email']);
    if ($info['destination_type'] == 'remote') {
        $info['virtual_destination'] = Horde_String::lower($info['virtual_destination']);
    }
    try {
        $virtual_id = $vilma->driver->saveVirtual($info, $domain);
        $notification->push(_("Virtual email saved."), 'horde.success');
        Horde::url('virtuals/index.php', true)->add('user', $info['virtual_destination'])->redirect();
    } catch (Exception $e) {
        Horde::log($e);
        $notification->push(sprintf(_("Error saving 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/edit.php'), 'post');
$page_output->footer();
Exemple #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();
 }
Exemple #15
0
$form->addHidden('', 'fax_id', 'int', false);
$form->addVariable(_("Fax destination"), 'fax_number', 'text', true, false, null, array('/^\\d+$/'));
if ($form->validate($vars)) {
    $form->getInfo($vars, $info);
    $send = $hylax->storage->send($info['fax_id'], $info['fax_number']);
    if (is_a($send, 'PEAR_Error')) {
        $notification->push(sprintf(_("Could not send fax ID \"%s\". %s"), $info['fax_id'], $send->getMessage()), 'horde.error');
    } else {
        $notification->push(sprintf(_("Fax ID \"%s\" submitted successfully."), $info['fax_id']), 'horde.success');
    }
    Horde::url($url, true)->redirect();
}
/* Get the preview pages. */
$pages = Hylax::getPages($fax_id, $fax['fax_pages']);
/* Render the form. */
require_once 'Horde/Form/Renderer.php';
$renderer = new Horde_Form_Renderer();
Horde::startBuffer();
$form->renderActive($renderer, $vars, Horde::url('send.php'), 'post');
$send_form = Horde::endBuffer();
/* Set up template. */
$template = $injector->createInstance('Horde_Template');
$template->set('form', $send_form);
$template->set('pages', $pages);
$template->set('menu', $menu->getMenu());
Horde::startBuffer();
$notification->notify(array('listeners' => 'status'));
$template->set('notify', Horde::endBuffer());
$page_output->header(array('title' => $title));
echo $template->fetch(HYLAX_TEMPLATES . '/fax/fax.html');
$page_output->footer();
Exemple #16
0
    $vars = Horde_Variables::getDefaultVariables();
    $ftpform = new Horde_Form($vars);
    $ftpform->setButtons(_("Upload"), true);
    $ftpform->addVariable(_("Username"), 'username', 'text', true, false, null, array('', 20));
    $ftpform->addVariable(_("Password"), 'password', 'password', false);
    if ($ftpform->validate($vars)) {
        $ftpform->getInfo($vars, $info);
        $upload = _uploadFTP($info);
        if ($upload) {
            $notification->push(_("Uploaded all application configuration files to the server."), 'horde.success');
            Horde::url('admin/config/index.php', true)->redirect();
        }
    }
    /* Render the form. */
    Horde::startBuffer();
    $ftpform->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('admin/config/index.php'), 'post');
    $ftpform = Horde::endBuffer();
}
if (file_exists(Horde::getTempDir() . '/horde_configuration_upgrade.php')) {
    /* Action to remove the configuration upgrade PHP script. */
    $url = Horde::url('admin/config/scripts.php')->add('clean', 'tmp');
    $action = _("Remove saved script from server's temporary directory.");
    $actions[] = array('icon' => Horde_Themes_Image::tag('delete.png', array('attr' => array('align' => 'middle'))), 'link' => Horde::link($url) . $action . '</a>');
}
$view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/admin/config'));
$view->actions = $actions;
$view->apps = $apps;
$view->config_outdated = $config_outdated;
$view->ftpform = $ftpform;
$view->schema_outdated = $schema_outdated;
$view->version_action = Horde::url('admin/config/index.php');
Exemple #17
0
 public function render()
 {
     $this->_vars->actionID = 'search_memos';
     parent::renderActive(null, null, Horde::url('list.php'));
 }
Exemple #18
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());
 }
Exemple #19
0
            $id = $alarm = null;
        }
    }
}
$view = new Horde_View(array('templatePath' => HORDE_TEMPLATES . '/admin/alarms'));
$view->addHelper('Text');
if ($horde_alarm instanceof Horde_Alarm_Null) {
    $view->alarms = array();
    $view->error = _("Alarms have been disabled in the configuration");
} else {
    try {
        $alarms = $horde_alarm->globalAlarms();
        $url = Horde::url('admin/alarms.php');
        foreach ($alarms as &$alarm) {
            $url->add('alarm', $alarm['id']);
            $alarm['edit_link'] = $url->link() . htmlspecialchars($alarm['title']) . '</a>';
            $alarm['delete_link'] = $url->copy()->add('delete', 1)->link(array('title' => sprintf(_("Delete \"%s\""), $alarm['title']), 'onclick' => 'return confirm(\'' . addslashes(sprintf(_("Are you sure you want to delete '%s'?"), $alarm['title'])) . '\')')) . Horde_Themes_Image::tag('delete.png') . '</a>';
        }
        $view->alarms = $alarms;
    } catch (Horde_Alarm_Exception $e) {
        $view->alarms = array();
        $view->error = sprintf(_("Listing alarms failed: %s"), $e->getMessage());
    }
}
$page_output->header(array('title' => _("Alarms")));
require HORDE_TEMPLATES . '/admin/menu.inc';
echo $view->render('list');
if (!$horde_alarm instanceof Horde_Alarm_Null) {
    $form->renderActive();
}
$page_output->footer();
Exemple #20
0
                $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);
                $notification->push(_("Forward deleted."), 'horde.success');
            } catch (Exception $e) {
                $notification->push(sprintf(_("Error deleting forward. %s."), $e->getMessage()), 'horde.error');
            }
            Horde::url('users/index.php', true)->add('domain_id', $domain['id'])->redirect();
        default:
            try {
                $vilma->driver->deleteUser($address['address']);
                $notification->push(_("{$type} deleted."), 'horde.success');
            } catch (Exception $e) {
                $notification->push(sprintf(_("Error deleting user. %s."), $e->getMessage()), 'horde.error');
            }
            Horde::url('users/index.php', true)->add('domain_id', $domain['id'])->redirect();
    }
}
/* Render the form. */
$renderer = new Horde_Form_Renderer();
$page_output->header();
$notification->notify(array('listeners' => 'status'));
$form->renderActive($renderer, $vars, Horde::url('users/delete.php'), 'post');
$page_output->footer();
Exemple #21
0
    $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');
    }
} catch (Horde_Exception $e) {
    /* Go back to forms if inexistant form_id, permission denied or another
     * error. */
    $notification->push($e->getMessage(), 'horde.error');
    Horde::url('forms.php', true)->redirect();
}
/* Set up the template. */
$view = new Horde_View(array('templatePath' => ULAFORM_TEMPLATES));
/* Set up the template action links. */
$actions = Horde::link(Horde::url('genhtml.php')->add('form_id', $form_id), _("Generate HTML")) . Horde::img('html.png', _("Generate HTML")) . '</a> ' . Horde::link(Horde::url('display.php')->add('form_id', $form_id), _("Preview")) . Horde::img('display.png', _("Preview")) . '</a> ' . Horde::link(Horde::url('sortfields.php')->add('form_id', $form_id), _("Sort fields")) . Horde::img('sort.png', _("Sort fields")) . '</a>';
$view->actions = $actions;
/* Render the form. */
Horde::startBuffer();
$fieldform->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('fields.php'), 'post');
$view->inputform = Horde::endBuffer();
/* Set up the field list. */
$fieldproperties = array('name' => _("Name"), 'label' => _("Label"), 'type' => _("Type"), 'required' => _("Required"), 'readonly' => _("Read only"), 'desc' => _("Description"));
$view->fieldproperties = $fieldproperties;
$images = array('delete' => Horde::img('delete.png', _("Delete Field"), null), 'edit' => Horde::img('edit.png', _("Edit Field"), ''));
$view->images = $images;
$view->fields = $fields_list;
/* Render the page. */
$page_output->header(array('title' => _("Form Fields")));
$notification->notify(array('listeners' => 'status'));
echo $view->render('fields');
$page_output->footer();
Exemple #22
0
$form = new Horde_Form($vars, $title);
$form->setButtons(_("Continue"));
$form->addVariable(_("Old password"), 'old_password', 'password', true);
$form->addVariable(_("New password"), 'password_1', 'password', true);
$form->addVariable(_("Retype new password"), 'password_2', 'password', true);
if ($form->validate($vars)) {
    $form->getInfo($vars, $info);
    if ($registry->getAuthCredential('password') != $info['old_password']) {
        $notification->push(_("Old password is not correct."), 'horde.error');
    } elseif ($info['password_1'] != $info['password_2']) {
        $notification->push(_("New passwords don't match."), 'horde.error');
    } elseif ($info['old_password'] == $info['password_1']) {
        $notification->push(_("Old and new passwords must be different."), 'horde.error');
    } else {
        try {
            $auth->updateUser($registry->getAuth(), $registry->getAuth(), array('password' => $info['password_1']));
            $notification->push(_("Password changed successfully."), 'horde.success');
            $registry->getLogoutUrl(array('msg' => _("Your password has been succesfully changed. You need to re-login to the system with your new password."), 'reason' => Horde_Auth::REASON_MESSAGE))->redirect();
        } catch (Horde_Auth_Exception $e) {
            $notification->push(sprintf(_("Error updating password: %s"), $e->getMessage()), 'horde.error');
        }
    }
}
$vars->remove('old_password');
$vars->remove('password_1');
$vars->remove('password_2');
$page_output->topbar = $page_output->sidebar = false;
$page_output->header(array('title' => $title));
$notification->notify(array('listeners' => 'status'));
$form->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('services/changepassword.php'), 'post');
$page_output->footer();
Exemple #23
0
    }
    foreach ($forum['moderators'] as $id => $moderator) {
        $delete = $url->add(array('moderator' => $moderator, 'forum_id' => $forum['forum_id']));
        $forums_list[$key]['moderators'][$id] = Horde::link($delete, _("Delete")) . $moderator . '</a>';
    }
}
$title = _("Moderators");
$vars = Horde_Variables::getDefaultVariables();
$form = new Horde_Form($vars, $title);
$form->addHidden('', 'scope', 'text', false);
$form->addHidden('', 'action', 'text', false);
$vars->set('action', 'add');
$form->addVariable(_("Moderator"), 'moderator', 'text', true);
if ($messages->countForums() > 50) {
    $form->addVariable(_("Forum"), 'forum_id', 'int', true);
} else {
    $forums_enum = Agora::formatCategoryTree($messages->getForums(0, false, 'forum_name', 0, !$registry->isAdmin()));
    $form->addVariable(_("Forum"), 'forum_id', 'enum', true, false, false, array($forums_enum));
}
/* Set up template data. */
$view = new Agora_View();
Horde::startBuffer();
$form->renderActive(null, null, Horde::url('moderators.php'), 'post');
$view->formbox = Horde::endBuffer();
Horde::startBuffer();
$notification->notify(array('listeners' => 'status'));
$view->notify = Horde::endBuffer();
$view->forums = $forums_list;
$page_output->header(array('title' => $title));
echo $view->render('moderators');
$page_output->footer();
Exemple #24
0
 /**
  * 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();
 }
Exemple #25
0
    $page_output->addInlineJsVars(array('HordeAdminUserUpdate.pass_error' => _("Passwords must match.")));
}
$page_output->header(array('title' => _("User Administration")));
require HORDE_TEMPLATES . '/admin/menu.inc';
if (isset($update_form) && $auth->hasCapability('list')) {
    $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create($f_user_name);
    require HORDE_TEMPLATES . '/admin/user/update.inc';
} elseif (isset($remove_form) && $auth->hasCapability('list') && $auth->hasCapability('remove')) {
    require HORDE_TEMPLATES . '/admin/user/remove.inc';
} elseif (isset($clear_form)) {
    require HORDE_TEMPLATES . '/admin/user/clear.inc';
} elseif (isset($removequeued_form)) {
    require HORDE_TEMPLATES . '/admin/user/removequeued.inc';
} elseif ($auth->hasCapability('add')) {
    $vars->form = 'add';
    $addForm->renderActive(new Horde_Form_Renderer(), $vars, Horde::selfUrl(), 'post');
    if ($conf['signup']['allow'] && $conf['signup']['approve']) {
        require HORDE_TEMPLATES . '/admin/user/approve.inc';
    }
} else {
    require HORDE_TEMPLATES . '/admin/user/noadd.inc';
}
if ($auth->hasCapability('list')) {
    /* If we aren't supplied with a page number, default to page 0. */
    $page = $vars->get('page', 0);
    $search_pattern = $vars->get('search_pattern', '');
    try {
        $users = $auth->listUsers();
        /* Returns only users that match the specified pattern. */
        $users = preg_grep('/' . $search_pattern . '/', $users);
        sort($users);
Exemple #26
0
$tpl = Horde_Util::getFormData('template', 'default');
if (empty($_covers[$tpl])) {
    throw new Horde_Exception(_("The requested Cover Page does not exist."));
}
/* Load Form Actions */
$action = Horde_Form_Action::factory('submit');
/* Create Form */
$vars = Horde_Variables::getDefaultVariables();
$form = new Horde_Form($vars, _("Compose a new Fax"), 'compose');
$form->setButtons(_("Send"));
$form->appendButtons(_("Preview"));
/* Cover Page section */
$form->addVariable(_("Cover Page"), 'fromhdr', 'header', false);
$form->addVariable(_("Template"), 'template', 'enum', true, false, null, array($covers));
$form->addVariable(_("Fax Number"), 'faxnum', 'text', true);
$form->addVariable(_("Name"), 'name', 'text', false);
$form->addVariable(_("Company"), 'company', 'text', false);
$form->addVariable(_("Subject"), 'subject', 'text', false, false, null, array(false, 60));
$form->addVariable(_("Comment"), 'comment', 'longtext', false, false, null, array(4, 80));
/* Set up template. */
$template = $injector->createInstance('Horde_Template');
$template->set('form', '');
$template->set('menu', Hylax::getMenu('string'));
Horde::startBuffer();
$notification->notify(array('listeners' => 'status'));
$template->set('notify', Horde::endBuffer());
$page_output->header();
echo $template->fetch(HYLAX_TEMPLATES . '/compose/compose.html');
$renderer = new Horde_Form_Renderer();
$form->renderActive($renderer, $vars, Horde::selfURL(), 'post');
$page_output->footer();
Exemple #27
0
$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;
}
$page_output->header(array('title' => $title));
$notification->notify(array('listeners' => 'status'));
$form->renderActive(null, null, null, 'post');
$page_output->footer();
Exemple #28
0
$form->addHidden('', 'scope', 'text', $scope);
$form->addVariable(_("This will delete the forum, any subforums and all relative messages."), 'prompt', 'description', false);
$form->addVariable(_("Forum name"), 'forum_name', 'text', false, true);
$vars->set('forum_name', $forum['forum_name']);
$vars->set('forum_id', $forum_id);
/* Get a list of available forums. */
$forums_list = Agora::formatCategoryTree($forums->getForums($forum_id, false, null, null));
if (!empty($forums_list)) {
    $html = implode('<br />', $forums_list);
    $form->addVariable(_("Subforums"), 'subforums', 'html', false, true);
    $vars->set('subforums', $html);
}
/* Process delete. */
if ($form->validate()) {
    if ($vars->get('submitbutton') == _("Delete")) {
        try {
            // TODO also delete child forums as we state in the GUI
            $forums->deleteForum($vars->get('forum_id'));
            $notification->push(_("Forum deleted."), 'horde.success');
        } catch (Agora_Exception $e) {
            $notification->push(sprintf(_("Could not delete the forum. %s"), $e->getMessage()), 'horde.error');
        }
    } else {
        $notification->push(_("Forum not deleted."), 'horde.message');
    }
    Horde::url('forums.php', true)->redirect();
}
$page_output->header();
$notification->notify(array('listeners' => 'status'));
$form->renderActive(null, $vars, Horde::url('deleteforum.php'), 'post');
$page_output->footer();
Exemple #29
0
 /**
  * Renders the edit form.
  */
 public function renderForm($form_script = 'edit.php')
 {
     $renderer = new Horde_Form_Renderer();
     $this->_form->renderActive($renderer, $this->_vars, $form_script, 'post');
 }
Exemple #30
0
                $groups[$client] = array('client' => $client, 'hours' => array($id));
            }
        }
    } else {
        foreach ($info['hours'] as $id) {
            $groups[] = array('client' => $hours[$id]['client'], 'hours' => array($id));
        }
    }
    foreach ($groups as $group) {
        $invoice = array();
        $invoice['client'] = array('id' => $group['client']);
        $invoice['invoice'] = array('type' => $conf['invoices']['params']['type'], 'status' => $conf['invoices']['params']['status'], 'expire' => $conf['invoices']['params']['expire'], 'place' => $conf['invoices']['params']['place'], 'service' => date('Y-m-d'));
        $invoice['articles'] = array();
        foreach ($group['hours'] as $hour) {
            $invoice['articles'][] = array('name' => $list[$hour]['description'], 'price' => $list[$hour]['rate'], 'qt' => $list[$hour]['hours'], 'discount' => 0);
        }
        try {
            $invoice_id = $registry->call('invoices/save', array($invoice));
            $msg = sprintf(_("Invoice for client %s successfuly created."), $clients[$group['client']]);
            $notification->push($msg, 'horde.success');
        } catch (Exception $e) {
            $notification->push($invoice_id->getMessage(), 'horde.error');
        }
    }
    Horde::url('time.php')->redirect();
}
$renderer = new Horde_Form_Renderer(array('varrenderer_driver' => 'tableset_html'));
$page_output->header(array('title' => $title));
$notification->notify(array('listeners' => 'status'));
$form->renderActive($renderer, null, Horde::url('invoicing.php'), 'post');
$page_output->footer();