singleton() публичный Метод

public singleton ( $form, &$vars, $title = '', $name = null )
Пример #1
0
    return $out;
}
/* Set up VFS. */
require_once HORDE_LIBS . 'VFS.php';
$vfs_type = $conf['vfs']['type'];
$vfs_args = Horde::getDriverConfig('vfs', $vfs_type);
$vfs_args['user'] = Auth::getAuth();
$vfs =& VFS::singleton($vfs_type, $vfs_args);
@define('TEMPLATES_VFS_PATH', '.horde_templates');
/* Require Horde_Form libs. */
require_once HORDE_LIBS . 'Horde/Form.php';
require_once HORDE_LIBS . 'Horde/Form/Renderer.php';
require_once HORDE_LIBS . 'Horde/Form/Action.php';
/* Set up Horde_Form. */
$vars =& Variables::getDefaultVariables();
$form =& Horde_Form::singleton('TemplatesForm', $vars);
$action =& Horde_Form_Action::factory('submit');
/* Set up form fields. */
$apps = _setValuesToKeys($registry->listApps());
$select_app =& $form->addVariable(_("Application"), 'app', 'enum', true, false, null, array($apps));
$select_app->setAction($action);
$form->addHidden('', 'old_app', 'text', false, false);
/* Set up some variables. */
$formname = $vars->get('formname');
$app = $vars->get('app');
$old_app = $vars->get('old_app');
$template_path = $vars->get('template_path');
$template_orig = $vars->get('template_orig');
$old_template_orig = $vars->get('old_template_orig');
$has_changed = false;
if ($app != $old_app) {
Пример #2
0
        if (!is_a($result, 'PEAR_Error')) {
            $form = 'edit.inc';
        }
    }
} else {
    $permission =& $perms->getPermissionById($cid);
}
/* If the permission fetched is an error return to the permissions
 * list. */
