1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
<?php
/**
* $Horde: horde/services/prefs.php,v 1.19.2.2 2005/01/03 12:25:45 jan Exp $
*
* Copyright 1999-2005 Charles J. Hagenbuch <chuck@horde.org>
* Copyright 1999-2005 Jon Parise <jon@horde.org>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*/
@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once dirname(__FILE__) . '/../lib/core.php';
require_once 'Horde/Prefs/UI.php';
$registry = &Registry::singleton();
/* Figure out which application we're setting preferences for. */
$app = Util::getFormData('app', Prefs_UI::getDefaultApp());
$appbase = $registry->get('fileroot', $app);
/* See if we have a preferences group set. */
$group = Util::getFormData('group');
/* Load $app's base environment. */
require_once $appbase . '/lib/base.php';
/* Set title. */
$title = sprintf(_("Options for %s"), $registry->get('name'));
if ($group == 'identities') {
require_once 'Horde/Identity.php';
$identity = &Identity::singleton($app == 'horde' ? null : array($app, $app));
if ($app != 'horde') {
require HORDE_BASE . '/config/prefs.php';
$horde_members = $prefGroups['identities']['members'];
unset($prefGroups);
}
}
/* Load $app's preferences, if any. */
if (file_exists($appbase . '/config/prefs.php')) {
require $appbase . '/config/prefs.php';
}
/* Load custom preference handlers for $app, if present. */
if (file_exists($appbase . '/lib/prefs.php')) {
require_once $appbase . '/lib/prefs.php';
}
if ($group == 'identities') {
if (isset($horde_members)) {
$prefGroups['identities']['members'] = array_merge($horde_members, $prefGroups['identities']['members']);
}
switch (Util::getFormData('actionID')) {
case 'update_prefs':
if ($prefs->isLocked('default_identity')) {
$default = $identity->getDefault();
} else {
$default = Util::getPost('default_identity');
$id = Util::getPost('identity');
if ($id == -1) {
$id = $identity->add();
} elseif ($id == -2) {
$prefGroups['identities']['members'] = array('default_identity');
}
$identity->setDefault($id);
}
if (Prefs_UI::handleForm($group, $identity)) {
$result = $identity->verify();
$identity->setDefault($default);
if (is_a($result, 'PEAR_Error')) {
$notification->push($result, 'horde.error');
} else {
$identity->save();
}
} else {
$identity->setDefault($default);
$identity->save();
}
unset($prefGroups);
require $appbase . '/config/prefs.php';
break;
case 'delete_identity':
$deleted_identity = $identity->delete(Util::getFormData('id'));
$notification->push(sprintf(_("The identity \"%s\" has been deleted."), $deleted_identity[0]['id']), 'horde.success');
break;
}
} elseif (Prefs_UI::handleForm($group, $prefs)) {
require $appbase . '/config/prefs.php';
}
/* Show the UI. */
Prefs_UI::generateUI($group);
require $registry->get('templates', 'horde') . '/common-footer.inc';
|