From 46c956a4fd2a72c4f9457e09ad7a2c8615f9b6b4 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 7 Apr 2010 07:33:58 -0600 Subject: [PATCH] Convert mnemo to new preferences UI --- mnemo/config/prefs.php.dist | 59 ++++++++++----------------------- mnemo/lib/Application.php | 32 +++++++++++++++--- mnemo/templates/prefs/notepadselect.inc | 16 --------- 3 files changed, 45 insertions(+), 62 deletions(-) delete mode 100644 mnemo/templates/prefs/notepadselect.inc diff --git a/mnemo/config/prefs.php.dist b/mnemo/config/prefs.php.dist index ddeb1c2f0..b1b37c326 100644 --- a/mnemo/config/prefs.php.dist +++ b/mnemo/config/prefs.php.dist @@ -1,13 +1,10 @@ _("General Options"), 'label' => _("Display Options"), @@ -19,7 +16,7 @@ $prefGroups['share'] = array( 'column' => _("General Options"), 'label' => _("Default Notepad"), 'desc' => _("Choose your default Notepad."), - 'members' => array('notepadselect') + 'members' => array('default_notepad') ); $prefGroups['deletion'] = array( @@ -33,8 +30,6 @@ $prefGroups['deletion'] = array( // show a notepad column in the list view? $_prefs['show_notepad'] = array( 'value' => 0, - 'locked' => false, - 'shared' => false, 'type' => 'checkbox', 'desc' => _("Should the Notepad be shown in its own column in the List view?") ); @@ -42,76 +37,58 @@ $_prefs['show_notepad'] = array( // show the notepad options panel? // a value of 0 = no, 1 = yes $_prefs['show_panel'] = array( - 'value' => 1, - 'locked' => false, - 'shared' => false, - 'type' => 'implicit', + 'value' => 1 ); // user preferred sorting column $_prefs['sortby'] = array( 'value' => MNEMO_SORT_DESC, - 'locked' => false, - 'shared' => false, 'type' => 'enum', - 'enum' => array(MNEMO_SORT_DESC => _("Note Text"), - MNEMO_SORT_CATEGORY => _("Note Category"), - MNEMO_SORT_NOTEPAD => _("Notepad")), + 'enum' => array( + MNEMO_SORT_DESC => _("Note Text"), + MNEMO_SORT_CATEGORY => _("Note Category"), + MNEMO_SORT_NOTEPAD => _("Notepad") + ), 'desc' => _("Default sorting criteria:") ); // user preferred sorting direction $_prefs['sortdir'] = array( 'value' => 0, - 'locked' => false, - 'shared' => false, 'type' => 'enum', - 'enum' => array(MNEMO_SORT_ASCEND => _("Ascending"), - MNEMO_SORT_DESCEND => _("Descending")), + 'enum' => array( + MNEMO_SORT_ASCEND => _("Ascending"), + MNEMO_SORT_DESCEND => _("Descending") + ), 'desc' => _("Default sorting direction:") ); // user note categories $_prefs['memo_categories'] = array( - 'value' => '', - 'locked' => false, - 'shared' => false, - 'type' => 'implicit' + 'value' => '' ); // category highlight colors $_prefs['memo_colors'] = array( - 'value' => '', - 'locked' => false, - 'shared' => false, - 'type' => 'implicit' + 'value' => '' ); -// default notepad selection widget -$_prefs['notepadselect'] = array('type' => 'special'); - // default notepad // Set locked to true if you don't want users to have multiple notepads. $_prefs['default_notepad'] = array( 'value' => Horde_Auth::getAuth() ? Horde_Auth::getAuth() : 0, - 'locked' => false, - 'shared' => false, - 'type' => 'implicit' + 'type' => 'enum', + 'desc' => _("Your default notepad:") ); // store the notepads to diplay $_prefs['display_notepads'] = array( - 'value' => 'a:0:{}', - 'locked' => false, - 'shared' => false, - 'type' => 'implicit' + 'value' => 'a:0:{}' ); // preference for delete confirmation dialog. $_prefs['delete_opt'] = array( 'value' => 1, - 'locked' => false, - 'shared' => false, 'type' => 'checkbox', 'desc' => _("Do you want to confirm deleting entries?") ); diff --git a/mnemo/lib/Application.php b/mnemo/lib/Application.php index 6378663af..3633cbc44 100644 --- a/mnemo/lib/Application.php +++ b/mnemo/lib/Application.php @@ -40,10 +40,10 @@ class Mnemo_Application extends Horde_Registry_Application * @var string */ public $version = 'H4 (3.0-git)'; - + /** * Initialization function. - * + * * Global variables defined: * $mnemo_shares - TODO */ @@ -51,13 +51,35 @@ class Mnemo_Application extends Horde_Registry_Application { // Set the timezone variable. Horde_Nls::setTimeZone(); - + // Create a share instance. $GLOBALS['mnemo_shares'] = Horde_Share::singleton($GLOBALS['registry']->getApp()); - + Mnemo::initialize(); } - + + /** + * Code to run on init when viewing prefs for this application. + * + * @param Horde_Core_Prefs_Ui $ui The UI object. + */ + public function prefsInit($ui) + { + global $conf, $prefs, $registry; + + switch ($ui->group) { + case 'share': + if (!$prefs->isLocked('default_notepad')) { + $notepads = array(); + foreach (Mnemo::listNotepads() as $key => $val) { + $notepads[htmlspecialchars($key)] = htmlspecialchars($val->get('name')); + } + $ui->override['default_tasklist'] = $notepads; + } + break; + } + } + /** * Generate the menu to use on the prefs page. * diff --git a/mnemo/templates/prefs/notepadselect.inc b/mnemo/templates/prefs/notepadselect.inc deleted file mode 100644 index 1c6e64bdb..000000000 --- a/mnemo/templates/prefs/notepadselect.inc +++ /dev/null @@ -1,16 +0,0 @@ -isLocked('default_notepad')): - $notepads = Mnemo::listNotepads(); - if (($default_notepad = $prefs->getValue('default_notepad')) == null || - !isset($notepads[$default_notepad])) { - $default_notepad = Horde_Auth::getAuth(); - } -?> - -
-

- -- 2.11.0