if (is_a($permission, 'PEAR_Error')) {
    $notification->push(_("Attempt to edit a non-existent permission."), 'horde.error');
    $url = Horde::applicationUrl('admin/perms/index.php', true);
    header('Location: ' . $url);
    exit;
}
$form =& Horde_Form::singleton('', $vars);
$form->setButtons(_("Update"), true);
$form->addHidden('', 'cid', 'text', false);
/* Set up the columns for the permissions matrix. */
$cols = Perms::getPermsArray();
/* Default permissions. */
$perm_val = $permission->getDefaultPermissions();
/* Define a single matrix row for default perms. */
$matrix = array();
$matrix[0] = Perms::integerToArray($perm_val);
$form->setSection('default', Horde::img('perms.gif') . ' ' . _("Default Permissions"), false);
$form->addVariable(_("Default permissions"), 'default', 'matrix', false, false, null, array($cols, array(0 => ''), $matrix));
/* Guest permissions. */
$perm_val = $permission->getGuestPermissions();
/* Define a single matrix row for guest perms. */
$matrix = array();
Пример #3
0
@define('AUTH_HANDLER', true);
@define('HORDE_BASE', dirname(__FILE__));
require_once HORDE_BASE . '/lib/base.php';
require_once HORDE_LIBS . 'Horde/Auth/Signup.php';
require_once HORDE_LIBS . 'Horde/Variables.php';
// Make sure signups are enabled before proceeding
if ($conf['signup']['allow'] !== true) {
    $notification->push(_("User Registration has been disabled for this site."), 'horde.error');
    header('Location: ' . Auth::getLoginScreen());
    exit;
}
$auth =& Auth::singleton($conf['auth']['driver']);
$signup =& Auth_Signup::singleton();
$renderer =& new Horde_Form_Renderer();
$vars =& Variables::getDefaultVariables();
$formsignup =& Horde_Form::singleton('HordeSignupForm', $vars);
$formsignup->validate($vars);
if ($vars->get('formname') != 'hordesignupform') {
    /* Not yet submitted. */
    $formsignup->clearValidation();
}
if ($formsignup->isValid() && $vars->get('formname') == 'hordesignupform') {
    $formsignup->getInfo($vars, $info);
    if ($auth->hasCapability('add')) {
        if (!$conf['signup']['approve']) {
            /* User can sign up directly, no intervention necessary. */
            $success = $signup->addSignup($info);
            $success_message = sprintf(_("Added '%s' to the system. You can log in now."), $info['user_name']);
        } elseif ($conf['signup']['approve']) {
            /* Insert this user into a queue for admin approval. */
            $success = $signup->queueSignup($info);
Пример #4
0
        case 'activate':
            if ($admin) {
                $result = $nwndriver->useModule($moduleName, true);
                if (is_a($result, 'PEAR_Error')) {
                    $notification->push(_("Module load failure: ") . $result->getMessage(), 'horde.error');
                } else {
                    $notification->push(_("Module loaded."), 'horde.success');
                }
            }
            break;
    }
}
// form configuration
$vars =& Variables::getDefaultVariables();
$renderer =& new Horde_Form_Renderer();
$form =& Horde_Form::singleton('NewNWNModule', $vars);
$valid = $form->validate($vars);
if ($valid) {
    // get the information about the file
    $form->getInfo($vars, $info);
    if (!empty($info['module']['file'])) {
        // as long as it was uploaded and there is information
        if (!is_a(Browser::wasFileUploaded('module'), 'PEAR_Error') && filesize($info['module']['file'])) {
            // check the file for validity
            $extension = substr($info['module']['name'], -3);
            if ($extension == "mod" || $extension == "MOD") {
                $moduleOutputName = escapeshellcmd($moduleDir . $info['module']['name']);
                // do not overwrite files
                if (file_exists($moduleOutputName)) {
                    $notification->push(_("Cannot overwrite existing module!"), 'horde.error');
                } else {
Пример #5
0
$vars =& Variables::getDefaultVariables();
$actionId = Util::getFormData('actionId');
if (is_null($actionId)) {
    $settings =& $nwndriver->getParams();
    if (is_null($settings)) {
        $notification->push(_("There was a problem fetching the settings!"), 'horde.error');
    } elseif (!is_a($settings, 'PEAR_Error')) {
        foreach ($settings as $key => $val) {
            $vars->set($key, $val);
        }
    } else {
        $notification->push(_("There was a problem fetching the settings: ") . $settings->getMessage(), 'horde.error');
    }
}
$renderer =& new Horde_Form_Renderer();
$form =& Horde_Form::singleton('ServerSettings', $vars);
$valid = $form->validate($vars);
if ($valid) {
    $newSettings = array('servername' => Util::getFormData('servername'), 'port' => Util::getFormData('port'), 'playerpass' => Util::getFormData('playerpass'), 'dmpass' => Util::getFormData('dmpass'), 'maxclients' => Util::getFormData('maxclients'), 'minlevel' => Util::getFormData('minlevel'), 'maxlevel' => Util::getFormData('maxlevel'), 'pauseandplay' => Util::getFormData('pauseandplay'), 'pvp' => Util::getFormData('pvp'), 'servervault' => Util::getFormData('servervault'), 'elc' => Util::getFormData('elc'), 'ilr' => Util::getFormData('ilr'), 'gametype' => Util::getFormData('gametype'), 'oneparty' => Util::getFormData('oneparty'), 'difficulty' => Util::getFormData('difficulty'), 'autosaveinterval' => Util::getFormData('autosaveinterval'), 'reloadwhenempty' => Util::getFormData('reloadwhenempty'), 'publicserver' => Util::getFormData('publicserver'));
    $result = $nwndriver->setData($newSettings);
    if (is_a($result, 'PEAR_Error')) {
        $notification->push(_("Error while saving parameters: ") . $result->getMessage(), 'horde.error');
    } else {
        $notification->push(_("Successfully saved the settings."), 'horde.success');
    }
    if ($nwndriver->serverRunning()) {
        $result = null;
        foreach ($newSettings as $key => $val) {
            $result = $nwndriver->sendCommand($key . ' ' . $val);
            if (is_a($result, 'PEAR_Error')) {
                $notification->push(_("There was a problem loading the settings: ") . $result->getMessage(), 'horde.error');